class 9 science chapter 6

ch6 part2

<!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: Force</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;">Force and Balanced & Unbalanced Forces</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. Jab ek box ko surface par push kiya jaata hai, to push ke opposite direction mein kaunsa force act karta hai?",
    options: [
      "A. Gravitational force",
      "B. Frictional force",
      "C. Buoyant force",
      "D. Magnetic force"
    ],
    correct: 1,
    explanation: "Friction motion ke opposite direction mein act karta hai aur box ki motion ko oppose karta hai."
  },
  {
    question: "2. Paani par floating ball par kaun-se do forces act karte hain?",
    options: [
      "A. Frictional force aur magnetic force",
      "B. Gravitational force aur frictional force",
      "C. Gravitational force aur buoyant force",
      "D. Magnetic force aur buoyant force"
    ],
    correct: 2,
    explanation: "Earth ka gravitational force ball par downward act karta hai, jabki water ka buoyant force upward act karta hai."
  },
  {
    question: "3. Tug of war mein dono teams rope ko equal force se opposite directions mein pull karti hain. Rope par kya effect hoga?",
    options: [
      "A. Rope left side move karegi",
      "B. Rope right side move karegi",
      "C. Rope move nahi karegi",
      "D. Rope circular motion karegi"
    ],
    correct: 2,
    explanation: "Equal magnitude ke opposite forces ek-doosre ko balance kar dete hain, isliye net force zero hota hai."
  },
  {
    question: "4. Equal magnitude aur opposite direction mein acting karne wale forces ko kya kaha jaata hai?",
    options: [
      "A. Unbalanced forces",
      "B. Balanced forces",
      "C. Magnetic forces",
      "D. Frictional forces"
    ],
    correct: 1,
    explanation: "Jab forces magnitude mein equal aur direction mein opposite hote hain, to unhe balanced forces kehte hain."
  },
  {
    question: "5. Tug of war mein ek team doosri team se zyada force lagati hai. Rope kis direction mein move karegi?",
    options: [
      "A. Smaller force ki direction mein",
      "B. Larger force ki direction mein",
      "C. Opposite to both forces",
      "D. Rope move nahi karegi"
    ],
    correct: 1,
    explanation: "Unequal opposite forces ka net force larger force ki direction mein hota hai, isliye rope usi direction mein move karti hai."
  },
  {
    question: "6. Do opposite forces 50 N aur 30 N hain. Net force ka magnitude kitna hoga?",
    options: [
      "A. 20 N",
      "B. 30 N",
      "C. 50 N",
      "D. 80 N"
    ],
    correct: 0,
    explanation: "Opposite aur unequal forces ke liye net force = difference = 50 N − 30 N = 20 N."
  },
  {
    question: "7. Agar do forces 40 N aur 25 N opposite directions mein act kar rahe hain, to net force kis direction mein hoga?",
    options: [
      "A. 25 N force ki direction mein",
      "B. 40 N force ki direction mein",
      "C. Dono ke perpendicular",
      "D. Net force zero hoga"
    ],
    correct: 1,
    explanation: "Net force hamesha larger magnitude wale force ki direction mein hota hai."
  },
  {
    question: "8. Ek stalled car ko do log same direction mein 100 N aur 150 N force se push karte hain. Net force kitna hoga?",
    options: [
      "A. 50 N",
      "B. 100 N",
      "C. 150 N",
      "D. 250 N"
    ],
    correct: 3,
    explanation: "Same direction mein forces add hote hain: 100 N + 150 N = 250 N."
  },
  {
    question: "9. Jab ek object par acting forces balanced hote hain, to net force ka value kya hota hai?",
    options: [
      "A. Zero",
      "B. One",
      "C. Maximum",
      "D. Negative"
    ],
    correct: 0,
    explanation: "Balanced forces ek-doosre ko cancel kar dete hain, isliye object par net force zero hota hai."
  },
  {
    question: "10. Niche diye gaye statements mein se unbalanced forces ke baare mein correct statement kaunsa hai?",
    options: [
      "A. Unbalanced forces ka net force hamesha zero hota hai.",
      "B. Unbalanced forces equal aur opposite hote hain.",
      "C. Unbalanced forces ke case mein non-zero net force act karta hai.",
      "D. Unbalanced forces object ko kabhi move nahi karte."
    ],
    correct: 2,
    explanation: "Jab forces balanced nahi hote, to non-zero net force act karta hai aur object ki motion mein change ho sakta hai."
  }
];

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

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(a => a === null || a === 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++;
    }
  });

  submitted = true;
  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>${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