Merge pull request #319 from pateljannat/certification

This commit is contained in:
Jannat Patel
2022-04-07 14:58:27 +05:30
committed by GitHub
41 changed files with 965 additions and 215 deletions

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2022, Frappe and contributors
// For license information, please see license.txt
frappe.ui.form.on('Course Evaluator', {
onload: (frm) => {
frm.set_query('evaluator', function(doc) {
return {
filters: {
"ignore_user_type": 1,
}
};
});
}
});

View File

@@ -0,0 +1,53 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:evaluator",
"creation": "2022-03-29 10:51:47.667284",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"evaluator",
"schedule"
],
"fields": [
{
"fieldname": "evaluator",
"fieldtype": "Link",
"label": "Evaluator",
"options": "User",
"unique": 1
},
{
"fieldname": "schedule",
"fieldtype": "Table",
"label": "Schedule",
"options": "Evaluator Schedule"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-01 15:14:03.300260",
"modified_by": "Administrator",
"module": "LMS",
"name": "Course Evaluator",
"naming_rule": "By fieldname",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

View File

@@ -0,0 +1,38 @@
# Copyright (c) 2022, Frappe and contributors
# For license information, please see license.txt
import frappe
from frappe import _
from frappe.model.document import Document
class CourseEvaluator(Document):
def validate(self):
self.validate_time_slots()
def validate_time_slots(self):
for schedule in self.schedule:
if schedule.start_time >= schedule.end_time:
frappe.throw(_("Start Time cannot be greater than End Time"))
self.validate_overlaps(schedule)
def validate_overlaps(self, schedule):
same_day_slots = list(filter(lambda x: x.day == schedule.day and x.name != schedule.name , self.schedule))
overlap = False
for slot in same_day_slots:
if schedule.start_time <= slot.start_time < schedule.end_time:
overlap = True
if schedule.start_time < slot.end_time <= schedule.end_time:
overlap = True
if slot.start_time < schedule.start_time and schedule.end_time < slot.end_time:
overlap = True
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"])

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2022, Frappe and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestCourseEvaluator(FrappeTestCase):
pass

View File

@@ -0,0 +1,50 @@
{
"actions": [],
"autoname": "autoincrement",
"creation": "2022-03-29 11:09:47.726629",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"day",
"start_time",
"end_time"
],
"fields": [
{
"fieldname": "day",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Day",
"options": "Sunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday",
"reqd": 1
},
{
"fieldname": "start_time",
"fieldtype": "Time",
"in_list_view": 1,
"label": "Start Time",
"reqd": 1
},
{
"fieldname": "end_time",
"fieldtype": "Time",
"in_list_view": 1,
"label": "End Time",
"reqd": 1
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2022-03-29 12:58:22.229033",
"modified_by": "Administrator",
"module": "LMS",
"name": "Evaluator Schedule",
"naming_rule": "Autoincrement",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}

View File

@@ -0,0 +1,8 @@
# Copyright (c) 2022, Frappe and contributors
# For license information, please see license.txt
# import frappe
from frappe.model.document import Document
class EvaluatorSchedule(Document):
pass

View File

@@ -115,7 +115,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-03-09 15:17:15.386067",
"modified": "2022-03-29 09:47:05.007133",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Batch Membership",
@@ -135,7 +135,9 @@
}
],
"quick_entry": 1,
"show_title_field_in_link": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": []
"states": [],
"title_field": "member"
}

View File

@@ -0,0 +1,14 @@
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('LMS Certificate', {
onload: function (frm) {
frm.set_query("member", function (doc) {
return {
filters: {
"ignore_user_type": 1,
}
};
});
}
});

View File

