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, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2022-03-09 15:17:15.386067", "modified": "2022-03-29 09:47:05.007133",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Batch Membership", "name": "LMS Batch Membership",
@@ -135,7 +135,9 @@
} }
], ],
"quick_entry": 1, "quick_entry": 1,
"show_title_field_in_link": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "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, "editable_grid": 1,
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"student",
"issue_date",
"column_break_3",
"course", "course",
"member",
"member_name",
"column_break_3",
"issue_date",
"expiry_date" "expiry_date"
], ],
"fields": [ "fields": [
{
"fieldname": "student",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Student",
"options": "User"
},
{ {
"fieldname": "issue_date", "fieldname": "issue_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Issue Date" "label": "Issue Date",
"reqd": 1
}, },
{ {
"fieldname": "column_break_3", "fieldname": "column_break_3",
@@ -35,20 +29,37 @@
"in_list_view": 1, "in_list_view": 1,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Course", "label": "Course",
"options": "LMS Course" "options": "LMS Course",
"reqd": 1
}, },
{ {
"fieldname": "expiry_date", "fieldname": "expiry_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Expiry 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, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2021-08-16 15:47:19.494055", "modified": "2022-04-06 11:49:36.077370",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Certification", "name": "LMS Certificate",
"owner": "Administrator", "owner": "Administrator",
"permissions": [ "permissions": [
{ {
@@ -66,5 +77,7 @@
], ],
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"states": [],
"title_field": "member_name",
"track_changes": 1 "track_changes": 1
} }

View File

@@ -8,16 +8,16 @@ from frappe import _
from frappe.utils.pdf import get_pdf from frappe.utils.pdf import get_pdf
from lms.lms.utils import is_certified from lms.lms.utils import is_certified
class LMSCertification(Document): class LMSCertificate(Document):
def validate(self): def validate(self):
certificates = frappe.get_all("LMS Certification", { certificates = frappe.get_all("LMS Certificate", {
"student": self.student, "member": self.member,
"course": self.course, "course": self.course,
"expiry_date": [">", nowdate()] "expiry_date": [">", nowdate()]
}) })
if len(certificates): 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") 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)) 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) expiry_date = add_years(nowdate(), expires_after_yrs)
certificate = frappe.get_doc({ certificate = frappe.get_doc({
"doctype": "LMS Certification", "doctype": "LMS Certificate",
"student": frappe.session.user, "member": frappe.session.user,
"course": course, "course": course,
"issue_date": nowdate(), "issue_date": nowdate(),
"expiry_date": expiry_date "expiry_date": expiry_date

View File

@@ -4,19 +4,19 @@
import frappe import frappe
import unittest import unittest
from lms.lms.doctype.lms_course.test_lms_course import new_course 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 from frappe.utils import nowdate, add_years, cint
class TestLMSCertification(unittest.TestCase): class TestLMSCertificate(unittest.TestCase):
def test_certificate_creation(self): def test_certificate_creation(self):
course = new_course("Test Certificate", 1, 2) course = new_course("Test Certificate", 1, 2)
certificate = create_certificate(course.name) certificate = create_certificate(course.name)
self.assertEqual(certificate.student, "Administrator") self.assertEqual(certificate.member, "Administrator")
self.assertEqual(certificate.course, course.name) self.assertEqual(certificate.course, course.name)
self.assertEqual(certificate.issue_date, nowdate()) self.assertEqual(certificate.issue_date, nowdate())
self.assertEqual(certificate.expiry_date, add_years(nowdate(), cint(course.expiry))) 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) 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", "related_courses",
"certification_section", "certification_section",
"enable_certification", "enable_certification",
"expiry" "expiry",
"column_break_22",
"grant_certificate_after",
"evaluator",
"pricing_section",
"paid_certificate",
"currency",
"price_certificate"
], ],
"fields": [ "fields": [
{ {
@@ -129,9 +136,8 @@
"default": "0", "default": "0",
"depends_on": "enable_certification", "depends_on": "enable_certification",
"fieldname": "expiry", "fieldname": "expiry",
"fieldtype": "Select", "fieldtype": "Int",
"label": "Certification Expires After Years", "label": "Certification Expires After (Years)"
"options": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10"
}, },
{ {
"fieldname": "related_courses", "fieldname": "related_courses",
@@ -161,6 +167,50 @@
{ {
"fieldname": "column_break_12", "fieldname": "column_break_12",
"fieldtype": "Column Break" "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", "is_published_field": "published",
@@ -186,7 +236,7 @@
"link_fieldname": "course" "link_fieldname": "course"
} }
], ],
"modified": "2022-03-24 13:09:37.228855", "modified": "2022-04-07 12:27:05.353788",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Course", "name": "LMS Course",
@@ -220,9 +270,10 @@
} }
], ],
"search_fields": "title", "search_fields": "title",
"show_title_field_in_link": 1,
"sort_field": "creation", "sort_field": "creation",
"sort_order": "DESC", "sort_order": "DESC",
"states": [], "states": [],
"title_field": "title", "title_field": "title",
"track_changes": 1 "track_changes": 1
} }

View File

@@ -170,9 +170,9 @@ def get_sorted_reviews(course):
return rating_percent return rating_percent
def is_certified(course): 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 "course": course
}) })
if len(certificate): if len(certificate):

