From 2e79190977881ac3f466ac83e0d42c8525d5d588 Mon Sep 17 00:00:00 2001 From: Fahid Latheef Alungal Date: Tue, 2 Sep 2025 01:36:18 +0530 Subject: [PATCH] fix: added Patch to update wrong indexes for SCORM Lesson References --- lms/patches.txt | 3 ++- lms/patches/v2_0/fix_scorm_lesson_reference_idx.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 lms/patches/v2_0/fix_scorm_lesson_reference_idx.py diff --git a/lms/patches.txt b/lms/patches.txt index 79b4afad..42f6430b 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -110,4 +110,5 @@ lms.patches.v2_0.link_zoom_account_to_batch lms.patches.v2_0.sidebar_for_certified_members lms.patches.v2_0.move_batch_instructors_to_evaluators lms.patches.v2_0.enable_programming_exercises_in_sidebar -lms.patches.v2_0.count_in_program \ No newline at end of file +lms.patches.v2_0.count_in_program +lms.patches.v2_0.fix_scorm_lesson_reference_idx diff --git a/lms/patches/v2_0/fix_scorm_lesson_reference_idx.py b/lms/patches/v2_0/fix_scorm_lesson_reference_idx.py new file mode 100644 index 00000000..a57aeef1 --- /dev/null +++ b/lms/patches/v2_0/fix_scorm_lesson_reference_idx.py @@ -0,0 +1,13 @@ +import frappe + + +def execute(): + scorm_lessons = frappe.get_all("Course Lesson", filters={"is_scorm_package": 1}, pluck="name") + table = frappe.qb.DocType("Lesson Reference") + + q = frappe.qb.from_(table).select(table.name).where(table.lesson.isin(scorm_lessons) & table.idx == 0) + wrong_idx_lesson_references = q.run(pluck=True) + + for lesson_reference in wrong_idx_lesson_references: + # For SCORM, there is only 1 lesson per chapter, so directly setting 1 is fine + frappe.db.set_value("Lesson Reference", lesson_reference, "idx", 1)