Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle html files during scorm page render #1170

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading