feat: füge neue Funktionen zur Analyse und Zählung von Lektionen hinzu, einschließlich der Generierung von Lernkontrollpunkten
All checks were successful
Deploy to production / deploy (push) Successful in 2m3s

This commit is contained in:
Torsten Schulz (local)
2026-05-21 16:33:57 +02:00
parent 8e5b990cf5
commit 1bd47fedb7
6 changed files with 312 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
const fs = require('fs');
const path = require('path');
function extractBlocks(content) {
// Find occurrences like 'Key': { ... corePatterns: [ ... ] ... }
const re = /['"]([^'"]+)['"]\s*:\s*\{([\s\S]*?)\n\s*\}/g;
const blocks = {};
let m;
while ((m = re.exec(content))) {
blocks[m[1]] = m[2];
}
return blocks;
}
function countCorePatternsInBlock(blockText) {
const cpRe = /corePatterns\s*:\s*\[([\s\S]*?)\]/g;
let m = cpRe.exec(blockText);
if (!m) return 0;
const arrText = m[1];
const targetRe = /\btarget\s*:/g;
return (arrText.match(targetRe) || []).length;
}
function parseDidacticsFile(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
const blocks = extractBlocks(content);
const counts = {};
let total = 0;
for (const [k, v] of Object.entries(blocks)) {
const c = countCorePatternsInBlock(v);
if (c > 0) {
counts[k] = c;
total += c;
}
}
return { counts, total };
}
function extractLessonArray(content, varName) {
// crude: find 'const VAR = [' up to closing '];'
const re = new RegExp(varName.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + "\\s*=\\s*\\[([\\s\\S]*?)\\];", 'm');
const m = re.exec(content);
if (!m) return null;
return m[1];
}
function countExamLessonsFromArrayText(arrayText) {
// Count objects with type:'review' or title containing checkpoint/test/abschluss (case-insensitive)
const objRe = /\{([\s\S]*?)\}(?=\s*,|$)/g;
let m;
let examCount = 0;
let total = 0;
while ((m = objRe.exec(arrayText))) {
total++;
const obj = m[1];
const typeMatch = /type\s*:\s*['"](\w+)['"]/.exec(obj);
const titleMatch = /title\s*:\s*['"]([\s\S]*?)['"]/.exec(obj);
const type = typeMatch ? typeMatch[1] : '';
const title = titleMatch ? titleMatch[1].toLowerCase() : '';
if (type === 'review' || /checkpoint|test|abschluss|prüfung|check/i.test(title)) {
examCount++;
}
}
return { examCount, total };
}
function analyze() {
const repoRoot = path.join(__dirname);
const file1 = path.join(repoRoot, 'bisaya-course-plan-24-43.js');
const file2 = path.join(repoRoot, 'bisaya-course-phase3-extension.js');
const res1 = parseDidacticsFile(file1);
const res2 = parseDidacticsFile(file2);
const f1 = fs.readFileSync(file1, 'utf8');
const f2 = fs.readFileSync(file2, 'utf8');
const arr1Text = extractLessonArray(f1, 'const BISAYA_LESSONS_24_43_BASE') || extractLessonArray(f1, 'BISAYA_LESSONS_24_43') || extractLessonArray(f1, 'BISAYA_LESSONS_24_43_BASE =');
const arr2Text = extractLessonArray(f2, 'export const BISAYA_PHASE3_LESSONS') || extractLessonArray(f2, 'BISAYA_PHASE3_LESSONS');
const a1 = arr1Text ? countExamLessonsFromArrayText(arr1Text) : { examCount: 0, total: 0 };
const a2 = arr2Text ? countExamLessonsFromArrayText(arr2Text) : { examCount: 0, total: 0 };
console.log('--- BISAYA 24-43 didactics corePatterns per key ---');
Object.entries(res1.counts).sort((a,b)=>b[1]-a[1]).forEach(([k,v])=>console.log(`${k}: ${v}`));
console.log(`Total corePatterns (24-43 files): ${res1.total}`);
console.log(`Lessons parsed in array (approx): ${a1.total}, exam-like lessons (type=review or title contains checkpoint/test/abschluss): ${a1.examCount}`);
console.log('\n--- BISAYA Phase3 didactics corePatterns per key ---');
Object.entries(res2.counts).sort((a,b)=>b[1]-a[1]).forEach(([k,v])=>console.log(`${k}: ${v}`));
console.log(`Total corePatterns (phase3 file): ${res2.total}`);
console.log(`Lessons parsed in phase3 array (approx): ${a2.total}, exam-like lessons: ${a2.examCount}`);
}
analyze();