class 10 science chapter 8

ch8 part1

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

<title>🧠 Reproduction and Variations 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;
}
.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;
}
</style>
</head>

<body>

<div class="quiz-container">

<h2>🧠 Reproduction and Variations 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. Reproduction ke through new individuals kaise hote hain?",
options: [
"A. Completely different",
"B. Similar but subtly different",
"C. Always exactly identical",
"D. Completely unrelated"
],
correct: 1,
explanation: "Reproductive processes se new individuals generally <b>similar</b> hote hain, lekin unmein kuch <b>small variations</b> bhi ho sakti hain."
},

{
question: "2. Asexual reproduction mein variations ka main source kya ho sakta hai?",
options: [
"A. Small inaccuracies in DNA copying",
"B. Only environmental temperature",
"C. Only food",
"D. Only respiration"
],
correct: 0,
explanation: "Asexual reproduction mein DNA copying ke dauran <b>small inaccuracies</b> ho sakti hain, jisse minor variations arise hoti hain."
},

{
question: "3. Sexual reproduction ka variation par kya effect hota hai?",
options: [
"A. Variations completely stop ho jaati hain",
"B. Greater diversity generate hoti hai",
"C. Sirf identical individuals bante hain",
"D. DNA copying nahi hoti"
],
correct: 1,
explanation: "Sexual reproduction mein different individuals ke genetic material combine hote hain, isliye <b>greater diversity</b> generate ho sakti hai."
},

{
question: "4. Sugarcane ke field mein individual plants ke beech generally kya observe kiya jaata hai?",
options: [
"A. Very large variations",
"B. Very little variation",
"C. No DNA",
"D. Different species"
],
correct: 1,
explanation: "Sugarcane mein generally <b>very little variation</b> observe hoti hai, especially compared with many sexually reproducing animals."
},

{
question: "5. Inheritance previous generation se next generation ko kya provide karta hai?",
options: [
"A. Sirf food",
"B. Common basic body design aur subtle changes",
"C. Sirf water",
"D. Sirf hormones"
],
correct: 1,
explanation: "Inheritance next generation ko <b>common basic body design</b> ke saath kuch subtle changes bhi provide karta hai."
},

{
question: "6. Agar ek bacterium divide hota hai aur resulting two bacteria phir divide hote hain, to four bacteria mein generally kya hoga?",
options: [
"A. Bahut large differences",
"B. Very similar individuals with minor differences",
"C. Completely different species",
"D. No variation at all"
],
correct: 1,
explanation: "Asexual reproduction mein DNA copying ki small inaccuracies ki wajah se <b>minor differences</b> ho sakte hain, lekin individuals generally very similar rahenge."
},

{
question: "7. Second generation mein variations kis source se aa sakti hain?",
options: [
"A. Sirf inherited differences",
"B. Sirf newly created differences",
"C. Inherited differences aur newly created differences dono",
"D. Sirf environmental changes"
],
correct: 2,
explanation: "Second generation ko first generation se <b>inherited differences</b> milte hain aur reproduction ke dauran <b>new differences</b> bhi create ho sakte hain."
},

{
question: "8. Kya species mein present sabhi variations ke survival chances equal hote hain?",
options: [
"A. Haan, always equal",
"B. Nahi, variation ki nature aur environment par depend karta hai",
"C. Sirf sexual reproduction mein equal hote hain",
"D. Sirf plants mein equal hote hain"
],
correct: 1,
explanation: "Different variations environment mein different effects produce kar sakti hain. Isliye sabhi variations ke <b>survival chances equal nahi hote</b>."
},

{
question: "9. Agar asexual reproducing species ki population mein Trait A 10% aur Trait B 60% individuals mein present hai, to kaunsa trait likely earlier arise hua hoga?",
options: [
"A. Trait A",
"B. Trait B",
"C. Dono exactly same time",
"D. Determine nahi kiya ja sakta"
],
correct: 1,
explanation: "Asexual reproduction mein agar variation gradually accumulate ho rahi hai, to <b>60% population mein present Trait B</b> likely earlier arise hua hoga, kyunki usse spread hone ke liye zyada generations ka time mila hoga."
},

{
question: "10. Creation of variations species ke survival mein kaise help kar sakti hai?",
options: [
"A. Changing environment mein kuch individuals ke survive karne ka chance badha sakti hai",
"B. Sabhi organisms ko identical bana deti hai",
"C. Reproduction ko completely stop kar deti hai",
"D. DNA copying ko prevent karti hai"
],
correct: 0,
explanation: "Environment change hone par kuch <b>useful variations</b> individuals ko survive karne mein help kar sakti hain. Is tarah variations species ke long-term survival ko support kar sakti hain."
}

];

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 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