class 10 science chapter5

ch5 part2

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Science Quiz – Nutrition in Living Organisms</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;
  line-height: 1.6;
}
.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;
  line-height: 1.6;
}
.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 – Nutrition in Living Organisms</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. Living organisms ko food ki need mainly kis liye hoti hai?",
options: [
"A. Sirf body ko colourful banane ke liye",
"B. Energy aur materials provide karne ke liye",
"C. Sirf water store karne ke liye",
"D. Sirf movement rokne ke liye"
],
correct: 1,
explanation: "Food organism ko <b>energy</b> provide karta hai aur growth, development aur proteins jaise substances ko synthesise karne ke liye materials bhi provide karta hai."
},

{
question: "2. Autotrophs food banane ke liye mainly kaunse inorganic substances use karte hain?",
options: [
"A. Oxygen aur nitrogen",
"B. Proteins aur fats",
"C. Carbon dioxide aur water",
"D. Glucose aur starch"
],
correct: 2,
explanation: "Autotrophs, jaise green plants, <b>carbon dioxide aur water</b> jaise simple inorganic substances ko use karke food prepare karte hain."
},

{
question: "3. Heterotrophs complex food substances ko simpler substances mein break down karne ke liye kis bio-catalyst ka use karte hain?",
options: [
"A. Hormones",
"B. Enzymes",
"C. Chlorophyll",
"D. Starch"
],
correct: 1,
explanation: "Heterotrophs complex substances ko directly use nahi kar sakte, isliye <b>enzymes</b> ki help se unhe simpler substances mein break down kiya jaata hai."
},

{
question: "4. Heterotrophic organisms mein kaun include hote hain?",
options: [
"A. Animals and fungi",
"B. Green plants only",
"C. All bacteria only",
"D. Green algae only"
],
correct: 0,
explanation: "NCERT ke according <b>animals aur fungi</b> heterotrophic organisms hain. Inka survival directly ya indirectly autotrophs par depend karta hai."
},

{
question: "5. Autotrophic nutrition mein carbon aur energy requirements mainly kis process se fulfil hoti hain?",
options: [
"A. Respiration",
"B. Digestion",
"C. Photosynthesis",
"D. Excretion"
],
correct: 2,
explanation: "<b>Photosynthesis</b> mein autotrophs carbon dioxide aur water ko sunlight aur chlorophyll ki presence mein carbohydrates mein convert karte hain."
},

{
question: "6. Photosynthesis ke dauraan carbohydrates immediately use na hone par kis form mein store hote hain?",
options: [
"A. Glycogen",
"B. Protein",
"C. Starch",
"D. Fat"
],
correct: 2,
explanation: "Plants carbohydrates ko immediately use na karne par <b>starch</b> ke form mein store karte hain. Starch plant ka internal energy reserve hota hai."
},

{
question: "7. Photosynthesis mein chlorophyll ka main role kya hai?",
options: [
"A. Water ko soil mein absorb karna",
"B. Light energy ko absorb karna",
"C. Nitrogen ko protein mein convert karna",
"D. Waste products remove karna"
],
correct: 1,
explanation: "<b>Chlorophyll</b> sunlight ki light energy ko absorb karta hai. Ye energy photosynthesis ke process mein chemical energy mein convert hoti hai."
},

{
question: "8. Leaf ke surface par present tiny pores ko kya kaha jaata hai?",
options: [
"A. Chloroplasts",
"B. Guard cells",
"C. Stomata",
"D. Veins"
],
correct: 2,
explanation: "<b>Stomata</b> leaves ki surface par present tiny pores hain. Inke through photosynthesis ke liye gaseous exchange hota hai."
},

{
question: "9. Stomatal pore ko open aur close karne ka function kis cells ka hota hai?",
options: [
"A. Root cells",
"B. Guard cells",
"C. Chloroplasts",
"D. Xylem cells"
],
correct: 1,
explanation: "<b>Guard cells</b> stomatal pore ke opening aur closing ko control karte hain. Jab guard cells water absorb karke swell hote hain, stomata open ho jaata hai."
},

{
question: "10. Plants soil se nitrogen ko mainly kis form mein absorb karte hain?",
options: [
"A. Inorganic nitrates or nitrites",
"B. Carbon dioxide",
"C. Oxygen",
"D. Glucose"
],
correct: 0,
explanation: "Nitrogen proteins aur other compounds ki synthesis ke liye essential hai. Plants ise mainly <b>inorganic nitrates ya nitrites</b> ke form mein soil se obtain karte hain."
}

];

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

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

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

  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 saveAnswer() {
  const selected = document.querySelector('input[name="option"]:checked');

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

function nextQuestion() {
  saveAnswer();

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

function prevQuestion() {
  saveAnswer();

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

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;">
        <b>Explanation:</b> ${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: name,
    score: 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