From 915bbdf2476408d23ecf3cf359e0323f9ed2a899 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 31 Oct 2022 11:50:36 +0530 Subject: [PATCH] fix: batch context --- lms/www/batch/learn.py | 12 ++---------- lms/www/utils.py | 7 +------ 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lms/www/batch/learn.py b/lms/www/batch/learn.py index c8b2aabf..2b060f9c 100644 --- a/lms/www/batch/learn.py +++ b/lms/www/batch/learn.py @@ -16,10 +16,7 @@ def get_context(context): }, "chapter") if not chapter_index or not lesson_index: - if context.batch: - index_ = get_lesson_index(context.course, context.batch, frappe.session.user) or "1.1" - else: - index_ = "1.1" + index_ = "1.1" redirect_to_lesson(context.course, index_) context.lesson = get_current_lesson_details(lesson_number, context) @@ -48,7 +45,7 @@ def get_context(context): context.page_extensions = get_page_extensions(context) context.page_context = { "course": context.course.name, - "batch": context.get("batch") and context.batch.name, + "batch": context.batch, "lesson": context.lesson.name if context.lesson.name else "New Lesson", "is_member": context.membership is not None } @@ -72,11 +69,6 @@ def get_url(lesson_number, course): return get_lesson_url(course.name, lesson_number) and get_lesson_url(course.name, lesson_number) + course.query_parameter -def get_lesson_index(course, batch, user): - lesson = batch.get_current_lesson(user) - return lesson and course.get_lesson_index(lesson) - - def get_page_extensions(context): default_value = ["lms.plugins.PageExtension"] classnames = frappe.get_hooks("lms_lesson_page_extensions") or default_value diff --git a/lms/www/utils.py b/lms/www/utils.py index 167c6c01..75ddf6c4 100644 --- a/lms/www/utils.py +++ b/lms/www/utils.py @@ -17,12 +17,7 @@ def get_common_context(context): context.lessons = get_lessons(course.name) membership = get_membership(course.name, frappe.session.user, batch_name) context.membership = membership - if membership: - batch = get_batch(course.name, membership.batch) - - if batch: - context.batch = batch - + context.batch = membership.batch if membership.batch else None context.course.query_parameter = "?batch=" + membership.batch if membership and membership.batch else "" context.livecode_url = get_livecode_url()