blob: 563f685bfd333822ef79e4b59c8c24bc21f9ec2d (
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
71
|
import { fetchStudentsMock } from "./mock.ts";
export {
DATE_FMT,
DATETIME_FMT,
dateStringNow,
datetimeStringNow,
getUserIconUrl,
} 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 getName() {
let name = "";
const params = new URLSearchParams(document.location.search);
if (params.has("firstname")) name = params.get("firstname");
if (params.has("lastname")) name += " " + params.get("lastname");
return name.trim();
}
export function getUserId() {
const name = getName();
return fetchStudentsMock.filter((s) => s.name === name)[0].id;
}
export function getActivityUrl(name) {
switch (name) {
case "Cockpit":
return "cockpit.html";
default:
return "";
}
}
export function getCourseId() {
return "1337";
}
export function getSesskey() {
return "sesskey";
}
export function getCourseParticipantsUrl() {
console.error("Try to get mocked participations URL");
return "";
}
export class CourseLocalStorage {
static getItem(key) {
return localStorage.getItem(`${key}-mock`);
}
static setItem(key, val) {
return localStorage.setItem(`${key}-mock`, val);
}
}
|