diff --git a/lms/lms/doctype/course_lesson/course_lesson.json b/lms/lms/doctype/course_lesson/course_lesson.json index 66798e15..eaee75f2 100644 --- a/lms/lms/doctype/course_lesson/course_lesson.json +++ b/lms/lms/doctype/course_lesson/course_lesson.json @@ -66,7 +66,7 @@ }, { "fieldname": "body", - "fieldtype": "Text Editor", + "fieldtype": "Markdown Editor", "ignore_xss_filter": 1, "label": "Body", "reqd": 1 @@ -135,7 +135,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-04-05 12:42:16.926753", + "modified": "2023-05-02 12:42:16.926753", "modified_by": "Administrator", "module": "LMS", "name": "Course Lesson", diff --git a/lms/lms/doctype/lms_course/lms_course.json b/lms/lms/doctype/lms_course/lms_course.json index 839cf40a..beac3d4e 100644 --- a/lms/lms/doctype/lms_course/lms_course.json +++ b/lms/lms/doctype/lms_course/lms_course.json @@ -57,7 +57,7 @@ }, { "fieldname": "description", - "fieldtype": "Text Editor", + "fieldtype": "Markdown Editor", "label": "Description", "reqd": 1 }, @@ -260,7 +260,7 @@ } ], "make_attachments_public": 1, - "modified": "2023-02-23 09:45:54.826328", + "modified": "2023-05-02 09:45:54.826328", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/lms/patches.txt b/lms/patches.txt index 067812a9..3fe84429 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -50,7 +50,6 @@ lms.patches.v0_0.video_embed_link lms.patches.v0_0.rename_exercise_doctype lms.patches.v0_0.add_question_type #09-04-2023 lms.patches.v0_0.add_evaluator_to_assignment #09-04-2023 -lms.patches.v0_0.convert_lesson_markdown_to_html #05-04-2023 -lms.patches.v0_0.convert_course_description_to_html lms.patches.v0_0.share_certificates execute:frappe.delete_doc("Web Form", "class", ignore_missing=True, force=True) +lms.patches.v0_0.amend_course_and_lesson_editor_fields diff --git a/lms/patches/v0_0/amend_course_and_lesson_editor_fields.py b/lms/patches/v0_0/amend_course_and_lesson_editor_fields.py new file mode 100644 index 00000000..aa40a4a1 --- /dev/null +++ b/lms/patches/v0_0/amend_course_and_lesson_editor_fields.py @@ -0,0 +1,37 @@ +import frappe +from frappe.utils import to_markdown + + +def execute(): + amend_lesson_content() + amend_course_description() + + +def amend_lesson_content(): + lesson_content_field = frappe.db.get_value( + "DocField", {"parent": "Course Lesson", "fieldname": "body"}, "fieldtype" + ) + + if lesson_content_field == "Text Editor": + lessons = frappe.get_all("Course Lesson", fields=["name", "body"]) + + for lesson in lessons: + frappe.db.set_value("Course Lesson", lesson.name, "body", to_markdown(lesson.body)) + + frappe.reload_doc("lms", "doctype", "course_lesson") + + +def amend_course_description(): + course_description_field = frappe.db.get_value( + "DocField", {"parent": "LMS Course", "fieldname": "description"}, "fieldtype" + ) + + if course_description_field == "Text Editor": + courses = frappe.get_all("LMS Course", fields=["name", "description"]) + + for course in courses: + frappe.db.set_value( + "LMS Course", course.name, "description", to_markdown(course.description) + ) + + frappe.reload_doc("lms", "doctype", "lms_course")