class 9 science chapter 4

ch4 part2

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Motion, Distance and Displacement 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: 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: 12px;
    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: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    margin: 5px;
}
button:hover {
    background-color: #1e3c72;
}
#userName {
    padding: 10px;
    width: 90%;
    max-width: 350px;
    border: 1px solid #ccc;
    border-radius: 6px;
    margin-bottom: 10px;
}
#scoreboard {
    margin-top: 25px;
    background: #eef3f7;
    padding: 15px;
    border-radius: 8px;
}
#scoreboard h3 {
    text-align: center;
}
#result {
    text-align: center;
    margin-top: 20px;
}
.progress {
    text-align: center;
    color: #555;
    margin-bottom: 12px;
}
hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 20px 0;
}
@media(max-width:600px) {
    body { padding: 10px; }
    .quiz-container { width: 100%; padding: 15px; }
}
</style>
</head>

<body>
<div class="quiz-container">

<h2>🧠 APICAL CLASSES – Motion, Distance & Displacement Quiz</h2>

<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. Ek athlete point O se start karti hai, point B tak 40 m jaati hai, phir point A tak 100 m jaati hai aur finally wapas point B par ruk jaati hai. Usne total kitni distance travel ki?",
options: [
"A. 40 m",
"B. 60 m",
"C. 100 m",
"D. 160 m"
],
correct: 3,
explanation: "<strong>Answer: D. 160 m</strong><br><br><strong>Explanation:</strong> Total distance = O se A tak 100 m + A se B tak 60 m = <strong>160 m</strong>. Distance mein poora path consider kiya jata hai."
},

{
question: "2. Usi athlete ke starting point O aur stopping point B ke beech distance 40 m hai. Athlete ka displacement kitna hoga?",
options: [
"A. 40 m",
"B. 60 m",
"C. 100 m",
"D. 160 m"
],
correct: 0,
explanation: "<strong>Answer: A. 40 m</strong><br><br><strong>Explanation:</strong> Displacement <strong>initial position se final position ka net change</strong> hota hai. O se B = <strong>40 m</strong>."
},

{
question: "3. Displacement ko completely describe karne ke liye kya specify karna zaroori hai?",
options: [
"A. Sirf numerical value",
"B. Sirf distance",
"C. Magnitude aur direction",
"D. Sirf time"
],
correct: 2,
explanation: "<strong>Answer: C. Magnitude aur direction</strong><br><br><strong>Explanation:</strong> Displacement ek <strong>vector quantity</strong> hai, isliye iske liye <strong>magnitude + direction</strong> dono specify karne hote hain."
},

{
question: "4. Athlete t = 0 s par O se start karti hai aur t = 16 s par B par stop karti hai. Agar B, O ke right side mein 40 m hai, toh displacement kya hoga?",
options: [
"A. āˆ’40 m",
"B. +40 m",
"C. +160 m",
"D. āˆ’160 m"
],
correct: 1,
explanation: "<strong>Answer: B. +40 m</strong><br><br><strong>Explanation:</strong> Final position B, initial position O ke <strong>right side</strong> mein 40 m hai. Right direction ko positive lene par displacement = <strong>+40 m</strong>."
},

{
question: "5. Distance travelled aur displacement mein main difference kya hai?",
options: [
"A. Distance mein direction required hoti hai, displacement mein nahi",
"B. Distance total path length batati hai, displacement initial aur final position ka net change batata hai",
"C. Dono hamesha equal hote hain",
"D. Distance vector hai aur displacement scalar hai"
],
correct: 1,
explanation: "<strong>Answer: B. Distance total path length batati hai, displacement initial aur final position ka net change batata hai</strong><br><br><strong>Explanation:</strong> <strong>Distance = total path travelled</strong>, jabki <strong>displacement = initial se final position ka net change</strong>."
},

{
question: "6. SI unit of both distance and displacement kya hai?",
options: [
"A. Second (s)",
"B. Kilogram (kg)",
"C. Metre (m)",
"D. Metre per second (m/s)"
],
correct: 2,
explanation: "<strong>Answer: C. Metre (m)</strong><br><br><strong>Explanation:</strong> Distance aur displacement dono length-related physical quantities hain, isliye dono ka <strong>SI unit metre (m)</strong> hai."
},

{
question: "7. Ek runner 50 m east jaata hai aur phir same path par 20 m west return karta hai. Total distance aur displacement ka magnitude respectively kya hoga?",
options: [
"A. 30 m, 70 m",
"B. 70 m, 30 m",
"C. 50 m, 20 m",
"D. 20 m, 50 m"
],
correct: 1,
explanation: "<strong>Answer: B. 70 m, 30 m</strong><br><br><strong>Explanation:</strong> Total distance = 50 + 20 = <strong>70 m</strong>. Net displacement = 50 āˆ’ 20 = <strong>30 m east</strong>."
},

{
question: "8. ā€œt = 10 sā€ kya represent karta hai?",
options: [
"A. Time interval",
"B. Instant of time",
"C. Total distance",
"D. Displacement"
],
correct: 1,
explanation: "<strong>Answer: B. Instant of time</strong><br><br><strong>Explanation:</strong> <strong>Instant of time</strong> clock ki ek single reading hoti hai, jaise t = 10 s. Do instants ke beech ka duration <strong>time interval</strong> hota hai."
},

{
question: "9. Agar ek object t = 5 s se t = 12 s tak move karta hai, toh is duration ka time interval kitna hoga?",
options: [
"A. 5 s",
"B. 7 s",
"C. 12 s",
"D. 17 s"
],
correct: 1,
explanation: "<strong>Answer: B. 7 s</strong><br><br><strong>Explanation:</strong> Time interval = final time āˆ’ initial time = 12 āˆ’ 5 = <strong>7 s</strong>."
},

{
question: "10. Kaunsi physical quantity ko describe karne ke liye sirf numerical value aur unit sufficient hote hain, direction ki need nahi hoti?",
options: [
"A. Displacement",
"B. Velocity",
"C. Scalar quantity",
"D. Vector quantity"
],
correct: 2,
explanation: "<strong>Answer: C. Scalar quantity</strong><br><br><strong>Explanation:</strong> <strong>Scalar quantities</strong> ko sirf magnitude/numerical value aur unit se describe kiya ja sakta hai. Vector quantities ke liye <strong>magnitude aur direction</strong> dono required hote 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";

    showQuestion();
    loadScoreboard();
}

function showQuestion() {
    const q = questions[currentQuestion];
    const container = document.getElementById("questionContainer");

    document.getElementById("progress").innerHTML =
        "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();

    if (userAnswers.some(answer => answer === null || answer === undefined)) {
        alert("Please attempt all questions before submitting.");
        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];
        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("progress").style.display = "none";

    const percentage = (score / questions.length) * 100;

    document.getElementById("result").innerHTML = `
        <h3>šŸŽ‰ Quiz Completed!</h3>
        <h2>Your Score: ${score} / ${questions.length}</h2>
        <h3>Percentage: ${percentage}%</h3>
        <p><strong>Student Name:</strong> ${escapeHTML(userName)}</p>
        <button onclick="location.reload()">Try Again</button>
    `;
}

function escapeHTML(str) {
    return String(str).replace(/[&<>"']/g, function(char) {
        return {
            "&": "&amp;",
            "<": "&lt;",
            ">": "&gt;",
            '"': "&quot;",
            "'": "&#039;"
        }[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}/10 (${escapeHTML(s.date)})</li>`
    ).join("");
}
</script>

</body>
</html>

Leave a Comment