ch13 part1
<!DOCTYPE html>
<html lang="en">
<head>
<title>🌱 Ecosystem – 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; }
.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>🌱 Ecosystem – Class 10 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. Ecosystem kya hota hai?",
options: [
"A. Sirf living organisms ka group",
"B. Sirf non-living things ka group",
"C. Living organisms aur non-living components ke interaction ka system",
"D. Sirf plants aur animals ka group"
],
correct: 2,
explanation: "Ecosystem mein biotic (living) aur abiotic (non-living) components ek-doosre ke saath interact karte hain."
},
{
question: "2. Ecosystem ke biotic components mein kya include hota hai?",
options: [
"A. Temperature aur rainfall",
"B. Soil aur minerals",
"C. Plants, animals aur microorganisms",
"D. Wind aur water"
],
correct: 2,
explanation: "Biotic components living organisms hote hain, jaise plants, animals, microorganisms aur human beings."
},
{
question: "3. Inmein se kaunsa abiotic component hai?",
options: [
"A. Grass",
"B. Frog",
"C. Bacteria",
"D. Temperature"
],
correct: 3,
explanation: "Abiotic components non-living factors hote hain, jaise temperature, rainfall, wind, soil aur minerals."
},
{
question: "4. Garden ko ecosystem kyun kaha ja sakta hai?",
options: [
"A. Garden mein sirf plants hote hain",
"B. Garden mein living organisms aur physical surroundings interact karte hain",
"C. Garden hamesha natural hota hai",
"D. Garden mein sirf animals hote hain"
],
correct: 1,
explanation: "Garden mein plants, insects, frogs, birds etc. living components hote hain aur soil, temperature, water etc. abiotic components. Ye sab interact karte hain."
},
{
question: "5. Inmein se kaunsa natural ecosystem ka example hai?",
options: [
"A. Crop-field",
"B. Garden",
"C. Forest",
"D. Aquarium"
],
correct: 2,
explanation: "Forest, pond aur lake natural ecosystems ke examples hain. Garden aur crop-field human-made ecosystems hain."
},
{
question: "6. Producers kise kaha jata hai?",
options: [
"A. Jo doosre organisms ko consume karte hain",
"B. Jo dead organisms ko decompose karte hain",
"C. Jo inorganic substances se apna food banate hain",
"D. Jo sirf animals ko eat karte hain"
],
correct: 2,
explanation: "Green plants aur kuch bacteria photosynthesis ke through sunlight aur chlorophyll ki presence mein food banate hain. Isliye ye producers kehlate hain."
},
{
question: "7. Consumers ke baare mein kaunsa statement correct hai?",
options: [
"A. Consumers apna food photosynthesis se banate hain",
"B. Consumers producers par directly ya indirectly depend karte hain",
"C. Consumers sirf plants hote hain",
"D. Consumers dead matter ko inorganic substances mein convert karte hain"
],
correct: 1,
explanation: "Consumers food ke liye producers ya other consumers par depend karte hain. Consumers mein herbivores, carnivores, omnivores aur parasites include hote hain."
},
{
question: "8. Cow, lion aur human being respectively kis category ke consumers hain?",
options: [
"A. Carnivore, herbivore, parasite",
"B. Herbivore, carnivore, omnivore",
"C. Omnivore, herbivore, carnivore",
"D. Parasite, carnivore, herbivore"
],
correct: 1,
explanation: "Cow plants khati hai, isliye herbivore; lion other animals khata hai, isliye carnivore; human beings plant aur animal dono foods consume kar sakte hain, isliye omnivore."
},
{
question: "9. Decomposers ka main function kya hai?",
options: [
"A. Sunlight ko absorb karna",
"B. Food chain ko start karna",
"C. Dead organisms aur waste products ko break down karna",
"D. Sirf oxygen produce karna"
],
correct: 2,
explanation: "Bacteria aur fungi decomposers hain. Ye dead remains aur waste ko break down karke complex organic substances ko simple inorganic substances mein convert karte hain."
},
{
question: "10. Agar ecosystem mein decomposers na hon, to kya hoga?",
options: [
"A. Dead plants aur animals accumulate honge",
"B. Soil mein nutrients ka natural replenishment ruk jayega",
"C. Waste materials properly break down nahi honge",
"D. Upar ke sabhi"
],
correct: 3,
explanation: "Decomposers dead organisms aur waste ko break down karke nutrients ko soil mein return karte hain. Unke absence mein garbage aur dead remains accumulate honge aur nutrients ka natural recycling disturb ho jayega."
}
];
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;">
${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>