Add levels 08-12 (functions, dicts, files, libraries, errors), persistent data/ folder, narration

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-16 17:04:09 +02:00
parent 88879ce8fb
commit b19d3c038d
55 changed files with 1337 additions and 11 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ const root = new URL('../../', import.meta.url).pathname.replace(/\/$/, '');
const e = new LessonEngine({ levelsUrl: 'http://x/levels/', fetchFn: async (u) => {
try { const t = await readFile(root + new URL(u).pathname, 'utf8'); return { ok: true, text: async () => t }; }
catch { return { ok: false, status: 404 }; } } });
assert.deepEqual((await e.listLevels()).map((l) => l.id), ['00-intro', '01-hello', '02-variables', '03-input', '04-math', '05-decide', '06-lists', '07-while']);
assert.deepEqual((await e.listLevels()).map((l) => l.id), ['00-intro', '01-hello', '02-variables', '03-input', '04-math', '05-decide', '06-lists', '07-while', '08-functions', '09-dicts', '10-files', '11-libraries', '12-errors']);
const s = await e.startLevel('02-variables', 'en');
assert.equal(s.title, 'Variables and types'); assert.equal(s.stepCount, 7);
assert.equal(s.step.type, 'explain');
@@ -23,7 +23,7 @@ test('les solutions de référence passent, les codes de départ échouent', { s
let checked = 0;
for (const id of readdirSync(`${root}levels`).filter((name) => /^\d\d-/.test(name))) {
const { exercises, problems } = await checker.check(load(id));
assert.deepEqual(summary(problems), [], `${id}`);
assert.deepEqual(summary(problems), [], `${id} : ${JSON.stringify(problems)}`);
checked += exercises.length;
}
assert.ok(checked > 0);