View File

@@ -60,12 +60,18 @@
<div class="progress"> <div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="{{ progress }}" <div class="progress-bar" role="progressbar" aria-valuenow="{{ progress }}"
aria-valuemin="0" aria-valuemax="100" style="width:{{ 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> </div>
<div class="progress-percent">{{ progress }}% Completed</div> <div class="progress-percent">{{ progress }}% {{ _("Completed") }} </div>
{% endif %} {% 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"> <div class="course-card-footer">
<span class=""> <span class="">
{% set instructors = get_instructors(course.name) %} {% 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 school.patches.v0_0.set_status_in_course #21-03-2022
lms.patches.v0_0.change_published_field_data #25-03-2022 lms.patches.v0_0.change_published_field_data #25-03-2022
execute:frappe.delete_doc("Workspace", "School", ignore_missing=True, force=True) 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; display: flex;
flex-direction: column; flex-direction: column;
flex: 1 1 auto; flex: 1 1 auto;
color: var(--text-color);
} }
.course-card-title { .course-card-title {
@@ -813,16 +814,6 @@ input[type=checkbox] {
.progress-percent { .progress-percent {
margin: 0.5rem 0; margin: 0.5rem 0;
font-size: var(--text-base); 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 { pre {
@@ -856,67 +847,76 @@ pre {
.certificate-content { .certificate-content {
padding: 2.5rem 3rem; padding: 2.5rem 3rem;
background-color: #FFFFFF;
} }
.certificate-footer { .certificate-footer {
margin-top: 4.5rem; display: flex;
display: flex; justify-content: space-between;
width: 30%;
margin: 5rem auto 0;
} }
.certificate-footer-item { .certificate-price {
margin-right: 3.5rem; font-weight: bold;
margin-bottom: 0.5rem;
} }
.certificate-ribbon { .certificate-ribbon {
background-color: var(--primary-color); background-color: var(--primary-color);
margin-left: auto; padding: 0.5rem;
margin-right: 2.5rem; border-radius: var(--border-radius-md);
width: 4.5rem;
} }
.certificate-heading { .certificate-heading {
font-size: 3rem; font-size: 1.5rem;
font-weight: 500; font-weight: 500;
color: var(--gray-800); color: var(--text-color);
} }
.certificate-para { .certificate-para {
margin-bottom: 4rem; 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 { .certificate-logo {
height: 20px; height: 1.5rem;
}
@media (max-width: 1050px) {
.certificate-footer {
width: 50%;
}
} }
@media (max-width: 768px) { @media (max-width: 768px) {
.certificate-heading { .certificate-card {
font-size: 2rem; margin: 0;
} }
} }
@media (max-width: 550px) { @media (max-width: 550px) {
.certificate-footer { .certificate-content {
flex-direction: column; padding: 1rem;
} }
.certificate-footer-item { .certificate-footer {
margin-bottom: 1rem; width: 100%;
} }
}
@media (max-width: 500px) {
.certificate-heading {
font-size: 1.5rem;
}
.certificate-content {
padding: 2.5rem 2rem;
}
.certificate-ribbon {
margin-right: 1rem;
width: 1.5rem;
}
} }
.profile-card { .profile-card {
@@ -940,7 +940,7 @@ pre {
.empty-state-heading { .empty-state-heading {
font-size: var(--text-xl); font-size: var(--text-xl);
color: var(--gray-900); color: var(--text-color);
font-weight: 600; font-weight: 600;
} }
@@ -953,7 +953,7 @@ pre {
background-image: url(/assets/frappe/icons/timeless/search.svg); background-image: url(/assets/frappe/icons/timeless/search.svg);
border: none; border: none;
border-radius: var(--border-radius-md); border-radius: var(--border-radius-md);
font-size: var(--text-base); font-size: var(--text-sm);
padding: 0.625rem 0.75rem; padding: 0.625rem 0.75rem;
height: 36px; height: 36px;
background-repeat: no-repeat; background-repeat: no-repeat;
@@ -978,11 +978,11 @@ pre {
.testimonial-author { .testimonial-author {
font-weight: 500; font-weight: 500;
font-size: var(--text-lg); font-size: var(--text-lg);
color: var(--gray-900); color: var(--text-color);
} }
.testimonial-review { .testimonial-review {
color: var(--gray-900); color: var(--text-color);
margin-bottom: 2rem; margin-bottom: 2rem;
} }
@@ -1208,7 +1208,8 @@ pre {
.course-overlay-content { .course-overlay-content {
padding: 1.25rem; padding: 1.25rem;
font-size: var(--text-base); font-size: var(--text-base);
color: var(--gray-900); color: var(--text-color);
text-align: center;
} }
.breadcrumb-destination { .breadcrumb-destination {

View File

@@ -1,49 +1,50 @@
<div class="common-card-style"> <div class="certificate-card">
<div class="certificate-content"> <div class="certificate-ribbon">
<img src="{{ logo }}" class="certificate-logo"> <div class="certificate-content">
<div class="text-muted mt-18"> <img src="{{ logo }}" class="certificate-logo">
Completion Certificate <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>
<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> </div>
<script src="/assets/lms/js/html2canvas.js"></script> <script src="/assets/lms/js/html2canvas.js"></script>

View File

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

View File

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

View File

@@ -9,8 +9,8 @@ def get_context(context):
except KeyError: except KeyError:
redirect_to_course_list() redirect_to_course_list()
context.certificate = frappe.db.get_value("LMS Certification", certificate_name, context.certificate = frappe.db.get_value("LMS Certificate", certificate_name,
["name", "student", "issue_date", "expiry_date", "course"], as_dict=True) ["name", "member", "issue_date", "expiry_date", "course"], as_dict=True)
if context.certificate.course != course_name: if context.certificate.course != course_name:
redirect_to_course_list() redirect_to_course_list()
@@ -21,7 +21,7 @@ def get_context(context):
context.instructor = frappe.db.get_value("User", context.course.instructor, context.instructor = frappe.db.get_value("User", context.course.instructor,
["full_name", "username"], as_dict=True) ["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) ["full_name"], as_dict=True)
context.logo = frappe.db.get_single_value("Website Settings", "banner_image") 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.") }} {{ _("You have opted to be notified for this course. You will receive an email when the course becomes available.") }}
</div> </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" %} {% if course.status == "Under Review" %}
<div class="mb-4"> <div class="mb-4">
{{ _("Your course is currently under review. Once the review is complete, the System Admins will publish it on the website.") }} {{ _("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> </div>
{% endif %} {% endif %}
<div class="vertically-center mb-2"> <div class="vertically-center justify-content-center mb-2">
<div class=""> <div class="">
<svg class="icon icon-md mr-1"> <svg class="icon icon-md mr-1">
<use class="" href="#icon-users"> <use class="" href="#icon-users">
@@ -145,6 +151,12 @@
{% endif %} {% endif %}
</div> </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 {% set lesson_index = get_lesson_index(membership.current_lesson) if membership and
membership.current_lesson membership.current_lesson
else '1.1' %} else '1.1' %}
@@ -155,7 +167,7 @@
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" /> <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
</div> </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 }}"> <div class="button wide-button is-primary" id="submit-for-review" data-course="{{ course.name | urlencode }}">
{{ _("Submit for Review") }} {{ _("Submit for Review") }}
<img class="ml-2" src="/assets/lms/icons/white-arrow.svg" /> <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" /> {{ _("Checkout Course") }} <img class="ml-2" src="/assets/lms/icons/white-arrow.svg" />
</a> </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 %} {% elif course.upcoming and not is_user_interested %}
<div class="button wide-button is-default" <div class="button wide-button is-default"
id="notify-me" data-course="{{course.name | urlencode}}"> id="notify-me" data-course="{{course.name | urlencode}}">
@@ -185,22 +191,73 @@
style="color: inherit;"> style="color: inherit;">
{{ _("Manage the course") }} {{ _("Manage the course") }}
</a> </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 %} {% endif %}
{% set certificate = is_certified(course.name) %} {% set certificate = is_certified(course.name) %}
{% set progress = frappe.utils.cint(membership.progress) %} {% set progress = frappe.utils.cint(membership.progress) %}
{% if membership and course.enable_certification %}
{% if certificate %} {% if certificate %}
<a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}"> <a class="button wide-button is-secondary mt-2" href="/courses/{{ course.name }}/{{ certificate }}">
{{ _("Get Certificate") }} {{ _("Get Certificate") }}
</a> </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 }}"> <div class="button wide-button is-secondary mt-4" id="certification" data-course="{{ course.name }}">
{{ _("Get Certificate") }} {{ _("Get Certificate") }}
</div> </div>
{% endif %} {% endif %}
{% endif %}
</div> </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> </div>
{% endmacro %} {% endmacro %}

View File

@@ -1,50 +1,62 @@
frappe.ready(() => { frappe.ready(() => {
hide_wrapped_mentor_cards(); hide_wrapped_mentor_cards();
$("#cancel-request").click((e) => { $("#cancel-request").click((e) => {
cancel_mentor_request(e); cancel_mentor_request(e);
}); });
$(".join-batch").click((e) => { $(".join-batch").click((e) => {
join_course(e) join_course(e)
}); });
$(".view-all-mentors").click((e) => { $(".view-all-mentors").click((e) => {
view_all_mentors(e); view_all_mentors(e);
}); });
$(".review-link").click((e) => { $(".review-link").click((e) => {
show_review_dialog(e); show_review_dialog(e);
}); });
$(".icon-rating").click((e) => { $(".icon-rating").click((e) => {
highlight_rating(e); highlight_rating(e);
}); });
$("#submit-review").click((e) => { $("#submit-review").click((e) => {
submit_review(e); submit_review(e);
}) })
$("#notify-me").click((e) => { $("#notify-me").click((e) => {
notify_user(e); notify_user(e);
}) })
$("#certification").click((e) => { $("#certification").click((e) => {
create_certificate(e); create_certificate(e);
}); });
$("#submit-for-review").click((e) => { $("#submit-for-review").click((e) => {
submit_for_review(e); submit_for_review(e);
}); });
$(document).scroll(function() { $("#apply-certificate").click((e) => {
let timer; apply_cetificate(e);
clearTimeout(timer); });
timer = setTimeout(() => { handle_overlay_display.apply(this, arguments); }, 500);
});
}) $("#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 hide_wrapped_mentor_cards = () => {
var offset_top_prev; var offset_top_prev;
@@ -185,7 +197,7 @@ const create_certificate = (e) => {
e.preventDefault(); e.preventDefault();
course = $(e.currentTarget).attr("data-course"); course = $(e.currentTarget).attr("data-course");
frappe.call({ frappe.call({
method: "lms.lms.doctype.lms_certification.lms_certification.create_certificate", method: "lms.lms.doctype.lms_certificate.lms_certificate.create_certificate",
args: { args: {
"course": course "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 raise frappe.Redirect
course = frappe.db.get_value("LMS Course", course_name, course = frappe.db.get_value("LMS Course", course_name,
["name", "title", "image", "short_introduction", "description", "published", "upcoming", ["name", "title", "image", "short_introduction", "description", "published", "upcoming", "disable_self_learning", "status",
"disable_self_learning", "video_link", "enable_certification", "status"], "video_link", "enable_certification", "grant_certificate_after", "paid_certificate", "price_certificate", "currency"],
as_dict=True) as_dict=True)
if course is None: if course is None:
@@ -30,10 +30,19 @@ def get_context(context):
membership = get_membership(course.name, frappe.session.user) membership = get_membership(course.name, frappe.session.user)
context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else "" context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else ""
context.membership = membership context.membership = membership
if context.course.upcoming:
context.is_user_interested = get_user_interest(context.course.name)
context.restriction = check_profile_restriction() context.restriction = check_profile_restriction()
context.show_start_learing_cta = show_start_learing_cta(course, membership, context.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 = { context.metatags = {
"title": course.title, "title": course.title,
"image": course.image, "image": course.image,

View File

@@ -15,7 +15,8 @@ def get_context(context):
def get_courses(): def get_courses():
courses = frappe.get_all("LMS Course", courses = frappe.get_all("LMS Course",
filters={"published": True}, 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 = [], [] live_courses, upcoming_courses = [], []
for course in courses: for course in courses:

View File

@@ -9,7 +9,7 @@ def get_common_context(context):
batch_name = None batch_name = None
course = frappe.db.get_value("LMS Course", 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: if not course:
context.template = "www/404.html" context.template = "www/404.html"
return return