From c6d399438385f26385539d6c7b4553891a282640 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Fri, 20 Aug 2021 14:23:18 +0530 Subject: [PATCH] fix: course page --- community/lms/doctype/chapter/chapter.json | 14 ++++++- .../lms/doctype/lms_course/lms_course.js | 9 +++++ .../lms/doctype/lms_course/lms_course.json | 37 ++++++++++--------- .../lms/doctype/lms_course/lms_course.py | 2 + community/patches.txt | 1 + .../patches/v0_0/course_instructor_update.py | 7 ++++ community/www/courses/certificate.py | 4 +- community/www/courses/course.html | 2 +- community/www/discussions/__init__.py | 0 9 files changed, 54 insertions(+), 22 deletions(-) create mode 100644 community/patches/v0_0/course_instructor_update.py create mode 100644 community/www/discussions/__init__.py diff --git a/community/lms/doctype/chapter/chapter.json b/community/lms/doctype/chapter/chapter.json index ca5b3fa5..36ab38f5 100644 --- a/community/lms/doctype/chapter/chapter.json +++ b/community/lms/doctype/chapter/chapter.json @@ -8,7 +8,9 @@ "field_order": [ "course", "title", + "column_break_3", "description", + "section_break_5", "lessons" ], "fields": [ @@ -20,7 +22,7 @@ }, { "fieldname": "description", - "fieldtype": "Markdown Editor", + "fieldtype": "Small Text", "label": "Description" }, { @@ -35,6 +37,14 @@ "fieldtype": "Table", "label": "Lessons", "options": "Lessons" + }, + { + "fieldname": "column_break_3", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_5", + "fieldtype": "Section Break" } ], "index_web_pages_for_search": 1, @@ -45,7 +55,7 @@ "link_fieldname": "chapter" } ], - "modified": "2021-07-27 16:28:08.667964", + "modified": "2021-08-19 13:43:51.025072", "modified_by": "Administrator", "module": "LMS", "name": "Chapter", diff --git a/community/lms/doctype/lms_course/lms_course.js b/community/lms/doctype/lms_course/lms_course.js index 3bcaaaab..d40f641e 100644 --- a/community/lms/doctype/lms_course/lms_course.js +++ b/community/lms/doctype/lms_course/lms_course.js @@ -4,6 +4,7 @@ frappe.ui.form.on('LMS Course', { onload: function (frm) { + frm.set_query("chapter", "chapters", function () { return { filters: { @@ -11,6 +12,14 @@ frappe.ui.form.on('LMS Course', { } }; }); + + frm.set_query("instructor", function (doc) { + return { + filters: { + "ignore_user_type": 1, + } + }; + }); } }); diff --git a/community/lms/doctype/lms_course/lms_course.json b/community/lms/doctype/lms_course/lms_course.json index 81f00238..82463ede 100644 --- a/community/lms/doctype/lms_course/lms_course.json +++ b/community/lms/doctype/lms_course/lms_course.json @@ -18,17 +18,18 @@ "video_link", "image", "column_break_3", + "instructor", "tags", + "section_break_7", "is_published", + "column_break_9", "upcoming", + "column_break_11", "disable_self_learning", "section_break_5", "short_introduction", "description", - "chapters", - "certification_section", - "enable_certification", - "expiry" + "chapters" ], "fields": [ { @@ -99,23 +100,25 @@ "options": "Chapters" }, { - "fieldname": "certification_section", + "fieldname": "instructor", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Instructor", + "options": "User" + }, + { + "fieldname": "section_break_7", "fieldtype": "Section Break", - "label": "Certification" + "label": "Course Settings" }, { - "default": "0", - "fieldname": "enable_certification", - "fieldtype": "Check", - "label": "Enable Certification" + "fieldname": "column_break_9", + "fieldtype": "Column Break" }, { - "default": "0", - "depends_on": "enable_certification", - "fieldname": "expiry", - "fieldtype": "Select", - "label": "Certification Expires After Years", - "options": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10" + "fieldname": "column_break_11", + "fieldtype": "Column Break" } ], "index_web_pages_for_search": 1, @@ -137,7 +140,7 @@ "link_fieldname": "course" } ], - "modified": "2021-08-18 18:02:12.623807", + "modified": "2021-08-20 11:01:15.795219", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course", diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index 126f6504..babbe45b 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -144,6 +144,8 @@ class LMSCourse(Document): return batch_name and frappe.get_doc("LMS Batch", batch_name) def get_instructor(self): + if self.instructor: + return frappe.get_doc("User", self.instructor) return frappe.get_doc("User", self.owner) def get_chapters(self): diff --git a/community/patches.txt b/community/patches.txt index 36d99e94..86c39f41 100644 --- a/community/patches.txt +++ b/community/patches.txt @@ -8,3 +8,4 @@ community.patches.replace_member_with_user_in_lms_message community.patches.replace_member_with_user_in_mentor_request community.patches.v0_0.chapter_lesson_index_table execute:frappe.delete_doc("DocType", "LMS Message") +community.patches.v0_0.course_instructor_update diff --git a/community/patches/v0_0/course_instructor_update.py b/community/patches/v0_0/course_instructor_update.py new file mode 100644 index 00000000..f8fd6019 --- /dev/null +++ b/community/patches/v0_0/course_instructor_update.py @@ -0,0 +1,7 @@ +import frappe + +def execute(): + frappe.reload_doc("lms", "doctype", "lms_course") + courses = frappe.get_all("LMS Course", fields=["name", "owner"]) + for course in courses: + frappe.db.set_value("LMS Course", course.name, "instructor", course.owner) diff --git a/community/www/courses/certificate.py b/community/www/courses/certificate.py index d734989f..aae2ba10 100644 --- a/community/www/courses/certificate.py +++ b/community/www/courses/certificate.py @@ -16,9 +16,9 @@ def get_context(context): redirect_to_course_list() context.course = frappe.db.get_value("LMS Course", course_name, - ["owner", "title", "name"], as_dict=True) + ["instructor", "title", "name"], as_dict=True) - context.instructor = frappe.db.get_value("User", context.course.owner, + context.instructor = frappe.db.get_value("User", context.course.instructor, ["full_name", "username"], as_dict=True) context.student = frappe.db.get_value("User", context.certificate.student, diff --git a/community/www/courses/course.html b/community/www/courses/course.html index a7437e5f..da0a9eae 100644 --- a/community/www/courses/course.html +++ b/community/www/courses/course.html @@ -43,7 +43,7 @@
- {% if not course.disable_self_learning and not membership %} + {% if not course.disable_self_learning and not membership and not course.upcoming %}
Start Learning diff --git a/community/www/discussions/__init__.py b/community/www/discussions/__init__.py new file mode 100644 index 00000000..e69de29b