class 8 science chapter 11

ch11 part6

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Science Quiz – Lunar and Solar Calendars</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>🧠 Science Quiz – Lunar and Solar Calendars</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. Lunar calendar kis natural cycle par based hota hai?",
    options: [
      "A. Earth ke rotation par",
      "B. Moon ke phases ke cycle par",
      "C. Sun ke colour change par",
      "D. Earth ke daily temperature par"
    ],
    correct: 1,
    explanation: "Lunar calendar mein Moon ke phases ke cycle ko time measure karne ke liye use kiya jata hai. Ek lunar month lagbhag 29.5 days ka hota hai.<br><br>Example: Moon ke ek New Moon se agle New Moon tak ke cycle ko ek lunar month ka basis banaya ja sakta hai."
  },
  {
    question: "2. Ek lunar year mein generally kitne lunar months hote hain?",
    options: [
      "A. 10",
      "B. 11",
      "C. 12",
      "D. 13"
    ],
    correct: 2,
    explanation: "Ancient people ne observe kiya tha ki ek seasonal cycle mein lagbhag 12 lunar cycles fit hote hain. Isliye lunar year mein 12 lunar months rakhe gaye.<br><br>Example: 12 lunar months ko approximately 354 days mein complete kiya jata hai."
  },
  {
    question: "3. Ek lunar month ki duration lagbhag kitni hoti hai?",
    options: [
      "A. 24 days",
      "B. 29.5 days",
      "C. 30.5 days",
      "D. 365 days"
    ],
    correct: 1,
    explanation: "Moon ke phases ka ek complete cycle lagbhag 29.5 days leta hai. Lunar calendar ka month isi natural cycle par based hota hai.<br><br>Example: Ek Full Moon se agle Full Moon tak approximately 29–30 days lagte hain."
  },
  {
    question: "4. Lunar year ki duration approximately kitni hoti hai?",
    options: [
      "A. 300 days",
      "B. 354 days",
      "C. 365 days",
      "D. 400 days"
    ],
    correct: 1,
    explanation: "Lunar year mein 12 lunar months hote hain. Inki total duration approximately 354 days hoti hai, jo solar year se lagbhag 11 days kam hai.<br><br>Example: Agar solar year 365 days ka ho, toh lunar year approximately 11 days chhota hota hai."
  },
  {
    question: "5. Lunar calendar mein seasons har saal same lunar months ke saath synchronised kyun nahi rehte?",
    options: [
      "A. Moon apni light produce nahi karta",
      "B. Earth rotate nahi karti",
      "C. Lunar year solar year se chhota hota hai",
      "D. Har lunar month 40 days ka hota hai"
    ],
    correct: 2,
    explanation: "Lunar year lagbhag 354 days ka hota hai, jabki seasons ka cycle approximately 365 days mein repeat hota hai. Isliye lunar calendar ke months seasons ke comparison mein har saal shift ho sakte hain.<br><br>Example: Koi festival jo lunar calendar ki date par based ho, woh Gregorian calendar mein har saal different date par aa sakta hai."
  },
  {
    question: "6. Solar calendar banane ka important reason kya tha?",
    options: [
      "A. Moon ka size measure karna",
      "B. Seasons ko calendar ke saath synchronised rakhna",
      "C. Stars ki counting karna",
      "D. Day aur night ko khatam karna"
    ],
    correct: 1,
    explanation: "Agriculture ke liye seasons ka sahi samay par aana important tha. Solar calendars ko seasons ke cycle ke saath synchronised rakhne ke liye develop kiya gaya.<br><br>Example: Farmers ko sowing aur harvesting ke liye seasonal timing jaanne mein calendar help karta hai."
  },
  {
    question: "7. Aaj widely used Gregorian calendar kis type ka calendar hai?",
    options: [
      "A. Lunar calendar",
      "B. Solar calendar",
      "C. Star calendar",
      "D. Daily calendar only"
    ],
    correct: 1,
    explanation: "Gregorian calendar Earth ke Sun ke around revolution aur seasonal cycle par based solar calendar hai. Ismein normal year 365 days ka hota hai.<br><br>Example: January se December tak ka commonly used calendar Gregorian calendar hai."
  },
  {
    question: "8. Gregorian calendar mein February mein normal year ke dauran kitne days hote hain?",
    options: [
      "A. 27",
      "B. 28",
      "C. 29",
      "D. 30"
    ],
    correct: 1,
    explanation: "Gregorian calendar mein normal year 365 days ka hota hai. February mein 28 days hote hain, jabki leap year mein 29 days hote hain.<br><br>Example: 2025 ek normal year tha, isliye February mein 28 days the."
  },
  {
    question: "9. Leap year mein February mein kitne days hote hain?",
    options: [
      "A. 27",
      "B. 28",
      "C. 29",
      "D. 30"
    ],
    correct: 2,
    explanation: "Earth ko Sun ke around ek revolution complete karne mein approximately 365ΒΌ days lagte hain. Extra quarter days lagbhag chaar saal mein ek extra day banate hain. Is adjustment ke liye leap year mein February mein 29 days hote hain.<br><br>Example: 2024 ek leap year tha, isliye February mein 29 days the."
  },
  {
    question: "10. Gregorian calendar ke basic rule ke according, agar year 4 se completely divisible hai, toh kya hota hai?",
    options: [
      "A. Year mein sirf 300 days hote hain",
      "B. February mein 29 days ho sakte hain",
      "C. December mein 32 days hote hain",
      "D. Lunar months 13 ho jate hain"
    ],
    correct: 1,
    explanation: "Gregorian calendar ke basic rule ke according, 4 se divisible year leap year hota hai. Lekin century years ke liye exception hai: woh leap year tabhi hote hain jab 400 se bhi divisible hon.<br><br>Example: 2024, 4 se divisible hai, isliye leap year tha. Lekin 1900 leap year nahi tha, kyunki woh 400 se divisible nahi tha."
  }
];

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