class 8 science chapter 8

ch8 part 3

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Air Pollution and Mixtures Quiz</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>🧠 Air Pollution and Mixtures Quiz</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. Air mein present dust particles ko kya maana jaata hai?",
    options: [
      "A. Essential gases",
      "B. Pure substances",
      "C. Pollutants",
      "D. Water vapour"
    ],
    correct: 2,
    explanation: "Dust particles air mein suspended ho sakte hain aur air pollution ka kaaran ban sakte hain.<br><br><b>Example:</b> Road par vehicles chalne se dust hawa mein udti hai aur air quality kharab kar sakti hai."
  },

  {
    question: "2. AQI ka full form kya hai?",
    options: [
      "A. Air Quality Index",
      "B. Air Quantity Indicator",
      "C. Air Quick Inspection",
      "D. Atmospheric Quality Indicator"
    ],
    correct: 0,
    explanation: "AQI ka use air quality ko describe karne ke liye kiya jaata hai. Isse pata chalta hai ki air kitni polluted hai.<br><br><b>Example:</b> High AQI generally indicate karta hai ki air pollution zyada hai."
  },

  {
    question: "3. Inmein se kaunsa air pollutant hai?",
    options: [
      "A. Oxygen",
      "B. Carbon monoxide",
      "C. Pure water",
      "D. Common salt"
    ],
    correct: 1,
    explanation: "Carbon monoxide ek poisonous gas hai jo incomplete combustion ke dauran produce ho sakti hai.<br><br><b>Example:</b> Poor ventilation mein charcoal jalane se carbon monoxide jama ho sakti hai."
  },

  {
    question: "4. Science ke according, mixture ke components kaise hone chahiye?",
    options: [
      "A. Sirf gases",
      "B. Sirf liquids",
      "C. Pure substances",
      "D. Sirf solids"
    ],
    correct: 2,
    explanation: "Scientific definition ke according, mixture ke components pure substances hote hain. Ye components apni individual properties retain karte hain.<br><br><b>Example:</b> Sugar aur water ko mix karne par sugar-water mixture banta hai."
  },

  {
    question: "5. Air kis type ka mixture hai?",
    options: [
      "A. Solid and liquid",
      "B. Gas and gas",
      "C. Solid and solid",
      "D. Liquid and liquid"
    ],
    correct: 1,
    explanation: "Air mainly nitrogen, oxygen, argon, carbon dioxide aur water vapour ka mixture hai. Ye gases uniformly distributed hoti hain.<br><br><b>Example:</b> Hum saans lete waqt air se oxygen receive karte hain."
  },

  {
    question: "6. Oil aur water ka mixture kis type ka hota hai?",
    options: [
      "A. Uniform mixture",
      "B. Non-uniform mixture",
      "C. Pure substance",
      "D. Gas-gas mixture"
    ],
    correct: 1,
    explanation: "Oil aur water evenly mix nahi hote. Kuch samay baad ye separate layers bana lete hain.<br><br><b>Example:</b> Ek glass mein oil aur water daalne par oil ki layer water ke upar aa jaati hai."
  },

  {
    question: "7. Seawater mein mainly kaun-se do components present hote hain?",
    options: [
      "A. Sand and oxygen",
      "B. Salt and water",
      "C. Oil and water",
      "D. Sugar and water"
    ],
    correct: 1,
    explanation: "Seawater mein water ke andar salts dissolved hote hain. Dissolved salts generally evenly distributed hote hain, isliye seawater ek uniform mixture hai.<br><br><b>Example:</b> Seawater ko evaporate karne par salt crystals obtain kiye ja sakte hain."
  },

  {
    question: "8. Carbon particles in air kis type ka mixture hai?",
    options: [
      "A. Gas and gas",
      "B. Solid and gas",
      "C. Liquid and liquid",
      "D. Solid and liquid"
    ],
    correct: 1,
    explanation: "Carbon particles solid hote hain, jabki air gases ka mixture hai. Isliye carbon particles in air ek solid-gas mixture hai.<br><br><b>Example:</b> Vehicles se nikalne wala soot air mein suspended ho sakta hai."
  },

  {
    question: "9. Inmein se kaunsa uniform mixture ka example hai?",
    options: [
      "A. Oil and water",
      "B. Sand and water",
      "C. Properly dissolved salt solution",
      "D. Stones and sand"
    ],
    correct: 2,
    explanation: "Uniform mixture mein components evenly distributed hote hain aur separately distinguish nahi kiye ja sakte.<br><br><b>Example:</b> Jab salt water mein completely dissolve ho jaata hai, toh solution ke different parts mein salt uniformly distributed hota hai."
  },

  {
    question: "10. Science mein mixture ko separate karne ka main purpose kya hai?",
    options: [
      "A. New elements create karna",
      "B. Mixture ka colour change karna",
      "C. Pure substances obtain karna",
      "D. Hamesha gas produce karna"
    ],
    correct: 2,
    explanation: "Mixture separation se uske components ko alag kiya ja sakta hai. Science mein iska important purpose pure substances obtain karna hota hai.<br><br><b>Example:</b> Water ki distillation se dissolved salts ko separate karke pure water obtain kiya ja sakta hai."
  }

];

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}/10 (${s.date})</li>`
    ).join('');
}
</script>

</body>
</html>

Leave a Comment