class 10 science chapter 12

ch12 part1

<!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. Jab electric current ek copper wire se pass kiya jata hai, to compass needle mein kya change hota hai?",
options: [
"A. Needle completely stop ho jaati hai",
"B. Needle deflect hoti hai",
"C. Needle melt ho jaati hai",
"D. Needle ki length badh jaati hai"
],
correct: 1,
explanation: "Current-carrying wire ke around <b>magnetic effect</b> produce hota hai. Is magnetic field ke karan nearby compass needle <b>deflect</b> hoti hai."
},

{
question: "2. Oersted ke experiment ne kya prove kiya?",
options: [
"A. Electricity aur magnetism unrelated hain",
"B. Electricity aur magnetism related phenomena hain",
"C. Current sirf heat produce karta hai",
"D. Magnetism sirf permanent magnets mein hota hai"
],
correct: 1,
explanation: "Hans Christian Oersted ne observe kiya ki current-carrying wire ke paas compass needle deflect hoti hai. Isse <b>electricity aur magnetism ke connection</b> ka evidence mila."
},

{
question: "3. Magnetic field kya hota hai?",
options: [
"A. Magnet ke andar ka empty space",
"B. Magnet ke surrounding ka woh region jahan magnetic force detect ki ja sakti hai",
"C. Sirf compass ke andar ka region",
"D. Sirf electric circuit ka region"
],
correct: 1,
explanation: "Magnet ke around jis region mein uski <b>magnetic force detect</b> ki ja sakti hai, use magnetic field kehte hain."
},

{
question: "4. Iron filings ko bar magnet ke around rakhne par pattern kyun banta hai?",
options: [
"A. Iron filings magnetic force ke influence mein align hoti hain",
"B. Iron filings gravity ke karan magnet ke around circle banati hain",
"C. Magnet iron filings ko heat karta hai",
"D. Iron filings electricity produce karti hain"
],
correct: 0,
explanation: "Magnet surrounding region mein magnetic force exert karta hai. Iron filings is force ke influence mein <b>specific pattern mein arrange</b> ho jaati hain."
},

{
question: "5. Magnetic field lines ki direction conventionally outside a bar magnet kahan se kahan hoti hai?",
options: [
"A. South pole → North pole",
"B. North pole → South pole",
"C. Centre → North pole",
"D. Centre → South pole"
],
correct: 1,
explanation: "Bar magnet ke <b>outside</b>, magnetic field lines North pole se emerge hokar South pole mein merge karti hain."
},

{
question: "6. Bar magnet ke andar magnetic field lines ki direction kya hoti hai?",
options: [
"A. North → South",
"B. South → North",
"C. Centre → North",
"D. Centre → South"
],
correct: 1,
explanation: "Magnet ke <b>inside</b>, field lines ki direction South pole se North pole ki taraf hoti hai. Isliye magnetic field lines <b>closed curves</b> hoti hain."
},

{
question: "7. Magnetic field lines ki closeness kya indicate karti hai?",
options: [
"A. Magnet ka colour",
"B. Magnetic field ki relative strength",
"C. Magnet ka temperature",
"D. Electric current ka unit"
],
correct: 1,
explanation: "Jahan field lines <b>zyada crowded ya close</b> hoti hain, wahan magnetic field stronger hota hai aur magnetic force bhi greater hoti hai."
},

{
question: "8. Magnetic field ki nature kya hai?",
options: [
"A. Sirf magnitude hota hai",
"B. Sirf direction hoti hai",
"C. Direction aur magnitude dono hote hain",
"D. Na direction hoti hai na magnitude"
],
correct: 2,
explanation: "Magnetic field ek <b>vector quantity</b> hai, kyunki ismein <b>magnitude aur direction dono</b> hote hain."
},

{
question: "9. Do magnetic field lines ek-doosre ko cross kyun nahi karti hain?",
options: [
"A. Field lines hamesha straight hoti hain",
"B. Crossing point par compass needle ko ek hi time par do directions mein point karna padega",
"C. Field lines sirf magnets ke andar hoti hain",
"D. Iron filings field lines ko destroy kar deti hain"
],
correct: 1,
explanation: "Agar do field lines cross karein, to intersection point par magnetic field ki <b>do directions</b> hongi. Compass needle ek point par simultaneously do directions mein point nahi kar sakti."
},

{
question: "10. Compass needle ka north-seeking pole magnetic field ki direction ko kaise indicate karta hai?",
options: [
"A. Needle field ki opposite direction mein move karti hai",
"B. Needle ka north pole magnetic field ki direction mein point karta hai",
"C. Needle hamesha east direction mein point karti hai",
"D. Needle random direction mein point karti hai"
],
correct: 1,
explanation: "Magnetic field ki direction conventionally woh direction li jaati hai jisme <b>compass needle ka north pole point</b> 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.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.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