diff --git a/src/rand.ts b/src/rand.ts new file mode 100644 index 0000000..451c63f --- /dev/null +++ b/src/rand.ts @@ -0,0 +1,9 @@ +export default function randomize(input: T[]): T[] { + let res: T[] = []; + input = [...input]; + while (input.length > 0) { + let randomIndex = Math.floor(Math.random() * input.length); + res.push(...input.splice(randomIndex, 1)); + } + return res; +} \ No newline at end of file diff --git a/src/views/questions/SelectMultiple.svelte b/src/views/questions/SelectMultiple.svelte index 381a64e..993ecfd 100644 --- a/src/views/questions/SelectMultiple.svelte +++ b/src/views/questions/SelectMultiple.svelte @@ -1,10 +1,12 @@