Refactor updateFoodCareExercises function to optimize database queries and improve code clarity

- Replaced the Sequelize findAll method with a raw SQL query to fetch Bisaya courses along with native language information, enhancing performance.
- Updated variable names for consistency and clarity, ensuring better readability of the code.
- Adjusted the handling of course owner IDs to align with the new query structure, improving data integrity.
This commit is contained in:
Torsten Schulz (local)
2026-01-21 13:22:03 +01:00
parent a21a2314d7
commit 3018b1f2e1
4 changed files with 77 additions and 18 deletions

View File

@@ -408,7 +408,8 @@
"recordingError": "Aufnahme-Fehler",
"recognizedText": "Erkannter Text",
"speechRecognitionNotSupported": "Speech Recognition wird von diesem Browser nicht unterstützt. Bitte verwende Chrome oder Edge.",
"keywords": "Schlüsselwörter"
"keywords": "Schlüsselwörter",
"switchBackToMultipleChoice": "Zurück zu Multiple Choice"
}
}
}

View File

@@ -408,7 +408,8 @@
"recordingError": "Recording error",
"recognizedText": "Recognized Text",
"speechRecognitionNotSupported": "Speech Recognition is not supported by this browser. Please use Chrome or Edge.",
"keywords": "Keywords"
"keywords": "Keywords",
"switchBackToMultipleChoice": "Switch back to Multiple Choice"
}
}
}

View File

@@ -110,6 +110,11 @@
</div>
<!-- Texteingabe Modus -->
<div v-else class="vocab-answer-area typing">
<div v-if="vocabTrainerAutoSwitchedToTyping" class="mode-switch-notice">
<button @click="switchBackToMultipleChoice" class="btn-switch-mode">
{{ $t('socialnetwork.vocab.courses.switchBackToMultipleChoice') }}
</button>
</div>
<input
v-model="vocabTrainerAnswer"
@keydown.enter.prevent="checkVocabAnswer"
@@ -430,6 +435,7 @@ export default {
vocabTrainerActive: false,
vocabTrainerPool: [],
vocabTrainerMode: 'multiple_choice', // 'multiple_choice' oder 'typing'
vocabTrainerAutoSwitchedToTyping: false, // Track ob automatisch zu Typing gewechselt wurde
vocabTrainerCorrect: 0,
vocabTrainerWrong: 0,
vocabTrainerTotalAttempts: 0,
@@ -997,6 +1003,7 @@ export default {
this.vocabTrainerActive = true;
this.vocabTrainerPool = [...this.importantVocab];
this.vocabTrainerMode = 'multiple_choice';
this.vocabTrainerAutoSwitchedToTyping = false;
this.vocabTrainerCorrect = 0;
this.vocabTrainerWrong = 0;
this.vocabTrainerTotalAttempts = 0;
@@ -1008,6 +1015,8 @@ export default {
},
stopVocabTrainer() {
this.vocabTrainerActive = false;
this.vocabTrainerMode = 'multiple_choice';
this.vocabTrainerAutoSwitchedToTyping = false;
this.currentVocabQuestion = null;
this.vocabTrainerAnswer = '';
this.vocabTrainerSelectedChoice = null;
@@ -1029,6 +1038,7 @@ export default {
const successRate = (this.vocabTrainerCorrect / this.vocabTrainerTotalAttempts) * 100;
if (successRate >= 80) {
this.vocabTrainerMode = 'typing';
this.vocabTrainerAutoSwitchedToTyping = true; // Markiere als automatisch gewechselt
// Reset Stats für Texteingabe-Modus
this.vocabTrainerCorrect = 0;
this.vocabTrainerWrong = 0;
@@ -1036,6 +1046,17 @@ export default {
}
}
},
switchBackToMultipleChoice() {
// Wechsle zurück zu Multiple Choice
this.vocabTrainerMode = 'multiple_choice';
this.vocabTrainerAutoSwitchedToTyping = false;
// Reset Stats für Multiple Choice Modus
this.vocabTrainerCorrect = 0;
this.vocabTrainerWrong = 0;
this.vocabTrainerTotalAttempts = 0;
// Starte neue Frage im Multiple Choice Modus
this.nextVocabQuestion();
},
buildChoiceOptions(correctAnswer, allVocabs, excludePrompt = null) {
const options = new Set([correctAnswer]);
// Normalisiere alle Werte für den Vergleich (trim + lowercase)
@@ -1765,9 +1786,37 @@ export default {
.vocab-answer-area.typing {
display: flex;
flex-direction: column;
gap: 10px;
}
.mode-switch-notice {
margin-bottom: 10px;
padding: 10px;
background: #fff3cd;
border: 1px solid #ffc107;
border-radius: 4px;
text-align: center;
}
.btn-switch-mode {
padding: 8px 16px;
background: #F9A22C;
color: #000000;
border: 1px solid #F9A22C;
border-radius: 4px;
cursor: pointer;
font-size: 0.9em;
font-weight: 500;
transition: background 0.05s;
}
.btn-switch-mode:hover {
background: #fdf1db;
color: #7E471B;
border: 1px solid #7E471B;
}
.vocab-answer-area.multiple-choice {
display: flex;
flex-direction: column;