From d712881e16fbdf225e0d0120d06f0d921267a4e6 Mon Sep 17 00:00:00 2001 From: Medjahdi Islem <88147785+IslemMedjahdi@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:32:00 +0100 Subject: [PATCH 1/6] Update docker-installation.md --- docker-installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-installation.md b/docker-installation.md index 99a272f1..b5c8ef80 100644 --- a/docker-installation.md +++ b/docker-installation.md @@ -4,6 +4,8 @@ $ git clone https://github.com/frappe/lms.git $ cd lms + +$ cd docker ``` **Step 2:** Run docker-compose From 5e569ab0e6d8b03a3a441cb19542f9f429929227 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Fri, 19 Jan 2024 23:56:48 +0530 Subject: [PATCH 2/6] feat: self enrollment in batches --- .../doctype/batch_student/batch_student.py | 12 +++++++++- lms/lms/doctype/lms_batch/lms_batch.json | 18 +++++++++++++- lms/www/batches/batch_details.html | 4 ++++ lms/www/batches/batch_details.js | 24 +++++++++++++++++++ lms/www/batches/batch_details.py | 1 + 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/lms/lms/doctype/batch_student/batch_student.py b/lms/lms/doctype/batch_student/batch_student.py index 7cd9a61a..d3168f71 100644 --- a/lms/lms/doctype/batch_student/batch_student.py +++ b/lms/lms/doctype/batch_student/batch_student.py @@ -1,9 +1,19 @@ # Copyright (c) 2022, Frappe and contributors # For license information, please see license.txt -# import frappe +import frappe from frappe.model.document import Document class BatchStudent(Document): pass + + +@frappe.whitelist() +def enroll_batch(batch_name): + enrollment = frappe.new_doc("Batch Student") + enrollment.student = frappe.session.user + enrollment.parent = batch_name + enrollment.parentfield = "students" + enrollment.parenttype = "LMS Batch" + enrollment.save(ignore_permissions=True) diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index b05ee563..48d2e0c8 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -15,6 +15,7 @@ "start_time", "end_time", "published", + "allow_self_enrollment", "section_break_rgfj", "medium", "category", @@ -293,11 +294,17 @@ "fieldname": "amount_usd", "fieldtype": "Currency", "label": "Amount (USD)" + }, + { + "default": "0", + "fieldname": "allow_self_enrollment", + "fieldtype": "Check", + "label": "Allow Self Enrollment" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-12-21 12:27:16.849362", + "modified": "2024-01-19 23:36:17.351413", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", @@ -327,6 +334,15 @@ "role": "Moderator", "share": 1, "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "LMS Student", + "share": 1 } ], "show_title_field_in_link": 1, diff --git a/lms/www/batches/batch_details.html b/lms/www/batches/batch_details.html index 9fd5c93e..7c5b5123 100644 --- a/lms/www/batches/batch_details.html +++ b/lms/www/batches/batch_details.html @@ -146,6 +146,10 @@ href="/billing/batch/{{ batch_info.name }}"> {{ _("Register Now") }} + {% elif batch_info.allow_self_enrollment %} + {% else %}
{{ _("To join this batch, please contact the Administrator.") }} diff --git a/lms/www/batches/batch_details.js b/lms/www/batches/batch_details.js index 92070ece..865fbcd6 100644 --- a/lms/www/batches/batch_details.js +++ b/lms/www/batches/batch_details.js @@ -12,6 +12,10 @@ frappe.ready(() => { $(".btn-remove-course").click((e) => { remove_course(e); }); + + $(".enroll-batch").click((e) => { + enroll_batch(e); + }); }); const show_course_modal = (e) => { @@ -54,6 +58,26 @@ const show_course_modal = (e) => { }, 1000); }; +const enroll_batch = (e) => { + let batch_name = $(".class-details").data("batch"); + frappe.call({ + method: "lms.lms.doctype.batch_student.batch_student.enroll_batch", + args: { + batch_name: batch_name, + }, + callback(r) { + frappe.show_alert( + { + message: __("Successfully Enrolled"), + indicator: "green", + }, + 2000 + ); + window.location.href = `/batches/${batch_name}`; + }, + }); +}; + const add_course = (values, course_name) => { frappe.call({ method: "lms.lms.doctype.lms_batch.lms_batch.add_course", diff --git a/lms/www/batches/batch_details.py b/lms/www/batches/batch_details.py index fdeb035b..97f950d9 100644 --- a/lms/www/batches/batch_details.py +++ b/lms/www/batches/batch_details.py @@ -35,6 +35,7 @@ def get_context(context): "batch_details_raw", "evaluation_end_date", "amount_usd", + "allow_self_enrollment", ], as_dict=1, ) From b67210815547228be3e4fdfb7a11b67ce20797c9 Mon Sep 17 00:00:00 2001 From: Md Hussain Nagaria <34810212+NagariaHussain@users.noreply.github.com> Date: Mon, 22 Jan 2024 10:33:55 +0530 Subject: [PATCH 3/6] fix: remove $ typos (#723) --- .../certificate_request_reminder.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json index b334eabf..0335d51b 100644 --- a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json +++ b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json @@ -11,7 +11,7 @@ "event": "Days Before", "idx": 0, "is_standard": 1, - "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\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\n

{{ _(\"Please prepare well and be on time for the evaluations.\") }}

\n", + "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\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\n

{{ _(\"Please prepare well and be on time for the evaluations.\") }}

\n", "message_type": "HTML", "modified": "2023-11-29 17:26:53.355501", "modified_by": "Administrator", @@ -29,4 +29,4 @@ "send_system_notification": 0, "send_to_all_assignees": 0, "subject": "Reminder for Certificate Evaluation" -} \ No newline at end of file +} From 28043e634b444d27dc3b6517dd31cd8c48ee741a Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 22 Jan 2024 10:43:02 +0530 Subject: [PATCH 4/6] fix: removed unnecessary roles --- lms/lms/doctype/lms_batch/lms_batch.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index 48d2e0c8..82023f6f 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -304,7 +304,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-19 23:36:17.351413", + "modified": "2024-01-22 10:42:42.872995", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", @@ -334,15 +334,6 @@ "role": "Moderator", "share": 1, "write": 1 - }, - { - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "LMS Student", - "share": 1 } ], "show_title_field_in_link": 1, From b7000137047ecc9a1b8a9ade6365243e2cadc13d Mon Sep 17 00:00:00 2001 From: Md Hussain Nagaria <34810212+NagariaHussain@users.noreply.github.com> Date: Mon, 22 Jan 2024 10:55:36 +0530 Subject: [PATCH 5/6] fix: only show start date for single day batches (#726) --- lms/www/batches/batch.html | 9 ++++++--- lms/www/batches/batch_details.html | 22 +++++++++++++--------- lms/www/batches/index.html | 8 +++++--- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lms/www/batches/batch.html b/lms/www/batches/batch.html index cc501ddc..f368c70c 100644 --- a/lms/www/batches/batch.html +++ b/lms/www/batches/batch.html @@ -49,11 +49,14 @@ - {{ frappe.utils.format_date(batch_info.start_date, "long") }} - + {{ frappe.utils.format_date(batch_info.start_date, "long") }} + + {% if batch_info.start_date != batch_info.end_date %} - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + {% endif %}
@@ -646,4 +649,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/lms/www/batches/batch_details.html b/lms/www/batches/batch_details.html index 7c5b5123..ddfbba43 100644 --- a/lms/www/batches/batch_details.html +++ b/lms/www/batches/batch_details.html @@ -57,11 +57,13 @@ - {{ frappe.utils.format_date(batch_info.start_date, "long") }} - - - - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + {{ frappe.utils.format_date(batch_info.start_date, "long") }} + {% if batch_info.start_date != batch_info.end_date %} + + - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + + {% endif %} {% if batch_info.start_time and batch_info.end_time %} @@ -115,11 +117,13 @@ - {{ frappe.utils.format_date(batch_info.start_date, "long") }} - - - - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + {{ frappe.utils.format_date(batch_info.start_date, "long") }} + {% if batch_info.start_date != batch_info.end_date %} + + - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + + {% endif %} {% if batch_info.start_time and batch_info.end_time %} @@ -239,4 +243,4 @@ let batch_info = {{ batch_info | json }}; {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/lms/www/batches/index.html b/lms/www/batches/index.html index 60eaad4f..cdcd56eb 100644 --- a/lms/www/batches/index.html +++ b/lms/www/batches/index.html @@ -140,11 +140,13 @@ - {{ frappe.utils.format_date(batch.start_date, "medium") }} - + {{ frappe.utils.format_date(batch.start_date, "medium") }} + {% if batch.start_date != batch.end_date %} - {{ frappe.utils.format_date(batch.end_date, "medium") }} + - {{ frappe.utils.format_date(batch.end_date, "long") }} + {% endif %}
@@ -204,4 +206,4 @@ let batch_info = null; {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} From d3b3d85c8403330eaa5ca856be5deadfc6f68723 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 22 Jan 2024 11:19:32 +0530 Subject: [PATCH 6/6] fix: redirect to login if guest before batch enrollment --- lms/www/batches/batch_details.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lms/www/batches/batch_details.js b/lms/www/batches/batch_details.js index 865fbcd6..9e1eeeb5 100644 --- a/lms/www/batches/batch_details.js +++ b/lms/www/batches/batch_details.js @@ -60,6 +60,10 @@ const show_course_modal = (e) => { const enroll_batch = (e) => { let batch_name = $(".class-details").data("batch"); + if (frappe.session.user == "Guest") { + window.location.href = + "/login?redirect-to=/batches/details/" + batch_name; + } frappe.call({ method: "lms.lms.doctype.batch_student.batch_student.enroll_batch", args: {