class 9 science chapter 4

ch4 part14


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APICAL CLASSES - Motion and Braking Distance 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; }
.brand {
  text-align: center;
  color: #2a5298;
  font-weight: bold;
  letter-spacing: 2px;
}
.question {
  font-weight: bold;
  margin: 15px 0;
  line-height: 1.6;
}
.options label {
  display: block;
  margin: 8px 0;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #ccc;
  cursor: pointer;
  transition: 0.3s;
  line-height: 1.5;
}
.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: 12px;
  margin-top: 10px;
  border-left: 5px solid #2a5298;
  border-radius: 5px;
  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; }
#progress {
  text-align: center;
  font-weight: bold;
  color: #555;
}
#result {
  text-align: center;
  margin-top: 20px;
}
input[type="text"] {
  padding: 10px;
  width: 90%;
  max-width: 350px;
  border: 1px solid #aaa;
  border-radius: 6px;
  font-size: 15px;
}
@media(max-width:600px) {
  body { padding: 10px; }
  .quiz-container { width: 100%; padding: 16px; }
}
</style>
</head>
<body>

<div class="quiz-container">
  <div class="brand">APICAL CLASSES</div>
  <h2>🧠 Motion and Braking Distance Quiz</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;">
    <p id="progress"></p>
    <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. Ek car 54 km/h ki speed se move kar rahi hai. Brakes lagane par acceleration −4 m/s² ho jaati hai. Car ko stop hone se pehle kitna distance travel karna padega?",
  options: ["A. 18.75 m", "B. 28.125 m", "C. 36.25 m", "D. 45 m"],
  correct: 1,
  explanation: "54 km/h = 15 m/s. Using v² = u² + 2as: 0 = 15² − 8s, so s = 225/8 = 28.125 m."
},
{
  question: "2. Same braking acceleration −4 m/s² ke saath ek car 108 km/h ki speed se chal rahi hai. Stop hone se pehle car kitna distance travel karegi?",
  options: ["A. 56.25 m", "B. 75 m", "C. 112.5 m", "D. 135 m"],
  correct: 2,
  explanation: "108 km/h = 30 m/s. 0 = 30² − 8s. Therefore, s = 900/8 = 112.5 m."
},
{
  question: "3. Agar ek car ki speed 54 km/h se 108 km/h ho jaaye aur braking acceleration same rahe, toh stopping distance par kya effect hoga?",
  options: ["A. Half ho jayegi", "B. Double ho jayegi", "C. Four times ho jayegi", "D. Same rahegi"],
  correct: 2,
  explanation: "Stopping distance s ∝ u². Speed double hone par stopping distance 2² = 4 times ho jaati hai."
},
{
  question: "4. Example 4.8 mein braking ke baad car ka final velocity kya hai?",
  options: ["A. 4 m/s", "B. 15 m/s", "C. 30 m/s", "D. 0 m/s"],
  correct: 3,
  explanation: "Braking ke baad jab car completely stop ho jaati hai, uski final velocity 0 m/s hoti hai."
},
{
  question: "5. 54 km/h ko SI unit m/s mein convert karne par kya value milegi?",
  options: ["A. 10 m/s", "B. 12.5 m/s", "C. 15 m/s", "D. 18 m/s"],
  correct: 2,
  explanation: "54 × 5/18 = 15 m/s."
},
{
  question: "6. Moving vehicle ke brakes lagane ke baad bhi vehicle kuch distance travel karta hai. Is stopping distance ko kaunse factors affect kar sakte hain?",
  options: ["A. Sirf vehicle ki colour", "B. Initial velocity, road surface aur braking capacity", "C. Sirf vehicle ka horn", "D. Sirf vehicle ki height"],
  correct: 1,
  explanation: "Stopping distance initial velocity, road condition, braking capacity aur driver ke reaction time par depend karti hai."
},
{
  question: "7. Wet road par braking conditions dry road ke comparison mein different ho sakti hain. Isliye safe driving ke liye kya karna chahiye?",
  options: ["A. Vehicle ke aage bahut kam distance rakhna", "B. Safe following distance maintain karna", "C. Speed ko hamesha maximum rakhna", "D. Brakes ka use bilkul nahi karna"],
  correct: 1,
  explanation: "Wet road jaise conditions mein stopping distance badh sakti hai, isliye sufficient safe distance maintain karna important hai."
},
{
  question: "8. Driver ka reaction time stopping distance ko kyun affect karta hai?",
  options: ["A. Reaction ke dauran vehicle distance travel kar sakta hai", "B. Reaction time vehicle ka mass badha deta hai", "C. Reaction time acceleration ko hamesha zero kar deta hai", "D. Reaction time road ko dry kar deta hai"],
  correct: 0,
  explanation: "Brakes apply hone se pehle driver ko danger notice karke react karne mein time lagta hai. Is duration mein vehicle aage distance travel karta hai."
},
{
  question: "9. V2V communication technology ka main purpose kya hai?",
  options: ["A. Vehicles ka fuel automatically fill karna", "B. Vehicles ke beech signals exchange karke possible collision ke warning dena", "C. Vehicle ki speed ko hamesha double karna", "D. Road ki length measure karna"],
  correct: 1,
  explanation: "V2V (Vehicle-to-Vehicle) communication vehicles ko signals exchange karne aur possible collision ke baare mein drivers ko warn karne mein help karti hai."
},
{
  question: "10. Agar braking acceleration ka magnitude 4 m/s² hai aur car ki initial speed 30 m/s hai, toh stop hone se pehle distance kitna hoga?",
  options: ["A. 56.25 m", "B. 75 m", "C. 112.5 m", "D. 120 m"],
  correct: 2,
  explanation: "Using v² = u² + 2as: 0 = 30² + 2(−4)s. Therefore, 0 = 900 − 8s, so s = 900/8 = 112.5 m."
}
];

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

  userAnswers = new Array(questions.length).fill(null);
  currentQuestion = 0;

  showQuestion();
  loadScoreboard();
}

function showQuestion() {
  const q = questions[currentQuestion];
  const container = document.getElementById("questionContainer");

  document.getElementById("progress").textContent =
    "Question " + (currentQuestion + 1) + " of " + questions.length;

  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) : 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.findIndex(answer => answer === null);

  if (unanswered !== -1) {
    alert("Please attempt all questions. Question " + (unanswered + 1) + " is unanswered.");
    currentQuestion = unanswered;
    showQuestion();
    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;

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

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

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

  document.getElementById("result").innerHTML = `
    <h3>🎉 Quiz Completed!</h3>
    <h2>Your Score: ${score} / ${questions.length}</h2>
    <h3>Percentage: ${percentage}%</h3>
    <p><strong>Student Name:</strong> ${escapeHTML(userName)}</p>
    <button onclick="location.reload()">Try Again</button>
  `;
}

function escapeHTML(value) {
  const div = document.createElement("div");
  div.textContent = value;
  return div.innerHTML;
}

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

Leave a Comment