Skip to content

fix : added correct answer capture per round in Math-Quiz check_answer - #1835

Closed
tmdeveloper007 wants to merge 1 commit into
steam-bell-92:mainfrom
tmdeveloper007:pr1830
Closed

fix : added correct answer capture per round in Math-Quiz check_answer#1835
tmdeveloper007 wants to merge 1 commit into
steam-bell-92:mainfrom
tmdeveloper007:pr1830

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary of What Has Been Done

Fixed a closure bug in games/Math-Quiz/Math-Quiz.py where button commands in load_question all referenced the same option variable, causing incorrect answers to be checked on subsequent rounds. Also fixed check_answer to accept a correct parameter so it uses the captured correct answer rather than the current self.correct_answer which may have changed.

File changed: games/Math-Quiz/Math-Quiz.py

Changes Made

  • load_question: Changed button command lambda from lambda opt=option: self.check_answer(opt) to lambda opt=option, correct=self.correct_answer: self.check_answer(opt, correct) to capture both the selected option and the correct answer for that round
  • check_answer: Added optional correct=None parameter; when provided, uses it instead of self.correct_answer to avoid race condition when self.correct_answer changes between question load and answer check

Impact it Made

  • Each round's buttons check against that round's correct answer
  • No cross-round answer contamination
  • Correct answers are always properly validated regardless of question type

Closes #1830

Note

Please assign this PR to the tmdeveloper007 account.

@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

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 : Math-Quiz marks correct float division answers as wrong

2 participants