feat: evaluation end date

This commit is contained in:
Jannat Patel
2023-11-29 17:36:34 +05:30
parent de60fbb25a
commit eef5bd6062
11 changed files with 49 additions and 16 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -12,6 +12,7 @@ from lms.lms.utils import get_evaluator
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 @@ class LMSCertificateRequest(Document):
)
)
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)

View File

@@ -11,7 +11,8 @@
"idx": 0,
"is_standard": 1,
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n<p> {{ _(\"Hey {0}\").format(doc.member_name) }} </p>\n<p> {{ _('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\")) }}</p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\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",
@@ -22,9 +23,12 @@
},
{
"receiver_by_document_field": "evaluator"
},
{
"receiver_by_role": "Frappe School Admin"
}
],
"send_system_notification": 0,
"send_to_all_assignees": 0,
"subject": "Your evaluation slot has been booked"
}
}

View File

@@ -1 +0,0 @@
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -1,5 +1,5 @@
{% set title = frappe.db.get_value("LMS Course", doc.course, "title") %}
<p> {{ _("Hey {0}").format(doc.member_name) }} </p>
<p> {{ _('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")) }}</p>
<p> {{ _('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")) }}</p>
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -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<p> {{ _('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\")) }}</p>\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
"modified": "2022-06-03 11:51:02.681803",
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n<p> {{ _('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\")) }}</p>\n\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\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,

View File

@@ -1,3 +0,0 @@
{% set title = frappe.db.get_value("LMS Course", doc.course, "title") %}
<p> {{ _('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")) }}</p>
<p> {{ _("Please prepare well and be on time for the evaluations.") }} </p>

View File

@@ -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 '' }}"
</script>
<link rel="stylesheet" href="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.css" />

View File

@@ -503,6 +503,7 @@ const remove_assessment = (e) => {
};
const open_evaluation_form = (e) => {
console.log(evaluation_end_date);
this.eval_form = new frappe.ui.Dialog({
title: __("Schedule Evaluation"),
fields: [
@@ -530,6 +531,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();
},

View File

@@ -43,6 +43,7 @@ def get_context(context):
"batch_details",
"published",
"allow_future",
"evaluation_end_date",
],
as_dict=True,
)