feat: Erweiterung der akzeptierten Antworten im Vokabeltrainer durch Deduplizierung und Variantenaufspaltung
All checks were successful
Deploy to production / deploy (push) Successful in 2m13s

This commit is contained in:
Torsten Schulz (local)
2026-05-20 16:10:57 +02:00
parent 97b4b01b22
commit 431dd0bd37

View File

@@ -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);