-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectCode.py
More file actions
735 lines (735 loc) · 21.5 KB
/
projectCode.py
File metadata and controls
735 lines (735 loc) · 21.5 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
//Questions:https:satsuitequestionbank.collegeboard.org/digital/results
//Chat gpt was only used to format the 400 line list :
//had a colabrative partner
//
//==============================================================================
// SAT PRACTICE APP - VARIABLE DECLARATIONS
//==============================================================================
var questionsCorrect = 0; // tracks the user's correct questions
var totalQuestions = 0; // tracks the total number of questions they have done
var currentQuestion = {}; //will take a question from the allQuestion list and be used on screen
var maxQuestions = 20; // max amount of questions the user can attempt per module
var currentModule = 1; // Start in Module 1, and tells current module
var currentDifficulty = "easy"; // default to easy for Module 1
//==============================================================================
// EVENT HANDLERS - START BUTTON
//==============================================================================
// the screen will update to Start Screen when the startbutton is clicked
onEvent("startButton", "click", function () {
// Reset all progress and settings to default values
currentDifficulty = "easy"; // Reset to easy difficulty
currentModule = 1; // <<< add this line
totalQuestions = 0; // Reset question counter
questionsCorrect = 0; // Reset correct answers counter
setScreen("questionScreen"); // Show the question interface
loadRandomQuestion(currentDifficulty); // Load the first question with appropriate difficulty
});
//==============================================================================
// QUESTION DATABASE
//==============================================================================
//question bank
//Used pdf plugged into chatgpt from offical SAT question bank to get contents of the list
var allQuestions = [
// EASY DIFFICULTY QUESTIONS
{
question: "If f(x) = 2x + 3, what is f(4)?",
choices: ["10", "11", "12", "13"],
correct: "11",
difficulty: "easy",
},{
question: "In a triangle, two sides are extended. What is the value of x?",
choices: ["110", "120", "130", "140"],
correct: "120",
difficulty: "easy",
},
{
question: "A store sells two different-sized containers of Greek yogurt. What does the coefficient of x represent in the equation modeling the sales?",
choices: ["Price of small container", "Total sales from large containers", "Price of large container", "Total sales from small containers"],
correct: "Price of small container",
difficulty: "easy",
},
{
question: "Which equation is equivalent to the given equation after dividing by 5?",
choices: ["A", "B", "C", "D"],
correct: "A",
difficulty: "easy",
},
{
question: "Line l is defined by y = -2x + 5. Line m is perpendicular to line l. What is the slope of line m?",
choices: ["1/2", "-1/2", "2", "-2"],
correct: "1/2",
difficulty: "easy",
},
{
question: "The point (2, 3) is a solution to which system of inequalities?",
choices: ["A", "B", "C", "D"],
correct: "A",
difficulty: "easy",
},
{
question: "The solution to a system of equations is (x, y). What is the value of x?",
choices: ["A", "B", "C", "D"],
correct: "C",
difficulty: "easy",
},
{
question: "What value of x satisfies 5x - 3 = 7?",
choices: ["A", "B", "C", "D"],
correct: "A",
difficulty: "easy",
},
{
question: "A roller-coaster car starts 15 feet above the ground and rises 8 feet per second. What equation models the height h after s seconds?",
choices: ["h = 8s + 15", "h = 15s + 8", "h = 8 + 15s", "h = s/8 + 15"],
correct: "h = 8s + 15",
difficulty: "easy",
},
{
question: "The graph of a system of equations is shown. What is the solution to the system?",
choices: ["A", "B", "C", "D"],
correct: "C",
difficulty: "easy",
},
{
question: "If 4x = 20, what is the value of x?",
choices: ["3", "5", "7", "8"],
correct: "5",
difficulty: "easy",
},
{
question: "Solve for x: 8x + 40 = 108.",
choices: ["100", "90", "130", "130"],
correct: "130",
difficulty: "easy",
},
{
question: "If 3x + 5 = 56, what is x?",
choices: ["17", "18", "19", "20"],
correct: "17",
difficulty: "easy",
},
{
question: "If f(x) = x/2 + 3 and f(x) = 7, what is x?",
choices: ["6", "8", "10", "12"],
correct: "8",
difficulty: "easy",
},
{
question: "If f(x) = 2x + b and f(3) = 9, what is b?",
choices: ["1", "2", "3", "4"],
correct: "3",
difficulty: "easy",
},
{
question:
"Gabriella has $60 in savings and deposits $5 per week. How much after 10 weeks?",
choices: ["100", "110", "70", "80"],
correct: "70",
difficulty: "easy",
},
{
question: "Which equation matches 25 calories per lb + 50?",
choices: ["c = 25w + 50", "c = 50w + 25", "c = 25 + 50w", "c = w/25 + 50"],
correct: "c = 25w + 50",
difficulty: "easy",
},
{
question: "If total cost T = 12x, what is T when x = 10?",
choices: ["120", "100", "150", "140"],
correct: "120",
difficulty: "easy",
},
{
question: "Solve: 4x + 2 = 18",
choices: ["4", "5", "6", "7"],
correct: "4",
difficulty: "easy",
},
{
question:
"What system matches: Hiro buys 4 shirts and 2 pants = $86, Sofia 3 shirts and 5 pants = $166?",
choices: ["A", "B", "C", "D"],
correct: "A",
difficulty: "easy",
},
{
question: "A printer makes 42 posters per minute. How many per hour?",
choices: ["2520", "2000", "2400", "2600"],
correct: "2520",
difficulty: "easy",
},
{
question: "A 6-sided die. What's the probability of rolling a 3?",
choices: ["1/6", "1/3", "1/2", "2/3"],
correct: "1/6",
difficulty: "easy",
},
{
question:
"In a group of 40, 10 are blue marbles. What is the probability of picking a blue one?",
choices: ["1/4", "1/3", "2/5", "1/2"],
correct: "1/4",
difficulty: "easy",
},
{
question: "Median of [1, 2, 3, 3, 4, 5, 9]?",
choices: ["2", "3", "4", "9"],
correct: "3",
difficulty: "easy",
},
{
question: "If 3x = 390, what is x?",
choices: ["130", "120", "140", "150"],
correct: "130",
difficulty: "easy",
},
{
question: "Solve: 2x - 4 = 10",
choices: ["6", "7", "8", "9"],
correct: "7",
difficulty: "easy",
},
{
question: "If y = -2x + 8, what is the slope of a perpendicular line?",
choices: ["1/2", "2", "-1/2", "-2"],
correct: "1/2",
difficulty: "easy",
},
{
question: "What is the y-intercept of y = 3x + 7?",
choices: ["3", "7", "10", "-3"],
correct: "7",
difficulty: "easy",
},
{
question: "What is the x-intercept of 3x - 6 = 0?",
choices: ["1", "2", "3", "4"],
correct: "2",
difficulty: "easy",
},
{
question:
"The height of a roller-coaster is h = 8s + 15. What is h when s = 5?",
choices: ["40", "45", "50", "55"],
correct: "55",
difficulty: "easy",
},
{
question: "System of equations intersects at (3, 4). What is y?",
choices: ["2", "3", "4", "5"],
correct: "4",
difficulty: "easy",
},
{
question: "In y = 2x + 5, what is y when x = 3?",
choices: ["10", "11", "12", "13"],
correct: "11",
difficulty: "easy",
},
{
question: "What's the solution to 5x - 3 = 2x + 6?",
choices: ["2", "3", "4", "5"],
correct: "3",
difficulty: "easy",
},
{
question: "Which is equivalent to 3(x + 2) + 4(x - 1)?",
choices: ["7x + 2", "6x + 1", "8x + 5", "5x + 3"],
correct: "7x + 2",
difficulty: "easy",
},
{
question: "Which is equivalent to 2x + 4x - 3 + 5?",
choices: ["6x + 2", "7x - 2", "5x + 3", "6x - 8"],
correct: "6x + 2",
difficulty: "easy",
},
{
question:
"Probability of event A in a sample space of 10 is 0.2. What is the number of A outcomes?",
choices: ["2", "3", "4", "5"],
correct: "2",
difficulty: "easy",
},
{
question: "Simplify: 4a^2 * 2a^3",
choices: ["8a^5", "6a^5", "8a^6", "4a^6"],
correct: "8a^5",
difficulty: "easy",
},
{
question: "Simplify: 6x^2 + 4x",
choices: ["2x(3x + 2)", "2x(x + 2)", "4x(x + 1.5)", "3x(2x + 2)"],
correct: "2x(3x + 2)",
difficulty: "easy",
},
{
question: "Best fit line for a scatterplot that curves upward?",
choices: ["Linear", "Exponential", "Quadratic", "Logarithmic"],
correct: "Quadratic",
difficulty: "easy",
},
{
question: "Ball reaches max height at 3 sec. Which point shows this?",
choices: ["(3, h)", "(0, 0)", "(6, 0)", "(1.5, h)"],
correct: "(3, h)",
difficulty: "easy",
},
{
question: "Coffee cools fastest in which interval?",
choices: ["0–10 min", "30–40 min", "50–60 min", "90–100 min"],
correct: "0–10 min",
difficulty: "easy",
},
{
question: "Ratio m to k = 1:5. If k = 25, what's m?",
choices: ["5", "6", "7", "8"],
correct: "5",
difficulty: "easy",
},
{
question:
"In a survey, 5 out of 8 plan to enroll. If 40 students, how many enroll?",
choices: ["25", "20", "15", "30"],
correct: "25",
difficulty: "easy",
},
{
question: "Device makes 60 items/hour. How many in 3 hours?",
choices: ["180", "150", "200", "170"],
correct: "180",
difficulty: "easy",
},
{
question: "Which inequality is equivalent to 3x < 15?",
choices: ["x < 5", "x > 5", "x <= 5", "x >= 5"],
correct: "x < 5",
difficulty: "easy",
},
{
question: "System: x + y = 4 and x - y = 2. What's x?",
choices: ["3", "2", "4", "5"],
correct: "3",
difficulty: "easy",
},
{
question: "Which expression is equivalent to (2x + 3) + (3x - 1)?",
choices: ["5x + 2", "6x - 1", "4x + 2", "5x - 2"],
correct: "5x + 2",
difficulty: "easy",
},
// Medium and hard questions
{
question: "What values satisfy (x - 5)(x - 2) = 0?",
choices: ["x = 2 or 5", "x = 1 or 2", "x = 3 or 4", "x = 0 or 5"],
correct: "x = 2 or 5",
difficulty: "medium",
},
{
question: "Which is equivalent to (x² + 3x + 2)/(x + 1)?",
choices: ["x + 1", "x + 2", "x + 3", "x + 4"],
correct: "x + 2",
difficulty: "medium",
},
{
question: "Minimum value of f(x) = (x – 3)² + 2?",
choices: ["1", "2", "3", "4"],
correct: "2",
difficulty: "medium",
},
{
question: "What is the median of the data: 3, 5, 7, 9, 11, 13, 15?",
choices: ["5", "7", "9", "11"],
correct: "9",
difficulty: "medium",
},
{
question:
"Space station moves at 4.76 miles/sec. What is that in miles/hour?",
choices: ["285.6", "571.2", "856.8", "17,136.0"],
correct: "17,136.0",
difficulty: "medium",
},
{
question:
"Iceland's density went from 2.5 to 3.3. Land = 100,250 km². How much did population increase?",
choices: ["330,825", "132,330", "125,312", "80,200"],
correct: "80,200",
difficulty: "medium",
},
{
question: "Ratio 4:5 = x:1225. What is x?",
choices: ["980", "1000", "1100", "1125"],
correct: "980",
difficulty: "medium",
},
{
question: "Survey: 87% of 200 residents say yes. Which must be true?",
choices: ["Neither", "I only", "II only", "I and II"],
correct: "Neither",
difficulty: "medium",
},
{
question: "How many fluid ounces in 76 quarts?",
choices: ["2432", "2560", "2400", "2500"],
correct: "2432",
difficulty: "medium",
},
// Starting hard questions
{
question:
"A margin of error of 3% is given for a 30% estimate of heavy texters. What is a correct conclusion?",
choices: [
"About 3% of teens aren't really heavy texters",
"It's not possible % is less than 27%",
"The percent is 33%",
"It's doubtful % is 35%",
],
correct: "It's doubtful % is 35%",
difficulty: "hard",
},
{
question:
"Each cereal serving gives 5% potassium. If p is % of daily value from x servings, what's p in terms of x?",
choices: ["p = x/5", "p = 5x", "p = 5^x", "p = x^5"],
correct: "p = 5x",
difficulty: "hard",
},
{
question:
"The expression 0.75y represents a 25% decrease of y. What % decrease is that?",
choices: ["15%", "20%", "10%", "25%"],
correct: "25%",
difficulty: "hard",
},
{
question:
"Committee has 6 students (15% parents, 45% teachers, 25% admins). How many more teachers than admins?",
choices: ["4", "6", "8", "10"],
correct: "8",
difficulty: "hard",
},
{
question:
"A sample of 40 4th graders shows 32 think announcements are helpful. To whom can we apply the result?",
choices: [
"Only the 40 surveyed",
"All 4th graders at the school",
"All students at school",
"All 4th graders in the county",
],
correct: "All 4th graders at the school",
difficulty: "hard",
},
{
question:
"x is 1/3 the sum of y and z, and y is 2/5 of x. What percent of z is y?",
choices: ["30%", "40%", "50%", "60%"],
correct: "60%",
difficulty: "hard",
},
{
question:
"x is 1/3 of y, y is 2/3 of z, and x is 1/4 of w. What's the value of w?",
choices: ["18", "20", "22", "24"],
correct: "24",
difficulty: "hard",
},
{
question:
"Given 9 integers < 55 with a mean of 34, and 8 values shown, what's the largest integer?",
choices: ["49", "50", "51", "52"],
correct: "52",
difficulty: "hard",
},
{
question:
"27 numbers: mean = 33, median = 33. Adding 7 to values >33 and subtracting 7 from <33, what changes?",
choices: ["Median", "Mean", "Sum", "Standard deviation"],
correct: "Standard deviation",
difficulty: "hard",
},
{
question:
"A tree is selected from rows of birch and maple. Given it's ≥10 ft tall, what's the probability it's maple?",
choices: ["2/5", "1/2", "3/5", "4/5"],
correct: "3/5",
difficulty: "hard",
},
{
question:
"Two integers multiply to 392. One is 2 more than twice the other. What's the smaller integer?",
choices: ["12", "14", "16", "18"],
correct: "14",
difficulty: "hard",
},
{
question:
"The graph of h(x) intersects x-axis at (4 - √32, 0) and (4 + √32, 0). What is t?",
choices: ["1", "2", "4", "8"],
correct: "8",
difficulty: "hard",
},
{
question:
"What is the minimum value of the function f(x) = (x - 6)² + 1728?",
choices: ["0", "6", "1728", "1734"],
correct: "1728",
difficulty: "hard",
},
{
question: "What is the positive solution to the equation |2x - 3| = 15?",
choices: ["6", "7", "8", "9"],
correct: "9",
difficulty: "hard",
},
{
question: "f(x) = -2(x - 1)(x + 3). What is the y-intercept?",
choices: ["6", "-6", "2", "-2"],
correct: "6",
difficulty: "hard",
},
{
question:
"One solution is x = -5 + √21. What is the value of k in x² + 10x + k = 4?",
choices: ["13", "17", "21", "25"],
correct: "17",
difficulty: "hard",
},
{
question:
"Line y = 6x intersects parabola y = x² + kx at one point. What is the value of k?",
choices: ["3", "4", "5", "6"],
correct: "6",
difficulty: "hard",
},
{
question:
"If f(t) = 500(1.02)^t models yearly ads sent since 2000, what does the y-intercept represent?",
choices: [
"Min ads in 10 years was 500",
"Min ads in 0 years was 500",
"Ads sent in 2010",
"Ads sent in 2000",
],
correct: "Ads sent in 2000",
difficulty: "hard",
},
{
question:
"Sequence starts at 3 and each term is 2× previous. Which equation gives the nth term?",
choices: ["a_n = 2^n", "a_n = 3^n", "a_n = 6n", "a_n = 3(2)^(n - 1)"],
correct: "a_n = 3(2)^(n - 1)",
difficulty: "hard",
},
];
//==============================================================================
// FILTERING QUESTIONS BY DIFFICULTY
//==============================================================================
//filters the easy questions out of the allQuestions list
//this is so that on module 1 the user only recieves easy questions
//also could be used in module 2
var easyQuestions = allQuestions.filter(function (q) {
return q.difficulty === "easy";
});
//==============================================================================
// QUESTION SELECTION AND DISPLAY
//==============================================================================
// Select a random question from the list
var randomIndex = randomNumber(0, allQuestions.length - 1);
var currentQuestion = allQuestions[randomIndex];
//Loads a random question from the list, only easy questions for now
//also will check if the user has completed 20 questions and moved on from module 1
function loadRandomQuestion() {
// Check if user has reached the maximum number of questions
if (totalQuestions >= maxQuestions) {
// If max questions reached, show completion screen
setScreen("module1Complete");
setText(
"questionsMissed",
"Module 1 complete! You scored " +
questionsCorrect +
" out of " +
maxQuestions +
"."
);
setText("qRemain", "0!");
return;
}
//creates a number variable to fix the string error problem
//then uses this number variable to load a question into the currentQuestion varibale
var randomIndex = randomNumber(0, easyQuestions.length - 1);
currentQuestion = easyQuestions[randomIndex];
//sets the on screen text boxes to be on the same question as the currentQuestion variable
setText("questionLabel", currentQuestion.question);
setText("choice1", currentQuestion.choices[0]);
setText("choice2", currentQuestion.choices[1]);
setText("choice3", currentQuestion.choices[2]);
setText("choice4", currentQuestion.choices[3]);
//removes the current question from the list to prevent repetition
removeItem(easyQuestions, randomIndex);
//updates the onscreen counter to match the new question count
setText(
"qRemain",
"Remaining questions = " + (maxQuestions - totalQuestions)
);
}
//==============================================================================
// ANSWER CHECKING
//==============================================================================
// This checks the user input against the correct answer
function checkAnswer(userAnswer) {
if (userAnswer == currentQuestion.correct) {
questionsCorrect++;
}
//loads a question and updates the queston counter
totalQuestions++;
loadRandomQuestion();
}
//==============================================================================
// IMPROVED QUESTION LOADING WITH DIFFICULTY SUPPORT
//==============================================================================
// Enhanced version of loadRandomQuestion that supports different difficulty levels
function loadRandomQuestion(difficulty) {
// Filter questions based on specified difficulty level
var questionPool = allQuestions.filter(function (q) {
return q.difficulty == difficulty;
});
// Check if user completed max questions or if we're out of questions
if (totalQuestions >= maxQuestions || questionPool.length === 0) {
// Show appropriate completion screen based on current module
if (currentModule == 1) {
setScreen("module1Complete");
setText(
"questionsMissed",
"Module 1 complete! You scored " +
questionsCorrect +
" out of " +
maxQuestions +
"."
);
} else if (currentModule == 2) {
setScreen("module2Complete");
setText(
"questionsMissed2",
"You finished! Module 2 complete! You scored " +
questionsCorrect +
" out of " +
maxQuestions +
"."
);
}
setText("qRemain", "0!");
return;
}
// Select random question from filtered pool
var randomIndex = randomNumber(0, questionPool.length - 1);
currentQuestion = questionPool[randomIndex];
// Remove selected question from main bank to prevent repetition
removeItem(allQuestions, allQuestions.indexOf(currentQuestion));
// Update UI with new question and choices
setText("questionLabel", currentQuestion.question);
setText("choice1", currentQuestion.choices[0]);
setText("choice2", currentQuestion.choices[1]);
setText("choice3", currentQuestion.choices[2]);
setText("choice4", currentQuestion.choices[3]);
// Update remaining questions counter
setText(
"qRemain",
"Remaining questions = " + (maxQuestions - totalQuestions)
);
}
// Updated answer checking function that works with the difficulty parameter
function checkAnswer(userAnswer) {
// Check if answer is correct and increment counter if it is
if (userAnswer == currentQuestion.correct) {
questionsCorrect++;
}
// Increment total questions counter
totalQuestions++;
// Load next question with current difficulty level
loadRandomQuestion(currentDifficulty);
}
//==============================================================================
// MODULE 2 HANDLING
//==============================================================================
// Start Module 2 based on score
onEvent("startModule2", "click", function () {
// Switch to question screen and reset counters for Module 2
setScreen("questionScreen");
totalQuestions = 0;
currentModule = 2; // <<< add this line
// Set Module 2 difficulty based on Module 1 performance
if (questionsCorrect >= 16) {
// 80%+ correct = hard difficulty
currentDifficulty = "hard";
} else if (questionsCorrect >= 12) {
// 60-75% correct = medium difficulty
currentDifficulty = "medium";
} else {
// <60% correct = stay on easy difficulty
currentDifficulty = "easy";
}
// Reset correct answers counter for Module 2
questionsCorrect = 0;
// Load first question with appropriate difficulty
loadRandomQuestion(currentDifficulty);
});
//==============================================================================
// HOME BUTTON AND QUESTION RESET FUNCTIONALITY
//==============================================================================
//Home button handling
//Will send the user back to the start screen so they can take the practice test again
// Create a deep copy of the original questions
var originalQuestions = [];
for (var i = 0; i < allQuestions.length; i++) {
// Create a deep copy of each question object
var question = allQuestions[i];
var questionCopy = {
question: question.question,
choices: question.choices.slice(), // Make a copy of the choices array
correct: question.correct,
difficulty: question.difficulty
};
originalQuestions.push(questionCopy);
}
onEvent("homeButton", "click", function () {
// Reset the questions array from the backup
allQuestions = [];
for (var i = 0; i < originalQuestions.length; i++) {
// Restore questions from backup to prevent repetition issues
var question = originalQuestions[i];
var questionCopy = {
question: question.question,
choices: question.choices.slice(), // Make a copy of the choices array
correct: question.correct,
difficulty: question.difficulty
};
allQuestions.push(questionCopy);
}
// Reset all app settings to default values
currentDifficulty = "easy";
currentModule = 1;
totalQuestions = 0;
questionsCorrect = 0;
// Switch to question screen and load first question
setScreen("questionScreen");
loadRandomQuestion(currentDifficulty);
});
//==============================================================================
// ANSWER CHOICE EVENT HANDLERS
//==============================================================================
// Answer handling
// Event handlers for each answer choice button
onEvent("choice1", "click", function () {
checkAnswer(getText("choice1"));
});
onEvent("choice2", "click", function () {
checkAnswer(getText("choice2"));
});
onEvent("choice3", "click", function () {
checkAnswer(getText("choice3"));
});
onEvent("choice4", "click", function () {
checkAnswer(getText("choice4"));
});