@@ -5,25 +5,19 @@
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"student",
"issue_date",
"column_break_3",
"course",
"member",
"member_name",
"column_break_3",
"issue_date",
"expiry_date"
],
"fields": [
{
"fieldname": "student",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Student",
"options": "User"
},
{
"fieldname": "issue_date",
"fieldtype": "Date",
"label": "Issue Date"
"label": "Issue Date",
"reqd": 1
},
{
"fieldname": "column_break_3",
@@ -35,20 +29,37 @@
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Course",
"options": "LMS Course"
"options": "LMS Course",
"reqd": 1
},
{
"fieldname": "expiry_date",
"fieldtype": "Date",
"label": "Expiry Date"
},
{
"fieldname": "member",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Member",
"options": "User",
"reqd": 1
},
{
"fetch_from": "member.full_name",
"fieldname": "member_name",
"fieldtype": "Data",
"label": "Member Name",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2021-08-16 15:47:19.494055",
"modified": "2022-04-06 11:49:36.077370",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certification",
"name": "LMS Certificate",
"owner": "Administrator",
"permissions": [
{
@@ -66,5 +77,7 @@
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"title_field": "member_name",
"track_changes": 1
}

View File

@@ -8,16 +8,16 @@ from frappe import _
from frappe.utils.pdf import get_pdf
from lms.lms.utils import is_certified
class LMSCertification(Document):
class LMSCertificate(Document):
def validate(self):
certificates = frappe.get_all("LMS Certification", {
"student": self.student,
certificates = frappe.get_all("LMS Certificate", {
"member": self.member,
"course": self.course,
"expiry_date": [">", nowdate()]
})
if len(certificates):
full_name = frappe.db.get_value("User", self.student, "full_name")
full_name = frappe.db.get_value("User", self.member, "full_name")
course_name = frappe.db.get_value("LMS Course", self.course, "title")
frappe.throw(_("There is already a valid certificate for user {0} for the course {1}").format(full_name, course_name))
@@ -35,8 +35,8 @@ def create_certificate(course):
expiry_date = add_years(nowdate(), expires_after_yrs)
certificate = frappe.get_doc({
"doctype": "LMS Certification",
"student": frappe.session.user,
"doctype": "LMS Certificate",
"member": frappe.session.user,
"course": course,
"issue_date": nowdate(),
"expiry_date": expiry_date

View File

@@ -4,19 +4,19 @@
import frappe
import unittest
from lms.lms.doctype.lms_course.test_lms_course import new_course
from lms.lms.doctype.lms_certification.lms_certification import create_certificate
from lms.lms.doctype.lms_certificate.lms_certificate import create_certificate
from frappe.utils import nowdate, add_years, cint
class TestLMSCertification(unittest.TestCase):
class TestLMSCertificate(unittest.TestCase):
def test_certificate_creation(self):
course = new_course("Test Certificate", 1, 2)
certificate = create_certificate(course.name)
self.assertEqual(certificate.student, "Administrator")
self.assertEqual(certificate.member, "Administrator")
self.assertEqual(certificate.course, course.name)
self.assertEqual(certificate.issue_date, nowdate())
self.assertEqual(certificate.expiry_date, add_years(nowdate(), cint(course.expiry)))
frappe.db.delete("LMS Certification", certificate.name)
frappe.db.delete("LMS Certificate", certificate.name)
frappe.db.delete("LMS Course", course.name)

View File

@@ -0,0 +1,32 @@
// Copyright (c) 2022, Frappe and contributors
// For license information, please see license.txt
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
});
});
},
onload: function(frm) {
frm.set_query("course", function(doc) {
return {
filters: {
"enable_certification": true,
"grant_certificate_after": "Evaluation"
}
};
});
frm.set_query('member', function(doc) {
return {
filters: {
"ignore_user_type": 1,
}
};
});
}
});

View File

