From 6232f8703e133402929209478df3bd25661ea7ba Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 20 Apr 2023 17:55:03 +0530 Subject: [PATCH] feat: new design system for exisitng course home --- lms/hooks.py | 1 + lms/lms/utils.py | 16 ++- lms/lms/widgets/CourseOutline.html | 83 +++++------ lms/public/css/style.css | 155 +++++++++++++------- lms/templates/reviews.html | 14 +- lms/www/courses/course.html | 219 +++++++++++++---------------- lms/www/courses/course.py | 2 + lms/www/courses/create.html | 67 +++++++++ lms/www/courses/create.js | 38 +++++ lms/www/courses/create.py | 5 + lms/www/courses/index.html | 4 +- 11 files changed, 364 insertions(+), 240 deletions(-) create mode 100644 lms/www/courses/create.html create mode 100644 lms/www/courses/create.js create mode 100644 lms/www/courses/create.py diff --git a/lms/hooks.py b/lms/hooks.py index c9078ef3..801da69c 100644 --- a/lms/hooks.py +++ b/lms/hooks.py @@ -138,6 +138,7 @@ fixtures = ["Custom Field", "Function", "Industry"] website_route_rules = [ {"from_route": "/sketches/", "to_route": "sketches/sketch"}, {"from_route": "/courses/", "to_route": "courses/course"}, + {"from_route": "/courses//edit", "to_route": "courses/create"}, {"from_route": "/courses//", "to_route": "courses/certificate"}, {"from_route": "/courses//learn", "to_route": "batch/learn"}, { diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 3a22fbdf..6e1b6e63 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -93,18 +93,24 @@ def get_chapters(course): return chapters -def get_lessons(course, chapter=None): +def get_lessons(course, chapter=None, get_details=True): """If chapter is passed, returns lessons of only that chapter. Else returns lessons of all chapters of the course""" lessons = [] + lesson_count = 0 if chapter: - return get_lesson_details(chapter) + if get_details: + return get_lesson_details(chapter) + else: + return frappe.db.count("Lesson Reference", {"parent": chapter.name}) for chapter in get_chapters(course): - lesson = get_lesson_details(chapter) - lessons += lesson + if get_details: + lessons += get_lesson_details(chapter) + else: + lesson_count += frappe.db.count("Lesson Reference", {"parent": chapter.name}) - return lessons + return lessons if get_details else lesson_count def get_lesson_details(chapter): diff --git a/lms/lms/widgets/CourseOutline.html b/lms/lms/widgets/CourseOutline.html index 5a765218..69ac09c8 100644 --- a/lms/lms/widgets/CourseOutline.html +++ b/lms/lms/widgets/CourseOutline.html @@ -1,81 +1,64 @@ {% set chapters = get_chapters(course.name) %} +{% set is_instructor = is_instructor(course.name) %} -{% if course.edit_mode or chapters | length %} +{% if chapters | length %}
- - {% if course.edit_mode and course.name %} - - {% endif %} - - {% if course.name and (course.edit_mode or chapters | length) %} -
+
{{ _("Course Content") }}
- {% endif %} - {% if course.edit_mode and course.name and not chapters | length %} -
-
-
- +
+ + {{ chapters | length }} chapters + + + . {{ get_lessons(course.name, None, False) }} lessons +
- {% endif %} {% if chapters | length %} -
+
{% for chapter in chapters %} -
-