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