class 8 science chapter 11

ch11 part5

<!DOCTYPE html>
<html lang="en">
<head>
<title>🧠 Science Quiz – Earth, Sun and Time</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 – Earth, Sun and Time</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. Earth par day aur night hone ka main reason kya hai?",
    options: [
      "A. Earth ka Sun ke around revolution",
      "B. Earth ka apni axis par rotation",
      "C. Moon ka Earth ke around revolution",
      "D. Sun ka Earth ke around rotation"
    ],
    correct: 1,
    explanation: "Earth apni axis par rotate karti hai. Is rotation ke kaaran humein Sun east mein rise aur west mein set hota hua dikhai deta hai. Earth ka jo part Sun ki taraf hota hai, wahan day hota hai.<br><br>Example: Jab India mein day hota hai, tab Earth ke doosre part mein night ho sakti hai."
  },
  {
    question: "2. Mean solar day ki duration kitni hoti hai?",
    options: [
      "A. 12 hours",
      "B. 23 hours",
      "C. 24 hours",
      "D. 365 days"
    ],
    correct: 2,
    explanation: "Mean solar day woh average time hai jo Sun ko sky mein apni highest position se agle din phir highest position par pahunchne mein lagta hai.<br><br>Example: Hum daily activities, jaise school jaana aur sona, ko 24-hour day ke according plan karte hain."
  },
  {
    question: "3. Sun jab sky mein apni highest position par hota hai, tab object ki shadow generally kaisi hoti hai?",
    options: [
      "A. Sabse lambi",
      "B. Sabse chhoti",
      "C. Bilkul red",
      "D. Hamesha invisible"
    ],
    correct: 1,
    explanation: "Jab Sun sky mein highest position par hota hai, toh vertical object ki shadow generally din ki sabse chhoti hoti hai.<br><br>Example: Ek vertical stick ki shadow midday ke aas-paas subah aur shaam ke comparison mein chhoti hoti hai."
  },
  {
    question: "4. Moon ke phases ka complete cycle lagbhag kitne din ka hota hai?",
    options: [
      "A. 7 days",
      "B. 15 days",
      "C. 29.5 days",
      "D. 365 days"
    ],
    correct: 2,
    explanation: "Moon ko New Moon se next New Moon tak apne phases ka cycle complete karne mein lagbhag 29.5 days lagte hain. Isi natural cycle ko month define karne ka ek basis banaya gaya.<br><br>Example: Ek Full Moon ke baad next Full Moon lagbhag 29–30 days mein aata hai."
  },
  {
    question: "5. Calendar mein month ko define karne ka ek natural basis kya hai?",
    options: [
      "A. Earth ka daily rotation",
      "B. Moon ke phases ka cycle",
      "C. Sun ki brightness",
      "D. Stars ka colour"
    ],
    correct: 1,
    explanation: "Moon ke phases ka cycle lagbhag 29.5 days ka hota hai. Is natural cycle ne month jaise time unit ko develop karne mein important role play kiya.<br><br>Example: Lunar calendars mein months ko Moon ke phases ke basis par determine kiya ja sakta hai."
  },
  {
    question: "6. Earth ko Sun ke around ek revolution complete karne mein lagbhag kitna time lagta hai?",
    options: [
      "A. 24 hours",
      "B. 29.5 days",
      "C. 180 days",
      "D. 365ÂĽ days"
    ],
    correct: 3,
    explanation: "Earth Sun ke around ek complete revolution lagbhag 365ÂĽ days mein karti hai. Isi duration ko solar year ka basis mana jata hai.<br><br>Example: Earth ke revolution aur seasons ke cycle ke basis par year ko define kiya jata hai."
  },
  {
    question: "7. Solar year ka relation kis natural cycle se hai?",
    options: [
      "A. Moon ke daily movement se",
      "B. Earth ke Sun ke around revolution aur seasons ke cycle se",
      "C. Earth ke ek rotation se",
      "D. Stars ke daily colour change se"
    ],
    correct: 1,
    explanation: "Earth jab Sun ke around ek revolution complete karti hai, toh lagbhag ek seasonal cycle complete hota hai. Is duration ko solar year kehte hain.<br><br>Example: Summer, rainy season aur winter jaise seasonal changes year ke cycle ka part hain."
  },
  {
    question: "8. Earth ke revolution ka duration 365ÂĽ days hone ka kya result hai?",
    options: [
      "A. Har year mein 100 days hote hain",
      "B. Calendar year hamesha exactly 365 days ka hona chahiye",
      "C. Har year lagbhag ek-quarter day extra hota hai",
      "D. Moon ke phases band ho jate hain"
    ],
    correct: 2,
    explanation: "Earth ko Sun ke around ek revolution complete karne mein 365 days se lagbhag 6 hours zyada lagte hain. Yeh extra time chaar saal mein lagbhag ek din ho jata hai.<br><br>Example: Isi extra time ko account karne ke liye leap year mein February mein 29 days hote hain, aam taur par har chaar saal mein."
  },
  {
    question: "9. Sun ki sky mein apparent daily movement ka main reason kya hai?",
    options: [
      "A. Sun ka Earth ke around daily revolution",
      "B. Earth ka apni axis par rotation",
      "C. Moon ka Earth se door jaana",
      "D. Earth ka apna size change karna"
    ],
    correct: 1,
    explanation: "Sun humein east se west ki taraf move karta hua dikhta hai, lekin yeh apparent motion mainly Earth ke west-to-east rotation ke kaaran hota hai.<br><br>Example: Subah Sun eastern sky mein aur shaam ko western sky mein dikhai deta hai."
  },
  {
    question: "10. Day, month aur year ke natural bases ka correct combination kaunsa hai?",
    options: [
      "A. Day—Moon's revolution; Month—Earth's rotation; Year—Sun's rotation",
      "B. Day—Earth's rotation; Month—Moon's phase cycle; Year—Earth's revolution around Sun",
      "C. Day—Earth's revolution; Month—Sun's rotation; Year—Moon's rotation",
      "D. Day—Stars; Month—Earth's rotation; Year—Moon's phases only"
    ],
    correct: 1,
    explanation: "Different natural cycles time measure karne ke liye use hote hain. Earth ka rotation day ka, Moon ke phases ka cycle month ka aur Earth ka Sun ke around revolution year ka basis hai.<br><br>Example: Hum daily schedule ke liye day, monthly planning ke liye month aur birthdays ya annual exams ke liye year use karte 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