diff --git a/lms/hooks.py b/lms/hooks.py index 188a9e45..9c94b94c 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -194,7 +194,8 @@ jinja = { "lms.lms.utils.first_lesson_exists", "lms.lms.utils.get_courses_under_review", "lms.lms.utils.has_course_instructor_role", - "lms.lms.utils.has_course_moderator_role" + "lms.lms.utils.has_course_moderator_role", + "lms.lms.utils.get_certificates" ], "filters": [] } diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 22f78197..3e1da754 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -455,3 +455,8 @@ def get_courses_under_review(): }, ["name", "upcoming", "title", "image", "enable_certification", "status", "published"] ) + +def get_certificates(member=None): + return frappe.get_all("LMS Certificate", { + "member": member or frappe.session.user + }, ["course", "member", "issue_date", "expiry_date", "name"]) diff --git a/lms/lms/web_template/courses_enrolled/courses_enrolled.html b/lms/lms/web_template/courses_enrolled/courses_enrolled.html index b165aa70..7e17c865 100644 --- a/lms/lms/web_template/courses_enrolled/courses_enrolled.html +++ b/lms/lms/web_template/courses_enrolled/courses_enrolled.html @@ -2,28 +2,28 @@ {% if enrolled | length %}
- {% for course in enrolled %} - {{ widgets.CourseCard(course=course) }} - {% endfor %} + {% for course in enrolled %} + {{ widgets.CourseCard(course=course) }} + {% endfor %}
{% else %} -{% set site_name = frappe.db.get_single_value("System Settings", "app_name") %} -
-
-
-
{{ _("You haven't enrolled for any courses") }}
-
{{ _("Here are a few courses we recommend for you to get started with {0}").format(site_name) }}
+ {% set site_name = frappe.db.get_single_value("System Settings", "app_name") %} +
+
+
+
{{ _("You haven't enrolled for any courses") }}
+
{{ _("Here are a few courses we recommend for you to get started with {0}").format(site_name) }}
+
+ {% set recommended_courses = get_popular_courses() %} +
+ {% for course in recommended_courses %} + {% if course %} + {% set course_details = frappe.get_doc("LMS Course", course.course) %} + {{ widgets.CourseCard(course=course_details) }} + {% endif %} + {% endfor %} +
+
- {% set recommended_courses = get_popular_courses() %} -
- {% for course in recommended_courses %} - {% if course %} - {% set course_details = frappe.get_doc("LMS Course", course.course) %} - {{ widgets.CourseCard(course=course_details) }} - {% endif %} - {% endfor %} -
-
-
{% endif %} diff --git a/lms/public/css/style.css b/lms/public/css/style.css index d24d8ff8..6d43a2bd 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -894,9 +894,9 @@ pre { } } -.profile-card { - flex-direction: column; - padding: 1rem 1.25rem; +.column-card { + flex-direction: column; + padding: 1.25rem; } .empty-state { @@ -1398,19 +1398,19 @@ pre { overflow: inherit; } -.dashboard .nav-link { +.lms-nav .nav-link { color: var(--text-muted); padding: 0 0 var(--padding-md); margin-right: var(--margin-xl); } -.dashboard .nav-link.active { +.lms-nav .nav-link.active { font-weight: 600; border-bottom: 1px solid var(--primary); color: var(--text-color); } -.dashboard .nav-link:hover { +.lma.nav .nav-link:hover { color: inherit; } diff --git a/lms/templates/certificate.html b/lms/templates/certificate.html index e798cc1d..6851422d 100644 --- a/lms/templates/certificate.html +++ b/lms/templates/certificate.html @@ -1,18 +1,25 @@
+
+
{{ _("This certifies that") }}
-
{{ member.full_name }}
-
{{ _("has successfully completed the course on") }} - {{ course.title }} on {{ frappe.utils.format_date(certificate.issue_date, "medium") }}.
+ +
+ {{ member.full_name }} +
+
+ {{ _("has successfully completed the course on") }} + {{ course.title }} + on {{ frappe.utils.format_date(certificate.issue_date, "medium") }}. +
- {% if instructors %}
@@ -25,14 +32,13 @@ {% if certificate.expiry_date %}
-
- {{ frappe.utils.format_date(certificate.expiry_date, "medium") }} -
-
-
{{ _("Expiry date") }}
+
+ {{ frappe.utils.format_date(certificate.expiry_date, "medium") }} +
+
+
{{ _("Expiry date") }}
{% endif %} -
diff --git a/lms/templates/certificates_section.html b/lms/templates/certificates_section.html new file mode 100644 index 00000000..a60a8b5c --- /dev/null +++ b/lms/templates/certificates_section.html @@ -0,0 +1,30 @@ +{% set certificates = get_certificates(user) %} + +{% if certificates | length %} +
+ {% for certificate in certificates %} + {% set course = frappe.db.get_value("LMS Course", certificate.course, ["title", "name", "image"], as_dict=True) %} + +
+
+ {{ course.title }} +
+
+ {{ _("Issued on") }} : {{ frappe.utils.format_date(certificate.issue_date, "medium") }} +
+ +
+ {% endfor %} +
+ +{% else %} +{% set course_list_link = " course list " %} +
+ +
+
{{ _("No certificates") }}
+
{{ _("Check out the {0} to know more about certification.").format(course_list_link) }}
+
+
+{% endif %} + diff --git a/lms/templates/courses_created.html b/lms/templates/courses_created.html index f51d9d13..b70db8a8 100644 --- a/lms/templates/courses_created.html +++ b/lms/templates/courses_created.html @@ -1,4 +1,4 @@ -{% set courses = get_authored_courses(None, only_published=False) %} +{% set courses = get_authored_courses(user or None, only_published=False) %} {% if courses | length %}
diff --git a/lms/www/courses/certificate.html b/lms/www/courses/certificate.html index 61d48d53..85b164d7 100644 --- a/lms/www/courses/certificate.html +++ b/lms/www/courses/certificate.html @@ -16,9 +16,9 @@ {{ course.title }}
{% if custom_template %} - {{ custom_template }} + {{ custom_template }} {% else %} - {% include "lms/templates/certificate.html" %} + {% include "lms/templates/certificate.html" %} {% endif %} diff --git a/lms/www/courses/certificate.py b/lms/www/courses/certificate.py index 70dd7ff9..f624311d 100644 --- a/lms/www/courses/certificate.py +++ b/lms/www/courses/certificate.py @@ -19,8 +19,7 @@ def get_context(context): context.course = frappe.db.get_value("LMS Course", course_name, ["title", "name", "image"], as_dict=True) context.instructors = (", ").join([x.full_name for x in get_instructors(course_name)]) - context.member = frappe.db.get_value("User", context.certificate.member, - ["full_name"], as_dict=True) + 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") template_name = frappe.db.get_single_value("LMS Settings", "custom_certificate_template") diff --git a/lms/www/dashboard/index.html b/lms/www/dashboard/index.html index c7d76e57..fff3a979 100644 --- a/lms/www/dashboard/index.html +++ b/lms/www/dashboard/index.html @@ -14,7 +14,7 @@ {% endif %} -