From fe86e1b21b0ae531bd760b1247c513a81414c43d Mon Sep 17 00:00:00 2001 From: Jack Wilburn Date: Mon, 12 Aug 2024 14:59:58 -0600 Subject: [PATCH] Fix issue with checking dropdown/checkbox --- src/components/response/ResponseBlock.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/response/ResponseBlock.tsx b/src/components/response/ResponseBlock.tsx index 56de05a79..c12f20bc7 100644 --- a/src/components/response/ResponseBlock.tsx +++ b/src/components/response/ResponseBlock.tsx @@ -91,10 +91,15 @@ export default function ResponseBlock({ const correctAnswers = responses.every((response) => { const configCorrectAnswer = configInUse.correctAnswer?.find((answer) => answer.id === response.id)?.answer; - const suppliedAnswer = answerValidator.getInputProps(response.id, { - type: response.type === 'checkbox' ? 'checkbox' : 'input', - }).value; - return configCorrectAnswer === suppliedAnswer; + const suppliedAnswer = (answerValidator.values as Record)[response.id]; + + return Array.isArray(suppliedAnswer) + ? ( + typeof configCorrectAnswer === 'string' + ? (suppliedAnswer.length === 1 && configCorrectAnswer === suppliedAnswer[0]) + : (suppliedAnswer.length === configCorrectAnswer.length && suppliedAnswer.every((answer) => configCorrectAnswer.includes(answer))) + ) + : configCorrectAnswer === suppliedAnswer; }); if (hasCorrectAnswerFeedback) {