From b63a8fafd5a6049010e10b93fa3cb21f0b9e4fb2 Mon Sep 17 00:00:00 2001 From: recluzegeek Date: Thu, 22 May 2025 07:16:21 +0000 Subject: [PATCH] Improve feedback for single-option questions --- kit/src/lib/Question.svelte | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kit/src/lib/Question.svelte b/kit/src/lib/Question.svelte index 96c0f94d..c436d5fb 100644 --- a/kit/src/lib/Question.svelte +++ b/kit/src/lib/Question.svelte @@ -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; + } +
@@ -91,6 +97,8 @@ You didn't select all the correct answers, there's more! + {:else if isSingleOption()} + You got it right! {:else} You got all the answers! {/if}