Randomize order of options
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
<script>
|
||||
import randomize from "../../rand.ts";
|
||||
|
||||
export let question;
|
||||
export let showResult = false;
|
||||
export let isCorrect = false;
|
||||
|
||||
|
||||
$: options = Object.keys(question.options).map(e => ({ key: e, value: question.options[e] }));
|
||||
$: options = randomize(Object.keys(question.options).map(e => ({ key: e, value: question.options[e] })));
|
||||
|
||||
let selected = [];
|
||||
$: isCorrect = selected.length === question.correct.length && selected.every(val => question.correct.find(v => v === val));
|
||||
|
@ -1,11 +1,12 @@
|
||||
<script>
|
||||
import randomize from "../../rand.ts";
|
||||
|
||||
export let question;
|
||||
export let showResult = false;
|
||||
|
||||
export let isCorrect = false;
|
||||
|
||||
|
||||
$: options = Object.keys(question.options).map(e => ({ key: e, value: question.options[e] }));
|
||||
$: options = randomize(Object.keys(question.options).map(e => ({ key: e, value: question.options[e] })));
|
||||
|
||||
let selected = undefined;
|
||||
$: isCorrect = selected === question.correct;
|
||||
|
Reference in New Issue
Block a user