class 9 science chapter 7

ch7 part11

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Work, Energy and Escape Ramp Quiz – APICAL CLASSES</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;
  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; }
.brand {
  text-align: center;
  color: #1e3c72;
  font-weight: bold;
  margin-top: 15px;
}
</style>
</head>
<body>
<div class="quiz-container">
  <h2>🧠 Work, Energy and Escape Ramp Quiz</h2>
  <div class="brand">APICAL CLASSES</div>

  <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. Escape ramp ka main purpose kya hota hai?",
    options: [
      "A. Trucks ki speed increase karna",
      "B. Brake fail hone par truck ko safely stop karna",
      "C. Truck ka fuel save karna",
      "D. Truck ko highway par wapas bhejna"
    ],
    correct: 1,
    explanation: "Escape ramps sand ya gravel se filled inclined planes hote hain jo brake failure ke case mein moving truck ko stop karne mein help karte hain."
  },
  {
    question: "2. Example 7.9 mein truck ka mass kitna hai?",
    options: [
      "A. 1,000 kg",
      "B. 5,000 kg",
      "C. 10,000 kg",
      "D. 20,000 kg"
    ],
    correct: 2,
    explanation: "Question mein truck ka mass 10,000 kg diya gaya hai."
  },
  {
    question: "3. Truck ki initial speed 72 km/h hai. Is speed ko m/s mein convert karne par kya value milegi?",
    options: [
      "A. 10 m/s",
      "B. 15 m/s",
      "C. 20 m/s",
      "D. 25 m/s"
    ],
    correct: 2,
    explanation: "72 km/h × 5/18 = 20 m/s."
  },
  {
    question: "4. Truck ki initial kinetic energy kitni hai, jab uska mass 10,000 kg aur speed 20 m/s hai?",
    options: [
      "A. 200,000 J",
      "B. 1,000,000 J",
      "C. 2,000,000 J",
      "D. 4,000,000 J"
    ],
    correct: 2,
    explanation: "KE = ½mv² = ½ × 10,000 × 20² = 2,000,000 J."
  },
  {
    question: "5. Escape ramp ka inclination kitna diya gaya hai?",
    options: [
      "A. 15°",
      "B. 30°",
      "C. 45°",
      "D. 60°"
    ],
    correct: 1,
    explanation: "Example mein escape ramp 30° inclined hai."
  },
  {
    question: "6. 30° inclined ramp ke liye truck ramp par har 2 m travel karne par vertically kitna height gain karta hai?",
    options: [
      "A. 0.5 m",
      "B. 1 m",
      "C. 2 m",
      "D. 4 m"
    ],
    correct: 1,
    explanation: "Given hint ke according, truck ramp par 2 m travel karta hai to uski vertical height 1 m increase hoti hai."
  },
  {
    question: "7. Truck ke brakes fail hone ke baad sand truck ki motion ke opposite kitna force lagati hai?",
    options: [
      "A. 10,000 N",
      "B. 20,000 N",
      "C. 50,000 N",
      "D. 100,000 N"
    ],
    correct: 2,
    explanation: "Question mein sand ka opposing force 50,000 N diya gaya hai."
  },
  {
    question: "8. Escape ramp par aane ke baad truck finally kis state mein pahunchta hai?",
    options: [
      "A. Maximum speed par",
      "B. Constant speed par",
      "C. Rest mein",
      "D. Reverse direction mein moving"
    ],
    correct: 2,
    explanation: "Escape ramp ka purpose truck ko stop karna hai, isliye final kinetic energy zero hoti hai."
  },
  {
    question: "9. Example 7.9 mein truck ko stop karne ke liye minimum ramp length kitni honi chahiye?",
    options: [
      "A. 10 m",
      "B. 15 m",
      "C. 20 m",
      "D. 40 m"
    ],
    correct: 2,
    explanation: "Initial kinetic energy 2,000,000 J hai. Gravity ke against aur sand ke friction ke against energy use hoti hai, jisse calculation se minimum ramp length 20 m milti hai."
  },
  {
    question: "10. Example 7.9 mein conservation of mechanical energy ka use karne ka main advantage kya hai?",
    options: [
      "A. Truck ka mass change karna",
      "B. Intermediate motion ke detailed steps ke bina stopping distance find karna",
      "C. Sand ka force zero karna",
      "D. Gravity ko ignore karna"
    ],
    correct: 1,
    explanation: "Conservation of mechanical energy se initial aur final energy compare karke truck ki required ramp length directly find ki ja sakti hai."
  }
];

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

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 = `
    <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>
    <div class="explanation" id="explain${currentQuestion}">${q.explanation}</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 nextQuestion() {
  saveAnswer();
  if (currentQuestion < questions.length - 1) {
    currentQuestion++;
    showQuestion();
  }
}

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

function saveAnswer() {
  const selected = document.querySelector('input[name="option"]:checked');
  userAnswers[currentQuestion] = selected ? parseInt(selected.value) : null;
}

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

  document.querySelector(".controls").style.display = "none";
  document.getElementById("result").innerHTML =
    `<h3>Your Score: ${score} / ${questions.length}</h3>`;
}

function saveScore(name, score) {
  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  scores.push({
    name,
    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>${s.name} - ${s.score}/10 (${s.date})</li>`
    ).join("");
}
</script>
</body>
</html>

Leave a Comment