class 10 science chapter 9

ch9part1

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Light and Reflection Quiz – APICAL CLASSES</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>🧠 Light and Reflection Quiz – APICAL CLASSES</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. Hum kisi object ko kab dekh paate hain?",
    options: [
      "A. Jab object sound produce kare",
      "B. Jab object se reflected light hamari eyes tak aaye",
      "C. Jab room completely dark ho",
      "D. Jab object transparent ho"
    ],
    correct: 1,
    explanation: "Kisi object par light fall karti hai aur object us light ko reflect karta hai. Ye reflected light jab hamari eyes tak pahunchti hai, tab humein object visible hota hai."
  },
  {
    question: "2. Light ke straight-line path ko kya kaha jata hai?",
    options: [
      "A. Beam",
      "B. Ray of light",
      "C. Reflection",
      "D. Refraction"
    ],
    correct: 1,
    explanation: "Light ke straight-line propagation ko generally ray of light se represent kiya jata hai. Small light source se opaque object ki sharp shadow bhi light ke straight path ko show karti hai."
  },
  {
    question: "3. Reflection ka first law kya kehta hai?",
    options: [
      "A. Angle of incidence, angle of reflection se double hota hai",
      "B. Angle of incidence = angle of reflection",
      "C. Angle of reflection hamesha zero hota hai",
      "D. Angle of incidence hamesha 90° hota hai"
    ],
    correct: 1,
    explanation: "Reflection ke first law ke according angle of incidence is equal to angle of reflection."
  },
  {
    question: "4. Plane mirror se banne wali image ki property kya hoti hai?",
    options: [
      "A. Real aur inverted",
      "B. Virtual aur erect",
      "C. Real aur erect",
      "D. Virtual aur inverted"
    ],
    correct: 1,
    explanation: "Plane mirror ki image virtual aur erect hoti hai. Image ka size object ke equal hota hai aur image mirror ke behind utni hi distance par banti hai jitni distance par object mirror ke in front hota hai."
  },
  {
    question: "5. Concave mirror ki reflecting surface kis direction mein curved hoti hai?",
    options: [
      "A. Bahar ki taraf",
      "B. Andar ki taraf, centre of sphere ki taraf",
      "C. Bilkul flat",
      "D. Sirf side ki taraf"
    ],
    correct: 1,
    explanation: "Jis spherical mirror ki reflecting surface inwards curved hoti hai, use concave mirror kehte hain."
  },
  {
    question: "6. Convex mirror ki reflecting surface kis direction mein curved hoti hai?",
    options: [
      "A. Inwards",
      "B. Outwards",
      "C. Flat",
      "D. Downwards"
    ],
    correct: 1,
    explanation: "Jis spherical mirror ki reflecting surface outwards curved hoti hai, use convex mirror kehte hain."
  },
  {
    question: "7. Spherical mirror ke reflecting surface ke centre ko kya kaha jata hai?",
    options: [
      "A. Focus",
      "B. Centre of curvature",
      "C. Pole",
      "D. Aperture"
    ],
    correct: 2,
    explanation: "Spherical mirror ke reflecting surface ke centre point ko pole (P) kaha jata hai. Ye mirror ki surface par hi located hota hai."
  },
  {
    question: "8. Concave mirror ka centre of curvature kahan hota hai?",
    options: [
      "A. Mirror ke behind",
      "B. Mirror ke front mein",
      "C. Mirror ke pole par",
      "D. Mirror ke andar hamesha"
    ],
    correct: 1,
    explanation: "Concave mirror ka centre of curvature (C) mirror ke front mein hota hai. Convex mirror mein centre of curvature mirror ke behind hota hai."
  },
  {
    question: "9. Principal focus kya hota hai?",
    options: [
      "A. Jahan mirror ka pole hota hai",
      "B. Jahan principal axis mirror ko touch karti hai",
      "C. Jahan principal axis ke parallel rays reflection ke baad meet ya appear to meet karti hain",
      "D. Mirror ka outer edge"
    ],
    correct: 2,
    explanation: "Concave mirror mein principal axis ke parallel rays reflection ke baad actually meet karti hain. Convex mirror mein reflected rays appear to come from a point. Is point ko principal focus (F) kehte hain."
  },
  {
    question: "10. Spherical mirror ke radius of curvature (R) aur focal length (f) ke beech kya relationship hai?",
    options: [
      "A. R = f",
      "B. R = 3f",
      "C. R = 2f",
      "D. R = f/2"
    ],
    correct: 2,
    explanation: "Small aperture wale spherical mirrors ke liye radius of curvature focal length ka twice hota hai.<br><br><strong>Formula: R = 2f</strong><br><br>Iska matlab principal focus (F), P aur C ke beech midway mein hota hai."
  }
];

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

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() {
  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;">${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