class 9 science chapter 5

ch5part10

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APICAL CLASSES - Science 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;
    margin: 0;
  }
  .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; }
  .branding {
    text-align: center;
    color: #2a5298;
    font-weight: bold;
    letter-spacing: 1px;
  }
  .question { font-weight: bold; margin: 15px 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;
    line-height: 1.5;
  }
  .options label:hover { background: #f0f0f0; }
  .options input { margin-right: 8px; }
  .correct {
    background-color: #c8f7c5 !important;
    border-color: #28a745 !important;
  }
  .wrong {
    background-color: #f8d7da !important;
    border-color: #dc3545 !important;
  }
  .explanation {
    background: #e9ecef;
    padding: 12px;
    margin-top: 10px;
    border-left: 5px solid #2a5298;
    display: none;
    line-height: 1.6;
    border-radius: 4px;
  }
  .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; }
  input[type="text"] {
    padding: 10px;
    width: 65%;
    border: 1px solid #ccc;
    border-radius: 6px;
  }
  #scoreboard {
    margin-top: 25px;
    background: #eef3f7;
    padding: 15px;
    border-radius: 8px;
  }
  #scoreboard h3 { text-align: center; }
  ol { padding-left: 20px; }
  hr { border: 0; border-top: 1px solid #ddd; margin: 20px 0; }
  @media(max-width:600px) {
    body { padding: 10px; }
    .quiz-container { width: 100%; padding: 15px; }
    input[type="text"] { width: 90%; }
  }
</style>
</head>
<body>

<div class="quiz-container">
  <div class="branding">APICAL CLASSES</div>
  <h2>🧠 Science Quiz – Sublimation, Alloys & Suspensions</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. Camphor aur sand ke mixture ko heat karne par camphor ka kya hota hai?",
    options: [
      "A. Camphor liquid mein convert hota hai",
      "B. Camphor directly solid se vapour mein convert hota hai",
      "C. Camphor sand ke saath dissolve hota hai",
      "D. Camphor burn hokar water banata hai"
    ],
    correct: 1,
    explanation: "Camphor melting point tak liquid bane bina solid se directly vapour mein change hota hai. Is process ko <strong>sublimation</strong> kehte hain."
  },
  {
    question: "2. Camphor aur sand ko heat karke separate karne ka main reason kya hai?",
    options: [
      "A. Dono substances sublime karte hain",
      "B. Sirf sand sublime karta hai",
      "C. Camphor sublime karta hai, lekin sand nahi",
      "D. Sand vapour ban jaata hai"
    ],
    correct: 2,
    explanation: "Heating par <strong>camphor vapour</strong> ban kar upar chala jaata hai, jabki sand china dish mein remain karta hai."
  },
  {
    question: "3. Camphor ke vapours glass funnel ki inner wall ko touch karne par kya hota hai?",
    options: [
      "A. Vapours liquid water mein change hote hain",
      "B. Vapours wapas solid camphor mein change hote hain",
      "C. Vapours gas hi rehte hain",
      "D. Vapours sand mein change hote hain"
    ],
    correct: 1,
    explanation: "Cooling par camphor vapours directly solid camphor mein convert ho jaate hain. Is process ko <strong>deposition</strong> kehte hain."
  },
  {
    question: "4. Inmein se kaunsa camphor ke alawa sublimation ka example hai?",
    options: [
      "A. Naphthalene",
      "B. Common salt",
      "C. Sand",
      "D. Sugar"
    ],
    correct: 0,
    explanation: "<strong>Naphthalene</strong> ek sublimable substance hai. Isliye ise camphor ki jagah sublimation experiment mein use kiya ja sakta hai."
  },
  {
    question: "5. Solid carbon dioxide, jise dry ice kaha jaata hai, heating par kya karta hai?",
    options: [
      "A. Pehle liquid aur phir solid banta hai",
      "B. Directly solid se vapour mein change hota hai",
      "C. Sirf melt hota hai",
      "D. Sand mein change hota hai"
    ],
    correct: 1,
    explanation: "<strong>Dry ice (solid CO₂)</strong> sublimation show karta hai, yani liquid state mein aaye bina solid se gas mein change hota hai."
  },
  {
    question: "6. Do ya more metals, ya metal aur non-metal ka homogeneous mixture kya kehlata hai?",
    options: [
      "A. Suspension",
      "B. Alloy",
      "C. Solution only",
      "D. Emulsion"
    ],
    correct: 1,
    explanation: "Do ya more metals, ya metal + non-metal ka <strong>homogeneous mixture</strong> alloy kehlata hai, jaise brass aur bronze."
  },
  {
    question: "7. Brass approximately kis composition ka alloy hai?",
    options: [
      "A. 80% copper + 20% zinc",
      "B. 80% zinc + 20% copper",
      "C. 80% copper + 20% tin",
      "D. 50% copper + 50% zinc"
    ],
    correct: 0,
    explanation: "<strong>Brass</strong> approximately 80% copper aur 20% zinc ka alloy hai."
  },
  {
    question: "8. Sand particles water mein clearly visible hain aur dissolve nahi hote. Aisa heterogeneous mixture kya kehlata hai?",
    options: [
      "A. Solution",
      "B. Suspension",
      "C. Alloy",
      "D. Pure substance"
    ],
    correct: 1,
    explanation: "Suspension mein solid particles liquid mein <strong>dissolve nahi hote</strong>, suspended rehte hain aur generally naked eye se visible hote hain."
  },
  {
    question: "9. Muddy water ko kuch time undisturbed rakhne par heavier mud particles kya karte hain?",
    options: [
      "A. Vapour ban jaate hain",
      "B. Bottom par settle ho jaate hain",
      "C. Water mein completely dissolve ho jaate hain",
      "D. Gas mein convert ho jaate hain"
    ],
    correct: 1,
    explanation: "Mud ke heavier particles gravity ki wajah se <strong>bottom par settle</strong> ho jaate hain. Is process ko <strong>sedimentation</strong> kaha jaata hai."
  },
  {
    question: "10. Muddy water ko filter karne ke baad bhi water cloudy rahe, to tiny particles ko separate karne ke liye kaunsi techniques use ki ja sakti hain?",
    options: [
      "A. Sublimation only",
      "B. Centrifugation and/or coagulation",
      "C. Distillation only",
      "D. Chromatography only"
    ],
    correct: 1,
    explanation: "Bahut tiny suspended particles simple filtration se completely remove nahi hote. Aise cases mein <strong>centrifugation aur/or coagulation</strong> ka use kiya ja sakta hai."
  }
];

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];

    let optsHTML = q.options.map((opt, i) => {
      let cls = "";

      if (i === q.correct) cls = "correct";
      if (selected === i && selected !== q.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;">
        <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 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 => {
    const safeName = escapeHTML(s.name);
    const safeDate = escapeHTML(s.date);
    return `<li>${safeName} - ${s.score}/10 (${safeDate})</li>`;
  }).join("");
}

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

</body>
</html>

Leave a Comment