The Essential French Revolution Quiz Class 9,Master It!
Correct Answer: A) i → ii → iii → iv –
Population growth (i) → production shortfall (ii) → price rise (iii) → wage stagnation (iv).
Common Sense Clue: Cause-effect chain: More people → higher demand → low supply → inflation → wages lag.
` }, { question: "A peasant in 18th-century France would most likely be required to:", options: [ "Pay tithes to the Church and taille to the state", "Serve as a clergy member", "Advise the king on economic policies", "Trade salt and tobacco tax-free" ], correctAnswer: 0, // Index of "Pay tithes to the Church and taille to the state" explanation: `
Correct Answer: A) Pay tithes to the Church and taille to the state –
Peasants paid tithes (Church tax) and taille (state tax).
Why Others Are Wrong:
- B/D: Clergy roles and tax-free trade were privileges of other estates.
- C: Peasants had no political power.
Common Sense Clue: The text emphasizes the Third Estate’s tax burden.
` } ];// DOM elements const container = document.getElementById('french-revolution-quiz'); const quizContent = container.querySelector('#quiz-content'); const resultsContent = container.querySelector('#results-content'); const questionTextEl = container.querySelector('#question-text'); const optionsGrid = container.querySelector('#options-grid'); const explanationContainer = container.querySelector('#explanation-container'); const explanationContent = container.querySelector('#explanation-content'); const explanationBtn = container.querySelector('#explanation-btn'); const feedbackAnimation = container.querySelector('#feedback-animation'); // Select the Lottie player directly const wrongLottiePlayer = document.getElementById('wrong-lottie-player'); const prevBtn = container.querySelector('#prev-btn'); const nextBtn = container.querySelector('#next-btn'); const restartQuizBtn = container.querySelector('#restart-quiz-btn'); const finalScoreEl = container.querySelector('#final-score'); const scoreTextEl = container.querySelector('#score-text'); const feedbackTextEl = container.querySelector('#feedback-text');// Quiz state let currentQuestionIndex = 0; let score = 0; let answered = false; let userAnswers = Array(quizData.length).fill(null); // Initialize quiz function initQuiz() { currentQuestionIndex = 0; score = 0; userAnswers = Array(quizData.length).fill(null); // Show quiz content, hide results content quizContent.style.display = 'block'; resultsContent.style.display = 'none';loadQuestion(currentQuestionIndex); } // Load question function loadQuestion(index) { const question = quizData[index]; answered = false; // Reset UI optionsGrid.innerHTML = ''; explanationContainer.classList.remove('show'); explanationBtn.classList.remove('active'); explanationBtn.innerHTML = ' Explanation'; // Reset button text // Hide and stop Lottie animation feedbackAnimation.classList.remove('show'); if (wrongLottiePlayer) { wrongLottiePlayer.stop(); }// Prepend the question number to the question text questionTextEl.textContent = `${index + 1}. ${question.question}`;question.options.forEach((option, i) => { const optionEl = document.createElement('div'); optionEl.classList.add('option'); optionEl.textContent = option; optionEl.dataset.index = i; // Store index for easy lookup optionEl.addEventListener('click', () => selectOption(optionEl, i));// If already answered, apply appropriate classes and disable if (userAnswers[index] !== null) { optionEl.classList.add('disabled'); if (Array.isArray(question.correctAnswer)) { if (question.correctAnswer.includes(i)) { optionEl.classList.add('correct'); } else if (userAnswers[index].includes(i)) { optionEl.classList.add('incorrect'); } } else { if (i === question.correctAnswer) { optionEl.classList.add('correct'); } else if (i === userAnswers[index]) { optionEl.classList.add('incorrect'); } } } optionsGrid.appendChild(optionEl); });updateNavigationButtons(); // Show explanation if already answered if (userAnswers[index] !== null) { showExplanation(); } }// Select option function selectOption(selectedOptionEl, selectedIndex) { if (answered) return; // Prevent re-answering answered = true;const question = quizData[currentQuestionIndex]; let isCorrect = false;// Handle single or multiple correct answers if (Array.isArray(question.correctAnswer)) { // For multiple correct answers, we assume a single selection for simplicity in this UI. // If the user selects one of the correct answers, it's marked correct. // For a true multiple-choice, the UI would need checkboxes and a "Submit" button. if (question.correctAnswer.includes(selectedIndex)) { isCorrect = true; } userAnswers[currentQuestionIndex] = [selectedIndex]; // Store the single selected answer } else { if (selectedIndex === question.correctAnswer) { isCorrect = true; } userAnswers[currentQuestionIndex] = selectedIndex; // Store the single selected answer }// Apply styling based on correctness if (isCorrect) { selectedOptionEl.classList.add('correct'); score++;// Get the bounding box of the question container const questionContainerRect = container.querySelector('.question-container').getBoundingClientRect();// Create a temporary canvas for confetti to confine it const confettiCanvas = document.createElement('canvas'); confettiCanvas.style.position = 'absolute'; confettiCanvas.style.top = `${questionContainerRect.top + window.scrollY}px`; confettiCanvas.style.left = `${questionContainerRect.left + window.scrollX}px`; confettiCanvas.style.width = `${questionContainerRect.width}px`; confettiCanvas.style.height = `${questionContainerRect.height}px`; confettiCanvas.style.pointerEvents = 'none'; // Allow clicks to pass through confettiCanvas.style.zIndex = '9999'; // Ensure it's on top document.body.appendChild(confettiCanvas); // Corrected: ensure this is a complete statementconst myConfetti = confetti.create(confettiCanvas, { resize: true }); // Corrected: proper variable assignment and function callmyConfetti({ particleCount: 800, // Even denser spread: 180, // Wider spread to fill the area startVelocity: 70, // Higher initial velocity scalar: 2.2, // Even larger particles // Origin relative to the *confettiCanvas* (which is positioned over the question-container) origin: { x: 0.5, y: 0.5 }, colors: ['#000000', '#1a1a1a', '#333333', '#4d4d4d', '#666666', '#808080'], // Darker, HD grayscale colors shapes: ['circle', 'square', 'star', 'line'], // More variety of shapes disableForReducedMotion: true });// Remove the confetti canvas after a delay setTimeout(() => { confettiCanvas.remove(); }, 4000); // Adjust duration as needed} else { selectedOptionEl.classList.add('incorrect'); // Show Lottie animation for wrong answer feedbackAnimation.classList.add('show'); if (wrongLottiePlayer) { wrongLottiePlayer.play(); } // Find and highlight the correct answer Array.from(optionsGrid.children).forEach((optionEl) => { if (Array.isArray(question.correctAnswer)) { if (question.correctAnswer.includes(parseInt(optionEl.dataset.index))) { optionEl.classList.add('correct'); } } else { if (parseInt(optionEl.dataset.index) === question.correctAnswer) { optionEl.classList.add('correct'); } } });// Hide Lottie after a short delay setTimeout(() => { feedbackAnimation.classList.remove('show'); if (wrongLottiePlayer) { wrongLottiePlayer.stop(); } }, 1500); // Animation duration + a little extra }// Disable all options after selection Array.from(optionsGrid.children).forEach(option => { option.classList.add('disabled'); });showExplanation(); }// Show explanation function showExplanation() { const question = quizData[currentQuestionIndex]; explanationContent.innerHTML = `


