-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
841 lines (745 loc) · 35.2 KB
/
Copy pathindex.html
File metadata and controls
841 lines (745 loc) · 35.2 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
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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Physics MCQ Quiz - Dimensions & Measurements</title>
<style>
/* CSS Variables for Themes */
:root {
--bg: #ffffff;
--card: #f8f9fa;
--text: #212529;
--accent: #0066cc;
--tint: #e6f0fa;
--explanation-bg: #f0f4f8;
--correct: #28a745;
--incorrect: #dc3545;
--border: #dee2e6;
--shadow: rgba(0,0,0,0.05);
}
[data-theme="dark"] {
--bg: #121212;
--card: #1e1e1e;
--text: #f5f5f5;
--accent: #3788d8;
--tint: #1a2d42;
--explanation-bg: #25282c;
--border: #333333;
--shadow: rgba(0,0,0,0.3);
}
/* Base Reset & Styling */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: 'Arial', 'Helvetica', sans-serif;
background-color: var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding: 20px;
transition: background-color 0.3s ease, color 0.3s ease;
}
/* Main Container Layout */
.quiz-wrapper {
width: 100%;
max-width: 650px;
margin: auto;
}
/* Prominent Header Title */
.main-title {
text-align: center;
margin-bottom: 25px;
font-size: 2.2rem;
font-weight: 800;
color: var(--accent);
text-transform: uppercase;
letter-spacing: 1.5px;
}
.quiz-container {
background-color: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 30px;
box-shadow: 0 4px 12px var(--shadow);
position: relative;
width: 100%;
}
/* Header Control Widgets */
.quiz-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 25px;
padding-bottom: 15px;
border-bottom: 1px solid var(--border);
}
.btn-control {
background-color: transparent;
color: var(--text);
border: 1px solid var(--border);
padding: 8px 14px;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
font-size: 0.9rem;
transition: all 0.2s ease;
}
.btn-control:hover {
background-color: var(--tint);
border-color: var(--accent);
}
/* Question Section */
.question-meta {
font-size: 0.9rem;
color: var(--accent);
font-weight: bold;
margin-bottom: 10px;
}
.question-text {
font-size: 1.15rem;
line-height: 1.5;
margin-bottom: 20px;
font-weight: 600;
}
/* Options Selection */
.options-list {
list-style: none;
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 25px;
}
.option-label {
display: flex;
align-items: center;
padding: 14px 18px;
border: 1px solid var(--border);
border-radius: 8px;
cursor: pointer;
transition: all 0.2s ease;
width: 100%;
}
.option-label:hover {
background-color: var(--tint);
border-color: var(--accent);
}
.option-label input[type="radio"] {
margin-right: 14px;
width: 18px;
height: 18px;
accent-color: var(--accent);
cursor: pointer;
}
.option-label.selected {
background-color: var(--tint);
border-color: var(--accent);
font-weight: bold;
}
/* Footer Navigation Controls */
.quiz-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20px;
padding-top: 15px;
border-top: 1px solid var(--border);
}
.btn-nav {
background-color: var(--accent);
color: #ffffff;
border: none;
padding: 10px 22px;
border-radius: 6px;
font-weight: bold;
cursor: pointer;
font-size: 1rem;
transition: opacity 0.2s ease;
}
.btn-nav:hover {
opacity: 0.9;
}
.btn-nav:disabled {
background-color: var(--border);
color: var(--text);
opacity: 0.5;
cursor: not-allowed;
}
/* Unsolved List Center Modal Layout */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 1000;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
}
.modal-overlay.open {
opacity: 1;
pointer-events: auto;
}
.modal-content {
background-color: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 25px;
width: 90%;
max-width: 450px;
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
text-align: center;
transform: scale(0.9);
transition: transform 0.3s ease;
}
.modal-overlay.open .modal-content {
transform: scale(1);
}
.modal-title {
font-size: 1.2rem;
margin-bottom: 20px;
font-weight: bold;
}
.unsolved-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 10px;
margin-bottom: 25px;
max-height: 250px;
overflow-y: auto;
padding: 5px;
}
.grid-item {
background-color: var(--bg);
border: 1px solid var(--border);
padding: 10px 0;
border-radius: 6px;
cursor: pointer;
font-weight: bold;
transition: all 0.2s ease;
}
.grid-item:hover {
background-color: var(--tint);
border-color: var(--accent);
}
.grid-item.answered {
opacity: 0.5;
font-weight: normal;
}
/* Advanced Results Panel Styling */
.results-view {
display: none;
}
.scorecard-panel {
background-color: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 25px;
margin-bottom: 30px;
box-shadow: 0 4px 10px var(--shadow);
}
.scorecard-title {
font-size: 1.4rem;
font-weight: bold;
margin-bottom: 15px;
border-bottom: 2px solid var(--accent);
padding-bottom: 8px;
}
.metrics-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
font-size: 0.95rem;
}
.metrics-table td {
padding: 8px 0;
border-bottom: 1px solid var(--border);
}
.metrics-table td:last-child {
text-align: right;
font-weight: bold;
}
.score-percentage {
font-size: 1.6rem;
color: var(--accent);
font-weight: bold;
text-align: center;
margin: 15px 0;
}
/* Review Sheet Layout */
.review-sheet {
display: flex;
flex-direction: column;
gap: 25px;
}
.review-card {
background-color: var(--card);
border: 1px solid var(--border);
border-radius: 10px;
padding: 20px;
}
.review-question-header {
font-weight: bold;
margin-bottom: 12px;
font-size: 1.05rem;
}
.review-option {
padding: 10px 14px;
border: 1px solid var(--border);
border-radius: 6px;
margin-bottom: 8px;
font-size: 0.95rem;
display: flex;
align-items: center;
justify-content: space-between;
}
.review-option.correct-choice {
background-color: rgba(40, 167, 69, 0.15);
border-color: var(--correct);
color: var(--correct);
font-weight: bold;
}
.review-option.incorrect-choice {
background-color: rgba(220, 53, 69, 0.15);
border-color: var(--incorrect);
color: var(--incorrect);
}
.explanation-box {
margin-top: 15px;
background-color: var(--explanation-bg);
border-left: 4px solid var(--accent);
padding: 12px 16px;
border-radius: 0 8px 8px 0;
font-size: 0.9rem;
line-height: 1.45;
}
.explanation-title {
font-weight: bold;
margin-bottom: 4px;
color: var(--text);
}
.status-badge {
font-weight: bold;
font-size: 0.8rem;
padding: 2px 8px;
border-radius: 4px;
text-transform: uppercase;
}
.status-badge.correct { background-color: var(--correct); color: white; }
.status-badge.incorrect { background-color: var(--incorrect); color: white; }
.status-badge.unattempted { background-color: #6c757d; color: white; }
/* Utilities */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.w-100 { width: 100%; }
</style>
</head>
<body>
<div class="quiz-wrapper">
<!-- Big Header Title Component -->
<h1 class="main-title">Prepared by CORE</h1>
<!-- Active Quiz Interface Section -->
<div id="quiz-view" class="quiz-container">
<div class="quiz-header">
<button id="btn-unsolved-trigger" class="btn-control" onclick="openUnsolvedModal()">Unsolved List</button>
<button id="btn-theme-toggle" class="btn-control" onclick="toggleTheme()">Dark Mode</button>
</div>
<div id="question-block">
<div id="question-meta" class="question-meta">Question 1 of 20</div>
<div id="question-text" class="question-text">Loading question content...</div>
<div id="options-container" class="options-list">
<!-- Javascript populates row options dynamically -->
</div>
</div>
<div class="quiz-footer">
<button id="btn-prev" class="btn-nav" onclick="navigateQuestion(-1)">Back</button>
<button id="btn-next" class="btn-nav" onclick="navigateQuestion(1)">Next</button>
</div>
</div>
<!-- Advanced Results Analysis View Section -->
<div id="results-view" class="results-view">
<div class="scorecard-panel">
<div class="scorecard-title">Quiz Performance Scorecard</div>
<div id="score-percent-display" class="score-percentage">0%</div>
<table class="metrics-table">
<tr><td>Total Multiple-Choice Questions</td><td id="m-total">20</td></tr>
<tr><td>Correct Answers Count</td><td id="m-correct" style="color: var(--correct);">0</td></tr>
<tr><td>Incorrect Answers Count</td><td id="m-incorrect" style="color: var(--incorrect);">0</td></tr>
<tr><td>Unattempted Questions Count</td><td id="m-unattempted" style="color: #6c757d;">0</td></tr>
<tr><td>Completion Date</td><td id="m-date">-</td></tr>
<tr><td>Time Submitted</td><td id="m-time">-</td></tr>
</table>
<button class="btn-nav w-100 text-center mt-20" onclick="restartQuiz()">Restart Quiz</button>
</div>
<div id="review-sheet-container" class="review-sheet">
<!-- Javascript will load the comprehensive sequential analysis here -->
</div>
</div>
</div>
<!-- Unsolved Center Modal Markup -->
<div id="unsolved-modal" class="modal-overlay" onclick="closeUnsolvedModal(event)">
<div class="modal-content" onclick="event.stopPropagation()">
<div class="modal-title">Unanswered Questions Grid</div>
<div id="unsolved-grid-container" class="unsolved-grid">
<!-- Grid map links rendered via JS -->
</div>
<button class="btn-control w-100" onclick="closeUnsolvedModal()">Close Matrix</button>
</div>
</div>
<script>
// Complete Quiz Dataset Array Configuration
const quizData = [
{
id: 1,
question: "The density of a cube is measured by measuring its mass and the length of its side. If the maximum errors in the measurement of mass and length are 3% and 2%, respectively, then maximum error in the measurement of density is:",
options: ["3%", "5%", "7%", "9%"],
correctIndex: 3,
explanation: "Density is formulated as ρ = m / V = m / l³. To determine the maximum relative fractional error compilation rules, exponents scale accumulated variances regardless of initial signs: (Δρ / ρ) = (Δm / m) + 3 × (Δl / l). Substituting values yields 3% + 3(2%) = 9% maximum structural variations."
},
{
id: 2,
question: "The dimensions of the relation √(F × l / m) are equal to the dimension of:",
options: ["Force", "Velocity", "Acceleration", "Work"],
correctIndex: 1,
explanation: "Dimensional configurations require tracking the values explicitly: Force [F] = [MLT⁻²], Length [l] = [L], and Mass [m] = [M]. Evaluating inside the radical yields: ([MLT⁻²] × [L]) / [M] = [L²T⁻²]. Extracting the square root returns [LT⁻¹], identifying purely as the standard dimensions of velocity."
},
{
id: 3,
question: "Which of the following is not a base unit in the S.I system?",
options: ["Metre", "Ampere", "Candela", "Radian"],
correctIndex: 3,
explanation: "Metre (length), Ampere (electrical current), and Candela (luminous intensity) represent standard baseline components within the seven physical metric systems. A radian characterizes a supplementary standard metric scale framework reserved strictly for measuring abstract planar geometric configurations."
},
{
id: 4,
question: "The number of significant zeros in the quantitative value 0.0001 is:",
options: ["Zero", "One", "Three", "Four"],
correctIndex: 0,
explanation: "According to mathematical precision tracking systems, leading zeros that immediately precede the first non-zero positional figure function exclusively as scaling fractional placeholders to define local decimal positioning. They do not denote measurement clarity; hence there are zero valid significant figures among them."
},
{
id: 5,
question: "While measuring acceleration due to gravity by a simple pendulum, a student makes a positive error of 1% in the length of the pendulum and a negative error of 3% in the value of time period. The percentage error in the measurement of g is:",
options: ["2%", "4%", "7%", "10%"],
correctIndex: 2,
explanation: "Arranging via the pendulum configuration isolating gravity yields g = 4π²l / T². When determining total upper uncertainty limitations across independent factors, all error metrics combine through absolute addition metrics: % error in g = (% error in l) + 2 × (% error in T). This yields 1% + 2(3%) = 7% absolute error boundary constraints."
},
{
id: 6,
question: "If pressure P, velocity v and time T are taken as fundamental physical quantities, then the dimensional formula of force is:",
options: ["P v² T²", "P⁻¹ v² T²", "P v⁻² T²", "P v² T⁻²"],
correctIndex: 0,
explanation: "By balancing relative systems, let Force F ∝ P^a × v^b × T^c. Substituting basic metric definitions gives [MLT⁻²] = [ML⁻¹T⁻²]^a × [LT⁻¹]^b × [T]^c = [M^a × L^(-a+b) × T^(-2a-b+c)]. Matching structural coefficients yields a = 1, b = 2, and c = 2, resulting in the configuration: P v² T²."
},
{
id: 7,
question: "The length, breadth and thickness of a sheet are 3.233 m, 2.105 m and 1.05 m respectively. The volume of the sheet up to the appropriate significant digits is:",
options: ["7.146 m³", "7.15 m³", "7.1 m³", "7.1457 m³"],
correctIndex: 1,
explanation: "Evaluating raw product volume yields: 3.233 × 2.105 × 1.05 = 7.1457... m³. Standard compound multiplication rules declare that absolute precision figures cannot exceed the weakest link component scale indicator. Because the thickness measurement (1.05 m) contains only 3 significant figures, the final estimation rounds to 3 significant figures: 7.15 m³."
},
{
id: 8,
question: "The dimensions of work, Joule and Torque or moment are:",
options: ["Similar", "Different", "Opposite", "Reciprocal"],
correctIndex: 0,
explanation: "Work equals force vector displacement, yielding structural tracking components of [ML²T⁻²]. A Joule represents the standardized metric energetic unit measuring that exact same value. Torque maps as perpendicular spatial force projections, also yielding [ML²T⁻²]. Therefore, all three maintain structurally identical dimensional dimensions."
},
{
id: 9,
question: "The number of significant figures in the value 8.80 × 10⁴ kg is:",
options: ["1", "2", "3", "4"],
correctIndex: 2,
explanation: "When evaluating data formatting patterns based on traditional scientific notation models, exponential base multipliers do not adjust system certainty levels. We look solely at the tracking base factor coefficient (8.80). Trailing fractional components positioned past a written decimal point denote active measurement precision, confirming 3 total significant figures."
},
{
id: 10,
question: "The dimensional expression M⁰ L⁰ T⁻¹ represents:",
options: ["Time period", "Frequency", "Angular acceleration", "Linear velocity"],
correctIndex: 1,
explanation: "The expression M⁰ L⁰ T⁻¹ characterizes an active inverse temporal value (1/T). Since mathematical frequency denotes structural periodic counts executing across a standard tracking cycle unit (f = 1/T), its base structural configuration precisely matches this dimension."
},
{
id: 11,
question: "The standard frequency and the angular velocity of a system possess the:",
options: ["Same dimension", "Different dimension", "Opposite dimension", "No dimension"],
correctIndex: 0,
explanation: "Cyclic frequency measures standard wave events per time period, rendering dimensions of [T⁻¹]. Angular velocity metrics capture angular tracking adjustments mapped across a temporal sequence (ω = θ / t). Because rotational angles reflect a pure ratio of spatial arcs, they lack dimensions, yielding an identical value of [T⁻¹]."
},
{
id: 12,
question: "The dimensional configuration of the universal gravitational constant G divided by gravity acceleration g simplifies to:",
options: ["M⁻¹ L²", "M L²", "M⁻¹ L³", "M L⁻¹"],
correctIndex: 0,
explanation: "The universal gravitational tracking constant maintains values of G = [M⁻¹L³T⁻²], while structural acceleration parameters map as g = [LT⁻²]. Dividing the relative metric formulas directly isolates the residual variables: [M⁻¹L³T⁻²] / [LT⁻²] = [M⁻¹L²]."
},
{
id: 13,
question: "Determine the correct dimensions of constants a and b in the formulation P = (b - x²) / (a × t) where P is power, t is time, and x is distance.",
options: ["a = M⁻¹ T², b = L²", "a = M L², b = L", "a = M T⁻², b = L²", "a = M⁻¹ L², b = T²"],
correctIndex: 0,
explanation: "By the principle of dimensional homogeneity, values combined through subtraction must possess matching dimensions. Thus, b matches x², yielding [L²]. Power P is defined as [ML²T⁻³]. Substituting the known parameters allows us to isolate constant a: [ML²T⁻³] = [L²] / (a × [T]), which simplifies to a = [M⁻¹T²]."
},
{
id: 14,
question: "Which of the following numeric values features the largest number of significant figures?",
options: ["0.2020", "20.2", "2020", "All have same"],
correctIndex: 0,
explanation: "Evaluating precision counts for each value: 0.2020 possesses 4 significant figures (leading zero excluded, trailing decimal zero included). 20.2 possesses 3 significant figures. 2020 possesses 3 significant figures because trailing zeros lacking an explicit decimal point are not counted as active indicators."
},
{
id: 15,
question: "A measurement is recorded as r = 2.25 ± 0.01 cm. Find out the total percentage uncertainty in r.",
options: ["0.1%", "0.2%", "0.4%", "0.8%"],
correctIndex: 2,
explanation: "To calculate percentage uncertainty, divide absolute system deviation metrics directly by the base measured value, then multiply by one hundred: (0.01 / 2.25) × 100% = 0.444...%. Rounding to the nearest configuration matches the 0.4% target choice."
},
{
id: 16,
question: "A light-year represents a fundamental physical unit used to quantify:",
options: ["Time", "Distance", "Velocity", "Intensity"],
correctIndex: 1,
explanation: "A light-year measures the absolute scalar linear distance that a photon covers traveling through an uninhibited vacuum space during one complete Julian year tracking cycle. Because it tracks distance, it does not represent time."
},
{
id: 17,
question: "Absolute uncertainty is structurally equivalent to the measuring instrument's:",
options: ["Least count", "Fractional error", "Percentage error", "Mean value"],
correctIndex: 0,
explanation: "Absolute uncertainty defines the fundamental resolution limit for a standalone data entry point. It is determined by the minimum structural indexing scale step, or least count, of the apparatus utilized."
},
{
id: 18,
question: "Why is uncertainty structurally included with every physical measurement?",
options: ["To account for human error only", "To account for limitations in measurement precision", "To make calculations harder", "Because instruments change over time randomly"],
correctIndex: 1,
explanation: "Every physical measuring instrument has physical design limits and constraint resolutions. Uncertainty metrics quantify these design limits, ensuring experimental data transparency."
},
{
id: 19,
question: "Which of the following physical measurements exhibits the lowest precision?",
options: ["12.30 m", "0.0450 m", "9.875 m", "1.2 m"],
correctIndex: 3,
explanation: "Precision tracks the minimal decimal configuration value of a measurement. Values extending to hundredths or thousandths signify higher internal tracking resolutions. 1.2 m extends only to the tenths place (±0.1 m resolution), making it the coarsest and lowest precision entry."
},
{
id: 20,
question: "How many significant figures are present in the structural measurement 0.004560?",
options: ["3", "4", "5", "6"],
correctIndex: 1,
explanation: "Leading placeholders before the 4 are skipped when calculating significant figures. The non-zero values (4, 5, 6) along with the trailing zero following the decimal mark are all significant. This leaves us with 4 significant figures."
}
];
// State variables
let currentIdx = 0;
let userAnswers = Array(quizData.length).fill(null);
// On Page Load Initialization
window.addEventListener('DOMContentLoaded', () => {
renderQuestion();
initTheme();
});
// Theme Switcher Logic
function initTheme() {
const systemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
setTheme(systemDark ? 'dark' : 'light');
}
function toggleTheme() {
const currentTheme = document.documentElement.getAttribute('data-theme');
setTheme(currentTheme === 'dark' ? 'light' : 'dark');
}
function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
const toggleBtn = document.getElementById('btn-theme-toggle');
if (theme === 'dark') {
toggleBtn.innerText = "Light Mode";
} else {
toggleBtn.innerText = "Dark Mode";
}
}
// Dynamic Question Rendering Engine
function renderQuestion() {
const question = quizData[currentIdx];
// Meta & Text
document.getElementById('question-meta').innerText = `Question ${currentIdx + 1} of ${quizData.length}`;
document.getElementById('question-text').innerText = question.question;
// Options container population
const container = document.getElementById('options-container');
container.innerHTML = '';
question.options.forEach((option, index) => {
const label = document.createElement('label');
label.className = `option-label${userAnswers[currentIdx] === index ? ' selected' : ''}`;
const input = document.createElement('input');
input.type = 'radio';
input.name = `quiz-option-${question.id}`;
input.value = index;
input.checked = (userAnswers[currentIdx] === index);
input.addEventListener('change', () => {
selectOption(index);
});
label.appendChild(input);
label.appendChild(document.createTextNode(option));
container.appendChild(label);
});
// Handle standard navigation controls
document.getElementById('btn-prev').disabled = (currentIdx === 0);
const nextBtn = document.getElementById('btn-next');
if (currentIdx === quizData.length - 1) {
nextBtn.innerText = "Submit";
nextBtn.onclick = manualSubmitAttempt;
} else {
nextBtn.innerText = "Next";
nextBtn.onclick = () => navigateQuestion(1);
}
}
function selectOption(index) {
userAnswers[currentIdx] = index;
// Re-render matching elements to apply selected classes
const options = document.querySelectorAll('.option-label');
options.forEach((lbl, idx) => {
if (idx === index) {
lbl.classList.add('selected');
} else {
lbl.classList.remove('selected');
}
});
}
function navigateQuestion(direction) {
currentIdx += direction;
if (currentIdx < 0) currentIdx = 0;
if (currentIdx >= quizData.length) currentIdx = quizData.length - 1;
renderQuestion();
}
// Unsolved Modal Control System
function openUnsolvedModal() {
const grid = document.getElementById('unsolved-grid-container');
grid.innerHTML = '';
quizData.forEach((_, idx) => {
const item = document.createElement('div');
const isAnswered = userAnswers[idx] !== null;
item.className = `grid-item${isAnswered ? ' answered' : ''}`;
item.innerText = idx + 1;
item.onclick = () => {
currentIdx = idx;
renderQuestion();
closeUnsolvedModal();
};
grid.appendChild(item);
});
document.getElementById('unsolved-modal').classList.add('open');
}
function closeUnsolvedModal() {
document.getElementById('unsolved-modal').classList.remove('open');
}
// Verification & Submission Logic
function manualSubmitAttempt() {
const totalAnswered = userAnswers.filter(ans => ans !== null).length;
if (totalAnswered < quizData.length) {
alert("You must answer all questions to submit! Please fill out the missing questions marked in the Unsolved Matrix.");
openUnsolvedModal();
} else {
if (confirm("Are you sure you want to submit your quiz for final grading?")) {
processQuizGrading();
}
}
}
function processQuizGrading() {
// Performance Metrics Accounting
let correctCount = 0;
let incorrectCount = 0;
let unattemptedCount = 0;
quizData.forEach((q, idx) => {
if (userAnswers[idx] === null) {
unattemptedCount++;
} else if (userAnswers[idx] === q.correctIndex) {
correctCount++;
} else {
incorrectCount++;
}
});
const scorePercent = Math.round((correctCount / quizData.length) * 100);
// Fetch Current Date and Time
const currentDateTime = new Date();
const formattedDate = currentDateTime.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric'
});
const formattedTime = currentDateTime.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit'
});
// Inject Metrics Content into Scorecard
document.getElementById('score-percent-display').innerText = `${scorePercent}%`;
document.getElementById('m-correct').innerText = correctCount;
document.getElementById('m-incorrect').innerText = incorrectCount;
document.getElementById('m-unattempted').innerText = unattemptedCount;
document.getElementById('m-date').innerText = formattedDate;
document.getElementById('m-time').innerText = formattedTime;
// Build Comprehensive Scrollable Review Sheet Panel
const sheet = document.getElementById('review-sheet-container');
sheet.innerHTML = '';
quizData.forEach((q, idx) => {
const card = document.createElement('div');
card.className = 'review-card';
// Assign Badges Based on Grading Output
let badgeHTML = '';
if (userAnswers[idx] === null) {
badgeHTML = '<span class="status-badge unattempted">Unattempted</span>';
} else if (userAnswers[idx] === q.correctIndex) {
badgeHTML = '<span class="status-badge correct">✓ Correct</span>';
} else {
badgeHTML = '<span class="status-badge incorrect">✗ Incorrect</span>';
}
let choicesHTML = '';
q.options.forEach((opt, oIdx) => {
let styleClass = '';
if (oIdx === q.correctIndex) {
styleClass = ' correct-choice';
} else if (userAnswers[idx] === oIdx && userAnswers[idx] !== q.correctIndex) {
styleClass = ' incorrect-choice';
}
choicesHTML += `<div class="review-option${styleClass}">
<span>${opt}</span>
${oIdx === q.correctIndex ? '<strong>[Correct Choice]</strong>' : ''}
${userAnswers[idx] === oIdx && userAnswers[idx] !== q.correctIndex ? '<span>[Your Selection]</span>' : ''}
</div>`;
});
card.innerHTML = `
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px;">
<div class="review-question-header">Question ${idx + 1}: ${q.question}</div>
<div>${badgeHTML}</div>
</div>
<div>${choicesHTML}</div>
<div class="explanation-box">
<div class="explanation-title">Detailed Scientific Explanation:</div>
<div>${q.explanation}</div>
</div>
`;
sheet.appendChild(card);
});
// Toggle Interfaces Views
document.getElementById('quiz-view').style.display = 'none';
document.getElementById('results-view').style.display = 'block';
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// Restart Mechanism Implementation
function restartQuiz() {
currentIdx = 0;
userAnswers = Array(quizData.length).fill(null);
document.getElementById('results-view').style.display = 'none';
document.getElementById('quiz-view').style.display = 'block';
renderQuestion();
}
</script>
</body>
</html>