ch12 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 – Habitat and Its Components</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;
}
#userName {
padding: 10px;
width: 60%;
max-width: 300px;
border: 1px solid #ccc;
border-radius: 6px;
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>🌿 Science Quiz – Habitat and Its Components</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. Habitat kise kehte hain?",
options: [
"A. Sirf animals ke khane ko",
"B. Us place ko jahan koi organism rehta hai",
"C. Sirf jungle ko",
"D. Sirf paani mein rehne wali jagah ko"
],
correct: 1,
explanation: "Habitat woh natural place hota hai jahan koi organism rehta hai aur apni survival ke liye zaroori resources paata hai.<br><br>Example: Pond fish ka habitat hai, aur tree bark par rehne wale kuch insects ke liye tree bark habitat ho sakti hai."
},
{
question: "2. Biotic components kya hote hain?",
options: [
"A. Environment ki non-living cheezein",
"B. Environment ke living organisms",
"C. Sirf rocks aur soil",
"D. Sirf sunlight aur air"
],
correct: 1,
explanation: "Environment mein present living organisms ko biotic components kehte hain. Inmein plants, animals aur microorganisms shamil hain.<br><br>Example: Grass, fish, birds aur bacteria biotic components hain."
},
{
question: "3. Inmein se kaunsa abiotic component hai?",
options: [
"A. Tree",
"B. Fish",
"C. Soil",
"D. Frog"
],
correct: 2,
explanation: "Abiotic components environment ki non-living cheezein hoti hain. Ye organisms ke survival ko affect karti hain.<br><br>Example: Air, water, sunlight, soil aur temperature abiotic components hain."
},
{
question: "4. Fish pond mein survive karne ke liye oxygen kahan se leti hai?",
options: [
"A. Soil se",
"B. Water mein dissolved oxygen se",
"C. Sunlight se directly",
"D. Tree bark se"
],
correct: 1,
explanation: "Fish apni gills ki help se water mein dissolved oxygen absorb karti hai. Oxygen respiration ke liye zaroori hai.<br><br>Example: Agar pond mein dissolved oxygen bahut kam ho jaaye, toh fish ko survive karne mein difficulty ho sakti hai."
},
{
question: "5. Forests kaatne se wild animals ke liye kya problem ho sakti hai?",
options: [
"A. Unka habitat aur food kam ho sakta hai",
"B. Unhe hamesha zyada food milega",
"C. Unki water requirement khatam ho jayegi",
"D. Sabhi animals domestic animals ban jayenge"
],
correct: 0,
explanation: "Deforestation se animals ke living places, food sources aur shelter destroy ho sakte hain. Is wajah se kuch animals human settlements ki taraf move karte hain.<br><br>Example: Forest mein food kam hone par elephants nearby farms mein bananas ya sugarcane khane aa sakte hain."
},
{
question: "6. Wildlife corridors ka main purpose kya hai?",
options: [
"A. Animals ko ek chhote cage mein rakhna",
"B. Forest habitats ko connect karke animals ko safely move karne dena",
"C. Forests mein buildings banana",
"D. Animals ko food dena band karna"
],
correct: 1,
explanation: "Wildlife corridors aise routes hote hain jo different forest areas ko connect karte hain. Inse animals ko move karne aur human settlements ke saath conflict kam karne mein help milti hai.<br><br>Example: Elephant corridor elephants ko ek forest area se doosre forest area tak travel karne mein help kar sakta hai."
},
{
question: "7. Ek pond mein fish, frogs, algae aur water present hain. Inmein se kaun biotic components hain?",
options: [
"A. Sirf water",
"B. Fish, frogs aur algae",
"C. Water aur sunlight",
"D. Sirf soil aur rocks"
],
correct: 1,
explanation: "Fish, frogs aur algae living organisms hain, isliye ye biotic components hain. Water non-living hai, isliye abiotic component hai.<br><br>Example: Pond mein algae food chain ka part ho sakti hai, jabki water fish ko rehne ka medium provide karta hai."
},
{
question: "8. Different organisms ek hi habitat mein kaise coexist kar sakte hain?",
options: [
"A. Sabhi organisms bilkul same food khate hain",
"B. Sabhi organisms sirf daytime mein active hote hain",
"C. Organisms resources ko different ways mein use kar sakte hain aur different times par active ho sakte hain",
"D. Habitat mein abiotic components nahi hote"
],
correct: 2,
explanation: "Ek habitat mein organisms alag resources use kar sakte hain ya different times par active ho sakte hain. Isse unke beech direct competition kam ho sakta hai.<br><br>Example: Ek rodent daytime mein active ho sakta hai, jabki ek snake night mein active ho sakta hai."
},
{
question: "9. Rainfall aur temperature mein changes elephants ke habitat ko kaise affect kar sakte hain?",
options: [
"A. Vegetation aur water availability change ho sakti hai",
"B. Elephants ko oxygen ki zaroorat nahi rehti",
"C. Forests hamesha bade ho jaate hain",
"D. Elephants ko food ki zaroorat khatam ho jaati hai"
],
correct: 0,
explanation: "Rainfall aur temperature vegetation ki growth aur water availability ko affect karte hain. Food aur water ki kami hone par elephants farms ya villages ki taraf move kar sakte hain.<br><br>Example: Drought ke dauraan forest ke waterholes dry ho jaane par elephants water ki search mein human settlements ke paas aa sakte hain."
},
{
question: "10. Organisms ke survival ke liye habitat mein kaun-si conditions important hoti hain?",
options: [
"A. Sirf sunlight",
"B. Sirf food",
"C. Food, water, oxygen, shelter aur suitable physical conditions",
"D. Sirf temperature"
],
correct: 2,
explanation: "Har organism ko survive karne ke liye specific resources aur environmental conditions chahiye. Different organisms ki requirements different ho sakti hain.<br><br>Example: Plants ko sunlight, water, air aur suitable soil chahiye, jabki fish ko water, dissolved oxygen aur food chahiye."
}
];
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 = `
<p><strong>Question ${currentQuestion + 1} of ${questions.length}</strong></p>
<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>
<p>${score === questions.length
? "Excellent! All answers are correct."
: "Keep practicing to improve your score!"}
</p>
`;
}
function saveScore(name, score) {
let scores = JSON.parse(localStorage.getItem("quizScores")) || [];
scores.push({
name: name,
score: 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}/${questions.length} (${s.date})</li>`
).join("");
}
</script>
</body>
</html>