feat(VocabLessonView): enhance vocab trainer logic and answer normalization
All checks were successful
Deploy to production / deploy (push) Successful in 1m51s
All checks were successful
Deploy to production / deploy (push) Successful in 1m51s
- 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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user