From 94e7f6a1f47d898f2112c4b9d89b1850bb78d0b1 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Wed, 9 Nov 2022 15:21:08 +0530 Subject: [PATCH 1/2] feat: course and lesson completion count --- .../lms_course_progress.json | 20 +++++++- lms/patches.txt | 1 + lms/patches/v0_0/set_member_in_progress.py | 9 ++++ lms/public/css/style.css | 19 ++++++-- lms/templates/statistics.html | 46 +++++++++++++++---- lms/templates/stats.html | 3 ++ lms/www/courses/index.html | 14 +++--- 7 files changed, 88 insertions(+), 24 deletions(-) create mode 100644 lms/patches/v0_0/set_member_in_progress.py diff --git a/lms/lms/doctype/lms_course_progress/lms_course_progress.json b/lms/lms/doctype/lms_course_progress/lms_course_progress.json index 78452c69..91de677d 100644 --- a/lms/lms/doctype/lms_course_progress/lms_course_progress.json +++ b/lms/lms/doctype/lms_course_progress/lms_course_progress.json @@ -5,6 +5,8 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "member", + "member_name", "status", "column_break_3", "lesson", @@ -26,7 +28,6 @@ "fetch_from": "lesson.chapter", "fieldname": "chapter", "fieldtype": "Link", - "in_list_view": 1, "label": "Chapter", "options": "Course Chapter", "read_only": 1 @@ -49,11 +50,24 @@ { "fieldname": "column_break_3", "fieldtype": "Column Break" + }, + { + "fieldname": "member", + "fieldtype": "Link", + "label": "Member", + "options": "User" + }, + { + "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-09-30 13:07:54.246863", + "modified": "2022-11-09 14:24:06.312623", "modified_by": "Administrator", "module": "LMS", "name": "LMS Course Progress", @@ -74,5 +88,7 @@ ], "sort_field": "modified", "sort_order": "DESC", + "states": [], + "title_field": "member_name", "track_changes": 1 } \ No newline at end of file diff --git a/lms/patches.txt b/lms/patches.txt index ba88ca6a..9438129d 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -34,3 +34,4 @@ lms.patches.v0_0.create_course_instructor_role #29-08-2022 lms.patches.v0_0.create_course_moderator_role lms.patches.v0_0.set_dashboard #11-10-2022 lms.patches.v0_0.set_courses_page_as_home +lms.patches.v0_0.set_member_in_progress diff --git a/lms/patches/v0_0/set_member_in_progress.py b/lms/patches/v0_0/set_member_in_progress.py new file mode 100644 index 00000000..cfcb6cf8 --- /dev/null +++ b/lms/patches/v0_0/set_member_in_progress.py @@ -0,0 +1,9 @@ +import frappe + +def execute(): + progress_records = frappe.get_all("LMS Course Progress", fields=["name", "owner"]) + + for progress in progress_records: + full_name = frappe.db.get_value("User", progress.owner, "full_name") + frappe.db.set_value("LMS Course Progress", progress.name, "member", progress.owner) + frappe.db.set_value("LMS Course Progress", progress.name, "member_name", full_name) diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 54203126..a1be2240 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -1216,9 +1216,9 @@ pre { } .preview-video { - width: 100%; - height: 190px; - border: none; + width: 100%; + height: 190px; + border: none; } .course-body-container { @@ -1715,6 +1715,11 @@ li { grid-gap: 2rem; } +.tab-pane .stats-parent { + grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); + grid-gap: 1rem; +} + .stats-label { color: var(--gray-900); font-weight: 500; @@ -1770,8 +1775,8 @@ li { .frappe-chart .title { font-size: 1rem; - font-weight: bold; - color: var(--gray-900); + font-weight: 500; + fill: var(--gray-900); } .course-description-section { @@ -1799,3 +1804,7 @@ select { appearance: none; -webkit-appearance: none; } + +.course-list-cta { + float: right; +} diff --git a/lms/templates/statistics.html b/lms/templates/statistics.html index 57b84e68..94ea9c1c 100644 --- a/lms/templates/statistics.html +++ b/lms/templates/statistics.html @@ -33,17 +33,43 @@ {% endif %} - {% if enrollment_count %} -
-
- {{ _("Enrollment Count") }} -
-
- {{ frappe.utils.fmt_money( + {% if enrollment_count %} +
+
+ {{ _("Enrollment Count") }} +
+
+ {{ frappe.utils.fmt_money( frappe.db.count("LMS Batch Membership") , 0) }} -
-
- {% endif %} +
+
+ {% endif %} + + {% if course_completion %} + {% set course_completion_count = frappe.db.count("LMS Batch Membership", { + "progress":["=","100"] + }) %} +
+
+ {{ _("Courses Completed") }} +
+
+ {{ frappe.utils.fmt_money(course_completion_count, 0) }} +
+
+ {% endif %} + + {% if lesson_completion %} + {% set lesson_completion_count = frappe.db.count("LMS Course Progress") %} +
+
+ {{ _("Lessons Completed") }} +
+
+ {{ frappe.utils.fmt_money(lesson_completion_count, 0) }} +
+
+ {% endif %} diff --git a/lms/templates/stats.html b/lms/templates/stats.html index e35591c1..e0f25fd1 100644 --- a/lms/templates/stats.html +++ b/lms/templates/stats.html @@ -1,6 +1,9 @@ {% set published_courses = True %} {% set total_signups = True %} {% set enrollment_count = True %} +{% set course_completion = True %} +{% set lesson_completion = True %} +{% set quiz_completion = True %}
{% include "lms/templates/statistics.html" %} diff --git a/lms/www/courses/index.html b/lms/www/courses/index.html index 219524d6..a69c62ff 100644 --- a/lms/www/courses/index.html +++ b/lms/www/courses/index.html @@ -29,24 +29,24 @@ -
- {{ _("All Courses") }} -
- -