Skip to content

fix: validate quiz submissions based on question type#424

Open
Dhyeya29 wants to merge 1 commit into
MRIARC-08:mainfrom
Dhyeya29:fix-quiz-submission-validation
Open

fix: validate quiz submissions based on question type#424
Dhyeya29 wants to merge 1 commit into
MRIARC-08:mainfrom
Dhyeya29:fix-quiz-submission-validation

Conversation

@Dhyeya29

Copy link
Copy Markdown

Closes #280

Summary

This PR strengthens server-side validation for quiz submissions by ensuring responses match the expected question type before they are processed and stored.

Changes Made

  • Updated the question lookup to fetch the corresponding question type during submission.

  • Added validation to ensure:

    • MCQ questions require a valid selected option.
    • Subjective questions require a non-empty written answer.
  • Returns a 400 Bad Request for invalid quiz submissions before persisting response records.

Why

Although quiz submissions already validate the existence of questions and selected options, they did not verify that the submitted response matched the expected question type. This change adds an additional validation layer to prevent invalid quiz records from being stored.

Validation

  • Built the project successfully using pnpm build.
  • Verified that the changes compile successfully without introducing build errors.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Dhyeya29 is attempting to deploy a commit to the Adarsh's projects Team on Vercel.

A member of the Team first needs to authorize it.

@MRIARC-08 MRIARC-08 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dhyeya29 The validation logic is aligned with the question type contract, and the branch merges cleanly with current main.

Local checks:

  • pnpm exec tsc --noEmit passes.
  • pnpm test passes: 8 files / 35 tests.
  • pnpm exec eslint src/modules/quiz/quiz.repository.ts src/modules/quiz/quiz.service.ts fails on one Prettier formatting issue in src/modules/quiz/quiz.service.ts.

Please run the repo formatter on the touched quiz files and push that result. No logic rewrite needed from what I checked.

@MRIARC-08 MRIARC-08 added gssoc gssoc level:beginner GSSoC difficulty: beginner type:bug Bug fix contribution labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc gssoc level:beginner GSSoC difficulty: beginner type:bug Bug fix contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Quiz submission accepts empty answers, storing invalid quiz records

2 participants