class 9 science chapter 2

ch2 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 – Human Eye and Microscope</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 – Human Eye and Microscope</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. Human eye ki ability jisme do bahut close objects ko separate aur distinct objects ke roop mein dekha ja sakta hai, use kya kehte hain?",
options: [
"A. Magnification",
"B. Resolution",
"C. Reflection",
"D. Refraction"
],
correct: 1,
explanation: "Do close objects ko alag-alag identify karne ki ability ko <b>resolution</b> kehte hain."
},

{
question: "2. Human eye ka limit of resolution approximately kitna hota hai?",
options: [
"A. 0.01 mm",
"B. 0.1 mm",
"C. 1 mm",
"D. 10 mm"
],
correct: 1,
explanation: "About <b>25 cm</b> ki distance par human eye approximately <b>0.1 mm</b> apart points ko distinct dekh sakti hai."
},

{
question: "3. Human eye ke near point ki distance approximately kitni hoti hai?",
options: [
"A. 10 cm",
"B. 15 cm",
"C. 25 cm",
"D. 50 cm"
],
correct: 2,
explanation: "Normal human eye ka <b>near point approximately 25 cm</b> maana jaata hai."
},

{
question: "4. Cell ko unaided human eye se generally kyun nahi dekha ja sakta?",
options: [
"A. Cell transparent hota hai",
"B. Cell ka size bahut chhota hota hai",
"C. Cell light produce karta hai",
"D. Cell sirf darkness mein hota hai"
],
correct: 1,
explanation: "Most cells human eye ki <b>limit of resolution</b> se bhi chhote hote hain, isliye unhe unaided eye se nahi dekha ja sakta."
},

{
question: "5. Kisi object ko larger appear karne ke liye microscope mein mainly kya use kiya jaata hai?",
options: [
"A. Mirrors only",
"B. Convex lens ya combination of lenses",
"C. Plane glass",
"D. Prism only"
],
correct: 1,
explanation: "<b>Convex lens</b> ya objective lens aur eyepiece ka combination object ka magnified image banata hai."
},

{
question: "6. Robert Hooke ne cell ko pehli baar kis year mein observe kiya tha?",
options: [
"A. 1655",
"B. 1665",
"C. 1675",
"D. 1685"
],
correct: 1,
explanation: "<b>Robert Hooke ne 1665 mein</b> apne self-designed microscope se cork ki thin slice observe ki thi."
},

{
question: "7. Robert Hooke ne cork ki thin slice mein kya observe kiya tha?",
options: [
"A. Round blood cells",
"B. Small box-like compartments",
"C. Long nerve fibres",
"D. Green chloroplasts"
],
correct: 1,
explanation: "Cork ko microscope se dekhte waqt Hooke ko <b>small box-like compartments</b> dikhe, jinko unhone <b>cells</b> naam diya."
},

{
question: "8. School laboratory mein light microscope objects ko observe karne ke liye kaunsi light use karta hai?",
options: [
"A. Infrared light",
"B. Ultraviolet light",
"C. Visible light",
"D. X-rays"
],
correct: 2,
explanation: "School laboratories mein commonly <b>light microscopes</b> visible light ka use karke magnified images produce karte hain."
},

{
question: "9. Agar microscope mein objective lens 40X magnification provide karta hai, iska basic meaning kya hai?",
options: [
"A. Object 40 times smaller dikhega",
"B. Object 40 times larger appear karega",
"C. Object ka colour 40 times change hoga",
"D. Object ki mass 40 times increase hogi"
],
correct: 1,
explanation: "<b>40X magnification</b> ka matlab hai ki object ka image uske original appearance ke comparison mein approximately <b>40 times magnified</b> dikhega."
},

{
question: "10. Microscope ke through kisi object ka magnified image dekhne ke baad uska actual size estimate karne ke liye kis concept ko samajhna important hai?",
options: [
"A. Magnification",
"B. Temperature",
"C. Density",
"D. Pressure"
],
correct: 0,
explanation: "Magnified image aur actual object size ke relationship ko samajhne ke liye <b>magnification</b> ka concept important 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 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() {

  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;">
        <strong>Explanation:</strong> ${q.explanation}
      </div>
      <hr>
    `;

  });

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

  document.getElementById("result").innerHTML = `
    <h3>Your Score: ${score} / ${questions.length}</h3>
    <h3>Percentage: ${(score / questions.length * 100).toFixed(0)}%</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