class 8 science chapter 11

ch11 part1

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>🧠 Science Quiz – Phases of the Moon</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 – Phases of the Moon</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. Moon apni light khud produce karta hai ya sunlight ko reflect karta hai?",
    options: [
      "A. Moon apni light khud produce karta hai",
      "B. Moon sunlight ko reflect karta hai",
      "C. Moon stars ki light produce karta hai",
      "D. Moon Earth ki light produce karta hai"
    ],
    correct: 1,
    explanation: "Moon ek natural satellite hai. Yeh Sun ki light ko reflect karta hai, isliye humein bright dikhai deta hai.<br><br>Example: Jaise mirror sunlight ko reflect karta hai, waise hi Moon bhi sunlight reflect karta hai."
  },

  {
    question: "2. Moon ka shape humein har raat badalta hua kyun dikhai deta hai?",
    options: [
      "A. Moon ka actual shape badalta hai",
      "B. Moon ka kuch hissa toot jata hai",
      "C. Earth se Moon ka illuminated portion alag-alag dikhai deta hai",
      "D. Moon apni light band kar deta hai"
    ],
    correct: 2,
    explanation: "Moon spherical hai aur Sun ki light se uska aadha hissa illuminated hota hai. Moon ke Earth ke around move karne ke kaaran humein illuminated portion alag-alag dikhai deta hai.<br><br>Example: Kabhi Moon patli crescent jaisa dikhta hai, kabhi half circle aur kabhi full circle."
  },

  {
    question: "3. Full Moon day ko Hindi mein kya kehte hain?",
    options: [
      "A. Amavasya",
      "B. Purnima",
      "C. Krishna Paksha",
      "D. Shukla Paksha"
    ],
    correct: 1,
    explanation: "Jab Moon ka bright portion humein poore circle ke roop mein dikhai deta hai, us din ko Full Moon day ya Purnima kehte hain.<br><br>Example: Purnima ki raat Moon poora gol aur bright dikhai deta hai."
  },

  {
    question: "4. New Moon day ko Hindi mein kya kehte hain?",
    options: [
      "A. Purnima",
      "B. Gibbous Moon",
      "C. Amavasya",
      "D. Crescent Moon"
    ],
    correct: 2,
    explanation: "New Moon day par Moon ka illuminated portion Earth se lagbhag dikhai nahi deta. Isliye Moon ko aasman mein dekhna mushkil hota hai.<br><br>Example: Amavasya ki raat humein aam taur par Moon ka bright disc dikhai nahi deta."
  },

  {
    question: "5. Moon ke bright portion ke decrease hone wale period ko kya kehte hain?",
    options: [
      "A. Waxing period",
      "B. Waning period",
      "C. Solar period",
      "D. Eclipse period"
    ],
    correct: 1,
    explanation: "Full Moon ke baad Moon ka visible bright portion dheere-dheere kam hota hai. Is period ko waning period kehte hain. India mein ise Krishna Paksha bhi kaha jata hai.<br><br>Example: Full Moon ke baad Moon ka bright circle dheere-dheere half circle aur phir crescent jaisa ho jata hai."
  },

  {
    question: "6. Moon ke bright portion ke increase hone wale period ko kya kehte hain?",
    options: [
      "A. Waning period",
      "B. Krishna Paksha",
      "C. Waxing period",
      "D. New Moon period"
    ],
    correct: 2,
    explanation: "New Moon ke baad Moon ka visible bright portion dheere-dheere badhta hai. Is period ko waxing period ya Shukla Paksha kehte hain.<br><br>Example: Patle crescent se Moon half circle aur phir full circle jaisa dikhne lagta hai."
  },

  {
    question: "7. Ek Full Moon se agle Full Moon tak ka cycle lagbhag kitne samay mein complete hota hai?",
    options: [
      "A. 7 days",
      "B. 10 days",
      "C. 15 days",
      "D. 1 month"
    ],
    correct: 3,
    explanation: "Moon ke phases ka ek complete cycle ek Full Moon se agle Full Moon tak lagbhag 29.5 days ka hota hai, jise aam taur par about one month kaha jata hai.<br><br>Example: Agar ek Full Moon aaj hai, toh agla Full Moon lagbhag 29–30 din baad hoga."
  },

  {
    question: "8. Moon ka visible bright portion full circle se half circle tak lagbhag kitne samay mein kam hota hai?",
    options: [
      "A. Ek din",
      "B. Ek week",
      "C. Ek month",
      "D. Ek saal"
    ],
    correct: 1,
    explanation: "Full Moon ke baad lagbhag ek week mein Moon ka bright portion half circle jaisa dikhne lagta hai. Iske baad bright portion aur kam hota rehta hai.<br><br>Example: Purnima ke kuch din baad Moon ka shape poore circle ke bajay aadhe circle jaisa dikh sakta hai."
  },

  {
    question: "9. Moon ko daytime mein dekhna possible hai ya nahi?",
    options: [
      "A. Nahi, Moon sirf raat mein dikhta hai",
      "B. Haan, Moon daytime mein bhi dikh sakta hai",
      "C. Sirf eclipse ke time dikhta hai",
      "D. Sirf Purnima ko dikhta hai"
    ],
    correct: 1,
    explanation: "Moon din mein bhi sky mein present ho sakta hai. Agar uski position aur brightness suitable ho, toh sunlight ke bawajood hum use dekh sakte hain.<br><br>Example: Meera ne Makar Sankranti ke din Ahmedabad mein daytime sky mein Moon dekha."
  },

  {
    question: "10. Moon ke changing visible shapes ko kya kaha jata hai?",
    options: [
      "A. Constellations",
      "B. Phases of the Moon",
      "C. Solar system",
      "D. Lunar surface"
    ],
    correct: 1,
    explanation: "Earth se Moon ke bright portion ka roz alag shape mein dikhna, Moon ke phases kehlata hai. Ye phases Moon ke Earth ke around move karne ke kaaran dikhai dete hain.<br><br>Example: New Moon, Crescent Moon, Half Moon, Gibbous Moon aur Full Moon, Moon ke different phases hain."
  }

];

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