feat(bisaya-course): add new lesson and update course creation logic
All checks were successful
Deploy to production / deploy (push) Successful in 2m51s

- Introduced a new lesson titled "Zahlen & Preise" to enhance the numerical curriculum in Bisaya.
- Updated the course creation logic to check for existing "Familien"-Bisaya courses, ensuring idempotency in course creation.
- Enhanced the lesson didactics by mapping legacy titles to current lesson keys, improving data consistency.
- Adjusted the course generation script to limit Bisaya courses to German-speaking learners only, streamlining course offerings.
This commit is contained in:
Torsten Schulz (local)
2026-04-16 22:16:23 +02:00
parent 6dce418728
commit 68ac5ec281
6 changed files with 406 additions and 21 deletions

View File

@@ -10,7 +10,12 @@ import { sequelize } from '../utils/sequelize.js';
import VocabCourseLesson from '../models/community/vocab_course_lesson.js';
import { getBisayaLessonPedagogy } from './bisaya-course-phase2-pedagogy.js';
const LESSON_DIDACTICS = {
/** Alte Kurstitel → aktueller Schlüssel in LESSON_DIDACTICS (bestehende Datenbanken). */
export const LEGACY_DIDACTICS_TITLE_MAP = {
'Zahlen & Preise': 'Zahlen 120'
};
export const LESSON_DIDACTICS = {
'Begrüßungen & Höflichkeit': {
learningGoals: [
'Einfache Begrüßungen verstehen und selbst verwenden.',
@@ -438,6 +443,14 @@ const LESSON_DIDACTICS = {
}
};
function resolveDidacticsForLesson(lesson) {
const direct = LESSON_DIDACTICS[lesson.title];
if (direct) return direct;
const mappedTitle = LEGACY_DIDACTICS_TITLE_MAP[lesson.title];
if (mappedTitle) return LESSON_DIDACTICS[mappedTitle];
return null;
}
async function updateBisayaDidactics() {
await sequelize.authenticate();
const [bisayaLanguage] = await sequelize.query(
@@ -464,25 +477,29 @@ async function updateBisayaDidactics() {
let updated = 0;
for (const row of lessons) {
const lesson = await VocabCourseLesson.findByPk(row.id);
const didactics = LESSON_DIDACTICS[lesson.title];
const didactics = resolveDidacticsForLesson(lesson);
const pedagogy = getBisayaLessonPedagogy(lesson.lessonNumber);
if (!didactics && !pedagogy) continue;
const normalizedDidactics = didactics || {};
await lesson.update({
learningGoals: normalizedDidactics.learningGoals || [],
corePatterns: normalizedDidactics.corePatterns || [],
grammarFocus: normalizedDidactics.grammarFocus || [],
speakingPrompts: normalizedDidactics.speakingPrompts || [],
practicalTasks: normalizedDidactics.practicalTasks || [],
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)
});
const patch = {};
if (didactics) {
patch.learningGoals = didactics.learningGoals || [];
patch.corePatterns = didactics.corePatterns || [];
patch.grammarFocus = didactics.grammarFocus || [];
patch.speakingPrompts = didactics.speakingPrompts || [];
patch.practicalTasks = didactics.practicalTasks || [];
}
if (pedagogy) {
patch.didacticMode = pedagogy.didacticMode || null;
patch.phaseLabel = pedagogy.phaseLabel || null;
patch.blockNumber = pedagogy.blockNumber ?? null;
patch.difficultyWeight = pedagogy.difficultyWeight ?? null;
patch.newUnitTarget = pedagogy.newUnitTarget ?? null;
patch.reviewWeight = pedagogy.reviewWeight ?? null;
patch.isIntensiveReview = Boolean(pedagogy.isIntensiveReview);
}
await lesson.update(patch);
updated++;
console.log(`✅ Didaktik aktualisiert: Lektion ${lesson.lessonNumber} - ${lesson.title}`);
}