- Updated gap fill exercises in create-bisaya-course-content.js to include clearer instructions and contextual hints for better understanding. - Refined the logic in VocabLessonView.vue to prevent duplicate vocabulary entries and ensure only distinct translations are added, enhancing the learning experience. - Adjusted timing for transitioning between questions in VocabLessonView to improve user interaction flow.
90 lines
2.9 KiB
JavaScript
Executable File
90 lines
2.9 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
/**
|
|
* Script zum Korrigieren der Gap-Fill-Übung in "Begrüßungen & Höflichkeit"
|
|
* Fügt Muttersprache-Hinweise hinzu, damit Vokabeln korrekt extrahiert werden können
|
|
*/
|
|
|
|
import { sequelize } from '../utils/sequelize.js';
|
|
import VocabCourseLesson from '../models/community/vocab_course_lesson.js';
|
|
import VocabGrammarExercise from '../models/community/vocab_grammar_exercise.js';
|
|
import VocabCourse from '../models/community/vocab_course.js';
|
|
|
|
async function fixBegruessungenGapFill() {
|
|
await sequelize.authenticate();
|
|
console.log('Datenbankverbindung erfolgreich hergestellt.\n');
|
|
|
|
// Finde alle "Begrüßungen & Höflichkeit" Lektionen
|
|
const lessons = await VocabCourseLesson.findAll({
|
|
where: { title: 'Begrüßungen & Höflichkeit' },
|
|
include: [{ model: VocabCourse, as: 'course' }]
|
|
});
|
|
|
|
console.log(`Gefunden: ${lessons.length} "Begrüßungen & Höflichkeit"-Lektionen\n`);
|
|
|
|
let totalUpdated = 0;
|
|
|
|
for (const lesson of lessons) {
|
|
console.log(`📚 Kurs: ${lesson.course.title} (Kurs-ID: ${lesson.course.id}, Lektion-ID: ${lesson.id})`);
|
|
|
|
// Finde Gap-Fill-Übung mit "ko" als Antwort
|
|
const exercises = await VocabGrammarExercise.findAll({
|
|
where: {
|
|
lessonId: lesson.id,
|
|
exerciseTypeId: 1 // gap_fill
|
|
}
|
|
});
|
|
|
|
for (const exercise of exercises) {
|
|
const qData = typeof exercise.questionData === 'string'
|
|
? JSON.parse(exercise.questionData)
|
|
: exercise.questionData;
|
|
const aData = typeof exercise.answerData === 'string'
|
|
? JSON.parse(exercise.answerData)
|
|
: exercise.answerData;
|
|
|
|
// Prüfe ob es die problematische Übung ist (enthält "ko" als Antwort ohne Muttersprache-Hinweis)
|
|
if (aData.answers && aData.answers.includes('ko')) {
|
|
const text = qData.text || '';
|
|
|
|
// Prüfe ob Muttersprache-Hinweise fehlen
|
|
if (!text.includes('(ich)') && !text.includes('(I)')) {
|
|
console.log(` 🔧 Korrigiere Übung "${exercise.title}" (ID: ${exercise.id})`);
|
|
|
|
// Korrigiere den Text
|
|
const correctedText = text.replace(
|
|
'Maayo {gap}.',
|
|
'Maayo {gap} (ich).'
|
|
);
|
|
|
|
qData.text = correctedText;
|
|
|
|
await exercise.update({
|
|
questionData: qData
|
|
});
|
|
|
|
totalUpdated++;
|
|
console.log(` ✅ Aktualisiert: "${correctedText}"`);
|
|
} else {
|
|
console.log(` ✓ Übung "${exercise.title}" bereits korrekt`);
|
|
}
|
|
}
|
|
}
|
|
console.log('');
|
|
}
|
|
|
|
console.log(`\n🎉 Zusammenfassung:`);
|
|
console.log(` ${lessons.length} Lektionen verarbeitet`);
|
|
console.log(` ${totalUpdated} Übungen aktualisiert`);
|
|
}
|
|
|
|
fixBegruessungenGapFill()
|
|
.then(() => {
|
|
sequelize.close();
|
|
process.exit(0);
|
|
})
|
|
.catch((error) => {
|
|
console.error('❌ Fehler:', error);
|
|
sequelize.close();
|
|
process.exit(1);
|
|
});
|