feat(VocabLessonView): implement vocab trainer continue timer management
All checks were successful
Deploy to production / deploy (push) Successful in 2m2s
All checks were successful
Deploy to production / deploy (push) Successful in 2m2s
- Added a new timer management feature to the vocab trainer, allowing for better control over the continuation of questions after user answers. - Introduced `clearVocabTrainerContinueTimer` method to prevent multiple timers from running simultaneously, enhancing the stability of the training session. - Updated various methods to utilize the new timer management, ensuring a smoother user experience during vocabulary training.
This commit is contained in:
@@ -1084,6 +1084,7 @@ export default {
|
|||||||
vocabTrainerSelectedChoice: null,
|
vocabTrainerSelectedChoice: null,
|
||||||
vocabTrainerAnswered: false,
|
vocabTrainerAnswered: false,
|
||||||
vocabTrainerLastCorrect: false,
|
vocabTrainerLastCorrect: false,
|
||||||
|
vocabTrainerContinueTimer: null,
|
||||||
vocabTrainerDirection: 'L2R', // L2R: learning->reference, R2L: reference->learning
|
vocabTrainerDirection: 'L2R', // L2R: learning->reference, R2L: reference->learning
|
||||||
isCheckingLessonCompletion: false, // Flag um Endlosschleife zu verhindern
|
isCheckingLessonCompletion: false, // Flag um Endlosschleife zu verhindern
|
||||||
isNavigatingToNext: false, // Flag um mehrfache Navigation zu verhindern
|
isNavigatingToNext: false, // Flag um mehrfache Navigation zu verhindern
|
||||||
@@ -3329,6 +3330,7 @@ export default {
|
|||||||
// Vokabeltrainer-Methoden
|
// Vokabeltrainer-Methoden
|
||||||
startVocabTrainer() {
|
startVocabTrainer() {
|
||||||
debugLog('[VocabLessonView] startVocabTrainer aufgerufen');
|
debugLog('[VocabLessonView] startVocabTrainer aufgerufen');
|
||||||
|
this.clearVocabTrainerContinueTimer();
|
||||||
if (!this.trainableLessonVocab || this.trainableLessonVocab.length === 0) {
|
if (!this.trainableLessonVocab || this.trainableLessonVocab.length === 0) {
|
||||||
debugLog('[VocabLessonView] Keine Vokabeln vorhanden');
|
debugLog('[VocabLessonView] Keine Vokabeln vorhanden');
|
||||||
return;
|
return;
|
||||||
@@ -3361,6 +3363,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
stopVocabTrainer() {
|
stopVocabTrainer() {
|
||||||
|
this.clearVocabTrainerContinueTimer();
|
||||||
this.vocabTrainerActive = false;
|
this.vocabTrainerActive = false;
|
||||||
this.vocabTrainerMode = 'multiple_choice';
|
this.vocabTrainerMode = 'multiple_choice';
|
||||||
this.vocabTrainerAutoSwitchedToTyping = false;
|
this.vocabTrainerAutoSwitchedToTyping = false;
|
||||||
@@ -3564,10 +3567,17 @@ export default {
|
|||||||
return ranked[0]?.vocab || pool[Math.floor(Math.random() * pool.length)];
|
return ranked[0]?.vocab || pool[Math.floor(Math.random() * pool.length)];
|
||||||
},
|
},
|
||||||
continueAfterVocabAnswer() {
|
continueAfterVocabAnswer() {
|
||||||
|
this.clearVocabTrainerContinueTimer();
|
||||||
const completedKey = this.currentVocabQuestion?.key || '';
|
const completedKey = this.currentVocabQuestion?.key || '';
|
||||||
this.advanceRepeatQueue(completedKey);
|
this.advanceRepeatQueue(completedKey);
|
||||||
this.nextVocabQuestion();
|
this.nextVocabQuestion();
|
||||||
},
|
},
|
||||||
|
clearVocabTrainerContinueTimer() {
|
||||||
|
if (this.vocabTrainerContinueTimer) {
|
||||||
|
window.clearTimeout(this.vocabTrainerContinueTimer);
|
||||||
|
this.vocabTrainerContinueTimer = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
checkVocabModeSwitch() {
|
checkVocabModeSwitch() {
|
||||||
this.updateExerciseUnlockState();
|
this.updateExerciseUnlockState();
|
||||||
|
|
||||||
@@ -3731,6 +3741,7 @@ export default {
|
|||||||
},
|
},
|
||||||
nextVocabQuestion() {
|
nextVocabQuestion() {
|
||||||
debugLog('[VocabLessonView] nextVocabQuestion aufgerufen');
|
debugLog('[VocabLessonView] nextVocabQuestion aufgerufen');
|
||||||
|
this.clearVocabTrainerContinueTimer();
|
||||||
if (!this.vocabTrainerPool || this.vocabTrainerPool.length === 0) {
|
if (!this.vocabTrainerPool || this.vocabTrainerPool.length === 0) {
|
||||||
debugLog('[VocabLessonView] Keine Vokabeln im Pool');
|
debugLog('[VocabLessonView] Keine Vokabeln im Pool');
|
||||||
this.currentVocabQuestion = null;
|
this.currentVocabQuestion = null;
|
||||||
@@ -3951,9 +3962,19 @@ export default {
|
|||||||
// Prüfe ob noch Fragen vorhanden sind
|
// Prüfe ob noch Fragen vorhanden sind
|
||||||
if (this.vocabTrainerPool && this.vocabTrainerPool.length > 0) {
|
if (this.vocabTrainerPool && this.vocabTrainerPool.length > 0) {
|
||||||
const delay = this.vocabTrainerMode === 'multiple_choice' ? 1000 : 500; // 1 Sekunde für Multiple Choice, 500ms für Typing
|
const delay = this.vocabTrainerMode === 'multiple_choice' ? 1000 : 500; // 1 Sekunde für Multiple Choice, 500ms für Typing
|
||||||
setTimeout(() => {
|
const answeredQuestionKey = this.currentVocabQuestion?.key || '';
|
||||||
|
this.clearVocabTrainerContinueTimer();
|
||||||
|
this.vocabTrainerContinueTimer = window.setTimeout(() => {
|
||||||
|
this.vocabTrainerContinueTimer = null;
|
||||||
// Prüfe erneut, ob noch Fragen vorhanden sind (könnte sich geändert haben)
|
// Prüfe erneut, ob noch Fragen vorhanden sind (könnte sich geändert haben)
|
||||||
if (this.vocabTrainerPool && this.vocabTrainerPool.length > 0 && this.vocabTrainerActive) {
|
if (
|
||||||
|
this.vocabTrainerPool
|
||||||
|
&& this.vocabTrainerPool.length > 0
|
||||||
|
&& this.vocabTrainerActive
|
||||||
|
&& this.vocabTrainerAnswered
|
||||||
|
&& this.vocabTrainerLastCorrect
|
||||||
|
&& this.currentVocabQuestion?.key === answeredQuestionKey
|
||||||
|
) {
|
||||||
this.continueAfterVocabAnswer();
|
this.continueAfterVocabAnswer();
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
@@ -4089,6 +4110,7 @@ export default {
|
|||||||
window.clearTimeout(this.lessonStateSaveTimer);
|
window.clearTimeout(this.lessonStateSaveTimer);
|
||||||
this.lessonStateSaveTimer = null;
|
this.lessonStateSaveTimer = null;
|
||||||
}
|
}
|
||||||
|
this.clearVocabTrainerContinueTimer();
|
||||||
this.stopAssistantWaitTimer();
|
this.stopAssistantWaitTimer();
|
||||||
// Stoppe alle aktiven Recognition-Instanzen
|
// Stoppe alle aktiven Recognition-Instanzen
|
||||||
Object.keys(this.activeRecognition).forEach(exerciseId => {
|
Object.keys(this.activeRecognition).forEach(exerciseId => {
|
||||||
|
|||||||
Reference in New Issue
Block a user