Skip to content

Commit

Permalink
update multiple-choice-dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
d471061c committed Aug 9, 2023
1 parent 347d8b7 commit 604f50e
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,31 @@ const assessMultipleChoiceDropdown = (
)
}

const correct = quizItemAnswer.selectedOptionIds.length == 1
// No option was selected
if (quizItemAnswer.selectedOptionIds.length == 0) {
return {
quizItemId: quizItem.id,
correct: false,
correctnessCoefficient: 0,
}
}

const selectedOption = quizItemAnswer.selectedOptionIds[0]
const answer = quizItem.options.find((item) => item.id == selectedOption)

// Answer does not exist in quiz item
if (!answer) {
return {
quizItemId: quizItem.id,
correct: false,
correctnessCoefficient: 0,
}
}

return {
quizItemId: quizItem.id,
correct,
correctnessCoefficient: correct ? 1 : 0,
correct: answer.correct,
correctnessCoefficient: answer.correct ? 1 : 0,
}
}

Expand Down

0 comments on commit 604f50e

Please sign in to comment.