feat: Erweiterung der akzeptierten Antworten im Vokabeltrainer durch Deduplizierung und Variantenaufspaltung
All checks were successful
Deploy to production / deploy (push) Successful in 2m13s
All checks were successful
Deploy to production / deploy (push) Successful in 2m13s
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user