diff --git a/school/lms/doctype/lms_certification/lms_certification.py b/school/lms/doctype/lms_certification/lms_certification.py index 4f57c484..f0b29ee5 100644 --- a/school/lms/doctype/lms_certification/lms_certification.py +++ b/school/lms/doctype/lms_certification/lms_certification.py @@ -23,13 +23,13 @@ class LMSCertification(Document): @frappe.whitelist() def create_certificate(course): - certificate = is_certified() + certificate = is_certified(course) if certificate: return certificate else: - expires_after_yrs = int(course_details.expiry) + expires_after_yrs = int(frappe.db.get_value("LMS Course", course, "expiry")) expiry_date = None if expires_after_yrs: expiry_date = add_years(nowdate(), expires_after_yrs) diff --git a/school/public/css/style.css b/school/public/css/style.css index d7deff62..eb327077 100644 --- a/school/public/css/style.css +++ b/school/public/css/style.css @@ -92,8 +92,7 @@ input[type=checkbox] { background: #FFFFFF; border-radius: var(--border-radius-md); position: relative; - border: 1px solid #EEF0F2; - box-shadow: var(--shadow-base); + box-shadow: var(--shadow-sm); } .course-card { @@ -400,7 +399,6 @@ input[type=checkbox] { display: flex; align-items: center; justify-content: center; - width: fit-content; padding: 0.25rem 1.25rem; font-size: var(--text-md); line-height: 20px; @@ -424,6 +422,7 @@ input[type=checkbox] { .is-secondary { background: #FFFFFF; + color: inherit; } .is-secondary:hover { @@ -1274,17 +1273,17 @@ pre { } .search { background-image: url(/assets/frappe/icons/timeless/search.svg); - border: 1px solid #C8CFD5; - box-sizing: border-box; - border-radius: var(--border-radius); - font-size: 0.75rem; + border: none; + border-radius: var(--border-radius-md); + font-size: var(--text-sm); padding: 0.625rem 0.75rem; height: 36px; background-repeat: no-repeat; text-indent: 1.5rem; - background-position: 1rem 0.65rem; + background-position: 1rem 0.6rem; float: right; width: 25%; + background-color: var(--gray-100); } .section-heading { diff --git a/school/public/icons/search.svg b/school/public/icons/search.svg index 2cd7407c..287edd66 100644 --- a/school/public/icons/search.svg +++ b/school/public/icons/search.svg @@ -1,3 +1,3 @@ - + diff --git a/school/www/courses/course.html b/school/www/courses/course.html index 3cc0c72e..6412e64a 100644 --- a/school/www/courses/course.html +++ b/school/www/courses/course.html @@ -176,6 +176,18 @@ {% endif %} + {% set certificate = is_certified(course.name) %} + {% set progress = frappe.utils.cint(membership.progress) %} + {% if certificate %} + + {{ _("Get Certificate") }} + + {% elif course.enable_certification and progress == 100 %} +
+ {{ _("Get Certificate") }} +
+ {% endif %} +
{{ _("Course Include:") }}
{% if get_lessons(course.name) | length %}
diff --git a/school/www/courses/course.js b/school/www/courses/course.js index 511f09d8..f726eeb9 100644 --- a/school/www/courses/course.js +++ b/school/www/courses/course.js @@ -41,6 +41,10 @@ frappe.ready(() => { notify_user(e); }) + $("#certification").click((e) => { + create_certificate(e); + }); + }) var check_mentor_request = () => { @@ -196,7 +200,7 @@ var submit_review = (e) => { } } }) -} +}; var notify_user = (e) => { e.preventDefault(); @@ -216,4 +220,20 @@ var notify_user = (e) => { $("#notify-me").addClass("hide"); } }) -} +}; + +const create_certificate = (e) => { + e.preventDefault(); + course = $(e.currentTarget).attr("data-course"); + console.log(course) + console.log($(e.currentTarget)) + frappe.call({ + method: "school.lms.doctype.lms_certification.lms_certification.create_certificate", + args: { + "course": course + }, + callback: (data) => { + window.location.href = `/courses/${course}/${data.message}`; + } + }) +}; diff --git a/school/www/courses/course.py b/school/www/courses/course.py index 612088ef..2a55baae 100644 --- a/school/www/courses/course.py +++ b/school/www/courses/course.py @@ -13,7 +13,7 @@ def get_context(context): course = frappe.db.get_value("LMS Course", course_name, ["name", "title", "image", "short_introduction", "description", "is_published", "upcoming", - "disable_self_learning", "video_link"], + "disable_self_learning", "video_link", "enable_certification"], as_dict=True) related_courses = frappe.get_all("Related Courses", {"parent": course.name}, ["course"])