fix: web form description and redirection
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
"field_order": [
|
||||
"chapter",
|
||||
"course",
|
||||
"include_in_preview",
|
||||
"column_break_4",
|
||||
"title",
|
||||
"include_in_preview",
|
||||
"index_label",
|
||||
"section_break_6",
|
||||
"body",
|
||||
@@ -75,7 +75,6 @@
|
||||
"fetch_from": "chapter.course",
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 1,
|
||||
"label": "Course",
|
||||
"options": "LMS Course",
|
||||
"read_only": 1
|
||||
@@ -83,7 +82,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-03-14 18:56:31.969801",
|
||||
"modified": "2022-04-22 12:59:23.641915",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Course Lesson",
|
||||
|
||||
@@ -25,7 +25,6 @@ import html as HTML
|
||||
def markdown_to_html(text):
|
||||
"""Renders markdown text into html.
|
||||
"""
|
||||
print(text)
|
||||
return markdown.markdown(text, extensions=['fenced_code', MacroExtension()])
|
||||
|
||||
def find_macros(text):
|
||||
@@ -106,7 +105,7 @@ def sanitize_html(html, macro):
|
||||
any broken tags. This makes sures that all those things are fixed
|
||||
before passing to the etree parser.
|
||||
"""
|
||||
soup = BeautifulSoup(html, features="html5lib")
|
||||
soup = BeautifulSoup(html, features="lxml")
|
||||
nodes = soup.body.children
|
||||
classname = ""
|
||||
if macro == "YouTubeVideo":
|
||||
|
||||
@@ -2,10 +2,11 @@ frappe.ready(function() {
|
||||
|
||||
frappe.web_form.after_load = () => {
|
||||
add_file_upload_component();
|
||||
fetch_course();
|
||||
};
|
||||
|
||||
frappe.web_form.after_save = () => {
|
||||
show_success_message();
|
||||
show_success_message();
|
||||
};
|
||||
|
||||
$(document).on("click", ".add-attachment", (e) => {
|
||||
@@ -14,10 +15,23 @@ frappe.ready(function() {
|
||||
|
||||
$(document).on("click", ".copy-link", (e) => {
|
||||
frappe.utils.copy_to_clipboard($(e.currentTarget).data("link"));
|
||||
$(".attachments").collapse("hide");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
const fetch_course = () => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.course_lesson.course_lesson.get_lesson_info",
|
||||
args: {
|
||||
"chapter": frappe.web_form.doc.chapter
|
||||
},
|
||||
callback: (data) => {
|
||||
this.course = data.message;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const show_upload_modal = () => {
|
||||
new frappe.ui.FileUploader({
|
||||
folder: "Home/Attachments",
|
||||
@@ -35,18 +49,10 @@ const show_upload_modal = () => {
|
||||
};
|
||||
|
||||
const show_success_message = () => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.course_lesson.course_lesson.get_lesson_info",
|
||||
args: {
|
||||
"chapter": frappe.web_form.doc.chapter
|
||||
},
|
||||
callback: (data) => {
|
||||
frappe.msgprint(__(`Lesson has been saved successfully. Go back to the chapter and add this lesson to the lessons table.`));
|
||||
setTimeout(() => {
|
||||
window.location.href = `/courses/${data.message}`;
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
frappe.msgprint(__(`Lesson has been saved successfully. Go back to the chapter and add this lesson to the lessons table.`));
|
||||
setTimeout(() => {
|
||||
window.location.href = `/courses/${this.course}`;
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
const add_file_upload_component = () => {
|
||||
@@ -68,7 +74,7 @@ const get_attachment_controls_html = () => {
|
||||
<svg class="icon icon-sm">
|
||||
<use class="" href="#icon-upload">
|
||||
</svg>
|
||||
{{ _("Upload Image") }}
|
||||
{{ _("Upload Attachments") }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
"apply_document_permissions": 1,
|
||||
"button_label": "Save",
|
||||
"creation": "2022-03-07 18:41:42.549831",
|
||||
"custom_css": "",
|
||||
"custom_css": "#introduction {\n font-size: var(--text-base);\n}",
|
||||
"doc_type": "Course Lesson",
|
||||
"docstatus": 0,
|
||||
"doctype": "Web Form",
|
||||
"idx": 0,
|
||||
"introduction_text": "<div class=\"ql-editor read-mode\"><p><br></p><p><br></p><p>Create lessons for your course. For adding content, use markdown syntax. You can add some additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.</p><p><br></p><table class=\"table table-bordered\"><tbody><tr><td data-row=\"row-wxk1\"><strong>Content Type</strong></td><td data-row=\"row-wxk1\"><strong>Syntax</strong></td></tr><tr><td data-row=\"row-lawj\">Video</td><td data-row=\"row-lawj\">{{ Video(\"url_of_source\") }}</td></tr><tr><td data-row=\"insert-table\">YouTube Video</td><td data-row=\"insert-table\">{{ YouTubeVideo(\"unique_embed_id\") }}</td></tr><tr><td data-row=\"insert-row-below\">Exercise</td><td data-row=\"insert-row-below\">{{ Exercise(\"exercise_name\") }}</td></tr><tr><td data-row=\"row-3b6n\">Quiz</td><td data-row=\"row-3b6n\">{{ Quiz(\"lms_quiz_name\") }}</td></tr><tr><td data-row=\"row-r57s\">Assignment</td><td data-row=\"row-r57s\">{{ Assignment(\"id-filetype\") }}</td></tr></tbody></table></div>",
|
||||
"introduction_text": "<div class=\"ql-editor read-mode\">\n <p>Create lessons for your course. For adding content, use markdown syntax. You can add some additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.</p>\n <table class=\"table table-bordered\">\n <tbody>\n <tr>\n <td data-row=\"row-wxk1\">\n <strong>Content Type</strong>\n </td>\n <td data-row=\"row-wxk1\">\n <strong> Syntax </strong>\n </td>\n </tr>\n <tr>\n <td data-row=\"row-r57s\"> Assignment </td>\n <td data-row=\"row-r57s\">{{ Assignment(\"id-filetype\") }}</td>\n </tr>\n <tr>\n <td data-row=\"row-3b6n\"> Quiz </td>\n <td data-row=\"row-3b6n\">{{ Quiz(\"lms_quiz_name\") }}</td>\n </tr>\n <tr>\n <td data-row=\"insert-table\"> YouTube Video </td>\n <td data-row=\"insert-table\">{{ YouTubeVideo(\"unique_embed_id\") }}</td>\n </tr>\n </tbody>\n </table>\n <p> <b> Note: </b> You can also attach videos from Vimeo by including the iframe embed of the video to the lesson. </p>\n</div>",
|
||||
"is_multi_step_form": 0,
|
||||
"is_standard": 1,
|
||||
"login_required": 1,
|
||||
"max_attachment_size": 0,
|
||||
"modified": "2022-04-20 15:45:55.567759",
|
||||
"modified": "2022-04-25 10:26:12.691050",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "lesson",
|
||||
@@ -34,7 +34,7 @@
|
||||
"show_in_grid": 0,
|
||||
"show_sidebar": 0,
|
||||
"sidebar_items": [],
|
||||
"success_url": "/lesson",
|
||||
"success_url": "",
|
||||
"title": "Lesson",
|
||||
"web_form_fields": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user