ch4 part10
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>🧠 Science Quiz – Soap and Detergents</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;
}
.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: 10px;
margin-top: 10px;
margin-bottom: 15px;
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;
}
input[type="text"] {
padding: 10px;
width: 65%;
max-width: 300px;
border: 1px solid #ccc;
border-radius: 6px;
}
#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;
}
input[type="text"] {
width: 90%;
}
}
</style>
</head>
<body>
<div class="quiz-container">
<h2>🧠 Science Quiz – Soap and Detergents</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. Most dirt water mein easily dissolve kyun nahi hota?",
options: [
"A. Dirt generally oily nature ka hota hai",
"B. Dirt ionic hota hai",
"C. Dirt gas hota hai",
"D. Dirt sirf oxygen se bana hota hai"
],
correct: 0,
explanation: "Most dirt oily in nature hota hai aur oil water mein dissolve nahi hota. Soap is oily dirt ko remove karne mein help karta hai."
},
{
question: "2. Soap molecules chemically kya hote hain?",
options: [
"A. Sodium or potassium salts of long-chain carboxylic acids",
"B. Calcium salts of short-chain acids",
"C. Sodium chloride molecules",
"D. Hydrocarbons only"
],
correct: 0,
explanation: "Soap long-chain carboxylic acids ke sodium ya potassium salts hote hain."
},
{
question: "3. Soap molecule ka ionic end kis ke saath interact karta hai?",
options: [
"A. Oil",
"B. Water",
"C. Hydrocarbon tail",
"D. Dirt only"
],
correct: 1,
explanation: "Soap ka ionic end hydrophilic hota hai, yani ye water ke saath interact karta hai."
},
{
question: "4. Soap molecule ka hydrocarbon chain kis ke saath interact karta hai?",
options: [
"A. Water",
"B. Oil",
"C. Salt",
"D. Oxygen"
],
correct: 1,
explanation: "Soap ka hydrocarbon part hydrophobic hota hai aur oil/hydrocarbon ke saath interact karta hai."
},
{
question: "5. Soap molecules ke clusters, jisme hydrophobic tails andar aur ionic ends bahar hote hain, kya kehlate hain?",
options: [
"A. Emulsions",
"B. Micelles",
"C. Crystals",
"D. Precipitates"
],
correct: 1,
explanation: "Soap molecules water mein micelles form karte hain. Inmein hydrophobic tails interior mein aur ionic ends surface par hote hain."
},
{
question: "6. Soap micelle mein oily dirt generally kahan collect hota hai?",
options: [
"A. Micelle ke centre mein",
"B. Water ke surface par only",
"C. Ionic end ke bahar",
"D. Soap solution ke bottom par"
],
correct: 0,
explanation: "Hydrophobic tails oily dirt ko attract karte hain, isliye oily dirt micelle ke centre mein collect ho jata hai."
},
{
question: "7. Soap molecule ke water-interacting end ko kya kaha jata hai?",
options: [
"A. Hydrophobic end",
"B. Hydrophilic end",
"C. Hydrocarbon end",
"D. Non-polar end"
],
correct: 1,
explanation: "Hydrophilic ka meaning hai “water-loving”. Soap ka ionic end water ke saath interact karta hai."
},
{
question: "8. Hard water mein soap se scum kyun form hota hai?",
options: [
"A. Sodium aur potassium ions ke karan",
"B. Calcium aur magnesium salts ke saath reaction ke karan",
"C. Oxygen ke karan",
"D. Soap ke evaporation ke karan"
],
correct: 1,
explanation: "Hard water mein calcium aur magnesium ions/salts present hote hain. Ye soap ke saath react karke insoluble substance (scum) form karte hain."
},
{
question: "9. Hard water mein detergents soaps se zyada effective kyun hote hain?",
options: [
"A. Detergents water ko soft bana dete hain",
"B. Detergents calcium aur magnesium ions ke saath insoluble precipitate nahi banate",
"C. Detergents mein carbon nahi hota",
"D. Detergents sirf oil ko dissolve karte hain"
],
correct: 1,
explanation: "Detergents ke charged ends Ca²⁺ aur Mg²⁺ ions ke saath insoluble precipitate nahi banate, isliye detergents hard water mein bhi effective rehte hain."
},
{
question: "10. Detergents ka commonly use kin products mein hota hai?",
options: [
"A. Shampoos aur clothes-cleaning products",
"B. Only fuels",
"C. Only medicines",
"D. Only fertilisers"
],
correct: 0,
explanation: "Detergents ko commonly shampoos aur clothes-cleaning products mein cleansing agents ke roop mein use kiya jata 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;
}
currentQuestion = 0;
score = 0;
userAnswers = new Array(questions.length).fill(null);
quizSubmitted = false;
document.getElementById("nameSection").style.display = "none";
document.getElementById("quizSection").style.display = "block";
document.getElementById("result").innerHTML = "";
document.querySelector(".controls").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}"
onchange="saveAnswer()"
${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() {
if (quizSubmitted) return;
const selected = document.querySelector('input[name="option"]:checked');
userAnswers[currentQuestion] = selected
? parseInt(selected.value)
: null;
}
function nextQuestion() {
if (quizSubmitted) return;
saveAnswer();
if (currentQuestion < questions.length - 1) {
currentQuestion++;
showQuestion();
}
}
function prevQuestion() {
if (quizSubmitted) return;
saveAnswer();
if (currentQuestion > 0) {
currentQuestion--;
showQuestion();
}
}
function submitQuiz() {
if (quizSubmitted) return;
saveAnswer();
const unanswered = userAnswers.filter(answer => answer === null).length;
if (unanswered > 0) {
const confirmSubmit = confirm(
"You have " + unanswered + " unanswered question(s). Do you still want to submit?"
);
if (!confirmSubmit) return;
}
quizSubmitted = true;
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;">
<strong>Explanation:</strong> ${q.explanation}
</div>
<hr>
`;
});
document.querySelector(".controls").style.display = "none";
document.getElementById("result").innerHTML = `
<h3>Your Score: ${score} / ${questions.length}</h3>
<p>Correct Answers: ${score}</p>
<p>Incorrect or Unanswered: ${questions.length - score}</p>
`;
}
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>${s.name} - ${s.score}/10 (${s.date})</li>
`).join("");
}
</script>
</body>
</html>