85005c1c27
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22 lines
813 B
JavaScript
22 lines
813 B
JavaScript
// Minimal quiz widget — shared across lessons
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
document.querySelectorAll('.quiz').forEach(quiz => {
|
|
const radios = quiz.querySelectorAll('input[type="radio"]');
|
|
const feedbackCorrect = quiz.querySelector('.feedback.correct');
|
|
const feedbackWrong = quiz.querySelector('.feedback.wrong');
|
|
|
|
radios.forEach(radio => {
|
|
radio.addEventListener('change', () => {
|
|
if (feedbackCorrect) feedbackCorrect.style.display = 'none';
|
|
if (feedbackWrong) feedbackWrong.style.display = 'none';
|
|
|
|
if (radio.dataset.correct === 'true') {
|
|
if (feedbackCorrect) feedbackCorrect.style.display = 'block';
|
|
} else {
|
|
if (feedbackWrong) feedbackWrong.style.display = 'block';
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|