@@ -0,0 +1,105 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2022-03-29 09:32:16.769951",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"course",
"member",
"member_name",
"date",
"start_time",
"end_time",
"column_break_5",
"rating",
"summary"
],
"fields": [
{
"fieldname": "course",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Course",
"options": "LMS Course",
"reqd": 1
},
{
"fieldname": "member",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Member",
"options": "User",
"reqd": 1
},
{
"fieldname": "column_break_5",
"fieldtype": "Column Break"
},
{
"fieldname": "rating",
"fieldtype": "Rating",
"in_list_view": 1,
"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"
},
{
"fetch_from": "member.full_name",
"fieldname": "member_name",
"fieldtype": "Data",
"label": "Member Name",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-06 11:44:17.051279",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Evaluation",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"title_field": "member_name"
}

View File

@@ -0,0 +1,18 @@
# Copyright (c) 2022, Frappe and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
from frappe.model.mapper import get_mapped_doc
class LMSCertificateEvaluation(Document):
pass
@frappe.whitelist()
def create_lms_certificate(source_name, target_doc=None):
doc = get_mapped_doc("LMS Certificate Evaluation", source_name, {
"LMS Certificate Evaluation": {
"doctype": "LMS Certificate"
}
}, target_doc)
return doc

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2022, Frappe and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestLMSCertificateEvaluation(FrappeTestCase):
pass

View File

@@ -0,0 +1,23 @@
// Copyright (c) 2022, Frappe and contributors
// For license information, please see license.txt
frappe.ui.form.on('LMS Certificate Request', {
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
});
});
},
onload: function(frm) {
frm.set_query('member', function(doc) {
return {
filters: {
"ignore_user_type": 1,
}
};
});
}
});

View File

@@ -0,0 +1,110 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2022-03-29 10:43:50.889723",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"course",
"member",
"member_name",
"evaluator",
"column_break_4",
"date",
"day",
"start_time",
"end_time"
],
"fields": [
{
"fieldname": "course",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Course",
"options": "LMS Course",
"reqd": 1
},
{
"fieldname": "member",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Member",
"options": "User",
"reqd": 1
},
{
"fetch_from": "course.evaluator",
"fieldname": "evaluator",
"fieldtype": "Link",
"label": "Evaluator",
"options": "Course Evaluator",
"read_only": 1
},
{
"fieldname": "date",
"fieldtype": "Date",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Date",
"reqd": 1
},
{
"fieldname": "day",
"fieldtype": "Select",
"label": "Day",
"options": "Sunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday"
},
{
"fieldname": "start_time",
"fieldtype": "Time",
"in_list_view": 1,
"label": "Start Time",
"reqd": 1
},
{
"fieldname": "end_time",
"fieldtype": "Time",
"in_list_view": 1,
"label": "End Time",
"reqd": 1
},
{
"fieldname": "column_break_4",
"fieldtype": "Column Break"
},
{
"fetch_from": "member.full_name",
"fieldname": "member_name",
"fieldtype": "Data",
"label": "Member Name",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2022-04-06 11:33:33.711545",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate Request",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"title_field": "member_name"
}

View File

@@ -0,0 +1,40 @@
# Copyright (c) 2022, Frappe and contributors
# For license information, please see license.txt
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, 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

View File

@@ -0,0 +1,9 @@
# Copyright (c) 2022, Frappe and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestLMSCertificateRequest(FrappeTestCase):
pass

View File

@@ -1,14 +0,0 @@
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('LMS Certification', {
onload: function (frm) {
frm.set_query("student", function (doc) {
return {
filters: {
"ignore_user_type": 1,
}
};
});
}
});

View File

@@ -34,7 +34,14 @@
"related_courses",
"certification_section",
"enable_certification",
"expiry"
"expiry",
"column_break_22",
"grant_certificate_after",
"evaluator",
"pricing_section",
"paid_certificate",
"currency",
"price_certificate"
],
"fields": [
{
@@ -129,9 +136,8 @@
"default": "0",
"depends_on": "enable_certification",
"fieldname": "expiry",
"fieldtype": "Select",
"label": "Certification Expires After Years",
"options": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
"fieldtype": "Int",
"label": "Certification Expires After (Years)"
},
{
"fieldname": "related_courses",
@@ -161,6 +167,50 @@
{
"fieldname": "column_break_12",
"fieldtype": "Column Break"
},
{
"default": "0",
"depends_on": "enable_certification",
"fieldname": "paid_certificate",
"fieldtype": "Check",
"label": "Paid Certificate"
},
{
"fieldname": "column_break_22",
"fieldtype": "Column Break"
},
{
"depends_on": "enable_certification",
"fieldname": "grant_certificate_after",
"fieldtype": "Select",
"label": "Grant Certificate After",
"options": "Completion\nEvaluation"
},
{
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
"fieldname": "evaluator",
"fieldtype": "Link",
"label": "Evaluator",
"options": "Course Evaluator"
},
{
"depends_on": "eval: doc.grant_certificate_after == \"Evaluation\"",
"fieldname": "pricing_section",
"fieldtype": "Section Break",
"label": "Pricing"
},
{
"depends_on": "paid_certificate",
"fieldname": "price_certificate",
"fieldtype": "Currency",
"label": "Certificate Price"
},
{
"depends_on": "paid_certificate",
"fieldname": "currency",
"fieldtype": "Link",
"label": "Currency",
"options": "Currency"
}
],
"is_published_field": "published",
@@ -186,7 +236,7 @@
"link_fieldname": "course"
}
],
"modified": "2022-03-24 13:09:37.228855",
"modified": "2022-04-07 12:27:05.353788",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Course",
@@ -220,9 +270,10 @@
}
],
"search_fields": "title",
"show_title_field_in_link": 1,
"sort_field": "creation",
"sort_order": "DESC",
"states": [],
"title_field": "title",
"track_changes": 1
}
}

