diff --git a/school/lms/utils.py b/school/lms/utils.py index cf0fd163..4df6f045 100644 --- a/school/lms/utils.py +++ b/school/lms/utils.py @@ -1,7 +1,7 @@ import re import frappe from frappe.utils import flt, cint, cstr -from school.lms.md import markdown_to_html +from school.lms.md import markdown_to_html, find_macros import string from frappe import _ @@ -85,6 +85,13 @@ def get_lesson_details(chapter): lesson_details = frappe.db.get_value("Course Lesson", row.lesson, ["name", "title", "include_in_preview", "body", "creation"], as_dict=True) lesson_details.number = flt("{}.{}".format(chapter.idx, row.idx)) + lesson_details.icon = "icon-list" + macros = find_macros(lesson_details.body) + for macro in macros: + if macro[0] == "YouTubeVideo": + lesson_details.icon = "icon-video" + elif macro[0] == "Quiz": + lesson_details.icon = "icon-quiz" lessons.append(lesson_details) return lessons diff --git a/school/lms/web_form/chapter/chapter.js b/school/lms/web_form/chapter/chapter.js index 5315afbf..6d710013 100644 --- a/school/lms/web_form/chapter/chapter.js +++ b/school/lms/web_form/chapter/chapter.js @@ -1,5 +1,8 @@ frappe.ready(function() { - frappe.web_form.after_save = () => { - window.location.href = `/courses/${frappe.web_form.doc.course}`; + frappe.web_form.after_save = () => { + frappe.msgprint(__("Chapter has been saved successfully. Go back to the course and add this chapter to the chapters table.")) + setTimeout(() => { + window.location.href = `/courses/${frappe.web_form.doc.course}`; + }, 3000); } }); diff --git a/school/lms/web_form/lesson/lesson.js b/school/lms/web_form/lesson/lesson.js index bf3a24c8..0044ba2d 100644 --- a/school/lms/web_form/lesson/lesson.js +++ b/school/lms/web_form/lesson/lesson.js @@ -1,15 +1,16 @@ frappe.ready(function() { frappe.web_form.after_save = () => { - setTimeout(() => { frappe.call({ method: "school.lms.doctype.course_lesson.course_lesson.get_lesson_info", args: { "chapter": frappe.web_form.doc.chapter }, callback: (data) => { - window.location.href = `/courses/${data.message}`; + 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); } - }); }); }; }); diff --git a/school/lms/widgets/CourseCard.html b/school/lms/widgets/CourseCard.html index 437d54ab..fb7fae59 100644 --- a/school/lms/widgets/CourseCard.html +++ b/school/lms/widgets/CourseCard.html @@ -17,11 +17,41 @@