class 10 science chapter 12

ch12 part5

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>đź§  Magnetic Effects of Electric Current 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;
}
.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;
}
.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;
}
</style>
</head>

<body>

<div class="quiz-container">

<h2>🧠 Magnetic Effects of Electric Current – Quiz</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. Magnetic field mein current-carrying conductor par kya act karta hai?",
options: [
"A. Gravitational force",
"B. Magnetic force",
"C. Electrostatic force only",
"D. Nuclear force"
],
correct: 1,
explanation: "Jab current-carrying conductor ko magnetic field mein rakha jata hai, to magnetic field conductor par <b>force</b> exert karta hai."
},

{
question: "2. André Marie Ampère ne current-carrying conductor aur magnet ke force ke baare mein kya suggest kiya?",
options: [
"A. Sirf conductor magnet par force lagata hai",
"B. Magnet conductor par equal aur opposite force lagata hai",
"C. Magnet conductor par koi force nahi lagata",
"D. Force sirf current ke zero hone par lagta hai"
],
correct: 1,
explanation: "Ampère ke according, agar current-carrying conductor magnet par force lagata hai, to <b>magnet bhi conductor par equal and opposite force</b> lagata hai."
},

{
question: "3. Current-carrying rod ki direction of force kis cheez ko reverse karne par reverse ho sakti hai?",
options: [
"A. Current ki direction",
"B. Rod ka colour",
"C. Rod ka temperature",
"D. Wire ka material only"
],
correct: 0,
explanation: "Current ki direction reverse karne par conductor par lagne wale <b>force ki direction bhi reverse</b> ho jaati hai."
},

{
question: "4. Agar magnetic field ki direction ko reverse kar diya jaye, to current-carrying conductor par force ki direction par kya effect hoga?",
options: [
"A. Force ki direction reverse ho jayegi",
"B. Force hamesha same rahega",
"C. Force completely disappear ho jayega",
"D. Current ki magnitude automatically double ho jayegi"
],
correct: 0,
explanation: "Force ki direction <b>magnetic field ki direction</b> par depend karti hai. Field ko reverse karne par force ki direction bhi reverse hoti hai."
},

{
question: "5. Current-carrying conductor par magnetic force ki direction kin do factors par depend karti hai?",
options: [
"A. Current aur magnetic field ki direction",
"B. Resistance aur voltage ki direction",
"C. Wire ki length aur colour",
"D. Temperature aur pressure"
],
correct: 0,
explanation: "Magnetic force ki direction <b>current ki direction</b> aur <b>magnetic field ki direction</b>, dono par depend karti hai."
},

{
question: "6. Current-carrying conductor par magnetic force maximum kab hota hai?",
options: [
"A. Jab current aur magnetic field same direction mein hon",
"B. Jab current aur magnetic field opposite direction mein hon",
"C. Jab current magnetic field ke perpendicular ho",
"D. Jab current zero ho"
],
correct: 2,
explanation: "Jab current ki direction magnetic field se <b>90° (right angle)</b> par hoti hai, tab magnetic force maximum hota hai."
},

{
question: "7. Fleming’s Left-Hand Rule mein forefinger kis direction ko represent karta hai?",
options: [
"A. Current ki direction",
"B. Magnetic field ki direction",
"C. Force ki direction",
"D. Resistance ki direction"
],
correct: 1,
explanation: "Fleming’s Left-Hand Rule mein <b>forefinger magnetic field</b> ki direction batata hai."
},

{
question: "8. Fleming’s Left-Hand Rule mein middle finger kis direction ko represent karta hai?",
options: [
"A. Magnetic field",
"B. Current",
"C. Force",
"D. Motion only"
],
correct: 1,
explanation: "Fleming’s Left-Hand Rule mein <b>middle finger current ki direction</b> ko represent karta hai."
},

{
question: "9. Fleming’s Left-Hand Rule mein thumb kya batata hai?",
options: [
"A. Magnetic field ki direction",
"B. Current ki direction",
"C. Conductor par force ya motion ki direction",
"D. Resistance ki direction"
],
correct: 2,
explanation: "Left hand ke three mutually perpendicular fingers mein <b>thumb force ya conductor ke motion ki direction</b> batata hai."
},

{
question: "10. Inmein se kaunsa device current-carrying conductor aur magnetic field ke principle ka use karta hai?",
options: [
"A. Electric motor",
"B. Electric generator",
"C. Loudspeaker",
"D. All of the above"
],
correct: 3,
explanation: "<b>Electric motor, electric generator, loudspeaker, microphone aur measuring instruments</b> mein current-carrying conductors aur magnetic fields ka use hota 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.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 nextQuestion() {

  saveAnswer();

  if (currentQuestion < questions.length - 1) {
    currentQuestion++;
    showQuestion();
  }
}

function prevQuestion() {

  saveAnswer();

  if (currentQuestion > 0) {
    currentQuestion--;
    showQuestion();
  }
}

function saveAnswer() {

  const selected = document.querySelector('input[name="option"]:checked');

  userAnswers[currentQuestion] =
    selected ? parseInt(selected.value) : null;
}

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.question}</div>

      <div class="options">${optsHTML}</div>

      <div class="explanation" style="display:block;">
        ${q.explanation}
      </div>

      <hr>
    `;
  });

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

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

function saveScore(name, score) {

  let scores = JSON.parse(localStorage.getItem("quizScores")) || [];

  scores.push({
    name,
    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