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 %} -
-