Skip to content

Prevent duplicate quiz scoring from repeated answer submissions - #152

Merged
kristofer merged 2 commits into
mainfrom
copilot/fix-quiz-scoring-issue
Jun 8, 2026
Merged

kristofer merged 2 commits into
mainfrom
copilot/fix-quiz-scoring-issue

Conversation

Copilot AI commented Jun 8, 2026 •

Copy link
Copy Markdown

Students could repeatedly click a correct answer on the same question and increment correct_answers multiple times, allowing quiz scores above 100%. Each question should contribute at most one correct point per quiz attempt.

  • Scoring logic

    • Updated quiz answer submission handling to derive correct_answers from question_results on every submission, instead of incrementing a counter per correct click.
    • This makes scoring idempotent per question: re-submitting the same question no longer inflates totals.
  • Regression coverage

    • Added a focused API test that submits the same correct answer twice for one question and asserts correct_answers remains 1.
quizAttempt.QuestionResults[question.TopicQuestionID] = correct
quizAttempt.CorrectAnswers = 0
for _, wasCorrect := range quizAttempt.QuestionResults {
    if wasCorrect {
        quizAttempt.CorrectAnswers++
    }
}

Copilot AI linked an issue Jun 8, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix bug allowing more than 100% score on quizzes Prevent duplicate quiz scoring from repeated answer submissions Jun 8, 2026
Copilot AI requested a review from kristofer June 8, 2026 13:28
@kristofer
kristofer marked this pull request as ready for review June 8, 2026 14:22
@kristofer
kristofer merged commit 192b331 into main Jun 8, 2026
2 checks passed
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.

BUG: able to get more than 100% on a quiz.

2 participants