diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index bbef6ee..8e42e32 100644 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -39,7 +39,7 @@ -
+

{{ $t('socialnetwork.vocab.courses.importantVocab') }}

@@ -196,41 +196,52 @@ export default { }, importantVocab() { // Extrahiere wichtige Begriffe aus den Übungen - if (!this.lesson || !this.lesson.grammarExercises) return []; - - const vocabMap = new Map(); - - this.lesson.grammarExercises.forEach(exercise => { - // Extrahiere aus questionData - const qData = this.getQuestionData(exercise); - const aData = this.getAnswerData(exercise); - - if (qData && aData) { - // Für Multiple Choice: Extrahiere Optionen und richtige Antwort - if (this.getExerciseType(exercise) === 'multiple_choice') { - const correct = Array.isArray(aData.correct) ? aData.correct[0] : aData.correct; - const question = qData.text || ''; - - // Versuche die Frage zu analysieren (z.B. "Wie sagt man X auf Bisaya?") - const match = question.match(/['"]([^'"]+)['"]/); - if (match) { - const germanWord = match[1]; - vocabMap.set(correct, { learning: correct, reference: germanWord }); - } else if (correct) { - // Fallback: Verwende die richtige Antwort als Lernwort - vocabMap.set(correct, { learning: correct, reference: correct }); - } - } - - // Für Gap Fill: Extrahiere richtige Antworten - if (this.getExerciseType(exercise) === 'gap_fill' && aData.correct) { - const correct = Array.isArray(aData.correct) ? aData.correct[0] : aData.correct; - vocabMap.set(correct, { learning: correct, reference: correct }); - } + try { + if (!this.lesson || !this.lesson.grammarExercises || !Array.isArray(this.lesson.grammarExercises)) { + return []; } - }); - - return Array.from(vocabMap.values()); + + const vocabMap = new Map(); + + this.lesson.grammarExercises.forEach(exercise => { + try { + // Extrahiere aus questionData + const qData = this.getQuestionData(exercise); + const aData = this.getAnswerData(exercise); + + if (qData && aData) { + // Für Multiple Choice: Extrahiere Optionen und richtige Antwort + if (this.getExerciseType(exercise) === 'multiple_choice') { + const correct = Array.isArray(aData.correct) ? aData.correct[0] : aData.correct; + const question = qData.text || ''; + + // Versuche die Frage zu analysieren (z.B. "Wie sagt man X auf Bisaya?") + const match = question.match(/['"]([^'"]+)['"]/); + if (match) { + const germanWord = match[1]; + vocabMap.set(correct, { learning: correct, reference: germanWord }); + } else if (correct) { + // Fallback: Verwende die richtige Antwort als Lernwort + vocabMap.set(correct, { learning: correct, reference: correct }); + } + } + + // Für Gap Fill: Extrahiere richtige Antworten + if (this.getExerciseType(exercise) === 'gap_fill' && aData.correct) { + const correct = Array.isArray(aData.correct) ? aData.correct[0] : aData.correct; + vocabMap.set(correct, { learning: correct, reference: correct }); + } + } + } catch (e) { + console.warn('Fehler beim Extrahieren von Vokabeln aus Übung:', e); + } + }); + + return Array.from(vocabMap.values()); + } catch (e) { + console.error('Fehler in importantVocab computed property:', e); + return []; + } } }, computed: {