Skip to content

fix(quizzes): align selectedIndex max in submitQuizSchema with MAX_QUIZ_OPTIONS (#538) - #548

Closed
lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:fix/quiz-submission-selected-index-max-538
Closed

lmduy2612 wants to merge 1 commit into
ChainLearnOfficial:mainfrom
lmduy2612:fix/quiz-submission-selected-index-max-538

Conversation

@lmduy2612

Copy link
Copy Markdown

Summary

Closes #538.

Aligns selectedIndex maximum boundary in submitQuizSchema (src/modules/quizzes/quiz.types.ts) with MAX_QUIZ_OPTIONS - 1, preventing out-of-range option index submissions that cause false-positive server warning logs.

Changes Made

  • Moved MIN_QUIZ_OPTIONS (2) and MAX_QUIZ_OPTIONS (10) to the primary Constants section in src/modules/quizzes/quiz.types.ts.
  • Updated submitQuizSchema to bound selectedIndex using max(MAX_QUIZ_OPTIONS - 1) instead of the static max(20).
  • Updated tests/unit/schemas/input-validation.test.ts to verify that valid option indices (0 through MAX_QUIZ_OPTIONS - 1) are accepted, while indices at or above MAX_QUIZ_OPTIONS are rejected by the schema.
  • Verified all schema and quiz validation tests pass 100% (34/34 tests green).

Acceptance Criteria

  • Align selectedIndex max with MAX_QUIZ_OPTIONS (10 options -> index 0-9)
  • Reduce false-positive warnings in logs for out-of-range option indices

@DeFiVC DeFiVC closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align selectedIndex max in quiz submission schema with MAX_QUIZ_OPTIONS

2 participants