diff --git a/frappe-ui b/frappe-ui new file mode 160000 index 000000000..2898a0bdd --- /dev/null +++ b/frappe-ui @@ -0,0 +1 @@ +Subproject commit 2898a0bdd1a07433e5f6adedb42786177c473d50 diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index c5c667238..fd9f7793d 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -20,6 +20,7 @@ "category", "column_break_flwy", "seat_count", + "evaluation_end_date", "section_break_6", "description", "batch_details_raw", @@ -279,11 +280,16 @@ "fieldname": "allow_future", "fieldtype": "Check", "label": "Allow accessing future dates" + }, + { + "fieldname": "evaluation_end_date", + "fieldtype": "Date", + "label": "Evaluation End Date" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-17 10:41:00.340418", + "modified": "2023-11-29 12:06:58.776479", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", diff --git a/lms/lms/doctype/lms_batch/lms_batch.py b/lms/lms/doctype/lms_batch/lms_batch.py index 9f96d4cd7..857df297e 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.py +++ b/lms/lms/doctype/lms_batch/lms_batch.py @@ -29,6 +29,7 @@ def validate(self): self.validate_membership() self.validate_timetable() self.send_confirmation_mail() + self.validate_evaluation_end_date() def validate_duplicate_students(self): students = [row.student for row in self.students] @@ -68,6 +69,10 @@ def send_confirmation_mail(self): self.send_mail(student) student.confirmation_email_sent = 1 + def validate_evaluation_end_date(self): + if self.evaluation_end_date and self.evaluation_end_date < self.end_date: + frappe.throw(_("Evaluation end date cannot be less than the batch end date.")) + def send_mail(self, student): subject = _("Enrollment Confirmation for the Next Training Batch") template = "batch_confirmation" @@ -253,6 +258,7 @@ def create_batch( currency=None, name=None, published=0, + evaluation_end_date=None, ): frappe.only_for("Moderator") if name: @@ -278,6 +284,7 @@ def create_batch( "amount": amount, "currency": currency, "published": published, + "evaluation_end_date": evaluation_end_date, } ) doc.save() 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 e8f350281..af9a5cb75 100644 --- a/lms/lms/doctype/lms_certificate_request/lms_certificate_request.json +++ b/lms/lms/doctype/lms_certificate_request/lms_certificate_request.json @@ -103,13 +103,13 @@ "fieldname": "batch_name", "fieldtype": "Link", "in_standard_filter": 1, - "label": "Batch Name", + "label": "Batch", "options": "LMS Batch" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-08-23 14:50:37.618352", + "modified": "2023-11-29 15:00:30.617298", "modified_by": "Administrator", "module": "LMS", "name": "LMS Certificate Request", diff --git a/lms/lms/doctype/lms_certificate_request/lms_certificate_request.py b/lms/lms/doctype/lms_certificate_request/lms_certificate_request.py index 6368bd794..9b33ed999 100644 --- a/lms/lms/doctype/lms_certificate_request/lms_certificate_request.py +++ b/lms/lms/doctype/lms_certificate_request/lms_certificate_request.py @@ -12,6 +12,7 @@ class LMSCertificateRequest(Document): def validate(self): self.validate_if_existing_requests() + self.validate_evaluation_date() def validate_if_existing_requests(self): existing_requests = frappe.get_all( @@ -32,6 +33,20 @@ def validate_if_existing_requests(self): ) ) + def validate_evaluation_date(self): + if self.batch_name: + evaluation_end_date = frappe.db.get_value( + "LMS Batch", self.batch_name, "evaluation_end_date" + ) + + if evaluation_end_date: + if getdate(self.date) > getdate(evaluation_end_date): + frappe.throw( + _("You cannot schedule evaluations after {0}.").format( + format_date(evaluation_end_date, "medium") + ) + ) + def schedule_evals(): if frappe.db.get_single_value("LMS Settings", "send_calendar_invite_for_evaluations"): @@ -104,7 +119,9 @@ def update_meeting_details(eval, event, calendar): @frappe.whitelist() -def create_certificate_request(course, date, day, start_time, end_time, batch=None): +def create_certificate_request( + course, date, day, start_time, end_time, batch_name=None +): is_member = frappe.db.exists( {"doctype": "LMS Enrollment", "course": course, "member": frappe.session.user} ) @@ -115,13 +132,13 @@ def create_certificate_request(course, date, day, start_time, end_time, batch=No eval.update( { "course": course, - "evaluator": get_evaluator(course, batch), + "evaluator": get_evaluator(course, batch_name), "member": frappe.session.user, "date": date, "day": day, "start_time": start_time, "end_time": end_time, - "batch": batch, + "batch_name": batch_name, } ) eval.save(ignore_permissions=True) 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 8f350a8a8..8a4302d61 100644 --- a/lms/lms/notification/certificate_request_creation/certificate_request_creation.json +++ b/lms/lms/notification/certificate_request_creation/certificate_request_creation.json @@ -11,7 +11,8 @@ "idx": 0, "is_standard": 1, "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", + "message_type": "HTML", + "modified": "2023-11-29 17:34:54.514031", "modified_by": "Administrator", "module": "LMS", "name": "Certificate Request Creation", @@ -27,4 +28,4 @@ "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/lms/notification/certificate_request_creation/certificate_request_creation.md b/lms/lms/notification/certificate_request_creation/certificate_request_creation.md deleted file mode 100644 index 46f352a05..000000000 --- a/lms/lms/notification/certificate_request_creation/certificate_request_creation.md +++ /dev/null @@ -1 +0,0 @@ -

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

