Skip to content
This repository has been archived by the owner on Sep 20, 2022. It is now read-only.

Frontend paths and lms_version in request #2

Merged
merged 5 commits into from
Aug 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions formgradernext/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
from notebook.notebookapp import NotebookApp
from notebook.utils import url_path_join as ujoin

lms_version = os.environ.get("LMS_VERSION") or "0.1.0"
DEFAULT_LMS_VERSION = os.environ.get("DEFAULT_LMS_VERSION") or "0.1.0"

template_response = requests.get(
f"https://content.illumidesk.com/lms/{lms_version}/index.html"
)
template_html = template_response.text.replace(
"</head>", '<script>var base_url = "{{ base_url }}";</script></head>'
)

def get_template(version):
template_response = requests.get(
f"https://content.illumidesk.com/lms/{version}/index.html"
)
return template_response.text.replace(
"</head>", '<script>var base_url = "{{ base_url }}";</script></head>'
)

class LMSHandler(BaseHandler):
@web.authenticated
Expand All @@ -31,7 +32,7 @@ class LMSHandler(BaseHandler):
def get(self):
html = (
Environment(loader=BaseLoader)
.from_string(template_html)
.from_string(get_template(self.get_query_argument("lms_version", DEFAULT_LMS_VERSION)))
.render(
url_prefix=self.url_prefix,
base_url=self.base_url,
Expand All @@ -46,6 +47,9 @@ def get(self):

handlers = [
(r"/formgradernext/?", LMSHandler),
(r"/formgradernext/manage-assignments/?", LMSHandler),
(r"/formgradernext/manage-students/?", LMSHandler),
(r"/formgradernext/manual-grading/?", LMSHandler),
rupeshparab marked this conversation as resolved.
Show resolved Hide resolved
]


Expand Down