-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
402 lines (393 loc) · 11.2 KB
/
app.js
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
const SectionContainer = document.querySelector(".QuizSection2");
// console.log(SectionContainer);
let questionNumber = 0;
// Questions
const QuestionBank = [
{
cat_id: 1,
category: "English",
quiz: ` She is not shabby, she is not stupid.(Join Using ..... neither ...nor ...)`,
options: {
A: "Shes shabby neither nor stupid",
B: "Shabby she not neither she is nor stupid",
C: "Shes neither shabby nor stupid",
D: "Shes neither shabby and nor stupid",
},
answer: "C",
},
{
cat_id: 1,
category: "English",
quiz: ` She is not shabby, she is not stupid.(Join Using ..... neither ...nor ...)`,
options: {
A: "Shes shabby neither nor stupid",
B: "Shabby she not neither she is nor stupid",
C: "Shes neither shabby nor stupid",
D: "Shes neither shabby and nor stupid",
},
answer: "C",
},
{
cat_id: 1,
category: "English",
quiz: "The teacher from whom I borrowed a red pen has left (Rewrite and begin : The teachers .....) ",
options: {
A: "The teacher I borrowed a red pen has left",
B: "The teachers from whom I borrowed a red pen have left",
C: "The teachers with whom I took a pen has left",
D: "The teacher who gave me a red has gone",
},
answer: "B",
},
{
cat_id: 1,
category: "English",
quiz: `"Stop playing , boys" ordered the coach.(Begin : The Coach ....)`,
options: {
A: "The coach order the boys to stop playing",
B: "The coach told the boys to stop playing",
C: "The coach ordered the boys that they should stop to play",
D: "The coach ordered the boys to stop playing",
},
answer: "D",
},
{
cat_id: 1,
category: "English",
quiz: `"Ethan asked Dube where he had put his bag"(Rewrite ending : ....?" Ethan asked.)`,
options: {
A: "Where have you put my bag, Ethan asked",
B: "where is my bag Ethan asked",
C: "where dube asked he placed his bag",
D: "Ethan asked Dube that where he had put his bag",
},
answer: "A",
},
{
cat_id: 1,
category: "English",
quiz: `"Kagame milked the cows." (Begin : The cows .....)`,
options: {
A: "The cows Kagame milked them",
B: "The cows were milked and it was Kagame ",
C: "The cows were milked by Kagame ",
D: "The cows were milked by him Kagame ",
},
answer: "C",
},
{
cat_id: 2,
category: "Math",
quiz: ` The cost of three pens is sh.9000. How many pens will one buy with sh.15000 ?`,
options: {
A: "3 pens",
B: "8 pens",
C: "5 pens",
D: "4 pens",
},
answer: "C",
},
{
cat_id: 2,
category: "Math",
quiz: ` The cost of three pens is sh.9000. How many pens will one buy with sh.15000 ?`,
options: {
A: "3 pens",
B: "8 pens",
C: "5 pens",
D: "4 pens",
},
answer: "C",
},
{
cat_id: 2,
category: "Math",
quiz: "Betty is 3 years older than Ritah. The sum of their age is 19. How old is Betty ? ",
options: {
A: "5 years ",
B: "11 years",
C: "20 years",
D: "15 years",
},
answer: "B",
},
{
cat_id: 2,
category: "Math",
quiz: `An Examination which took 2 and Half hours ended at 5:30pm. At What did the examination start.`,
options: {
A: "3:00 pm",
B: "1:00 pm",
C: "6:00 pm",
D: "7:00 pm",
},
answer: "A",
},
{
cat_id: 2,
category: "Math",
quiz: `Given that K and 37 deg are complementally angles. Find the value of K.`,
options: {
A: "40 deg",
B: "35 deg",
C: "20 deg",
D: "53 deg",
},
answer: "D",
},
{
cat_id: 2,
category: "Math",
quiz: `The base area of a cube is 28cm squared. Find the Volume of the cube`,
options: {
A: "120 cm cubed",
B: "140 cm cubed",
C: "30 cm cubed",
D: "80 cm cubed ",
},
answer: "B",
},
{
cat_id: 3,
category: "Science",
quiz: ` Name the force that is reduced by synovial fluid in a joint.`,
options: {
A: "Gravitational force",
B: "Friction force",
C: "Kinectic force",
D: "Pressure",
},
answer: "B",
},
{
cat_id: 3,
category: "Science",
quiz: ` Name the force that is reduced by synovial fluid in a joint.`,
options: {
A: "Gravitational force",
B: "Friction force",
C: "Kinectic force",
D: "Pressure",
},
answer: "B",
},
{
cat_id: 3,
category: "Science",
quiz: "What part of the Human skeleton is protected by the Vertebral column ? ",
options: {
A: "Bones",
B: "Skull",
C: "Spinal cord",
D: "Ribs",
},
answer: "C",
},
{
cat_id: 3,
category: "Science",
quiz: `Define the term pitch as used in sound`,
options: {
A: "Pitch is the highness and lawness of Eco",
B: "Pitch is the form of energy produced by vibration",
C: "Pitch is the form of vibration produced by sound",
D: "Pitch is the highness and lawness of sound",
},
answer: "D",
},
{
cat_id: 3,
category: "Science",
quiz: `How is sound produced when a girl is talking ?`,
options: {
A: "By enlargement of the Vocal code",
B: "By vibration of the Ambrico code",
C: "By vibration of the Vocal code",
D: "By Enlargement of the Gullet",
},
answer: "C",
},
{
cat_id: 3,
category: "Science",
quiz: `State the function of the Liver as abody organism`,
options: {
A: "To filter urine from the blood",
B: "To remove toxins from the blood ",
C: "To add toxins in the blood ",
D: "To center blood in the kidneys ",
},
answer: "B ",
},
{
cat_id: 4,
category: "Sst",
quiz: ` Which is the smallest continent in the World ?`,
options: {
A: "Austria",
B: "Africa",
C: "Uganda",
D: "Australia",
},
answer: "D",
},
{
cat_id: 4,
category: "Sst",
quiz: ` Which is the smallest continent in the World ?`,
options: {
A: "Austria",
B: "Africa",
C: "Uganda",
D: "Australia",
},
answer: "D",
},
{
cat_id: 4,
category: "Sst",
quiz: "Why does the government discourage poaching in a country ? ",
options: {
A: "To generate Income",
B: "To promote Tourism",
C: "To develop money",
D: "To reduce thefty",
},
answer: "B",
},
{
cat_id: 4,
category: "Sst",
quiz: `What is population cencus ?`,
options: {
A: "Population cencus is the counting of people in an area",
B: "Population cencus is the actual number of people in an area",
C: "Population cencus is the counting of animals in an area",
D: "Population cencus is the total number of people per square km",
},
answer: "A",
},
{
cat_id: 4,
category: "Sst",
quiz: `Give two enclave countries`,
options: {
A: "Dubai, Ethopia",
B: "South Africa, China",
C: "Madagascar, Zambia",
D: "Uganda, Eritrea",
},
answer: "D",
},
{
cat_id: 4,
category: "Sst",
quiz: `Why is the Equator marked at 0 degres ?`,
options: {
A: "The Equator has latitudes and longitudes",
B: "The Equator runs all over Uganda",
C: "The Equator divides Uganda into two parts",
D: "The Equator runs East and West",
},
answer: "C",
},
];
SectionContainer.innerHTML = `
<div class="SubjectBtns">
<button id="subjectButtons" data-id="1" class="EngBtn">ENGLISH</button>
<span class="text-white text-3xl">?</span>
<button id="subjectButtons" data-id="2" class="MathBtn">MATH</button>
<span class="text-white text-3xl">?</span>
<button id="subjectButtons" data-id="3" class="SciBtn">SCIENCE</button>
<span class="text-white text-3xl">?</span>
<button id="subjectButtons" data-id="4" class="SstBtn">SST</button>
</div>
`;
const note = document.querySelector(".note");
// console.log(note);
function showNotification(message) {
note.textContent = message;
note.style.left = "10px";
setTimeout(() => {
note.style.left = "-300px";
}, 3000);
}
//buttons For each
const buttons = document.querySelectorAll("#subjectButtons");
// console.log(buttons);
buttons.forEach((button) => {
button.addEventListener("click", function selectSubject(e) {
const btnId = e.target.dataset.id;
// console.log(QuestionBank, btnId);
// filtering questions according to subject click
const filteredQuestions = QuestionBank.filter((question) => {
return question.cat_id == btnId;
});
//on page load
renderQuestion(filteredQuestions);
// console.log(filteredQuestions);
showNotification(`${filteredQuestions[questionNumber].category} Questions`);
SectionContainer.style.display = "none";
nextBtn.style.display = "flex";
questionContainer.style.display = "flex";
nextBtn.addEventListener("click", function NextQuestion() {
renderQuestion(filteredQuestions);
});
// console.log(nextBtn);
});
});
const questionContainer = document.querySelector(".Qtncontainer");
// console.log(questionContainer);
const nextBtn = document.querySelector(".nextBtn");
// console.log("Nextbtn clicked");
// render questions function
let score = 0;
function renderQuestion(filteredQuestions) {
questionNumber++;
if (questionNumber == 6) {
showNotification(` Questions are done`);
// alert("questions are done");
questionContainer.innerHTML = `
<div class="ScoredDiv">
<h2 class="scoredHd">Overall Score</h2>
<p class="score flex align-center justify-center ">${score}</p>
</div>
`;
nextBtn.innerHTML = `
<a href="subjects.html">Next Subject</a>
`;
}
questionContainer.innerHTML = `
<h3 class="filteredSubject">${filteredQuestions[questionNumber].category}</h3>
<h2 class="question" id="question">${filteredQuestions[questionNumber].quiz}</h2>
<ul class="solution">
<li><span class="Optnz">A.</span> <span >${filteredQuestions[questionNumber].options.A}</span></li>
<li><span class="Optnz">B.</span> <span >${filteredQuestions[questionNumber].options.B}</span></li>
<li><span class="Optnz">C.</span> <span >${filteredQuestions[questionNumber].options.C}</span></li>
<li><span class="Optnz">D.</span> <span >${filteredQuestions[questionNumber].options.D}</span></li>
</ul>
`;
const optionAnswers = document.querySelectorAll("li");
// FOR EACH WITH EVENT LISTNER
optionAnswers.forEach((optionAnswer) => {
optionAnswer.addEventListener("click", function questionOption() {
console.log(" Option clicked");
const optionContent = optionAnswer.textContent.split(". ")[0];
const currentQuestion = QuestionBank[questionNumber];
const answer = currentQuestion.answer;
// console.log(optionContent, answer);
if (optionContent == answer) {
showNotification(`${optionContent} , Is a correct Answer `);
score++;
// console.log(score);
// console.log("its a correct Answer");
renderQuestion(filteredQuestions);
} else {
console.log(score);
showNotification(`Wrong answer, ${answer} is the Answer `);
// console.log("its a wrong answer");
renderQuestion(filteredQuestions);
}
});
});
}