Geografia Vero o Falso
let correctAnswers = 0;
function checkAnswer(question, correctOption) { var options = document.getElementsByName(question); for (var i = 0; i < options.length; i++) { if (options[i].checked) { if (options[i].value == correctOption) { options[i].parentElement.classList.add('correct'); correctAnswers++; } else { options[i].parentElement.classList.add('incorrect'); var correctElement = document.querySelector(`input[name="${question}"][value="${correctOption}"]`).parentElement; correctElement.classList.add('correct'); } break; } } document.getElementById(question + '-next').style.display = 'inline'; updateScore(); } function showNextQuestion(currentQuestion, nextQuestion) { document.getElementById(currentQuestion).style.display = 'none'; document.getElementById(nextQuestion).style.display = 'block'; } function updateScore() { document.getElementById('score').textContent = `${correctAnswers}/5`; } function restartQuiz() { correctAnswers = 0; var questions = document.getElementsByClassName('quiz-question'); for (var i = 0; i { option.classList.remove('correct', 'incorrect'); });
var inputs = document.querySelectorAll('.quiz-options input'); inputs.forEach(input => { input.checked = false; });
var nextButtons = document.querySelectorAll('.next-button'); nextButtons.forEach(button => { button.style.display = 'none'; });
document.getElementById('quiz-result').style.display = 'none';
updateScore();
}
Geografia Vero o Falso
Domanda 1: L’Australia è sia un paese che un continente.