Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
parmsam committed Sep 4, 2024
1 parent 1764bfc commit ecc2608
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions _extensions/quiz/quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,14 @@ window.RevealQuiz = function () {
// console.log(cloneFeedbackElement);
if (selectedOption && !isAnswered) {
isAnswered = true;
// console.log(selectedOption);
//check if selected option has span and if it has class of correct
let isCorrect = selectedOption.querySelector('span') && selectedOption.querySelector('span').classList.contains('correct');
let explanation = selectedOption.querySelector('span').getAttribute('data-explanation'); // Get the explanation attribute
// check if selected option has and data-explanation attribute
let hasExplanation = selectedOption.querySelector('span') && selectedOption.querySelector('span').hasAttribute('data-explanation');
let explanation = null;
if (hasExplanation) {
explanation = selectedOption.querySelector('span').getAttribute('data-explanation');
}
if (isCorrect) {
selectedOption.classList.add('correct');
cloneFeedbackElement.textContent = explanation || 'Correct!'; // Use explanation if available
Expand Down

0 comments on commit ecc2608

Please sign in to comment.