class 9 science chapter 6

ch6 part8

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Science Quiz โ€“ Newton's Second Law of Motion</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;
  margin: 0;
  box-sizing: border-box;
}
.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: 15px 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;
}
.options input {
  margin-right: 8px;
}
.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;
}
hr {
  border: 0;
  border-top: 1px solid #ddd;
  margin: 20px 0;
}
@media (max-width: 600px) {
  body {
    padding: 12px;
  }
  .quiz-container {
    width: 100%;
    padding: 15px;
  }
}
</style>
</head>

<body>
<div class="quiz-container">

  <h2>๐Ÿง  Science Quiz โ€“ Newton's Second Law of Motion</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. Newtonโ€™s second law ke according, force kisi object ki motion mein kya produce karta hai?",
    options: ["A. Mass", "B. Acceleration", "C. Density", "D. Volume"],
    correct: 1,
    explanation: "Net force object ki velocity mein change produce karta hai, aur velocity ka change acceleration kehlata hai."
  },
  {
    question: "2. Ek ball ko gently push karne par woh slowly move karna start karti hai. Iska matlab applied force se acceleration kaisa hoga?",
    options: ["A. Bahut large", "B. Zero", "C. Small", "D. Infinite"],
    correct: 2,
    explanation: "Gentle push mein force ka magnitude small hota hai, isliye same object ke liye acceleration bhi comparatively small hota hai."
  },
  {
    question: "3. Agar same ball ko stronger force se push kiya jaaye, to uski acceleration par kya effect hoga?",
    options: ["A. Acceleration larger hogi", "B. Acceleration zero ho jaayegi", "C. Acceleration same rahegi", "D. Acceleration hamesha negative hogi"],
    correct: 0,
    explanation: "Same object ke liye force ka magnitude badhne par acceleration bhi increase hoti hai."
  },
  {
    question: "4. Same object aur same surface ke liye force aur acceleration ke beech kya relationship investigate kiya ja raha hai?",
    options: ["A. Larger force โ†’ larger acceleration", "B. Larger force โ†’ smaller acceleration", "C. Force badhne par acceleration zero", "D. Force aur acceleration ka koi relation nahi"],
    correct: 0,
    explanation: "Activity ka hypothesis hai ki same object par larger force apply karne se larger acceleration produce hoti hai."
  },
  {
    question: "5. Different magnitudes ki force apply karne ke liye Activity 6.3 mein kis cheez ka use kiya ja sakta hai?",
    options: ["A. Different coloured pencils", "B. Different weights/coins", "C. Different size tables", "D. Different temperatures"],
    correct: 1,
    explanation: "Different weights different gravitational forces provide karte hain. Activity mein cup mein coins ya other objects rakhkar applied force change ki ja sakti hai."
  },
  {
    question: "6. Activity 6.3 mein cup neeche ki taraf kyun move karta hai?",
    options: ["A. Magnetic force ke kaaran", "B. Friction ke kaaran", "C. Earth ke gravitational force ke kaaran", "D. Normal force ke kaaran"],
    correct: 2,
    explanation: "Earth cup ko downward gravitational force se pull karti hai, jisse cup neeche move karta hai."
  },
  {
    question: "7. Activity 6.3 mein cup ki downward motion cart ko kaise pull karti hai?",
    options: ["A. Thread ke through", "B. Pencil ke through", "C. Wheels ke through", "D. Table ke through"],
    correct: 0,
    explanation: "Cup se attached thread pipe ke over se pass hota hai. Cup downward move karta hai aur thread ke through cart ko pull karta hai."
  },
  {
    question: "8. Activity 6.3 mein cardboard box mein pencils ka main purpose kya hai?",
    options: ["A. Cart ka mass measure karna", "B. Axles ki tarah kaam karna", "C. Force produce karna", "D. Thread ko cut karna"],
    correct: 1,
    explanation: "Do pencils box ke sides ke through insert ki jaati hain aur axles ki tarah kaam karti hain, jin par wheels attached hote hain."
  },
  {
    question: "9. Activity 6.3 mein cart ki motion ko record karne ke liye kya use kiya jaata hai?",
    options: ["A. Stopwatch only", "B. Slow-motion video recording", "C. Thermometer", "D. Spring balance"],
    correct: 1,
    explanation: "Cart ko start line se release karke doosre end tak uski motion ko slow-motion video mein record kiya jaata hai, taaki motion ka analysis kiya ja sake."
  },
  {
    question: "10. Activity 6.3 mein cup ke saath objects/coins ki quantity badhakar kya investigate kiya ja sakta hai?",
    options: ["A. Different forces ke effect on cart acceleration", "B. Cart ka colour change", "C. Table ka temperature", "D. Wheel ka shape change"],
    correct: 0,
    explanation: "Cup mein different weights rakhne se gravitational force aur cart par pulling force ka magnitude change hota hai. Isse force aur acceleration ke relationship ko investigate kiya jaata 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 = `
    <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, 10) : null;
}

function nextQuestion() {
  saveAnswer();

  if (currentQuestion < questions.length - 1) {
    currentQuestion++;
    showQuestion();
  }
}

function prevQuestion() {
  saveAnswer();

  if (currentQuestion > 0) {
    currentQuestion--;
    showQuestion();
  }
}

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 optsHTML = q.options.map((opt, i) => {
      let cls = "";

      if (i === q.correct) {
        cls = "correct";
      }

      if (selected === i && selected !== q.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>`;
}

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

function saveScore(name, score) {
  let scores = [];

  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  } catch (error) {
    scores = [];
  }

  scores.push({
    name,
    score,
    date: new Date().toLocaleString()
  });

  localStorage.setItem("quizScores", JSON.stringify(scores));
}

function loadScoreboard() {
  let scores = [];

  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  } catch (error) {
    scores = [];
  }

  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("");
}
</script>
</body>
</html>

Leave a Comment