CLASS X INTERNET BASICS NOTES
Make a presentation on the topics of chapter internet basics.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MCQ Test</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
background: #f4f4f4;
}
.container {
max-width: 900px;
margin: auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.2);
}
h1, h2 {
text-align: center;
}
.question {
margin-bottom: 15px;
padding: 10px;
background: #f9f9f9;
border-radius: 8px;
}
button {
display: block;
width: 100%;
padding: 12px;
background: green;
color: white;
border: none;
font-size: 16px;
cursor: pointer;
border-radius: 8px;
}
button:hover {
background: darkgreen;
}
#result {
margin-top: 20px;
padding: 15px;
background: #e8f5e9;
border-radius: 8px;
font-size: 18px;
}
input[type="text"] {
width: 100%;
padding: 8px;
margin: 5px 0 15px 0;
border-radius: 5px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div class="container">
<h1>MCQ Based Test</h1>
<label>Name:</label>
<input type="text" id="studentName" placeholder="Enter your name">
<label>Class:</label>
<input type="text" id="studentClass" placeholder="Enter your class">
<label>Section:</label>
<input type="text" id="studentSection" placeholder="Enter your section">
<form id="quizForm"></form>
<button onclick="calculateScore()">Submit Test</button>
<div id="result"></div>
</div>
<script>
const questions = [
{q:"1. What does CPU stand for?", options:["Central Process Unit","Central Processing Unit","Computer Personal Unit","Central Processor Utility"], answer:1},
{q:"2. Which device is used to input text?", options:["Monitor","Keyboard","Printer","Speaker"], answer:1},
{q:"3. HTML stands for?", options:["Hyper Text Markup Language","High Text Machine Language","Hyper Tool Markup Language","None"], answer:0},
{q:"4. Which is an output device?", options:["Mouse","Keyboard","Monitor","Scanner"], answer:2},
{q:"5. Which company developed Windows?", options:["Apple","Google","Microsoft","IBM"], answer:2},
];
// Add placeholder questions up to 50
for(let i=6; i<=50; i++){
questions.push({
q: i + ". Sample Question " + i + "?",
options:["Option A","Option B","Option C","Option D"],
answer:0
});
}
const quizForm = document.getElementById("quizForm");
questions.forEach((item, index) => {
let div = document.createElement("div");
div.classList.add("question");
div.innerHTML = `<p>${item.q}</p>` +
item.options.map((opt, i) =>
`<label><input type="radio" name="q${index}" value="${i}"> ${opt}</label><br>`
).join("");
quizForm.appendChild(div);
});
function calculateScore() {
let score = 0;
questions.forEach((item, index) => {
const selected = document.querySelector(`input[name="q${index}"]:checked`);
if(selected && parseInt(selected.value) === item.answer){
score++;
}
});
let name = document.getElementById("studentName").value;
let studentClass = document.getElementById("studentClass").value;
let section = document.getElementById("studentSection").value;
document.getElementById("result").innerHTML = `
<h2>Result</h2>
<p><strong>Name:</strong> ${name}</p>
<p><strong>Class:</strong> ${studentClass}</p>
<p><strong>Section:</strong> ${section}</p>
<p><strong>Marks Obtained:</strong> ${score} / ${questions.length}</p>
`;
}
</script>
</body>
</html>
Comments
Post a Comment