class 8 science chapter 2

ch2 part6

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Science Quiz – Cell Wall</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;
    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: 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;
}

.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;
}

#userName {
    padding: 10px;
    width: 90%;
    max-width: 300px;
    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;
}

ol {
    padding-left: 20px;
}

@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .quiz-container {
        width: 100%;
        padding: 15px;
    }
}
</style>
</head>

<body>

<div class="quiz-container">

    <h2>🧠 Science Quiz – Cell Wall</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. Cell wall mainly kis type ki cells mein present hoti hai?",
    options: [
        "A. Animal cells",
        "B. Plant cells",
        "C. Red blood cells",
        "D. Nerve cells"
    ],
    correct: 1,
    explanation: "Cell wall plant cells ki outer protective layer hoti hai. Yeh cell ko shape, strength aur support deti hai.<br><br><strong>Example:</strong> Onion ki cells mein cell wall hoti hai, jo microscope mein clearly dikh sakti hai."
},

{
    question: "2. Plant cell wall mainly kis substance se bani hoti hai?",
    options: [
        "A. Protein",
        "B. Fat",
        "C. Cellulose",
        "D. Starch"
    ],
    correct: 2,
    explanation: "Plant cell wall ka main structural component cellulose hota hai. Yeh cell wall ko strength aur rigidity deta hai.<br><br><strong>Example:</strong> Tree ki wood aur plant stems ki strength mein cellulose ka important role hota hai."
},

{
    question: "3. Cell wall ka main function kya hai?",
    options: [
        "A. Cell ko protection aur support dena",
        "B. Energy produce karna",
        "C. Protein banana",
        "D. Genetic information store karna"
    ],
    correct: 0,
    explanation: "Cell wall cell ko ek definite shape deti hai aur external pressure se protection mein help karti hai.<br><br><strong>Example:</strong> Plant ka stem seedha khada rehne mein cell walls ki strength se help leta hai."
},

{
    question: "4. Animal cells mein cell wall hoti hai ya nahi?",
    options: [
        "A. Sirf large animal cells mein",
        "B. Sirf blood cells mein",
        "C. Sabhi animal cells mein",
        "D. Animal cells mein cell wall nahi hoti"
    ],
    correct: 3,
    explanation: "Animal cells ke bahar cell membrane hoti hai, lekin cell wall nahi hoti. Plant cells mein cell membrane ke bahar cell wall bhi hoti hai.<br><br><strong>Example:</strong> Human cheek cells mein cell membrane hoti hai, par cell wall nahi hoti."
},

{
    question: "5. Plant cell mein cell wall, cell membrane ke kis taraf hoti hai?",
    options: [
        "A. Cell membrane ke andar",
        "B. Cell membrane ke bahar",
        "C. Nucleus ke andar",
        "D. Cytoplasm ke andar"
    ],
    correct: 1,
    explanation: "Plant cell mein cell wall sabse outer protective layer hoti hai. Cell membrane uske just andar hoti hai.<br><br><strong>Example:</strong> Onion peel ki cell ko dekho, toh uski outer boundary cell wall hoti hai."
},

{
    question: "6. Cell wall plant cell ko kaunsi property provide karti hai?",
    options: [
        "A. Genetic information",
        "B. Photosynthesis ke liye chlorophyll",
        "C. Mechanical strength",
        "D. Protein synthesis"
    ],
    correct: 2,
    explanation: "Cell wall plant cell ko support aur rigidity deti hai, jisse cell apni shape maintain kar pata hai.<br><br><strong>Example:</strong> Plant ke leaves aur stems ko structure maintain karne mein cell walls help karti hain."
},

{
    question: "7. Cell wall aur cell membrane ke baare mein kaunsa statement correct hai?",
    options: [
        "A. Dono bilkul same structure hain",
        "B. Cell membrane sirf plants mein hoti hai",
        "C. Cell wall sabhi animal cells mein hoti hai",
        "D. Cell wall aur cell membrane alag structures hain"
    ],
    correct: 3,
    explanation: "Cell wall ek rigid outer layer hai, jabki cell membrane ek selectively permeable boundary hai jo substances ke movement ko regulate karti hai.<br><br><strong>Example:</strong> Plant cell mein cell wall protection aur support deti hai, jabki cell membrane materials ke entry aur exit ko control karti hai."
},

{
    question: "8. Cell wall plant cell ko shape maintain karne mein kaise help karti hai?",
    options: [
        "A. Rigid outer support dekar",
        "B. DNA ko destroy karke",
        "C. Nucleus ko remove karke",
        "D. Cytoplasm ko produce karke"
    ],
    correct: 0,
    explanation: "Cell wall ki rigidity cell ko ek definite shape maintain karne mein help karti hai.<br><br><strong>Example:</strong> Onion cells microscope mein aksar rectangular ya brick-like shape mein dikhai deti hain."
},

{
    question: "9. Plant cell mein cell wall damage hone par kya effect ho sakta hai?",
    options: [
        "A. Cell mein nucleus nahi rahega",
        "B. Cell ka protection aur support kam ho sakta hai",
        "C. Cell turant animal cell ban jayegi",
        "D. Cell mein DNA ka role khatam ho jayega"
    ],
    correct: 1,
    explanation: "Cell wall damage hone se cell ki structural strength aur protection affect ho sakti hai. Lekin cell plant cell hi rehti hai.<br><br><strong>Example:</strong> Agar plant tissue ki cell walls weak ho jaayein, toh tissue ki firmness kam ho sakti hai."
},

{
    question: "10. Plant cell ki outer layers ka correct order kya hai, outside se inside ki taraf?",
    options: [
        "A. Cytoplasm → Cell wall → Cell membrane",
        "B. Nucleus → Cell membrane → Cell wall",
        "C. Cell wall → Cell membrane → Cytoplasm",
        "D. Cell membrane → Nucleus → Cell wall"
    ],
    correct: 2,
    explanation: "Plant cell mein sabse bahar cell wall hoti hai. Uske andar cell membrane aur phir cytoplasm hota hai.<br><br><strong>Example:</strong> Onion peel ki cell ko microscope se observe karte waqt cell wall outer boundary ke roop mein dikhai deti 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");

    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() {

    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];
        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>

Leave a Comment