Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions kit/src/lib/Question.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
// after the decimal.
return `${prefix}${Math.random().toString(36).substr(2, 9)}`;
}

function isSingleOption() {
// return whether there's single answer to the question or not
return choices.filter(c => c.correct).length === 1;
}

</script>

<div>
Expand Down Expand Up @@ -91,6 +97,8 @@
<span class="text-red-900 dark:text-red-200">
You didn't select all the correct answers, there's more!
</span>
{:else if isSingleOption()}
<span class="text-green-900 dark:text-green-200"> You got it right! </span>
{:else}
<span class="text-green-900 dark:text-green-200"> You got all the answers! </span>
{/if}
Expand Down