[Bug]: Duplicate quiz option values corrupt rendering and grading
Bug Description
A generated choice quiz can contain duplicate options[].value identifiers within the same question, for example A, B, B, D.
That causes two separate problems in playback:
QuizViewusesopt.valueas the React key, so duplicate values trigger a non-unique-key warning.- The same value is also used to store and grade the selected answer, so two distinct options with the same value become indistinguishable. In the observed quiz, both
Bchoices were shown as correct after submission.
This was observed in a locally generated course using Gemini 3.5 Flash-Lite.
Steps to Reproduce
A deterministic minimal reproduction is to persist/load a quiz question with duplicate option values, such as:
{
id: 'q1',
type: 'single',
question: 'What is the main benefit of diversification?',
options: [
{ value: 'A', label: 'Option A' },
{ value: 'B', label: 'Correct answer' },
{ value: 'B', label: 'Different answer' },
{ value: 'D', label: 'Option D' },
],
answer: ['B'],
}Then open the quiz in classroom playback.
This also occurred naturally during course generation, where the model emitted the same malformed option-value shape.
Expected Behavior
Generated choice questions should require unique option values within each question. Malformed persisted/imported quiz data should also fail safely instead of entering ambiguous rendering/grading state.
Actual Behavior
Playback logs:
Encountered two children with the same key, `B`. Keys should be unique so that components maintain their identity across updates.Because answer selection/grading is keyed by the same option value, the two distinct B choices are treated as the same answer. In the observed result, both duplicate B rows were marked correct.
Deployment Method
Local development (pnpm dev / Next.js dev server)
OpenMAIC Version
OpenMAIC 1.1.1, commit 1c70e86a13b07ea1ed6a6b160582e2e05aecdb3c
Affected Area
Classroom generation and playback / presentation
Browser
Chrome 153
Operating System
macOS 27
Additional Context
I have a tested fix prepared on a fork that:
- rejects duplicate option values during quiz generation;
- adds regression coverage for the generation contract;
- guards playback against malformed persisted/imported quiz data;
- shows an internationalized learner-facing invalid-content message instead of rendering the ambiguous quiz.
The fix has been verified against both a newly generated valid quiz and the original malformed saved quiz.
Source: THU-MAIC/OpenMAIC