Repository Public
1import { z } from "zod";2import raw from "../../content/paths.json";34export const LearningPath = z.object({ id: z.string(), audience: z.string(), title: z.string(), description: z.string(), sessions: z.array(z.string().regex(/^S\d{2,3}$/)).min(2) });5export type LearningPath = z.infer<typeof LearningPath>;6export const LEARNING_PATHS: LearningPath[] = z.array(LearningPath).parse(raw.paths);78/** Problems of a path against the course plan: unknown session, missing prerequisite, prerequisite placed after. */9export function pathProblems(path: LearningPath, sessions: { id: string; dependsOn: string[] }[]): string[] {10 const byId = new Map(sessions.map((s) => [s.id, s])), seen = new Set<string>(), out: string[] = [];11 for (const id of path.sessions) {12 const s = byId.get(id);13 if (!s) { out.push(`${id} n'existe pas dans le plan de cours`); continue; }14 if (seen.has(id)) out.push(`${id} apparaît deux fois`);15 for (const d of s.dependsOn) if (!seen.has(d)) out.push(`${id} vient avant son préalable ${d}, ou ${d} manque`);16 seen.add(id);17 }18 return out;19}20