Skip to content

Fix: show translation (not repeated word) on MultipleChoiceContext solution#1002

Open
mircealungu wants to merge 2 commits intomasterfrom
auto-fix/issue-999
Open

Fix: show translation (not repeated word) on MultipleChoiceContext solution#1002
mircealungu wants to merge 2 commits intomasterfrom
auto-fix/issue-999

Conversation

@mircealungu
Copy link
Copy Markdown
Member

Summary

Closes #999

In the MultipleChoiceContext exercise, clicking "Show Solution" showed the learned L2 word twice — once in the headline and once highlighted in the sentence context. The translation was never revealed.

Root cause: wordInContextHeadline was stored in state, initialized to exerciseBookmark.from (the L2 word). It was only updated to exerciseBookmark.to (the translation) when the user selected the correct answer. When "Show Solution" was clicked, isExerciseOver was set to true externally but the headline state never updated.

Fix: Remove the stateful headline and replace it with a derived value: show exerciseBookmark.from during the exercise, exerciseBookmark.to once the exercise is over — regardless of whether the user answered correctly or clicked "Show Solution".


Commits

Commit 1 — core fix (Fix: show translation (not repeated L2 word) on MultipleChoiceContext solution):

  • Remove wordInContextHeadline state
  • Replace with inline derived expression: isExerciseOver ? removePunctuation(exerciseBookmark.to) : removePunctuation(exerciseBookmark.from)
  • Remove now-unnecessary setWordInContextHeadline call in notifyChoiceSelection

Commit 2 — cleanup (Refactor: simplify MultipleChoiceContext (boy scout rule)):

  • Replace 4-line for-loop with a single .map() when initialising isExercise flags
  • Remove unused selectedChoiceContext parameter from notifyChoiceSelection

To discuss this fix or request changes, find this session at:
https://claude.ai/code/session_01XDzZpStH9hhodMUwUpvLSC

claude added 2 commits March 30, 2026 14:13
… solution

When a user clicked "Show Solution" in the MultipleChoiceContext exercise,
isExerciseOver was set to true externally but wordInContextHeadline stayed as
exerciseBookmark.from (the L2 word). The context also highlighted that same
word, so the learned word appeared twice and the translation was never shown.

Fix: replace the wordInContextHeadline state with a derived value —
show exerciseBookmark.from during the exercise, exerciseBookmark.to once over.
This also removes the now-unnecessary setWordInContextHeadline call in
notifyChoiceSelection.

Closes #999
- Replace 4-line for-loop with a single .map() for setting isExercise flags
- Remove unused selectedChoiceContext parameter from notifyChoiceSelection
  (option.context was passed at the call site but never read in the function)
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for voluble-nougat-015dd1 ready!

Name Link
🔨 Latest commit 2384b81
🔍 Latest deploy log https://app.netlify.com/projects/voluble-nougat-015dd1/deploys/69ca855df0dab700084058ca
😎 Deploy Preview https://deploy-preview-1002--voluble-nougat-015dd1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

We have one exercise type where we don't show the translation on solution but we show twice the learned word

2 participants