ch6 part17
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Newton's Laws of Motion 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;
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;
}
.subtitle {
text-align: center;
color: #555;
font-weight: bold;
}
.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;
display: none;
}
.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;
font-size: 15px;
}
button:hover {
background-color: #1e3c72;
}
#scoreboard {
margin-top: 25px;
background: #eef3f7;
padding: 15px;
border-radius: 8px;
}
#scoreboard h3 {
text-align: center;
}
ol {
padding-left: 25px;
}
#userName {
padding: 11px;
width: 65%;
max-width: 300px;
border: 1px solid #aaa;
border-radius: 5px;
}
#nameSection {
text-align: center;
padding: 20px 0;
}
#result {
text-align: center;
margin-top: 20px;
color: #1e3c72;
}
.progress {
text-align: right;
color: #555;
font-size: 14px;
}
@media(max-width: 600px) {
body { padding: 10px; }
.quiz-container { width: 100%; padding: 15px; }
#userName { width: 90%; }
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>🧠 APICAL CLASSES</h2>
<p class="subtitle">Newton's Laws of Motion – Practice Quiz</p>
<div id="nameSection">
<p><strong>Enter your name to start the quiz:</strong></p>
<input type="text" id="userName" placeholder="Enter Your Name">
<br><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. Ek table ko horizontal force F lagakar floor par constant velocity se move kiya ja raha hai. Table par floor dwara lagne wali frictional force ka magnitude kya hoga?",
options: [
"A. F se greater",
"B. F se smaller",
"C. F ke equal",
"D. Zero"
],
correct: 2,
explanation: "Table constant velocity se move kar raha hai, isliye acceleration zero hai aur net force zero hoga. Isliye frictional force applied force F ke equal magnitude ki hogi aur opposite direction mein act karegi."
},
{
question: "2. Ek ball smooth, frictionless surface par move kar rahi hai. Agar ball par koi net force apply na ho, to uski velocity kya hogi?",
options: [
"A. Increase hogi",
"B. Decrease hogi",
"C. Same rahegi",
"D. Zero ho jayegi"
],
correct: 2,
explanation: "Newton’s First Law ke according net force zero hone par moving object constant velocity se move karta rahega."
},
{
question: "3. Ek ball smooth frictionless surface par move kar rahi hai. Agar net force ball ki motion ki direction mein lagaya jaaye, to ball ki velocity ka magnitude kya hoga?",
options: [
"A. Increase hoga",
"B. Decrease hoga",
"C. Same rahega",
"D. Immediately zero ho jayega"
],
correct: 0,
explanation: "Net force motion ki direction mein hone par acceleration bhi usi direction mein hoti hai. Isliye ball ki speed/velocity ka magnitude increase hota hai."
},
{
question: "4. Ek ball smooth frictionless surface par right direction mein move kar rahi hai. Agar net force left direction mein lagaya jaaye, to ball ki speed kya hogi?",
options: [
"A. Increase hogi",
"B. Decrease hogi",
"C. Same rahegi",
"D. Hamesha double hogi"
],
correct: 1,
explanation: "Force motion ke opposite direction mein hai, isliye acceleration bhi opposite direction mein hogi aur ball ki speed decrease hogi."
},
{
question: "5. Newton’s First Law ke according ek object rest mein hai aur us par net force zero hai. Object ka kya hoga?",
options: [
"A. Automatically move karega",
"B. Rest mein hi rahega",
"C. Constant acceleration se move karega",
"D. Uski mass change hogi"
],
correct: 1,
explanation: "Newton’s First Law ke according net force zero hone par rest object rest mein hi remain karta hai."
},
{
question: "6. Newton’s Second Law ke according kisi object par net force lagne par acceleration ki direction kiske same hoti hai?",
options: [
"A. Velocity ke opposite",
"B. Net force ke same",
"C. Gravity ke same only",
"D. Friction ke same only"
],
correct: 1,
explanation: "Newton’s Second Law ke according object ki acceleration net force ki direction mein hoti hai."
},
{
question: "7. Agar kisi object par same mass ke saath net force ko double kar diya jaaye, to acceleration par kya effect hoga?",
options: [
"A. Half ho jayegi",
"B. Same rahegi",
"C. Double ho jayegi",
"D. Zero ho jayegi"
],
correct: 2,
explanation: "Newton’s Second Law ke according same mass ke liye acceleration net force ke directly proportional hoti hai."
},
{
question: "8. Same net force ke under agar kisi object ka mass double kar diya jaaye, to uski acceleration kya hogi?",
options: [
"A. Double",
"B. Half",
"C. Four times",
"D. Same"
],
correct: 1,
explanation: "Same force ke liye acceleration mass ke inversely proportional hoti hai. Mass double karne par acceleration half ho jaati hai."
},
{
question: "9. Smooth horizontal surface par block P par 5 N right aur 4 N left forces act kar rahe hain. Block P par net force kitna hoga?",
options: [
"A. 9 N right",
"B. 9 N left",
"C. 1 N right",
"D. 1 N left"
],
correct: 2,
explanation: "Opposite direction ki forces subtract hoti hain: 5 N − 4 N = 1 N right. Isliye P net force experience karta hai."
},
{
question: "10. Smooth horizontal surface par block P par 5 N right aur 4 N left forces act kar rahe hain, jabki block Q constant velocity se move kar raha hai. Kaunsa statement correct hai?",
options: [
"A. P aur Q dono net force experience karte hain",
"B. P net force experience nahi karta, Q net force experience karta hai",
"C. P net force experience karta hai, Q net force experience nahi karta",
"D. P aur Q dono net force experience nahi karte"
],
correct: 2,
explanation: "P par net force = 5 − 4 = 1 N, isliye P par net force hai. Q constant velocity se move kar raha hai, isliye uska acceleration aur net force zero hai."
}
];
let currentQuestion = 0;
let score = 0;
let userAnswers = [];
let userName = "";
let quizSubmitted = false;
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");
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, 10)
: null;
}
function nextQuestion() {
saveAnswer();
if (currentQuestion < questions.length - 1) {
currentQuestion++;
showQuestion();
}
}
function prevQuestion() {
saveAnswer();
if (currentQuestion > 0) {
currentQuestion--;
showQuestion();
}
}
function submitQuiz() {
if (quizSubmitted) return;
saveAnswer();
score = 0;
questions.forEach((q, index) => {
if (userAnswers[index] === q.correct) {
score++;
}
});
quizSubmitted = true;
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.getElementById("progress").textContent = "Quiz Completed";
document.querySelector(".controls").style.display = "none";
document.getElementById("result").innerHTML = `
<h3>Your Score: ${score} / ${questions.length}</h3>
<p><strong>${escapeHTML(userName)}</strong>, ${
score >= 8 ? "Excellent performance!" :
score >= 5 ? "Good effort! Keep practising." :
"Keep learning and try again!"
}</p>
`;
}
function escapeHTML(str) {
return String(str).replace(/[&<>"']/g, function(char) {
return {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'"
}[char];
});
}
function saveScore(name, score) {
let scores = [];
try {
scores = JSON.parse(localStorage.getItem("quizScores")) || [];
if (!Array.isArray(scores)) scores = [];
} catch (e) {
scores = [];
}
scores.push({
name: name,
score: score,
date: new Date().toLocaleString()
});
localStorage.setItem("quizScores", JSON.stringify(scores));
}
function loadScoreboard() {
let scores = [];
try {
scores = JSON.parse(localStorage.getItem("quizScores")) || [];
if (!Array.isArray(scores)) scores = [];
} catch (e) {
scores = [];
}
scores.sort((a, b) => b.score - a.score);
document.getElementById("scoreList").innerHTML =
scores.length
? scores.map(s =>
`<li>${escapeHTML(s.name)} - ${s.score}/10 (${escapeHTML(s.date)})</li>`
).join("")
: "<li>No scores yet. Be the first to play!</li>";
}
</script>
</body>
</html>