Ancient Civilisations

Ancient Civilisations Quiz
  
    body { font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f9; }
    h1 { text-align: center; }
    .question { margin-bottom: 20px; background: white; padding: 15px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
    .options { margin-top: 10px; }
    .options label { display: block; margin: 5px 0; }
    button { margin-top: 20px; padding: 10px 20px; font-size: 16px; border: none; background: #007bff; color: white; border-radius: 5px; cursor: pointer; }
    button:hover { background: #0056b3; }
    #results, #review { margin-top: 30px; font-size: 18px; font-weight: bold; }
    #review { margin-top: 40px; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
    .review-item { margin-bottom: 15px; }
    .correct { color: green; }
    .incorrect { color: red; }
  


  <h1>Ancient Civilisations Quiz</h1>
  
    <div id="questions"></div>
    Submit Quiz
  

  <div id="results"></div>
  <div id="review"></div>

  
    const quizData = [
      {q: "Where did the ancient Sumerians develop their civilisation?", options: ["Nile River", "Indus River", "Tigris and Euphrates Rivers", "Amazon River"], answer: 2},
      {q: "The plough was invented by the ancient Egyptians.", options: ["True", "False"], answer: 1},
      {q: "Did most ancient Egyptian cities have two main entrances?", options: ["Yes", "No"], answer: 0},
      {q: "What material were most houses made from in ancient Sumer and Egypt?", options: ["Stone", "Wood", "Mud bricks", "Metal"], answer: 2},
      {q: "Which king united the city states of ancient Sumer?", options: ["King Tutankhamun", "King Lugalzaggisi", "King Sargon", "King Ramses"], answer: 1},
      {q: "Place these civilisations in order: Ancient Sumer, Ancient Egypt, Indus Valley.", options: ["Sumer, Egypt, Indus", "Indus, Sumer, Egypt", "Egypt, Indus, Sumer", "Sumer, Indus, Egypt"], answer: 0},
      {q: "Which invention is NOT credited to the Sumerians?", options: ["Wheel", "Beer", "Shaduf", "Cuneiform writing"], answer: 2},
      {q: "The Indus Valley cities had sophisticated sewerage systems.", options: ["True", "False"], answer: 0},
      {q: "What was the main crop grown in ancient Egypt?", options: ["Rice", "Wheat", "Maize", "Potatoes"], answer: 1},
      {q: "Did Sumerian city states frequently go to war with each other?", options: ["Yes", "No"], answer: 0},
      {q: "Which river supported the Indus Valley civilisation?", options: ["Yellow River", "Ganges River", "Nile River", "Indus River"], answer: 3},
      {q: "Historians know a lot about how the Indus Valley was ruled.", options: ["True", "False"], answer: 1},
      {q: "What innovation helped ancient Egyptians move water for crops?", options: ["The wheel", "Shaduf", "Plough", "Dice"], answer: 1},
      {q: "What material did Egyptians use to make paper?", options: ["Papyrus", "Flax", "Linen", "Wheat"], answer: 0},
      {q: "Were the Great Bath and citadel part of Mohenjo-daro?", options: ["Yes", "No"], answer: 0},
      {q: "Ziggurats were large pyramids built from stone.", options: ["True", "False"], answer: 1},
      {q: "Which civilisation lasted the longest?", options: ["Ancient Egypt", "Ancient Sumer", "Indus Valley"], answer: 0},
      {q: "What was the first civilisation according to historians?", options: ["Ancient Egypt", "Indus Valley", "Ancient Sumer"], answer: 2},
      {q: "Did the Indus Valley people invent standardised weights and measures?", options: ["Yes", "No"], answer: 0},
      {q: "Tutankhamun's tomb was discovered by:", options: ["Howard Carter", "King Sargon", "Ramses II", "Alexander the Great"], answer: 0}
    ];

    const questionsContainer = document.getElementById('questions');
    quizData.forEach((item, index) =&gt; {
      const div = document.createElement('div');
      div.className = 'question';
      div.innerHTML = `<p><strong>Q${index + 1}:</strong> ${item.q}</p>` +
        item.options.map((opt, i) =&gt; `<div class='options'> ${opt}</div>`).join('');
      questionsContainer.appendChild(div);
    });

    function submitQuiz() {
      let score = 0;
      const userAnswers = [];

      quizData.forEach((item, index) =&gt; {
        const radios = document.getElementsByName(`q${index}`);
        let selected = null;
        radios.forEach(r =&gt; { if (r.checked) selected = parseInt(r.value); });
        userAnswers.push(selected);
        if (selected === item.answer) {
          score++;
        }
      });

      document.getElementById('results').innerText = `You scored ${score} out of ${quizData.length}!`;
      showReview(userAnswers);
    }

    function showReview(userAnswers) {
      const review = document.getElementById('review');
      review.innerHTML = '<h2>Review Answers</h2>';
      quizData.forEach((item, index) =&gt; {
        const isCorrect = userAnswers[index] === item.answer;
        const userAnswerText = userAnswers[index] !== null ? item.options[userAnswers[index]] : "No Answer";
        const correctAnswerText = item.options[item.answer];
        review.innerHTML += `<div class='review-item'><strong>Q${index + 1}:</strong> ${item.q}<br>Your answer: <span class='${isCorrect ? "correct" : "incorrect"}'>${userAnswerText}</span><br>Correct answer: <span class='correct'>${correctAnswerText}</span></div>`;
      });
    }