feat: max attempts fields

This commit is contained in:
Jannat Patel
2022-04-25 18:48:31 +05:30
parent 3bbe5d33d3
commit 430a2bc08d
3 changed files with 47 additions and 14 deletions

View File

@@ -14,6 +14,7 @@
"end_time",
"column_break_5",
"rating",
"status",
"summary"
],
"fields": [
@@ -75,11 +76,17 @@
"fieldtype": "Data",
"label": "Member Name",
"read_only": 1
},
{
"fieldname": "status",
"fieldtype": "Select",
"label": "Status",
"options": "Pass\nFail"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-06 11:44:17.051279",
"modified": "2022-04-25 12:14:28.262851",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Evaluation",

View File

@@ -35,9 +35,12 @@
"certification_section",
"enable_certification",
"expiry",
"column_break_22",
"section_break_22",
"grant_certificate_after",
"evaluator",
"column_break_22",
"max_attempts",
"reapplication",
"pricing_section",
"paid_certificate",
"currency",
@@ -212,6 +215,24 @@
"fieldtype": "Link",
"label": "Currency",
"options": "Currency"
},
{
"default": "1",
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
"fieldname": "max_attempts",
"fieldtype": "Int",
"label": "Max Number of Attempts for Evaluations"
},
{
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
"fieldname": "reapplication",
"fieldtype": "Select",
"label": "Re-application After (Months)",
"options": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12"
},
{
"fieldname": "section_break_22",
"fieldtype": "Section Break"
}
],
"is_published_field": "published",
@@ -237,7 +258,7 @@
"link_fieldname": "course"
}
],
"modified": "2022-04-08 14:36:22.254656",
"modified": "2022-04-25 17:47:23.648958",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",

View File

@@ -12,8 +12,9 @@ def get_context(context):
raise frappe.Redirect
course = frappe.db.get_value("LMS Course", course_name,
["name", "title", "image", "short_introduction", "description", "published", "upcoming", "disable_self_learning", "status",
"video_link", "enable_certification", "grant_certificate_after", "paid_certificate", "price_certificate", "currency"],
["name", "title", "image", "short_introduction", "description", "published", "upcoming", "disable_self_learning",
"status", "video_link", "enable_certification", "grant_certificate_after", "paid_certificate",
"price_certificate", "currency", "max_attempts", "reapplication"],
as_dict=True)
if course is None:
@@ -33,14 +34,19 @@ 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",
{
context.certificate_request = frappe.db.get_value("LMS Certificate Request", {
"course": course.name,
"member": frappe.session.user
},
["date", "start_time", "end_time"],
}, ["date", "start_time", "end_time"],
as_dict=True)
context.no_of_attempts = frappe.db.count("LMS Certificate Evaluation", {
"course": course.name,
"member": frappe.session.user,
"status" != "Pass",
"creation": [">=", add_days()]
})
if context.course.upcoming:
context.is_user_interested = get_user_interest(context.course.name)
@@ -52,11 +58,10 @@ def get_context(context):
}
def get_user_interest(course):
return frappe.db.count("LMS Course Interest",
{
"course": course,
"user": frappe.session.user
})
return frappe.db.count("LMS Course Interest", {
"course": course,
"user": frappe.session.user
})
def show_start_learing_cta(course, membership, restriction):
return not course.disable_self_learning and not membership and not course.upcoming and not restriction.get("restrict") and not is_instructor(course.name)