ch8 part2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Heredity Quiz – APICAL CLASSES</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>🧠 Heredity Quiz – APICAL CLASSES</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. Heredity ka main role kya hai?",
options: [
"A. Body ko energy dena",
"B. Traits aur characteristics ko reliably inherit karwana",
"C. Food ko digest karna",
"D. Respiration karna"
],
correct: 1,
explanation: "Heredity ke rules decide karte hain ki parents ke <b>traits aur characteristics</b> offspring mein kaise inherit hote hain."
},
{
question: "2. Human child ko genetic material approximately kitna father aur mother se milta hai?",
options: [
"A. Father se zyada",
"B. Mother se zyada",
"C. Dono se practically equal amount",
"D. Sirf mother se"
],
correct: 2,
explanation: "Father aur mother dono child ko <b>practically equal amounts of genetic material</b> contribute karte hain. Isliye har trait ko paternal aur maternal DNA dono influence kar sakte hain."
},
{
question: "3. Mendel ne apne experiments ke liye mainly kis plant ka use kiya?",
options: [
"A. Rose",
"B. Garden pea",
"C. Wheat",
"D. Mango"
],
correct: 1,
explanation: "Gregor Mendel ne <b>garden pea plants</b> par experiments kiye aur different contrasting characters ko study kiya, jaise <b>tall/short</b> aur <b>round/wrinkled seeds</b>."
},
{
question: "4. Mendel ke tall × short pea plants ke F1 generation mein kya result mila?",
options: [
"A. Sabhi plants short the",
"B. Half tall aur half short the",
"C. Sabhi plants medium-height the",
"D. Sabhi plants tall the"
],
correct: 3,
explanation: "Tall plant ko short plant ke saath cross karne par <b>F1 generation ke sabhi plants tall</b> the. Koi medium-height plant nahi tha."
},
{
question: "5. Mendel ke experiment mein F2 generation ke kitne plants short the?",
options: [
"A. 1/2",
"B. 1/4",
"C. 3/4",
"D. 1/10"
],
correct: 1,
explanation: "F1 tall plants ko self-pollination karne par F2 generation mein <b>one-quarter (1/4) plants short</b> aaye. Isse pata chala ki shortness trait F1 mein present tha but expressed nahi hua."
},
{
question: "6. Agar genotype TT ya Tt ho, to pea plant ka appearance kya hoga?",
options: [
"A. Short",
"B. Medium-height",
"C. Tall",
"D. Wrinkled"
],
correct: 2,
explanation: "<b>TT aur Tt dono tall</b> plants banate hain. Sirf <b>tt</b> mein plant short hota hai. Ek single <b>T</b> copy tallness express karne ke liye enough hai."
},
{
question: "7. Mendel ke according, jo trait ek single copy mein bhi express ho jata hai, use kya kaha jata hai?",
options: [
"A. Recessive trait",
"B. Dominant trait",
"C. Hybrid trait",
"D. Mixed trait"
],
correct: 1,
explanation: "Jo trait ek single copy hone par bhi express ho jata hai, woh <b>dominant trait</b> kehlata hai. Example: <b>T = tallness</b>."
},
{
question: "8. Short pea plant ka genotype kya hoga?",
options: [
"A. TT",
"B. Tt",
"C. tt",
"D. TTT"
],
correct: 2,
explanation: "Shortness tabhi express hoti hai jab dono copies <b>t</b> hon. Isliye short plant ka genotype <b>tt</b> hota hai. <b>t</b> recessive trait hai."
},
{
question: "9. Tall plant with round seeds × short plant with wrinkled seeds ke F1 progeny kaise honge?",
options: [
"A. Sabhi short aur wrinkled",
"B. Sabhi tall aur round",
"C. Half tall-round aur half short-wrinkled",
"D. Sabhi tall aur wrinkled"
],
correct: 1,
explanation: "Mendel ke experiment mein <b>tallness aur round seeds dominant traits</b> the. Isliye pure-breeding parents ke cross se F1 generation ke plants <b>tall aur round seeds</b> wale hote hain."
},
{
question: "10. F2 generation mein new combinations kaise appear hote hain?",
options: [
"A. Traits disappear ho jaate hain",
"B. Genes destroy ho jaate hain",
"C. Different traits ke factors recombine hote hain",
"D. Sirf dominant traits inherit hote hain"
],
correct: 2,
explanation: "F2 generation mein factors <b>recombine</b> karte hain, jiski wajah se new combinations mil sakte hain, jaise <b>tall + wrinkled seeds</b> ya <b>short + round seeds</b>. Isse pata chalta hai ki different traits independently inherit ho sakte 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 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>