aboutsummaryrefslogtreecommitdiff
path: root/src/mock.ts
blob: 3ffcc53acde161d09f84dfafcf888af4e59759b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Graduation, GraduationChange } 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(false, "Gute Arbeit", "Florian Fischer"),
					GraduationChange.newOrangePointChange(true, "", "Florian Fischer"),
				]),
			);
			break;
		case "maxi mustermensch":
			graduations.set(
				s,
				Graduation.from(s, [
					GraduationChange.newGreenPointChange(false, "", "Florian Fischer"),
					GraduationChange.newGreenPointChange(false, "", "Florian Fischer"),
					GraduationChange.newCoachAssignmentChange({ 2: ["Florian Fischer"] }),
				]),
			);
			break;
		case "b b b":
			graduations.set(
				s,
				Graduation.from(s, [GraduationChange.newRedPointChange(false, "", "Florian Fischer")]),
			);
	}
}

async function fetchGraduationMock(s: Student) {
	return graduations.get(s);
}

export { fetchStudentsMock, fetchSubjectsMock, fetchProgressMock, fetchGraduationMock };