class 9 science chapter 2

ch2 part1

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Science Quiz – Origin of Life and Cell</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; 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>🧠 Science Quiz – Origin of Life and Cell</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. Scientific community ke according life ka origin kis environment mein hua maana jaata hai?",
options: [
"A. Desert",
"B. Water",
"C. Mountains",
"D. Dry land"
],
correct: 1,
explanation: "Scientists ke according life ka origin water mein hua maana jaata hai. Kuch researchers small water pools ko possible place maante hain."
},

{
question: "2. India mein Puga Valley ke hot springs kis jagah par located hain?",
options: [
"A. Rajasthan",
"B. Kerala",
"C. Ladakh",
"D. Assam"
],
correct: 2,
explanation: "Puga Valley Ladakh mein hai, jahan hot springs ka temperature water ke boiling point ke near hota hai."
},

{
question: "3. Puga Valley ke hot springs mein mainly kaun-se organisms paaye jaate hain?",
options: [
"A. Heat-loving bacteria",
"B. Fish",
"C. Fungi only",
"D. Green plants"
],
correct: 0,
explanation: "In hot springs mein mostly thermophiles paaye jaate hain. Thermophiles aise bacteria hain jo high temperature mein survive kar sakte hain."
},

{
question: "4. Thermophiles ka kya meaning hai?",
options: [
"A. Cold-loving organisms",
"B. Water-loving organisms",
"C. Heat-loving organisms",
"D. Light-loving organisms"
],
correct: 2,
explanation: "Thermo ka meaning heat aur philes ka meaning loving hota hai. Isliye thermophiles heat-loving organisms hote hain."
},

{
question: "5. Puga Valley ke hot springs mein scientists ne kya rapidly form hote hue paaya?",
options: [
"A. Sodium chloride",
"B. Calcium carbonate",
"C. Glucose",
"D. Protein"
],
correct: 1,
explanation: "Birbal Sahni Institute of Palaeosciences ke scientists ne hot springs ke around calcium carbonate deposits rapidly form hote hue paaye."
},

{
question: "6. Calcium carbonate deposits ne early organic molecules ko kis cheez se protect karne mein help ki hogi?",
options: [
"A. Harmful radiation aur extreme conditions",
"B. Oxygen only",
"C. Rainwater only",
"D. Sunlight completely"
],
correct: 0,
explanation: "Calcium carbonate deposits ne early organic molecules ko harmful radiation aur extreme environmental conditions se protection di hogi."
},

{
question: "7. Living organisms mein life ki fundamental unit kya hai?",
options: [
"A. Tissue",
"B. Organ",
"C. Cell",
"D. Organ system"
],
correct: 2,
explanation: "Cell structure aur function ki fundamental unit hai. Har living organism cells se bana hota hai."
},

{
question: "8. Bacteria aur yeast kis type ke organisms ke examples hain?",
options: [
"A. Multicellular",
"B. Unicellular",
"C. Non-cellular",
"D. Organ-level organisms"
],
correct: 1,
explanation: "Bacteria aur yeast mein sirf ek cell hota hai, isliye unhe unicellular organisms kehte hain."
},

{
question: "9. Similar cells jo similar functions perform karte hain, unka group kya kehlata hai?",
options: [
"A. Organ",
"B. Tissue",
"C. Organ system",
"D. Organism"
],
correct: 1,
explanation: "Similar cells jab similar functions perform karte hue group banate hain, toh us group ko tissue kehte hain."
},

{
question: "10. Nasal pores, nasal cavity, trachea aur lungs milkar kya form karte hain?",
options: [
"A. Digestive system",
"B. Circulatory system",
"C. Respiratory system",
"D. Nervous system"
],
correct: 2,
explanation: "Nasal pores, nasal cavity, trachea aur lungs milkar respiratory system banate hain, jo breathing mein important role play karta hai."
}

];

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