feat: embed pdf
This commit is contained in:
@@ -23,8 +23,8 @@
|
|||||||
"column_break_15",
|
"column_break_15",
|
||||||
"file_type",
|
"file_type",
|
||||||
"section_break_11",
|
"section_break_11",
|
||||||
"instructor_notes",
|
|
||||||
"body",
|
"body",
|
||||||
|
"instructor_notes",
|
||||||
"help_section",
|
"help_section",
|
||||||
"help"
|
"help"
|
||||||
],
|
],
|
||||||
@@ -135,13 +135,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "instructor_notes",
|
"fieldname": "instructor_notes",
|
||||||
"fieldtype": "Text Editor",
|
"fieldtype": "Text",
|
||||||
"label": "Instructor Notes"
|
"label": "Instructor Notes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-08-31 11:11:22.034553",
|
"modified": "2023-08-31 21:47:06.314995",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "Course Lesson",
|
"name": "Course Lesson",
|
||||||
|
|||||||
@@ -147,6 +147,8 @@ def get_lesson_details(chapter):
|
|||||||
)
|
)
|
||||||
lesson_details.number = flt(f"{chapter.idx}.{row.idx}")
|
lesson_details.number = flt(f"{chapter.idx}.{row.idx}")
|
||||||
lesson_details.icon = get_lesson_icon(lesson_details.body)
|
lesson_details.icon = get_lesson_icon(lesson_details.body)
|
||||||
|
if lesson_details.instructor_notes:
|
||||||
|
lesson_details.instructor_notes = markdown_to_html(lesson_details.instructor_notes)
|
||||||
|
|
||||||
lessons.append(lesson_details)
|
lessons.append(lesson_details)
|
||||||
return lessons
|
return lessons
|
||||||
@@ -311,7 +313,6 @@ def render_html(lesson):
|
|||||||
if lesson.question:
|
if lesson.question:
|
||||||
assignment = "{{ Assignment('" + lesson.question + "-" + lesson.file_type + "') }}"
|
assignment = "{{ Assignment('" + lesson.question + "-" + lesson.file_type + "') }}"
|
||||||
text = text + assignment
|
text = text + assignment
|
||||||
|
|
||||||
return markdown_to_html(text)
|
return markdown_to_html(text)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -156,9 +156,17 @@ def youtube_video_renderer(video_id):
|
|||||||
|
|
||||||
|
|
||||||
def embed_renderer(details):
|
def embed_renderer(details):
|
||||||
|
type = details.split("|||")[0]
|
||||||
src = details.split("|||")[1]
|
src = details.split("|||")[1]
|
||||||
|
width = "100%"
|
||||||
|
height = "400"
|
||||||
|
|
||||||
|
if type == "pdf":
|
||||||
|
width = "75%"
|
||||||
|
height = "600"
|
||||||
|
|
||||||
return f"""
|
return f"""
|
||||||
<iframe width="100%" height="400"
|
<iframe width={width} height={height}
|
||||||
src={src}
|
src={src}
|
||||||
title="Embedded Content"
|
title="Embedded Content"
|
||||||
frameborder="0"
|
frameborder="0"
|
||||||
@@ -175,20 +183,21 @@ def video_renderer(src):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def assignment_renderer(detail):
|
def assignment_renderer(name):
|
||||||
supported_types = {
|
|
||||||
"Document": ".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
"""supported_types = {
|
||||||
"PDF": ".pdf",
|
"Document": ".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
"Image": ".png, .jpg, .jpeg",
|
"PDF": ".pdf",
|
||||||
"Video": "video/*",
|
"Image": ".png, .jpg, .jpeg",
|
||||||
|
"Video": "video/*",
|
||||||
}
|
}
|
||||||
question = detail.split("-")[0]
|
question = detail.split("-")[0]
|
||||||
file_type = detail.split("-")[1]
|
file_type = detail.split("-")[1]
|
||||||
accept = supported_types[file_type] if file_type else ""
|
accept = supported_types[file_type] if file_type else ""
|
||||||
return frappe.render_template(
|
return frappe.render_template(
|
||||||
"templates/assignment.html",
|
"templates/assignment.html",
|
||||||
{"question": question, "accept": accept, "file_type": file_type},
|
{"question": question, "accept": accept, "file_type": file_type},
|
||||||
)
|
)"""
|
||||||
|
|
||||||
|
|
||||||
def show_custom_signup():
|
def show_custom_signup():
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ const setup_editor = () => {
|
|||||||
"https://docs.google.com/presentation/d/e/<%= remote_id %>/embed",
|
"https://docs.google.com/presentation/d/e/<%= remote_id %>/embed",
|
||||||
html: "<iframe width='100%' height='300' frameborder='0' allowfullscreen='true'></iframe>",
|
html: "<iframe width='100%' height='300' frameborder='0' allowfullscreen='true'></iframe>",
|
||||||
},
|
},
|
||||||
|
pdf: {
|
||||||
|
regex: /(https?:\/\/.*\.pdf)/,
|
||||||
|
embedUrl: "<%= remote_id %>",
|
||||||
|
html: "<iframe width='100%' height='600px' frameborder='0'></iframe>",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -165,6 +170,11 @@ const parse_lesson_to_string = (data) => {
|
|||||||
} else if (block.type == "paragraph") {
|
} else if (block.type == "paragraph") {
|
||||||
lesson_content += `${block.data.text}\n`;
|
lesson_content += `${block.data.text}\n`;
|
||||||
} else if (block.type == "embed") {
|
} else if (block.type == "embed") {
|
||||||
|
if (block.data.service == "pdf") {
|
||||||
|
if (!block.data.embed.startsWith(window.location.origin)) {
|
||||||
|
frappe.throw(__("Invalid PDF URL"));
|
||||||
|
}
|
||||||
|
}
|
||||||
lesson_content += `{{ Embed("${
|
lesson_content += `{{ Embed("${
|
||||||
block.data.service
|
block.data.service
|
||||||
}|||${block.data.embed.replace(/&/g, "&")}") }}\n`;
|
}|||${block.data.embed.replace(/&/g, "&")}") }}\n`;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@
|
|||||||
|
|
||||||
{% if lesson.instructor_notes and (is_moderator or instructor or is_evaluator) %}
|
{% if lesson.instructor_notes and (is_moderator or instructor or is_evaluator) %}
|
||||||
<div class="alert alert-info mb-4">
|
<div class="alert alert-info mb-4">
|
||||||
<div class="bold-heading">
|
<div class="bold-heading mb-2">
|
||||||
{{ _("Instructor Notes") }}
|
{{ _("Instructor Notes") }}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user