aboutsummaryrefslogtreecommitdiff
path: root/src/utils-common.ts
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2026-09-28 15:56:31 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2026-09-28 15:56:31 +0200
commit482c006782c8270801d82e82e113fa5fba6b774d (patch)
tree7c538097100ea633258064c0b1088e08e1071c24 /src/utils-common.ts
parent5267fd80deb6ab5cdfba117b4f20f75b9f91fcfd (diff)
downloadbycs-sol-482c006782c8270801d82e82e113fa5fba6b774d.tar.gz
bycs-sol-482c006782c8270801d82e82e113fa5fba6b774d.zip
utils: move get*Id functions into utils-common.ts
Diffstat (limited to 'src/utils-common.ts')
-rw-r--r--src/utils-common.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/utils-common.ts b/src/utils-common.ts
index 153bbaa..7bca889 100644
--- a/src/utils-common.ts
+++ b/src/utils-common.ts
@@ -22,6 +22,20 @@ export function datetimeStringNow() {
return DATETIME_FMT.format(new Date());
}
+declare global {
+ var M: { cfg: { userId: number; courseId: number } };
+}
+
+export function getUserId(): number {
+ // M is exported by Moodle
+ return globalThis.M.cfg.userId;
+}
+
+export function getCourseId(): number {
+ // M is exported by Moodle
+ return globalThis.M.cfg.courseId;
+}
+
// TODO(muhq): Cache the retrieved URL
export async function getUserIconUrl(userId: number): Promise<string> {
const userRes = await fetch(`https://lernplattform.bycs.de/user/profile.php?id=${userId}`);