Repository navigation
Fix Seed: store demo question options as JSON arrays and repair existing rows - #30
Merged
Merged
Conversation
…ting rows
seed_demo_data.sql inserted question options as a JSON object ({"A": "10", ...}),
but Question.options is mapped as List<String>, so opening or starting the demo
exams failed with 500.
- Seed the four affected questions with JSON arrays, the format the editor writes.
- Add V4 migration that converts existing object-shaped options into arrays
(ordered by key, so the original option order is kept). Rows already stored as
arrays are not touched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
seed_demo_data.sqlinserted question options as a JSON object ({"A": "10", "B": "20", ...}).Question.optionsis mapped asList<String>, so Jackson cannot read those rows.On any database seeded with the demo data, including the public demo, the demo exams were unusable:
GET /api/v1/exams/{id}/questions)POST /api/v1/exams/{id}/start)Changes
seed_demo_data.sql: the four affected questions now use JSON arrays, the same format the question editor writes. True/false questions use["Benar", "Salah"].V4__fix_question_options_format.sql: converts existing object-shapedoptionsinto arrays, ordered by key. Keys areA..EorBenar/Salah, so the original option order is kept.jsonb_typeof(options) = 'object'are touched. The application always writes arrays, so questions created by teachers are not affected.Testing
Isolated Docker stack:
main+ old seed (before)Grading also stays correct with
shuffle_optionsenabled. The answer is matched by option text, not position.Deploy note
Back up the database first. V4 runs automatically when the backend starts.