From 77e6fdb0d437b03cd5d8174934006d100e8ecee7 Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sat, 5 Apr 2025 15:29:57 +0300 Subject: fix: update quiz data loader to match json structure --- scripts/load_quiz_data.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/load_quiz_data.py b/scripts/load_quiz_data.py index 6b0a6c9..25186e6 100644 --- a/scripts/load_quiz_data.py +++ b/scripts/load_quiz_data.py @@ -25,11 +25,23 @@ def load_questions(json_path, db_path): # Insert questions for q in questions: + # Handle null options and different JSON structure + options = [str(o).strip() if o else "" for o in q['options']] + while len(options) < 4: # Ensure we always have 4 options + options.append("") + c.execute('''INSERT INTO questions (id, text, option1, option2, option3, option4, correct_index, requirement, explanation) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)''', - (q['id'], q['text'], q['option1'], q['option2'], q['option3'], q['option4'], - q['correct_index'], q.get('requirement', ''), q.get('explanation', ''))) + (q['id'], + q['question'], + options[0], + options[1], + options[2], + options[3], + q['correct_index'], + q.get('requirement', ''), + q.get('explanation', ''))) conn.commit() conn.close() -- cgit v1.2.3