class 9 science chapter 4

ch4 part10

<!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 Graph 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: 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: 20px; }
button {
  background-color: #2a5298;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  margin: 5px;
}
button:hover { background-color: #1e3c72; }
input[type="text"] {
  padding: 11px;
  width: 95%;
  max-width: 350px;
  border: 1px solid #aaa;
  border-radius: 6px;
  margin: 10px 0;
}
#scoreboard {
  margin-top: 25px;
  background: #eef3f7;
  padding: 15px;
  border-radius: 8px;
}
#scoreboard h3 { text-align: center; }
ol { padding-left: 25px; }
.progress {
  text-align: center;
  color: #555;
  margin-bottom: 15px;
  font-weight: bold;
}
#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>🧠 APICAL CLASSES</h2>
  <h3 style="text-align:center;color:#2a5298;">
    Position-Time Graph Quiz
  </h3>

  <div id="nameSection">
    <p><strong>Enter your name to start:</strong></p>
    <input type="text" id="userName" placeholder="Your Name">
    <br>
    <button onclick="startQuiz()">Start Quiz</button>
  </div>

  <div id="quizSection" style="display:none;">
    <div class="progress" id="progress"></div>
    <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 Quiz</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 vehicle rest se start karta hai aur uski positions 0 s par 0 m, 2 s par 1 m, 4 s par 4 m, 6 s par 9 m, 8 s par 16 m, 10 s par 25 m aur 12 s par 36 m hain. In points ko position-time graph par plot karne par graph kaisa hoga?",
    options: [
      "A. Straight line",
      "B. Curved line",
      "C. Horizontal line",
      "D. Vertical line"
    ],
    correct: 1,
    explanation: "Equal time intervals mein position increase hone ki amount same nahi hai. Isliye points <b>straight line par nahi</b>, balki curve par aate hain."
  },
  {
    question: "2. Position-time graph mein agar graph ek straight line ho, toh object ke motion ke baare mein kya pata chalta hai?",
    options: [
      "A. Velocity constant hai",
      "B. Velocity continuously increase ho rahi hai",
      "C. Object rest mein hai",
      "D. Acceleration hamesha increasing hai"
    ],
    correct: 0,
    explanation: "Straight-line position-time graph ka <b>slope constant</b> hota hai. Isliye object constant velocity se move karta hai."
  },
  {
    question: "3. Position-time graph mein agar graph curved ho, toh generally object ke motion ko kaise describe kiya jaata hai?",
    options: [
      "A. Constant velocity motion",
      "B. Accelerated motion",
      "C. Rest only",
      "D. Zero displacement motion"
    ],
    correct: 1,
    explanation: "Curved position-time graph ka slope change hota rehta hai. Iska matlab velocity constant nahi hai, yani object generally <b>accelerated motion</b> mein hai."
  },
  {
    question: "4. Ek position-time graph mein object 2–3 s ke interval mein 20 m displacement aur 5–6 s ke interval mein bhi 20 m displacement karta hai. Equal time intervals mein equal displacement hone se kya indicate hota hai?",
    options: [
      "A. Velocity ka magnitude constant hai",
      "B. Velocity zero hai",
      "C. Velocity continuously decrease ho rahi hai",
      "D. Object directionless hai"
    ],
    correct: 0,
    explanation: "Equal time intervals mein equal displacement ka magnitude <b>constant velocity</b> ko indicate karta hai."
  },
  {
    question: "5. Ek position-time graph mein 4–6 s ke interval mein displacement 5 m hai aur 10–12 s ke interval mein displacement 15 m hai. Dono intervals equal duration ke hain. Isse kya conclude hoga?",
    options: [
      "A. Velocity ka magnitude decrease ho raha hai",
      "B. Velocity ka magnitude increase ho raha hai",
      "C. Velocity constant hai",
      "D. Object rest mein hai"
    ],
    correct: 1,
    explanation: "Dono time intervals 2 s ke hain, lekin later interval mein displacement zyada hai. Isliye <b>velocity ka magnitude increase</b> ho raha hai."
  },
  {
    question: "6. Position-time graph se kisi particular instant par object ki kaunsi information directly obtain ki ja sakti hai?",
    options: [
      "A. Object ka mass",
      "B. Object ki position",
      "C. Object ka temperature",
      "D. Object ka volume"
    ],
    correct: 1,
    explanation: "Position-time graph directly batata hai ki <b>given time par object kis position par hai</b>."
  },
  {
    question: "7. Position-time graph mein do points A aur B ke corresponding positions s₁ = 40 m aur s₂ = 80 m hain. Unke corresponding times t₁ = 2 s aur t₂ = 4 s hain. A se B ke beech average velocity ka magnitude kya hoga?",
    options: [
      "A. 10 m/s",
      "B. 20 m/s",
      "C. 40 m/s",
      "D. 60 m/s"
    ],
    correct: 1,
    explanation: "Average velocity = Change in position ÷ Change in time = (80 − 40) ÷ (4 − 2) = 40 ÷ 2 = <b>20 m/s</b>."
  },
  {
    question: "8. Position-time graph mein line AB ka slope kis physical quantity ke baare mein information deta hai?",
    options: [
      "A. Mass",
      "B. Average velocity",
      "C. Force",
      "D. Temperature"
    ],
    correct: 1,
    explanation: "Position-time graph ka slope = Change in position ÷ Change in time, jo <b>average velocity</b> ko represent karta hai."
  },
  {
    question: "9. Position-time graph mein line AB ke liye BC = 40 m aur CA = 2 s hai. Graph ki slope aur average velocity ka magnitude kya hoga?",
    options: [
      "A. 10 m/s",
      "B. 20 m/s",
      "C. 40 m/s",
      "D. 80 m/s"
    ],
    correct: 1,
    explanation: "Slope = BC ÷ CA = 40 ÷ 2 = <b>20 m/s</b>. Position-time graph mein yahi average velocity ka magnitude deta hai."
  },
  {
    question: "10. Position-time graph ka slope physically kya represent karta hai?",
    options: [
      "A. X-axis ki quantity ke change ke respect mein Y-axis ki quantity ke change ki rate",
      "B. Sirf total distance",
      "C. Object ka mass per unit time",
      "D. Sirf acceleration"
    ],
    correct: 0,
    explanation: "Graph ka slope batata hai ki <b>Y-axis wali physical quantity X-axis wali quantity ke respect mein kitni rapidly change ho rahi hai</b>. Position-time graph mein yeh average velocity deta hai."
  }
];

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);
  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 answer all questions before submitting. 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");
  let reviewHTML = "";

  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}
        ${i === correct ? " ✓ Correct Answer" : ""}
        ${selected === i && selected !== correct ? " ✗ Your Answer" : ""}
      </label>`;
    }).join("");

    reviewHTML += `
      <div class="question">${q.question}</div>
      <div class="options">${optsHTML}</div>
      <div class="explanation">${q.explanation}</div>
      <hr>
    `;
  });

  container.innerHTML = reviewHTML;

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

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

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

function escapeHTML(value) {
  return value.replace(/[&<>"']/g, char => ({
    "&": "&amp;",
    "<": "&lt;",
    ">": "&gt;",
    '"': "&quot;",
    "'": "&#039;"
  })[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(s.name)} - ${s.score}/${questions.length} (${escapeHTML(s.date)})</li>`
  ).join("");
}
</script>

</body>
</html>

Leave a Comment