class 9 science chapter 9

ch9part1

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Class 9 Science Quiz – Laws of Chemical Combination</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>🧠 Class 9 Science Quiz – Laws of Chemical Combination</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. Activity 9.1 mein water aur common salt ko beaker mein mix karke salt dissolve kiya gaya. Is process mein mass ke baare mein kya observation hoti hai?",
    options: [
      "A. Mass completely disappear ho jata hai",
      "B. Solution ka mass water aur salt ke masses ke sum ke equal hota hai",
      "C. Solution ka mass sirf water ke equal hota hai",
      "D. Solution ka mass sirf salt ke equal hota hai"
    ],
    correct: 1,
    explanation: "Salt dissolve hone ke baad bhi total mass practically same rehta hai. Solution ka mass = water ka mass + salt ka mass. Baaki options mass conservation ko show nahi karte."
  },
  {
    question: "2. Activity 9.1 mein salt ko water mein dissolve karna kis type ka change hai?",
    options: [
      "A. Chemical change",
      "B. Nuclear change",
      "C. Physical change",
      "D. Permanent chemical reaction"
    ],
    correct: 2,
    explanation: "Salt dissolve hone par koi new substance form nahi hota; isliye ise <b>physical change</b> maana jata hai. Baaki options is process ki correct classification nahi hain."
  },
  {
    question: "3. Activity 9.1 mein digital weighing balance ko zero karne ke liye kaunsa button press kiya jata hai?",
    options: [
      "A. Start button",
      "B. Tare ya reset button",
      "C. Power button twice",
      "D. Calibration lock button"
    ],
    correct: 1,
    explanation: "Beaker ko balance par rakhne ke baad <b>tare/reset</b> press karke reading zero ki jaati hai, taaki baad mein added substances ka mass measure ho sake."
  },
  {
    question: "4. Activity 9.1 mein approximately kitna water 100 mL beaker mein liya gaya tha?",
    options: [
      "A. 10 mL",
      "B. 20 mL",
      "C. 50 mL",
      "D. 100 mL"
    ],
    correct: 2,
    explanation: "Activity mein approximately <b>50 mL water</b> beaker mein pour kiya gaya tha. 20 mL Activity 9.2 mein vinegar/lemon juice ke liye use hota hai."
  },
  {
    question: "5. Activity 9.1 mein paper ko weigh karke tear karne ke baad dobara weigh karne ka purpose kya hai?",
    options: [
      "A. Paper ka colour check karna",
      "B. Physical change mein mass change hota hai ya nahi, check karna",
      "C. Paper ko dissolve karna",
      "D. Paper ka temperature measure karna"
    ],
    correct: 1,
    explanation: "Paper ko pieces mein tear karna ek <b>physical change</b> hai. Activity ka purpose observe karna hai ki tearing ke baad mass practically change hota hai ya nahi."
  },
  {
    question: "6. Activity 9.2 mein baking soda ko vinegar ya lemon juice mein add karne par kaunsi gas form hoti hai?",
    options: [
      "A. Oxygen",
      "B. Hydrogen",
      "C. Nitrogen",
      "D. Carbon dioxide"
    ],
    correct: 3,
    explanation: "Baking soda (sodium hydrogencarbonate) aur vinegar/lemon juice ke reaction mein <b>carbon dioxide gas</b> release hoti hai. Isliye brisk effervescence yani bubbles/fizzing observe hoti hai."
  },
  {
    question: "7. Activity 9.2 ke experimental set-up mein approximately kitna vinegar ya lemon juice conical flask mein liya gaya tha?",
    options: [
      "A. 5 mL",
      "B. 10 mL",
      "C. 20 mL",
      "D. 50 mL"
    ],
    correct: 2,
    explanation: "Experiment mein approximately <b>20 mL vinegar ya lemon juice</b> conical flask mein liya jata hai. 50 mL water Activity 9.1 mein use hua tha."
  },
  {
    question: "8. Activity 9.2 mein approximately <b>2 g baking soda</b> balloon mein rakhkar flask mein transfer kiya gaya. Balloon ko flask ke saath balance par rakhne ka main purpose kya tha?",
    options: [
      "A. Balloon ko inflate karna",
      "B. Baking soda ko dry karna",
      "C. Mass measurement mein material loss ko minimise karna",
      "D. Vinegar ko cool karna"
    ],
    correct: 2,
    explanation: "Balloon flask ke saath attached/saath rakha jata hai, taaki balloon mein stuck baking soda ki small quantity se <b>measurement error</b> na aaye."
  },
  {
    question: "9. Baking soda aur vinegar ke reaction ke baad final weighing reading initial reading se match nahi karti. Passage ke according iska important possible reason kya hai?",
    options: [
      "A. Reaction ke dauran gas form hui aur system se escape ho sakti hai",
      "B. Baking soda ka mass suddenly zero ho gaya",
      "C. Water ka mass double ho gaya",
      "D. Balance automatically mass change karta hai"
    ],
    correct: 0,
    explanation: "Chemical reaction mein <b>carbon dioxide gas</b> banti hai. Agar gas open system se bahar nikal jaaye, toh balance par measured final mass initial mass se different ho sakta hai."
  },
  {
    question: "10. Activity 9.1 aur Activity 9.2 ko compare karne par kaunsa statement correct hai?",
    options: [
      "A. Physical aur chemical changes dono mein hamesha mass decrease hota hai",
      "B. Physical change mein mass practically same rehta hai, jabki open chemical reaction mein gas escape hone se measured mass different ho sakta hai",
      "C. Physical change mein new gas banti hai",
      "D. Chemical change mein kabhi gas form nahi hoti"
    ],
    correct: 1,
    explanation: "Salt-water solution mein mass practically <b>conserved</b> rehta hai. Baking soda + vinegar reaction mein CO₂ gas banti hai; agar gas system se escape kare, toh balance ki final reading different ho sakti hai."
  }
];

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

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

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

  currentQuestion = 0;
  score = 0;
  userAnswers = [];
  quizSubmitted = false;

  document.getElementById("nameSection").style.display = "none";
  document.getElementById("quizSection").style.display = "block";
  document.getElementById("result").innerHTML = "";
  document.querySelector(".controls").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>
    <p><strong>${userName}</strong>, you got ${score} questions correct.</p>
  `;
}

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