-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
5988 lines (5624 loc) · 214 KB
/
app.js
File metadata and controls
5988 lines (5624 loc) · 214 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 questionSets = {
swift: {
beginner: [
{
type: "vocab",
prompt: "In Swift, what does let mean?",
options: [
"A mutable variable",
"A constant value that cannot be changed",
"A type annotation keyword",
"A function return keyword"
],
answer: 1,
explanation: "let creates a constant. Use var for values that can change."
},
{
type: "tf",
prompt: "True or False: Text(\"Hello\") is valid SwiftUI syntax.",
options: ["True", "False"],
answer: 0,
explanation: "True. Text is the base view for displaying strings."
},
{
type: "code",
prompt: "Write 2-4 lines of Swift that declare `name` as a String constant with value \"Taylor\" and print `Name: <value>` using string interpolation.",
checks: ["let name: string", "\"taylor\"", "print(", "\\(name)"],
sample: "let name: String = \"Taylor\"\nprint(\"Name: \\(name)\")",
autofill: ["let name: String = \"Taylor\"", "print(\"Name: \\(name)\")", "String", "\\(name)"]
},
{
type: "vocab",
prompt: "Which keyword declares a variable that can change in Swift?",
options: ["let", "var", "func", "class"],
answer: 1,
explanation: "var is used for mutable values."
},
{
type: "tf",
prompt: "True or False: Swift type annotations can be written like var age: Int = 21.",
options: ["True", "False"],
answer: 0,
explanation: "True. Type annotations use a colon followed by the type."
}
],
medium: [
{
type: "vocab",
prompt: "Which wrapper is commonly used to observe an ObservableObject inside a SwiftUI view?",
options: ["@Binding", "@State", "@ObservedObject", "@Environment"],
answer: 2,
explanation: "@ObservedObject subscribes a view to an ObservableObject's published changes."
},
{
type: "tf",
prompt: "True or False: A SwiftUI view body must produce something that conforms to View.",
options: ["True", "False"],
answer: 0,
explanation: "True. The body property returns some View."
},
{
type: "code",
prompt: "Write 6-10 lines of SwiftUI that include `@State private var count = 0` inside a `ContentView`, with `var body: some View`, a `Text` showing count, and a Button that increments by 1.",
checks: ["struct contentview: view", "@state private var count = 0", "var body: some view", "text(\"count:", "button(||button {", "count += 1"],
sample:
"struct ContentView: View {\n @State private var count = 0\n\n var body: some View {\n VStack {\n Text(\"Count: \\(count)\")\n Button(\"Add 1\") { count += 1 }\n }\n }\n}",
autofill: ["struct ContentView: View {", "@State private var count = 0", "var body: some View {", "VStack {", "Text(\"Count: \\(count)\")", "Button(\"Add 1\") { count += 1 }", "}"]
},
{
type: "vocab",
prompt: "In SwiftUI, which stack arranges views horizontally?",
options: ["VStack", "ZStack", "HStack", "List"],
answer: 2,
explanation: "HStack places child views from left to right."
},
{
type: "tf",
prompt: "True or False: @Binding lets a child view read and write a value owned by a parent.",
options: ["True", "False"],
answer: 0,
explanation: "True. @Binding passes a two-way connection to state."
}
],
advanced: [
{
type: "vocab",
prompt: "What does @MainActor help guarantee in Swift concurrency code?",
options: [
"Background-only execution",
"UI-related code executes on the main actor",
"Automatic error retries",
"Compile-time memory allocation"
],
answer: 1,
explanation: "@MainActor isolates code to the main actor, commonly used for UI updates."
},
{
type: "tf",
prompt: "True or False: You can call async functions from a Task block using await.",
options: ["True", "False"],
answer: 0,
explanation: "True. Task creates an asynchronous context where await is valid."
},
{
type: "code",
prompt: "Write 4-8 lines defining a Swift `Todo` model that conforms to `Identifiable` and `Codable`, with `id: UUID = UUID()` and `title: String`.",
checks: ["struct todo: identifiable, codable", "let id: uuid = uuid()", "let title: string"],
sample: "struct Todo: Identifiable, Codable {\n let id: UUID = UUID()\n let title: String\n}",
autofill: ["struct Todo: Identifiable, Codable {", "let id: UUID = UUID()", "let title: String", "}"]
},
{
type: "vocab",
prompt: "Which protocol is commonly required to decode JSON into Swift models?",
options: ["Equatable", "Codable", "Hashable", "Sequence"],
answer: 1,
explanation: "Codable combines Encodable and Decodable for data conversion."
},
{
type: "code",
prompt: "Write 5-9 lines of Swift for `func greet(name: String) -> String` that uses `guard !name.isEmpty` and returns `Hello, <name>` with interpolation.",
checks: ["func greet(name: string) -> string", "guard !name.isempty", "else", "return \"hello, guest\"", "return \"hello, \\(name)\""],
sample:
"func greet(name: String) -> String {\n guard !name.isEmpty else {\n return \"Hello, Guest\"\n }\n return \"Hello, \\(name)\"\n}",
autofill: ["func greet(name: String) -> String {", "guard !name.isEmpty else {", "return \"Hello, Guest\"", "return \"Hello, \\(name)\"", "}"]
}
]
},
web: {
beginner: [
{
type: "vocab",
prompt: "What does HTML stand for?",
options: [
"HyperText Markup Language",
"HighText Machine Language",
"Hyperlink and Text Management Language",
"Home Tool Markup Language"
],
answer: 0,
explanation: "HTML stands for HyperText Markup Language."
},
{
type: "tf",
prompt: "True or False: CSS is used to style how web pages look.",
options: ["True", "False"],
answer: 0,
explanation: "True. CSS controls presentation and layout."
},
{
type: "code",
prompt: "Write 2-4 lines of HTML that create an h1 with text Hello Web.",
checks: ["<h1", "Hello Web", "</h1>"],
sample: "<h1>Hello Web</h1>"
},
{
type: "vocab",
prompt: "Which CSS property changes text color?",
options: ["font-style", "text-transform", "color", "background"],
answer: 2,
explanation: "Use color to set the foreground text color."
},
{
type: "tf",
prompt: "True or False: JavaScript can update page content after the page has loaded.",
options: ["True", "False"],
answer: 0,
explanation: "True. JavaScript can modify the DOM at runtime."
}
],
medium: [
{
type: "vocab",
prompt: "Which JavaScript method is commonly used to attach an event handler to a DOM element?",
options: ["setInterval", "addEventListener", "querySelector", "appendChild"],
answer: 1,
explanation: "addEventListener registers event callbacks like click, input, and submit."
},
{
type: "tf",
prompt: "True or False: const prevents reassignment, but object properties can still be changed.",
options: ["True", "False"],
answer: 0,
explanation: "True. const locks the binding, not deep object mutation."
},
{
type: "code",
prompt: "Write 4-7 lines of JavaScript that selects a button with id saveBtn and toggles class active on click.",
checks: ["querySelector", "#saveBtn", "addEventListener", "click", "classList.toggle"],
sample:
"const saveBtn = document.querySelector('#saveBtn')\nsaveBtn.addEventListener('click', () => {\n saveBtn.classList.toggle('active')\n})"
},
{
type: "vocab",
prompt: "Which array method creates a new array by transforming each element?",
options: ["forEach", "map", "filter", "find"],
answer: 1,
explanation: "map returns a new array with transformed values."
},
{
type: "code",
prompt: "Write 3-6 lines of CSS that center text in a class named card and add 16px padding.",
checks: [".card", "text-align", "center", "padding", "16px"],
sample: ".card {\n text-align: center;\n padding: 16px;\n}"
}
],
advanced: [
{
type: "vocab",
prompt: "Which CSS layout system is designed for two-dimensional layout control (rows and columns)?",
options: ["Flexbox", "Grid", "Float", "Inline-block"],
answer: 1,
explanation: "CSS Grid is designed for two-dimensional layouts."
},
{
type: "tf",
prompt: "True or False: In fetch, you typically parse JSON by calling await response.json().",
options: ["True", "False"],
answer: 0,
explanation: "True. response.json() parses the body into a JavaScript object."
},
{
type: "code",
prompt: "Write 4-8 lines of async JavaScript that fetches /api/users, awaits JSON, and logs the data.",
checks: ["async", "fetch", "await", "response.json", "console.log"],
sample:
"async function loadUsers() {\n const response = await fetch('/api/users')\n const data = await response.json()\n console.log(data)\n}"
},
{
type: "vocab",
prompt: "What does CORS primarily control in browsers?",
options: [
"How CSS is minified",
"Cross-origin request permissions",
"JavaScript variable scope",
"Image compression format"
],
answer: 1,
explanation: "CORS is a browser security policy for cross-origin HTTP requests."
},
{
type: "tf",
prompt: "True or False: CSS Grid can place items by named areas.",
options: ["True", "False"],
answer: 0,
explanation: "True. grid-template-areas lets you assign named layout regions."
}
]
},
react: {
beginner: [
{
type: "vocab",
prompt: "What is JSX in React?",
options: [
"A CSS preprocessor",
"A syntax extension that lets you write HTML-like markup in JavaScript",
"A built-in database",
"A package manager"
],
answer: 1,
explanation: "JSX is a JavaScript syntax extension used to describe UI."
},
{
type: "tf",
prompt: "True or False: React components should start with a capital letter.",
options: ["True", "False"],
answer: 0,
explanation: "True. Component names are capitalized by convention and parsing rules."
},
{
type: "code",
prompt: "Write 2-4 lines for a React component named Greeting that returns an h1 with text Hello React.",
checks: ["function Greeting", "return", "<h1", "Hello React"],
sample: "function Greeting() {\n return <h1>Hello React</h1>\n}"
},
{
type: "vocab",
prompt: "How do components usually receive input data from a parent in React?",
options: ["props", "routes", "reducers", "keys"],
answer: 0,
explanation: "Props are the standard way to pass data into child components."
},
{
type: "tf",
prompt: "True or False: A React component can return only one root JSX element (or a fragment).",
options: ["True", "False"],
answer: 0,
explanation: "True. JSX must return a single root wrapper or fragment."
}
],
medium: [
{
type: "vocab",
prompt: "What is the primary purpose of useEffect in React?",
options: [
"Create routes",
"Run side effects after render",
"Define CSS variables",
"Compile JSX"
],
answer: 1,
explanation: "useEffect is used for side effects like fetching data or subscriptions."
},
{
type: "tf",
prompt: "True or False: Directly mutating state objects is recommended in React.",
options: ["True", "False"],
answer: 1,
explanation: "False. State should be updated immutably via setter functions."
},
{
type: "code",
prompt: "Write 4-8 lines with useState and useEffect that logs count whenever count changes.",
checks: ["useState", "useEffect", "count", "console.log", "[count]"],
sample:
"const [count, setCount] = useState(0)\nuseEffect(() => {\n console.log(count)\n}, [count])"
},
{
type: "vocab",
prompt: "What is the typical purpose of a key prop when rendering lists in React?",
options: [
"Style each list item",
"Help React track item identity between renders",
"Encrypt list data",
"Sort items alphabetically"
],
answer: 1,
explanation: "Keys help React reconcile list item changes efficiently."
},
{
type: "tf",
prompt: "True or False: useEffect runs after render by default.",
options: ["True", "False"],
answer: 0,
explanation: "True. Effects run after React commits updates to the DOM."
}
],
advanced: [
{
type: "vocab",
prompt: "Which hook memoizes a computed value to avoid unnecessary recalculation?",
options: ["useRef", "useMemo", "useEffect", "useId"],
answer: 1,
explanation: "useMemo memoizes computed values based on dependencies."
},
{
type: "tf",
prompt: "True or False: Using array index as key is always the best choice for dynamic lists.",
options: ["True", "False"],
answer: 1,
explanation: "False. Stable unique keys are preferred, especially when list order can change."
},
{
type: "code",
prompt: "Write 4-8 lines for a custom hook useToggle that stores a boolean and returns value plus a toggle function.",
checks: ["function useToggle", "useState", "toggle", "set", "return"],
sample:
"function useToggle(initial = false) {\n const [value, setValue] = useState(initial)\n const toggle = () => setValue((v) => !v)\n return [value, toggle]\n}"
},
{
type: "vocab",
prompt: "Which API is commonly used in React to provide global state without prop drilling?",
options: ["Context API", "localStorage", "setInterval", "ReactDOM.render"],
answer: 0,
explanation: "The Context API shares values across component trees."
},
{
type: "code",
prompt: "Write 4-8 lines that memoize a filtered array named visibleItems using useMemo with dependencies [items, query].",
checks: ["useMemo", "visibleItems", "items", "query", "[items, query]"],
sample:
"const visibleItems = useMemo(() => {\n return items.filter((item) => item.name.includes(query))\n}, [items, query])"
}
]
},
python: {
beginner: [],
medium: [],
advanced: []
},
typescript: {
beginner: [],
medium: [],
advanced: []
},
markdown: {
beginner: [],
medium: [],
advanced: []
},
java: {
beginner: [],
medium: [],
advanced: []
},
kotlin: {
beginner: [],
medium: [],
advanced: []
},
csharp: {
beginner: [],
medium: [],
advanced: []
},
sql: {
beginner: [],
medium: [],
advanced: []
},
go: {
beginner: [],
medium: [],
advanced: []
},
rust: {
beginner: [],
medium: [],
advanced: []
},
cpp: {
beginner: [],
medium: [],
advanced: []
},
php: {
beginner: [],
medium: [],
advanced: []
},
dart: {
beginner: [],
medium: [],
advanced: []
},
bash: {
beginner: [],
medium: [],
advanced: []
},
ides: {
beginner: [],
medium: [],
advanced: []
},
sourcecontrol: {
beginner: [],
medium: [],
advanced: []
}
};
const extraQuestionSets = {
swift: {
beginner: [
{
type: "vocab",
prompt: "Which Swift type is best for whole numbers like 3, 42, or 100?",
options: ["Double", "String", "Int", "Bool"],
answer: 2,
explanation: "Int represents whole numbers."
},
{
type: "code",
prompt: "Write 3-6 lines of Swift that declare a typed city array (`[String]`) and safely print the first city using optional binding.",
checks: ["let cities: [string]", "if let firstcity = cities.first", "print(firstcity)"],
sample: "let cities: [String] = [\"Paris\", \"Rome\", \"Tokyo\"]\nif let firstCity = cities.first {\n print(firstCity)\n}",
autofill: ["let cities: [String] = [\"Paris\", \"Rome\", \"Tokyo\"]", "if let firstCity = cities.first {", "print(firstCity)", "}"]
},
{
type: "tf",
prompt: "True or False: In Swift, strings are written with double quotes.",
options: ["True", "False"],
answer: 0,
explanation: "True. String literals use double quotes."
},
{
type: "output",
prompt: "Output Prediction: What is printed by this Swift code? let count = 2; print(\"Count: \\(count)\")",
options: ["Count: count", "Count: 2", "2", "Nothing"],
answer: 1,
explanation: "String interpolation inserts the value of count, so it prints Count: 2."
},
{
type: "debug",
prompt: "Debug This: Fix the code so it declares a mutable score and then increments it.",
starterCode: "let score = 0\nscore += 1",
checks: ["var score = 0", "score += 1"],
sample: "var score = 0\nscore += 1"
}
],
medium: [
{
type: "vocab",
prompt: "Which SwiftUI wrapper is commonly used for view-local value changes like toggles or counters?",
options: ["@State", "@EnvironmentObject", "@Published", "@AppStorage"],
answer: 0,
explanation: "@State is used for local mutable view state."
},
{
type: "code",
prompt: "Write 5-9 lines of SwiftUI that declare `@State private var isOn = false`, add a `Toggle`, and show a `Text` label that changes between On and Off.",
checks: ["@state private var ison = false", "toggle(", "$ison", "text(ison ?"],
sample:
"@State private var isOn = false\n\nVStack {\n Toggle(\"Notifications\", isOn: $isOn)\n Text(isOn ? \"On\" : \"Off\")\n}",
autofill: ["@State private var isOn = false", "VStack {", "Toggle(\"Notifications\", isOn: $isOn)", "Text(isOn ? \"On\" : \"Off\")", "}"]
},
{
type: "code",
prompt: "Visual Replication: Write 5-10 lines of SwiftUI to recreate the target preview: two circles next to each other in one row.",
checks: ["hstack", "circle()", "fill(.blue)", "fill(.green)", ".frame("],
sample:
"HStack(spacing: 12) {\n Circle()\n .fill(.blue)\n .frame(width: 44, height: 44)\n\n Circle()\n .fill(.green)\n .frame(width: 44, height: 44)\n}",
autofill: ["HStack(spacing: 12) {", "Circle()", ".fill(.blue)", ".fill(.green)", ".frame(width: 44, height: 44)", "}"],
visualTarget: "swift-two-circles-row",
visualTitle: "Target Preview"
},
{
type: "code",
prompt: "Visual Replication: Write 6-10 lines of SwiftUI to recreate the target preview: a VStack with a title and a button below it.",
checks: ["vstack", "text(", "button(||button {", "spacing:"],
sample:
"VStack(spacing: 10) {\n Text(\"Profile\")\n .font(.headline)\n\n Button(\"Continue\") {\n print(\"Tapped\")\n }\n}",
autofill: ["VStack(spacing: 10) {", "Text(\"Profile\")", ".font(.headline)", "Button(\"Continue\") {", "print(\"Tapped\")", "}", "}"],
visualTarget: "swift-vstack-title-button",
visualTitle: "Target Preview"
},
{
type: "tf",
prompt: "True or False: A computed property can return a value without storing it directly.",
options: ["True", "False"],
answer: 0,
explanation: "True. Computed properties derive values from other data."
},
{
type: "output",
prompt: "Output Prediction: What does this Swift condition print? let isReady = true; print(isReady ? \"Go\" : \"Stop\")",
options: ["true", "Go", "Stop", "No output"],
answer: 1,
explanation: "The condition is true, so the first branch is printed: Go."
},
{
type: "debug",
prompt: "Debug This: Fix the SwiftUI view so tapping the button updates count.",
starterCode: "struct CounterView: View {\n @State private var count = 0\n\n var body: some View {\n VStack {\n Text(\"Count: \\(count)\")\n Button(\"Add\") {\n count + 1\n }\n }\n }\n}",
checks: ["count += 1"],
sample: "struct CounterView: View {\n @State private var count = 0\n\n var body: some View {\n VStack {\n Text(\"Count: \\(count)\")\n Button(\"Add\") {\n count += 1\n }\n }\n }\n}"
}
],
advanced: [
{
type: "vocab",
prompt: "What keyword is used to define an asynchronous function in Swift?",
options: ["sync", "await", "async", "actor"],
answer: 2,
explanation: "Functions are marked async to indicate asynchronous behavior."
},
{
type: "code",
prompt: "Write 5-9 lines of Swift for an enum `LoadState` with cases `idle`, `loading`, `success`, and `failure(Error)`.",
checks: ["enum loadstate", "case idle", "case loading", "case success", "case failure(error)"],
sample: "enum LoadState {\n case idle\n case loading\n case success\n case failure(Error)\n}",
autofill: ["enum LoadState {", "case idle", "case loading", "case success", "case failure(Error)", "}"]
},
{
type: "tf",
prompt: "True or False: Actors in Swift help protect mutable state from data races.",
options: ["True", "False"],
answer: 0,
explanation: "True. Actors provide isolation for mutable state."
},
{
type: "output",
prompt: "Output Prediction: What is returned? func greet(_ name: String?) -> String { name ?? \"Guest\" } then greet(nil)",
options: ["nil", "name", "Guest", "Error"],
answer: 2,
explanation: "The nil-coalescing operator returns the fallback value Guest when name is nil."
},
{
type: "debug",
prompt: "Debug This: Fix the async function so it compiles and returns the fetched title.",
starterCode: "func loadTitle() async -> String {\n let title = await fetchTitle()\n return\n}",
checks: ["return title"],
sample: "func loadTitle() async -> String {\n let title = await fetchTitle()\n return title\n}"
}
]
},
web: {
beginner: [
{
type: "vocab",
prompt: "Which HTML element is best for a clickable navigation link?",
options: ["<button>", "<a>", "<div>", "<section>"],
answer: 1,
explanation: "Use <a> for navigation links with href destinations."
},
{
type: "code",
prompt: "Write 3-5 lines of HTML for a labeled text input with id username.",
checks: ["<label", "for=\"username\"", "<input", "id=\"username\""],
sample: "<label for=\"username\">Username</label>\n<input id=\"username\" type=\"text\" />"
},
{
type: "tf",
prompt: "True or False: CSS classes can be reused on multiple elements.",
options: ["True", "False"],
answer: 0,
explanation: "True. Classes are designed for reusable styling."
},
{
type: "output",
prompt: "Output Prediction: What appears in the browser for <h1>Hello</h1>?",
options: ["A level-1 heading saying Hello", "Nothing", "A JavaScript alert", "A link"],
answer: 0,
explanation: "An h1 element renders a top-level heading with the text Hello."
},
{
type: "debug",
prompt: "Debug This: Fix the HTML so the link works.",
starterCode: "<a href=\"/about\">About<a>",
checks: ["</a>"],
sample: "<a href=\"/about\">About</a>"
}
],
medium: [
{
type: "vocab",
prompt: "Which JavaScript method returns only elements that pass a condition?",
options: ["map", "reduce", "filter", "join"],
answer: 2,
explanation: "filter creates a new array of matching elements."
},
{
type: "code",
prompt: "Write 4-8 lines of JavaScript that gets an input with id search and logs its value on input events.",
checks: ["querySelector", "#search", "addEventListener", "input", "console.log"],
sample: "const search = document.querySelector('#search')\nsearch.addEventListener('input', (event) => {\n console.log(event.target.value)\n})"
},
{
type: "tf",
prompt: "True or False: const arrays can still be mutated with methods like push.",
options: ["True", "False"],
answer: 0,
explanation: "True. const prevents reassignment, not mutation of nested data."
},
{
type: "output",
prompt: "Output Prediction: What does this print? const n = 3; console.log(n * 2)",
options: ["3", "6", "32", "undefined"],
answer: 1,
explanation: "3 multiplied by 2 is 6."
},
{
type: "debug",
prompt: "Debug This: Fix the event listener so the click handler runs.",
starterCode: "const btn = document.querySelector('#saveBtn')\nbtn.addEventListener('click', () => {\n console.log('saved')\n}",
checks: [");"],
sample: "const btn = document.querySelector('#saveBtn')\nbtn.addEventListener('click', () => {\n console.log('saved')\n});"
}
],
advanced: [
{
type: "vocab",
prompt: "Which HTTP status range generally indicates successful requests?",
options: ["100s", "200s", "300s", "500s"],
answer: 1,
explanation: "2xx status codes are usually successful responses."
},
{
type: "code",
prompt: "Write 4-8 lines that use try/catch around fetch('/api/cities') and log errors.",
checks: ["try", "catch", "fetch", "console.log"],
sample:
"async function loadCities() {\n try {\n const response = await fetch('/api/cities')\n console.log(await response.json())\n } catch (error) {\n console.log(error)\n }\n}"
},
{
type: "tf",
prompt: "True or False: Event delegation can reduce the number of event listeners in large lists.",
options: ["True", "False"],
answer: 0,
explanation: "True. One parent listener can handle many child interactions."
},
{
type: "output",
prompt: "Output Prediction: What logs first? console.log('A'); setTimeout(() => console.log('B'), 0); console.log('C');",
options: ["B", "A", "C", "A then C then B"],
answer: 3,
explanation: "Synchronous logs run first (A then C); the timeout callback runs after (B)."
},
{
type: "debug",
prompt: "Debug This: Fix the async code so `data` gets parsed JSON.",
starterCode: "async function load() {\n const response = await fetch('/api/users')\n const data = response.json\n return data\n}",
checks: ["response.json()"],
sample: "async function load() {\n const response = await fetch('/api/users')\n const data = await response.json()\n return data\n}"
}
]
},
react: {
beginner: [
{
type: "vocab",
prompt: "What do props represent in React?",
options: [
"Mutable global state",
"Inputs passed into a component",
"Database tables",
"Only CSS class names"
],
answer: 1,
explanation: "Props are component inputs passed from parent to child."
},
{
type: "code",
prompt: "Write 3-6 lines for a component CityTitle that receives a prop name and renders it in an h2.",
checks: ["function CityTitle", "name", "return", "<h2"],
sample: "function CityTitle({ name }) {\n return <h2>{name}</h2>\n}"
},
{
type: "tf",
prompt: "True or False: React re-renders when state changes through its setter function.",
options: ["True", "False"],
answer: 0,
explanation: "True. Setter calls schedule React updates."
},
{
type: "output",
prompt: "Output Prediction: What does this render? function App(){ return <p>Hello</p> }",
options: ["A paragraph with Hello", "Nothing", "A button", "An error"],
answer: 0,
explanation: "The component returns a paragraph element containing Hello."
},
{
type: "debug",
prompt: "Debug This: Fix the component so JSX compiles correctly.",
starterCode: "function Greeting() {\n return <h1>Hello</h1\n}",
checks: ["return <h1>hello</h1>"],
sample: "function Greeting() {\n return <h1>Hello</h1>\n}"
}
],
medium: [
{
type: "vocab",
prompt: "Which hook stores data that persists between renders but does not trigger re-renders when changed directly?",
options: ["useRef", "useEffect", "useMemo", "useContext"],
answer: 0,
explanation: "useRef stores mutable values that survive renders."
},
{
type: "code",
prompt: "Write 4-8 lines using useState for text and an input that updates text onChange.",
checks: ["useState", "onChange", "set", "value="],
sample:
"const [text, setText] = useState('')\n<input value={text} onChange={(event) => setText(event.target.value)} />"
},
{
type: "tf",
prompt: "True or False: Effects with an empty dependency array typically run once after initial mount.",
options: ["True", "False"],
answer: 0,
explanation: "True. [] generally means run once after first render."
},
{
type: "output",
prompt: "Output Prediction: If count starts at 0, what shows after one `setCount(count + 1)` call and re-render?",
options: ["0", "1", "2", "undefined"],
answer: 1,
explanation: "The next render reflects the updated state value, which is 1."
},
{
type: "debug",
prompt: "Debug This: Fix the list render so React gets stable keys.",
starterCode: "{items.map((item) => (\n <li>{item.name}</li>\n))}",
checks: ["key={item.id}"],
sample: "{items.map((item) => (\n <li key={item.id}>{item.name}</li>\n))}"
}
],
advanced: [
{
type: "vocab",
prompt: "What problem does memoization in React mainly try to reduce?",
options: ["Network latency", "Unnecessary recalculations/renders", "Syntax errors", "Package size"],
answer: 1,
explanation: "Memoization avoids repeated expensive work when dependencies are unchanged."
},
{
type: "code",
prompt: "Write 4-8 lines for a React Context creation and provider value for a theme string.",
checks: ["createContext", "Provider", "value", "theme"],
sample:
"const ThemeContext = createContext('light')\n<ThemeContext.Provider value={theme}>\n {children}\n</ThemeContext.Provider>"
},
{
type: "tf",
prompt: "True or False: useCallback returns a memoized function reference based on dependencies.",
options: ["True", "False"],
answer: 0,
explanation: "True. useCallback memoizes function identity across renders."
},
{
type: "output",
prompt: "Output Prediction: What logs if `useEffect(() => console.log('run'), [query])` and `query` changes once?",
options: ["Nothing", "run once", "run twice", "Syntax error"],
answer: 1,
explanation: "The effect runs when query changes, so it logs run once for that change."
},
{
type: "debug",
prompt: "Debug This: Fix the effect dependencies so stale `query` is not captured.",
starterCode: "useEffect(() => {\n fetchResults(query)\n}, [])",
checks: ["[query]"],
sample: "useEffect(() => {\n fetchResults(query)\n}, [query])"
}
]
},
python: {
beginner: [
{
type: "vocab",
prompt: "Which keyword defines a function in Python?",
options: ["func", "def", "function", "lambda"],
answer: 1,
explanation: "Python uses def to define named functions."
},
{
type: "tf",
prompt: "True or False: Python uses indentation to define code blocks.",
options: ["True", "False"],
answer: 0,
explanation: "True. Indentation is syntactically significant in Python."
},
{
type: "code",
prompt: "Write 2-4 lines of Python that set name = 'Ava' and print 'Hello, Ava'.",
checks: ["name = 'ava'", "print("],
sample: "name = 'Ava'\nprint(f'Hello, {name}')"
},
{
type: "output",
prompt: "Output Prediction: What prints? x = 3\nprint(x * 2)",
options: ["3", "6", "32", "Error"],
answer: 1,
explanation: "3 * 2 evaluates to 6."
},
{
type: "debug",
prompt: "Debug This: Fix the function syntax.",
starterCode: "def greet(name)\n print(name)",
checks: ["def greet(name):", "print(name)"],
sample: "def greet(name):\n print(name)"
}
],
medium: [
{
type: "vocab",
prompt: "What data structure stores key-value pairs in Python?",
options: ["List", "Tuple", "Set", "Dictionary"],
answer: 3,
explanation: "A dictionary maps keys to values."
},
{
type: "tf",
prompt: "True or False: List comprehensions create a new list.",
options: ["True", "False"],
answer: 0,
explanation: "True. They return a new list expression result."
},
{
type: "code",
prompt: "Write 3-6 lines to create nums = [1,2,3] and print squares using a list comprehension.",
checks: ["nums = [1, 2, 3]", "[n * n for n in nums]", "print("],
sample: "nums = [1, 2, 3]\nsquares = [n * n for n in nums]\nprint(squares)"
},
{
type: "output",
prompt: "Output Prediction: What prints? values = [1, 2, 3]\nprint(len(values))",
options: ["2", "3", "[1,2,3]", "Error"],
answer: 1,
explanation: "len on a 3-item list returns 3."
},
{
type: "debug",
prompt: "Debug This: Fix the append usage.",
starterCode: "items = [1, 2]\nitems.add(3)\nprint(items)",
checks: ["items.append(3)"],
sample: "items = [1, 2]\nitems.append(3)\nprint(items)"
}
],
advanced: [
{
type: "vocab",
prompt: "Which keyword is used to handle exceptions in Python?",
options: ["catch", "except", "trap", "error"],
answer: 1,
explanation: "Python catches exceptions with except."
},
{
type: "tf",
prompt: "True or False: A generator function uses yield.",
options: ["True", "False"],
answer: 0,
explanation: "True. yield produces values lazily."
},
{
type: "code",
prompt: "Write 4-8 lines defining a function safe_div(a,b) that returns None when b == 0.",
checks: ["def safe_div(a, b):", "if b == 0", "return none", "return a / b"],
sample: "def safe_div(a, b):\n if b == 0:\n return None\n return a / b"
},
{
type: "output",
prompt: "Output Prediction: What prints? print('A' + str(2))",
options: ["A", "2", "A2", "Error"],
answer: 2,
explanation: "The string concatenation outputs A2."
},
{
type: "debug",
prompt: "Debug This: Fix this exception handling block.",
starterCode: "try:\n x = 1 / 0\nexcept ZeroDivisionError\n print('bad')",
checks: ["except zerodivisionerror:"],
sample: "try:\n x = 1 / 0\nexcept ZeroDivisionError:\n print('bad')"
}
]
},
typescript: {
beginner: [
{
type: "vocab",
prompt: "What TypeScript type would you use for whole numbers?",
options: ["int", "number", "float", "numeric"],
answer: 1,
explanation: "TypeScript uses number for all numeric values."
},
{
type: "tf",
prompt: "True or False: TypeScript is a superset of JavaScript.",
options: ["True", "False"],
answer: 0,
explanation: "True. TypeScript adds static typing to JavaScript."
},
{
type: "code",
prompt: "Write 2-4 lines declaring a typed variable title: string with value 'Intro' and log it.",
checks: ["const title: string = 'intro'", "console.log(title)"],
sample: "const title: string = 'Intro'\nconsole.log(title)"
},
{
type: "output",
prompt: "Output Prediction: What logs? const n: number = 5; console.log(n + 1)",
options: ["5", "6", "51", "Error"],
answer: 1,
explanation: "n + 1 evaluates to 6."
},
{
type: "debug",
prompt: "Debug This: Fix the type annotation.",
starterCode: "let age: string = 21",
checks: ["let age: number = 21"],
sample: "let age: number = 21"
}
],
medium: [
{
type: "vocab",
prompt: "What does an interface usually define in TypeScript?",
options: ["Loop control", "Object shape", "Runtime class", "Database schema"],
answer: 1,
explanation: "Interfaces define structural contracts for objects."
},
{
type: "tf",
prompt: "True or False: Optional properties are marked with ? in interfaces.",
options: ["True", "False"],
answer: 0,
explanation: "True. Example: name?: string"
},
{
type: "code",
prompt: "Write 4-8 lines for interface User { id: number; name: string } and a variable user of that type.",
checks: ["interface user", "id: number", "name: string", "const user: user"],
sample: "interface User {\n id: number\n name: string\n}\nconst user: User = { id: 1, name: 'Ava' }"
},
{
type: "output",
prompt: "Output Prediction: What logs? const flags: boolean[] = [true, false]; console.log(flags[0])",
options: ["true", "false", "0", "undefined"],
answer: 0,
explanation: "flags[0] is true."
},
{
type: "debug",
prompt: "Debug This: Fix generic array typing.",
starterCode: "const names: string = ['A', 'B']",
checks: ["const names: string[] = ['a', 'b']"],
sample: "const names: string[] = ['A', 'B']"
}
],
advanced: [
{
type: "vocab",