class 9 science chapter 9

ch9part4

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Law of Conservation of Mass – 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>🧠 Law of Conservation of Mass – 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. Example 9.1 mein calcium carbonate aur hydrochloric acid ke masses respectively <b>4.0 g</b> aur <b>2.92 g</b> hain. Total mass of reactants kitna hoga?",
    options: [
      "A. 5.92 g",
      "B. 6.92 g",
      "C. 7.92 g",
      "D. 8.92 g"
    ],
    correct: 1,
    explanation: "Total mass of reactants = 4.0 g + 2.92 g = <b>6.92 g</b>. Isliye B correct hai."
  },
  {
    question: "2. Example 9.1 mein products ke masses hain: CO₂ = <b>1.76 g</b>, water = <b>0.72 g</b>, aur calcium chloride = <b>4.44 g</b>. Total mass of products kitna hai?",
    options: [
      "A. 5.92 g",
      "B. 6.02 g",
      "C. 6.92 g",
      "D. 7.92 g"
    ],
    correct: 2,
    explanation: "Total products = 1.76 + 0.72 + 4.44 = <b>6.92 g</b>. Ye reactants ke total mass ke equal hai."
  },
  {
    question: "3. Example 9.1 mein reactants ka total mass <b>6.92 g</b> aur products ka total mass bhi <b>6.92 g</b> hai. Is observation se kya conclusion milta hai?",
    options: [
      "A. Law of Conservation of Mass obeyed hai",
      "B. Mass destroy hua hai",
      "C. Mass create hua hai",
      "D. Chemical reaction nahi hui"
    ],
    correct: 0,
    explanation: "Reactants ka total mass = products ka total mass, yani <b>6.92 g = 6.92 g</b>. Therefore, Law of Conservation of Mass obeyed hai."
  },
  {
    question: "4. Example 9.2 mein <b>12 g carbon + 32 g oxygen → 44 g carbon dioxide</b>. Agar <b>2.4 g carbon</b> completely react kare, toh kitna carbon dioxide produce hoga?",
    options: [
      "A. 4.4 g",
      "B. 6.6 g",
      "C. 8.8 g",
      "D. 10.8 g"
    ],
    correct: 2,
    explanation: "12 g carbon se 44 g CO₂ banta hai. 2.4 g carbon is amount ka 1/5 hai, so CO₂ = 44 × 2.4 ÷ 12 = <b>8.8 g</b>."
  },
  {
    question: "5. Example 9.2 mein carbon aur oxygen milkar carbon dioxide banate hain. <b>12 g carbon</b> ke complete reaction ke liye kitna oxygen required hai?",
    options: [
      "A. 22 g",
      "B. 32 g",
      "C. 44 g",
      "D. 56 g"
    ],
    correct: 1,
    explanation: "Given data ke according <b>12 g carbon + 32 g oxygen → 44 g carbon dioxide</b>. Isliye required oxygen = <b>32 g</b>."
  },
  {
    question: "6. Ek student open beaker mein <b>10 g ethanol</b> burn karta hai. Reaction ke baad beaker mein koi residue nahi bachta. Kya iska matlab Law of Conservation of Mass violate ho gaya?",
    options: [
      "A. Haan, kyunki 10 g mass disappear ho gaya",
      "B. Haan, kyunki residue hona compulsory hai",
      "C. Nahi, combustion products gases ke form mein environment mein chale gaye",
      "D. Nahi, kyunki ethanol reaction nahi karta"
    ],
    correct: 2,
    explanation: "Open system mein ethanol ke combustion se <b>CO₂ aur water vapour</b> jaise products form hote hain jo air mein escape kar sakte hain. Isliye beaker mein residue na hona mass destruction prove nahi karta."
  },
  {
    question: "7. Jab <b>20 g hydrogen</b> completely <b>160 g oxygen</b> ke saath react karta hai, toh Law of Conservation of Mass ke according kitna water form hoga?",
    options: [
      "A. 140 g",
      "B. 160 g",
      "C. 180 g",
      "D. 200 g"
    ],
    correct: 2,
    explanation: "Total reactant mass = 20 g + 160 g = <b>180 g</b>. Mass conservation ke according water ka mass <b>180 g</b> hoga."
  },
  {
    question: "8. Conical flasks ko transfer ke time weighing balance par rakhne ka main purpose kya hai?",
    options: [
      "A. Reaction ko fast karna",
      "B. Flask ko heat karna",
      "C. Flask ki walls par stuck solution ki wajah se measurement error ko prevent karna",
      "D. Solution ka colour change karna"
    ],
    correct: 2,
    explanation: "Transfer ke baad flask ki walls par thoda solution stuck reh sakta hai. Dono flasks ko balance par rakhne se <b>mass measurement error minimise</b> hota hai."
  },
  {
    question: "9. Agar kisi chemical reaction mein koi gas form nahi hoti aur reaction open system mein perform ki ja rahi hai, toh mass conservation verify karna relatively easy kyun ho sakta hai?",
    options: [
      "A. Koi gaseous product system se escape nahi kar raha hota",
      "B. Mass automatically increase ho jata hai",
      "C. Reactants ka mass zero ho jata hai",
      "D. Chemical reaction stop ho jaati hai"
    ],
    correct: 0,
    explanation: "Jab gas form nahi hoti, toh matter ka gaseous form mein system se escape hone ka issue nahi hota. Isliye initial aur final mass ko compare karke conservation verify kiya ja sakta hai."
  },
  {
    question: "10. Agar <b>12 g carbon → 44 g carbon dioxide</b> produce karta hai, toh <b>1 g carbon</b> se kitna carbon dioxide produce hoga?",
    options: [
      "A. 2.67 g",
      "B. 3.67 g",
      "C. 4.67 g",
      "D. 5.67 g"
    ],
    correct: 1,
    explanation: "1 g carbon se CO₂ = 44 ÷ 12 = <b>3.67 g approximately</b>. Isi ratio ka use karke 2.4 g carbon ke liye 8.8 g CO₂ calculate kiya gaya hai."
  }
];

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

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() {
  if (quizSubmitted) return;

  saveAnswer();
  score = 0;

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

  quizSubmitted = true;
  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