feat: füge Unterstützung für temporäre gap_fill-Übungen aus chapterLexemeTraining hinzu
All checks were successful
Deploy to production / deploy (push) Successful in 2m0s

This commit is contained in:
Torsten Schulz (local)
2026-05-26 16:04:36 +02:00
parent 1232edd570
commit 52ee406165
2 changed files with 41 additions and 0 deletions

View File

@@ -2881,6 +2881,23 @@ export default class VocabService {
});
const plainLesson = lesson.get({ plain: true });
// Normalize exercise types: if question text contains clear gap placeholders,
// ensure the questionData.type is 'gap_fill' so the frontend renders the gap UI.
(plainLesson.grammarExercises || []).forEach((ex) => {
try {
const qData = typeof ex.questionData === 'string' ? JSON.parse(ex.questionData || '{}') : (ex.questionData || {});
const text = String(qData.text || qData.question || '').trim();
const hasUnderscoreGap = /_{3,}/.test(text);
const hasBraceGap = /\{\s*gap\s*\}/i.test(text);
const hasParenPlaceholders = /\(\s*_{0,}\s*\)/.test(text);
if ((hasUnderscoreGap || hasBraceGap || hasParenPlaceholders) && qData.type !== 'gap_fill') {
qData.type = 'gap_fill';
ex.questionData = qData;
}
} catch (err) {
// ignore parse errors
}
});
// Lade Vokabeln aus vorherigen Lektionen (für Wiederholung UND für gemischten Vokabeltrainer)
if (plainLesson.lessonNumber > 1) {