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
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Computer Diploma Quiz Challenge</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
    <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <style>
        .progress-bar {
            transition: width 0.3s ease;
        }
        .option:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .pulse {
            animation: pulse 1s infinite;
        }
        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }
    </style>
</head>
<body class="bg-gradient-to-br from-blue-900 to-purple-900 min-h-screen text-white">
    <div id="app" class="container mx-auto px-4 py-8">
        <!-- Start Screen -->
        <div id="start-screen" class="text-center max-w-2xl mx-auto mt-16" data-aos="zoom-in">
            <div class="bg-white/10 backdrop-blur-md rounded-xl p-8 shadow-2xl border border-white/20">
                <h1 class="text-4xl font-bold mb-6 text-transparent bg-clip-text bg-gradient-to-r from-blue-300 to-purple-300">Computer Diploma Quiz</h1>
                <p class="text-xl mb-8 text-blue-100">Test your knowledge with 20 challenging questions in just 2 minutes!</p>
                <div class="flex items-center justify-center mb-8">
                    <i data-feather="clock" class="w-8 h-8 mr-2"></i>
                    <span class="text-lg">2 Minute Challenge</span>
                </div>
                <button id="start-btn" class="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white font-bold py-3 px-8 rounded-full text-lg transition-all duration-300 transform hover:scale-105 shadow-lg pulse">
                    Start Quiz
                </button>
            </div>
        </div>

        <!-- Quiz Screen -->
        <div id="quiz-screen" class="hidden max-w-3xl mx-auto mt-8">
            <div class="flex justify-between items-center mb-6">
                <div class="text-xl font-semibold">
                    Question <span id="question-counter">1</span>/20
                </div>
                <div class="flex items-center">
                    <i data-feather="clock" class="w-5 h-5 mr-2"></i>
                    <span id="timer" class="text-xl font-bold">02:00</span>
                </div>
            </div>

            <div class="bg-white/10 backdrop-blur-md rounded-xl p-6 shadow-xl border border-white/20">
                <!-- Progress Bar -->
                <div class="h-3 bg-white/20 rounded-full mb-6">
                    <div id="progress-bar" class="progress-bar h-full bg-gradient-to-r from-blue-400 to-purple-500 rounded-full" style="width: 5%"></div>
                </div>

                <!-- Question -->
                <h2 id="question" class="text-2xl font-semibold mb-8"></h2>

                <!-- Options -->
                <div id="options" class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-8">
                    <!-- Options will be inserted here by JavaScript -->
                </div>

                <!-- Navigation -->
                <div class="flex justify-between">
                    <button id="prev-btn" class="bg-white/20 hover:bg-white/30 text-white font-medium py-2 px-6 rounded-lg transition-all duration-200 hidden">
                        <i data-feather="arrow-left" class="inline mr-2"></i> Previous
                    </button>
                    <button id="next-btn" class="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white font-medium py-2 px-6 rounded-lg transition-all duration-200 ml-auto">
                        Next <i data-feather="arrow-right" class="inline ml-2"></i>
                    </button>
                    <button id="submit-btn" class="bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-6 rounded-lg transition-all duration-200 hidden">
                        Submit <i data-feather="check" class="inline ml-2"></i>
                    </button>
                </div>
            </div>
        </div>

        <!-- Results Screen -->
        <div id="results-screen" class="hidden max-w-2xl mx-auto mt-16 text-center">
            <div class="bg-white/10 backdrop-blur-md rounded-xl p-8 shadow-2xl border border-white/20" data-aos="zoom-in">
                <h2 class="text-3xl font-bold mb-6">Quiz Completed!</h2>
                <div class="text-5xl font-bold mb-6 text-transparent bg-clip-text bg-gradient-to-r from-blue-300 to-purple-300">
                    <span id="score">0</span>/20
                </div>
                <div class="text-xl mb-8">
                    <span id="percentage">0</span>% Correct
                </div>
                <div class="h-4 bg-white/20 rounded-full mb-8">
                    <div id="score-bar" class="h-full bg-gradient-to-r from-blue-400 to-purple-500 rounded-full" style="width: 0%"></div>
                </div>
                <div class="mb-8">
                    <p id="feedback" class="text-lg"></p>
                </div>
                <button id="restart-btn" class="bg-gradient-to-r from-blue-500 to-purple-600 hover:from-blue-600 hover:to-purple-700 text-white font-bold py-3 px-8 rounded-full text-lg transition-all duration-300 transform hover:scale-105 shadow-lg">
                    Try Again <i data-feather="refresh-cw" class="inline ml-2"></i>
                </button>
            </div>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', () => {
            feather.replace();
            AOS.init();

            // Quiz questions
            const questions = [
                {
                    question: "What is the full form of WWW?",
                    options: [
                        "World Wide Web",
                        "Web World Wide",
                        "Wide World Web",
                        "World Web Wide"
                    ],
                    answer: 0
                },
                {
                    question: "Which key is used to refresh a webpage?",
                    options: [
                        "F1",
                        "F5",
                        "F9",
                        "F12"
                    ],
                    answer: 1
                },
                {
                    question: "What is the main purpose of a mouse?",
                    options: [
                        "Typing",
                        "Pointing and clicking",
                        "Printing",
                        "Scanning"
                    ],
                    answer: 1
                },
                {
                    question: "Which of these is NOT an input device?",
                    options: [
                        "Keyboard",
                        "Mouse",
                        "Monitor",
                        "Scanner"
                    ],
                    answer: 2
                },
                {
                    question: "What does USB stand for?",
                    options: [
                        "Universal Serial Bus",
                        "United Serial Bus",
                        "Universal System Bus",
                        "United System Bus"
                    ],
                    answer: 0
                },
                {
                    question: "Which company created Windows?",
                    options: [
                        "Apple",
                        "Microsoft",
                        "Google",
                        "IBM"
                    ],
                    answer: 1
                },
                {
                    question: "What is the default extension for Word documents?",
                    options: [
                        ".txt",
                        ".docx",
                        ".pdf",
                        ".xlsx"
                    ],
                    answer: 1
                },
                {
                    question: "Which program is used for spreadsheets?",
                    options: [
                        "Word",
                        "PowerPoint",
                        "Excel",
                        "Access"
                    ],
                    answer: 2
                },
                {
                    question: "What is the shortcut to copy text?",
                    options: [
                        "Ctrl+A",
                        "Ctrl+C",
                        "Ctrl+V",
                        "Ctrl+X"
                    ],
                    answer: 1
                },
                {
                    question: "Which of these is a web browser?",
                    options: [
                        "Photoshop",
                        "Chrome",
                        "Word",
                        "Excel"
                    ],
                    answer: 1
                },
                {
                    question: "What is the function of the 'Delete' key?",
                    options: [
                        "Move cursor left",
                        "Remove text to the right",
                        "Create new line",
                        "Save document"
                    ],
                    answer: 1
                },
                {
                    question: "Which folder contains deleted files?",
                    options: [
                        "Downloads",
                        "Documents",
                        "Recycle Bin",
                        "Desktop"
                    ],
                    answer: 2
                },
                {
                    question: "What does PDF stand for?",
                    options: [
                        "Portable Document Format",
                        "Personal Document File",
                        "Printed Document Format",
                        "Public Document File"
                    ],
                    answer: 0
                },
                {
                    question: "Which key combination opens Task Manager?",
                    options: [
                        "Ctrl+Alt+Delete",
                        "Shift+Alt+Delete",
                        "Ctrl+Shift+Esc",
                        "Both 1 and 3"
                    ],
                    answer: 3
                },
                {
                    question: "What is the purpose of a screensaver?",
                    options: [
                        "Improve performance",
                        "Prevent screen burn-in",
                        "Increase brightness",
                        "Show notifications"
                    ],
                    answer: 1
                },
                {
                    question: "Which of these is a social media platform?",
                    options: [
                        "Word",
                        "Excel",
                        "Facebook",
                        "Photoshop"
                    ],
                    answer: 2
                },
                {
                    question: "What does 'CC' mean in email?",
                    options: [
                        "Carbon Copy",
                        "Computer Copy",
                        "Central Copy",
                        "Client Copy"
                    ],
                    answer: 0
                },
                {
                    question: "Which device connects computers to the internet?",
                    options: [
                        "Printer",
                        "Scanner",
                        "Modem",
                        "Speaker"
                    ],
                    answer: 2
                },
                {
                    question: "What is the function of the 'Caps Lock' key?",
                    options: [
                        "Delete text",
                        "Type in uppercase",
                        "Open calculator",
                        "Save document"
                    ],
                    answer: 1
                },
                {
                    question: "Which of these is a search engine?",
                    options: [
                        "Facebook",
                        "Google",
                        "WhatsApp",
                        "Instagram"
                    ],
                    answer: 1
                }
            ];

            // Quiz state
            let currentQuestion = 0;
            let score = 0;
            let timeLeft = 120; // 2 minutes in seconds
            let timer;
            let userAnswers = Array(questions.length).fill(null);

            // DOM elements
            const startScreen = document.getElementById('start-screen');
            const quizScreen = document.getElementById('quiz-screen');
            const resultsScreen = document.getElementById('results-screen');
            const startBtn = document.getElementById('start-btn');
            const prevBtn = document.getElementById('prev-btn');
            const nextBtn = document.getElementById('next-btn');
            const submitBtn = document.getElementById('submit-btn');
            const restartBtn = document.getElementById('restart-btn');
            const questionCounter = document.getElementById('question-counter');
            const timerElement = document.getElementById('timer');
            const progressBar = document.getElementById('progress-bar');
            const questionElement = document.getElementById('question');
            const optionsContainer = document.getElementById('options');
            const scoreElement = document.getElementById('score');
            const percentageElement = document.getElementById('percentage');
            const scoreBar = document.getElementById('score-bar');
            const feedbackElement = document.getElementById('feedback');

            // Start quiz
            startBtn.addEventListener('click', startQuiz);

            function startQuiz() {
                startScreen.classList.add('hidden');
                quizScreen.classList.remove('hidden');
                startTimer();
                showQuestion();
            }

            // Timer function
            function startTimer() {
                updateTimerDisplay();
                timer = setInterval(() => {
                    timeLeft--;
                    updateTimerDisplay();
                    
                    if (timeLeft <= 0) {
                        clearInterval(timer);
                        endQuiz();
                    }
                }, 1000);
            }

            function updateTimerDisplay() {
                const minutes = Math.floor(timeLeft / 60);
                const seconds = timeLeft % 60;
                timerElement.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
                
                // Change color when time is running low
                if (timeLeft <= 30) {
                    timerElement.classList.add('text-red-400', 'animate-pulse');
                } else {
                    timerElement.classList.remove('text-red-400', 'animate-pulse');
                }
            }

            // Show question
            function showQuestion() {
                const question = questions[currentQuestion];
                questionElement.textContent = question.question;
                questionCounter.textContent = currentQuestion + 1;
                
                // Update progress bar
                const progress = ((currentQuestion + 1) / questions.length) * 100;
                progressBar.style.width = `${progress}%`;
                
                // Clear previous options
                optionsContainer.innerHTML = '';
                
                // Add new options
                question.options.forEach((option, index) => {
                    const optionElement = document.createElement('button');
                    optionElement.className = `option bg-white/10 hover:bg-white/20 border border-white/20 rounded-lg p-4 text-left transition-all duration-200 ${userAnswers[currentQuestion] === index ? 'bg-blue-500/30 border-blue-400' : ''}`;
                    optionElement.textContent = option;
                    optionElement.addEventListener('click', () => selectOption(index));
                    optionsContainer.appendChild(optionElement);
                });
                
                // Update navigation buttons
                prevBtn.classList.toggle('hidden', currentQuestion === 0);
                nextBtn.classList.toggle('hidden', currentQuestion === questions.length - 1);
                submitBtn.classList.toggle('hidden', currentQuestion !== questions.length - 1);
            }

            // Select option
            function selectOption(optionIndex) {
                userAnswers[currentQuestion] = optionIndex;
                
                // Highlight selected option
                const options = optionsContainer.querySelectorAll('.option');
                options.forEach((option, index) => {
                    if (index === optionIndex) {
                        option.classList.add('bg-blue-500/30', 'border-blue-400');
                    } else {
                        option.classList.remove('bg-blue-500/30', 'border-blue-400');
                    }
                });
            }

            // Navigation
            prevBtn.addEventListener('click', () => {
                if (currentQuestion > 0) {
                    currentQuestion--;
                    showQuestion();
                }
            });

            nextBtn.addEventListener('click', () => {
                if (currentQuestion < questions.length - 1) {
                    currentQuestion++;
                    showQuestion();
                }
            });

            submitBtn.addEventListener('click', endQuiz);

            // End quiz
            function endQuiz() {
                clearInterval(timer);
                quizScreen.classList.add('hidden');
                resultsScreen.classList.remove('hidden');
                
                // Calculate score
                score = 0;
                userAnswers.forEach((answer, index) => {
                    if (answer === questions[index].answer) {
                        score++;
                    }
                });
                
                const percentage = Math.round((score / questions.length) * 100);
                
                // Display results
                scoreElement.textContent = score;
                percentageElement.textContent = percentage;
                scoreBar.style.width = `${percentage}%`;
                
                // Provide feedback
                if (percentage >= 80) {
                    feedbackElement.textContent = "Excellent! You have a strong understanding of computer diploma concepts.";
                } else if (percentage >= 60) {
                    feedbackElement.textContent = "Good job! You have a solid foundation but could use some more practice.";
                } else if (percentage >= 40) {
                    feedbackElement.textContent = "Not bad! Consider reviewing some key concepts to improve.";
                } else {
                    feedbackElement.textContent = "Keep practicing! Review the material and try again.";
                }
            }

            // Restart quiz
            restartBtn.addEventListener('click', () => {
                currentQuestion = 0;
                score = 0;
                timeLeft = 120;
                userAnswers = Array(questions.length).fill(null);
                
                resultsScreen.classList.add('hidden');
                startScreen.classList.remove('hidden');
                
                // Reset timer display
                timerElement.classList.remove('text-red-400', 'animate-pulse');
            });
        });
    </script>
    <script>feather.replace();</script>
    <script>AOS.init();</script>
</body>
</html>