fix: course page

This commit is contained in:
pateljannat
2021-08-20 14:23:18 +05:30
parent eaec991f47
commit c6d3994383
9 changed files with 54 additions and 22 deletions

View File

@@ -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",

View File

@@ -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,
}
};
});
}
});

View File

@@ -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",

View File

@@ -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):

View File

@@ -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

View File

@@ -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)

View File

@@ -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,

View File

@@ -43,7 +43,7 @@
</div>
</div>
<div class="course-buttons">
{% if not course.disable_self_learning and not membership %}
{% if not course.disable_self_learning and not membership and not course.upcoming %}
<div class="button wide-button start-learning is-primary join-batch" data-course="{{ course.name | urlencode }}">
Start Learning
<img class="ml-2" src="/assets/community/icons/white-arrow.svg" />

View File