-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
113 lines (105 loc) · 9.73 KB
/
Copy pathscript.js
File metadata and controls
113 lines (105 loc) · 9.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const usernameInput = document.getElementById("username");
const passwordInput = document.getElementById("password");
const loginBtn = document.getElementById("login-btn");
const loginContainer = document.getElementById("login-container");
const quizContainer = document.getElementById("quiz-container");
const resultContainer = document.getElementById("result-container");
const quizForm = document.getElementById("quiz-form");
const submitBtn = document.getElementById("submit-btn");
const loginError = document.getElementById("login-error");
loginBtn.addEventListener("click", () => {
if (
usernameInput.value === "smit-student" &&
passwordInput.value === "smit-student123"
) {
loginContainer.classList.add("hidden");
quizContainer.classList.remove("hidden");
loadQuiz();
} else {
loginError.textContent = "❌ Invalid username or password!";
}
});
const questions = [
{ q: "1. What does HTML stand for?", options: ["Hyperlinks and Text Markup Language", "Hyper Text Markup Language", "Home Tool Markup Language", "Hyper Tool Multi Language"], ans: 1 },
{ q: "2. Who is making the Web standards?", options: ["Google", "Mozilla", "The World Wide Web Consortium", "Microsoft"], ans: 2 },
{ q: "3. Choose the correct HTML element for the largest heading:", options: ["<heading>", "<h1>", "<h6>", "<head>"], ans: 1 },
{ q: "4. What is the correct HTML element for inserting a line break?", options: ["<lb>", "<break>", "<br>", "<ln>"], ans: 2 },
{ q: "5. What is the correct HTML for adding a background color?", options: ["<body color='yellow'>", "<background>yellow</background>", "<body style='background-color:yellow;'>", "<bg>yellow</bg>"], ans: 2 },
{ q: "6. Choose the correct HTML element to define important text", options: ["<strong>", "<important>", "<i>", "<b>"], ans: 0 },
{ q: "7. Which tag is used to display a picture in a webpage?", options: ["<pic>", "<img>", "<image>", "<photo>"], ans: 1 },
{ q: "8. Which HTML attribute specifies an alternate text for an image?", options: ["title", "alt", "src", "longdesc"], ans: 1 },
{ q: "9. How can you make a numbered list?", options: ["<ul>", "<ol>", "<list>", "<dl>"], ans: 1 },
{ q: "10. How can you make a bulleted list?", options: ["<ul>", "<ol>", "<dl>", "<list>"], ans: 0 },
{ q: "11. What is the correct HTML for creating a hyperlink?", options: ["<a>http://example.com</a>", "<a name='http://example.com'>Example</a>", "<a href='http://example.com'>Example</a>", "<link>Example</link>"], ans: 2 },
{ q: "12. Which character is used to indicate an end tag?", options: ["*", "/", "<", "^"], ans: 1 },
{ q: "13. How can you open a link in a new tab?", options: ["<a href='url' target='_blank'>", "<a href='url' new>", "<a href='url' open='tab'>", "<a href='url' window='new'>"], ans: 0 },
{ q: "14. Which tag defines the document’s title?", options: ["<meta>", "<title>", "<head>", "<h1>"], ans: 1 },
{ q: "15. Where is the correct place to insert a JavaScript?", options: ["<head> or <body>", "<footer>", "<html>", "<meta>"], ans: 0 },
{ q: "16. Which element is used for inserting a comment?", options: ["<!-- comment -->", "// comment", "# comment", "<comment>"], ans: 0 },
{ q: "17. Which tag is used to define a table row?", options: ["<td>", "<th>", "<tr>", "<table>"], ans: 2 },
{ q: "18. Which tag defines a table cell?", options: ["<td>", "<th>", "<tr>", "<cell>"], ans: 0 },
{ q: "19. Which tag defines a table header cell?", options: ["<td>", "<th>", "<head>", "<header>"], ans: 1 },
{ q: "20. Which tag defines an unordered list?", options: ["<ul>", "<ol>", "<list>", "<dl>"], ans: 0 },
{ q: "21. What is the correct HTML for creating a checkbox?", options: ["<check>", "<input type='check'>", "<input type='checkbox'>", "<checkbox>"], ans: 2 },
{ q: "22. Which tag is used to define a dropdown list?", options: ["<list>", "<dropdown>", "<input type='dropdown'>", "<select>"], ans: 3 },
{ q: "23. Which tag is used for a text area?", options: ["<textbox>", "<input type='textarea'>", "<textarea>", "<text>"], ans: 2 },
{ q: "24. Which HTML tag is used to define an internal style sheet?", options: ["<style>", "<script>", "<css>", "<link>"], ans: 0 },
{ q: "25. Which HTML attribute is used to define inline styles?", options: ["font", "style", "class", "design"], ans: 1 },
{ q: "26. Which HTML tag is used to define an ordered list?", options: ["<ol>", "<ul>", "<li>", "<dl>"], ans: 0 },
{ q: "27. What is the correct HTML for inserting an image?", options: ["<img href='image.jpg'>", "<img src='image.jpg'>", "<image src='image.jpg'>", "<src>image.jpg</src>"], ans: 1 },
{ q: "28. Which HTML attribute specifies the URL of the page the link goes to?", options: ["src", "href", "link", "url"], ans: 1 },
{ q: "29. Which HTML tag is used to define a footer?", options: ["<bottom>", "<footer>", "<section>", "<base>"], ans: 1 },
{ q: "30. Which HTML tag is used to define navigation links?", options: ["<nav>", "<navigate>", "<links>", "<menu>"], ans: 0 },
{ q: "31. Which HTML tag is used to define a paragraph?", options: ["<para>", "<p>", "<pg>", "<text>"], ans: 1 },
{ q: "32. What does the <hr> tag do?", options: ["Draws a horizontal line", "Creates a header", "Starts a new paragraph", "Inserts a page break"], ans: 0 },
{ q: "33. What is the correct HTML element for inserting a line break?", options: ["<break>", "<lb>", "<br>", "<line>"], ans: 2 },
{ q: "34. Which tag is used to display code?", options: ["<computer>", "<code>", "<samp>", "<pre>"], ans: 1 },
{ q: "35. Which HTML tag is used to define emphasized text?", options: ["<i>", "<em>", "<italic>", "<strong>"], ans: 1 },
{ q: "36. How do you specify a comment in HTML?", options: ["// comment", "# comment", "<!-- comment -->", "<! comment>"], ans: 2 },
{ q: "37. What is the purpose of the <head> element?", options: ["To contain meta-information", "To display headings", "To link images", "To show main content"], ans: 0 },
{ q: "38. Which HTML element defines the main content?", options: ["<main>", "<body>", "<section>", "<article>"], ans: 0 },
{ q: "39. Which tag is used to define a list item?", options: ["<list>", "<item>", "<li>", "<ul>"], ans: 2 },
{ q: "40. Which tag defines the document body?", options: ["<main>", "<body>", "<html>", "<section>"], ans: 1 },
{ q: "41. Which element defines a clickable button?", options: ["<input type='button'>", "<btn>", "<button>", "<click>"], ans: 2 },
{ q: "42. What is the correct HTML for making text bold?", options: ["<strong>", "<bold>", "<b>", "<bl>"], ans: 2 },
{ q: "43. Which tag defines the title of a table?", options: ["<title>", "<caption>", "<head>", "<th>"], ans: 1 },
{ q: "44. What is the correct HTML for inserting a background image?", options: ["<background img='bg.jpg'>", "<body style='background-image:url(bg.jpg)'>", "<bg src='bg.jpg'>", "<body img='bg.jpg'>"], ans: 1 },
{ q: "45. Which tag is used for inline quotations?", options: ["<quote>", "<q>", "<block>", "<blockquote>"], ans: 1 },
{ q: "46. Which tag defines preformatted text?", options: ["<pre>", "<code>", "<text>", "<format>"], ans: 0 },
{ q: "47. What is the correct HTML tag for inserting a video?", options: ["<movie>", "<video>", "<media>", "<clip>"], ans: 1 },
{ q: "48. Which HTML tag is used to play audio files?", options: ["<sound>", "<music>", "<audio>", "<media>"], ans: 2 },
{ q: "49. Which HTML tag is used to display a list of options?", options: ["<select>", "<list>", "<dropdown>", "<ul>"], ans: 0 },
{ q: "50. Which tag is used to create a table?", options: ["<tab>", "<table>", "<tr>", "<grid>"], ans: 1 },
];
function loadQuiz() {
questions.forEach((q, index) => {
const div = document.createElement("div");
div.classList.add("question");
div.innerHTML = `
<h3>${q.q}</h3>
${q.options
.map(
(opt, i) =>
`<label><input type="radio" name="q${index}" value="${i}"> ${opt}</label>`
)
.join("")}
`;
quizForm.appendChild(div);
});
submitBtn.classList.remove("hidden");
}
submitBtn.addEventListener("click", (e) => {
e.preventDefault();
let correct = 0;
questions.forEach((q, i) => {
const selected = document.querySelector(`input[name="q${i}"]:checked`);
if (selected && parseInt(selected.value) === q.ans) correct++;
});
const wrong = questions.length - correct;
const marks = (correct / questions.length) * 100;
quizContainer.classList.add("hidden");
resultContainer.classList.remove("hidden");
document.getElementById("score").textContent = `Your Score: ${marks.toFixed(2)}%`;
document.getElementById("correct").textContent = `✅ Correct Answers: ${correct}`;
document.getElementById("wrong").textContent = `❌ Wrong Answers: ${wrong}`;
});