feat: conditions for evaluation eligibility
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
|
||||
frappe.ui.form.on('LMS Certificate Evaluation', {
|
||||
refresh: function(frm) {
|
||||
frm.add_custom_button(__("Create LMS Certificate"), () => {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "lms.lms.doctype.lms_certificate_evaluation.lms_certificate_evaluation.create_lms_certificate",
|
||||
frm: frm
|
||||
if (frm.doc.status == "Pass") {
|
||||
frm.add_custom_button(__("Create LMS Certificate"), () => {
|
||||
frappe.model.open_mapped_doc({
|
||||
method: "lms.lms.doctype.lms_certificate_evaluation.lms_certificate_evaluation.create_lms_certificate",
|
||||
frm: frm
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
|
||||
frappe.ui.form.on('LMS Certificate Request', {
|
||||
refresh: function(frm) {
|
||||
console.log(frm)
|
||||
if (frm.doc.status == "Pass") {
|
||||
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
|
||||
});
|
||||
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
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onload: function(frm) {
|
||||
|
||||
@@ -344,3 +344,26 @@ def get_popular_courses():
|
||||
|
||||
course_membership = sorted(course_membership, key = lambda x: x.get("members"), reverse=True)
|
||||
return course_membership[:3]
|
||||
|
||||
def get_evaluation_details(course):
|
||||
info = frappe.db.get_value("LMS Course", course, ["grant_certificate_after", "max_attempts"], as_dict=True)
|
||||
|
||||
request = frappe.db.get_value("LMS Certificate Request", {
|
||||
"course": course.name,
|
||||
"member": frappe.session.user,
|
||||
"date": [">=", getdate()]
|
||||
}, ["date", "start_time", "end_time"],
|
||||
as_dict=True)
|
||||
|
||||
no_of_attempts = frappe.db.count("LMS Certificate Evaluation", {
|
||||
"course": course.name,
|
||||
"member": frappe.session.user,
|
||||
"status": ["!=", "Pass"],
|
||||
"creation": [">=", add_months(getdate(), -2)]
|
||||
})
|
||||
|
||||
return {
|
||||
"eligible": info.grant_certificate_after == "Evaluation" and not request and no_of_attempts < info.max_attempts,
|
||||
"request": request,
|
||||
"no_of_attempts": no_of_attempts
|
||||
}
|
||||
|
||||
@@ -204,10 +204,12 @@
|
||||
<a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}">
|
||||
{{ _("Get Certificate") }}
|
||||
</a>
|
||||
{% elif course.grant_certificate_after == "Evaluation" and not certificate_request %}
|
||||
{% elif eligible_for_evaluation %}
|
||||
<a class="button wide-button is-secondary mt-2" id="apply-certificate" data-course="{{ course.name }}">
|
||||
{{ _("Apply for Certificate") }}
|
||||
</a>
|
||||
{% elif no_of_attempts < course.max_attempt %}
|
||||
<p> {{ _("You have exceeded the maximum number of attempts allowed to appear for evaluations for this course.") }} </p>
|
||||
{% elif progress == 100 %}
|
||||
<div class="button wide-button is-secondary mt-4" id="certification" data-course="{{ course.name }}">
|
||||
{{ _("Get Certificate") }}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import frappe
|
||||
from lms.lms.doctype.lms_settings.lms_settings import check_profile_restriction
|
||||
from lms.lms.utils import get_membership, is_instructor, is_certified
|
||||
from lms.lms.utils import get_membership, is_instructor, is_certified, eligible_for_certificate_evaluation
|
||||
from frappe.utils import add_months, getdate
|
||||
|
||||
def get_context(context):
|
||||
@@ -35,20 +35,9 @@ def get_context(context):
|
||||
context.restriction = check_profile_restriction()
|
||||
context.show_start_learing_cta = show_start_learing_cta(course, membership, context.restriction)
|
||||
context.certificate = is_certified(course.name)
|
||||
context.certificate_request = frappe.db.get_value("LMS Certificate Request", {
|
||||
"course": course.name,
|
||||
"member": frappe.session.user,
|
||||
"date": [">=", getdate()]
|
||||
}, ["date", "start_time", "end_time"],
|
||||
as_dict=True)
|
||||
context.eligible_for_evaluation = eligible_for_certificate_evaluation()
|
||||
context.certificate_request =
|
||||
|
||||
context.no_of_attempts = frappe.db.count("LMS Certificate Evaluation", {
|
||||
"course": course.name,
|
||||
"member": frappe.session.user,
|
||||
"status": ["!=", "Pass"],
|
||||
"creation": [">=", add_months(getdate(), -2)]
|
||||
})
|
||||
print(context.certificate_request)
|
||||
if context.course.upcoming:
|
||||
context.is_user_interested = get_user_interest(context.course.name)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user