From 6708162a6282518715633ec9c887a1e218418612 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 26 Aug 2026 11:53:13 +0200 Subject: [PATCH] feat(vocab): improve answer matching by accepting both displayed solutions and individual variants --- frontend/src/views/social/VocabLessonView.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index 02cc342..ef290dc 100755 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -4360,7 +4360,13 @@ export default { } }); - const phraseAlternatives = Array.from(variants).flatMap((entry) => this.splitPhraseAlternatives(entry)); + // Keep the original text as an acceptable variant as well. In multiple + // choice, an option such as "A / B" can be displayed verbatim; splitting + // it into A and B must not make that displayed option invalid. + const phraseAlternatives = Array.from(variants).flatMap((entry) => [ + entry, + ...this.splitPhraseAlternatives(entry) + ]); if (phraseAlternatives.length >= 2) { const expanded = phraseAlternatives.flatMap((part) => this.expandSingleAnswerVariants(part)); return [...new Set(expanded)]; @@ -4402,7 +4408,14 @@ export default { // Treat parenthetical notes as optional for answer matching. const normalizedUser = this.normalizeVocab(userAnswer); - const rawAnswers = this.currentVocabQuestion.answers || [this.currentVocabQuestion.answer]; + // `answer` is what we display as the correct solution. It may combine + // valid alternatives (for example "A / B"), while `answers` contains + // the individual variants. Accept both, so a displayed solution can + // never be rejected when entered verbatim. + const rawAnswers = [ + ...(Array.isArray(this.currentVocabQuestion.answers) ? this.currentVocabQuestion.answers : []), + this.currentVocabQuestion.answer + ].filter(Boolean); // Expand alternatives like "A / B" into separate acceptable answers const expandedAnswers = rawAnswers.flatMap(a => this.expandAnswerVariants(a)); const normalizedCorrectAnswers = expandedAnswers