import { Graduation, GraduationChange, Observation } from "./graduation-common.ts"; import { Student } from "./student-common.ts"; import { buildGroups } from "./group.ts"; const students = [ new Student(1, "foo bar", "test"), new Student(2, "maxi mustermensch", "test"), new Student(3, "b b b", "5a"), ]; // Build the groups from our mock students buildGroups(students); async function fetchStudentsMock(_id?: number, _name?: string, _group?: string) { return students; } async function fetchSubjectsMock() { return ["Mathe", "Deutsch", "Englisch"]; } function fetchProgressMock(subject: string) { return new Promise((resolve) => { if (subject === "Mathe") { resolve([40, 10, 3]); } else if (subject === "Deutsch") { resolve([10, 2, 0]); } else if (subject === "Englisch") { resolve([50, 25, 10]); } else { resolve([0, 0, 0]); } }); } const graduations = new Map(); for (const s of students) { switch (s.name) { case "foo bar": graduations.set( s, Graduation.from(s, [ GraduationChange.newGreenPointChange("Gute Arbeit", "Florian Fischer"), GraduationChange.newOrangePointChange("", "Florian Fischer"), ]), ); break; case "maxi mustermensch": graduations.set( s, Graduation.from(s, [ GraduationChange.newGreenPointChange("", "Florian Fischer"), GraduationChange.newGreenPointChange("", "Florian Fischer"), new GraduationChange(new Date(), s.id, "ObservationStart", "", "Florian Fischer", ""), ]), ); break; case "b b b": graduations.set( s, Graduation.from(s, [GraduationChange.newRedPointChange("", "Florian Fischer")]), ); } } async function fetchGraduationMock(s: Student) { return graduations.get(s); } function submitGraduationChangeMock(s: Student, c: GraduationChange) { if (s.graduation === null) throw new Error("no graduation"); s.graduation.addChange(c); } function submitObservationMock(s: Student, o: Observation) { if (s.graduation === null) throw new Error("no graduation"); if (s.graduation.observation === null) throw new Error("no observation period"); s.graduation.observation.addObservation(o); } export { fetchStudentsMock, fetchSubjectsMock, fetchProgressMock, fetchGraduationMock, submitGraduationChangeMock, submitObservationMock, };