summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder (aider) <wohilas@gmail.com>2025-04-05 15:29:57 +0300
committerGrail Finder (aider) <wohilas@gmail.com>2025-04-05 15:29:57 +0300
commit77e6fdb0d437b03cd5d8174934006d100e8ecee7 (patch)
tree988563a429df8a5c78b5dccd543913792e2d45e1
parente78315f9d722bc045c17e32b669c3efa84e78271 (diff)
fix: update quiz data loader to match json structure
-rw-r--r--scripts/load_quiz_data.py16
1 files 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()