class 8 science chapter 10

ch10 part6

<!DOCTYPE html>
<html lang="en">
<head>
<title>Class 10 Science Quiz – Light and Lenses</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 10 Science Quiz – Light and Lenses</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. Lens kise kehte hain?",
    options: [
      "A. Ek opaque material jisme light pass nahi hoti",
      "B. Ek transparent material jiske surfaces curved hote hain",
      "C. Ek flat mirror jo light reflect karta hai",
      "D. Ek material jo sirf light absorb karta hai"
    ],
    correct: 1,
    explanation: "Lens usually glass ya plastic ka bana hota hai. Iske curved surfaces light ko refract karte hain, jisse objects ki image ka size ya appearance change ho sakta hai.<br><br>Example: Magnifying glass ek lens hai, jo book ke chhote letters ko bada dikhane mein help karta hai."
  },
  {
    question: "2. Convex lens ki thickness kaisi hoti hai?",
    options: [
      "A. Edges par zyada aur middle mein kam",
      "B. Middle mein zyada aur edges par kam",
      "C. Har jagah equal",
      "D. Sirf ek edge par zyada"
    ],
    correct: 1,
    explanation: "Convex lens beech mein mota aur edges par patla hota hai. Yeh parallel light rays ko converge karta hai.<br><br>Example: Magnifying glass mein aam taur par convex lens hota hai."
  },
  {
    question: "3. Concave lens ki thickness kaisi hoti hai?",
    options: [
      "A. Middle mein zyada aur edges par kam",
      "B. Middle aur edges par equal",
      "C. Edges par zyada aur middle mein kam",
      "D. Har jagah zero"
    ],
    correct: 2,
    explanation: "Concave lens beech mein patla aur edges par mota hota hai. Yeh parallel light rays ko diverge karta hai.<br><br>Example: Concave lens ka use kuch eyeglasses mein vision correction ke liye hota hai."
  },
  {
    question: "4. Convex lens se chhoti distance par rakha object kaisa dikh sakta hai?",
    options: [
      "A. Erect aur enlarged",
      "B. Hamesha inverted aur chhota",
      "C. Hamesha invisible",
      "D. Sirf same size"
    ],
    correct: 0,
    explanation: "Jab object convex lens ke paas, yani focal length ke andar hota hai, toh uski image virtual, erect aur enlarged ban sakti hai.<br><br>Example: Magnifying glass ko printed text ke paas rakhne par letters bade aur seedhe dikh sakte hain."
  },
  {
    question: "5. Concave lens se dekhne par object ki image aam taur par kaisi hoti hai?",
    options: [
      "A. Inverted aur enlarged",
      "B. Erect aur diminished",
      "C. Hamesha same size",
      "D. Inverted aur same size"
    ],
    correct: 1,
    explanation: "Concave lens hamesha virtual, erect aur diminished yani object se chhoti image banata hai.<br><br>Example: Concave lens se kisi object ko dekhne par woh seedha aur chhota nazar aa sakta hai."
  },
  {
    question: "6. Convex lens ko converging lens kyun kehte hain?",
    options: [
      "A. Kyunki yeh light ko absorb karta hai",
      "B. Kyunki yeh parallel light rays ko ek doosre ke paas laata hai",
      "C. Kyunki yeh light ko reflect karta hai",
      "D. Kyunki yeh light ko rok deta hai"
    ],
    correct: 1,
    explanation: "Convex lens se pass hone wali parallel light rays converge karti hain, yani ek common point ki taraf aati hain.<br><br>Example: Convex lens sunlight ko ek chhote bright spot par focus kar sakta hai."
  },
  {
    question: "7. Concave lens ko diverging lens kyun kehte hain?",
    options: [
      "A. Kyunki yeh parallel light rays ko spread karta hai",
      "B. Kyunki yeh rays ko ek point par milata hai",
      "C. Kyunki yeh light produce karta hai",
      "D. Kyunki yeh light ko completely absorb karta hai"
    ],
    correct: 0,
    explanation: "Concave lens se pass hone ke baad parallel rays ek doosre se door spread hoti hain. Is process ko divergence kehte hain.<br><br>Example: Concave lens se parallel torch beams pass karne par woh spread hoti hui dikh sakti hain."
  },
  {
    question: "8. Thin transparent glass plate se parallel light rays pass hone par kya hota hai?",
    options: [
      "A. Rays strongly converge karti hain",
      "B. Rays strongly diverge karti hain",
      "C. Rays lagbhag usi direction mein parallel pass karti hain",
      "D. Saari light absorb ho jaati hai"
    ],
    correct: 2,
    explanation: "Ek thin, plane-parallel glass plate se pass hone wali light ray bahar nikalte waqt aam taur par apni original direction ke parallel hoti hai. Convex aur concave lenses ki tarah rays ko strongly converge ya diverge nahi karti.<br><br>Example: Clear flat glass window se bahar dekhne par objects aam taur par apne original shape aur lagbhag same size mein dikhte hain."
  },
  {
    question: "9. Inmein se kaunsa device lenses ka use karta hai?",
    options: [
      "A. Camera",
      "B. Microscope",
      "C. Eyeglasses",
      "D. Upar diye gaye sabhi"
    ],
    correct: 3,
    explanation: "Lenses ka use images banane ya vision improve karne ke liye kai optical devices mein hota hai.<br><br>Example: Camera lens photographs capture karta hai, microscope chhoti objects ko bada dikhata hai aur eyeglasses dekhne mein help karte hain."
  },
  {
    question: "10. Convex lens sunlight se paper ko jalane mein help kyun kar sakta hai?",
    options: [
      "A. Yeh sunlight ko ek chhote area mein concentrate kar sakta hai",
      "B. Yeh paper mein water produce karta hai",
      "C. Yeh sunlight ko completely block karta hai",
      "D. Yeh paper ko thanda karta hai"
    ],
    correct: 0,
    explanation: "Convex lens sunlight ki rays ko ek chhote area mein converge kar sakta hai. Isse us jagah heat badh sakti hai aur paper ignite ho sakta hai.<br><br>Example: Solar concentrators sunlight ki energy ko heat produce karne ke liye use karte hain.<br><br>⚠️ Safety Note: Is experiment ko sirf teacher ya adult ki supervision mein karein. Sun ko directly na dekhein aur focused sunlight ko kisi ki skin ya aankhon par na daalein."
  }
];

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

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 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() {
  if (submitted) return;

  saveAnswer();
  score = 0;

  questions.forEach((q, index) => {
    if (userAnswers[index] === q.correct) score++;
  });

  submitted = 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>`;
}

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