Enhance VocabLessonView and VocabService for grammar exercise handling
- Added logic to initialize grammar exercises directly from lesson data or load them separately if not included. - Introduced a new method to initialize answer arrays for gap fill exercises, improving user interaction and response tracking. - Updated comments for clarity on the exercise loading process and initialization logic.
This commit is contained in:
@@ -853,6 +853,19 @@ export default class VocabService {
|
||||
{
|
||||
model: VocabCourse,
|
||||
as: 'course'
|
||||
},
|
||||
{
|
||||
model: VocabGrammarExercise,
|
||||
as: 'grammarExercises',
|
||||
include: [
|
||||
{
|
||||
model: VocabGrammarExerciseType,
|
||||
as: 'exerciseType'
|
||||
}
|
||||
],
|
||||
required: false,
|
||||
separate: true,
|
||||
order: [['exerciseNumber', 'ASC']]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -132,9 +132,15 @@ export default {
|
||||
try {
|
||||
const res = await apiClient.get(`/api/vocab/lessons/${this.lessonId}`);
|
||||
this.lesson = res.data;
|
||||
// Lade Grammatik-Übungen
|
||||
// Initialisiere Übungen aus der Lektion oder lade sie separat
|
||||
if (this.lesson && this.lesson.id) {
|
||||
await this.loadGrammarExercises();
|
||||
if (this.lesson.grammarExercises && this.lesson.grammarExercises.length > 0) {
|
||||
// Übungen sind bereits in der Lektion enthalten
|
||||
this.initializeExercises(this.lesson.grammarExercises);
|
||||
} else {
|
||||
// Lade Übungen separat (Fallback)
|
||||
await this.loadGrammarExercises();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Konnte Lektion nicht laden:', e);
|
||||
@@ -142,22 +148,25 @@ export default {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
initializeExercises(exercises) {
|
||||
// Initialisiere Antwort-Arrays für Gap Fill Übungen
|
||||
exercises.forEach(exercise => {
|
||||
const exerciseType = this.getExerciseType(exercise);
|
||||
if (exerciseType === 'gap_fill') {
|
||||
const gapCount = this.getGapCount(exercise);
|
||||
this.$set(this.exerciseAnswers, exercise.id, new Array(gapCount).fill(''));
|
||||
} else {
|
||||
this.$set(this.exerciseAnswers, exercise.id, '');
|
||||
}
|
||||
this.$set(this.exerciseResults, exercise.id, null);
|
||||
});
|
||||
},
|
||||
async loadGrammarExercises() {
|
||||
try {
|
||||
const res = await apiClient.get(`/api/vocab/lessons/${this.lessonId}/grammar-exercises`);
|
||||
const exercises = res.data || [];
|
||||
this.lesson.grammarExercises = exercises;
|
||||
|
||||
// Initialisiere Antwort-Arrays für Gap Fill Übungen
|
||||
exercises.forEach(exercise => {
|
||||
const exerciseType = this.getExerciseType(exercise);
|
||||
if (exerciseType === 'gap_fill') {
|
||||
const gapCount = this.getGapCount(exercise);
|
||||
this.$set(this.exerciseAnswers, exercise.id, new Array(gapCount).fill(''));
|
||||
} else {
|
||||
this.$set(this.exerciseAnswers, exercise.id, '');
|
||||
}
|
||||
});
|
||||
this.initializeExercises(exercises);
|
||||
} catch (e) {
|
||||
console.error('Konnte Grammatik-Übungen nicht laden:', e);
|
||||
this.lesson.grammarExercises = [];
|
||||
|
||||
44
run-bisaya-content-script.sh
Executable file
44
run-bisaya-content-script.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# Script zum Ausführen des Bisaya-Content-Scripts auf dem Server
|
||||
# Verwendung: ./run-bisaya-content-script.sh [server_ip] [ssh_user]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SERVER_IP="${1:-your-part.de}"
|
||||
SSH_USER="${2:-root}"
|
||||
|
||||
echo "🚀 Führe Bisaya-Content-Script auf Server aus..."
|
||||
echo "Server: $SERVER_IP"
|
||||
echo "SSH User: $SSH_USER"
|
||||
echo ""
|
||||
|
||||
ssh "$SSH_USER@$SERVER_IP" << 'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
cd /opt/yourpart/backend
|
||||
|
||||
echo "📋 Prüfe ob Script vorhanden ist..."
|
||||
if [ ! -f "scripts/create-bisaya-course-content.js" ]; then
|
||||
echo "❌ Script nicht gefunden: scripts/create-bisaya-course-content.js"
|
||||
echo " Bitte zuerst Backend deployen!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Script gefunden"
|
||||
echo ""
|
||||
echo "🔧 Führe Script aus..."
|
||||
echo ""
|
||||
|
||||
# Führe Script als yourpart-Benutzer aus
|
||||
sudo -u yourpart node scripts/create-bisaya-course-content.js
|
||||
|
||||
echo ""
|
||||
echo "✅ Script erfolgreich ausgeführt!"
|
||||
EOF
|
||||
|
||||
echo ""
|
||||
echo "🎉 Fertig! Die Grammatik-Übungen wurden auf dem Server erstellt."
|
||||
echo ""
|
||||
echo "💡 Nächste Schritte:"
|
||||
echo " 1. Frontend neu bauen und deployen (falls noch nicht geschehen)"
|
||||
echo " 2. Browser-Cache leeren und Seite neu laden"
|
||||
Reference in New Issue
Block a user