kramars-realspeak / fm-gai-lottie-true-false-v1

0 stars 0 forks source link

Test Answer Evaluation Logic #12

Open Peter96K opened 1 day ago

Peter96K commented 1 day ago

In the current implementation if a user selects the correct answer, the sentence background is set to green. Otherwise it is set to red and strikethrough stiling is applied as well. Assess whether this user setting is appropirate in the sandbox with Ss.

script.js /

trueSpan.addEventListener('click', () => {
    const userChoice = trueSpan.textContent.trim().toUpperCase();
    const correctAnswer = jsonData.correct_answer.toUpperCase();

    if (userChoice === correctAnswer) {
      sentence_span.style.backgroundColor = '#8CC63F';
      sentence_span.style.color = 'white';
      sentence_div.marginLeft = '3vw';
      sentence_div.marginRight = '3vw';
    } else {
      sentence_span.style.backgroundColor = 'white';
      sentence_span.style.color = '#D32B45';
      sentence_span.style.textDecoration = 'line-through';
      sentence_div.marginLeft = '3vw';
      sentence_div.marginRight = '3vw';
    }
  });

  falseSpan.addEventListener('click', () => {
    const userChoice = falseSpan.textContent.trim().toUpperCase();
    const correctAnswer = jsonData.correct_answer.toUpperCase();

    if (userChoice === correctAnswer) {
      sentence_span.style.backgroundColor = '#8CC63F';
      sentence_span.style.color = 'white';
      sentence_div.marginLeft = '3vw';
      sentence_div.marginRight = '3vw';
    } else {
      sentence_span.style.backgroundColor = 'white';
      sentence_span.style.color = '#D32B45';
      sentence_span.style.textDecoration = 'line-through';
      sentence_div.marginLeft = '3vw';
      sentence_div.marginRight = '3vw';
    }
  });