diff --git a/.gitignore b/.gitignore index f6a99e30..222921e1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ tags community/docs/current community/public/dist +__pycache__/ +*.py[cod] +*$py.class diff --git a/community/hooks.py b/community/hooks.py index eca23eac..dbf8f2a2 100644 --- a/community/hooks.py +++ b/community/hooks.py @@ -165,7 +165,8 @@ whitelist = [ "/add-a-new-batch", "/new-sign-up", "/message", - "/about" + "/about", + "/lms-course-review" ] whitelist_rules = [{"from_route": p, "to_route": p[1:]} for p in whitelist] @@ -187,6 +188,10 @@ update_website_context = 'community.widgets.update_website_context' ## subclass of community.community.plugins.PageExtension # community_lesson_page_extension = None +community_lesson_page_extensions = [ + "community.plugins.LiveCodeExtension" +] + ## Markdown Macros for Lessons community_markdown_macro_renderers = { "Exercise": "community.plugins.exercise_renderer", diff --git a/community/lms/doctype/exercise_submission/exercise_submission.json b/community/lms/doctype/exercise_submission/exercise_submission.json index bd662b11..125af148 100644 --- a/community/lms/doctype/exercise_submission/exercise_submission.json +++ b/community/lms/doctype/exercise_submission/exercise_submission.json @@ -6,12 +6,17 @@ "engine": "InnoDB", "field_order": [ "exercise", - "solution", + "status", + "batch", + "column_break_4", "exercise_title", "course", - "batch", "lesson", - "image" + "section_break_8", + "solution", + "image", + "test_results", + "comments" ], "fields": [ { @@ -21,12 +26,6 @@ "label": "Exercise", "options": "Exercise" }, - { - "fieldname": "solution", - "fieldtype": "Code", - "in_list_view": 1, - "label": "Solution" - }, { "fetch_from": "exercise.title", "fieldname": "exercise_title", @@ -61,11 +60,41 @@ "fieldtype": "Code", "label": "Image", "read_only": 1 + }, + { + "fieldname": "status", + "fieldtype": "Select", + "label": "Status", + "options": "Correct\nIncorrect" + }, + { + "fieldname": "test_results", + "fieldtype": "Small Text", + "label": "Test Results" + }, + { + "fieldname": "comments", + "fieldtype": "Small Text", + "label": "Comments" + }, + { + "fieldname": "solution", + "fieldtype": "Code", + "in_list_view": 1, + "label": "Solution" + }, + { + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "fieldname": "section_break_8", + "fieldtype": "Section Break" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2021-05-21 11:28:45.833018", + "modified": "2021-06-24 16:22:50.570845", "modified_by": "Administrator", "module": "LMS", "name": "Exercise Submission", diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index 7889eb23..c3d797fd 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -199,7 +199,12 @@ class LMSCourse(Document): } if batch: filters["batch"] = batch - membership = frappe.db.get_value("LMS Batch Membership", filters, ["name","batch", "current_lesson"], as_dict=True) + + membership = frappe.db.get_value("LMS Batch Membership", + filters, + ["name", "batch", "current_lesson", "member_type"], + as_dict=True) + if membership and membership.batch: membership.batch_title = frappe.db.get_value("LMS Batch", membership.batch, "title") return membership @@ -244,6 +249,32 @@ class LMSCourse(Document): def get_tags(self): return self.tags.split(",") if self.tags else [] + def get_reviews(self): + reviews = frappe.get_all("LMS Course Review", + { + "course": self.name + }, + ["review", "rating", "owner"], + order_by= "creation desc") + + for review in reviews: + review.owner_details = frappe.get_doc("User", review.owner) + + return reviews + + def is_eligible_to_review(self, membership): + """ Checks if user is eligible to review the course """ + if not membership: + return False + if frappe.db.count("LMS Course Review", + { + "course": self.name, + "owner": frappe.session.user + }): + return False + return True + + def get_outline(self): return CourseOutline(self) diff --git a/community/lms/doctype/lms_course_review/__init__.py b/community/lms/doctype/lms_course_review/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/community/lms/doctype/lms_course_review/lms_course_review.js b/community/lms/doctype/lms_course_review/lms_course_review.js new file mode 100644 index 00000000..8382eb52 --- /dev/null +++ b/community/lms/doctype/lms_course_review/lms_course_review.js @@ -0,0 +1,8 @@ +// Copyright (c) 2021, FOSS United and contributors +// For license information, please see license.txt + +frappe.ui.form.on('LMS Course Review', { + // refresh: function(frm) { + + // } +}); diff --git a/community/lms/doctype/lms_course_review/lms_course_review.json b/community/lms/doctype/lms_course_review/lms_course_review.json new file mode 100644 index 00000000..c2684bbe --- /dev/null +++ b/community/lms/doctype/lms_course_review/lms_course_review.json @@ -0,0 +1,54 @@ +{ + "actions": [], + "creation": "2021-06-28 13:36:36.146718", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "review", + "rating", + "course" + ], + "fields": [ + { + "fieldname": "review", + "fieldtype": "Small Text", + "label": "Review" + }, + { + "fieldname": "rating", + "fieldtype": "Rating", + "label": "Rating" + }, + { + "fieldname": "course", + "fieldtype": "Link", + "label": "Course", + "options": "LMS Course" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2021-06-28 15:00:35.146196", + "modified_by": "Administrator", + "module": "LMS", + "name": "LMS Course Review", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1 +} \ No newline at end of file diff --git a/community/lms/doctype/lms_course_review/lms_course_review.py b/community/lms/doctype/lms_course_review/lms_course_review.py new file mode 100644 index 00000000..e2361ad0 --- /dev/null +++ b/community/lms/doctype/lms_course_review/lms_course_review.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + +class LMSCourseReview(Document): + pass diff --git a/community/lms/doctype/lms_course_review/test_lms_course_review.py b/community/lms/doctype/lms_course_review/test_lms_course_review.py new file mode 100644 index 00000000..da8a1450 --- /dev/null +++ b/community/lms/doctype/lms_course_review/test_lms_course_review.py @@ -0,0 +1,8 @@ +# Copyright (c) 2021, FOSS United and Contributors +# See license.txt + +# import frappe +import unittest + +class TestLMSCourseReview(unittest.TestCase): + pass diff --git a/community/lms/widgets/Reviews.html b/community/lms/widgets/Reviews.html new file mode 100644 index 00000000..9e0cf18b --- /dev/null +++ b/community/lms/widgets/Reviews.html @@ -0,0 +1,64 @@ +