-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvp-server.js
More file actions
2673 lines (2476 loc) · 112 KB
/
Copy pathmvp-server.js
File metadata and controls
2673 lines (2476 loc) · 112 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
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const express = require("express");
const crypto = require("crypto");
const https = require("https");
const app = express();
app.use(express.json({ limit: "10mb" }));
// ─── CORS ────────────────────────────────────────────────────────────────────
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE,OPTIONS");
res.header("Access-Control-Allow-Headers", "Content-Type,Authorization");
if (req.method === "OPTIONS") return res.sendStatus(200);
next();
});
// ─── GEMINI CONFIG ───────────────────────────────────────────────────────────
const GEMINI_API_KEY = process.env.GEMINI_API_KEY || "";
// ─── UTILITY HELPERS ─────────────────────────────────────────────────────────
const uid = () => crypto.randomBytes(6).toString("hex");
const shortUid = () => crypto.randomBytes(4).toString("hex").toUpperCase();
const sha256 = (data) => crypto.createHash("sha256").update(data).digest("hex");
const now = () => new Date().toISOString();
// ─── IN-MEMORY DATABASE ─────────────────────────────────────────────────────
const db = {
users: {},
questions: {},
exams: {},
candidates: {},
sessions: {},
submissions: {},
centers: {},
auditEvents: [],
auditHashChain: "0000000000000000000000000000000000000000000000000000000000000000",
proctorLogs: {}, // sessionId -> [{...}]
heartbeats: {}, // sessionId -> lastTimestamp
checkpoints: {}, // sessionId -> {...}
collusionResults: {}, // examId -> {...}
matrixJobs: {}, // examId -> { status, progress, ... }
encryptionJobs: {}, // examId -> { step, progress, ... }
equatingJobs: {}, // examId -> {...}
otpStore: {}, // admitCard -> otp
mfaStore: {}, // token -> code
};
// ─── AUDIT TRAIL ────────────────────────────────────────────────────────────
function addAuditEvent(eventType, actorId, examId, metadata = {}) {
const eventId = `evt_${uid()}`;
const prevHash = db.auditHashChain;
const entityHash = sha256(JSON.stringify({ eventType, actorId, examId, metadata, prevHash }));
db.auditHashChain = entityHash;
const event = {
eventId,
eventType,
examId: examId || "",
entityHash,
prevHash,
timestamp: now(),
actorId: actorId || "system",
actorOrg: "ParikshaSuraksha",
metadata,
txId: `tx_${uid()}`,
};
db.auditEvents.push(event);
return event;
}
// ─── SEED QUESTION BANK (30+ questions) ─────────────────────────────────────
const seedQuestions = [
// PHYSICS (10)
{
id: "q1", subject: "Physics", topic: "Mechanics", subtopic: "Kinematics",
bloomLevel: "apply",
templateText: "A ball is thrown upward with velocity {{v}} m/s. Find the maximum height reached. (g = 10 m/s²)",
parameters: [{ name: "v", type: "float", min: 10, max: 30, step: 5, values: [10, 15, 20, 25, 30] }],
answerFormula: "v^2 / (2*10)",
distractors: [
{ formula: "v^2 / (2*10) + 5", type: "calculation_error", label: "B" },
{ formula: "v^2 / 10", type: "common_misconception", label: "C" },
{ formula: "v^2 / (4*10)", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.2, aStd: 0.1, bMean: -0.5, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.55, B: 0.2, C: 0.15, D: 0.1 },
_compute: (v) => {
const ans = (v * v) / 20;
return [
{ label: "A", text: `${ans} m`, correct: true },
{ label: "B", text: `${ans + 5} m`, correct: false },
{ label: "C", text: `${(v * v) / 10} m`, correct: false },
{ label: "D", text: `${(v * v) / 40} m`, correct: false },
];
},
},
{
id: "q2", subject: "Physics", topic: "Optics", subtopic: "Lenses",
bloomLevel: "apply",
templateText: "A convex lens has focal length f = {{f}} cm. An object is placed at u = {{u}} cm. Find the image distance.",
parameters: [
{ name: "f", type: "float", min: 10, max: 20, step: 5, values: [10, 15, 20] },
{ name: "u", type: "float", min: 30, max: 60, step: 10, values: [30, 40, 60] },
],
answerFormula: "(f*u)/(u-f)",
distractors: [
{ formula: "(f*u)/(u-f) + 10", type: "calculation_error", label: "B" },
{ formula: "2*(f*u)/(u-f)", type: "common_misconception", label: "C" },
{ formula: "(f*u)/(2*(u-f))", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.12, bMean: 0.3, bStd: 0.2, cMean: 0.2, cStd: 0.04 },
distractorProfile: { A: 0.50, B: 0.22, C: 0.18, D: 0.10 },
_compute: (f, u) => {
const v = (f * u) / (u - f);
return [
{ label: "A", text: `${v.toFixed(1)} cm`, correct: true },
{ label: "B", text: `${(v + 10).toFixed(1)} cm`, correct: false },
{ label: "C", text: `${(v * 2).toFixed(1)} cm`, correct: false },
{ label: "D", text: `${(v / 2).toFixed(1)} cm`, correct: false },
];
},
},
{
id: "q3", subject: "Physics", topic: "Thermodynamics", subtopic: "Internal Energy",
bloomLevel: "apply",
templateText: "{{n}} mol of an ideal monoatomic gas is at {{T}} K. Find its internal energy.",
parameters: [
{ name: "n", type: "float", min: 1, max: 3, step: 1, values: [1, 2, 3] },
{ name: "T", type: "float", min: 300, max: 500, step: 100, values: [300, 400, 500] },
],
answerFormula: "1.5 * n * 8.314 * T",
distractors: [
{ formula: "1.5 * n * 8.314 * T * 2", type: "common_misconception", label: "B" },
{ formula: "n * 8.314 * T", type: "calculation_error", label: "C" },
{ formula: "1.5 * n * 8.314 * T * 0.67", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: 0.0, bStd: 0.18, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.52, B: 0.18, C: 0.20, D: 0.10 },
_compute: (n, T) => {
const r = Math.round(1.5 * n * 8.314 * T);
return [
{ label: "A", text: `${r} J`, correct: true },
{ label: "B", text: `${r * 2} J`, correct: false },
{ label: "C", text: `${Math.round(n * 8.314 * T)} J`, correct: false },
{ label: "D", text: `${Math.round(r * 0.67)} J`, correct: false },
];
},
},
{
id: "q4", subject: "Physics", topic: "Electricity", subtopic: "Resistance",
bloomLevel: "apply",
templateText: "A wire has resistivity ρ = {{rho}} Ω·m, length L = {{l}} m, area A = {{a}} mm². Find its resistance.",
parameters: [
{ name: "rho", type: "float", values: [1e-7, 1.7e-7] },
{ name: "l", type: "float", min: 1, max: 5, step: 1, values: [1, 2, 5] },
{ name: "a", type: "float", min: 1, max: 2, step: 1, values: [1, 2] },
],
answerFormula: "rho * l / (a * 1e-6)",
distractors: [
{ formula: "2 * rho * l / (a * 1e-6)", type: "calculation_error", label: "B" },
{ formula: "rho * l / (2 * a * 1e-6)", type: "unit_error", label: "C" },
{ formula: "rho * l / (a * 1e-6) + 0.05", type: "common_misconception", label: "D" },
],
irtParams: { aMean: 0.9, aStd: 0.11, bMean: 0.5, bStd: 0.2, cMean: 0.2, cStd: 0.04 },
distractorProfile: { A: 0.48, B: 0.20, C: 0.18, D: 0.14 },
_compute: (rho, l, a) => {
const r = (rho * l / (a * 1e-6)).toFixed(4);
return [
{ label: "A", text: `${r} Ω`, correct: true },
{ label: "B", text: `${(parseFloat(r) * 2).toFixed(4)} Ω`, correct: false },
{ label: "C", text: `${(parseFloat(r) / 2).toFixed(4)} Ω`, correct: false },
{ label: "D", text: `${(parseFloat(r) + 0.05).toFixed(4)} Ω`, correct: false },
];
},
},
{
id: "q5", subject: "Physics", topic: "Mechanics", subtopic: "Newton's Laws",
bloomLevel: "apply",
templateText: "A {{m}} kg block is pushed with force {{F}} N on a frictionless surface. Find acceleration.",
parameters: [
{ name: "m", type: "float", min: 2, max: 10, step: 2, values: [2, 4, 5, 8, 10] },
{ name: "F", type: "float", min: 10, max: 50, step: 10, values: [10, 20, 30, 40, 50] },
],
answerFormula: "F / m",
distractors: [
{ formula: "F * m", type: "common_misconception", label: "B" },
{ formula: "F / m + 2", type: "calculation_error", label: "C" },
{ formula: "m / F", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.3, aStd: 0.09, bMean: -0.8, bStd: 0.15, cMean: 0.25, cStd: 0.04 },
distractorProfile: { A: 0.60, B: 0.15, C: 0.15, D: 0.10 },
_compute: (m, F) => {
const a = F / m;
return [
{ label: "A", text: `${a} m/s²`, correct: true },
{ label: "B", text: `${F * m} m/s²`, correct: false },
{ label: "C", text: `${a + 2} m/s²`, correct: false },
{ label: "D", text: `${(m / F).toFixed(2)} m/s²`, correct: false },
];
},
},
{
id: "q6", subject: "Physics", topic: "Waves", subtopic: "Frequency",
bloomLevel: "understand",
templateText: "A wave has wavelength {{lambda}} m and speed {{v}} m/s. What is its frequency?",
parameters: [
{ name: "lambda", type: "float", values: [0.5, 1, 2, 4] },
{ name: "v", type: "float", values: [340, 300, 170, 680] },
],
answerFormula: "v / lambda",
distractors: [
{ formula: "v * lambda", type: "common_misconception", label: "B" },
{ formula: "v / lambda + 10", type: "calculation_error", label: "C" },
{ formula: "lambda / v", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: -0.3, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.58, B: 0.18, C: 0.14, D: 0.10 },
_compute: (lambda, v) => {
const f = v / lambda;
return [
{ label: "A", text: `${f} Hz`, correct: true },
{ label: "B", text: `${v * lambda} Hz`, correct: false },
{ label: "C", text: `${f + 10} Hz`, correct: false },
{ label: "D", text: `${(lambda / v).toFixed(4)} Hz`, correct: false },
];
},
},
{
id: "q7", subject: "Physics", topic: "Modern Physics", subtopic: "Photoelectric Effect",
bloomLevel: "analyze",
templateText: "Light of wavelength {{lambda}} nm strikes a metal with work function {{phi}} eV. Find max KE of emitted electrons. (h = 6.63×10⁻³⁴ J·s, c = 3×10⁸ m/s, 1 eV = 1.6×10⁻¹⁹ J)",
parameters: [
{ name: "lambda", type: "float", values: [200, 250, 300, 400] },
{ name: "phi", type: "float", values: [2.0, 2.5, 3.0, 3.5] },
],
answerFormula: "(1240 / lambda) - phi",
distractors: [
{ formula: "(1240 / lambda)", type: "common_misconception", label: "B" },
{ formula: "(1240 / lambda) - phi + 0.5", type: "calculation_error", label: "C" },
{ formula: "phi - (1240 / lambda)", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.4, aStd: 0.12, bMean: 1.0, bStd: 0.25, cMean: 0.2, cStd: 0.04 },
distractorProfile: { A: 0.40, B: 0.25, C: 0.20, D: 0.15 },
_compute: (lambda, phi) => {
const e = (1240 / lambda) - phi;
return [
{ label: "A", text: `${e.toFixed(2)} eV`, correct: true },
{ label: "B", text: `${(1240 / lambda).toFixed(2)} eV`, correct: false },
{ label: "C", text: `${(e + 0.5).toFixed(2)} eV`, correct: false },
{ label: "D", text: `${Math.abs(phi - (1240 / lambda)).toFixed(2)} eV`, correct: false },
];
},
},
{
id: "q8", subject: "Physics", topic: "Gravitation", subtopic: "Orbital Velocity",
bloomLevel: "apply",
templateText: "A satellite orbits Earth at height {{h}} km above surface. Find orbital velocity. (R = 6400 km, g = 9.8 m/s²)",
parameters: [
{ name: "h", type: "float", values: [200, 400, 600, 800] },
],
answerFormula: "sqrt(g * R^2 / (R + h))",
distractors: [
{ formula: "sqrt(g * R)", type: "common_misconception", label: "B" },
{ formula: "sqrt(g * R^2 / (R + h)) + 500", type: "calculation_error", label: "C" },
{ formula: "sqrt(2 * g * R^2 / (R + h))", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.13, bMean: 0.8, bStd: 0.2, cMean: 0.2, cStd: 0.04 },
distractorProfile: { A: 0.42, B: 0.25, C: 0.18, D: 0.15 },
_compute: (h) => {
const R = 6400;
const g = 9.8;
const v = Math.sqrt(g * (R * 1000) * (R * 1000) / ((R + h) * 1000));
return [
{ label: "A", text: `${Math.round(v)} m/s`, correct: true },
{ label: "B", text: `${Math.round(Math.sqrt(g * R * 1000))} m/s`, correct: false },
{ label: "C", text: `${Math.round(v) + 500} m/s`, correct: false },
{ label: "D", text: `${Math.round(v * Math.sqrt(2))} m/s`, correct: false },
];
},
},
{
id: "q9", subject: "Physics", topic: "Electrostatics", subtopic: "Coulomb's Law",
bloomLevel: "apply",
templateText: "Two charges of {{q1}} μC and {{q2}} μC are {{r}} m apart. Find the force between them. (k = 9×10⁹ N·m²/C²)",
parameters: [
{ name: "q1", type: "float", values: [1, 2, 3, 5] },
{ name: "q2", type: "float", values: [1, 2, 4, 6] },
{ name: "r", type: "float", values: [0.1, 0.2, 0.5, 1.0] },
],
answerFormula: "k * q1 * q2 * 1e-12 / r^2",
distractors: [
{ formula: "k * q1 * q2 / r^2 (without unit conversion)", type: "unit_error", label: "B" },
{ formula: "k * q1 * q2 * 1e-12 / r", type: "common_misconception", label: "C" },
{ formula: "k * q1 * q2 * 1e-12 / (2*r^2)", type: "calculation_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: 0.2, bStd: 0.18, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.50, B: 0.20, C: 0.18, D: 0.12 },
_compute: (q1, q2, r) => {
const F = (9e9 * q1 * q2 * 1e-12) / (r * r);
return [
{ label: "A", text: `${F.toFixed(4)} N`, correct: true },
{ label: "B", text: `${(9e9 * q1 * q2 / (r * r)).toExponential(2)} N`, correct: false },
{ label: "C", text: `${(9e9 * q1 * q2 * 1e-12 / r).toFixed(4)} N`, correct: false },
{ label: "D", text: `${(F / 2).toFixed(4)} N`, correct: false },
];
},
},
{
id: "q10", subject: "Physics", topic: "Mechanics", subtopic: "Momentum",
bloomLevel: "apply",
templateText: "A {{m}} kg object moving at {{v}} m/s collides and sticks to a stationary {{m2}} kg object. Find the final velocity.",
parameters: [
{ name: "m", type: "float", values: [2, 3, 4, 5] },
{ name: "v", type: "float", values: [10, 15, 20, 25] },
{ name: "m2", type: "float", values: [2, 3, 5, 8] },
],
answerFormula: "(m * v) / (m + m2)",
distractors: [
{ formula: "v", type: "common_misconception", label: "B" },
{ formula: "(m * v) / m2", type: "calculation_error", label: "C" },
{ formula: "(m + m2) * v / m", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.11, bMean: 0.1, bStd: 0.17, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.52, B: 0.20, C: 0.16, D: 0.12 },
_compute: (m, v, m2) => {
const vf = (m * v) / (m + m2);
return [
{ label: "A", text: `${vf.toFixed(2)} m/s`, correct: true },
{ label: "B", text: `${v} m/s`, correct: false },
{ label: "C", text: `${((m * v) / m2).toFixed(2)} m/s`, correct: false },
{ label: "D", text: `${(((m + m2) * v) / m).toFixed(2)} m/s`, correct: false },
];
},
},
// CHEMISTRY (8)
{
id: "q11", subject: "Chemistry", topic: "Stoichiometry", subtopic: "Moles",
bloomLevel: "apply",
templateText: "How many moles are in {{mass}} g of NaCl? (Molar mass = 58.5 g/mol)",
parameters: [{ name: "mass", type: "float", values: [29.25, 58.5, 117, 175.5, 234] }],
answerFormula: "mass / 58.5",
distractors: [
{ formula: "mass / 58.5 * 2", type: "calculation_error", label: "B" },
{ formula: "mass / 58.5 + 0.5", type: "common_misconception", label: "C" },
{ formula: "mass / 58.5 / 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.2, aStd: 0.1, bMean: -0.4, bStd: 0.14, cMean: 0.25, cStd: 0.03 },
distractorProfile: { A: 0.58, B: 0.18, C: 0.14, D: 0.10 },
_compute: (mass) => {
const c = mass / 58.5;
return [
{ label: "A", text: `${c.toFixed(2)} mol`, correct: true },
{ label: "B", text: `${(c * 2).toFixed(2)} mol`, correct: false },
{ label: "C", text: `${(c + 0.5).toFixed(2)} mol`, correct: false },
{ label: "D", text: `${(c / 2).toFixed(2)} mol`, correct: false },
];
},
},
{
id: "q12", subject: "Chemistry", topic: "Acids & Bases", subtopic: "pH",
bloomLevel: "apply",
templateText: "What is the pH of a {{c}} M HCl solution?",
parameters: [{ name: "c", type: "float", values: [0.1, 0.01, 0.001, 0.0001] }],
answerFormula: "-log10(c)",
distractors: [
{ formula: "-log10(c) + 1", type: "calculation_error", label: "B" },
{ formula: "14 - (-log10(c))", type: "common_misconception", label: "C" },
{ formula: "-log10(c) - 1", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: -0.2, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.55, B: 0.18, C: 0.17, D: 0.10 },
_compute: (c) => {
const p = -Math.log10(c);
return [
{ label: "A", text: `${p}`, correct: true },
{ label: "B", text: `${p + 1}`, correct: false },
{ label: "C", text: `${14 - p}`, correct: false },
{ label: "D", text: `${p - 1}`, correct: false },
];
},
},
{
id: "q13", subject: "Chemistry", topic: "Gas Laws", subtopic: "Ideal Gas",
bloomLevel: "apply",
templateText: "{{n}} mol of an ideal gas at {{T}} K in a {{V}} L container. Find the pressure in atm. (R = 0.0821 L·atm/mol·K)",
parameters: [
{ name: "n", type: "float", values: [1, 2, 3, 5] },
{ name: "T", type: "float", values: [273, 300, 373, 500] },
{ name: "V", type: "float", values: [10, 20, 22.4, 50] },
],
answerFormula: "n * 0.0821 * T / V",
distractors: [
{ formula: "n * T / V", type: "common_misconception", label: "B" },
{ formula: "n * 0.0821 * T / V + 1", type: "calculation_error", label: "C" },
{ formula: "n * 8.314 * T / V", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.12, bMean: 0.3, bStd: 0.18, cMean: 0.2, cStd: 0.04 },
distractorProfile: { A: 0.48, B: 0.22, C: 0.16, D: 0.14 },
_compute: (n, T, V) => {
const P = (n * 0.0821 * T) / V;
return [
{ label: "A", text: `${P.toFixed(2)} atm`, correct: true },
{ label: "B", text: `${(n * T / V).toFixed(2)} atm`, correct: false },
{ label: "C", text: `${(P + 1).toFixed(2)} atm`, correct: false },
{ label: "D", text: `${((n * 8.314 * T) / V).toFixed(2)} atm`, correct: false },
];
},
},
{
id: "q14", subject: "Chemistry", topic: "Electrochemistry", subtopic: "Cell Potential",
bloomLevel: "analyze",
templateText: "A galvanic cell has E°(cathode) = {{ec}} V and E°(anode) = {{ea}} V. Find the cell EMF.",
parameters: [
{ name: "ec", type: "float", values: [0.34, 0.80, 1.36, 0.77] },
{ name: "ea", type: "float", values: [-0.76, -0.44, -0.13, 0.34] },
],
answerFormula: "ec - ea",
distractors: [
{ formula: "ea - ec", type: "common_misconception", label: "B" },
{ formula: "ec + ea", type: "calculation_error", label: "C" },
{ formula: "(ec - ea) / 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.2, aStd: 0.11, bMean: 0.5, bStd: 0.2, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.45, B: 0.25, C: 0.18, D: 0.12 },
_compute: (ec, ea) => {
const emf = ec - ea;
return [
{ label: "A", text: `${emf.toFixed(2)} V`, correct: true },
{ label: "B", text: `${(ea - ec).toFixed(2)} V`, correct: false },
{ label: "C", text: `${(ec + ea).toFixed(2)} V`, correct: false },
{ label: "D", text: `${(emf / 2).toFixed(2)} V`, correct: false },
];
},
},
{
id: "q15", subject: "Chemistry", topic: "Chemical Kinetics", subtopic: "Half Life",
bloomLevel: "apply",
templateText: "A first-order reaction has rate constant k = {{k}} s⁻¹. Find the half-life.",
parameters: [{ name: "k", type: "float", values: [0.01, 0.02, 0.05, 0.1, 0.5] }],
answerFormula: "0.693 / k",
distractors: [
{ formula: "1 / k", type: "common_misconception", label: "B" },
{ formula: "0.693 * k", type: "calculation_error", label: "C" },
{ formula: "0.693 / (2 * k)", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: 0.0, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.52, B: 0.22, C: 0.16, D: 0.10 },
_compute: (k) => {
const t = 0.693 / k;
return [
{ label: "A", text: `${t.toFixed(2)} s`, correct: true },
{ label: "B", text: `${(1 / k).toFixed(2)} s`, correct: false },
{ label: "C", text: `${(0.693 * k).toFixed(4)} s`, correct: false },
{ label: "D", text: `${(t / 2).toFixed(2)} s`, correct: false },
];
},
},
{
id: "q16", subject: "Chemistry", topic: "Atomic Structure", subtopic: "Quantum Numbers",
bloomLevel: "remember",
templateText: "For n = {{n}}, what is the maximum number of electrons that can occupy this shell?",
parameters: [{ name: "n", type: "integer", values: [1, 2, 3, 4, 5] }],
answerFormula: "2 * n^2",
distractors: [
{ formula: "n^2", type: "common_misconception", label: "B" },
{ formula: "2 * n", type: "calculation_error", label: "C" },
{ formula: "2 * n^2 + 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.3, aStd: 0.09, bMean: -0.6, bStd: 0.14, cMean: 0.25, cStd: 0.03 },
distractorProfile: { A: 0.60, B: 0.18, C: 0.14, D: 0.08 },
_compute: (n) => {
const max = 2 * n * n;
return [
{ label: "A", text: `${max}`, correct: true },
{ label: "B", text: `${n * n}`, correct: false },
{ label: "C", text: `${2 * n}`, correct: false },
{ label: "D", text: `${max + 2}`, correct: false },
];
},
},
{
id: "q17", subject: "Chemistry", topic: "Solutions", subtopic: "Molarity",
bloomLevel: "apply",
templateText: "{{mass}} g of NaOH (M = 40 g/mol) is dissolved in {{vol}} mL of solution. Find the molarity.",
parameters: [
{ name: "mass", type: "float", values: [4, 8, 10, 20, 40] },
{ name: "vol", type: "float", values: [100, 200, 250, 500, 1000] },
],
answerFormula: "(mass / 40) / (vol / 1000)",
distractors: [
{ formula: "mass / 40", type: "common_misconception", label: "B" },
{ formula: "(mass / 40) / vol", type: "unit_error", label: "C" },
{ formula: "(mass / 40) / (vol / 1000) + 0.5", type: "calculation_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: -0.1, bStd: 0.16, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.54, B: 0.20, C: 0.16, D: 0.10 },
_compute: (mass, vol) => {
const M = (mass / 40) / (vol / 1000);
return [
{ label: "A", text: `${M.toFixed(2)} M`, correct: true },
{ label: "B", text: `${(mass / 40).toFixed(2)} M`, correct: false },
{ label: "C", text: `${((mass / 40) / vol).toFixed(4)} M`, correct: false },
{ label: "D", text: `${(M + 0.5).toFixed(2)} M`, correct: false },
];
},
},
{
id: "q18", subject: "Chemistry", topic: "Thermochemistry", subtopic: "Enthalpy",
bloomLevel: "apply",
templateText: "If {{n}} mol of methane combusts releasing {{dH}} kJ/mol, how much total heat is released?",
parameters: [
{ name: "n", type: "float", values: [1, 2, 3, 5] },
{ name: "dH", type: "float", values: [890, 802, 726, 1560] },
],
answerFormula: "n * dH",
distractors: [
{ formula: "dH / n", type: "common_misconception", label: "B" },
{ formula: "n * dH + 100", type: "calculation_error", label: "C" },
{ formula: "n * dH / 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: -0.3, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.55, B: 0.18, C: 0.15, D: 0.12 },
_compute: (n, dH) => {
const total = n * dH;
return [
{ label: "A", text: `${total} kJ`, correct: true },
{ label: "B", text: `${(dH / n).toFixed(1)} kJ`, correct: false },
{ label: "C", text: `${total + 100} kJ`, correct: false },
{ label: "D", text: `${total / 2} kJ`, correct: false },
];
},
},
// MATH (8)
{
id: "q19", subject: "Math", topic: "Calculus", subtopic: "Differentiation",
bloomLevel: "apply",
templateText: "Find the derivative of f(x) = {{a}}x³ + {{b}}x² at x = {{c}}.",
parameters: [
{ name: "a", type: "integer", values: [1, 2, 3, 4] },
{ name: "b", type: "integer", values: [2, 3, 4, 5] },
{ name: "c", type: "integer", values: [1, 2, 3] },
],
answerFormula: "3*a*c^2 + 2*b*c",
distractors: [
{ formula: "3*a*c^2 + 2*b*c + a", type: "calculation_error", label: "B" },
{ formula: "2*(3*a*c^2 + 2*b*c)", type: "common_misconception", label: "C" },
{ formula: "3*a*c^2 + 2*b*c - b", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.2, aStd: 0.1, bMean: 0.2, bStd: 0.17, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.50, B: 0.22, C: 0.16, D: 0.12 },
_compute: (a, b, c) => {
const r = 3 * a * c * c + 2 * b * c;
return [
{ label: "A", text: `${r}`, correct: true },
{ label: "B", text: `${r + a}`, correct: false },
{ label: "C", text: `${r * 2}`, correct: false },
{ label: "D", text: `${r - b}`, correct: false },
];
},
},
{
id: "q20", subject: "Math", topic: "Probability", subtopic: "Dice",
bloomLevel: "apply",
templateText: "Two dice are thrown. What is the probability of getting a sum of {{s}}?",
parameters: [{ name: "s", type: "integer", values: [5, 6, 7, 8, 9, 10] }],
answerFormula: "ways(s) / 36",
distractors: [
{ formula: "(ways(s)+1) / 36", type: "calculation_error", label: "B" },
{ formula: "(ways(s)-1) / 36", type: "common_misconception", label: "C" },
{ formula: "ways(s)*2 / 36", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: 0.0, bStd: 0.15, cMean: 0.25, cStd: 0.04 },
distractorProfile: { A: 0.55, B: 0.18, C: 0.17, D: 0.10 },
_compute: (s) => {
const ways = { 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 5, 9: 4, 10: 3, 11: 2, 12: 1 };
const n = ways[s] || 3;
return [
{ label: "A", text: `${n}/36`, correct: true },
{ label: "B", text: `${n + 1}/36`, correct: false },
{ label: "C", text: `${n - 1}/36`, correct: false },
{ label: "D", text: `${n * 2}/36`, correct: false },
];
},
},
{
id: "q21", subject: "Math", topic: "Algebra", subtopic: "Quadratic Equations",
bloomLevel: "apply",
templateText: "Find the roots of x² - {{s}}x + {{p}} = 0.",
parameters: [
{ name: "s", type: "integer", values: [5, 7, 8, 9, 11] },
{ name: "p", type: "integer", values: [6, 10, 12, 14, 18] },
],
answerFormula: "(s ± sqrt(s^2 - 4p)) / 2",
distractors: [
{ formula: "s and p", type: "common_misconception", label: "B" },
{ formula: "(s ± sqrt(s^2 - 4p)) / 2 + 1", type: "calculation_error", label: "C" },
{ formula: "(s ± sqrt(s^2 + 4p)) / 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: 0.1, bStd: 0.16, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.52, B: 0.20, C: 0.17, D: 0.11 },
_compute: (s, p) => {
const disc = s * s - 4 * p;
const r1 = (s + Math.sqrt(Math.abs(disc))) / 2;
const r2 = (s - Math.sqrt(Math.abs(disc))) / 2;
return [
{ label: "A", text: `${r1.toFixed(1)}, ${r2.toFixed(1)}`, correct: true },
{ label: "B", text: `${s}, ${p}`, correct: false },
{ label: "C", text: `${(r1 + 1).toFixed(1)}, ${(r2 + 1).toFixed(1)}`, correct: false },
{ label: "D", text: `${((s + Math.sqrt(s * s + 4 * p)) / 2).toFixed(1)}, ${((s - Math.sqrt(s * s + 4 * p)) / 2).toFixed(1)}`, correct: false },
];
},
},
{
id: "q22", subject: "Math", topic: "Trigonometry", subtopic: "Identities",
bloomLevel: "understand",
templateText: "If sin θ = {{s}}/{{h}}, and θ is in the first quadrant, find cos θ.",
parameters: [
{ name: "s", type: "integer", values: [3, 5, 8, 12] },
{ name: "h", type: "integer", values: [5, 13, 17, 13] },
],
answerFormula: "sqrt(h^2 - s^2) / h",
distractors: [
{ formula: "s / h", type: "common_misconception", label: "B" },
{ formula: "1 - s/h", type: "calculation_error", label: "C" },
{ formula: "h / s", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: -0.2, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.55, B: 0.20, C: 0.15, D: 0.10 },
_compute: (s, h) => {
const cosVal = Math.sqrt(h * h - s * s) / h;
return [
{ label: "A", text: `${cosVal.toFixed(4)}`, correct: true },
{ label: "B", text: `${(s / h).toFixed(4)}`, correct: false },
{ label: "C", text: `${(1 - s / h).toFixed(4)}`, correct: false },
{ label: "D", text: `${(h / s).toFixed(4)}`, correct: false },
];
},
},
{
id: "q23", subject: "Math", topic: "Calculus", subtopic: "Integration",
bloomLevel: "apply",
templateText: "Evaluate the definite integral of {{a}}x² from 0 to {{b}}.",
parameters: [
{ name: "a", type: "integer", values: [1, 2, 3, 5] },
{ name: "b", type: "integer", values: [1, 2, 3, 4] },
],
answerFormula: "a * b^3 / 3",
distractors: [
{ formula: "a * b^2", type: "common_misconception", label: "B" },
{ formula: "a * b^3 / 3 + 1", type: "calculation_error", label: "C" },
{ formula: "a * b^3 / 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.2, aStd: 0.11, bMean: 0.4, bStd: 0.18, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.48, B: 0.22, C: 0.18, D: 0.12 },
_compute: (a, b) => {
const val = (a * b * b * b) / 3;
return [
{ label: "A", text: `${val.toFixed(2)}`, correct: true },
{ label: "B", text: `${(a * b * b).toFixed(2)}`, correct: false },
{ label: "C", text: `${(val + 1).toFixed(2)}`, correct: false },
{ label: "D", text: `${((a * b * b * b) / 2).toFixed(2)}`, correct: false },
];
},
},
{
id: "q24", subject: "Math", topic: "Matrices", subtopic: "Determinant",
bloomLevel: "apply",
templateText: "Find the determinant of the 2×2 matrix [[{{a}}, {{b}}], [{{c}}, {{d}}]].",
parameters: [
{ name: "a", type: "integer", values: [1, 2, 3, 4] },
{ name: "b", type: "integer", values: [2, 3, 5, 1] },
{ name: "c", type: "integer", values: [3, 1, 2, 5] },
{ name: "d", type: "integer", values: [4, 5, 1, 2] },
],
answerFormula: "a*d - b*c",
distractors: [
{ formula: "a*d + b*c", type: "common_misconception", label: "B" },
{ formula: "a*c - b*d", type: "calculation_error", label: "C" },
{ formula: "(a*d - b*c) / 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: -0.3, bStd: 0.15, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.55, B: 0.20, C: 0.15, D: 0.10 },
_compute: (a, b, c, d) => {
const det = a * d - b * c;
return [
{ label: "A", text: `${det}`, correct: true },
{ label: "B", text: `${a * d + b * c}`, correct: false },
{ label: "C", text: `${a * c - b * d}`, correct: false },
{ label: "D", text: `${det / 2}`, correct: false },
];
},
},
{
id: "q25", subject: "Math", topic: "Vectors", subtopic: "Dot Product",
bloomLevel: "apply",
templateText: "Find the dot product of vectors A = ({{a1}}, {{a2}}) and B = ({{b1}}, {{b2}}).",
parameters: [
{ name: "a1", type: "integer", values: [1, 2, 3, -1] },
{ name: "a2", type: "integer", values: [2, 3, -1, 4] },
{ name: "b1", type: "integer", values: [3, 1, 2, -2] },
{ name: "b2", type: "integer", values: [1, -1, 4, 3] },
],
answerFormula: "a1*b1 + a2*b2",
distractors: [
{ formula: "a1*b2 + a2*b1", type: "common_misconception", label: "B" },
{ formula: "a1*b1 - a2*b2", type: "calculation_error", label: "C" },
{ formula: "a1*b1 + a2*b2 + 1", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: -0.4, bStd: 0.14, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.58, B: 0.17, C: 0.15, D: 0.10 },
_compute: (a1, a2, b1, b2) => {
const dp = a1 * b1 + a2 * b2;
return [
{ label: "A", text: `${dp}`, correct: true },
{ label: "B", text: `${a1 * b2 + a2 * b1}`, correct: false },
{ label: "C", text: `${a1 * b1 - a2 * b2}`, correct: false },
{ label: "D", text: `${dp + 1}`, correct: false },
];
},
},
{
id: "q26", subject: "Math", topic: "Statistics", subtopic: "Standard Deviation",
bloomLevel: "apply",
templateText: "Find the variance of the dataset: {{a}}, {{b}}, {{c}}, {{d}}, {{e}}.",
parameters: [
{ name: "a", type: "integer", values: [2, 4, 10] },
{ name: "b", type: "integer", values: [4, 6, 12] },
{ name: "c", type: "integer", values: [6, 8, 14] },
{ name: "d", type: "integer", values: [8, 10, 16] },
{ name: "e", type: "integer", values: [10, 12, 18] },
],
answerFormula: "mean((x-mean)^2)",
distractors: [
{ formula: "sqrt(variance)", type: "common_misconception", label: "B" },
{ formula: "variance + 1", type: "calculation_error", label: "C" },
{ formula: "variance * 2", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.0, aStd: 0.1, bMean: 0.3, bStd: 0.17, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.48, B: 0.24, C: 0.16, D: 0.12 },
_compute: (a, b, c, d, e) => {
const vals = [a, b, c, d, e];
const mean = vals.reduce((s, v) => s + v, 0) / 5;
const variance = vals.reduce((s, v) => s + (v - mean) ** 2, 0) / 5;
return [
{ label: "A", text: `${variance.toFixed(2)}`, correct: true },
{ label: "B", text: `${Math.sqrt(variance).toFixed(2)}`, correct: false },
{ label: "C", text: `${(variance + 1).toFixed(2)}`, correct: false },
{ label: "D", text: `${(variance * 2).toFixed(2)}`, correct: false },
];
},
},
// BIOLOGY (6)
{
id: "q27", subject: "Biology", topic: "Genetics", subtopic: "Mendelian",
bloomLevel: "understand",
templateText: "In a monohybrid cross Aa × Aa, what fraction of offspring will be homozygous recessive?",
parameters: [],
answerFormula: "1/4",
distractors: [
{ formula: "1/2", type: "common_misconception", label: "B" },
{ formula: "3/4", type: "calculation_error", label: "C" },
{ formula: "1/8", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.3, aStd: 0.09, bMean: -0.5, bStd: 0.14, cMean: 0.25, cStd: 0.03 },
distractorProfile: { A: 0.60, B: 0.18, C: 0.14, D: 0.08 },
_compute: () => [
{ label: "A", text: "1/4", correct: true },
{ label: "B", text: "1/2", correct: false },
{ label: "C", text: "3/4", correct: false },
{ label: "D", text: "1/8", correct: false },
],
},
{
id: "q28", subject: "Biology", topic: "Cell Biology", subtopic: "Organelles",
bloomLevel: "remember",
templateText: "Which organelle is the primary site of ATP production in eukaryotic cells?",
parameters: [],
answerFormula: "Mitochondria",
distractors: [
{ formula: "Golgi apparatus", type: "common_misconception", label: "B" },
{ formula: "Endoplasmic reticulum", type: "calculation_error", label: "C" },
{ formula: "Lysosome", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.4, aStd: 0.08, bMean: -1.0, bStd: 0.12, cMean: 0.25, cStd: 0.03 },
distractorProfile: { A: 0.72, B: 0.12, C: 0.10, D: 0.06 },
_compute: () => [
{ label: "A", text: "Mitochondria", correct: true },
{ label: "B", text: "Golgi apparatus", correct: false },
{ label: "C", text: "Endoplasmic reticulum", correct: false },
{ label: "D", text: "Lysosome", correct: false },
],
},
{
id: "q29", subject: "Biology", topic: "Ecology", subtopic: "Food Chain",
bloomLevel: "understand",
templateText: "In a food chain, if the primary producer has {{e}} kcal energy, how much energy is available at the third trophic level? (10% rule)",
parameters: [{ name: "e", type: "float", values: [10000, 20000, 50000, 100000] }],
answerFormula: "e * 0.01",
distractors: [
{ formula: "e * 0.1", type: "common_misconception", label: "B" },
{ formula: "e * 0.001", type: "calculation_error", label: "C" },
{ formula: "e * 0.05", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.1, bMean: 0.1, bStd: 0.16, cMean: 0.2, cStd: 0.03 },
distractorProfile: { A: 0.50, B: 0.22, C: 0.16, D: 0.12 },
_compute: (e) => {
const level3 = e * 0.01;
return [
{ label: "A", text: `${level3} kcal`, correct: true },
{ label: "B", text: `${e * 0.1} kcal`, correct: false },
{ label: "C", text: `${e * 0.001} kcal`, correct: false },
{ label: "D", text: `${e * 0.05} kcal`, correct: false },
];
},
},
{
id: "q30", subject: "Biology", topic: "Human Physiology", subtopic: "Blood Groups",
bloomLevel: "understand",
templateText: "A person with blood group AB can receive blood from which groups (in terms of ABO system)?",
parameters: [],
answerFormula: "A, B, AB, O (universal recipient)",
distractors: [
{ formula: "AB only", type: "common_misconception", label: "B" },
{ formula: "A and B only", type: "calculation_error", label: "C" },
{ formula: "O only", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.2, aStd: 0.1, bMean: -0.4, bStd: 0.15, cMean: 0.25, cStd: 0.03 },
distractorProfile: { A: 0.58, B: 0.18, C: 0.14, D: 0.10 },
_compute: () => [
{ label: "A", text: "A, B, AB, and O (universal recipient)", correct: true },
{ label: "B", text: "AB only", correct: false },
{ label: "C", text: "A and B only", correct: false },
{ label: "D", text: "O only", correct: false },
],
},
{
id: "q31", subject: "Biology", topic: "Molecular Biology", subtopic: "DNA Replication",
bloomLevel: "remember",
templateText: "DNA replication is described as semi-conservative. In the {{n}}th generation after replication, how many DNA molecules contain only new strands?",
parameters: [{ name: "n", type: "integer", values: [1, 2, 3, 4] }],
answerFormula: "2^n - 2 (for n>=2), 0 (for n=1)",
distractors: [
{ formula: "2^n", type: "common_misconception", label: "B" },
{ formula: "2^(n-1)", type: "calculation_error", label: "C" },
{ formula: "n", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.1, aStd: 0.12, bMean: 0.6, bStd: 0.2, cMean: 0.2, cStd: 0.04 },
distractorProfile: { A: 0.42, B: 0.25, C: 0.20, D: 0.13 },
_compute: (n) => {
const ans = n >= 2 ? Math.pow(2, n) - 2 : 0;
return [
{ label: "A", text: `${ans}`, correct: true },
{ label: "B", text: `${Math.pow(2, n)}`, correct: false },
{ label: "C", text: `${Math.pow(2, n - 1)}`, correct: false },
{ label: "D", text: `${n}`, correct: false },
];
},
},
{
id: "q32", subject: "Biology", topic: "Plant Biology", subtopic: "Photosynthesis",
bloomLevel: "remember",
templateText: "What is the net equation for photosynthesis? Choose the correct balanced equation.",
parameters: [],
answerFormula: "6CO2 + 6H2O -> C6H12O6 + 6O2",
distractors: [
{ formula: "reversed equation", type: "common_misconception", label: "B" },
{ formula: "wrong coefficients", type: "calculation_error", label: "C" },
{ formula: "missing water", type: "unit_error", label: "D" },
],
irtParams: { aMean: 1.3, aStd: 0.09, bMean: -0.7, bStd: 0.13, cMean: 0.25, cStd: 0.03 },
distractorProfile: { A: 0.65, B: 0.15, C: 0.12, D: 0.08 },
_compute: () => [
{ label: "A", text: "6CO₂ + 6H₂O → C₆H₁₂O₆ + 6O₂", correct: true },
{ label: "B", text: "C₆H₁₂O₆ + 6O₂ → 6CO₂ + 6H₂O", correct: false },
{ label: "C", text: "3CO₂ + 3H₂O → C₃H₆O₃ + 3O₂", correct: false },
{ label: "D", text: "6CO₂ → C₆H₁₂O₆ + 6O₂", correct: false },
],
},
];
// Register seed questions in db
seedQuestions.forEach((q) => {
db.questions[q.id] = {
id: q.id,
subject: q.subject,
topic: q.topic,
subtopic: q.subtopic || "",
bloomLevel: q.bloomLevel || "apply",
templateText: q.templateText,
parameters: q.parameters,
answerFormula: q.answerFormula,
distractors: q.distractors,
calibrationStatus: "calibrated",
fieldTestCount: 250 + Math.floor(Math.random() * 200),
calibrationDate: "2025-12-15T00:00:00.000Z",
irtParams: q.irtParams,
distractorProfile: q.distractorProfile,
source: "seed",
status: "CALIBRATED",
deleted: false,
createdAt: "2025-12-01T10:00:00.000Z",
updatedAt: "2025-12-15T10:00:00.000Z",
};
});
// ─── SEED CENTERS ─────────────────────────────────────────────────────────────
const seedCenters = [
{ id: "center_delhi", name: "Delhi Examination Center", city: "New Delhi", state: "Delhi", capacity: 200, seatCount: 200, seats: 200, status: "ready" },
{ id: "center_mumbai", name: "Mumbai Examination Center", city: "Mumbai", state: "Maharashtra", capacity: 300, seatCount: 300, seats: 300, status: "ready" },
{ id: "center_bangalore", name: "Bangalore Examination Center", city: "Bangalore", state: "Karnataka", capacity: 250, seatCount: 250, seats: 250, status: "ready" },
{ id: "center_kolkata", name: "Kolkata Examination Center", city: "Kolkata", state: "West Bengal", capacity: 150, seatCount: 150, seats: 150, status: "ready" },
{ id: "center_chennai", name: "Chennai Examination Center", city: "Chennai", state: "Tamil Nadu", capacity: 200, seatCount: 200, seats: 200, status: "ready" },
];
seedCenters.forEach((c) => { db.centers[c.id] = c; });
// ─── SEED EXAM ────────────────────────────────────────────────────────────────
const DEMO_EXAM_ID = "EXAM_DEMO2026";
db.exams[DEMO_EXAM_ID] = {
id: DEMO_EXAM_ID,
name: "NEET Mock Examination 2026",
date: "2026-04-15",
subjects: ["Physics", "Chemistry", "Math", "Biology"],
totalQuestions: 30,
totalCandidates: 2,
questionsPerPaper: 10,
status: "ACTIVE",
blueprint: {
difficultyDist: { easy: 30, medium: 50, hard: 20 },
topicCoverage: { Physics: 30, Chemistry: 25, Math: 25, Biology: 20 },
questionsPerPaper: 10,
},
centers: [
{ centerId: "center_delhi", seatCount: 1 },
{ centerId: "center_mumbai", seatCount: 1 },
],
activatedAt: "2026-04-15T09:00:00.000Z",
createdAt: "2026-03-01T10:00:00.000Z",
updatedAt: "2026-04-15T09:00:00.000Z",
};
// ─── SEED CANDIDATES ─────────────────────────────────────────────────────────
const DEMO_CANDIDATES = [
{
id: "CAND_001",
admitCard: "ADMIT2026001",
name: "Priya Sharma",
email: "priya@example.com",
examId: DEMO_EXAM_ID,
centerId: "center_delhi",
seatNum: 1,
registeredAt: "2026-03-10T10:00:00.000Z",
},
{
id: "CAND_002",
admitCard: "ADMIT2026002",
name: "Rahul Verma",
email: "rahul@example.com",
examId: DEMO_EXAM_ID,
centerId: "center_mumbai",
seatNum: 1,
registeredAt: "2026-03-10T11:00:00.000Z",
},
];
DEMO_CANDIDATES.forEach((c) => { db.candidates[c.id] = c; });
// ─── SEED USERS ──────────────────────────────────────────────────────────────
const SEED_USERS = [
{ id: "user_admin", email: "admin@pariksha.dmj.one", password: "admin123", role: "SUPER_ADMIN", name: "System Admin" },
{ id: "user_controller", email: "controller@pariksha.dmj.one", password: "controller123", role: "EXAM_CONTROLLER", name: "Exam Controller" },
{ id: "user_faculty", email: "faculty@pariksha.dmj.one", password: "faculty123", role: "QUESTION_SETTER", name: "Dr. Question Setter" },
{ id: "user_candidate1", email: "priya@example.com", password: "candidate123", role: "CANDIDATE", name: "Priya Sharma", candidateId: "CAND_001", admitCard: "ADMIT2026001" },
{ id: "user_candidate2", email: "rahul@example.com", password: "candidate123", role: "CANDIDATE", name: "Rahul Verma", candidateId: "CAND_002", admitCard: "ADMIT2026002" },
];
SEED_USERS.forEach((u) => { db.users[u.email] = u; });
// ─── SEED AUDIT EVENTS ──────────────────────────────────────────────────────
addAuditEvent("exam_created", "user_admin", DEMO_EXAM_ID, { name: "NEET Mock Examination 2026" });
addAuditEvent("blueprint_set", "user_controller", DEMO_EXAM_ID, { questionsPerPaper: 10 });
addAuditEvent("exam_activated", "user_controller", DEMO_EXAM_ID, {});
// ─── GEMINI API CALL ─────────────────────────────────────────────────────────
function callGemini(subject, topic, subtopic, bloomLevel) {
return new Promise((resolve, reject) => {
if (!GEMINI_API_KEY) return reject(new Error("GEMINI_API_KEY not set"));
const prompt = `You are an expert question paper setter for competitive exams like NEET/JEE.
Generate a parameterized multiple-choice question template for:
- Subject: ${subject}
- Topic: ${topic}
${subtopic ? `- Subtopic: ${subtopic}` : ""}
- Bloom's Level: ${bloomLevel || "apply"}
Return ONLY valid JSON with this exact structure (no markdown, no backticks, no explanation):
{
"templateText": "question text with {{param_name}} placeholders for variable numerical values",
"parameters": [{"name": "param_name", "type": "float", "min": 1, "max": 100, "step": 1}],
"answerFormula": "mathematical formula using param names that gives the correct answer",
"distractors": [
{"formula": "common wrong formula 1", "type": "common_misconception", "label": "B"},