File size: 31,330 Bytes
672cf86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHSSW Watlar - Cognitive Science Assessment (Grades 4-12)</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .progress-bar {
            height: 10px;
            transition: width 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .fade-in {
            animation: fadeIn 0.5s ease-in;
        }
        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen font-sans">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="bg-gradient-to-r from-blue-600 to-indigo-800 text-white rounded-xl shadow-lg mb-8 overflow-hidden">
            <div class="flex flex-col md:flex-row items-center justify-between p-6">
                <div class="flex items-center mb-4 md:mb-0">
                    <i class="fas fa-flask text-3xl mr-3"></i>
                    <div>
                        <h1 class="text-2xl font-bold">PHSSW Watlar</h1>
                        <p class="text-blue-100">Cognitive Science Assessment</p>
                    </div>
                </div>
                <div id="user-info" class="bg-white bg-opacity-20 px-4 py-2 rounded-full flex items-center">
                    <i class="fas fa-user-circle mr-2"></i>
                    <span id="student-name">Guest Student</span>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <main>
            <!-- Welcome Screen -->
            <div id="welcome-screen" class="bg-white rounded-xl shadow-md p-6 mb-8 fade-in">
                <div class="text-center py-8">
                    <i class="fas fa-atom text-6xl text-indigo-600 mb-6"></i>
                    <h2 class="text-3xl font-bold text-gray-800 mb-4">Science Aptitude Test</h2>
                    <p class="text-gray-600 mb-8 max-w-2xl mx-auto">
                        This assessment measures your cognitive abilities in science including pattern recognition, 
                        data interpretation, logical reasoning and conceptual understanding. Appropriate for 
                        students in grades 4-12. You will have 45 minutes to complete the test.
                    </p>
                    <div class="flex flex-col sm:flex-row justify-center gap-4 mb-8">
                        <button id="start-test" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-3 px-6 rounded-lg transition duration-300 flex items-center">
                            <i class="fas fa-play mr-2"></i> Start Test
                        </button>
                        <button id="instructions-btn" class="bg-white hover:bg-gray-100 text-gray-800 font-medium py-3 px-6 rounded-lg border border-gray-300 transition duration-300 flex items-center">
                            <i class="fas fa-info-circle mr-2"></i> Instructions
                        </button>
                    </div>
                </div>
            </div>

            <!-- Instructions Modal -->
            <div id="instructions-modal" class="hidden fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
                <div class="bg-white rounded-xl shadow-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto">
                    <div class="p-6">
                        <div class="flex justify-between items-center mb-4">
                            <h3 class="text-2xl font-bold text-indigo-700">Test Instructions</h3>
                            <button id="close-instructions" class="text-gray-500 hover:text-gray-700">
                                <i class="fas fa-times text-xl"></i>
                            </button>
                        </div>
                        <div class="space-y-4 text-gray-700">
                            <div class="flex items-start">
                                <i class="fas fa-clock text-indigo-500 mt-1 mr-3"></i>
                                <p>The test duration is 30 minutes with 50 multiple-choice questions.</p>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-check-circle text-indigo-500 mt-1 mr-3"></i>
                                <p>Select the best answer for each question. You cannot go back to previous questions.</p>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-calculator text-indigo-500 mt-1 mr-3"></i>
                                <p>Some questions may require calculations. Use paper for scratch work.</p>
                            </div>
                            <div class="flex items-start">
                                <i class="fas fa-ban text-indigo-500 mt-1 mr-3"></i>
                                <p>Do not refresh the page or use other browser tabs during the test.</p>
                            </div>
                            <div class="pt-4 border-t border-gray-200 italic text-sm">
                                <p>Your answers will be automatically saved. The results will be shown immediately after completion.</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Test Screen (hidden initially) -->
            <div id="test-screen" class="hidden fade-in">
                <!-- Test Header -->
                <div class="bg-white rounded-xl shadow-md p-4 mb-6 sticky top-0 z-10">
                    <div class="flex flex-col md:flex-row justify-between items-center">
                        <div class="flex items-center mb-3 md:mb-0">
                            <div id="timer" class="bg-red-100 text-red-700 px-3 py-1 rounded-full font-bold mr-4">
                                <i class="fas fa-clock mr-1"></i>
                                <span>30:00</span>
                            </div>
                            <div id="question-counter" class="text-gray-600">
                                Question <span id="current-question">1</span> of <span>50</span>
                            </div>
                        </div>
                        <div class="w-full md:w-auto md:min-w-[200px] flex-grow md:flex-grow-0">
                            <div class="h-3 bg-gray-200 rounded-full overflow-hidden">
                                <div id="progress-bar" class="progress-bar bg-indigo-600" style="width: 2%"></div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Question Container -->
                <div id="question-container" class="bg-white rounded-xl shadow-md p-6 mb-6">
                    <div id="question-text" class="text-lg font-medium mb-6">
                        Loading question...
                    </div>
                    <div id="options-container" class="space-y-3">
                        <div class="option-item flex items-center p-4 border border-gray-200 rounded-lg hover:bg-gray-50 cursor-pointer transition card-hover">
                            <div class="w-6 h-6 rounded-full border border-gray-300 mr-3 flex-shrink-0"></div>
                            <div class="option-text">Loading options...</div>
                        </div>
                    </div>
                </div>

                <!-- Navigation Buttons -->
                <div class="flex justify-between">
                    <button id="prev-btn" class="bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium py-2 px-6 rounded-lg transition duration-300 opacity-50 cursor-not-allowed" disabled>
                        <i class="fas fa-arrow-left mr-2"></i> Previous
                    </button>
                    <button id="next-btn" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-lg transition duration-300">
                        Next <i class="fas fa-arrow-right ml-2"></i>
                    </button>
                </div>
            </div>

            <!-- Result Screen (hidden initially) -->
            <div id="result-screen" class="hidden bg-white rounded-xl shadow-md p-8 text-center fade-in">
                <div class="max-w-2xl mx-auto">
                    <div class="w-24 h-24 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6">
                        <i class="fas fa-trophy text-green-500 text-4xl"></i>
                    </div>
                    <h2 class="text-3xl font-bold text-gray-800 mb-4">Test Completed!</h2>
                    <p class="text-gray-600 mb-8">Your assessment results are ready.</p>
                    
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
                        <div class="bg-blue-50 p-4 rounded-xl">
                            <div class="text-3xl font-bold text-blue-600 mb-2" id="score-display">0</div>
                            <div class="text-gray-600">Total Score</div>
                        </div>
                        <div class="bg-green-50 p-4 rounded-xl">
                            <div class="text-3xl font-bold text-green-600 mb-2" id="correct-answers">0</div>
                            <div class="text-gray-600">Correct Answers</div>
                        </div>
                        <div class="bg-orange-50 p-4 rounded-xl">
                            <div class="text-3xl font-bold text-orange-600 mb-2" id="time-taken">00:00</div>
                            <div class="text-gray-600">Time Taken</div>
                        </div>
                    </div>
                    
                    <div class="mb-8">
                        <h3 class="text-xl font-semibold text-gray-800 mb-4">Aptitude Areas</h3>
                        <div class="space-y-4">
                            <div>
                                <div class="flex justify-between mb-1">
                                    <span class="text-gray-700">Scientific Reasoning</span>
                                    <span class="text-gray-700"><span id="reasoning-percent">0</span>%</span>
                                </div>
                                <div class="w-full bg-gray-200 rounded-full h-2.5">
                                    <div id="reasoning-bar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between mb-1">
                                    <span class="text-gray-700">Problem Solving</span>
                                    <span class="text-gray-700"><span id="problem-percent">0</span>%</span>
                                </div>
                                <div class="w-full bg-gray-200 rounded-full h-2.5">
                                    <div id="problem-bar" class="bg-green-600 h-2.5 rounded-full" style="width: 0%"></div>
                                </div>
                            </div>
                            <div>
                                <div class="flex justify-between mb-1">
                                    <span class="text-gray-700">Conceptual Understanding</span>
                                    <span class="text-gray-700"><span id="concept-percent">0</span>%</span>
                                </div>
                                <div class="w-full bg-gray-200 rounded-full h-2.5">
                                    <div id="concept-bar" class="bg-indigo-600 h-2.5 rounded-full" style="width: 0%"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <button id="retake-test" class="bg-indigo-600 hover:bg-indigo-700 text-white font-medium py-2 px-6 rounded-lg transition duration-300 inline-block mr-3">
                        <i class="fas fa-redo mr-2"></i> Retake Test
                    </button>
                    <button id="review-answers" class="bg-white hover:bg-gray-100 text-gray-800 font-medium py-2 px-6 rounded-lg border border-gray-300 transition duration-300 inline-block">
                        <i class="fas fa-list-ul mr-2"></i> Review Answers
                    </button>
                </div>
            </div>
        </main>
        
        <footer class="text-center text-gray-500 text-sm mt-12 pb-6">
            <p>© 2023 PHSSW Watlar Cognitive Assessment</p>
            <p class="mt-1">Free educational resource - Version 2.0</p>
        </footer>
    </div>

    <script>
        // Constants
        const TOTAL_QUESTIONS = 40; // 10 per grade band (4-6, 7-9, 10-12)
        const TEST_DURATION = 45 * 60; // 45 minutes in seconds
        const AREAS = ['Pattern Recognition', 'Data Interpretation', 'Logical Reasoning', 'Conceptual Understanding'];
        
        // DOM Elements
        const welcomeScreen = document.getElementById('welcome-screen');
        const testScreen = document.getElementById('test-screen');
        const resultScreen = document.getElementById('result-screen');
        const instructionsModal = document.getElementById('instructions-modal');
        const questionText = document.getElementById('question-text');
        const optionsContainer = document.getElementById('options-container');
        const progressBar = document.getElementById('progress-bar');
        const questionCounter = document.getElementById('current-question');
        const timerDisplay = document.querySelector('#timer span');
        const scoreDisplay = document.getElementById('score-display');
        const correctAnswersDisplay = document.getElementById('correct-answers');
        const timeTakenDisplay = document.getElementById('time-taken');
        const reasoningPercent = document.getElementById('reasoning-percent');
        const problemPercent = document.getElementById('problem-percent');
        const conceptPercent = document.getElementById('concept-percent');
        const reasoningBar = document.getElementById('reasoning-bar');
        const problemBar = document.getElementById('problem-bar');
        const conceptBar = document.getElementById('concept-bar');
        
        // Buttons
        const startTestBtn = document.getElementById('start-test');
        const instructionsBtn = document.getElementById('instructions-btn');
        const closeInstructionsBtn = document.getElementById('close-instructions');
        const prevBtn = document.getElementById('prev-btn');
        const nextBtn = document.getElementById('next-btn');
        const retakeTestBtn = document.getElementById('retake-test');
        const reviewAnswersBtn = document.getElementById('review-answers');
        
        // State variables
        let currentQuestion = 1;
        let timer = TEST_DURATION;
        let startTime;
        let answers = [];
        let testQuestions = [];
        
        // Generate sample questions (in a real app, these would come from a database)
        function generateQuestions() {
            const questions = [];
            
            // Cognitive science questions across difficulty levels (grade 4-12)
            const cognitiveQuestions = [
                // Pattern Recognition
                {
                    id: 1,
                    text: "What comes next in this pattern: ○□△○□△○□___",
                    options: ["△", "○", "□", "▽"],
                    correct: 0,
                    area: 0,
                    difficulty: 'easy'
                },
                {
                    id: 2,
                    text: "Look at the number sequence: 2, 4, 8, 16, ___ What comes next?",
                    options: ["24", "32", "64", "128"],
                    correct: 1,
                    area: 0,
                    difficulty: 'medium'
                },
                
                // Data Interpretation
                {
                    id: 3,
                    text: "A plant grows 2cm each week. How tall will it be after 5 weeks?",
                    options: ["7cm", "10cm", "12cm", "15cm"],
                    correct: 1,
                    area: 1,
                    difficulty: 'easy'
                },
                {
                    id: 2,
                    text: "Which of the following best describes the scientific method?",
                    options: [
                        "A fixed set of steps that all scientists follow",
                        "A process that always proves hypotheses correct",
                        "A systematic approach to problem-solving and discovery",
                        "A method only used in laboratory settings"
                    ],
                    correct: 2,
                    area: 0,
                    difficulty: 'medium'
                },
                {
                    id: 3,
                    text: "A scientist observes that plants grow taller when given more light. This is an example of:",
                    options: [
                        "A hypothesis",
                        "An independent variable",
                        "A conclusion",
                        "An observation"
                    ],
                    correct: 3,
                    area: 0,
                    difficulty: 'easy'
                },
                
                // Problem Solving
                {
                    id: 4,
                    text: "If an object has a mass of 10 kg and is moving at 5 m/s, what is its kinetic energy? (KE = ½mv²)",
                    options: [
                        "25 J",
                        "50 J",
                        "125 J",
                        "250 J"
                    ],
                    correct: 2,
                    area: 1,
                    difficulty: 'medium'
                },
                {
                    id: 5,
                    text: "A solution has a pH of 3. How much more acidic is it than a solution with pH 6?",
                    options: [
                        "2 times",
                        "10 times",
                        "100 times",
                        "1000 times"
                    ],
                    correct: 3,
                    area: 1,
                    difficulty: 'hard'
                },
                {
                    id: 6,
                    text: "How many oxygen atoms are in 2 molecules of H₂SO₄?",
                    options: [
                        "2",
                        "4",
                        "6",
                        "8"
                    ],
                    correct: 3,
                    area: 1,
                    difficulty: 'medium'
                },
                
                // Conceptual Understanding
                {
                    id: 7,
                    text: "Which of these correctly describes Newton's Third Law of Motion?",
                    options: [
                        "Force equals mass times acceleration",
                        "An object in motion stays in motion unless acted upon",
                        "For every action there is an equal and opposite reaction",
                        "The force of gravity is proportional to mass"
                    ],
                    correct: 2,
                    area: 2,
                    difficulty: 'easy'
                },
                {
                    id: 8,
                    text: "In the periodic table, elements in the same group (column) have:",
                    options: [
                        "Similar atomic masses",
                        "The same number of electron shells",
                        "Similar chemical properties",
                        "The same number of protons"
                    ],
                    correct: 2,
                    area: 2,
                    difficulty: 'medium'
                },
                {
                    id: 9,
                    text: "Photosynthesis converts:",
                    options: [
                        "Solar energy to chemical energy",
                        "Chemical energy to kinetic energy",
                        "Thermal energy to electrical energy",
                        "Potential energy to mechanical energy"
                    ],
                    correct: 0,
                    area: 2,
                    difficulty: 'easy'
                },
                {
                    id: 10,
                    text: "Which of these is NOT a characteristic of living organisms?",
                    options: [
                        "Growth and development",
                        "Response to stimuli",
                        "Ability to reproduce",
                        "Maintenance of constant size"
                    ],
                    correct: 3,
                    area: 2,
                    difficulty: 'medium'
                }
            ];
            
            // Fill the rest with random questions for demo purposes
            while (questions.length < TOTAL_QUESTIONS) {
                const randomIndex = Math.floor(Math.random() * scienceQuestions.length);
                questions.push({...scienceQuestions[randomIndex], id: questions.length + 1});
            }
            
            return questions;
        }
        
        // Initialize the test
        function initTest() {
            // Reset state
            currentQuestion = 1;
            timer = TEST_DURATION;
            answers = [];
            testQuestions = generateQuestions();
            
            // Set timer
            updateTimerDisplay();
            window.timerInterval = setInterval(updateTimer, 1000);
            
            // Show first question
            showQuestion(currentQuestion);
            
            // Update progress bar
            updateProgress();
            
            // Switch screens
            welcomeScreen.classList.add('hidden');
            testScreen.classList.remove('hidden');
            resultScreen.classList.add('hidden');
            
            // Record start time
            startTime = new Date();
        }
        
        // Show question
        function showQuestion(questionIndex) {
            // Update question counter
            questionCounter.textContent = questionIndex;
            
            // Get current question
            const question = testQuestions[questionIndex - 1];
            
            // Set question text
            questionText.textContent = `${questionIndex}. ${question.text}`;
            
            // Clear previous options
            optionsContainer.innerHTML = '';
            
            // Add new options
            question.options.forEach((option, index) => {
                const optionElement = document.createElement('div');
                optionElement.className = `option-item flex items-center p-4 border border-gray-200 rounded-lg hover:bg-gray-50 cursor-pointer transition card-hover`;
                optionElement.dataset.optionIndex = index;
                
                // Check if this option was previously selected
                const userAnswer = answers.find(a => a.questionId === question.id);
                const isSelected = userAnswer && userAnswer.answer === index;
                const isCorrect = index === question.correct;
                
                // If viewing results (not implemented fully in this demo)
                if (isSelected) {
                    optionElement.classList.add('bg-blue-50', 'border-blue-300');
                }
                
                optionElement.innerHTML = `
                    <div class="w-6 h-6 rounded-full border-2 ${isSelected ? 'border-blue-500 bg-blue-500 text-white flex items-center justify-center' : 'border-gray-300'} mr-3 flex-shrink-0">
                        ${isSelected ? (isCorrect ? '<i class="fas fa-check text-xs"></i>' : '<i class="fas fa-times text-xs"></i>') : ''}
                    </div>
                    <div class="option-text">${option}</div>
                `;
                
                optionElement.addEventListener('click', () => selectOption(questionIndex, index));
                optionsContainer.appendChild(optionElement);
            });
            
            // Update nav buttons
            prevBtn.disabled = questionIndex === 1;
            nextBtn.textContent = questionIndex === TOTAL_QUESTIONS ? 'Submit Test' : 'Next';
        }
        
        // Select option
        function selectOption(questionIndex, optionIndex) {
            const question = testQuestions[questionIndex - 1];
            
            // Remove previous answer if exists
            answers = answers.filter(a => a.questionId !== question.id);
            
            // Add new answer
            answers.push({
                questionId: question.id,
                answer: optionIndex,
                correct: optionIndex === question.correct,
                area: question.area
            });
            
            // Update UI to show selection
            showQuestion(currentQuestion);
        }
        
        // Update progress bar
        function updateProgress() {
            const progress = (currentQuestion / TOTAL_QUESTIONS) * 100;
            progressBar.style.width = `${progress}%`;
        }
        
        // Timer functions
        function updateTimer() {
            timer--;
            updateTimerDisplay();
            
            if (timer <= 0) {
                clearInterval(window.timerInterval);
                finishTest();
            }
        }
        
        function updateTimerDisplay() {
            const minutes = Math.floor(timer / 60);
            const seconds = timer % 60;
            timerDisplay.textContent = `${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`;
            
            // Change color when time is running low
            if (timer <= 300) { // 5 minutes
                document.getElementById('timer').classList.remove('bg-red-100', 'text-red-700');
                document.getElementById('timer').classList.add('bg-red-500', 'text-white');
            }
        }
        
        // Calculate time taken
        function getTimeTaken() {
            const endTime = new Date();
            const timeDiffMs = endTime - startTime;
            const minutes = Math.floor(timeDiffMs / 60000);
            const seconds = Math.floor((timeDiffMs % 60000) / 1000);
            
            return `${minutes < 10 ? '0' + minutes : minutes}:${seconds < 10 ? '0' + seconds : seconds}`;
        }
        
        // Finish test and show results
        function finishTest() {
            clearInterval(window.timerInterval);
            
            // Calculate results
            const correctCount = answers.filter(a => a.correct).length;
            const score = Math.round((correctCount / TOTAL_QUESTIONS) * 1000);
            
            // Calculate area percentages
            const areaCounts = [0, 0, 0]; // [reasoning, problem, concept]
            const areaCorrect = [0, 0, 0];
            
            answers.forEach(answer => {
                areaCounts[answer.area]++;
                if (answer.correct) {
                    areaCorrect[answer.area]++;
                }
            });
            
            const reasoningPercentValue = areaCounts[0] ? Math.round((areaCorrect[0] / areaCounts[0]) * 100) : 0;
            const problemPercentValue = areaCounts[1] ? Math.round((areaCorrect[1] / areaCounts[1]) * 100) : 0;
            const conceptPercentValue = areaCounts[2] ? Math.round((areaCorrect[2] / areaCounts[2]) * 100) : 0;
            
            // Update UI with results
            scoreDisplay.textContent = score;
            correctAnswersDisplay.textContent = correctCount;
            timeTakenDisplay.textContent = getTimeTaken();
            
            reasoningPercent.textContent = reasoningPercentValue;
            problemPercent.textContent = problemPercentValue;
            conceptPercent.textContent = conceptPercentValue;
            
            reasoningBar.style.width = `${reasoningPercentValue}%`;
            problemBar.style.width = `${problemPercentValue}%`;
            conceptBar.style.width = `${conceptPercentValue}%`;
            
            // Show result screen
            testScreen.classList.add('hidden');
            resultScreen.classList.remove('hidden');
        }
        
        // Event listeners
        startTestBtn.addEventListener('click', initTest);
        
        instructionsBtn.addEventListener('click', () => {
            instructionsModal.classList.remove('hidden');
        });
        
        closeInstructionsBtn.addEventListener('click', () => {
            instructionsModal.classList.add('hidden');
        });
        
        prevBtn.addEventListener('click', () => {
            if (currentQuestion > 1) {
                currentQuestion--;
                showQuestion(currentQuestion);
                updateProgress();
            }
        });
        
        nextBtn.addEventListener('click', () => {
            if (currentQuestion < TOTAL_QUESTIONS) {
                currentQuestion++;
                showQuestion(currentQuestion);
                updateProgress();
            } else {
                finishTest();
            }
        });
        
        retakeTestBtn.addEventListener('click', () => {
            initTest();
        });
        
        reviewAnswersBtn.addEventListener('click', () => {
            alert('In a full implementation, this would show a detailed review of all questions and answers.');
        });
        
        // Close modal when clicking outside
        instructionsModal.addEventListener('click', (e) => {
            if (e.target === instructionsModal) {
                instructionsModal.classList.add('hidden');
            }
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=AARIFSHABIR/crispr" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>