Skip to content

Commit

Permalink
update training checkings
Browse files Browse the repository at this point in the history
  • Loading branch information
elizaan committed Aug 12, 2024
2 parents 50800e8 + fe86e1b commit 99207ec
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/response/ResponseBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>)[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) {
Expand Down

0 comments on commit 99207ec

Please sign in to comment.