Skip to content

Commit

Permalink
fix: handle html files during scorm page render
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Dec 6, 2024
1 parent c1fdddb commit 6f73be9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
2 changes: 0 additions & 2 deletions lms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@
"PDF": "lms.plugins.pdf_renderer",
}

website_path_resolver = "lms.lms.api.resolve_scorm_path"

# page_renderer to manage profile pages
page_renderer = [
"lms.page_renderers.ProfileRedirectPage",
Expand Down
11 changes: 0 additions & 11 deletions lms/lms/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from typing import Optional
from lms.lms.utils import get_average_rating, get_lesson_count
from xml.dom.minidom import parseString
from frappe.website.path_resolver import resolve_path as original_resolve_path


@frappe.whitelist()
Expand Down Expand Up @@ -1030,13 +1029,3 @@ def delete_scorm_package(scorm_package_path):
scorm_package_path = frappe.get_site_path("public", scorm_package_path[1:])
if os.path.exists(scorm_package_path):
shutil.rmtree(scorm_package_path)


def resolve_scorm_path(path):
try:
if "scorm/" in path and path.endswith(".html"):
return path
except Exception:
pass

return original_resolve_path(path)
5 changes: 5 additions & 0 deletions lms/page_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ def can_render(self):

def render(self):
path = os.path.join(frappe.local.site_path, "public", self.path.lstrip("/"))

extension = os.path.splitext(path)[1]
if not extension:
path = f"{path}.html"

f = open(path, "rb")
response = Response(
wrap_file(frappe.local.request.environ, f), direct_passthrough=True
Expand Down

0 comments on commit 6f73be9

Please sign in to comment.