From b6d749f781dda4a9d3f611270b9d60890a2d06b7 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 17 Apr 2026 17:30:03 +0200 Subject: [PATCH] feat(VocabLessonView): enhance vocab trainer logic and answer normalization - Refactored vocab trainer logic to improve handling of acceptable answers, allowing for multiple translations and synonyms. - Introduced a new method to retrieve equivalent vocabulary answers, ensuring mixed pools from different lessons provide valid alternatives. - Enhanced answer normalization process to prevent duplicates and improve the quality of acceptable answers presented to users. --- frontend/src/views/social/VocabLessonView.vue | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index 9f59759..83701f7 100644 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -3730,13 +3730,26 @@ export default { } this.vocabTrainerDirection = Math.random() < 0.5 ? 'L2R' : 'R2L'; const allTrainerVocabs = [...this.trainableLessonVocab, ...this.vocabTrainerMixedPool]; - const prompt = this.vocabTrainerDirection === 'L2R' ? vocab.learning : vocab.reference; - // Akzeptiere mehrere Übersetzungen für denselben Prompt (z. B. "Bitte wiederholen" UND "Kannst du das wiederholen?"). - const acceptableAnswers = this.vocabTrainerDirection === 'L2R' + const direction = this.vocabTrainerDirection; + const prompt = direction === 'L2R' ? vocab.learning : vocab.reference; + // Akzeptiere mehrere Übersetzungen für denselben Prompt (z. B. Synonyme / Varianten auf der Lernsprache). + // Zusätzlich alle im gesamten Trainer-Pool gleichwertigen Ziele (wie früher via getEquivalentVocabAnswers), + // damit gemischte Pools aus mehreren Lektionen nicht plötzlich gültige Alternativen ablehnen. + const baseAnswers = direction === 'L2R' ? [vocab.reference] : (Array.isArray(vocab.learningVariants) && vocab.learningVariants.length > 0 - ? vocab.learningVariants + ? [...vocab.learningVariants] : [vocab.learning]); + const equivalentAnswers = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs); + const mergedRaw = [...baseAnswers, ...equivalentAnswers].filter(Boolean); + const seenNorm = new Set(); + const acceptableAnswers = []; + for (const a of mergedRaw) { + const n = this.normalizeVocab(a); + if (!n || seenNorm.has(n)) continue; + seenNorm.add(n); + acceptableAnswers.push(a); + } this.currentVocabQuestion = { vocab: vocab, prompt,