ch9part4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Light – Reflection and Spherical Mirrors 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;
margin: 0;
}
.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;
line-height: 1.5;
}
.options label:hover {
background: #f0f0f0;
}
.options input {
margin-right: 8px;
}
.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;
overflow-wrap: anywhere;
}
#scoreboard h3 {
text-align: center;
}
ol {
padding-left: 20px;
}
#result {
text-align: center;
margin-top: 20px;
}
@media(max-width:600px) {
body { padding: 10px; }
.quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>🧠 Light – Reflection and Spherical Mirrors 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"></div>
<div id="scoreboard">
<h3>🏆 Scoreboard</h3>
<ol id="scoreList"></ol>
</div>
</div>
</div>
<script>
const questions = [
{
question: "1. Torches aur vehicle headlights mein concave mirrors ka use kyun kiya jata hai?",
options: [
"A. Diminished image banane ke liye",
"B. Powerful parallel beam of light obtain karne ke liye",
"C. Light ko absorb karne ke liye",
"D. Light ko completely stop karne ke liye"
],
correct: 1,
explanation: "Concave mirror light ko reflect karke powerful parallel beam bana sakta hai. Isliye iska use torches, search-lights aur vehicle headlights mein hota hai."
},
{
question: "2. Shaving mirror ke roop mein kaunsa mirror use kiya jata hai?",
options: [
"A. Plane mirror",
"B. Convex mirror",
"C. Concave mirror",
"D. Glass slab"
],
correct: 2,
explanation: "Concave mirror object ko suitable position par rakhne par erect aur enlarged image bana sakta hai. Isliye shaving ke time face ko magnified dekhne ke liye iska use hota hai."
},
{
question: "3. Dentists teeth ka enlarged image dekhne ke liye kaunsa mirror use karte hain?",
options: [
"A. Concave mirror",
"B. Convex mirror",
"C. Plane mirror",
"D. None"
],
correct: 0,
explanation: "Concave mirror enlarged image bana sakta hai, isliye dentists teeth ko large image ke form mein clearly observe karne ke liye concave mirror use karte hain."
},
{
question: "4. Solar furnaces mein large concave mirrors ka use kyun hota hai?",
options: [
"A. Sunlight ko scatter karne ke liye",
"B. Sunlight ko concentrate karke heat produce karne ke liye",
"C. Sunlight ko absorb karne ke liye",
"D. Image ko diminish karne ke liye"
],
correct: 1,
explanation: "Large concave mirror sunlight ko ek point ya region par concentrate karta hai. Isse high heat produce hoti hai, jo solar furnaces mein useful hai."
},
{
question: "5. Convex mirror mein object infinity par ho to image kahan banti hai?",
options: [
"A. Pole P par",
"B. Focus F ke paas, mirror ke behind",
"C. Centre C par",
"D. Mirror ke front mein"
],
correct: 1,
explanation: "Infinity par object se aane wali parallel rays convex mirror se reflect hone ke baad focus F se aati hui appear hoti hain. Image mirror ke behind focus F ke paas banti hai."
},
{
question: "6. Convex mirror mein object infinity par ho to image ki nature kya hogi?",
options: [
"A. Real, inverted aur enlarged",
"B. Virtual, erect aur highly diminished",
"C. Real aur erect",
"D. Virtual aur enlarged"
],
correct: 1,
explanation: "Infinity par object ke liye convex mirror highly diminished, point-sized, virtual aur erect image banata hai."
},
{
question: "7. Convex mirror finite distance par object ki image generally kaisi hoti hai?",
options: [
"A. Virtual, erect aur diminished",
"B. Real, inverted aur enlarged",
"C. Real, erect aur same size",
"D. Virtual aur enlarged"
],
correct: 0,
explanation: "Convex mirror mein finite distance par object ki image P aur F ke beech, mirror ke behind banti hai. Image virtual, erect aur diminished hoti hai."
},
{
question: "8. Vehicles mein rear-view mirror ke liye convex mirror ko prefer kyun kiya jata hai?",
options: [
"A. Ye always enlarged image deta hai",
"B. Ye wider field of view deta hai",
"C. Ye real image banata hai",
"D. Ye light ko absorb karta hai"
],
correct: 1,
explanation: "Convex mirror outward curved hota hai, isliye iska field of view wider hota hai. Driver vehicle ke behind larger area of traffic dekh sakta hai."
},
{
question: "9. Kaunsa mirror erect aur enlarged image de sakta hai?",
options: [
"A. Convex mirror",
"B. Plane mirror",
"C. Concave mirror",
"D. None"
],
correct: 2,
explanation: "Concave mirror mein agar object Pole P aur Focus F ke beech ho, to image virtual, erect aur enlarged hoti hai."
},
{
question: "10. Spherical mirror ka radius of curvature 20 cm hai. Uski focal length kitni hogi?",
options: [
"A. 5 cm",
"B. 10 cm",
"C. 20 cm",
"D. 40 cm"
],
correct: 1,
explanation: "Spherical mirror ke liye R = 2f. Given R = 20 cm. Therefore, f = R/2 = 20/2 = 10 cm. Isliye focal length 10 cm hogi."
}
];
let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";
function startQuiz() {
userName = document.getElementById("userName").value.trim();
if (!userName) {
alert("Please enter your name.");
return;
}
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();
const unanswered = userAnswers.filter(
a => a === null || a === undefined
).length;
if (unanswered > 0) {
if (!confirm(`You have ${unanswered} unanswered question(s). Do you still want to submit?`)) {
return;
}
}
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];
let optsHTML = q.options.map((opt, i) => {
let cls = "";
if (i === q.correct) {
cls = "correct";
}
if (selected === i && selected !== q.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>
<h3>${score >= 8 ? "Excellent Work! 🎉" : score >= 5 ? "Good Effort! 👍" : "Keep Practicing! 📚"}</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 escapeHTML(value) {
return String(value).replace(/[&<>"']/g, char => ({
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
})[char]);
}
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>${escapeHTML(s.name)} - ${s.score}/10 (${escapeHTML(s.date)})</li>`
).join("");
}
</script>
</body>
</html>