Skip to content

Commit

Permalink
fix(lib): incorrect answer class names (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong authored Sep 26, 2024
1 parent aa58c28 commit 83874d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
20 changes: 2 additions & 18 deletions src/lib/Core.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,6 @@ function Core({
);
};

const isCorrectCheck = (index, correctAnswerIndex) => {
if (typeof correctAnswerIndex === 'string') {
return index === Number(correctAnswerIndex);
}

if (typeof correctAnswerIndex === 'object') {
return correctAnswerIndex.find((element) => element === index) !== undefined;
}

return false;
};

const renderQuizResultQuestions = useCallback(() => {
let filteredQuestions;
let filteredUserInput;
Expand Down Expand Up @@ -304,11 +292,7 @@ function Core({
<button
type="button"
disabled={answerButtons[index].disabled || false}
className={`${answerButtons[index].className || ''} answerBtn btn ${
isCorrectCheck(index + 1, correctAnswer) && showInstantFeedback
? 'correct'
: ''
}`}
className={`${answerButtons[index].className || ''} answerBtn btn`}
onClick={() => (revealAnswerOnSubmit ? onSelectAnswer(index) : onClickAnswer(index))}
>
{questionType === 'text' && <span>{answer}</span>}
Expand All @@ -319,7 +303,7 @@ function Core({
<button
type="button"
onClick={() => (revealAnswerOnSubmit ? onSelectAnswer(index) : onClickAnswer(index))}
className={`answerBtn btn ${(allowNavigation && checkSelectedAnswer(index + 1)) ? 'selected' : null}`}
className={`answerBtn btn ${(allowNavigation && checkSelectedAnswer(index + 1)) ? 'selected' : ''}`}
>
{questionType === 'text' && answer}
{questionType === 'photo' && <img src={answer} alt="answer" />}
Expand Down
9 changes: 0 additions & 9 deletions src/lib/core-components/helpers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ export const checkAnswer = (index, correctAnswer, answerSelectionType, answers,
}
}

for (let i = 0; i < answers.length; i += 1) {
if (correctAnswer.includes(i + 1)) {
setButtons((prevState) => ({
...prevState,
[i]: {},
}));
}
}

if (cnt === maxNumberOfMultipleSelection) {
correct.push(currentQuestionIndex);

Expand Down

0 comments on commit 83874d2

Please sign in to comment.