diff --git a/community/lms/doctype/lms_course/lms_course.py b/community/lms/doctype/lms_course/lms_course.py index 867dda3b..fe44f04b 100644 --- a/community/lms/doctype/lms_course/lms_course.py +++ b/community/lms/doctype/lms_course/lms_course.py @@ -194,7 +194,13 @@ class LMSCourse(Document): """Returns the {chapter_index}.{lesson_index} for the lesson. """ lesson = frappe.db.get_value("Lessons", {"lesson": lesson_name}, ["idx", "parent"], as_dict=True) + if not lesson: + return None + chapter = frappe.db.get_value("Chapters", {"chapter": lesson.parent}, ["idx"], as_dict=True) + if not chapter: + return None + return f"{chapter.idx}.{lesson.idx}" def reindex_exercises(self): diff --git a/community/lms/widgets/ChapterTeaser.html b/community/lms/widgets/ChapterTeaser.html index 1f6ce0b2..c5019573 100644 --- a/community/lms/widgets/ChapterTeaser.html +++ b/community/lms/widgets/ChapterTeaser.html @@ -27,7 +27,7 @@ {{ lesson.title }} {% if membership %} - {% endif %} diff --git a/community/public/css/style.css b/community/public/css/style.css index def9fb6e..46e6e0e9 100644 --- a/community/public/css/style.css +++ b/community/public/css/style.css @@ -780,7 +780,7 @@ input[type=checkbox] { } .lesson-links { - display: flex; + display: block; padding: 0 1rem; margin-bottom: .25rem; color: inherit; @@ -794,6 +794,13 @@ input[type=checkbox] { border-radius: .25rem; } +.course-content-parent .lesson-links { + padding: 0 0 0 1rem; + margin-bottom: 0.75rem; + font-size: 0.85rem; + line-height: 200%; +} + .chapter-content { margin: 0; margin-left: .875rem; diff --git a/community/www/batch/learn.js b/community/www/batch/learn.js index 27bd9dca..db26eddf 100644 --- a/community/www/batch/learn.js +++ b/community/www/batch/learn.js @@ -58,6 +58,7 @@ var mark_active_question = (e = undefined) => { $(".current-question").text(`${next_index}`); $("#check").removeClass("hide").attr("disabled", true); $("#next").addClass("hide"); + $(".explanation").addClass("hide"); } var mark_progress = (e) => { diff --git a/community/www/batch/learn.py b/community/www/batch/learn.py index 54e96da1..52fdddaf 100644 --- a/community/www/batch/learn.py +++ b/community/www/batch/learn.py @@ -17,10 +17,9 @@ def get_context(context): index_ = get_lesson_index(context.course, context.batch, frappe.session.user) or "1.1" else: index_ = "1.1" - frappe.local.flags.redirect_location = context.course.get_learn_url(index_) + context.course.query_parameter - raise frappe.Redirect + utils.redirect_to_lesson(context.course, index_) - context.lesson = list(filter(lambda x: cstr(x.number) == lesson_number, context.lessons))[0] + context.lesson = get_current_lesson_details(lesson_number, context) neighbours = context.course.get_neighbours(lesson_number, context.lessons) context.next_url = get_learn_url(neighbours["next"], context.course) context.prev_url = get_learn_url(neighbours["prev"], context.course) @@ -40,6 +39,12 @@ def get_context(context): "is_member": context.membership is not None } +def get_current_lesson_details(lesson_number, context): + details_list = list(filter(lambda x: cstr(x.number) == lesson_number, context.lessons)) + if not len(details_list): + utils.redirect_to_lesson(context.course) + return details_list[0] + def get_learn_url(lesson_number, course): return course.get_learn_url(lesson_number) and course.get_learn_url(lesson_number) + course.query_parameter