ch4 part6
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>APICAL CLASSES - Motion 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: 20px;
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: 15px 0; line-height: 1.6; }
.options label {
display: block;
margin: 8px 0;
padding: 12px;
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: 12px;
margin-top: 10px;
border-left: 5px solid #2a5298;
border-radius: 5px;
line-height: 1.6;
}
.controls { text-align: center; margin-top: 20px; }
button {
background-color: #2a5298;
color: white;
border: none;
padding: 11px 22px;
border-radius: 6px;
cursor: pointer;
margin: 5px;
}
button:hover { background-color: #1e3c72; }
input[type="text"] {
padding: 11px;
width: 95%;
max-width: 350px;
border: 1px solid #aaa;
border-radius: 6px;
margin: 10px 0;
}
#scoreboard {
margin-top: 25px;
background: #eef3f7;
padding: 15px;
border-radius: 8px;
}
#scoreboard h3 { text-align: center; }
#scoreList { padding-left: 25px; }
#result { text-align: center; margin-top: 20px; }
.progress {
text-align: center;
color: #555;
margin-bottom: 15px;
font-weight: bold;
}
@media(max-width:600px) {
body { padding: 10px; }
.quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>🧠 APICAL CLASSES</h2>
<h3 style="text-align:center;color:#2a5298;">
Distance, Displacement, Average Speed & Velocity Quiz
</h3>
<div id="nameSection">
<p><strong>Enter your name to start:</strong></p>
<input type="text" id="userName" placeholder="Your Name">
<br>
<button onclick="startQuiz()">Start Quiz</button>
</div>
<div id="quizSection" style="display:none;">
<div class="progress" id="progress"></div>
<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 Quiz</button>
</div>
<div id="result"></div>
<div id="scoreboard">
<h3>🏆 Scoreboard</h3>
<ol id="scoreList"></ol>
</div>
</div>
</div>
<script>
const questions = [
{
question: "1. Sarang ek swimming pool mein 50 m distance ka ek end se doosre end tak jaata hai aur phir wapas starting point par aata hai. Agar total time 50 s hai, toh uski total distance travelled kitni hogi?",
options: ["A. 0 m", "B. 25 m", "C. 50 m", "D. 100 m"],
correct: 3,
explanation: "Sarang 50 m aage aur 50 m wapas swim karta hai. Total distance = 50 + 50 = <b>100 m</b>."
},
{
question: "2. Sarang 50 m aage jaakar same starting point par wapas aata hai. 50 s ke complete motion ke baad uska displacement kya hoga?",
options: ["A. 100 m", "B. 50 m", "C. 25 m", "D. 0 m"],
correct: 3,
explanation: "Initial aur final position same hai, isliye net displacement <b>0 m</b> hai."
},
{
question: "3. Sarang 100 m total distance 50 s mein cover karta hai. Uski average speed kya hogi?",
options: ["A. 0.5 m/s", "B. 1 m/s", "C. 2 m/s", "D. 50 m/s"],
correct: 2,
explanation: "Average speed = Total distance ÷ Time = 100 ÷ 50 = <b>2 m/s</b>."
},
{
question: "4. Sarang ka displacement 0 m hai aur total time 50 s hai. Uski average velocity kya hogi?",
options: ["A. 0 m/s", "B. 1 m/s", "C. 2 m/s", "D. 50 m/s"],
correct: 0,
explanation: "Average velocity = Displacement ÷ Time = 0 ÷ 50 = <b>0 m/s</b>."
},
{
question: "5. Sarang ke complete swimming motion mein average speed aur average velocity ke values different kyun hain?",
options: [
"A. Kyunki speed direction ke saath calculate hoti hai",
"B. Kyunki velocity total distance se calculate hoti hai",
"C. Kyunki Sarang starting point par wapas aa gaya, isliye displacement zero ho gaya",
"D. Kyunki time interval zero tha"
],
correct: 2,
explanation: "Sarang ne distance travel ki, isliye average speed non-zero hai. Lekin starting point par wapas aane ke kaaran displacement <b>zero</b> hai, isliye average velocity zero hai."
},
{
question: "6. Ek object ki average velocity 20 seconds ke large time interval ke liye 5 m/s hai. Kya uski velocity kisi particular instant par bhi exactly 5 m/s hona zaroori hai?",
options: [
"A. Haan, hamesha",
"B. Nahi, zaroori nahi",
"C. Sirf circular motion mein",
"D. Sirf rest mein"
],
correct: 1,
explanation: "Large time interval ki <b>average velocity</b> aur kisi particular instant ki velocity different ho sakti hain."
},
{
question: "7. Kisi particular instant par object ki velocity ko kya kaha jaata hai?",
options: [
"A. Average speed",
"B. Average velocity",
"C. Instantaneous velocity",
"D. Total displacement"
],
correct: 2,
explanation: "Kisi specific instant par object ki velocity ko <b>instantaneous velocity</b> kehte hain."
},
{
question: "8. Jab average velocity calculate karne ka time interval progressively smaller hota jaata hai aur infinitesimally small ho jaata hai, toh average velocity kis quantity ke paas approach karti hai?",
options: [
"A. Total distance",
"B. Instantaneous velocity",
"C. Average speed",
"D. Displacement"
],
correct: 1,
explanation: "Time interval ko bahut chhota karne par average velocity <b>instantaneous velocity</b> ke paas approach karti hai."
},
{
question: "9. Moving vehicle ka speedometer kisi particular instant par kya batata hai?",
options: [
"A. Total distance travelled",
"B. Average velocity only",
"C. Instantaneous speed ke approximately equal value",
"D. Total displacement"
],
correct: 2,
explanation: "Speedometer ki reading approximately us instant ki <b>speed</b>, yani instantaneous velocity ke magnitude, ke equal hoti hai."
},
{
question: "10. Vehicle ke speedometer ki reading kisi instant par 60 km/h hai aur tyres jis direction mein point kar rahe hain, wahi vehicle ki motion direction hai. Is information se kya determine kiya ja sakta hai?",
options: [
"A. Sirf total distance",
"B. Instantaneous velocity ka magnitude aur direction",
"C. Sirf total displacement",
"D. Sirf time interval"
],
correct: 1,
explanation: "Speedometer approximately <b>velocity ka magnitude</b> batata hai, aur tyres ki direction <b>velocity ki direction</b> batati hai. Dono milkar instantaneous velocity describe karte hain."
}
];
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";
userAnswers = new Array(questions.length).fill(null);
showQuestion();
loadScoreboard();
}
function showQuestion() {
const q = questions[currentQuestion];
const container = document.getElementById("questionContainer");
document.getElementById("progress").textContent =
"Question " + (currentQuestion + 1) + " of " + questions.length;
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>
`;
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.findIndex(answer => answer === null);
if (unanswered !== -1) {
alert("Please answer all questions before submitting. Question " + (unanswered + 1) + " is unanswered.");
currentQuestion = unanswered;
showQuestion();
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");
let reviewHTML = "";
questions.forEach((q, index) => {
const selected = userAnswers[index];
const correct = q.correct;
const 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}
${i === correct ? " ✓ Correct Answer" : ""}
${selected === i && selected !== correct ? " ✗ Your Answer" : ""}
</label>`;
}).join("");
reviewHTML += `
<div class="question">${q.question}</div>
<div class="options">${optsHTML}</div>
<div class="explanation">${q.explanation}</div>
<hr>
`;
});
container.innerHTML = reviewHTML;
document.querySelector(".controls").style.display = "none";
document.getElementById("progress").style.display = "none";
const percentage = (score / questions.length) * 100;
document.getElementById("result").innerHTML = `
<h2>Quiz Completed!</h2>
<h3>Student: ${escapeHTML(userName)}</h3>
<h3>Your Score: ${score} / ${questions.length}</h3>
<h3>Percentage: ${percentage}%</h3>
<button onclick="location.reload()">Try Again</button>
`;
}
function escapeHTML(value) {
return value.replace(/[&<>"']/g, char => ({
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
})[char]);
}
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>${escapeHTML(s.name)} - ${s.score}/${questions.length} (${escapeHTML(s.date)})</li>`
).join("");
}
</script>
</body>
</html>