From bf09385a34f928e6c266d2f81337237955ee949b Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 25 Sep 2026 20:19:43 +0200 Subject: mass-graduation: keep student selection stable for 45 minutes --- src/utils-common.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/utils-common.ts') diff --git a/src/utils-common.ts b/src/utils-common.ts index 8053043..153bbaa 100644 --- a/src/utils-common.ts +++ b/src/utils-common.ts @@ -33,3 +33,18 @@ export async function getUserIconUrl(userId: number): Promise { return (userpicture as HTMLImageElement).src ?? ""; } + +// SplitMix32 implementation taken from: +// https://github.com/bryc/code/blob/master/jshash/PRNGs.md +// We only need a seeded PRNG to choose students to observe. +export function splitmix32(a: number) { + return function () { + a |= 0; + a = (a + 0x9e3779b9) | 0; + let t = a ^ (a >>> 16); + t = Math.imul(t, 0x21f0aaad); + t = t ^ (t >>> 15); + t = Math.imul(t, 0x735a2d97); + return ((t = t ^ (t >>> 15)) >>> 0) / 4294967296; + }; +} -- cgit v1.2.3