feat(vocab): improve vocabulary preparation logic in VocabLessonView
All checks were successful
Deploy to production / deploy (push) Successful in 2m44s

- Refactored prepItems method to ensure only valid target-gloss pairs are included, enhancing the quality of vocabulary preparation.
- Introduced a mechanism to limit the output to a maximum of 30 unique pairs, improving the compactness of the preparation round.
- Enhanced handling of core patterns and extracted vocabulary to prioritize high-quality learning materials.
This commit is contained in:
Torsten Schulz (local)
2026-04-07 09:58:33 +02:00
parent 86dfb0d859
commit 62503191d4

View File

@@ -1296,12 +1296,32 @@ export default {
.filter(Boolean); .filter(Boolean);
}, },
prepItems() { prepItems() {
return this.lessonVocab // Vorbereitung nur mit echten Paaren (Zielsprache + Übersetzung),
.map((item) => ({ // damit weder leere Gloss-Zeilen noch übergroße Listen entstehen.
target: String(item?.reference || '').trim(), const out = [];
gloss: String(item?.learning || '').trim() const seen = new Set();
})) const pushUnique = (target, gloss) => {
.filter((item) => item.target); const t = String(target || '').trim();
const g = String(gloss || '').trim();
if (!t || !g) return;
const key = `${this.normalizeLessonVocabTerm(t)}|${this.normalizeLessonVocabTerm(g)}`;
if (seen.has(key)) return;
seen.add(key);
out.push({ target: t, gloss: g });
};
// 1) Didaktisch gepflegte Kernmuster zuerst (höchste Qualität)
this.normalizedCorePatterns.forEach((p) => {
pushUnique(p?.target, p?.gloss);
});
// 2) Ergänzung aus extrahierten Übungsvokabeln, aber nur saubere Paare
this.lessonVocab.forEach((item) => {
pushUnique(item?.reference, item?.learning);
});
// Begrenzen, damit die Vorbereitungsrunde kompakt bleibt
return out.slice(0, 30);
}, },
currentPrepItem() { currentPrepItem() {
return this.prepItems[this.lessonPrepIndex] || null; return this.prepItems[this.lessonPrepIndex] || null;