class 9 science chapter 4

ch4 part11

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APICAL CLASSES – Position-Time and Velocity-Time Graphs 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: Position-Time and Velocity-Time Graphs
  </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 position-time graph mein vehicle ki position 40 m par constant rehti hai aur time ke saath change nahi hoti. Vehicle ki motion kya hai?",
    options: [
      "A. Vehicle constant velocity se move kar raha hai",
      "B. Vehicle accelerated motion mein hai",
      "C. Vehicle rest mein hai",
      "D. Vehicle ki velocity continuously increase ho rahi hai"
    ],
    correct: 2,
    explanation: "Position time ke saath change nahi ho rahi, isliye vehicle 40 m position par stationary hai."
  },
  {
    question: "2. Position-time graph mein agar line time-axis ke parallel ho, toh iska kya meaning hota hai?",
    options: [
      "A. Object constant velocity se move kar raha hai",
      "B. Object stationary hai",
      "C. Object ki velocity continuously increase ho rahi hai",
      "D. Object ki acceleration maximum hai"
    ],
    correct: 1,
    explanation: "Time badhne ke baad bhi position same rahe toh object rest mein hota hai. Isliye graph time-axis ke parallel hota hai."
  },
  {
    question: "3. Do objects A aur B ke position-time graphs same time interval ke liye diye gaye hain. B ki line A se zyada steep hai. Kis object ki average velocity ka magnitude greater hoga?",
    options: [
      "A. A",
      "B. B",
      "C. Dono ki same",
      "D. Dono ki zero"
    ],
    correct: 1,
    explanation: "Position-time graph ka slope average velocity batata hai. B ki line steeper hai, isliye B ki velocity ka magnitude greater hai."
  },
  {
    question: "4. Do objects A aur B same time interval mein move karte hain. A ka displacement 30 m aur B ka displacement 60 m hai. Kis object ki average velocity ka magnitude greater hoga?",
    options: [
      "A. A",
      "B. B",
      "C. Dono equal",
      "D. Information insufficient"
    ],
    correct: 1,
    explanation: "Same time interval mein jis object ka displacement greater hai, uski average velocity ka magnitude bhi greater hoga. B ka displacement 60 m hai."
  },
  {
    question: "5. Velocity-time graph kya represent karta hai?",
    options: [
      "A. Position ka change with time",
      "B. Velocity ka change with time",
      "C. Distance ka change with mass",
      "D. Acceleration ka change with distance"
    ],
    correct: 1,
    explanation: "Velocity-time graph object ki velocity aur time ke relationship ko show karta hai."
  },
  {
    question: "6. Ek car straight highway par constant velocity 20 m/s se move kar rahi hai. Uska velocity-time graph kaisa hoga?",
    options: [
      "A. Time-axis ke parallel straight line",
      "B. Vertical straight line",
      "C. Curved line",
      "D. Downward sloping line"
    ],
    correct: 0,
    explanation: "Constant velocity ka matlab time ke saath velocity change nahi ho rahi. Isliye velocity-time graph X-axis ke parallel straight line hota hai."
  },
  {
    question: "7. Constant velocity se move karne wali car ke velocity-time graph mein acceleration kya hogi?",
    options: [
      "A. Zero",
      "B. 5 m/s²",
      "C. 20 m/s²",
      "D. Infinite"
    ],
    correct: 0,
    explanation: "Acceleration velocity ke change ki rate hai. Constant velocity mein velocity change nahi hoti, isliye acceleration 0 hoti hai."
  },
  {
    question: "8. Ek car rest se start karti hai aur velocity time ke saath uniformly increase hoti hai. Uska velocity-time graph ek upward straight line hai. Is motion ke baare mein kya correct hai?",
    options: [
      "A. Constant velocity hai",
      "B. Constant acceleration hai",
      "C. Acceleration zero hai",
      "D. Velocity decreasing hai"
    ],
    correct: 1,
    explanation: "Velocity equal time intervals mein uniformly increase kar rahi hai, isliye acceleration constant hai."
  },
  {
    question: "9. Ek car ki velocity time ke saath uniformly decrease hoti hai aur velocity-time graph downward sloping straight line hai. Acceleration ki direction kaisi hogi?",
    options: [
      "A. Velocity ke same direction",
      "B. Velocity ke opposite direction",
      "C. Hamesha upward",
      "D. Acceleration zero hogi"
    ],
    correct: 1,
    explanation: "Jab velocity ka magnitude decrease hota hai, acceleration velocity ke opposite direction mein hoti hai."
  },
  {
    question: "10. Velocity-time graph mein ek straight line X-axis ke parallel hai aur velocity 15 m/s par constant hai. Is graph se kya conclude hoga?",
    options: [
      "A. Object rest mein hai",
      "B. Object 15 m/s ki constant velocity se move kar raha hai",
      "C. Object ki velocity 15 m/s² se increase ho rahi hai",
      "D. Object ki acceleration continuously increase ho rahi hai"
    ],
    correct: 1,
    explanation: "X-axis ke parallel velocity-time line ka matlab velocity constant hai. Yahan velocity 15 m/s hai aur acceleration zero hai."
  }
];

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