Show full calculation in wrong-answer feedback
Browse filesOn an incorrect answer, display "❌ 15 + 9 = 24" (the question expression
plus the correct answer) instead of just "❌ Answer: 24", so kids see the
whole equation. Captures state["question"] before it's overwritten.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -303,7 +303,8 @@ def check_answer(user_input: str, state: dict, pre_image, pre_data_url: str, col
|
|
| 303 |
gr.update(), gr.update(), gr.update(), gr.update(), gr.update())
|
| 304 |
|
| 305 |
else:
|
| 306 |
-
correct_answer = state["answer"]
|
|
|
|
| 307 |
state["streak"] = 0
|
| 308 |
math_lv = _math_level(state)
|
| 309 |
question, answer = generate_question(math_lv)
|
|
@@ -311,7 +312,7 @@ def check_answer(user_input: str, state: dict, pre_image, pre_data_url: str, col
|
|
| 311 |
state["answer"] = answer
|
| 312 |
return (state, _status_text(state),
|
| 313 |
gr.update(value=_safe_question(state)), gr.update(value=""),
|
| 314 |
-
f"❌
|
| 315 |
gr.update(visible=False), "", gr.update(visible=False), "",
|
| 316 |
gr.update(), gr.update(), gr.update(), gr.update(), gr.update())
|
| 317 |
|
|
|
|
| 303 |
gr.update(), gr.update(), gr.update(), gr.update(), gr.update())
|
| 304 |
|
| 305 |
else:
|
| 306 |
+
correct_answer = state["answer"] # capture before overwrite
|
| 307 |
+
current_q = state["question"] # the expression, e.g. "15 + 9"
|
| 308 |
state["streak"] = 0
|
| 309 |
math_lv = _math_level(state)
|
| 310 |
question, answer = generate_question(math_lv)
|
|
|
|
| 312 |
state["answer"] = answer
|
| 313 |
return (state, _status_text(state),
|
| 314 |
gr.update(value=_safe_question(state)), gr.update(value=""),
|
| 315 |
+
f"❌ {current_q} = **{correct_answer}**",
|
| 316 |
gr.update(visible=False), "", gr.update(visible=False), "",
|
| 317 |
gr.update(), gr.update(), gr.update(), gr.update(), gr.update())
|
| 318 |
|