Skip to content

Commit

Permalink
fix(lib): disable answer after selected (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong authored Sep 26, 2024
1 parent fbce16b commit aa58c28
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/lib/core-components/helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,11 @@ export const checkAnswer = (index, correctAnswer, answerSelectionType, answers,
if (userInputCopy[currentQuestionIndex].length < maxNumberOfMultipleSelection) {
userInputCopy[currentQuestionIndex].push(index);

if (correctAnswer.includes(index)) {
if (userInputCopy[currentQuestionIndex].length <= maxNumberOfMultipleSelection) {
setButtons((prevState) => ({
...prevState,
[index - 1]: {
disabled: !prevState[index - 1],
className: (correctAnswer.includes(index)) ? 'correct' : 'incorrect',
},
}));
}
} else if (userInputCopy[currentQuestionIndex].length <= maxNumberOfMultipleSelection) {
if (userInputCopy[currentQuestionIndex].length <= maxNumberOfMultipleSelection) {
setButtons((prevState) => ({
...prevState,
[index - 1]: {
disabled: !prevState[index - 1],
className: (correctAnswer.includes(index)) ? 'correct' : 'incorrect',
},
}));
Expand Down

0 comments on commit aa58c28

Please sign in to comment.