diff --git a/lms/hooks.py b/lms/hooks.py index 627cf2df..1e7176e8 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -198,7 +198,8 @@ jinja = { "lms.lms.utils.has_course_instructor_role", "lms.lms.utils.has_course_moderator_role", "lms.lms.utils.get_certificates", - "lms.lms.utils.format_number" + "lms.lms.utils.format_number", + "lms.lms.utils.get_lesson_count" ], "filters": [] } diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 02452a69..b644fcae 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -508,4 +508,10 @@ def create_notification_log(doc, method): make_notification_logs(notification, users) +def get_lesson_count(course): + lesson_count = 0 + chapters = frappe.get_all("Chapter Reference", {"parent": course}, ["chapter"]) + for chapter in chapters: + lesson_count += frappe.db.count("Lesson Reference", {"parent": chapter.chapter}) + return lesson_count diff --git a/lms/lms/widgets/CourseCard.html b/lms/lms/widgets/CourseCard.html index 11af8e13..770247d5 100644 --- a/lms/lms/widgets/CourseCard.html +++ b/lms/lms/widgets/CourseCard.html @@ -14,116 +14,117 @@ {% endif %} -