aboutsummaryrefslogtreecommitdiff
path: root/src/utils-mock.js
blob: cd3c10c623b8621f96946761198e4039eebea27f (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
import { fetchStudentsMock, getName } from "./mock.ts";
export { getName } from "./mock.ts";
export {
	CourseLocalStorage,
	DATE_FMT,
	DATETIME_FMT,
	dateStringNow,
	datetimeStringNow,
	getCourseId,
	getUserIconUrl,
	getUserId,
	splitmix32,
} from "./utils-common.ts";

export function isTeacher() {
	return !new URLSearchParams(document.location.search).has("student");
}

export function getFirstAndLastname() {
	let firstname = "";
	let lastname = "";

	const params = new URLSearchParams(document.location.search);
	if (params.has("firstname")) firstname = params.get("firstname");
	if (params.has("lastname")) lastname = params.get("lastname");

	return [firstname, lastname];
}

export function getActivityUrl(name) {
	switch (name) {
		case "Cockpit":
			return "cockpit.html";
		default:
			return "";
	}
}

export function getSesskey() {
	return "sesskey";
}

export function getCourseParticipantsUrl() {
	console.error("Try to get mocked participations URL");
	return "";
}