Fix: show translation (not repeated word) on MultipleChoiceContext solution#1002
Open
mircealungu wants to merge 2 commits intomasterfrom
Open
Fix: show translation (not repeated word) on MultipleChoiceContext solution#1002mircealungu wants to merge 2 commits intomasterfrom
mircealungu wants to merge 2 commits intomasterfrom
Conversation
… 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)
✅ Deploy Preview for voluble-nougat-015dd1 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
wordInContextHeadlinewas stored in state, initialized toexerciseBookmark.from(the L2 word). It was only updated toexerciseBookmark.to(the translation) when the user selected the correct answer. When "Show Solution" was clicked,isExerciseOverwas set to true externally but the headline state never updated.Fix: Remove the stateful headline and replace it with a derived value: show
exerciseBookmark.fromduring the exercise,exerciseBookmark.toonce 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):wordInContextHeadlinestateisExerciseOver ? removePunctuation(exerciseBookmark.to) : removePunctuation(exerciseBookmark.from)setWordInContextHeadlinecall innotifyChoiceSelectionCommit 2 — cleanup (
Refactor: simplify MultipleChoiceContext (boy scout rule)):.map()when initialisingisExerciseflagsselectedChoiceContextparameter fromnotifyChoiceSelectionTo discuss this fix or request changes, find this session at:
https://claude.ai/code/session_01XDzZpStH9hhodMUwUpvLSC