feat: certification request
This commit is contained in:
@@ -31,3 +31,8 @@ class CourseEvaluator(Document):
|
||||
|
||||
if overlap:
|
||||
frappe.throw(_("Slot Times are overlapping for some schedules."))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_schedule(course):
|
||||
evaluator = frappe.db.get_value("LMS Course", course, "evaluator")
|
||||
return frappe.get_all("Evaluator Schedule", filters={"parent": evaluator}, fields=["day", "start_time", "end_time"])
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
"course",
|
||||
"member",
|
||||
"evaluator",
|
||||
"slot"
|
||||
"column_break_4",
|
||||
"date",
|
||||
"day",
|
||||
"start_time",
|
||||
"end_time"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -31,17 +35,38 @@
|
||||
{
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Data",
|
||||
"label": "Evaluator"
|
||||
"label": "Evaluator",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "slot",
|
||||
"fieldtype": "Data",
|
||||
"label": "Slot"
|
||||
"fieldname": "date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Date"
|
||||
},
|
||||
{
|
||||
"fieldname": "day",
|
||||
"fieldtype": "Select",
|
||||
"label": "Day",
|
||||
"options": "Sunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday"
|
||||
},
|
||||
{
|
||||
"fieldname": "start_time",
|
||||
"fieldtype": "Time",
|
||||
"label": "Start Time"
|
||||
},
|
||||
{
|
||||
"fieldname": "end_time",
|
||||
"fieldtype": "Time",
|
||||
"label": "End Time"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-03-29 10:43:50.889723",
|
||||
"modified": "2022-03-30 10:04:17.530698",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate Request",
|
||||
|
||||
@@ -1,8 +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 LMSCertificateRequest(Document):
|
||||
pass
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_certificate_request(course, day, start_time, end_time):
|
||||
evaluator = frappe.db.get_value("LMS Course", course, "evaluator")
|
||||
frappe.get_doc({
|
||||
"doctype": "LMS Certificate Request",
|
||||
"course": course,
|
||||
"day": day,
|
||||
"start_time": start_time,
|
||||
"end_time": end_time
|
||||
}).save(ignore_permissions=True)
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
</div>
|
||||
|
||||
{% elif is_instructor(course.name) and not course.published and course.status != "Under Review" %}
|
||||
{% elif is_instructor(course.name) and not course.published and course.status == "Under Review" %}
|
||||
<div class="button wide-button is-primary" id="submit-for-review" data-course="{{ course.name | urlencode }}">
|
||||
{{ _("Submit for Review") }}
|
||||
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
|
||||
@@ -195,7 +195,7 @@
|
||||
{{ _("Get Certificate") }}
|
||||
</a>
|
||||
{% elif course.grant_certificate_after == "Evaluation" %}
|
||||
<a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}">
|
||||
<a class="button wide-button is-secondary mt-2" id="apply-certificate" data-course="{{ course.name }}">
|
||||
{{ _("Apply for Certificate") }}
|
||||
</a>
|
||||
{% elif progress == 100 %}
|
||||
@@ -204,9 +204,49 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="slot-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="font-weight-bold">{{ _("Pick a slot") }}</div>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="slot-form">
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label reqd" style="padding-right: 0px;">{{ _("Date") }}</label>
|
||||
</div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<input type="text" autocomplete="off" class="input-with-feedback form-control bold" data-fieldtype="Date">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label reqd" style="padding-right: 0px;">{{ _("Slots") }}</label>
|
||||
</div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<div class="slots"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="btn btn-sm btn-primary" data-course="{{ course.name | urlencode}}" id="submit-slot">
|
||||
{{ _("Submit") }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
@@ -38,6 +38,14 @@ frappe.ready(() => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
|
||||
$("#apply-certificate").click((e) => {
|
||||
apply_cetificate(e);
|
||||
});
|
||||
|
||||
$(".slot").click((e) => {
|
||||
submit_slot(e);
|
||||
});
|
||||
|
||||
$(document).scroll(function() {
|
||||
let timer;
|
||||
clearTimeout(timer);
|
||||
@@ -236,4 +244,41 @@ const submit_for_review = (e) => {
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
const apply_cetificate = (e) => {
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.course_evaluator.course_evaluator.get_schedule",
|
||||
args: {
|
||||
"course": $(e.currentTarget).data("course")
|
||||
},
|
||||
callback: (data) => {
|
||||
let options = "";
|
||||
data.message.forEach((obj) => {
|
||||
options += `<button class="btn btn-sm btn-secondary mr-3 slot"
|
||||
data-course="${$(e.currentTarget).data("course")}"
|
||||
data-day="${obj.day}" data-start="${obj.start_time}" data-end="${obj.end_time}">
|
||||
${obj.day} ${obj.start_time} - ${obj.end_time}</button>`;
|
||||
});
|
||||
e.preventDefault();
|
||||
$("#slot-modal .slots").html(options);
|
||||
$("#slot-modal").modal("show");
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
const submit_slot = (e) => {
|
||||
const target = $(e.currentTarget);
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_certificate_request",
|
||||
args: {
|
||||
"course": target.data("course"),
|
||||
"day": target.data("day"),
|
||||
"start_time": target.data("start"),
|
||||
"end_time": target.data("end")
|
||||
},
|
||||
callback: (data) => {
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user