class 9 science chapter 6

ch6 part6

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APICAL CLASSES - Science Quiz: Newton's First Law</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;
  line-height: 1.5;
  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; }
#result { text-align: center; margin-top: 20px; }
</style>
</head>
<body>

<div class="quiz-container">
  <h2>๐Ÿง  APICAL CLASSES โ€“ Science Quiz</h2>
  <h3 style="text-align:center;color:#2a5298;">Newton's First Law of Motion and Inertia</h3>

  <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"></div>

    <div id="scoreboard">
      <h3>๐Ÿ† Scoreboard</h3>
      <ol id="scoreList"></ol>
    </div>
  </div>
</div>

<script>
const questions = [
  {
    question: "1. Galileo Galilei ke according, agar ek body horizontal plane par move kar rahi ho aur uski motion ke saare impediments remove kar diye jaayen, to body kya karegi?",
    options: [
      "A. Turant rest mein aa jaayegi",
      "B. Dheere-dheere ruk jaayegi",
      "C. Indefinitely move karti rahegi",
      "D. Circular motion karne lagegi"
    ],
    correct: 2,
    explanation: "Galileo ne thought experiments ke through explain kiya ki agar friction jaise impediments remove ho jaayen, to moving body indefinitely move karti rahegi."
  },
  {
    question: "2. Isaac Newton ne objects ki rest ya uniform motion ki state mein change ko resist karne ki tendency ko kya naam diya?",
    options: [
      "A. Momentum",
      "B. Inertia",
      "C. Acceleration",
      "D. Friction"
    ],
    correct: 1,
    explanation: "Newton ne object ki apni state of rest ya uniform motion mein change ko resist karne ki tendency ko inertia kaha."
  },
  {
    question: "3. Newton ne apne three laws of motion kis year mein present kiye the?",
    options: [
      "A. 1587",
      "B. 1687",
      "C. 1787",
      "D. 1887"
    ],
    correct: 1,
    explanation: "Newton ne motion ke three laws 1687 mein present kiye, jo science ke history mein ek important development tha."
  },
  {
    question: "4. Force ki SI unit ka naam kis scientist ke naam par rakha gaya hai?",
    options: [
      "A. Galileo",
      "B. Albert Einstein",
      "C. Isaac Newton",
      "D. Archimedes"
    ],
    correct: 2,
    explanation: "Force ki SI unit newton hai, jo scientist Isaac Newton ke naam par named hai. Iska symbol N hai."
  },
  {
    question: "5. Newton ke first law ke according, agar kisi object par net force zero ho, to object kya karega?",
    options: [
      "A. Hamesha accelerate karega",
      "B. Apni state of rest ya uniform motion maintain karega",
      "C. Hamesha slow hoga",
      "D. Direction automatically change karega"
    ],
    correct: 1,
    explanation: "Zero net force ke case mein object rest mein hai to rest mein rahega, aur motion mein hai to constant velocity se move karta rahega."
  },
  {
    question: "6. Ek object rest mein hai aur uski velocity zero hai. Agar us par net force zero rahe, to kya hoga?",
    options: [
      "A. Object move karna start karega",
      "B. Object ki velocity increase hogi",
      "C. Object rest mein hi rahega",
      "D. Object ki direction change hogi"
    ],
    correct: 2,
    explanation: "Newtonโ€™s first law ke according, rest mein object tab tak rest mein rahega jab tak us par non-zero net force act nahi karta."
  },
  {
    question: "7. Constant velocity ka correct meaning kya hai?",
    options: [
      "A. Sirf speed constant rahe",
      "B. Sirf direction constant rahe",
      "C. Velocity ka magnitude aur direction dono constant rahein",
      "D. Object ki acceleration continuously increase ho"
    ],
    correct: 2,
    explanation: "Constant velocity ka matlab hai velocity ke magnitude aur direction dono mein koi change na ho."
  },
  {
    question: "8. Agar koi object non-zero constant velocity se move kar raha hai aur net force zero hai, to uski motion kaisi hogi?",
    options: [
      "A. Straight line mein same direction aur same speed se",
      "B. Circular path mein",
      "C. Zig-zag path mein",
      "D. Increasing speed ke saath"
    ],
    correct: 0,
    explanation: "Non-zero constant velocity mein magnitude aur direction dono constant hote hain, isliye object straight line mein same speed aur direction se move karta hai."
  },
  {
    question: "9. Agar friction zero ho aur ek object already constant velocity se move kar raha ho, to use moving rakhne ke liye continuously force apply karna padega?",
    options: [
      "A. Haan, continuously force required hai",
      "B. Nahi, further force required nahi hai",
      "C. Sirf gravitational force required hai",
      "D. Sirf normal force required hai"
    ],
    correct: 1,
    explanation: "Friction zero hone par moving object ko constant velocity maintain karne ke liye additional force ki zarurat nahi hoti."
  },
  {
    question: "10. Ek moving object ki velocity ko change karna ya object ko stop karna ho, to kya required hoga?",
    options: [
      "A. Net force",
      "B. Zero force",
      "C. Sirf normal force",
      "D. Sirf gravitational force"
    ],
    correct: 0,
    explanation: "Velocity ka magnitude ya direction change karne, ya moving object ko stop karne ke liye net force apply karna padta hai."
  }
];

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

function startQuiz() {
  userName = document.getElementById("userName").value.trim();

  if (!userName) {
    alert("Please enter your name.");
    return;
  }

  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 = `
    <p style="color:#555;">Question ${currentQuestion + 1} of ${questions.length}</p>
    <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>
  `;

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

  const unanswered = userAnswers.filter(
    answer => answer === null || answer === undefined
  ).length;

  if (unanswered > 0) {
    if (!confirm(`You have ${unanswered} unanswered question(s). Do you want to submit anyway?`)) {
      return;
    }
  }

  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;">
        <strong>Explanation:</strong> ${q.explanation}
      </div>
      <hr>
    `;
  });

  document.querySelector(".controls").style.display = "none";

  document.getElementById("result").innerHTML = `
    <h3>Your Score: ${score} / ${questions.length}</h3>
    <p><strong>${escapeHTML(userName)}</strong></p>
    <p>${score >= 8 ? "Excellent Work! ๐ŸŽ‰" : score >= 5 ? "Good Attempt! Keep Practising." : "Keep Learning and Try Again!"}</p>
  `;
}

function saveScore(name, score) {
  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];

  scores.push({
    name: name,
    score: 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>${escapeHTML(s.name)} - ${s.score}/10 (${escapeHTML(s.date)})</li>`
  ).join("");
}

function escapeHTML(value) {
  return String(value).replace(/[&<>"']/g, char => ({
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#39;"
  })[char]);
}
</script>

</body>
</html>

Leave a Comment