From 5ea3b25d210a975e314e8b3ff6359f4bdd40f5e9 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 6 Jul 2021 17:58:36 +0530 Subject: [PATCH] feat: course home --- .../lms_batch_membership.js | 2 +- .../lms/doctype/lms_course/lms_course.py | 5 + .../lms_course_mentor_mapping.js | 12 +- .../lms_course_review/lms_course_review.json | 5 +- .../lms_course_review/lms_course_review.py | 12 +- community/lms/widgets/ChapterTeaser.html | 53 +- community/lms/widgets/CourseOutline.html | 8 +- community/lms/widgets/MemberCard.html | 14 + community/lms/widgets/Reviews.html | 71 +- community/public/css/style.css | 985 ++++++++++++------ community/public/images/play.png | Bin 0 -> 326 bytes community/www/courses/course.html | 284 +++-- community/www/courses/course.js | 279 +++-- community/www/courses/index.html | 2 +- 14 files changed, 1197 insertions(+), 535 deletions(-) create mode 100644 community/lms/widgets/MemberCard.html create mode 100644 community/public/images/play.png diff --git a/community/lms/doctype/lms_batch_membership/lms_batch_membership.js b/community/lms/doctype/lms_batch_membership/lms_batch_membership.js index 0a20239d..68ac4f55 100644 --- a/community/lms/doctype/lms_batch_membership/lms_batch_membership.js +++ b/community/lms/doctype/lms_batch_membership/lms_batch_membership.js @@ -10,5 +10,5 @@ frappe.ui.form.on('LMS Batch Membership', { } }; }); - }, + } }); diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index c3d797fd..29b6bb8d 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -274,6 +274,11 @@ class LMSCourse(Document): return False return True + def get_average_rating(self): + ratings = [review.rating for review in self.get_reviews()] + if not len(ratings): + return None + return sum(ratings)/len(ratings) def get_outline(self): return CourseOutline(self) diff --git a/community/lms/doctype/lms_course_mentor_mapping/lms_course_mentor_mapping.js b/community/lms/doctype/lms_course_mentor_mapping/lms_course_mentor_mapping.js index 5b17f61a..c995587f 100644 --- a/community/lms/doctype/lms_course_mentor_mapping/lms_course_mentor_mapping.js +++ b/community/lms/doctype/lms_course_mentor_mapping/lms_course_mentor_mapping.js @@ -2,7 +2,13 @@ // For license information, please see license.txt frappe.ui.form.on('LMS Course Mentor Mapping', { - // refresh: function(frm) { - - // } + onload: function(frm) { + frm.set_query('mentor', function(doc) { + return { + filters: { + "ignore_user_type": 1, + } + }; + }); + }, }); diff --git a/community/lms/doctype/lms_course_review/lms_course_review.json b/community/lms/doctype/lms_course_review/lms_course_review.json index c2684bbe..f2b78b5d 100644 --- a/community/lms/doctype/lms_course_review/lms_course_review.json +++ b/community/lms/doctype/lms_course_review/lms_course_review.json @@ -13,23 +13,26 @@ { "fieldname": "review", "fieldtype": "Small Text", + "in_list_view": 1, "label": "Review" }, { "fieldname": "rating", "fieldtype": "Rating", + "in_list_view": 1, "label": "Rating" }, { "fieldname": "course", "fieldtype": "Link", + "in_list_view": 1, "label": "Course", "options": "LMS Course" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-06-28 15:00:35.146196", + "modified": "2021-07-05 14:57:03.841430", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course Review", diff --git a/community/lms/doctype/lms_course_review/lms_course_review.py b/community/lms/doctype/lms_course_review/lms_course_review.py index e2361ad0..2c4199a4 100644 --- a/community/lms/doctype/lms_course_review/lms_course_review.py +++ b/community/lms/doctype/lms_course_review/lms_course_review.py @@ -1,8 +1,18 @@ # Copyright (c) 2021, FOSS United and contributors # For license information, please see license.txt -# import frappe +import frappe from frappe.model.document import Document class LMSCourseReview(Document): pass + +@frappe.whitelist() +def submit_review(rating, review, course): + frappe.get_doc({ + "doctype": "LMS Course Review", + "rating": rating, + "review": review, + "course": course + }).save(ignore_permissions=True) + return "OK" diff --git a/community/lms/widgets/ChapterTeaser.html b/community/lms/widgets/ChapterTeaser.html index 537c952c..0d08b078 100644 --- a/community/lms/widgets/ChapterTeaser.html +++ b/community/lms/widgets/ChapterTeaser.html @@ -1,42 +1,33 @@
- + +{% endif %} diff --git a/community/lms/widgets/MemberCard.html b/community/lms/widgets/MemberCard.html new file mode 100644 index 00000000..87cb60b8 --- /dev/null +++ b/community/lms/widgets/MemberCard.html @@ -0,0 +1,14 @@ +
+ {% set avatar_class = "avatar-xl" if dimension_class == "member-card-large" else "avatar-large"%} + {{ widgets.Avatar(member=member, avatar_class=avatar_class) }} +
+ {{ member.full_name }} +
+ {% set course_count = member.get_course_count() %} + {% if show_course_count and course_count > 0 %} + {% set suffix = "Courses" if course_count > 1 else "Course" %} +
+ Created {{ course_count }} {{ suffix }} +
+ {% endif %} +
diff --git a/community/lms/widgets/Reviews.html b/community/lms/widgets/Reviews.html index 962ad6fb..2d64ae20 100644 --- a/community/lms/widgets/Reviews.html +++ b/community/lms/widgets/Reviews.html @@ -1,22 +1,22 @@ -
+{% if course.get_reviews() | length %} +
-
Review
+
Review
{% if course.is_eligible_to_review(membership) %} - + Provide your Feedback {% endif %}
-
+
{% for review in course.get_reviews() %} -
-
{{ review.review }}
-
+
+
{{ review.review }}
- - - -