class 9 science chapter 5

ch5part12

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Science Quiz – Solution, Colloid and Suspension</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;
  box-sizing: border-box;
}
.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; }
input[type="text"] {
  padding: 10px;
  width: 65%;
  max-width: 300px;
  border: 1px solid #ccc;
  border-radius: 6px;
}
@media(max-width:600px) {
  body { padding: 10px; }
  .quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>

<body>
<div class="quiz-container">

<h2>🧠 Science Quiz – Solution, Colloid and Suspension</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. Blood ko centrifugation se components mein separate kiya ja sakta hai, lekin blood cells naked eye se directly visible nahi hote. Blood ko scientifically kis type ka mixture maana jaata hai?",
  options: ["A. True solution", "B. Suspension", "C. Colloid", "D. Pure substance"],
  correct: 2,
  explanation: "Blood na true solution hai aur na true suspension. Blood ek colloid hai."
},
{
  question: "2. Inmein se kaunsa colloid ka example hai?",
  options: ["A. Salt solution", "B. Milk", "C. Sugar solution", "D. Copper sulfate solution"],
  correct: 1,
  explanation: "Milk, tomato sauce aur ice cream colloids ke common examples hain."
},
{
  question: "3. Solution, colloid aur suspension mein main difference kis property ke basis par hota hai?",
  options: ["A. Colour", "B. Particle size", "C. Temperature", "D. Smell"],
  correct: 1,
  explanation: "In teen mixtures mein major difference dispersed ya dissolved particles ke size ka hota hai."
},
{
  question: "4. Ek true solution mein solute particles ka approximate diameter kitna hota hai?",
  options: ["A. Less than 1 nm", "B. 1–1000 nm", "C. More than 1000 nm", "D. Exactly 1000 nm"],
  correct: 0,
  explanation: "True solution mein solute particles bahut small hote hain, generally 1 nm se less diameter ke."
},
{
  question: "5. Colloid ke particles ka approximate size range kya hota hai?",
  options: ["A. Less than 0.1 nm", "B. 1–1000 nm", "C. More than 10,000 nm", "D. Exactly 1 nm"],
  correct: 1,
  explanation: "Colloid ke dispersed particles ka size approximately 1–1000 nm hota hai."
},
{
  question: "6. Suspension ke particles colloid ke particles se kaise different hote hain?",
  options: [
    "A. Suspension particles 1 nm se smaller hote hain",
    "B. Suspension particles generally 1000 nm se larger hote hain",
    "C. Suspension mein particles hote hi nahi",
    "D. Suspension particles always gases hote hain"
  ],
  correct: 1,
  explanation: "Suspension mein particles relatively large hote hain, generally 1000 nm se greater."
},
{
  question: "7. Colloid ko suspension se distinguish karne wali important property kya hai?",
  options: [
    "A. Colloid ke particles time ke saath easily settle nahi hote",
    "B. Colloid ke particles always naked eye se visible hote hain",
    "C. Colloid hamesha colourless hota hai",
    "D. Colloid mein particles completely dissolve ho jaate hain"
  ],
  correct: 0,
  explanation: "Colloid ke particles uniformly dispersed rehte hain aur suspension ki tarah time ke saath easily bottom par settle nahi hote."
},
{
  question: "8. Tyndall effect kya hai?",
  options: [
    "A. Particles ka dissolve hona",
    "B. Light ka particles ke dwara scattering hona",
    "C. Liquid ka boiling",
    "D. Solid ka melting"
  ],
  correct: 1,
  explanation: "Particles ke dwara light ka scattering ko Tyndall effect kehte hain. Iska naam scientist John Tyndall ke naam par hai."
},
{
  question: "9. Ek dark room mein small hole se sunlight ki thin beam enter karti hai aur uska path dust aur smoke particles ki wajah se visible ho jaata hai. Ye kaunsa phenomenon hai?",
  options: [
    "A. Evaporation",
    "B. Sublimation",
    "C. Tyndall effect",
    "D. Crystallization"
  ],
  correct: 2,
  explanation: "Air mein present dust aur smoke particles light ko scatter karte hain, jiski wajah se light beam ka path visible hota hai. Ye Tyndall effect hai."
},
{
  question: "10. Colloid mein dispersed particles jis component mein uniformly distributed hote hain, us component ko kya kaha jaata hai?",
  options: [
    "A. Dispersed phase",
    "B. Dispersion medium",
    "C. Solute only",
    "D. Residue"
  ],
  correct: 1,
  explanation: "Colloid mein dispersed particles = dispersed phase, aur jis component mein ye particles distributed hote hain = dispersion medium."
}
];

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${currentQuestion + 1}. ${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${index + 1}. ${q.question}</div>
      <div class="options">${optsHTML}</div>
      <div class="explanation" style="display:block;">
        <strong>Explanation:</strong> ${q.explanation}
      </div>
      <hr>
    `;
  });

  document.querySelector(".controls").style.display = "none";

  document.getElementById("result").innerHTML =
    `<h3>Your Score: ${score} / ${questions.length}</h3>`;
}

function escapeHTML(value) {
  return String(value).replace(/[&<>"']/g, char => ({
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#39;"
  })[char]);
}

function saveScore(name, score) {
  let scores = [];

  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  } catch (e) {
    scores = [];
  }

  scores.push({
    name: name,
    score: score,
    date: new Date().toLocaleString()
  });

  localStorage.setItem("quizScores", JSON.stringify(scores));
}

function loadScoreboard() {
  let scores = [];

  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  } catch (e) {
    scores = [];
  }

  scores.sort((a, b) => b.score - a.score);

  document.getElementById("scoreList").innerHTML =
    scores.map(s =>
      `<li>${escapeHTML(s.name)} - ${s.score}/10 (${escapeHTML(s.date)})</li>`
    ).join("");
}
</script>

</body>
</html>

Leave a Comment