class 8 science chapter 13

ch13 part3

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Science Quiz – Earth's Habitability & Atmosphere</title>
<style>
  body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #a1c4fd, #c2e9fb);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px;
    min-height: 100vh;
  }
  .quiz-container {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 800px;
  }
  h2 { text-align: center; color: #1e3c72; }
  .question { font-weight: bold; margin: 10px 0; }
  .options label {
    display: block;
    margin: 8px 0;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: 0.3s;
  }
  .options label:hover { background: #f0f0f0; }
  .correct { background-color: #c8f7c5 !important; border-color: #28a745 !important; }
  .wrong { background-color: #f8d7da !important; border-color: #dc3545 !important; }
  .explanation {
    background: #e9ecef;
    padding: 10px;
    margin-top: 10px;
    border-left: 5px solid #2a5298;
    display: none;
  }
  .controls { text-align: center; margin-top: 15px; }
  button {
    background-color: #2a5298;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    margin: 5px;
  }
  button:hover { background-color: #1e3c72; }
  #scoreboard {
    margin-top: 25px;
    background: #eef3f7;
    padding: 15px;
    border-radius: 8px;
  }
  #scoreboard h3 { text-align: center; }
  ol { padding-left: 20px; }
</style>
</head>
<body>
  <div class="quiz-container">
    <h2>🧠 Science Quiz – Earth's Habitability & Atmosphere</h2>

    <div id="nameSection">
      <p><strong>Enter your name to start:</strong></p>
      <input type="text" id="userName" placeholder="Your Name">
      <button onclick="startQuiz()">Start Quiz</button>
    </div>

    <div id="quizSection" style="display:none;">
      <div id="questionContainer"></div>

      <div class="controls">
        <button onclick="prevQuestion()" id="prevBtn">Previous</button>
        <button onclick="nextQuestion()" id="nextBtn">Next</button>
        <button onclick="submitQuiz()" id="submitBtn" style="display:none;">Submit</button>
      </div>

      <div id="result" style="text-align:center; margin-top:20px;"></div>

      <div id="scoreboard">
        <h3>🏆 Scoreboard</h3>
        <ol id="scoreList"></ol>
      </div>
    </div>
  </div>

<script>
const questions = [
  {
    question: "1. Earth par life exist karne ka ek important reason kya hai?",
    options: [
      "A. Earth Sun ke bahut paas hai",
      "B. Earth Sun se suitable distance par hai",
      "C. Earth par sunlight nahi aati",
      "D. Earth par gravity nahi hai"
    ],
    correct: 1,
    explanation: "Earth Sun se aisi distance par hai jahan temperature suitable conditions mein water ko liquid form mein rehne deta hai. Liquid water life ke liye essential hai, jaisa hum jaante hain.<br><br>Example: Earth par rivers, lakes aur oceans mein liquid water milta hai, jo living organisms ko support karta hai."
  },
  {
    question: "2. Habitable zone ko aur kis naam se jaana jaata hai?",
    options: [
      "A. Frozen Zone",
      "B. Goldilocks Zone",
      "C. Rocky Zone",
      "D. Dark Zone"
    ],
    correct: 1,
    explanation: "Habitable zone star ke around woh range hai jahan suitable atmospheric conditions hone par water liquid form mein exist kar sakta hai. Isse Goldilocks Zone bhi kehte hain.<br><br>Example: Earth Sun ke habitable zone mein hai, isliye yahan liquid water ke liye suitable conditions possible hain."
  },
  {
    question: "3. Earth ko Blue Planet kyun kaha jaata hai?",
    options: [
      "A. Kyunki Earth par blue-coloured rocks hain",
      "B. Kyunki Earth ka atmosphere completely blue hai",
      "C. Kyunki Earth ki surface ka bahut bada hissa water se covered hai",
      "D. Kyunki Earth par sirf oceans hain"
    ],
    correct: 2,
    explanation: "Earth ki surface ka approximately 71% hissa water se covered hai. Space se dekhne par oceans ki wajah se Earth blue dikhti hai.<br><br>Example: Earth ki photographs mein Pacific aur Atlantic Oceans ke large blue areas dikhai dete hain."
  },
  {
    question: "4. Agar Earth Sun se bahut zyada door hoti, toh water par kya effect ho sakta tha?",
    options: [
      "A. Saara water automatically boil karta",
      "B. Water ka bahut bada hissa freeze ho sakta tha",
      "C. Water oxygen mein convert ho jaata",
      "D. Water par koi effect nahi hota"
    ],
    correct: 1,
    explanation: "Sun se zyada distance par planet ko kam solar energy milti. Isse temperature bahut low ho sakta tha aur liquid water ka exist karna difficult ho sakta tha.<br><br>Example: Extremely cold conditions mein lakes aur rivers ka water ice mein freeze ho sakta hai."
  },
  {
    question: "5. Earth ka size atmosphere ko maintain karne mein kaise help karta hai?",
    options: [
      "A. Earth ki gravity gases ko hold karne mein help karti hai",
      "B. Earth ki gravity gases ko space mein push karti hai",
      "C. Earth ke paas gravity nahi hai",
      "D. Earth sirf oxygen ko attract karti hai"
    ],
    correct: 0,
    explanation: "Earth ka suitable size aur gravity atmosphere ko hold karne mein important role play karte hain. Agar gravity bahut weak hoti, toh gases space mein escape kar sakti thi.<br><br>Example: Earth ka atmosphere nitrogen, oxygen aur other gases contain karta hai, jo planet ke environment ke liye important hain."
  },
  {
    question: "6. Mars ka atmosphere Earth ke comparison mein kaisa hai?",
    options: [
      "A. Mars ka atmosphere Earth se 100 times thicker hai",
      "B. Mars ka atmosphere approximately 100 times thinner hai",
      "C. Mars ka atmosphere Earth ke exactly equal hai",
      "D. Mars par atmosphere bilkul nahi hai"
    ],
    correct: 1,
    explanation: "Mars ka atmosphere Earth ke atmosphere se bahut thin hai. Isse Mars ki surface conditions Earth se kaafi different hoti hain.<br><br>Example: Mars par surface pressure bahut low hai, isliye liquid water ko surface par long periods tak stable rehna difficult hota hai."
  },
  {
    question: "7. Earth ki atmosphere mein oxygen ka main importance kya hai?",
    options: [
      "A. Yeh harmful UV rays ko completely absorb karti hai",
      "B. Yeh humans aur many other organisms ko respiration ke liye chahiye",
      "C. Yeh gravity produce karti hai",
      "D. Yeh sunlight ko completely block karti hai"
    ],
    correct: 1,
    explanation: "Oxygen cellular respiration mein important role play karti hai. Is process se organisms food se usable energy release karte hain.<br><br>Example: Humans breathing ke through oxygen lete hain, jo body cells ko energy release karne mein help karti hai."
  },
  {
    question: "8. Ozone layer living organisms ko kaise protect karti hai?",
    options: [
      "A. Harmful ultraviolet rays ko absorb karke",
      "B. Saari sunlight ko block karke",
      "C. Earth ki gravity ko increase karke",
      "D. Oceans ka water freeze karke"
    ],
    correct: 0,
    explanation: "Ozone layer atmosphere mein present ozone molecules se rich region hai. Yeh Sun ki harmful ultraviolet (UV) radiation ka large part absorb karti hai, jo living cells ko damage kar sakti hai.<br><br>Example: Excessive UV exposure human skin aur eyes ko harm kar sakta hai. Ozone layer is exposure ko reduce karne mein help karti hai."
  },
  {
    question: "9. Ozone molecule mein oxygen ke kitne atoms hote hain?",
    options: [
      "A. 1",
      "B. 2",
      "C. 3",
      "D. 4"
    ],
    correct: 2,
    explanation: "Normal oxygen molecule ka formula O₂ hai, jismein 2 oxygen atoms hote hain. Ozone ka formula O₃ hai, jismein 3 oxygen atoms hote hain.<br><br>Example: O₂ woh oxygen hai jise hum breathing mein use karte hain, jabki O₃ ozone hai jo stratosphere mein UV protection provide karta hai."
  },
  {
    question: "10. India ke Mangalyaan mission ka main purpose kya tha?",
    options: [
      "A. Moon par humans ko land karna",
      "B. Mars ko explore karna aur uski atmosphere aur surface ka study karna",
      "C. Sun par land karna",
      "D. Earth ke oceans ko explore karna"
    ],
    correct: 1,
    explanation: "Mangalyaan, jise Mars Orbiter Mission bhi kehte hain, ISRO ne 2013 mein launch kiya tha. Is mission ne Mars ki exploration aur scientific study mein India ki capability demonstrate ki.<br><br>Example: Mangalyaan ne Mars ki atmosphere aur surface ke baare mein information collect karne ke liye scientific instruments carry kiye the."
  }
];

let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";

function startQuiz() {
  userName = document.getElementById("userName").value.trim();

  if (!userName) {
    return alert("Please enter your name.");
  }

  document.getElementById("nameSection").style.display = "none";
  document.getElementById("quizSection").style.display = "block";

  showQuestion();
  loadScoreboard();
}

function showQuestion() {
  const q = questions[currentQuestion];
  const container = document.getElementById("questionContainer");

  container.innerHTML = `
    <div class="question">${q.question}</div>
    <div class="options">
      ${q.options.map((opt, i) => `
        <label>
          <input type="radio" name="option" value="${i}"
          ${userAnswers[currentQuestion] === i ? 'checked' : ''}>
          ${opt}
        </label>
      `).join('')}
    </div>
    <div class="explanation" id="explain${currentQuestion}">
      ${q.explanation}
    </div>
  `;

  document.getElementById("prevBtn").style.display =
    currentQuestion === 0 ? "none" : "inline-block";

  document.getElementById("nextBtn").style.display =
    currentQuestion === questions.length - 1 ? "none" : "inline-block";

  document.getElementById("submitBtn").style.display =
    currentQuestion === questions.length - 1 ? "inline-block" : "none";
}

function nextQuestion() {
  saveAnswer();

  if (currentQuestion < questions.length - 1) {
    currentQuestion++;
    showQuestion();
  }
}

function prevQuestion() {
  saveAnswer();

  if (currentQuestion > 0) {
    currentQuestion--;
    showQuestion();
  }
}

function saveAnswer() {
  const selected = document.querySelector('input[name="option"]:checked');

  userAnswers[currentQuestion] = selected
    ? parseInt(selected.value)
    : null;
}

function submitQuiz() {
  saveAnswer();

  score = 0;

  questions.forEach((q, index) => {
    if (userAnswers[index] === q.correct) {
      score++;
    }
  });

  showResults();
  saveScore(userName, score);
  loadScoreboard();
}

function showResults() {
  const container = document.getElementById("questionContainer");
  container.innerHTML = "";

  questions.forEach((q, index) => {
    const selected = userAnswers[index];
    const correct = q.correct;

    let optsHTML = q.options.map((opt, i) => {
      let cls = "";

      if (i === correct) {
        cls = "correct";
      }

      if (selected === i && selected !== correct) {
        cls = "wrong";
      }

      return `<label class="${cls}">${opt}</label>`;
    }).join('');

    container.innerHTML += `
      <div class="question">${q.question}</div>
      <div class="options">${optsHTML}</div>
      <div class="explanation" style="display:block;">
        ${q.explanation}
      </div>
      <hr>
    `;
  });

  document.querySelector(".controls").style.display = "none";

  document.getElementById("result").innerHTML = `
    <h3>Your Score: ${score} / ${questions.length}</h3>
  `;
}

function saveScore(name, score) {
  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];

  scores.push({
    name,
    score,
    date: new Date().toLocaleString()
  });

  localStorage.setItem("quizScores", JSON.stringify(scores));
}

function loadScoreboard() {
  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];

  scores.sort((a, b) => b.score - a.score);

  document.getElementById("scoreList").innerHTML = scores.map(s =>
    `<li>${s.name} - ${s.score}/${questions.length} (${s.date})</li>`
  ).join('');
}
</script>
</body>
</html>

Leave a Comment