quiz

Literature Quiz body { font-family: Arial, sans-serif; margin: 20px auto; max-width: 800px; padding: 20px; line-height: 1.6; } .question { margin-bottom: 20px; padding: 15px; border: 1px solid #ddd; border-radius: 5px; display: none; } .active { display: block; } button { padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; margin-top: 10px; } button:hover { background-color: #45a049; } #results { display: none; } #answers-review { margin-top: 20px; } .answer-item { margin: 10px 0; padding: 10px; border: 1px solid #ddd; border-radius: 5px; } .correct { background-color: #e8f5e9; } .incorrect { background-color: #ffebee; } #username { padding: 8px; margin: 10px 0; width: 200px; } #question-counter { margin: 10px 0; color: #666; } .status { font-weight: bold; margin-top: 5px; } Literature Quiz Start Quiz 1. Who wrote “1984”? a) George Orwell
b) Aldous Huxley
c) Ray Bradbury
d) Philip K. Dick
2. Which Shakespeare play features the character Ophelia? a) Macbeth
b) Hamlet
c) Romeo and Juliet
d) King Lear
3. Who wrote “Pride and Prejudice”? a) Emily Brontë
b) Jane Austen
c) Charlotte Brontë
d) Virginia Woolf
4. What is the name of the first book in “The Chronicles of Narnia” series? a) Prince Caspian
b) The Lion, the Witch and the Wardrobe
c) The Magician’s Nephew
d) The Silver Chair
5. Who is the author of “The Catcher in the Rye”? a) F. Scott Fitzgerald
b) J.D. Salinger
c) Ernest Hemingway
d) John Steinbeck
6. What is the setting of “The Great Gatsby”? a) New York in the 1920s
b) Chicago in the 1930s
c) Boston in the 1910s
d) Los Angeles in the 1940s
7. Which novel begins with the line “It was the best of times, it was the worst of times”? a) Great Expectations
b) A Tale of Two Cities
c) Oliver Twist
d) David Copperfield
8. Who wrote “To Kill a Mockingbird”? a) Harper Lee
b) Truman Capote
c) William Faulkner
d) Carson McCullers
9. What is the name of Don Quixote’s horse? a) Sancho
b) Rocinante
c) Dulcinea
d) Panza
10. Which poet wrote “The Raven”? a) Edgar Allan Poe
b) Walt Whitman
c) Emily Dickinson
d) Robert Frost
Next Question Quiz Results

Review Your Answers: Take Quiz Again let currentQuestion = 1; let score = 0; let userAnswers = {}; const totalQuestions = 10; const correctAnswers = { q1: {value: 'a', text: 'George Orwell'}, q2: {value: 'b', text: 'Hamlet'}, q3: {value: 'b', text: 'Jane Austen'}, q4: {value: 'b', text: 'The Lion, the Witch and the Wardrobe'}, q5: {value: 'b', text: 'J.D. Salinger'}, q6: {value: 'a', text: 'New York in the 1920s'}, q7: {value: 'b', text: 'A Tale of Two Cities'}, q8: {value: 'a', text: 'Harper Lee'}, q9: {value: 'b', text: 'Rocinante'}, q10: {value: 'a', text: 'Edgar Allan Poe'} }; function startQuiz() { const username = document.getElementById('username').value.trim(); if (!username) { alert('Please enter your name to start'); return; } document.getElementById('start-screen').style.display = 'none'; document.getElementById('quiz').style.display = 'block'; updateQuestionCounter(); } function updateQuestionCounter() { document.getElementById('question-counter').textContent = `Question ${currentQuestion} of ${totalQuestions}`; } function nextQuestion() { const currentAnswer = document.querySelector(`input[name="q${currentQuestion}"]:checked`); if (!currentAnswer) { alert('Please select an answer'); return; } userAnswers[`q${currentQuestion}`] = currentAnswer.value; if (currentAnswer.value === correctAnswers[`q${currentQuestion}`].value) { score ; } if (currentQuestion === totalQuestions) { showResults(); return; } document.querySelector(`.question[data-question="${currentQuestion}"]`).classList.remove('active'); currentQuestion ; document.querySelector(`.question[data-question="${currentQuestion}"]`).classList.add('active'); if (currentQuestion === totalQuestions) { document.getElementById('next-btn').textContent = 'Finish Quiz'; } updateQuestionCounter(); } function getOptionText(questionNumber, optionValue) { const question = document.querySelector(`.question[data-question="${questionNumber}"]`); const option = question.querySelector(`input[value="${optionValue}"]`); return option.parentNode.textContent.trim(); } function showResults() { const username = document.getElementById('username').value; document.getElementById('quiz').style.display = 'none'; document.getElementById('results').style.display = 'block'; const percentage = (score / totalQuestions) * 100; document.getElementById('score').textContent = `${username}, you scored ${score} out of ${totalQuestions} (${percentage}%)`; let feedback = ''; if (percentage >= 80) { feedback = 'Excellent! You have a fantastic knowledge of Literature!'; } else if (percentage >= 60) { feedback = 'Good job! You have a solid understanding of Literature.'; } else if (percentage >= 40) { feedback = 'Not bad! Keep studying to improve your knowledge.'; } else { feedback = 'Keep learning! There\'s room for improvement.'; } document.getElementById('feedback').textContent = feedback; const reviewDiv = document.getElementById('answers-review'); for (let i = 1; i <= totalQuestions; i ) { const qKey = `q${i}`; const div = document.createElement('div'); div.className = 'answer-item'; const questionText = document.querySelector(`.question[data-question="${i}"]`).querySelector('h3').textContent; const userAnswer = userAnswers[qKey]; const isCorrect = userAnswer === correctAnswers[qKey].value; const userAnswerText = userAnswer ? getOptionText(i, userAnswer) : 'No answer'; const correctAnswerText = correctAnswers[qKey].text; div.classList.add(isCorrect ? 'correct' : 'incorrect'); div.innerHTML = ` <p><strong>${questionText}</strong></p> <p>Your answer: ${userAnswerText}</p> <p>Correct answer: ${correctAnswerText}</p> ${isCorrect ? '<p class="status">✓ Correct!</p>' : '<p class="status">✗ Incorrect</p>'} `; reviewDiv.appendChild(div); } }

The post quiz first appeared on Ronald Hadrian.

 •  0 comments  •  flag
Share on Twitter
Published on December 21, 2024 05:47
No comments have been added yet.