class 9 science chapter 4

ch4 part12

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Velocity-Time Graph 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: 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: 12px;
  margin-top: 10px;
  margin-bottom: 15px;
  border-left: 5px solid #2a5298;
  border-radius: 5px;
  line-height: 1.6;
  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; }
#userName {
  padding: 10px;
  width: 90%;
  max-width: 350px;
  border: 1px solid #aaa;
  border-radius: 6px;
}
#result { text-align: center; margin-top: 20px; }
@media(max-width:600px) {
  body { padding: 10px; }
  .quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>
<body>

<div class="quiz-container">
  <h2>🧠 Velocity-Time Graph Quiz</h2>
  <h3 style="text-align:center;color:#2a5298;">APICAL CLASSES</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. Velocity-time graph se velocity ke alawa kaunsi physical quantities calculate ki ja sakti hain?",
  options: [
    "A. Mass aur density",
    "B. Acceleration aur displacement",
    "C. Force aur pressure",
    "D. Volume aur temperature"
  ],
  correct: 1,
  explanation: "Velocity-time graph ka slope acceleration deta hai, aur graph ke neeche ka area displacement deta hai."
},
{
  question: "2. Velocity-time graph ki straight line ka slope kya represent karta hai?",
  options: [
    "A. Distance",
    "B. Displacement",
    "C. Acceleration",
    "D. Position"
  ],
  correct: 2,
  explanation: "Slope = change in velocity / change in time, yani acceleration."
},
{
  question: "3. Agar velocity-time graph X-axis ke parallel straight line ho, toh uska slope kya hoga?",
  options: [
    "A. Zero",
    "B. One",
    "C. Maximum",
    "D. Negative"
  ],
  correct: 0,
  explanation: "X-axis ke parallel line ki height change nahi hoti, isliye slope zero hota hai. Iska matlab velocity constant aur acceleration zero hai."
},
{
  question: "4. Ek velocity-time graph mein velocity 5 m/s se 10 m/s ho jaati hai 10 s se 20 s ke beech. Average acceleration ka magnitude kya hoga?",
  options: [
    "A. 0.25 m/s²",
    "B. 0.5 m/s²",
    "C. 1.5 m/s²",
    "D. 2 m/s²"
  ],
  correct: 1,
  explanation: "Acceleration = (10 − 5) / (20 − 10) = 5/10 = 0.5 m/s²."
},
{
  question: "5. Agar velocity-time graph mein velocity time ke saath decrease ho rahi hai, toh acceleration ka sign generally kya hoga, jab positive direction velocity ki direction mein li gayi ho?",
  options: [
    "A. Positive",
    "B. Zero",
    "C. Negative",
    "D. Infinite"
  ],
  correct: 2,
  explanation: "Velocity decrease hone par acceleration velocity ke opposite direction mein hoti hai, isliye sign negative hota hai."
},
{
  question: "6. Velocity-time graph aur time-axis ke beech enclosed area kya represent karta hai?",
  options: [
    "A. Acceleration",
    "B. Displacement",
    "C. Speed",
    "D. Force"
  ],
  correct: 1,
  explanation: "Velocity-time graph ke neeche ka area = displacement for that time interval."
},
{
  question: "7. Ek car 20 m/s ki constant velocity se 6 s tak move karti hai. Velocity-time graph ke neeche ka area kitna hoga?",
  options: [
    "A. 26 m",
    "B. 60 m",
    "C. 120 m",
    "D. 240 m"
  ],
  correct: 2,
  explanation: "Area = velocity × time = 20 × 6 = 120 m. Ye car ka displacement hai."
},
{
  question: "8. Ek car 10 s se 20 s ke beech move karti hai. Is interval mein velocity 5 m/s se 10 m/s tak uniformly increase hoti hai. Velocity-time graph ke neeche ka area 10–20 s ke beech kitna displacement show karega?",
  options: [
    "A. 50 m",
    "B. 75 m",
    "C. 100 m",
    "D. 150 m"
  ],
  correct: 1,
  explanation: "Area = rectangle + triangle = (5 × 10) + ½ × 10 × 5 = 50 + 25 = 75 m."
},
{
  question: "9. Velocity-time graph mein kisi time interval ke liye graph ke neeche area negative aaye, toh iska kya indication hoga?",
  options: [
    "A. Displacement ki direction negative hai",
    "B. Acceleration hamesha zero hai",
    "C. Object rest mein hai",
    "D. Distance negative hai"
  ],
  correct: 0,
  explanation: "Velocity ka negative sign displacement ki direction ko indicate karta hai. Isliye negative area negative displacement show karta hai."
},
{
  question: "10. Velocity-time graph se acceleration aur displacement nikalne ke liye respectively kya use kiya jaata hai?",
  options: [
    "A. Area aur slope",
    "B. Slope aur area",
    "C. Height aur slope",
    "D. Height aur area"
  ],
  correct: 1,
  explanation: "Velocity-time graph ka slope → acceleration aur graph ke neeche ka area → displacement deta 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="text-align:right;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() {
  if (submitted) return;

  saveAnswer();
  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];

    let 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>Correct Answer:</strong> ${q.options[q.correct]}<br>
        <strong>Explanation:</strong> ${q.explanation}
      </div>
      <hr>
    `;
  });

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

  document.getElementById("result").innerHTML = `
    <h3>Congratulations, ${escapeHTML(userName)}!</h3>
    <h2>Your Score: ${score} / ${questions.length}</h2>
    <p>${score >= 8 ? "Excellent Work!" : score >= 5 ? "Good Effort! Keep Practising." : "Keep Learning and Try Again!"}</p>
  `;
}

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

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(String(s.name))} - ${s.score}/10 (${escapeHTML(String(s.date))})</li>`
    ).join("");
}
</script>

</body>
</html>

Leave a Comment