REvision Quiz 1
Interactive Literature Quiz body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; } .question { margin-bottom: 20px; } button { margin-top: 20px; } Interactive Literature Quiz Enter your name:
Submit Quiz const questions = [ { question: "Which author wrote 'To the Lighthouse'?", options: ["Virginia Woolf", "James Joyce", "E.M. Forster", "D.H. Lawrence"], answer: 0 }, { question: "'The Canterbury Tales' is a work by:", options: ["John Donne", "Geoffrey Chaucer", "Edmund Spenser", "Christopher Marlowe"], answer: 1 }, { question: "Who is the author of 'Middlemarch'?", options: ["Jane Austen", "Charlotte Brontë", "George Eliot", "Elizabeth Gaskell"], answer: 2 }, { question: "'Heart of Darkness' was written by:", options: ["Joseph Conrad", "Rudyard Kipling", "H.G. Wells", "Thomas Hardy"], answer: 0 }, { question: "Which poet wrote 'The Waste Land'?", options: ["W.B. Yeats", "T.S. Eliot", "Ezra Pound", "Robert Frost"], answer: 1 }, { question: "'Mrs. Dalloway' is a novel by:", options: ["Virginia Woolf", "Katherine Mansfield", "Sylvia Plath", "Doris Lessing"], answer: 0 }, { question: "Who authored 'The Picture of Dorian Gray'?", options: ["Oscar Wilde", "Charles Dickens", "William Makepeace Thackeray", "Thomas Hardy"], answer: 0 }, { question: "'The Faerie Queene' was written by:", options: ["John Milton", "Edmund Spenser", "Sir Philip Sidney", "Christopher Marlowe"], answer: 1 }, { question: "Which author wrote 'Brave New World'?", options: ["George Orwell", "Aldous Huxley", "Ray Bradbury", "H.G. Wells"], answer: 1 }, { question: "'Sons and Lovers' is a work by:", options: ["E.M. Forster", "D.H. Lawrence", "Thomas Hardy", "Joseph Conrad"], answer: 1 }, { question: "Who is the author of 'The Mill on the Floss'?", options: ["George Eliot", "Thomas Hardy", "Charles Dickens", "Elizabeth Gaskell"], answer: 0 }, { question: "'The Importance of Being Earnest' was written by:", options: ["George Bernard Shaw", "Oscar Wilde", "W. Somerset Maugham", "Noël Coward"], answer: 1 }, { question: "Which poet wrote 'Ode on a Grecian Urn'?", options: ["John Keats", "Percy Bysshe Shelley", "Lord Byron", "William Wordsworth"], answer: 0 }, { question: "'A Room with a View' is a novel by:", options: ["E.M. Forster", "Virginia Woolf", "D.H. Lawrence", "Evelyn Waugh"], answer: 0 }, { question: "Who authored 'Frankenstein'?", options: ["Mary Shelley", "Jane Austen", "Emily Brontë", "Ann Radcliffe"], answer: 0 } ]; function renderQuestions() { const questionsDiv = document.getElementById('questions'); questions.forEach((q, index) => { const questionHTML = ` <div class="question"> <p>${index + 1}. ${q.question}</p> ${q.options.map((option, i) => ` <input type="radio" id="q${index}_${i}" name="q${index}" value="${i}"> <label for="q${index}_${i}">${option}</label><br> `).join('')} </div> `; questionsDiv.innerHTML += questionHTML; }); } function submitQuiz() { const name = document.getElementById('name').value; if (!name) { alert('Please enter your name.'); return; } let score = 0; const results = []; questions.forEach((q, index) => { const selectedAnswer = document.querySelector(`input[name="q${index}"]:checked`); if (selectedAnswer) { const userAnswer = parseInt(selectedAnswer.value); if (userAnswer === q.answer) { score++; } results.push({ question: q.question, userAnswer: q.options[userAnswer], correctAnswer: q.options[q.answer], isCorrect: userAnswer === q.answer }); } else { results.push({ question: q.question, userAnswer: 'Not answered', correctAnswer: q.options[q.answer], isCorrect: false }); } }); displayResults(name, score, results); } function displayResults(name, score, results) { const resultsDiv = document.getElementById('results'); resultsDiv.innerHTML = ` <h2>Quiz Results for ${name}</h2> <p>Your score: ${score} out of ${questions.length}</p> <h3>Detailed Results:</h3> <ul> ${results.map((result, index) => ` <li> <strong>Question ${index + 1}:</strong> ${result.question}<br> Your answer: ${result.userAnswer}<br> Correct answer: ${result.correctAnswer}<br> ${result.isCorrect ? '<span style="color: green;">Correct!</span>' : '<span style="color: red;">Incorrect</span>'} </li> `).join('')} </ul> `; document.getElementById('quiz').style.display = 'none'; resultsDiv.style.display = 'block'; } renderQuestions();
Submit Quiz const questions = [ { question: "Which author wrote 'To the Lighthouse'?", options: ["Virginia Woolf", "James Joyce", "E.M. Forster", "D.H. Lawrence"], answer: 0 }, { question: "'The Canterbury Tales' is a work by:", options: ["John Donne", "Geoffrey Chaucer", "Edmund Spenser", "Christopher Marlowe"], answer: 1 }, { question: "Who is the author of 'Middlemarch'?", options: ["Jane Austen", "Charlotte Brontë", "George Eliot", "Elizabeth Gaskell"], answer: 2 }, { question: "'Heart of Darkness' was written by:", options: ["Joseph Conrad", "Rudyard Kipling", "H.G. Wells", "Thomas Hardy"], answer: 0 }, { question: "Which poet wrote 'The Waste Land'?", options: ["W.B. Yeats", "T.S. Eliot", "Ezra Pound", "Robert Frost"], answer: 1 }, { question: "'Mrs. Dalloway' is a novel by:", options: ["Virginia Woolf", "Katherine Mansfield", "Sylvia Plath", "Doris Lessing"], answer: 0 }, { question: "Who authored 'The Picture of Dorian Gray'?", options: ["Oscar Wilde", "Charles Dickens", "William Makepeace Thackeray", "Thomas Hardy"], answer: 0 }, { question: "'The Faerie Queene' was written by:", options: ["John Milton", "Edmund Spenser", "Sir Philip Sidney", "Christopher Marlowe"], answer: 1 }, { question: "Which author wrote 'Brave New World'?", options: ["George Orwell", "Aldous Huxley", "Ray Bradbury", "H.G. Wells"], answer: 1 }, { question: "'Sons and Lovers' is a work by:", options: ["E.M. Forster", "D.H. Lawrence", "Thomas Hardy", "Joseph Conrad"], answer: 1 }, { question: "Who is the author of 'The Mill on the Floss'?", options: ["George Eliot", "Thomas Hardy", "Charles Dickens", "Elizabeth Gaskell"], answer: 0 }, { question: "'The Importance of Being Earnest' was written by:", options: ["George Bernard Shaw", "Oscar Wilde", "W. Somerset Maugham", "Noël Coward"], answer: 1 }, { question: "Which poet wrote 'Ode on a Grecian Urn'?", options: ["John Keats", "Percy Bysshe Shelley", "Lord Byron", "William Wordsworth"], answer: 0 }, { question: "'A Room with a View' is a novel by:", options: ["E.M. Forster", "Virginia Woolf", "D.H. Lawrence", "Evelyn Waugh"], answer: 0 }, { question: "Who authored 'Frankenstein'?", options: ["Mary Shelley", "Jane Austen", "Emily Brontë", "Ann Radcliffe"], answer: 0 } ]; function renderQuestions() { const questionsDiv = document.getElementById('questions'); questions.forEach((q, index) => { const questionHTML = ` <div class="question"> <p>${index + 1}. ${q.question}</p> ${q.options.map((option, i) => ` <input type="radio" id="q${index}_${i}" name="q${index}" value="${i}"> <label for="q${index}_${i}">${option}</label><br> `).join('')} </div> `; questionsDiv.innerHTML += questionHTML; }); } function submitQuiz() { const name = document.getElementById('name').value; if (!name) { alert('Please enter your name.'); return; } let score = 0; const results = []; questions.forEach((q, index) => { const selectedAnswer = document.querySelector(`input[name="q${index}"]:checked`); if (selectedAnswer) { const userAnswer = parseInt(selectedAnswer.value); if (userAnswer === q.answer) { score++; } results.push({ question: q.question, userAnswer: q.options[userAnswer], correctAnswer: q.options[q.answer], isCorrect: userAnswer === q.answer }); } else { results.push({ question: q.question, userAnswer: 'Not answered', correctAnswer: q.options[q.answer], isCorrect: false }); } }); displayResults(name, score, results); } function displayResults(name, score, results) { const resultsDiv = document.getElementById('results'); resultsDiv.innerHTML = ` <h2>Quiz Results for ${name}</h2> <p>Your score: ${score} out of ${questions.length}</p> <h3>Detailed Results:</h3> <ul> ${results.map((result, index) => ` <li> <strong>Question ${index + 1}:</strong> ${result.question}<br> Your answer: ${result.userAnswer}<br> Correct answer: ${result.correctAnswer}<br> ${result.isCorrect ? '<span style="color: green;">Correct!</span>' : '<span style="color: red;">Incorrect</span>'} </li> `).join('')} </ul> `; document.getElementById('quiz').style.display = 'none'; resultsDiv.style.display = 'block'; } renderQuestions();
The post REvision Quiz 1 first appeared on Ronald Hadrian.
Published on September 11, 2024 06:51
No comments have been added yet.


