ch4 part1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>๐ง Science Quiz โ Motion in a Straight Line</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;
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;
}
.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;
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;
}
#scoreboard h3 {
text-align: center;
}
ol {
padding-left: 20px;
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>๐ง Science Quiz โ Motion in a Straight Line</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. Jab koi object straight line mein move karta hai, toh uski motion ko kya kaha jata hai?",
options: [
"A. Circular motion",
"B. Oscillatory motion",
"C. Linear motion",
"D. Random motion"
],
correct: 2,
explanation: "Jab object straight line mein move karta hai, us motion ko <b>linear motion</b> ya motion in a straight line kehte hain."
},
{
question: "2. Scientists complex motion ko study karne ke liye pehle usse idealised aur simplified forms mein kyon study karte hain?",
options: [
"A. Complex phenomena ko easily understand aur analyse karne ke liye",
"B. Motion ko completely stop karne ke liye",
"C. Sirf distance measure karne ke liye",
"D. Objects ka mass change karne ke liye"
],
correct: 0,
explanation: "Nature mein motion bahut complex ho sakti hai. Isliye scientists pehle uske <b>simple and idealised forms</b> ko study karte hain."
},
{
question: "3. Nimn mein se kaunsa example linear motion ko represent karta hai?",
options: [
"A. Ceiling fan ka ghoomna",
"B. Straight track par train ka move karna",
"C. Pendulum ka aage-peeche swing karna",
"D. Earth ka Sun ke around revolve karna"
],
correct: 1,
explanation: "Straight track par train <b>straight line</b> mein move karti hai, isliye yeh linear motion ka example hai."
},
{
question: "4. Kisi object ki position describe karne ke liye sabse pehle kya specify karna zaroori hai?",
options: [
"A. Object ka colour",
"B. Object ka mass",
"C. Ek fixed reference point",
"D. Object ka temperature"
],
correct: 2,
explanation: "Position describe karne ke liye ek <b>fixed reference point</b> choose kiya jata hai. Object ki distance aur direction isi point ke respect mein batayi jaati hai."
},
{
question: "5. Kisi object ki position ko completely describe karne ke liye reference point ke respect mein kya specify karna hota hai?",
options: [
"A. Sirf distance",
"B. Sirf direction",
"C. Distance aur direction dono",
"D. Sirf speed"
],
correct: 2,
explanation: "Position batane ke liye object ki <b>distance aur direction dono</b> reference point ke respect mein specify karni hoti hain."
},
{
question: "6. Ek athlete straight track par start point O se running karti hai. Agar kuch time baad uski position reference point O se 40 m right side mein hai, toh uski position ko generally kaise represent kiya jayega?",
options: [
"A. โ40 m",
"B. 0 m",
"C. +40 m",
"D. +80 m"
],
correct: 2,
explanation: "Reference point O ke <b>right side ki positions generally positive</b> li jaati hain. Isliye 40 m right = <b>+40 m</b>."
},
{
question: "7. Agar kisi object ki position reference point O ke left side mein 20 m hai, toh position ko generally kis sign ke saath represent kiya jayega?",
options: [
"A. +20 m",
"B. โ20 m",
"C. 0 m",
"D. +40 m"
],
correct: 1,
explanation: "Reference point ke <b>left side ki positions generally negative</b> li jaati hain. Isliye position = <b>โ20 m</b>."
},
{
question: "8. Ek object tab motion mein kaha jayega jab uski position reference point ke respect mein kya kare?",
options: [
"A. Time ke saath change ho",
"B. Hamesha same rahe",
"C. Sirf positive ho",
"D. Sirf negative ho"
],
correct: 0,
explanation: "Agar object ki <b>position reference point ke respect mein time ke saath change hoti hai</b>, toh object motion mein hai."
},
{
question: "9. Ek object road par khada hai aur 10 minutes tak uski position ek fixed reference point ke respect mein change nahi hoti. Object ki state kya hogi?",
options: [
"A. Uniform motion",
"B. Circular motion",
"C. At rest",
"D. Oscillatory motion"
],
correct: 2,
explanation: "Agar reference point ke respect mein object ki <b>position time ke saath change nahi hoti</b>, toh object <b>at rest</b> hota hai."
},
{
question: "10. Straight-line motion mein direction ko represent karne ke liye generally kaunse signs use kiye jaate hain?",
options: [
"A. ร aur รท",
"B. + aur โ",
"C. = aur โ ",
"D. < aur >"
],
correct: 1,
explanation: "Straight line par object do directions mein move kar sakta hai. In directions ko represent karne ke liye generally <b>positive (+) aur negative (โ) signs</b> use kiye jaate 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>