#!/usr/bin/env node /** * Erweitert bestehende Bisaya-Kurse um die Stabilisierungsphase. * * Verwendung: * node backend/scripts/extend-bisaya-course-phase5.js */ import { sequelize } from '../utils/sequelize.js'; import VocabCourse from '../models/community/vocab_course.js'; import VocabCourseLesson from '../models/community/vocab_course_lesson.js'; import { getBisayaLessonPedagogy } from './bisaya-course-phase2-pedagogy.js'; import { BISAYA_PHASE5_DIDACTICS, BISAYA_PHASE5_LESSONS } from './bisaya-course-phase5-extension.js'; async function extendBisayaCoursePhase5() { await sequelize.authenticate(); const [bisayaLanguage] = await sequelize.query( `SELECT id FROM community.vocab_language WHERE name = 'Bisaya' LIMIT 1`, { type: sequelize.QueryTypes.SELECT } ); if (!bisayaLanguage) { console.error('❌ Bisaya-Sprache nicht gefunden.'); return; } const courses = await VocabCourse.findAll({ where: { languageId: bisayaLanguage.id } }); let addedLessons = 0; for (const course of courses) { await course.update({ title: 'Bisaya für Familien - Alltag & Stabilisierung', description: 'Lerne Bisaya (Cebuano) praxisnah für den Familienalltag. Der Pfad verbindet Schnellstart, Alltagsmodule und Stabilisierungsblöcke mit Spiralwiederholung, Fehlertraining und freier Produktion.' }); for (const lessonData of BISAYA_PHASE5_LESSONS) { const existing = await VocabCourseLesson.findOne({ where: { courseId: course.id, lessonNumber: lessonData.num } }); if (existing) { continue; } const didactics = BISAYA_PHASE5_DIDACTICS[lessonData.title] || {}; const pedagogy = getBisayaLessonPedagogy(lessonData.num) || {}; await VocabCourseLesson.create({ courseId: course.id, chapterId: null, lessonNumber: lessonData.num, title: lessonData.title, description: lessonData.desc, weekNumber: lessonData.week, dayNumber: lessonData.day, lessonType: lessonData.type, culturalNotes: lessonData.cultural, learningGoals: didactics.learningGoals || [], corePatterns: didactics.corePatterns || [], grammarFocus: didactics.grammarFocus || [], speakingPrompts: didactics.speakingPrompts || [], practicalTasks: didactics.practicalTasks || [], targetMinutes: lessonData.targetMin, targetScorePercent: lessonData.targetScore, requiresReview: lessonData.review, didacticMode: pedagogy.didacticMode || null, phaseLabel: pedagogy.phaseLabel || null, blockNumber: pedagogy.blockNumber ?? null, difficultyWeight: pedagogy.difficultyWeight ?? null, newUnitTarget: pedagogy.newUnitTarget ?? null, reviewWeight: pedagogy.reviewWeight ?? null, isIntensiveReview: Boolean(pedagogy.isIntensiveReview) }); addedLessons++; console.log(`✅ Kurs ${course.id}: Lektion ${lessonData.num} - ${lessonData.title} ergänzt`); } } console.log(`\n🎉 Phase 5 vorbereitet.`); console.log(` Kurse: ${courses.length}`); console.log(` Neue Lektionen ergänzt: ${addedLessons}`); console.log(' Das Einspielen in die DB kann später gesammelt mit den übrigen Phasen erfolgen.'); } extendBisayaCoursePhase5() .then(() => { sequelize.close(); process.exit(0); }) .catch((error) => { console.error('❌ Fehler:', error); sequelize.close(); process.exit(1); });