class 10 science chapter 4

ch4 part11

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carbon and Its Compounds - Science 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; }

@media(max-width:600px) {
  body { padding: 10px; }
  .quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>

<body>
<div class="quiz-container">

<h2>🧠 Carbon and Its Compounds – Science 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. Hard water ko detergent use karke check kiya ja sakta hai?",
options: [
"A. Yes, because detergent hard water mein bhi effective rehta hai",
"B. No, detergent water ke saath react nahi karta",
"C. Yes, because detergent water ko red kar deta hai",
"D. No, because detergent sirf oil mein soluble hai"
],
correct: 0,
explanation: "Detergents Ca²⁺ aur Mg²⁺ ions ke saath insoluble precipitate nahi banate, isliye hard water mein bhi effective rehte hain. Isliye detergent ke behaviour se hard water ka idea mil sakta hai."
},

{
question: "2. Clothes ko soap ke saath beat, scrub ya washing machine mein agitate kyun kiya jata hai?",
options: [
"A. Water ko heat karne ke liye",
"B. Soap ko remove karne ke liye",
"C. Soap ko dirt aur oily particles ke contact mein laakar cleaning improve karne ke liye",
"D. Clothes ka colour change karne ke liye"
],
correct: 2,
explanation: "Agitation soap ko dirt ke saath better contact mein laata hai aur micelles ko oily dirt ko suspend/remove karne mein help karta hai."
},

{
question: "3. Ethane (C₂H₆) molecule mein total kitne covalent bonds hote hain?",
options: [
"A. 6",
"B. 7",
"C. 8",
"D. 9"
],
correct: 1,
explanation: "Ethane mein 1 C–C bond + 6 C–H bonds = 7 covalent bonds hote hain."
},

{
question: "4. Butanone mein kaunsa functional group present hota hai?",
options: [
"A. Alcohol",
"B. Aldehyde",
"C. Ketone",
"D. Carboxylic acid"
],
correct: 2,
explanation: "Butanone ek four-carbon compound hai jisme ketone functional group (>C=O) present hota hai."
},

{
question: "5. Cooking ke time vessel ka bottom outside se black ho raha hai. Iska kya meaning hai?",
options: [
"A. Fuel completely burn ho raha hai",
"B. Fuel completely burn nahi ho raha",
"C. Food completely cook nahi hua",
"D. Fuel wet hai"
],
correct: 1,
explanation: "Blackening indicates incomplete combustion. Ismein soot (carbon) form hota hai, jo vessel ke bottom par deposit ho sakta hai."
},

{
question: "6. Homologous series ki main characteristic kya hai?",
options: [
"A. Successive members mein —CH₂— ka difference aur same functional group hota hai",
"B. Sabhi members ka molecular formula same hota hai",
"C. Sabhi compounds mein different functional groups hote hain",
"D. Sabhi compounds sirf carbon se bane hote hain"
],
correct: 0,
explanation: "Homologous series mein same functional group hota hai aur successive members generally —CH₂— unit se differ karte hain. Chemical properties similar hoti hain."
},

{
question: "7. Soap hard water mein scum kyun form karta hai?",
options: [
"A. Soap oxygen ke saath react karta hai",
"B. Soap Ca²⁺ aur Mg²⁺ ions ke saath insoluble substances banata hai",
"C. Soap water ko evaporate karta hai",
"D. Soap hydrogen gas release karta hai"
],
correct: 1,
explanation: "Hard water mein calcium aur magnesium salts hote hain. Soap inke saath react karke insoluble precipitate/scum banata hai."
},

{
question: "8. Hydrogenation kya hai?",
options: [
"A. Saturated hydrocarbons se hydrogen remove karna",
"B. Unsaturated hydrocarbons mein hydrogen add karna",
"C. Carbon ko oxygen mein burn karna",
"D. Water ko hydrogen mein convert karna"
],
correct: 1,
explanation: "Hydrogenation mein unsaturated compounds ke double/triple bonds par hydrogen add karke saturated compounds banaye jate hain. Vegetable oils ki industrial hydrogenation mein nickel catalyst use hota hai."
},

{
question: "9. Inmein se kaunse hydrocarbons addition reactions undergo kar sakte hain?",
options: [
"A. C₂H₆ aur C₃H₈",
"B. C₃H₆ aur C₂H₂",
"C. CH₄ aur C₂H₆",
"D. C₃H₈ aur CH₄"
],
correct: 1,
explanation: "Unsaturated hydrocarbons addition reactions karte hain. C₃H₆ mein double bond aur C₂H₂ mein triple bond hota hai."
},

{
question: "10. Saturated aur unsaturated hydrocarbons ko differentiate karne ke liye kaunsi test useful hai?",
options: [
"A. Bromine water test",
"B. Salt test",
"C. Litmus test only",
"D. Sugar test"
],
correct: 0,
explanation: "Unsaturated hydrocarbons bromine water ko decolourise kar dete hain because they undergo addition reaction, while saturated hydrocarbons normally bromine water ko decolourise nahi karte under ordinary conditions."
}

];

let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";

function startQuiz() {
  userName = document.getElementById("userName").value.trim();

  if (!userName) return alert("Please enter your name.");

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

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

  document.getElementById("result").innerHTML = `
    <h3>Your Score: ${score} / ${questions.length}</h3>
    <p>${score === 10 ? "Excellent! Perfect Score! 🎉" :
       score >= 7 ? "Very Good! Keep Practicing! 👏" :
       score >= 5 ? "Good Attempt! Keep Learning! 👍" :
       "Keep Practicing! You Can Improve! 💪"}</p>
    <button onclick="location.reload()">Try Again</button>
  `;
}

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