class 8 science chapter 12

ch12 part14

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Ecosystem Quiz – Population, Community & Sustainability</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>🧠 Ecosystem Quiz – Population, Community & Sustainability</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. Population, community aur ecosystem ke baare mein kaunsa statement wrong hai?",
    options: [
      "A. Population ek hi species ke organisms ka group hota hai.",
      "B. Community mein different populations hoti hain.",
      "C. Ecosystem, community ka ek chhota part hota hai.",
      "D. Ecosystem mein biotic aur abiotic components hote hain."
    ],
    correct: 2,
    explanation: "Ecosystem, community se larger hota hai. Ismein living organisms ke saath air, water, soil aur sunlight jaise abiotic components bhi hote hain.<br><br>Example: Ek pond mein fish ki population ho sakti hai, different organisms milkar community banate hain, aur community plus water, sunlight aur soil milkar ecosystem banate hain."
  },
  {
    question: "2. Agar forest se saare decomposers disappear ho jaayein, toh kya hoga?",
    options: [
      "A. Nutrients ka recycling process slow ho jayega.",
      "B. Soil fertility hamesha badhegi.",
      "C. Dead organisms turant disappear ho jayenge.",
      "D. Producers ko nutrients ki zaroorat nahi hogi."
    ],
    correct: 0,
    explanation: "Decomposers dead plants aur animals ko break down karke nutrients environment mein wapas laate hain. Unke bina dead matter accumulate hoga aur nutrient recycling disturb ho jayegi.<br><br>Example: Fungi aur bacteria na hon, toh forest floor par dead leaves zyada jama ho sakti hain aur plants ko nutrients milna difficult ho sakta hai."
  },
  {
    question: "3. Mangrove forests tsunami ke impact ko kaise reduce kar sakte hain?",
    options: [
      "A. Tsunami ko completely stop karke",
      "B. Waves ki energy ko reduce karne aur water flow ko slow karne mein help karke",
      "C. Sea water ko fresh water mein badal kar",
      "D. Earthquakes ko prevent karke"
    ],
    correct: 1,
    explanation: "Mangroves ki dense roots aur vegetation coastal areas mein waves aur water flow ki energy ko reduce karne mein help kar sakti hain. Lekin ye severe tsunami se complete protection guarantee nahi karti.<br><br>Example: Mangrove trees wala coastal area kuch situations mein bina mangroves wale area ke comparison mein kam damage experience kar sakta hai."
  },
  {
    question: "4. Food chain hai: Grass → Grasshopper → Frog → Snake. Agar frogs disappear ho jaayein, toh kya possible effect hoga?",
    options: [
      "A. Grasshoppers kam aur snakes zyada ho jayenge.",
      "B. Grasshoppers badh sakte hain aur snakes kam ho sakte hain.",
      "C. Grass aur grasshoppers dono immediately disappear ho jayenge.",
      "D. Snakes ko koi effect nahi hoga."
    ],
    correct: 1,
    explanation: "Frogs grasshoppers ko eat karte hain. Frogs kam hone par grasshoppers ki population badh sakti hai. Snakes ko food kam milne se unki population bhi decline kar sakti hai.<br><br>Example: Agar frogs kam ho jaayein, toh grasshoppers zyada grass kha sakte hain, jisse grass ki quantity bhi reduce ho sakti hai."
  },
  {
    question: "5. School garden mein butterflies ki population kam hone ka possible reason kya hai?",
    options: [
      "A. Flowering plants ki kami",
      "B. Pesticides ka excessive use",
      "C. Suitable habitat ka loss",
      "D. Ye sabhi"
    ],
    correct: 3,
    explanation: "Butterflies ko nectar, suitable plants aur safe habitat ki zaroorat hoti hai. Flowering plants ki kami, pesticides aur habitat loss unki population ko reduce kar sakte hain.<br><br>Example: Agar school garden mein flowers remove kar diye jaayein aur pesticides spray kiye jaayein, toh butterflies ko food aur shelter kam mil sakta hai."
  },
  {
    question: "6. School campus mein butterflies ki population badhane ke liye kaunsa step useful hoga?",
    options: [
      "A. Saare flowering plants hata dena",
      "B. Har jagah pesticides spray karna",
      "C. Native flowering plants lagana aur pesticides ka use reduce karna",
      "D. Garden ko completely concrete se cover kar dena"
    ],
    correct: 2,
    explanation: "Native flowering plants butterflies ko nectar aur suitable habitat provide kar sakte hain. Pesticides ka unnecessary use avoid karna bhi beneficial insects ko protect karne mein help karta hai.<br><br>Example: Students campus mein marigold aur locally suitable flowering plants laga sakte hain aur ek pesticide-free garden area maintain kar sakte hain."
  },
  {
    question: "7. Sirf producers wala ecosystem stable kyun nahi reh sakta?",
    options: [
      "A. Producers sunlight use nahi karte.",
      "B. Consumers aur decomposers food relationships aur nutrient recycling ke liye important hain.",
      "C. Producers kabhi food nahi banate.",
      "D. Abiotic components ki zaroorat nahi hoti."
    ],
    correct: 1,
    explanation: "Consumers producers ya doosre organisms se food lete hain, jabki decomposers dead matter ko break down karke nutrients recycle karte hain. Inke bina ecosystem ke important processes disturb ho jaate hain.<br><br>Example: Plants food banate hain, rabbits plants ko khate hain aur decomposers dead plants aur animals se nutrients soil mein return karte hain."
  },
  {
    question: "8. Park aur roadside ecosystem mein kya difference ho sakta hai?",
    options: [
      "A. Park mein living organisms nahi hote.",
      "B. Roadside par abiotic components nahi hote.",
      "C. Roadside par pollution zyada aur vegetation kam ho sakti hai.",
      "D. Dono jagah environmental conditions hamesha same hoti hain."
    ],
    correct: 2,
    explanation: "Park mein trees, grass aur flowering plants zyada ho sakte hain, jabki roadside par vehicle emissions, dust aur noise zyada ho sakte hain. Dono jagahon par biotic aur abiotic components present hote hain.<br><br>Example: Park mein butterflies aur birds zyada dikh sakte hain, jabki busy roadside par dust-tolerant plants aur fewer butterflies mil sakti hain."
  },
  {
    question: "9. Agricultural fields ko sustainable banana kyun zaroori hai?",
    options: [
      "A. Taaki soil fertility aur natural resources protect ho sakein.",
      "B. Taaki groundwater unlimited use kiya ja sake.",
      "C. Taaki saare beneficial insects destroy ho jaayein.",
      "D. Taaki soil mein organic matter completely remove ho jaaye."
    ],
    correct: 0,
    explanation: "Sustainable farming ka aim crops produce karna aur saath hi soil, water aur biodiversity ko protect karna hai. Isse future mein bhi food production maintain karne mein help milti hai.<br><br>Example: Crop rotation, compost aur efficient irrigation use karna sustainable farming practices hain."
  },
  {
    question: "10. Agar disease ke kaaran Indian hare ki population decrease ho jaaye, toh ecosystem par kya effect ho sakta hai?",
    options: [
      "A. Hare ko eat karne wale predators ko food kam mil sakta hai.",
      "B. Hare ke food plants par grazing pressure kam ho sakta hai.",
      "C. Food web ke doosre organisms bhi affect ho sakte hain.",
      "D. Ye sabhi"
    ],
    correct: 3,
    explanation: "Indian hare food web ka ek important part hai. Uski population kam hone par predators ko food kam mil sakta hai aur plants par grazing reduce ho sakti hai. Iska effect ecosystem ke doosre organisms par bhi pad sakta hai.<br><br>Example: Agar hares kam ho jaayein, toh unhe hunt karne wale kuch predators alternative prey par depend kar sakte hain, jabki grass aur other plants par grazing kam ho sakti 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}/${questions.length} (${s.date})</li>`
  ).join('');
}
</script>
</body>
</html>

Leave a Comment