class 9 science chapter 6

ch6 part7

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Science Quiz – Newton's First Law of Motion</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;
    margin: 0;
    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;
    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: 65%;
    max-width: 300px;
    border: 1px solid #ccc;
    border-radius: 6px;
  }
</style>
</head>
<body>

<div class="quiz-container">
  <h2>🧠 Science Quiz – Newton's First Law of Motion</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;">
    <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 moving box par person ka forward force friction ke backward force ke exactly equal hai. Box ki motion ka kya hoga?",
    options: [
      "A. Box turant stop ho jaayega",
      "B. Box accelerate karega",
      "C. Box constant velocity se move karta rahega",
      "D. Box ki direction automatically change hogi"
    ],
    correct: 2,
    explanation: "Dono forces equal aur opposite hain, isliye net force zero hai. Newton’s first law ke according box constant velocity se move karta rahega."
  },
  {
    question: "2. Example 6.2 mein box par applied force aur frictional force equal aur opposite hain. Net force kitna hoga?",
    options: [
      "A. Applied force ke equal",
      "B. Frictional force ke equal",
      "C. Zero",
      "D. Double force"
    ],
    correct: 2,
    explanation: "Equal aur opposite forces ek-doosre ko balance karte hain, isliye net force zero hota hai."
  },
  {
    question: "3. Agar koi object constant velocity se move kar raha hai, to us par net force kya hoga?",
    options: [
      "A. Zero",
      "B. Maximum",
      "C. Constant but non-zero",
      "D. Continuously increasing"
    ],
    correct: 0,
    explanation: "Constant velocity ka matlab acceleration zero hai. Newton’s first law ke according acceleration zero hone par net force bhi zero hota hai."
  },
  {
    question: "4. No net force acting on an object ke case mein kaunsi situation possible hai?",
    options: [
      "A. Object rest mein hai aur rest mein hi rahta hai",
      "B. Object ki speed continuously increase hoti hai",
      "C. Object constant acceleration se move karta hai",
      "D. Object ki direction continuously change hoti hai"
    ],
    correct: 0,
    explanation: "Net force zero hone par object agar initially rest mein hai, to woh rest mein hi rahega."
  },
  {
    question: "5. Agar koi object already move kar raha hai aur us par net force zero hai, to kya hoga?",
    options: [
      "A. Woh immediately stop karega",
      "B. Woh constant velocity se move karta rahega",
      "C. Uski velocity continuously increase hogi",
      "D. Uski direction automatically change hogi"
    ],
    correct: 1,
    explanation: "Newton’s first law ke according zero net force mein moving object same constant velocity maintain karta hai."
  },
  {
    question: "6. No net force acting object ke liye kaunsi situation possible nahi hai?",
    options: [
      "A. Object rest mein rahe",
      "B. Object constant velocity se move kare",
      "C. Object constant acceleration se move kare",
      "D. Object zero acceleration ke saath move kare"
    ],
    correct: 2,
    explanation: "Constant non-zero acceleration ke liye net force required hota hai. Zero net force mein acceleration zero hota hai."
  },
  {
    question: "7. Agar object rest mein hai aur us par net force zero hai, to uska position-time graph kaisa hoga?",
    options: [
      "A. Horizontal straight line",
      "B. Sloping straight line",
      "C. Curved line",
      "D. Zig-zag line"
    ],
    correct: 0,
    explanation: "Rest mein object ka position time ke saath change nahi hota, isliye position-time graph horizontal straight line hota hai."
  },
  {
    question: "8. Resting object ka velocity-time graph kaisa hoga?",
    options: [
      "A. Upward sloping line",
      "B. Downward sloping line",
      "C. Time-axis par horizontal line",
      "D. Curved line"
    ],
    correct: 2,
    explanation: "Resting object ki velocity continuously zero hoti hai, isliye velocity-time graph time-axis par horizontal line hota hai."
  },
  {
    question: "9. Constant velocity se moving object ka velocity-time graph kaisa hoga?",
    options: [
      "A. Time-axis ke parallel horizontal straight line",
      "B. Upward sloping straight line",
      "C. Downward sloping straight line",
      "D. Parabolic curve"
    ],
    correct: 0,
    explanation: "Constant velocity mein velocity change nahi hoti, isliye velocity-time graph horizontal straight line hota hai."
  },
  {
    question: "10. Constant velocity se moving object ka position-time graph kaisa hota hai?",
    options: [
      "A. Horizontal line",
      "B. Straight sloping line",
      "C. Circular curve",
      "D. Random curve"
    ],
    correct: 1,
    explanation: "Constant velocity mein object equal time intervals mein equal displacement cover karta hai, isliye position-time graph straight sloping line hota hai."
  }
];

let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";
let quizSubmitted = 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 = `
    <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 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 (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;

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

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

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

  document.getElementById("result").innerHTML = `
    <h3>Your Score: ${score} / ${questions.length}</h3>
    <h3>Percentage: ${percentage}%</h3>
    <p>${score >= 8 ? "Excellent Work! 🎉" : score >= 5 ? "Good Effort! 👍" : "Keep Practising! 📚"}</p>
  `;
}

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

</body>
</html>

Leave a Comment