View File

@@ -170,9 +170,9 @@ def get_sorted_reviews(course):
return rating_percent
def is_certified(course):
certificate = frappe.get_all("LMS Certification",
certificate = frappe.get_all("LMS Certificate",
{
"student": frappe.session.user,
"member": frappe.session.user,
"course": course
})
if len(certificate):

View File

@@ -60,12 +60,18 @@
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{{ progress }}"
aria-valuemin="0" aria-valuemax="100" style="width:{{ progress }}%">
<span class="sr-only"> {{ progress }} Complete</span>
<span class="sr-only"> {{ progress }} {{ _("Complete") }} </span>
</div>
</div>
<div class="progress-percent">{{ progress }}% Completed</div>
<div class="progress-percent">{{ progress }}% {{ _("Completed") }} </div>
{% endif %}
{% if course.paid_certificate %}
<div class="certificate-price small mt-3">
{{ _("Certificate Price: ") }} {{ frappe.utils.fmt_money(course.price_certificate, 2, course.currency) }}
</div>
{% endif %}
<div class="course-card-footer">
<span class="">
{% set instructors = get_instructors(course.name) %}

View File

@@ -26,3 +26,7 @@ school.patches.v0_0.set_course_in_lesson #21-03-2022
school.patches.v0_0.set_status_in_course #21-03-2022
lms.patches.v0_0.change_published_field_data #25-03-2022
execute:frappe.delete_doc("Workspace", "School", ignore_missing=True, force=True)
[post_model_sync]
lms.patches.v0_0.certification_member_field_data #04-04-2022
lms.patches.v0_0.move_certification_to_certificate

View File

@@ -0,0 +1,7 @@
import frappe
def execute():
frappe.reload_doc("lms", "doctype", "lms_certification")
certificates = frappe.get_all("LMS Certification", fields=["name", "student"])
for certificate in certificates:
frappe.db.set_value("LMS Certification", certificate.name, "member", certificate.student)

View File

@@ -0,0 +1,12 @@
import frappe
def execute():
old = frappe.get_all("LMS Certification", fields=["name", "course", "student", "issue_date", "expiry_date"])
for data in old:
frappe.get_doc({
"doctype": "LMS Certificate",
"course": data.course,
"member": data.member or data.student,
"issue_date": data.issue_date,
"expiry_date": data.expiry_date
}).save(ignore_permissions=True)

View File

@@ -122,6 +122,7 @@ input[type=checkbox] {
display: flex;
flex-direction: column;
flex: 1 1 auto;
color: var(--text-color);
}
.course-card-title {
@@ -813,16 +814,6 @@ input[type=checkbox] {
.progress-percent {
margin: 0.5rem 0;
font-size: var(--text-base);
font-weight: 500;
}
.progress-percentage {
width: 100%;
font-size: 12px;
line-height: 165%;
letter-spacing: 0.02em;
color: #000000;
text-align: center;
}
pre {
@@ -856,67 +847,76 @@ pre {
.certificate-content {
padding: 2.5rem 3rem;
background-color: #FFFFFF;
}
.certificate-footer {
margin-top: 4.5rem;
display: flex;
display: flex;
justify-content: space-between;
width: 30%;
margin: 5rem auto 0;
}
.certificate-footer-item {
margin-right: 3.5rem;
.certificate-price {
font-weight: bold;
margin-bottom: 0.5rem;
}
.certificate-ribbon {
background-color: var(--primary-color);
margin-left: auto;
margin-right: 2.5rem;
width: 4.5rem;
padding: 0.5rem;
border-radius: var(--border-radius-md);
}
.certificate-heading {
font-size: 3rem;
font-size: 1.5rem;
font-weight: 500;
color: var(--gray-800);
color: var(--text-color);
}
.certificate-para {
margin-bottom: 4rem;
}
.certificate-card {
background: #FFFFFF;
border-radius: var(--border-radius-md);
position: relative;
box-shadow: var(--shadow-sm);
padding: 1rem;
text-align: center;
margin: 0 6rem;
}
.certificate-footer-item {
color: var(--text-color);
font-weight: 500;
}
.certificate-logo {
height: 20px;
height: 1.5rem;
}
@media (max-width: 1050px) {
.certificate-footer {
width: 50%;
}
}
@media (max-width: 768px) {
.certificate-heading {
font-size: 2rem;
}
.certificate-card {
margin: 0;
}
}
@media (max-width: 550px) {
.certificate-footer {
flex-direction: column;
}
.certificate-content {
padding: 1rem;
}
.certificate-footer-item {
margin-bottom: 1rem;
}
}
@media (max-width: 500px) {
.certificate-heading {
font-size: 1.5rem;
}
.certificate-content {
padding: 2.5rem 2rem;
}
.certificate-ribbon {
margin-right: 1rem;
width: 1.5rem;
}
.certificate-footer {
width: 100%;
}
}
.profile-card {
@@ -940,7 +940,7 @@ pre {
.empty-state-heading {
font-size: var(--text-xl);
color: var(--gray-900);
color: var(--text-color);
font-weight: 600;
}
@@ -953,7 +953,7 @@ pre {
background-image: url(/assets/frappe/icons/timeless/search.svg);
border: none;
border-radius: var(--border-radius-md);
font-size: var(--text-base);
font-size: var(--text-sm);
padding: 0.625rem 0.75rem;
height: 36px;
background-repeat: no-repeat;
@@ -978,11 +978,11 @@ pre {
.testimonial-author {
font-weight: 500;
font-size: var(--text-lg);
color: var(--gray-900);
color: var(--text-color);
}
.testimonial-review {
color: var(--gray-900);
color: var(--text-color);
margin-bottom: 2rem;
}
@@ -1208,7 +1208,8 @@ pre {
.course-overlay-content {
padding: 1.25rem;
font-size: var(--text-base);
color: var(--gray-900);
color: var(--text-color);
text-align: center;
}
.breadcrumb-destination {

View File

@@ -1,49 +1,50 @@
<div class="common-card-style">
<div class="certificate-content">
<img src="{{ logo }}" class="certificate-logo">
<div class="text-muted mt-18">
Completion Certificate
<div class="certificate-card">
<div class="certificate-ribbon">
<div class="certificate-content">
<img src="{{ logo }}" class="certificate-logo">
<div class="mt-20">
{{ _("This certifies that") }}
</div>
<div class="certificate-heading"> {{ member.full_name }} </div>
<div class="mt-2"> {{ _("has successfully completed the course on") }} </div>
<div class="certificate-heading"> {{ course.title }} </div>
<div class="certificate-footer">
{% if certificate.issue_date %}
<div class="">
<div class="certificate-footer-item">
{{ frappe.utils.format_date(certificate.issue_date, "medium") }}
</div>
<div>
{{ _("Issue date") }}
</div>
</div>
{% endif %}
{% if certificate.expiry_date %}
<div class="">
<div class="certificate-footer-item">
{{ frappe.utils.format_date(certificate.expiry_date, "medium") }}
</div>
<div>
{{ _("Expiry date") }}
</div>
</div>
{% endif %}
{% if instructor.full_name %}
<div class="">
<div class="certificate-footer-item">
{{ instructor.full_name }}
</div>
<div>
{{ _("Instructor") }}
</div>
</div>
{% endif %}
</div>
</div>
</div>
<div class="certificate-heading"> {{ course.title }} </div>
<div class="text-muted mt-18"> Awarded To </div>
<div class="certificate-heading"> {{ student.full_name }} </div> 
<div class="certificate-footer">
{% if certificate.issue_date %}
<div class="certificate-footer-item">
<div class="font-weight-bold">
{{ frappe.utils.format_date(certificate.issue_date, "medium") }}
</div>
<div>
Issue date
</div>
</div>
{% endif %}
{% if certificate.expiry_date %}
<div class="certificate-footer-item">
<div class="font-weight-bold">
{{ frappe.utils.format_date(certificate.expiry_date, "medium") }}
</div>
<div>
Expiry date
</div>
</div>
{% endif %}
{% if instructor.full_name %}
<div class="certificate-footer-item">
<div class="font-weight-bold">
{{ instructor.full_name }}
</div>
<div>
Instructor
</div>
</div>
{% endif %}
</div>
</div>
<div class="certificate-ribbon"></div>
</div>
<script src="/assets/lms/js/html2canvas.js"></script>

View File

@@ -244,7 +244,7 @@ const create_certificate = (e) => {
e.preventDefault();
course = $(".title").attr("data-course");
frappe.call({
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate",
method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
args: {
"course": course
},

View File

@@ -1,24 +1,21 @@
{% extends "templates/base.html" %}
{% from "www/macros/common_macro.html" import MentorsSection %}
{% block title %} {{ student.full_name }} - {{ course.title }} {% endblock %}
{% block title %} {{ member.full_name }} - {{ course.title }} {% endblock %}
{% block content %}
<div class="common-page-style">
<div class="container certificate-page">
<div class="breadcrumb">
<a class="dark-links" href="/courses">All Courses</a>
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
<a class="dark-links" href="/courses/{{ course.name }}">{{ course.title }}</a>
</div>
{% if certificate.student == frappe.session.user %}
<div class="d-flex justify-content-end mb-5">
<div class="button is-secondary pull-right" id="export-as-pdf" data-certificate="{{ certificate.name }}"
data-certificate-name="{{ student.full_name }} - {{ course.title }}">Export</div>
</div>
{% if certificate.member == frappe.session.user %}
<div class="button is-secondary pull-right mt-4" id="export-as-pdf" data-certificate="{{ certificate.name }}"
data-certificate-name="{{ member.full_name }} - {{ course.title }}">{{ _("Export") }}</div>
{% endif %}
<div class="breadcrumb">
<a class="dark-links" href="/courses">{{ _("All Courses") }}</a>
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
<a class="dark-links" href="/courses/{{ course.name }}">{{ course.title }}</a>
</div>
{% include "lms/templates/certificate.html" %}
</div>
</div>

View File

@@ -9,8 +9,8 @@ def get_context(context):
except KeyError:
redirect_to_course_list()
context.certificate = frappe.db.get_value("LMS Certification", certificate_name,
["name", "student", "issue_date", "expiry_date", "course"], as_dict=True)
context.certificate = frappe.db.get_value("LMS Certificate", certificate_name,
["name", "member", "issue_date", "expiry_date", "course"], as_dict=True)
if context.certificate.course != course_name:
redirect_to_course_list()
@@ -21,7 +21,7 @@ def get_context(context):
context.instructor = frappe.db.get_value("User", context.course.instructor,
["full_name", "username"], as_dict=True)
context.student = frappe.db.get_value("User", context.certificate.student,
context.member = frappe.db.get_value("User", context.certificate.member,
["full_name"], as_dict=True)
context.logo = frappe.db.get_single_value("Website Settings", "banner_image")

View File

@@ -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 class="mb-2"> <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.") }}
@@ -125,7 +131,7 @@
</div>
{% endif %}
<div class="vertically-center mb-2">
<div class="vertically-center justify-content-center mb-2">
<div class="">
<svg class="icon icon-md mr-1">
<use class="" href="#icon-users">
@@ -145,6 +151,12 @@
{% endif %}
</div>
{% if course.paid_certificate %}
<div class="certificate-price">
{{ _("Certificate Price:") }} {{ frappe.utils.fmt_money(course.price_certificate, 2, course.currency) }}
</div>
{% endif %}
{% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
membership.current_lesson
else '1.1' %}
@@ -155,7 +167,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" />
@@ -167,12 +179,6 @@
{{ _("Checkout Course") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
</a>
{% elif membership %}
<a class="button wide-button is-primary" id="continue-learning"
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
{{ _("Continue Learning") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
</a>
{% elif course.upcoming and not is_user_interested %}
<div class="button wide-button is-default"
id="notify-me" data-course="{{course.name | urlencode}}">
@@ -185,22 +191,73 @@
style="color: inherit;">
{{ _("Manage the course") }}
</a>
{% elif membership %}
<a class="button wide-button is-primary" id="continue-learning"
href="{{ get_lesson_url(course.name, lesson_index) }}{{ course.query_parameter }}">
{{ _("Continue Learning") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
</a>
{% endif %}
{% set certificate = is_certified(course.name) %}
{% set progress = frappe.utils.cint(membership.progress) %}
{% if membership and course.enable_certification %}
{% if certificate %}
<a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}">
{{ _("Get Certificate") }}
</a>
{% elif course.enable_certification and progress == 100 %}
{% 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>
{% elif progress == 100 %}
<div class="button wide-button is-secondary mt-4" id="certification" data-course="{{ course.name }}">
{{ _("Get Certificate") }}
</div>
{% endif %}
{% endif %}
</div>
</div>
<div class="modal fade" id="slot-modal" tabindex="-1" role="dialog" 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">&times;</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 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 slot-label hide" style="padding-right: 0px;">{{ _("Slots") }}</label>
</div>
<div class="control-input-wrapper">
<div class="control-input">
<div class="slots"></div>
</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>
</div>
</div>
{% endmacro %}

View File

@@ -1,50 +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);
});
$(document).scroll(function() {
let timer;
clearTimeout(timer);
timer = setTimeout(() => { handle_overlay_display.apply(this, arguments); }, 500);
});
$("#apply-certificate").click((e) => {
apply_cetificate(e);
});
})
$("#slot-date").on("change", (e) => {
display_slots(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);
});
});
var hide_wrapped_mentor_cards = () => {
var offset_top_prev;
@@ -185,7 +197,7 @@ const create_certificate = (e) => {
e.preventDefault();
course = $(e.currentTarget).attr("data-course");
frappe.call({
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate",
method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
args: {
"course": course
},
@@ -236,4 +248,63 @@ 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 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>`;
});
e.preventDefault();
$("#slot-modal .slots").html(options);
$("#slot-modal").modal("show");
}
})
};
const submit_slot = (e) => {
e.preventDefault();
const slot = $(e.currentTarget);
frappe.call({
method: "lms.lms.doctype.lms_certificate_request.lms_certificate_request.create_certificate_request",
args: {
"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");
}
};

View File

@@ -12,8 +12,8 @@ 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", "video_link", "enable_certification", "status"],
["name", "title", "image", "short_introduction", "description", "published", "upcoming", "disable_self_learning", "status",
"video_link", "enable_certification", "grant_certificate_after", "paid_certificate", "price_certificate", "currency"],
as_dict=True)
if course is None:
@@ -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,

View File

@@ -15,7 +15,8 @@ def get_context(context):
def get_courses():
courses = frappe.get_all("LMS Course",
filters={"published": True},
fields=["name", "upcoming", "title", "image", "enable_certification"])
fields=["name", "upcoming", "title", "image", "enable_certification",
"paid_certificate", "price_certificate", "currency"])
live_courses, upcoming_courses = [], []
for course in courses:

View File

@@ -9,7 +9,7 @@ def get_common_context(context):
batch_name = None
course = frappe.db.get_value("LMS Course",
frappe.form_dict["course"], ["name", "title", "video_link"], as_dict=True)
frappe.form_dict["course"], ["name", "title", "video_link", "enable_certification"], as_dict=True)
if not course:
context.template = "www/404.html"
return