Refactor hasExercises computed property in VocabLessonView for improved validation
- Enhanced the hasExercises method to include comprehensive checks for lesson and grammarExercises, ensuring robust validation before accessing properties. - Removed redundant computed property declaration to streamline the code structure. - Added additional logging for important vocabulary and grammar explanations to aid in debugging and provide better insights during lesson loading.
This commit is contained in:
@@ -264,7 +264,10 @@ export default {
|
||||
computed: {
|
||||
...mapGetters(['user']),
|
||||
hasExercises() {
|
||||
return this.lesson && this.lesson.grammarExercises && this.lesson.grammarExercises.length > 0;
|
||||
if (!this.lesson) return false;
|
||||
if (!this.lesson.grammarExercises) return false;
|
||||
if (!Array.isArray(this.lesson.grammarExercises)) return false;
|
||||
return this.lesson.grammarExercises.length > 0;
|
||||
},
|
||||
grammarExplanations() {
|
||||
// Extrahiere Grammatik-Erklärungen aus den Übungen
|
||||
@@ -365,9 +368,6 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['user'])
|
||||
},
|
||||
watch: {
|
||||
courseId() {
|
||||
this.loadLesson();
|
||||
@@ -390,6 +390,8 @@ export default {
|
||||
console.log('[VocabLessonView] Anzahl Übungen:', this.lesson?.grammarExercises?.length || 0);
|
||||
console.log('[VocabLessonView] activeTab:', this.activeTab);
|
||||
console.log('[VocabLessonView] hasExercises:', this.hasExercises);
|
||||
console.log('[VocabLessonView] importantVocab:', this.importantVocab);
|
||||
console.log('[VocabLessonView] grammarExplanations:', this.grammarExplanations);
|
||||
// Initialisiere Übungen aus der Lektion oder lade sie separat
|
||||
if (this.lesson && this.lesson.id) {
|
||||
if (this.lesson.grammarExercises && this.lesson.grammarExercises.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user