fix: added Patch to update wrong indexes for SCORM Lesson References

This commit is contained in:
Fahid Latheef Alungal
2025-09-02 01:36:18 +05:30
parent ee7debeef7
commit 2e79190977
2 changed files with 15 additions and 1 deletions

View File

@@ -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
lms.patches.v2_0.count_in_program
lms.patches.v2_0.fix_scorm_lesson_reference_idx

View File

@@ -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)