Skip to content

Add functionality to the quiz-tab to support more than 4 options. #13

@divyamagrawal06

Description

@divyamagrawal06

Currently the professor quiz creation UI assumes exactly 4 options per question (the form initializes options as ["", "", "", ""] and renders inputs based on that fixed-length array). This prevents creating questions with more than 4 alternatives. Students' quiz UI already reads and renders whatever questions are present, but professor-side creation / storage flow needs to support variable-length options.

Files involved

  • QuizTab (frontend/components/professor/tabs/quiz-tab.jsx)
  • StudentQuizTab (frontend/components/student/tabs/quiz-tab.jsx)

Expected behavior

  • Professor quiz creation should allow adding/removing any number of options per question.
  • The "Correct Answer" select should reflect the current number of options.
  • Saved quiz objects should include variable-length option arrays so the student UI can render them.

Changes to make

  1. Replace the fixed 4-element options initialization with a dynamic array (e.g. start with 2 or 4 but allow add/remove):
  2. Add UI controls per question to "Add Option" and "Remove Option". Enforce a minimum of 2 options per question.
  3. Update the "Correct Answer" to map over current options length so indices stay valid. Ensure correctAnswer remains within bounds when options are added/removed (e.g., if the current correct index is removed, reset to 0 or require user selection). Ensure backend API accepts and stores variable-length questions[].options arrays (basically confirm backend accepts arbitrary-length arrays).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions