diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-09-28 15:56:31 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-09-28 15:56:31 +0200 |
| commit | 482c006782c8270801d82e82e113fa5fba6b774d (patch) | |
| tree | 7c538097100ea633258064c0b1088e08e1071c24 /src/utils-common.ts | |
| parent | 5267fd80deb6ab5cdfba117b4f20f75b9f91fcfd (diff) | |
| download | bycs-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.ts | 14 |
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}`); |
