Merge pull request #1170 from pateljannat/scorm-page-renderer
fix: handle html files during scorm page render
This commit is contained in:
@@ -220,8 +220,6 @@ lms_markdown_macro_renderers = {
|
||||
"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",
|
||||
|
||||
@@ -17,7 +17,6 @@ from frappe.utils import time_diff, now_datetime, get_datetime, flt
|
||||
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()
|
||||
@@ -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)
|
||||
|
||||
@@ -149,6 +149,11 @@ class SCORMRenderer(BaseRenderer):
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user