class 9 science chapter 4

ch4 part7

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APICAL CLASSES – Average Acceleration Quiz</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;
  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: 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;
  line-height: 1.5;
}
.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;
  margin-bottom: 15px;
  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; }
#userName {
  padding: 10px;
  width: 95%;
  max-width: 350px;
  border: 1px solid #ccc;
  border-radius: 6px;
}
@media (max-width: 600px) {
  body { padding: 10px; }
  .quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>
<body>
<div class="quiz-container">
  <h2>🧠 APICAL CLASSES – SCIENCE QUIZ</h2>
  <h3 style="text-align:center;color:#2a5298;">Topic: Average Acceleration</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" 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. Ek vehicle rest se suddenly move karta hai aur passenger ko jolt feel hota hai. Yeh jolt mainly kis change ko show karta hai?",
    options: [
      "A. Position ka change",
      "B. Velocity ka change",
      "C. Mass ka change",
      "D. Distance ka change"
    ],
    correct: 1,
    explanation: "Vehicle rest se move karte waqt velocity change hoti hai. Isi sudden change in velocity ke kaaran passenger ko jolt feel hota hai."
  },
  {
    question: "2. Average acceleration ko kaise define kiya jaata hai?",
    options: [
      "A. Total distance ÷ time interval",
      "B. Change in displacement ÷ distance",
      "C. Change in velocity ÷ time interval",
      "D. Time interval ÷ change in velocity"
    ],
    correct: 2,
    explanation: "Average acceleration = change in velocity / time interval."
  },
  {
    question: "3. Ek car ki initial velocity 10 m/s aur final velocity 30 m/s hai. Velocity ka yeh change 5 s mein hota hai. Car ki average acceleration kya hogi?",
    options: [
      "A. 2 m/s²",
      "B. 4 m/s²",
      "C. 6 m/s²",
      "D. 8 m/s²"
    ],
    correct: 1,
    explanation: "Average acceleration = (30 − 10) ÷ 5 = 20 ÷ 5 = 4 m/s²."
  },
  {
    question: "4. Agar kisi object ki velocity 20 m/s se 8 m/s ho jaati hai 4 seconds mein, toh average acceleration kya hogi?",
    options: [
      "A. +3 m/s²",
      "B. −3 m/s²",
      "C. +7 m/s²",
      "D. −7 m/s²"
    ],
    correct: 1,
    explanation: "Average acceleration = (8 − 20) ÷ 4 = −12 ÷ 4 = −3 m/s². Negative sign velocity ke decrease ko show karta hai."
  },
  {
    question: "5. Average acceleration ki SI unit kya hai?",
    options: [
      "A. m/s",
      "B. m",
      "C. m/s²",
      "D. km/h"
    ],
    correct: 2,
    explanation: "Acceleration velocity ke change ko time se divide karke milti hai, isliye SI unit metre per second squared (m/s²) hai."
  },
  {
    question: "6. Straight-line motion mein agar object ki velocity ka magnitude increase ho raha hai, toh average acceleration ki direction kaisi hogi?",
    options: [
      "A. Velocity ki direction ke same",
      "B. Velocity ki direction ke opposite",
      "C. Hamesha downward",
      "D. Hamesha zero"
    ],
    correct: 0,
    explanation: "Jab straight-line motion mein velocity ka magnitude increase hota hai, toh average acceleration velocity ki direction mein hoti hai."
  },
  {
    question: "7. Straight-line motion mein ek car ki speed decrease ho rahi hai. Average acceleration ki direction kya hogi?",
    options: [
      "A. Velocity ki same direction",
      "B. Velocity ke opposite direction",
      "C. Motion ke perpendicular",
      "D. Hamesha upward"
    ],
    correct: 1,
    explanation: "Jab velocity ka magnitude decrease hota hai, toh acceleration ki direction velocity ke opposite hoti hai. Car slow down kar rahi hoti hai."
  },
  {
    question: "8. Ek object ki speed constant hai, lekin uski direction change ho rahi hai. Kya acceleration ho sakti hai?",
    options: [
      "A. Nahi, kyunki speed constant hai",
      "B. Haan, kyunki velocity mein direction bhi included hoti hai",
      "C. Nahi, kyunki acceleration sirf speed change se hoti hai",
      "D. Sirf object rest mein ho toh"
    ],
    correct: 1,
    explanation: "Velocity mein magnitude aur direction dono hote hain. Direction change hone par speed constant rehne ke baad bhi velocity change hoti hai, isliye acceleration ho sakti hai."
  },
  {
    question: "9. Average acceleration kis-kis change ke kaaran ho sakti hai?",
    options: [
      "A. Sirf velocity ke magnitude ke change se",
      "B. Sirf velocity ki direction ke change se",
      "C. Magnitude, direction, ya dono ke change se",
      "D. Sirf mass ke change se"
    ],
    correct: 2,
    explanation: "Acceleration velocity ke change ko represent karti hai. Velocity ka magnitude, direction, ya dono change ho sakte hain."
  },
  {
    question: "10. Ek car 0 km/h se 100 km/h tak 10 seconds mein accelerate karti hai. Is situation mein average acceleration find karne ke liye sabse important information kya hai?",
    options: [
      "A. Sirf car ka mass",
      "B. Initial velocity, final velocity aur time interval",
      "C. Sirf total distance",
      "D. Sirf car ka colour"
    ],
    correct: 1,
    explanation: "Average acceleration calculate karne ke liye initial velocity, final velocity aur time interval required hote hain. Formula hai: change in velocity ÷ time interval."
  }
];

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

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 = `
    <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, 10) : null;
}

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

function prevQuestion() {
  saveAnswer();
  if (currentQuestion > 0) {
    currentQuestion--;
    showQuestion();
  }
}

function submitQuiz() {
  if (quizSubmitted) return;

  saveAnswer();

  score = 0;
  questions.forEach((q, index) => {
    if (userAnswers[index] === q.correct) score++;
  });

  quizSubmitted = 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;

    const 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";

  const percentage = ((score / questions.length) * 100).toFixed(1);

  document.getElementById("result").innerHTML = `
    <h3>Your Score: ${score} / ${questions.length}</h3>
    <h3>Percentage: ${percentage}%</h3>
    <p>${score === questions.length ? "Excellent! All answers are correct." :
      score >= questions.length * 0.6 ? "Well done! Keep practising." :
      "Keep learning and try again!"}</p>
  `;
}

function saveScore(name, score) {
  let scores = [];
  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
    if (!Array.isArray(scores)) scores = [];
  } catch (e) {
    scores = [];
  }

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

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

function loadScoreboard() {
  let scores = [];
  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
    if (!Array.isArray(scores)) scores = [];
  } catch (e) {
    scores = [];
  }

  scores.sort((a, b) => b.score - a.score);

  document.getElementById("scoreList").innerHTML = scores.map(s => `
    <li>${escapeHTML(s.name)} - ${s.score}/${s.total || 10} (${escapeHTML(s.date)})</li>
  `).join("");
}

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

Leave a Comment