class 8 science chapter 12

ch12 part3

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Science Quiz – Ecosystem and Interactions</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 – Ecosystem and Interactions</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. Pond mein fish ki presence nearby plants mein seed production ko kaise affect kar sakti hai?",
    options: [
      "A. Fish directly plants ko seeds banane mein help karti hain.",
      "B. Fish dragonfly larvae ko khati hain, jisse pollinators ki sankhya badh sakti hai.",
      "C. Fish sunlight ko increase karti hain.",
      "D. Fish plants ki roots ko nutrients deti hain."
    ],
    correct: 1,
    explanation: "Fish dragonfly larvae ko khati hain. Isse dragonflies ki sankhya kam ho sakti hai. Dragonflies kam hone par bees aur butterflies jaise pollinators zyada ho sakte hain, jo seed production mein help karte hain.<br><br><strong>Example:</strong> Bees ek flower ka pollen doosre flower tak le jaati hain, jisse plants seeds produce kar sakte hain."
  },
  {
    question: "2. Pollination mein bees aur butterflies ka kya role hota hai?",
    options: [
      "A. Plants ki roots ko strong banana",
      "B. Soil ko moist rakhna",
      "C. Pollen ko ek flower se doosre flower tak le jaana",
      "D. Plants ko oxygen dena"
    ],
    correct: 2,
    explanation: "Bees aur butterflies flowers par visit karti hain aur pollen transfer karne mein help karti hain. Is process se plants mein reproduction aur seed formation mein help milti hai.<br><br><strong>Example:</strong> Bee jab ek sunflower se doosre sunflower par jaati hai, toh pollen transfer ho sakta hai."
  },
  {
    question: "3. Overfishing se pond ke ecosystem par kya effect ho sakta hai?",
    options: [
      "A. Ecosystem ka balance change ho sakta hai.",
      "B. Sabhi organisms ki sankhya hamesha badhegi.",
      "C. Abiotic components disappear ho jayenge.",
      "D. Plants ko sunlight ki zaroorat nahi rahegi."
    ],
    correct: 0,
    explanation: "Overfishing se fish ki population bahut kam ho sakti hai. Isse food chain aur doosre organisms ki populations affect ho sakti hain. Ecosystem mein biotic aur abiotic components ek-doosre ko influence karte hain.<br><br><strong>Example:</strong> Fish kam hone par dragonfly larvae ki sankhya badh sakti hai, jo aage food chain ko affect kar sakti hai."
  },
  {
    question: "4. Inmein se kaunsa biotic aur abiotic components ke interaction ka example hai?",
    options: [
      "A. Frog insects ko khata hai.",
      "B. Water snake fish ko khata hai.",
      "C. Earthworm moist soil mein rehta hai.",
      "D. Bees aur butterflies flowers par visit karti hain."
    ],
    correct: 2,
    explanation: "Biotic components living organisms hote hain, jabki abiotic components non-living things hote hain. Earthworm living organism hai aur soil non-living component hai.<br><br><strong>Example:</strong> Plants soil se water aur nutrients absorb karte hain."
  },
  {
    question: "5. Frog insects ko khata hai. Yeh kis type ka interaction hai?",
    options: [
      "A. Do abiotic components ke beech",
      "B. Do biotic components ke beech",
      "C. Biotic aur abiotic components ke beech",
      "D. Sirf non-living components ke beech"
    ],
    correct: 1,
    explanation: "Frog aur insects dono living organisms hain. Jab ek organism doosre organism ko food ke liye use karta hai, toh yeh biotic interaction hota hai.<br><br><strong>Example:</strong> A water snake fish ko khata hai. Yeh bhi do biotic components ke beech interaction hai."
  },
  {
    question: "6. Bright sunlight ki wajah se daytime temperature high hona kis interaction ka example hai?",
    options: [
      "A. Do biotic components ke beech",
      "B. Biotic aur abiotic components ke beech",
      "C. Do abiotic components ke beech",
      "D. Predator aur prey ke beech"
    ],
    correct: 2,
    explanation: "Sunlight aur temperature dono abiotic components hain. Sunlight ki energy se surroundings ka temperature increase ho sakta hai.<br><br><strong>Example:</strong> Garmiyon mein bright sunlight ke kaaran pond ka surface water warm ho sakta hai."
  },
  {
    question: "7. Ecosystem kya hota hai?",
    options: [
      "A. Sirf plants ka group",
      "B. Sirf animals ka group",
      "C. Living organisms aur non-living components ka interaction system",
      "D. Sirf water aur soil ka combination"
    ],
    correct: 2,
    explanation: "Ecosystem mein plants, animals aur microorganisms jaise biotic components, air, water, soil aur sunlight jaise abiotic components ke saath interact karte hain.<br><br><strong>Example:</strong> Pond ecosystem mein fish, frogs, plants, water, sunlight aur microorganisms ek-doosre se interact karte hain."
  },
  {
    question: "8. Inmein se kaunsa aquatic ecosystem ka example hai?",
    options: [
      "A. Desert",
      "B. Grassland",
      "C. River",
      "D. Farmland"
    ],
    correct: 2,
    explanation: "Aquatic ecosystems water-based ecosystems hote hain. Rivers, ponds aur lakes aquatic ecosystems ke examples hain. Forests, grasslands aur farms terrestrial ecosystems hain.<br><br><strong>Example:</strong> River mein fish, aquatic plants aur microorganisms water ke saath interact karte hain."
  },
  {
    question: "9. Plants ki roots soil ko erosion se kaise bachati hain?",
    options: [
      "A. Roots soil ko pakad kar rakhti hain.",
      "B. Roots sunlight produce karti hain.",
      "C. Roots soil ko air mein uda deti hain.",
      "D. Roots water ko oxygen mein convert karti hain."
    ],
    correct: 0,
    explanation: "Plants ki roots soil particles ko bind karke rakhti hain. Isse wind aur flowing water ke kaaran soil ke behne ya udne ka risk kam hota hai.<br><br><strong>Example:</strong> Hills par trees ki roots rainfall ke samay soil ko behne se rokne mein help karti hain."
  },
  {
    question: "10. Plants photosynthesis ke dauran oxygen release karte hain. Yeh kis baat ko show karta hai?",
    options: [
      "A. Abiotic components kabhi change nahi hote.",
      "B. Biotic components abiotic environment ko influence karte hain.",
      "C. Plants ko water ki zaroorat nahi hoti.",
      "D. Sirf animals ecosystem ko affect karte hain."
    ],
    correct: 1,
    explanation: "Plants living organisms hain. Photosynthesis ke dauran woh oxygen release karte hain, jo environment ki air ko influence karti hai. Isse pata chalta hai ki living organisms non-living components ko bhi affect karte hain.<br><br><strong>Example:</strong> Plants oxygen release karte hain aur shade dekar surroundings ko cool rakhne mein help karte hain."
  }
];

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>
  `;

  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