Repository navigation
fix(validation): unique id per question for multi-question steps (#2514) - #2519
Merged
Merged
Conversation
Authors can put multiple [VALIDATE_N] blocks in one step (the number keys
the STEP, not the question) and the parser already accumulated them into
one array. But every question was assigned the same `validate-${stepNum}`
id, so client-side answer/verdict state (keyed by id) collided across the
questions: only one could hold an answer, MCQ selections appeared stuck,
and the all-or-nothing grader failed the step. The parser's own sibling
maps (`${stepNum}:${q.id}`) also overwrote each other, collapsing AI-graded
specs to one row per step.
Assign `validate-N` to the first question in a step and
`validate-N-<ordinal>` to each subsequent one. First-question id is
unchanged, so single-question steps and all published content are
byte-for-byte identical. The Validation.vue component and grading already
key everything by id and need no change.
Adds rules-multi-question-per-step.test.ts covering distinct ids,
backward-compat, and no sibling-map overwrite for AI-graded blocks.
This was referenced Sep 27, 2026
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.
Fixes #2514.
Problem
An author can put several
[VALIDATE_N]blocks in a single step (the number keys the step, not the question). The parser already accumulates them into one array andValidation.vuealready renders N questions per step — but every question was assigned the same idvalidate-${stepNum}(scripts/parsers/rules.ts:277,301).Because the client keys answer state and per-question verdicts by
q.id, three questions with identical ids collided onto one slot:${stepNum}:${q.id}) overwrote each other, collapsing AI-graded specs to one row per step.Fix
Thread an
ordinal(the count already in the step's array) intoparseBlockand assign:validate-N(unchanged — single-question steps and all published content are byte-for-byte identical),validate-N-<ordinal>.The id and the sibling-map keys are computed in one place so they stay consistent. No frontend change needed —
Validation.vue/grading.tsalready key by id.Tests
New
scripts/parsers/__tests__/rules-multi-question-per-step.test.ts:validate-N,Full parser + validation suites green (227 tests):
npx vitest run scripts/parsers/ hugo-apps/src/validation/.