From 431dd0bd3762ae35c19365852c282da841903b55 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 20 May 2026 16:10:57 +0200 Subject: [PATCH] feat: Erweiterung der akzeptierten Antworten im Vokabeltrainer durch Deduplizierung und Variantenaufspaltung --- frontend/src/views/social/VocabLessonView.vue | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index 5db5866..4f5e882 100644 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -3972,16 +3972,23 @@ export default { const allTrainerVocabs = pool; const direction = this.vocabTrainerDirection; const prompt = direction === 'L2R' ? vocab.learning : vocab.reference; - const acceptableAnswers = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs); + const rawAcceptable = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs); + // Expand variants (split slashes / parentheses) and dedupe by normalized form + const expanded = rawAcceptable.flatMap(a => this.expandAnswerVariants(a)); + const seen = new Set(); + const finalAnswers = []; + for (const a of expanded) { + const n = this.normalizeVocab(a); + if (!n || seen.has(n)) continue; + seen.add(n); + finalAnswers.push(a); + } + const fallback = direction === 'L2R' ? vocab.reference : vocab.learning; this.currentVocabQuestion = { vocab, prompt, - answers: acceptableAnswers.length > 0 - ? acceptableAnswers - : [direction === 'L2R' ? vocab.reference : vocab.learning], - answer: acceptableAnswers.length > 0 - ? acceptableAnswers.join(' / ') - : (direction === 'L2R' ? vocab.reference : vocab.learning), + answers: finalAnswers.length > 0 ? finalAnswers : [fallback], + answer: finalAnswers.length > 0 ? finalAnswers.join(' / ') : fallback, key: this.getVocabKey(vocab), source: 'hard' }; @@ -4072,9 +4079,10 @@ export default { : [vocab.learning]); const equivalentAnswers = this.getEquivalentVocabAnswers(prompt, direction, allTrainerVocabs); const mergedRaw = [...baseAnswers, ...equivalentAnswers].filter(Boolean); + const expandedMerged = mergedRaw.flatMap(a => this.expandAnswerVariants(a)); const seenNorm = new Set(); const acceptableAnswers = []; - for (const a of mergedRaw) { + for (const a of expandedMerged) { const n = this.normalizeVocab(a); if (!n || seenNorm.has(n)) continue; seenNorm.add(n);