feat: request for certification
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"actions": [],
|
||||
"allow_rename": 1,
|
||||
"autoname": "field:evaluator",
|
||||
"creation": "2022-03-29 10:51:47.667284",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -14,7 +15,8 @@
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Link",
|
||||
"label": "Evaluator",
|
||||
"options": "User"
|
||||
"options": "User",
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "schedule",
|
||||
@@ -25,10 +27,11 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-03-29 12:47:10.975155",
|
||||
"modified": "2022-04-01 15:14:03.300260",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Course Evaluator",
|
||||
"naming_rule": "By fieldname",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
@@ -46,6 +49,5 @@
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "evaluator"
|
||||
"states": []
|
||||
}
|
||||
@@ -8,8 +8,9 @@
|
||||
"field_order": [
|
||||
"course",
|
||||
"member",
|
||||
"start",
|
||||
"end",
|
||||
"date",
|
||||
"start_time",
|
||||
"end_time",
|
||||
"column_break_5",
|
||||
"rating",
|
||||
"summary"
|
||||
@@ -30,19 +31,9 @@
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Member",
|
||||
"options": "LMS Batch Membership",
|
||||
"options": "User",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "start",
|
||||
"fieldtype": "Datetime",
|
||||
"label": "Start"
|
||||
},
|
||||
{
|
||||
"fieldname": "end",
|
||||
"fieldtype": "Datetime",
|
||||
"label": "End"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_5",
|
||||
"fieldtype": "Column Break"
|
||||
@@ -51,17 +42,37 @@
|
||||
"fieldname": "rating",
|
||||
"fieldtype": "Rating",
|
||||
"in_list_view": 1,
|
||||
"label": "Rating"
|
||||
"label": "Rating",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "summary",
|
||||
"fieldtype": "Text",
|
||||
"label": "Summary"
|
||||
},
|
||||
{
|
||||
"fieldname": "date",
|
||||
"fieldtype": "Date",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Date",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "start_time",
|
||||
"fieldtype": "Time",
|
||||
"label": "Start Time",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "end_time",
|
||||
"fieldtype": "Time",
|
||||
"label": "End Time"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-03-29 09:48:45.682678",
|
||||
"modified": "2022-04-01 16:26:39.168390",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate Evaluation",
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('LMS Certificate Request', {
|
||||
// refresh: function(frm) {
|
||||
|
||||
// }
|
||||
refresh: function(frm) {
|
||||
frm.add_custom_button(__("Create LMS Certificate Evaluation"), () => {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_lms_certificate_evaluation",
|
||||
frm: frm
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
"fieldname": "course",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Course",
|
||||
"options": "LMS Course",
|
||||
"reqd": 1
|
||||
@@ -29,19 +30,24 @@
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Member",
|
||||
"options": "LMS Batch Membership",
|
||||
"options": "User",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fetch_from": "course.evaluator",
|
||||
"fieldname": "evaluator",
|
||||
"fieldtype": "Data",
|
||||
"fieldtype": "Link",
|
||||
"label": "Evaluator",
|
||||
"options": "Course Evaluator",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "date",
|
||||
"fieldtype": "Date",
|
||||
"label": "Date"
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Date",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "day",
|
||||
@@ -52,12 +58,16 @@
|
||||
{
|
||||
"fieldname": "start_time",
|
||||
"fieldtype": "Time",
|
||||
"label": "Start Time"
|
||||
"in_list_view": 1,
|
||||
"label": "Start Time",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "end_time",
|
||||
"fieldtype": "Time",
|
||||
"label": "End Time"
|
||||
"in_list_view": 1,
|
||||
"label": "End Time",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_4",
|
||||
@@ -66,7 +76,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-03-30 10:04:17.530698",
|
||||
"modified": "2022-04-01 15:29:31.553492",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate Request",
|
||||
|
||||
@@ -3,17 +3,38 @@
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
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")
|
||||
def create_certificate_request(course, date, day, start_time, end_time):
|
||||
is_member = frappe.db.exists({
|
||||
"doctype": "LMS Batch Membership",
|
||||
"course": course,
|
||||
"member": frappe.session.user
|
||||
})
|
||||
|
||||
if not is_member:
|
||||
return
|
||||
|
||||
frappe.get_doc({
|
||||
"doctype": "LMS Certificate Request",
|
||||
"course": course,
|
||||
"member": frappe.session.user,
|
||||
"date": date,
|
||||
"day": day,
|
||||
"start_time": start_time,
|
||||
"end_time": end_time
|
||||
}).save(ignore_permissions=True)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_lms_certificate_evaluation(source_name, target_doc=None):
|
||||
doc = get_mapped_doc("LMS Certificate Request", source_name, {
|
||||
"LMS Certificate Request": {
|
||||
"doctype": "LMS Certificate Evaluation"
|
||||
}
|
||||
}, target_doc)
|
||||
return doc
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"actions": [],
|
||||
"autoname": "format:CERT-{#####}",
|
||||
"creation": "2021-08-16 15:47:19.494055",
|
||||
"doctype": "DocType",
|
||||
"editable_grid": 1,
|
||||
@@ -45,10 +46,11 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2021-08-16 15:47:19.494055",
|
||||
"modified": "2022-04-01 16:41:10.213765",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certification",
|
||||
"naming_rule": "Expression",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
@@ -66,5 +68,6 @@
|
||||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -214,7 +214,7 @@
|
||||
"link_fieldname": "course"
|
||||
}
|
||||
],
|
||||
"modified": "2022-03-29 14:56:03.989375",
|
||||
"modified": "2022-04-01 15:19:13.075063",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
@@ -248,6 +248,7 @@
|
||||
}
|
||||
],
|
||||
"search_fields": "title",
|
||||
"show_title_field_in_link": 1,
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
|
||||
@@ -105,6 +105,12 @@
|
||||
{{ _("You have opted to be notified for this course. You will receive an email when the course becomes available.") }}
|
||||
</div>
|
||||
|
||||
{% if certificate_request %}
|
||||
<p> <b>{{ _("Evaluation On") }}</b>
|
||||
{{ _(": {0} at {1}").format(frappe.utils.format_date(certificate_request.date, "medium"),
|
||||
frappe.utils.format_time(certificate_request.start_time, "short")) }} </p>
|
||||
{% endif %}
|
||||
|
||||
{% if course.status == "Under Review" %}
|
||||
<div class="mb-4">
|
||||
{{ _("Your course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }}
|
||||
@@ -194,7 +200,7 @@
|
||||
<a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</a>
|
||||
{% elif course.grant_certificate_after == "Evaluation" %}
|
||||
{% elif course.grant_certificate_after == "Evaluation" and not certificate_request %}
|
||||
<a class="button wide-button is-secondary mt-2" id="apply-certificate" data-course="{{ course.name }}">
|
||||
{{ _("Apply for Certificate") }}
|
||||
</a>
|
||||
@@ -211,26 +217,28 @@
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="font-weight-bold">{{ _("Pick a slot") }}</div>
|
||||
<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">
|
||||
<p class="">{{ _("This course requires you to complete an evaluation to get certified. Please pick a slot based on your convenience for the evaluations. ") }}</p>
|
||||
<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 id="slot-date" type="date" class="input-with-feedback form-control bold" data-fieldtype="Date">
|
||||
<input type="date" class="input-with-feedback form-control bold" data-fieldtype="Date"
|
||||
id="slot-date" min="{{ frappe.utils.format_date(frappe.utils.getdate(), 'yyyy-mm-dd') }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="clearfix">
|
||||
<label class="control-label reqd" style="padding-right: 0px;">{{ _("Slots") }}</label>
|
||||
<label class="control-label reqd slot-label hide" style="padding-right: 0px;">{{ _("Slots") }}</label>
|
||||
</div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
@@ -238,12 +246,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p id="no-slots-message" class="small text-danger hide"> {{ _("There are no slots available on this day.") }} </p>
|
||||
</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>
|
||||
|
||||
@@ -1,62 +1,62 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
hide_wrapped_mentor_cards();
|
||||
hide_wrapped_mentor_cards();
|
||||
|
||||
$("#cancel-request").click((e) => {
|
||||
cancel_mentor_request(e);
|
||||
});
|
||||
$("#cancel-request").click((e) => {
|
||||
cancel_mentor_request(e);
|
||||
});
|
||||
|
||||
$(".join-batch").click((e) => {
|
||||
join_course(e)
|
||||
});
|
||||
$(".join-batch").click((e) => {
|
||||
join_course(e)
|
||||
});
|
||||
|
||||
$(".view-all-mentors").click((e) => {
|
||||
view_all_mentors(e);
|
||||
});
|
||||
$(".view-all-mentors").click((e) => {
|
||||
view_all_mentors(e);
|
||||
});
|
||||
|
||||
$(".review-link").click((e) => {
|
||||
show_review_dialog(e);
|
||||
});
|
||||
$(".review-link").click((e) => {
|
||||
show_review_dialog(e);
|
||||
});
|
||||
|
||||
$(".icon-rating").click((e) => {
|
||||
highlight_rating(e);
|
||||
});
|
||||
$(".icon-rating").click((e) => {
|
||||
highlight_rating(e);
|
||||
});
|
||||
|
||||
$("#submit-review").click((e) => {
|
||||
submit_review(e);
|
||||
})
|
||||
$("#submit-review").click((e) => {
|
||||
submit_review(e);
|
||||
})
|
||||
|
||||
$("#notify-me").click((e) => {
|
||||
notify_user(e);
|
||||
})
|
||||
$("#notify-me").click((e) => {
|
||||
notify_user(e);
|
||||
})
|
||||
|
||||
$("#certification").click((e) => {
|
||||
create_certificate(e);
|
||||
});
|
||||
$("#certification").click((e) => {
|
||||
create_certificate(e);
|
||||
});
|
||||
|
||||
$("#submit-for-review").click((e) => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
$("#submit-for-review").click((e) => {
|
||||
submit_for_review(e);
|
||||
});
|
||||
|
||||
$("#apply-certificate").click((e) => {
|
||||
apply_cetificate(e);
|
||||
});
|
||||
$("#apply-certificate").click((e) => {
|
||||
apply_cetificate(e);
|
||||
});
|
||||
|
||||
$(".slot").click((e) => {
|
||||
submit_slot(e);
|
||||
});
|
||||
$("#slot-date").on("change", (e) => {
|
||||
display_slots(e);
|
||||
});
|
||||
|
||||
$("#slot-date").on("change", (e) => {
|
||||
|
||||
});
|
||||
$(document).on("click", ".slot", (e) => {
|
||||
submit_slot(e);
|
||||
});
|
||||
|
||||
$(document).scroll(function() {
|
||||
let timer;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => { handle_overlay_display.apply(this, arguments); }, 500);
|
||||
});
|
||||
$(document).scroll(function() {
|
||||
let timer;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => { handle_overlay_display.apply(this, arguments); }, 500);
|
||||
});
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
var hide_wrapped_mentor_cards = () => {
|
||||
var offset_top_prev;
|
||||
@@ -259,7 +259,7 @@ const apply_cetificate = (e) => {
|
||||
callback: (data) => {
|
||||
let options = "";
|
||||
data.message.forEach((obj) => {
|
||||
options += `<button class="btn btn-sm btn-secondary mr-3 slot"
|
||||
options += `<button type="button" class="btn btn-sm btn-secondary mr-3 slot hide"
|
||||
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>`;
|
||||
@@ -272,17 +272,40 @@ const apply_cetificate = (e) => {
|
||||
};
|
||||
|
||||
const submit_slot = (e) => {
|
||||
const target = $(e.currentTarget);
|
||||
e.preventDefault();
|
||||
const slot = $(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")
|
||||
"course": slot.data("course"),
|
||||
"date": $("#slot-date").val(),
|
||||
"day": slot.data("day"),
|
||||
"start_time": slot.data("start"),
|
||||
"end_time": slot.data("end")
|
||||
},
|
||||
callback: (data) => {
|
||||
|
||||
$("#slot-modal").modal("hide");
|
||||
frappe.msgprint(__("Your slot has been booked. Prepare well for the evaluations."));
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const display_slots = (e) => {
|
||||
const weekday = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
|
||||
const day = weekday[new Date($(e.currentTarget).val()).getDay()]
|
||||
|
||||
$(".slot").addClass("hide");
|
||||
$(".slot-label").addClass("hide");
|
||||
|
||||
if ($(`[data-day='${day}']`).length) {
|
||||
$(".slot-label").removeClass("hide");
|
||||
$(`[data-day='${day}']`).removeClass("hide");
|
||||
$("#no-slots-message").addClass("hide");
|
||||
} else {
|
||||
$("#no-slots-message").removeClass("hide");
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
@@ -30,10 +30,19 @@ def get_context(context):
|
||||
membership = get_membership(course.name, frappe.session.user)
|
||||
context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else ""
|
||||
context.membership = membership
|
||||
if context.course.upcoming:
|
||||
context.is_user_interested = get_user_interest(context.course.name)
|
||||
context.restriction = check_profile_restriction()
|
||||
context.show_start_learing_cta = show_start_learing_cta(course, membership, context.restriction)
|
||||
context.certificate_request = frappe.db.get_value("LMS Certificate Request",
|
||||
{
|
||||
"course": course.name,
|
||||
"member": frappe.session.user
|
||||
},
|
||||
["date", "start_time", "end_time"],
|
||||
as_dict=True)
|
||||
|
||||
if context.course.upcoming:
|
||||
context.is_user_interested = get_user_interest(context.course.name)
|
||||
|
||||
context.metatags = {
|
||||
"title": course.title,
|
||||
"image": course.image,
|
||||
|
||||
Reference in New Issue
Block a user