From 305e137a1ade39f6b39310ab650d992380160836 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 19 Jan 2026 16:08:39 +0100 Subject: [PATCH] Reset exercise answers and results in VocabLessonView before loading new lessons - Added logic to clear previous exercise answers and results when loading a new lesson, ensuring accurate tracking of user responses. - Simplified the handling of exercise answers and results by directly assigning values instead of using Vue's `$set` method, improving code readability. --- frontend/src/views/social/VocabLessonView.vue | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index 4cb352b..704fae1 100644 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -129,6 +129,9 @@ export default { methods: { async loadLesson() { this.loading = true; + // Setze Antworten und Ergebnisse zurück + this.exerciseAnswers = {}; + this.exerciseResults = {}; try { const res = await apiClient.get(`/api/vocab/lessons/${this.lessonId}`); this.lesson = res.data; @@ -154,11 +157,11 @@ export default { const exerciseType = this.getExerciseType(exercise); if (exerciseType === 'gap_fill') { const gapCount = this.getGapCount(exercise); - this.$set(this.exerciseAnswers, exercise.id, new Array(gapCount).fill('')); + this.exerciseAnswers[exercise.id] = new Array(gapCount).fill(''); } else { - this.$set(this.exerciseAnswers, exercise.id, ''); + this.exerciseAnswers[exercise.id] = ''; } - this.$set(this.exerciseResults, exercise.id, null); + this.exerciseResults[exercise.id] = null; }); }, async loadGrammarExercises() { @@ -259,7 +262,7 @@ export default { } const res = await apiClient.post(`/api/vocab/grammar-exercises/${exerciseId}/check`, { answer }); - this.$set(this.exerciseResults, exerciseId, res.data); + this.exerciseResults[exerciseId] = res.data; } catch (e) { console.error('Fehler beim Prüfen der Antwort:', e); alert(e.response?.data?.error || 'Fehler beim Prüfen der Antwort');