class 9 science chapter 6

ch6 part4

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Science Quiz – Frictional Force</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; }
.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;
}
.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; }
input[type="text"] {
  padding: 10px;
  width: 65%;
  max-width: 300px;
  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>🧠 Science Quiz – Frictional Force</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. Agar floor par rakhe box ko forward direction mein push kiya jaaye aur box initially move na kare, to iska main reason kya hai?",
  options: [
    "A. Gravitational force",
    "B. Normal force",
    "C. Frictional force",
    "D. Buoyant force"
  ],
  correct: 2,
  explanation: "Friction applied force ke opposite direction mein act karta hai aur initially box ki motion ko oppose karta hai."
},
{
  question: "2. Box ko move karne ke liye applied force ko frictional force ke comparison mein kaisa hona chahiye?",
  options: [
    "A. Friction se smaller",
    "B. Friction ke equal hi hona chahiye",
    "C. Friction se larger",
    "D. Zero hona chahiye"
  ],
  correct: 2,
  explanation: "Box tab move karega jab applied force ka magnitude maximum static friction se larger ho, jisse net force motion ki direction mein act kare."
},
{
  question: "3. Pushed box par frictional force kis direction mein act karta hai?",
  options: [
    "A. Applied force ki same direction mein",
    "B. Motion ya applied force ki opposite direction mein",
    "C. Hamesha upward direction mein",
    "D. Hamesha downward direction mein"
  ],
  correct: 1,
  explanation: "Friction generally object ki relative motion ya motion ki tendency ko oppose karta hai."
},
{
  question: "4. Horizontal floor par rakhe box par gravitational force aur normal force kis direction mein act karte hain?",
  options: [
    "A. Dono upward",
    "B. Dono downward",
    "C. Gravity downward aur normal force upward",
    "D. Gravity upward aur normal force downward"
  ],
  correct: 2,
  explanation: "Weight/gravitational force downward act karta hai, jabki surface ka normal force surface ke perpendicular upward act karta hai."
},
{
  question: "5. Horizontal surface par resting box ke gravitational force aur normal force ke baare mein kaunsa statement correct hai?",
  options: [
    "A. Dono unbalanced hote hain",
    "B. Dono balanced hote hain",
    "C. Sirf normal force act karta hai",
    "D. Sirf gravitational force act karta hai"
  ],
  correct: 1,
  explanation: "Resting box ke case mein downward weight aur upward normal force balance karte hain, isliye vertical direction mein net force zero hota hai."
},
{
  question: "6. Moving box par air bhi frictional force laga sakti hai. Lekin many cases mein ise neglect kyun kiya ja sakta hai?",
  options: [
    "A. Air box par force nahi lagati",
    "B. Air friction ka magnitude bahut small hota hai",
    "C. Air friction hamesha zero hota hai",
    "D. Air friction gravity ke equal hota hai"
  ],
  correct: 1,
  explanation: "Moving box par air resistance act karta hai, lekin many situations mein iska magnitude itna small hota hai ki use neglect kiya ja sakta hai."
},
{
  question: "7. Agar moving box par applied force hata diya jaaye, to box kuch distance travel karne ke baad stop kyun hota hai?",
  options: [
    "A. Normal force use stop karta hai",
    "B. Gravitational force horizontal direction mein act karta hai",
    "C. Friction motion ke opposite direction mein act karta hai",
    "D. Air box ko hamesha accelerate karti hai"
  ],
  correct: 2,
  explanation: "Applied force hatne ke baad friction box ki motion ko oppose karta hai, isliye box slow hokar rest mein aa jaata hai."
},
{
  question: "8. Bicycle ko pedal karna band karne ke baad bicycle kuch distance travel karke ruk jaati hai. Iska main reason kya hai?",
  options: [
    "A. Frictional force",
    "B. Buoyant force",
    "C. Magnetic force",
    "D. Normal force"
  ],
  correct: 0,
  explanation: "Pedalling band hone par bicycle ko forward push nahi milta, jabki friction motion ko oppose karta rehta hai. Isliye bicycle eventually stop ho jaati hai."
},
{
  question: "9. Agar kisi moving object ko friction ke effect ke against continuously moving rakhna ho, to kya karna padega?",
  options: [
    "A. Continuously appropriate force apply karna padega",
    "B. Gravity ko remove karna padega",
    "C. Normal force ko double karna padega",
    "D. Object ka mass zero karna padega"
  ],
  correct: 0,
  explanation: "Friction motion ke opposite act karta hai. Motion ko maintain karne ke liye applied force se friction ko counter karna padta hai."
},
{
  question: "10. Activity 6.1 mein friction ki dependence investigate karne ke liye coins ko kin surfaces par move/test kiya ja sakta hai?",
  options: [
    "A. Sirf water surface par",
    "B. Wooden, cemented, laminated aur polished marble/tiled surfaces par",
    "C. Sirf glass surface par",
    "D. Sirf soil par"
  ],
  correct: 1,
  explanation: "Activity mein different horizontal surfaces use karke dekha jaata hai ki friction surfaces ki nature par depend karta 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";

  showQuestion();
  loadScoreboard();
}

function showQuestion() {
  const q = questions[currentQuestion];
  const container = document.getElementById("questionContainer");

  container.innerHTML = `
    <div class="question">Q${currentQuestion + 1}. ${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() {
  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${index + 1}. ${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";

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

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

function saveScore(name, score) {
  let scores = [];

  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  } catch (e) {
    scores = [];
  }

  scores.push({
    name: name,
    score: score,
    date: new Date().toLocaleString()
  });

  localStorage.setItem("quizScores", JSON.stringify(scores));
}

function loadScoreboard() {
  let scores = [];

  try {
    scores = JSON.parse(localStorage.getItem("quizScores")) || [];
  } catch (e) {
    scores = [];
  }

  scores.sort((a, b) => b.score - a.score);

  document.getElementById("scoreList").innerHTML =
    scores.map(s =>
      `<li>${escapeHTML(s.name)} - ${s.score}/10 (${escapeHTML(s.date)})</li>`
    ).join("");
}
</script>

</body>
</html>

Leave a Comment