\ No newline at end of file diff --git a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.html b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.html index 7a22c9389..feb0c4766 100644 --- a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.html +++ b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.html @@ -1,5 +1,5 @@ {% set title = frappe.db.get_value("LMS Course", doc.course, "title") %} -

{{ _("Hey {0}").format(doc.member_name) }}

-

{{ _('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")) }}

+

{{ _('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")) }}

+

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

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 315cf4453..b334eabf9 100644 --- a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json +++ b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json @@ -11,8 +11,9 @@ "event": "Days Before", "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:51:02.681803", + "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", "module": "LMS", "name": "Certificate Request Reminder", @@ -20,6 +21,9 @@ "recipients": [ { "receiver_by_document_field": "member" + }, + { + "receiver_by_document_field": "evaluator" } ], "send_system_notification": 0, diff --git a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.md b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.md deleted file mode 100644 index e8ff02cba..000000000 --- a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.md +++ /dev/null @@ -1,3 +0,0 @@ -{% set title = frappe.db.get_value("LMS Course", doc.course, "title") %} -

{{ _('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")) }}

-

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

diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index 88a86e28b..485590020 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -267,15 +267,6 @@ const open_batch_dialog = () => { fieldname: "published", default: batch_info && batch_info.published, }, - { - fieldtype: "Column Break", - }, - { - fieldtype: "Int", - label: __("Seat Count"), - fieldname: "seat_count", - default: batch_info && batch_info.seat_count, - }, { fieldtype: "Section Break", }, @@ -293,13 +284,6 @@ const open_batch_dialog = () => { reqd: 1, default: batch_info && batch_info.end_date, }, - { - fieldtype: "Select", - label: __("Medium"), - fieldname: "medium", - options: ["Online", "Offline"], - default: (batch_info && batch_info.medium) || "Online", - }, { fieldtype: "Column Break", }, @@ -317,6 +301,16 @@ const open_batch_dialog = () => { default: batch_info && batch_info.end_time, reqd: 1, }, + { + fieldtype: "Section Break", + }, + { + fieldtype: "Select", + label: __("Medium"), + fieldname: "medium", + options: ["Online", "Offline"], + default: (batch_info && batch_info.medium) || "Online", + }, { fieldtype: "Link", label: __("Category"), @@ -325,6 +319,21 @@ const open_batch_dialog = () => { only_select: 1, default: batch_info && batch_info.category, }, + { + fieldtype: "Column Break", + }, + { + fieldtype: "Int", + label: __("Seat Count"), + fieldname: "seat_count", + default: batch_info && batch_info.seat_count, + }, + { + fieldtype: "Date", + label: __("Evaluation End Date"), + fieldname: "evaluation_end_date", + default: batch_info && batch_info.evaluation_end_date, + }, { fieldtype: "Section Break", }, diff --git a/lms/www/batches/batch.html b/lms/www/batches/batch.html index 0183f5f57..cd38e0efc 100644 --- a/lms/www/batches/batch.html +++ b/lms/www/batches/batch.html @@ -639,6 +639,7 @@ let courses = {{ course_list | json }}; const legends = {{ legends | json }}; const allow_future = {{ batch_info.allow_future }} + const evaluation_end_date = "{{ batch_info.evaluation_end_date if batch_info.evaluation_end_date else '' }}" diff --git a/lms/www/batches/batch.js b/lms/www/batches/batch.js index cf81c223d..406dfaa59 100644 --- a/lms/www/batches/batch.js +++ b/lms/www/batches/batch.js @@ -530,6 +530,9 @@ const open_evaluation_form = (e) => { min_date: new Date( frappe.datetime.add_days(frappe.datetime.get_today(), 1) ), + max_date: evaluation_end_date + ? new Date(evaluation_end_date) + : "", change: () => { if (this.eval_form.get_value("date")) get_slots(); }, diff --git a/lms/www/batches/batch.py b/lms/www/batches/batch.py index ab339e157..666658cc9 100644 --- a/lms/www/batches/batch.py +++ b/lms/www/batches/batch.py @@ -43,6 +43,7 @@ def get_context(context): "batch_details", "published", "allow_future", + "evaluation_end_date", ], as_dict=True, )