diff --git a/README.md b/README.md index 0f98cbc5..5006cd26 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Currently, this app depends on the `develop` branch of [frappe](https://github.c bench --site lms.test install-app lms bench --site lms.test add-to-hosts - 1. Now, you can access the site at `http://gameplan.test:8080` + 1. Now, you can access the site at `http://lms.test:8000` ## Deployment diff --git a/lms/lms/api.py b/lms/lms/api.py index 6e36f79e..d58fc09d 100644 --- a/lms/lms/api.py +++ b/lms/lms/api.py @@ -21,7 +21,7 @@ def submit_solution(exercise, code): @exerecise: name of the exercise to submit @code: solution to the exercise """ - ex = frappe.get_doc("Exercise", exercise) + ex = frappe.get_doc("LMS Exercise", exercise) if not ex: return doc = ex.submit(code) diff --git a/lms/lms/doctype/course_lesson/course_lesson.js b/lms/lms/doctype/course_lesson/course_lesson.js index 7ea395d2..69d53d9a 100644 --- a/lms/lms/doctype/course_lesson/course_lesson.js +++ b/lms/lms/doctype/course_lesson/course_lesson.js @@ -7,7 +7,7 @@ frappe.ui.form.on("Course Lesson", { }, setup_help(frm) { let quiz_link = ` ${__("Quiz List")} `; - let exercise_link = ` ${__( + let exercise_link = ` ${__( "Exercise List" )} `; let file_link = ` ${__("File DocType")} `; diff --git a/lms/lms/doctype/course_lesson/course_lesson.py b/lms/lms/doctype/course_lesson/course_lesson.py index acc3bc7e..cf3f8c9d 100644 --- a/lms/lms/doctype/course_lesson/course_lesson.py +++ b/lms/lms/doctype/course_lesson/course_lesson.py @@ -25,7 +25,7 @@ class CourseLesson(Document): self.update_lesson_name_in_document(section) def update_lesson_name_in_document(self, section): - doctype_map = {"Exercise": "Exercise", "Quiz": "LMS Quiz"} + doctype_map = {"Exercise": "LMS Exercise", "Quiz": "LMS Quiz"} macros = find_macros(self.body) documents = [value for name, value in macros if name == section] index = 1 @@ -71,7 +71,7 @@ class CourseLesson(Document): macros = find_macros(self.body) exercises = [value for name, value in macros if name == "Exercise"] - return [frappe.get_doc("Exercise", name) for name in exercises] + return [frappe.get_doc("LMS Exercise", name) for name in exercises] def get_progress(self): return frappe.db.get_value( @@ -92,14 +92,9 @@ def save_progress(lesson, course, status): if not membership: return - if frappe.db.exists( - "LMS Course Progress", - {"lesson": lesson, "owner": frappe.session.user, "course": course}, - ): - doc = frappe.get_doc( - "LMS Course Progress", - {"lesson": lesson, "owner": frappe.session.user, "course": course}, - ) + filters = {"lesson": lesson, "owner": frappe.session.user, "course": course} + if frappe.db.exists("LMS Course Progress", filters): + doc = frappe.get_doc("LMS Course Progress", filters) doc.status = status doc.save(ignore_permissions=True) else: @@ -108,6 +103,7 @@ def save_progress(lesson, course, status): "doctype": "LMS Course Progress", "lesson": lesson, "status": status, + "member": frappe.session.user, } ).save(ignore_permissions=True) diff --git a/lms/lms/doctype/exercise_latest_submission/exercise_latest_submission.json b/lms/lms/doctype/exercise_latest_submission/exercise_latest_submission.json index 16ee0a6f..b92bc3e1 100644 --- a/lms/lms/doctype/exercise_latest_submission/exercise_latest_submission.json +++ b/lms/lms/doctype/exercise_latest_submission/exercise_latest_submission.json @@ -30,7 +30,7 @@ "in_list_view": 1, "in_standard_filter": 1, "label": "Exercise", - "options": "Exercise", + "options": "LMS Exercise", "search_index": 1 }, { @@ -163,4 +163,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 -} \ No newline at end of file +} diff --git a/lms/lms/doctype/exercise_submission/exercise_submission.json b/lms/lms/doctype/exercise_submission/exercise_submission.json index def5f1f7..f34d3f1a 100644 --- a/lms/lms/doctype/exercise_submission/exercise_submission.json +++ b/lms/lms/doctype/exercise_submission/exercise_submission.json @@ -25,7 +25,7 @@ "fieldtype": "Link", "in_list_view": 1, "label": "Exercise", - "options": "Exercise" + "options": "LMS Exercise" }, { "fetch_from": "exercise.title", @@ -123,4 +123,4 @@ "sort_field": "modified", "sort_order": "DESC", "track_changes": 1 -} \ No newline at end of file +} diff --git a/lms/lms/doctype/lms_certificate_request/lms_certificate_request.json b/lms/lms/doctype/lms_certificate_request/lms_certificate_request.json index f1756868..3532d24b 100644 --- a/lms/lms/doctype/lms_certificate_request/lms_certificate_request.json +++ b/lms/lms/doctype/lms_certificate_request/lms_certificate_request.json @@ -41,7 +41,7 @@ "fieldname": "evaluator", "fieldtype": "Link", "label": "Evaluator", - "options": "Course Evaluator", + "options": "User", "read_only": 1 }, { @@ -93,7 +93,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-02-23 09:47:46.480376", + "modified": "2023-02-28 19:53:17.534351", "modified_by": "Administrator", "module": "LMS", "name": "LMS Certificate Request", diff --git a/lms/lms/doctype/lms_class/lms_class.json b/lms/lms/doctype/lms_class/lms_class.json index 7f4c99cf..a2a51330 100644 --- a/lms/lms/doctype/lms_class/lms_class.json +++ b/lms/lms/doctype/lms_class/lms_class.json @@ -29,6 +29,7 @@ { "fieldname": "end_date", "fieldtype": "Date", + "in_list_view": 1, "label": "End Date", "reqd": 1 }, @@ -60,6 +61,7 @@ { "fieldname": "start_date", "fieldtype": "Date", + "in_list_view": 1, "label": "Start Date", "reqd": 1 }, @@ -73,7 +75,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2022-11-25 10:37:24.250557", + "modified": "2023-03-02 22:47:13.139289", "modified_by": "Administrator", "module": "LMS", "name": "LMS Class", @@ -107,5 +109,6 @@ ], "sort_field": "modified", "sort_order": "DESC", - "states": [] -} + "states": [], + "title_field": "title" +} \ No newline at end of file diff --git a/lms/lms/doctype/lms_course/test_lms_course.py b/lms/lms/doctype/lms_course/test_lms_course.py index d144e41b..7ad6f20a 100644 --- a/lms/lms/doctype/lms_course/test_lms_course.py +++ b/lms/lms/doctype/lms_course/test_lms_course.py @@ -35,7 +35,7 @@ class TestLMSCourse(unittest.TestCase): if frappe.db.exists("LMS Course", "test-course"): frappe.db.delete("Exercise Submission", {"course": "test-course"}) frappe.db.delete("Exercise Latest Submission", {"course": "test-course"}) - frappe.db.delete("Exercise", {"course": "test-course"}) + frappe.db.delete("LMS Exercise", {"course": "test-course"}) frappe.db.delete("LMS Batch Membership", {"course": "test-course"}) frappe.db.delete("LMS Batch", {"course": "test-course"}) frappe.db.delete("LMS Course Mentor Mapping", {"course": "test-course"}) diff --git a/lms/lms/doctype/exercise/__init__.py b/lms/lms/doctype/lms_exercise/__init__.py similarity index 100% rename from lms/lms/doctype/exercise/__init__.py rename to lms/lms/doctype/lms_exercise/__init__.py diff --git a/lms/lms/doctype/exercise/exercise.js b/lms/lms/doctype/lms_exercise/lms_exercise.js similarity index 79% rename from lms/lms/doctype/exercise/exercise.js rename to lms/lms/doctype/lms_exercise/lms_exercise.js index 02d9ca42..d86d34c6 100644 --- a/lms/lms/doctype/exercise/exercise.js +++ b/lms/lms/doctype/lms_exercise/lms_exercise.js @@ -1,7 +1,7 @@ // Copyright (c) 2021, FOSS United and contributors // For license information, please see license.txt -frappe.ui.form.on("Exercise", { +frappe.ui.form.on("LMS Exercise", { // refresh: function(frm) { // } }); diff --git a/lms/lms/doctype/exercise/exercise.json b/lms/lms/doctype/lms_exercise/lms_exercise.json similarity index 98% rename from lms/lms/doctype/exercise/exercise.json rename to lms/lms/doctype/lms_exercise/lms_exercise.json index 67530594..8c0068de 100644 --- a/lms/lms/doctype/exercise/exercise.json +++ b/lms/lms/doctype/lms_exercise/lms_exercise.json @@ -99,7 +99,7 @@ "modified": "2021-09-29 15:27:55.585874", "modified_by": "Administrator", "module": "LMS", - "name": "Exercise", + "name": "LMS Exercise", "owner": "Administrator", "permissions": [ { @@ -120,4 +120,4 @@ "sort_order": "ASC", "title_field": "title", "track_changes": 1 -} \ No newline at end of file +} diff --git a/lms/lms/doctype/exercise/exercise.py b/lms/lms/doctype/lms_exercise/lms_exercise.py similarity index 97% rename from lms/lms/doctype/exercise/exercise.py rename to lms/lms/doctype/lms_exercise/lms_exercise.py index 2ba58e3a..2342e383 100644 --- a/lms/lms/doctype/exercise/exercise.py +++ b/lms/lms/doctype/lms_exercise/lms_exercise.py @@ -7,7 +7,7 @@ from frappe.model.document import Document from lms.lms.utils import get_membership -class Exercise(Document): +class LMSExercise(Document): def get_user_submission(self): """Returns the latest submission for this user.""" user = frappe.session.user diff --git a/lms/lms/doctype/exercise/test_exercise.py b/lms/lms/doctype/lms_exercise/test_lms_exercise.py similarity index 91% rename from lms/lms/doctype/exercise/test_exercise.py rename to lms/lms/doctype/lms_exercise/test_lms_exercise.py index a57b2c4e..02560d37 100644 --- a/lms/lms/doctype/exercise/test_exercise.py +++ b/lms/lms/doctype/lms_exercise/test_lms_exercise.py @@ -8,7 +8,7 @@ import frappe from lms.lms.doctype.lms_course.test_lms_course import new_course -class TestExercise(unittest.TestCase): +class TestLMSExercise(unittest.TestCase): def new_exercise(self): course = new_course("Test Course") member = frappe.get_doc( @@ -21,7 +21,7 @@ class TestExercise(unittest.TestCase): member.insert() e = frappe.get_doc( { - "doctype": "Exercise", + "doctype": "LMS Exercise", "name": "test-problem", "course": course.name, "title": "Test Problem", @@ -51,4 +51,4 @@ class TestExercise(unittest.TestCase): def tearDown(self): frappe.db.sql("delete from `tabLMS Batch Membership`") frappe.db.sql("delete from `tabExercise Submission`") - frappe.db.sql("delete from `tabExercise`") + frappe.db.sql("delete from `tabLMS Exercise`") diff --git a/lms/lms/doctype/lms_section/lms_section.py b/lms/lms/doctype/lms_section/lms_section.py index 99b3f975..eb31a25e 100644 --- a/lms/lms/doctype/lms_section/lms_section.py +++ b/lms/lms/doctype/lms_section/lms_section.py @@ -11,7 +11,7 @@ class LMSSection(Document): def get_exercise(self): if self.type == "exercise": - return frappe.get_doc("Exercise", self.id) + return frappe.get_doc("LMS Exercise", self.id) def get_quiz(self): if self.type == "quiz": diff --git a/lms/lms/notification/certificate_request_creation/certificate_request_creation.json b/lms/lms/notification/certificate_request_creation/certificate_request_creation.json index d32f77bb..8f350a8a 100644 --- a/lms/lms/notification/certificate_request_creation/certificate_request_creation.json +++ b/lms/lms/notification/certificate_request_creation/certificate_request_creation.json @@ -10,8 +10,8 @@ "event": "New", "idx": 0, "is_standard": 1, - "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n
{{ _('Your evaluation for the course ${0} has been scheduled on ${1} at ${2}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\")) }}
\n{{ _(\"Please prepare well and be on time for the evaluations.\") }}
\n", - "modified": "2022-06-03 11:49:01.310656", + "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n{{ _(\"Hey {0}\").format(doc.member_name) }}
\n{{ _('Your evaluation for the course {0} has been scheduled on {1} at {2}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\")) }}
\n{{ _(\"Please prepare well and be on time for the evaluations.\") }}
\n", + "modified": "2023-02-28 19:53:47.716135", "modified_by": "Administrator", "module": "LMS", "name": "Certificate Request Creation", @@ -19,9 +19,12 @@ "recipients": [ { "receiver_by_document_field": "member" + }, + { + "receiver_by_document_field": "evaluator" } ], "send_system_notification": 0, "send_to_all_assignees": 0, "subject": "Your evaluation slot has been booked" -} \ No newline at end of file +} diff --git a/lms/patches.txt b/lms/patches.txt index ef8606d3..f67b6d87 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -34,7 +34,7 @@ lms.patches.v0_0.create_course_instructor_role #29-08-2022 lms.patches.v0_0.create_course_moderator_role lms.patches.v0_0.set_dashboard #11-10-2022 lms.patches.v0_0.set_courses_page_as_home -lms.patches.v0_0.set_member_in_progress #09-11-2022 +lms.patches.v0_0.set_member_in_progress #03-03-2023 lms.patches.v0_0.convert_progress_to_float lms.patches.v0_0.add_pages_to_nav #25-11-2022 lms.patches.v0_0.change_role_names @@ -47,3 +47,4 @@ lms.patches.v0_0.assignment_file_type lms.patches.v0_0.user_singles_issue #23-11-2022 lms.patches.v0_0.rename_community_to_users #06-01-2023 lms.patches.v0_0.video_embed_link +lms.patches.v0_0.rename_exercise_doctype diff --git a/lms/patches/v0_0/rename_exercise_doctype.py b/lms/patches/v0_0/rename_exercise_doctype.py new file mode 100644 index 00000000..3263dad5 --- /dev/null +++ b/lms/patches/v0_0/rename_exercise_doctype.py @@ -0,0 +1,13 @@ +import frappe +from frappe.model.rename_doc import rename_doc + + +def execute(): + if frappe.db.exists("DocType", "LMS Exercise"): + return + + frappe.flags.ignore_route_conflict_validation = True + rename_doc("DocType", "Exercise", "LMS Exercise") + frappe.flags.ignore_route_conflict_validation = False + + frappe.reload_doctype("LMS Exercise", force=True) diff --git a/lms/patches/v0_0/set_member_in_progress.py b/lms/patches/v0_0/set_member_in_progress.py index 7c9cff75..3548701a 100644 --- a/lms/patches/v0_0/set_member_in_progress.py +++ b/lms/patches/v0_0/set_member_in_progress.py @@ -3,9 +3,12 @@ import frappe def execute(): frappe.reload_doc("lms", "doctype", "lms_course_progress") - progress_records = frappe.get_all("LMS Course Progress", fields=["name", "owner"]) + progress_records = frappe.get_all( + "LMS Course Progress", fields=["name", "owner", "member"] + ) for progress in progress_records: - full_name = frappe.db.get_value("User", progress.owner, "full_name") - frappe.db.set_value("LMS Course Progress", progress.name, "member", progress.owner) - frappe.db.set_value("LMS Course Progress", progress.name, "member_name", full_name) + if not progress.member: + full_name = frappe.db.get_value("User", progress.owner, "full_name") + frappe.db.set_value("LMS Course Progress", progress.name, "member", progress.owner) + frappe.db.set_value("LMS Course Progress", progress.name, "member_name", full_name) diff --git a/lms/plugins.py b/lms/plugins.py index f542143f..cc4fb359 100644 --- a/lms/plugins.py +++ b/lms/plugins.py @@ -119,7 +119,7 @@ def quiz_renderer(quiz_name): def exercise_renderer(argument): - exercise = frappe.get_doc("Exercise", argument) + exercise = frappe.get_doc("LMS Exercise", argument) context = dict(exercise=exercise) return frappe.render_template("templates/exercise.html", context)