This commit is contained in:
Jannat Patel
2025-09-03 15:44:43 +05:30
2 changed files with 7 additions and 5 deletions

View File

@@ -111,4 +111,4 @@ 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.fix_scorm_lesson_reference_idx
lms.patches.v2_0.fix_scorm_lesson_reference_idx #02-09-2025

View File

@@ -2,11 +2,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")
scorm_chapters = frappe.get_all("Course Chapter", filters={"is_scorm_package": 1}, pluck="name")
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)
wrong_idx_lesson_references = frappe.get_all(
"Lesson Reference",
filters={"parenttype": "Course Chapter", "parent": ("in", scorm_chapters), "idx": 0},
pluck="name",
)
for lesson_reference in wrong_idx_lesson_references:
# For SCORM, there is only 1 lesson per chapter, so directly setting 1 is fine