-
Notifications
You must be signed in to change notification settings - Fork 3
/
qbank.html
1050 lines (955 loc) · 50.1 KB
/
qbank.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interlink QBank</title>
<link rel="stylesheet" href="https://interlinkcvhs.org/styles.css">
<link rel="icon" href="https://interlinkcvhs.org/favicon.png" type="image/png">
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<style>
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
select {
width: 100%;
padding: 10px;
border-radius: 5px;
background: var(--glass-background);
border: 1px solid var(--glass-border);
color: white;
font-size: 16px;
}
.search-container {
margin: 20px 0;
width: 100%;
}
.search-input {
width: 100%;
padding: 10px;
border-radius: 5px;
background: var(--glass-background);
border: 1px solid var(--glass-border);
color: white;
font-size: 16px;
font-family: 'Montserrat', sans-serif;
}
/* Modal Styles */
.modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
display: flex;
justify-content: center;
z-index: 1000;
}
.modal-content {
background: var(--glass-background);
backdrop-filter: blur(10px);
border: 1px solid var(--glass-border);
box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
border-radius: 10px;
padding: 40px;
max-width: 800px;
width: 94%;
max-width: 1200px;
max-height: 90vh;
overflow-y: auto;
position: relative;
margin: 20px;
display: flex;
align-items: center;
justify-content: center;
}
.modal-content-wrapper {
border-radius: 10px;
}
.modal-navigation {
display: flex;
justify-content: space-between;
position: absolute;
width: 90%;
top: 50%;
transform: translateY(-50%);
}
/* Question View Styles */
.modal-content h2 {
font-size: 1.2rem;
margin-bottom: 2rem;
color: #FFFFFF;
}
textarea {
width: 100%;
height: 150px;
padding: 0.5rem;
font-size: 1.5rem;
border: 2px solid var(--primary-color);
border-radius: 5px;
resize: none;
color: #FFFFFF;
background-color: rgba(255, 255, 255, 0.1);
}
.qotd-container {
display: flex;
flex-direction: column;
width: 100%;
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
}
.nav-controls {
display: flex;
justify-content: space-between;
width: 100%;
max-width: 800px;
margin-bottom: 1rem;
}
.eliminated {
text-decoration: line-through;
opacity: 0.5;
pointer-events: none;
}
.eliminate-button:hover {
background: #062f70;
}
.question-table td:nth-child(2) {
font-weight: bold;
}
</style>
</head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-8W81FT4M1N"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-8W81FT4M1N');
</script>
<body>
<div id="banner-container"></div>
<header class="glass-header">
<div class="logo-container">
<a href="https://interlinkcvhs.org">
<img src="https://interlinkcvhs.org/favicon.png" style="width:50px;height:50px">
</a>
<h1 class="glow-text">Question Bank</h1>
</div>
<div id="nav-container"></div>
</header>
<main class="fade-in">
<div class="games-container">
<h2 class="section-title glow-text">Practice Questions</h2>
<div id="root"></div>
</div>
</main>
<div id="root"></div>
<script type="module">
// Load navigation from nav.html
async function loadNav() {
try {
const response = await fetch('https://interlinkcvhs.org/navnav.html');
const nav = await response.text();
document.getElementById('nav-container').innerHTML = nav;
} catch (error) {
console.error('Error loading navigation:', error);
document.getElementById('nav-container').innerHTML = '<p>Error loading navigation. Please try again later.</p>';
}
}
// Function to load the banner
async function loadBanner() {
try {
const response = await fetch('https://interlinkcvhs.org/banner.html');
const bannerContent = await response.text();
document.getElementById('banner-container').innerHTML = bannerContent;
} catch (error) {
console.error('Error loading banner:', error);
document.getElementById('banner-container').innerHTML = '<p>Error loading banner. Please try again later.</p>';
}
}
const { useState, useEffect } = React;
const { createRoot } = ReactDOM;
function QuestionBank() {
const [questions, setQuestions] = useState([]);
const [categories, setCategories] = useState([]);
const [selectedSubject, setSelectedSubject] = useState('');
const [selectedSection, setSelectedSection] = useState('');
const [selectedSubsection, setSelectedSubsection] = useState('');
const [selectedQuestion, setSelectedQuestion] = useState(null);
const [feedback, setFeedback] = useState('');
const [attempts, setAttempts] = useState(0);
const [isAnswered, setIsAnswered] = useState(false);
const [selectedOption, setSelectedOption] = useState('');
const [textAnswer, setTextAnswer] = useState('');
const [categoryOrder, setCategoryOrder] = useState({});
const [searchQuery, setSearchQuery] = useState('');
// New state for multi-select
const [selectedQuestions, setSelectedQuestions] = useState(new Set());
const [isSelectAllChecked, setIsSelectAllChecked] = useState(false);
const [isInExportList, setIsInExportList] = useState(false);
const [questionNavigationIndex, setQuestionNavigationIndex] = useState(0);
const [eliminatedOptions, setEliminatedOptions] = useState(new Set());
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
fetchQuestions();
fetchCategories();
}, []);
async function fetchCategories() {
try {
const response = await fetch('/subj-cat5.txt');
if (!response.ok) {
throw new Error('Failed to fetch categories');
}
const text = await response.text();
const parsed = text.trim().split('\n').map((line, index) => {
const [subject, section, subsection] = line.split(' | ');
return { subject, section, subsection, order: index };
});
// Create order mapping
const orderMap = {};
parsed.forEach(({ subject, section, subsection, order }) => {
orderMap[`${subject}|${section}|${subsection}`] = order;
});
setCategoryOrder(orderMap);
setCategories(parsed);
} catch (error) {
console.error('Error fetching categories:', error);
setCategories([]);
}
}
async function fetchQuestions() {
try {
const response = await fetch('https://sheets.livepolls.app/api/spreadsheets/0576df12-21e9-4d9f-8528-286ad2cd4cf5/Sheet1');
const data = await response.json();
if (data.success) {
document.querySelector('table').style.display = 'block';
setQuestions(data.data);
}
} catch (error) {
console.error('Error fetching questions:', error);
} finally {
setIsLoading(false); // Add this line
}
}
const getSubjects = () => {
return ['---', ...new Set(categories.map(c => c.subject))];
};
const getSections = () => {
if (!selectedSubject || selectedSubject === '---') return ['---'];
return ['---', ...new Set(categories
.filter(c => c.subject === selectedSubject)
.map(c => c.section))];
};
const getSubsections = () => {
if (!selectedSection || selectedSection === '---') return ['---'];
return ['---', ...new Set(categories
.filter(c => c.subject === selectedSubject && c.section === selectedSection)
.map(c => c.subsection))];
};
const handleElimination = (option, e) => {
e.stopPropagation();
setEliminatedOptions(prev => {
const newSet = new Set(prev);
if (newSet.has(option)) {
newSet.delete(option);
} else {
newSet.add(option);
}
return newSet;
});
};
const filteredQuestions = questions
.filter(q => {
const matchesCategories = (!selectedSubject || selectedSubject === '---' || q.Subject === selectedSubject) &&
(!selectedSection || selectedSection === '---' || q.Section === selectedSection) &&
(!selectedSubsection || selectedSubsection === '---' || q.Subsection === selectedSubsection);
const matchesSearch = searchQuery === '' ||
q.ID.toString().toLowerCase().includes(searchQuery.toLowerCase());
return matchesCategories && matchesSearch;
})
.sort((a, b) => {
const keyA = `${a.Subject}|${a.Section}|${a.Subsection}`;
const keyB = `${b.Subject}|${b.Section}|${b.Subsection}`;
const orderA = categoryOrder[keyA] ?? Infinity;
const orderB = categoryOrder[keyB] ?? Infinity;
return orderA - orderB;
});
// Effect to manage selected questions based on filtered questions
useEffect(() => {
// Create a set of current filtered question IDs
const currentFilteredQuestionIds = new Set(filteredQuestions.map(q => q.ID));
// Update selected questions to only keep those in the current filtered set
setSelectedQuestions(prev => {
const updatedSelected = new Set(
[...prev].filter(id => currentFilteredQuestionIds.has(id))
);
// Update select all checkbox
setIsSelectAllChecked(
updatedSelected.size > 0 &&
updatedSelected.size === currentFilteredQuestionIds.size
);
return updatedSelected;
});
}, [selectedSubject, selectedSection, selectedSubsection, searchQuery, questions]);
const handleSubmit = () => {
let maxAttempts;
// Determine max attempts based on number of options or input type
if (selectedQuestion.Options) {
const optionCount = selectedQuestion.Options.split('\n').length;
if (optionCount <= 3) maxAttempts = 1;
else if (optionCount === 4) maxAttempts = 2;
else maxAttempts = 3;
} else {
// Text input always gets 3 attempts
maxAttempts = 3;
}
const answer = selectedQuestion.Options ? selectedOption : textAnswer;
// Handle multiple correct answers scenarios
const correctAnswers = selectedQuestion.Correct1.split('\n')
.map(ans => ans.trim().toLowerCase());
const correct = correctAnswers.includes(answer.toLowerCase());
setAttempts(prev => prev + 1);
if (correct) {
setFeedback('Correct! Great job!');
setIsAnswered(true);
} else if (attempts >= maxAttempts - 1) {
setFeedback(`Incorrect. The correct answer was: ${selectedQuestion.Correct1}`);
setIsAnswered(true);
} else {
setFeedback('Incorrect. Try again!');
}
};
const navigateQuestions = (direction) => {
const currentIndex = filteredQuestions.findIndex(q => q.ID === selectedQuestion.ID);
let newIndex;
if (direction === 'forward') {
newIndex = (currentIndex + 1) % filteredQuestions.length;
} else {
newIndex = (currentIndex - 1 + filteredQuestions.length) % filteredQuestions.length;
}
const newQuestion = filteredQuestions[newIndex];
setSelectedQuestion(newQuestion);
resetQuestion();
};
const resetQuestion = () => {
setSelectedOption('');
setTextAnswer('');
setFeedback('');
setAttempts(0);
setIsAnswered(false);
setEliminatedOptions(new Set());
};
const handleQuestionSelect = (questionId) => {
setSelectedQuestions(prev => {
const newSelectedQuestions = new Set(prev);
if (newSelectedQuestions.has(questionId)) {
newSelectedQuestions.delete(questionId);
} else {
newSelectedQuestions.add(questionId);
}
// Update select all checkbox
setIsSelectAllChecked(
newSelectedQuestions.size > 0 &&
newSelectedQuestions.size === filteredQuestions.length
);
return newSelectedQuestions;
});
};
const handleSelectAll = () => {
if (isSelectAllChecked) {
// Deselect all
setSelectedQuestions(new Set());
setIsSelectAllChecked(false);
} else {
// Select all currently filtered questions
const allQuestionIds = new Set(filteredQuestions.map(q => q.ID));
setSelectedQuestions(allQuestionIds);
setIsSelectAllChecked(true);
}
};
function addFavicon(doc) {
try {
const imgData = 'favicon.png';
const imgProps = doc.getImageProperties(imgData);
// Significantly reduce size
const imgWidth = 15; // Much smaller
const imgHeight = (imgProps.height / imgProps.width) * imgWidth;
// Position in header
const pageWidth = doc.internal.pageSize.getWidth();
doc.addImage(imgData, 'PNG', pageWidth - 25, 10, imgWidth, imgHeight);
} catch (error) {
console.error('Error adding favicon:', error);
}
}
const exportQuestions = async (withAnswers = false) => {
// Check if jsPDF is available
if (!window.jspdf || !window.jspdf.jsPDF) {
console.error('jsPDF not loaded');
return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF({
orientation: 'portrait',
unit: 'mm',
format: 'a4'
});
doc.setFont('courier');
// Utility function to add background
function addPageBackground(doc) {
doc.setFillColor(20, 20, 40); // Dark blue background
doc.rect(0, 0, 210, 297, 'F');
}
// Enhanced header function with better typography
function addHeader(doc, withAnswers, pageNum) {
addPageBackground(doc);
// Main title - Large, bold
doc.setTextColor(255, 255, 255);
doc.setFont('courier', 'bold');
doc.setFontSize(18);
doc.text('Interlink CVHS QBank', 20, 20);
// URL with styled link
doc.setFont('courier', 'normal');
doc.setFontSize(10);
const url = 'https://interlinkcvhs.org/qbank';
doc.setTextColor(100, 200, 255);
doc.textWithLink(url, 35, 26, {
url: url,
underline: true
});
// Page number - Small, normal weight
doc.setFont('courier', 'normal');
doc.setFontSize(8);
doc.text(`Page ${pageNum}`, 180, 290);
addFavicon(doc);
}
let currentPage = 1;
let yOffset = 40;
const pageHeight = 270;
// Add first page header
addHeader(doc, withAnswers, currentPage);
function checkNewPage(requiredSpace) {
if (yOffset + requiredSpace > pageHeight) {
doc.addPage();
currentPage++;
addHeader(doc, withAnswers, currentPage);
yOffset = 40;
return true;
}
return false;
}
async function processImages(text, doc) {
if (!text.includes('!!img=')) return text;
const imgMatch = text.match(/!!img='([^']+)'/);
if (imgMatch) {
try {
const imgUrl = imgMatch[1];
const response = await fetch(imgUrl);
const blob = await response.blob();
const base64 = await new Promise((resolve) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.readAsDataURL(blob);
});
// Add the image to the PDF
const img = new Image();
await new Promise((resolve) => {
img.onload = resolve;
img.src = base64;
});
const maxWidth = 75; // Adjust the maximum width as needed
const aspectRatio = img.height / img.width;
const width = Math.min(maxWidth, img.width);
const height = width * aspectRatio;
if (text.includes("flow='RIGHT'")) {
doc.autoTable({
body: [[
{ content: text.split("!!")[2], styles: { cellWidth: width, minCellHeight: height, fillColor: '#141428', font: 'Montserrat', marginLeft: '40px' } },
{ content: '', styles: { cellWidth: width, minCellHeight: height, fillColor: '#141428', padding: '0px' } },
]],
startY: yOffset,
tableWidth: 'wrap',
margin: {left: 25, right: 0 },
styles: {
lineColor: [255, 255, 255],
lineWidth: 0,
textColor: [255, 255, 255]
},
didDrawCell: function (data) {
if (data.column.index === 1) {
doc.addImage(base64, 'PNG', data.cell.x, data.cell.y, width, height);
}
}
});
}
else {
doc.autoTable({
body: [[
{ content: '', styles: { cellWidth: width, minCellHeight: height, fillColor: '#141428', padding: '0px' } },
{ content: text.split("!!")[2], styles: { cellWidth: width, minCellHeight: height, fillColor: '#141428', font: 'Montserrat', marginLeft: '40px' } }
]],
startY: yOffset,
tableWidth: 'wrap',
margin: {left: 25, right: 0 },
styles: {
lineColor: [255, 255, 255],
lineWidth: 0,
textColor: [255, 255, 255]
},
didDrawCell: function (data) {
if (data.column.index === 0) {
doc.addImage(base64, 'PNG', data.cell.x, data.cell.y, width, height);
}
}
});
}
yOffset += height;
return ""
} catch (error) {
console.error('Error processing image:', error);
// Replace the image code with the message
return "BROKEN IMAGE";
}
}
return text;
}
// Process each selected question
const selectedQuestionsList = filteredQuestions.filter(q => selectedQuestions.has(q.ID));
for (let index = 0; index < selectedQuestionsList.length; index++) {
const question = selectedQuestionsList[index];
checkNewPage(60);
// Question number and ID - Bold, larger
doc.setFontSize(12);
doc.setTextColor(255, 255, 255);
doc.setFont('courier', 'bold');
doc.text(`Question ${index + 1}`, 20, yOffset);
// Add ID in bold next to question number
const idText = `[ID: ${question.ID}]`;
const questionNumWidth = doc.getTextWidth(`Question ${index + 1} `);
doc.text(idText, 20 + questionNumWidth + 5, yOffset);
yOffset += 5;
// Metadata box with improved styling
doc.setTextColor(100, 200, 255);
doc.setFontSize(8);
doc.setFont('courier', 'normal');
// Draw box around metadata
const metadataText = `${question.Subject} | ${question.Section} | ${question.Subsection}`;
const metadataWidth = doc.getTextWidth(metadataText) + 6; // Add padding
doc.setDrawColor(100, 200, 255);
doc.rect(20, yOffset - 3, metadataWidth, 8);
// Add metadata text
doc.text(metadataText, 23, yOffset + 2);
yOffset += 10;
// Question text - Clear, readable size
doc.setFontSize(11);
doc.setTextColor(255, 255, 255);
doc.setFont('courier', 'normal');
const questionLines = doc.splitTextToSize(await processImages(question.Question, doc), 170);
checkNewPage(questionLines.length * 7);
doc.text(questionLines, 20, yOffset);
yOffset += questionLines.length * 7 + 5;
// Handle options or free response space
if (question.Options) {
const options = question.Options.split('\n');
const optionLetters = ['A', 'B', 'C', 'D', 'E'];
for (let i = 0; i < options.length; i++) {
const option = options[i];
checkNewPage(7);
// Add option letter and format consistently
const fullOptionText = `${optionLetters[i]}) ${option.replace(/^[A-E]\)\s*/, '')}`;
doc.setFontSize(10);
doc.text(fullOptionText, 25, yOffset);
yOffset += 7;
}
} else {
// Add lines for free response
checkNewPage(21);
for (let i = 0; i < 3; i++) {
doc.setDrawColor(100, 200, 255);
doc.line(25, yOffset, 185, yOffset);
yOffset += 7;
}
}
// Add correct answer if requested
if (withAnswers) {
checkNewPage(10);
doc.setTextColor(0, 255, 0);
doc.setFont('courier', 'bold');
doc.setFontSize(11);
doc.text(`Answer: ${question.Correct1}`, 20, yOffset);
yOffset += 10;
}
// Add spacing between questions
yOffset += 10;
}
// Generate filename with current date
const date = new Date().toISOString().split('T')[0];
const filename = `InterlinkCVHS_QBank_${date}_${withAnswers ? 'with_answers' : 'questions'}.pdf`;
// Save the PDF
try {
doc.save(filename);
} catch (error) {
console.error('Error saving PDF:', error);
alert('Error generating PDF. Please try again.');
}
};
return React.createElement('div', { className: 'container' },
React.createElement('div', {
className: 'export-buttons-container',
style: {
display: 'flex',
justifyContent: 'center',
gap: '20px',
width: '100%'
}
},
React.createElement('button', {
className: 'export-button export-button-questions',
style: { flex: '0 0 49%' },
fontSize: '16px',
onClick: () => exportQuestions(false),
disabled: selectedQuestions.size === 0
},
React.createElement('img', {
src: 'qbankExport.png',
alt: 'Export',
style: { width: '20px', marginRight: '8px' }
}),
'Export Questions'
),
React.createElement('button', {
className: 'export-button export-button-answers',
style: { flex: '0 0 49%' },
fontSize: '16px',
onClick: () => exportQuestions(true),
disabled: selectedQuestions.size === 0
},
React.createElement('img', {
src: 'qbankExport.png',
alt: 'Export with Answers',
style: { width: '20px', marginRight: '8px' }
}),
'Export with Answers'
)
),
React.createElement('div', { className: 'filters' },
React.createElement('select', {
value: selectedSubject,
onChange: (e) => {
setSelectedSubject(e.target.value);
setSelectedSection('');
setSelectedSubsection('');
}
}, getSubjects().map(subject =>
React.createElement('option', { key: subject, value: subject }, subject)
)),
React.createElement('select', {
value: selectedSection,
onChange: (e) => {
setSelectedSection(e.target.value);
setSelectedSubsection('');
}
}, getSections().map(section =>
React.createElement('option', { key: section, value: section }, section)
)),
React.createElement('select', {
value: selectedSubsection,
onChange: (e) => setSelectedSubsection(e.target.value)
}, getSubsections().map(subsection =>
React.createElement('option', { key: subsection, value: subsection }, subsection)
))
),
React.createElement('div', { className: 'search-container' },
React.createElement('input', {
type: 'text',
className: 'search-input',
placeholder: 'Search by ID...',
value: searchQuery,
onChange: (e) => setSearchQuery(e.target.value)
})
),
filteredQuestions.length > 0 && selectedQuestions.size > 0 &&
React.createElement('div', {
style: {
marginTop: '10px',
color: 'var(--primary-color)',
fontWeight: 'bold'
}
}, `${selectedQuestions.size} question(s) selected`),
React.createElement('table', {
className: 'question-table',
style: { width: '100%', tableLayout: 'fixed' }
},
React.createElement('thead', null,
React.createElement('tr', null,
React.createElement('th', {
style: {
width: '50px',
textAlign: 'center',
borderRight: '1px solid' ,
overflow: 'hidden',
textOverflow: 'ellipsis'
}
},
React.createElement('input', {
type: 'checkbox',
checked: isSelectAllChecked,
onChange: handleSelectAll,
style: { margin: 0 }
})
),
React.createElement('th', { style: { width: '150px', borderRight: '1px solid var(--primary-color)' } }, 'ID'),
React.createElement('th', { style: { width: '240px', borderRight: '1px solid var(--primary-color)' } }, 'Subject'),
React.createElement('th', { style: { width: '300px', borderRight: '1px solid var(--primary-color)' } }, 'Section'),
React.createElement('th', { style: { width: '240px', borderRight: '1px solid var(--primary-color)' } }, 'Subsection'),
React.createElement('th', { style: { width: '5%' } }, '')
)
),
React.createElement('tbody', null,
filteredQuestions.length === 0 ?
React.createElement('tr', null,
React.createElement('td', {
colSpan: 6,
className: 'no-questions',
style: {
height: '100px',
verticalAlign: 'middle',
textAlign: 'center',
color: isLoading ? '#ffffff' : '#ff0000',
fontSize: '1.5em',
fontWeight: 'bold',
width: '100%', // Ensure full width
padding: '20px'
}
}, isLoading ? 'LOADING QUESTIONS...' : 'NO QUESTIONS FOUND AT THE MOMENT... COMING SOON')
) :
filteredQuestions.map(q =>
React.createElement('tr', { key: q.ID },
React.createElement('td', {
style: {
textAlign: 'center',
borderRight: '1px solid var(--glass-border)' ,
overflow: 'hidden',
textOverflow: 'ellipsis'
}
},
React.createElement('input', {
type: 'checkbox',
checked: selectedQuestions.has(q.ID),
onChange: () => handleQuestionSelect(q.ID),
style: { margin: 0 }
})
),
React.createElement('td', { style: { borderRight: '1px solid var(--glass-border)' } }, q.ID),
React.createElement('td', { style: { borderRight: '1px solid var(--glass-border)' } }, q.Subject),
React.createElement('td', { style: { borderRight: '1px solid var(--glass-border)' } }, q.Section),
React.createElement('td', { style: { borderRight: '1px solid var(--glass-border)' } }, q.Subsection),
React.createElement('td', null,
React.createElement('button', {
className: 'view-button',
onClick: () => {
setSelectedQuestion(q);
resetQuestion();
}
}, 'VIEW')
)
)
)
)
),
selectedQuestion && React.createElement('div', {className: 'modal' },
React.createElement('div', { className: 'modal-content' },
React.createElement('button', {
className: 'close-button',
style: { position: 'absolute', top: '10px', right: '10px', zIndex: 10 },
onClick: () => setSelectedQuestion(null)
}, '×'),
React.createElement('div', { className: 'modal-content-wrapper', style: {display: 'flex', flexDirection: 'column', position: 'relative', width: '90%'} },
// Centered question metadata
React.createElement('div', { className: 'question-metadata' },
React.createElement('strong', null, selectedQuestion.ID),
` | ${selectedQuestion.Subject} | ${selectedQuestion.Section} | ${selectedQuestion.Subsection}`
),
// Centered question text
React.createElement('div', {
className: `question-with-image ${selectedQuestion.Question.includes('!!img=') ? 'has-image' : ''}`,
style: { textAlign: 'center' }
},
// Image placement logic
selectedQuestion.Question.includes('!!img=') && React.createElement('div', {
className: 'question-image',
style: {
margin: '20px 0',
textAlign: 'center'
}
},
React.createElement('img', {
src: selectedQuestion.Question.match(/!!img='([^']+)'/)[1],
alt: 'Question Image',
style: {
maxWidth: '100%',
height: 'auto'
}
})
),
React.createElement('h2', null,
selectedQuestion.Question.replace(/!!.*?!!/, '').trim()
)
),
selectedQuestion.Options ?
React.createElement('div', { className: 'options-container', style: { textAlign: 'left' } },
selectedQuestion.Options.split('\n').map(option => {
const hasImage = option.includes('!!img=');
const optionText = hasImage ?
option.replace(/!!.*?!!/g, '').trim() :
option;
const imgMatch = hasImage ?
option.match(/!!img='([^']+)'!!flow='RIGHT'/) :
null;
return React.createElement('div', {
key: option,
className: `option-wrapper`,
style: {
position: 'relative',
marginBottom: '10px'
}
},
React.createElement('div', {
className: `option ${selectedOption === option ? 'selected' : ''} ${eliminatedOptions.has(option) ? 'eliminated' : ''}`,
onClick: () => !isAnswered && !eliminatedOptions.has(option) && setSelectedOption(option),
style: {
width: '95%',
alignItems: 'center',
justifyContent: imgMatch ? 'space-between' : 'flex-start',
gap: '10px',
position: 'relative',
padding: '10px'
}
},
React.createElement('div', null, optionText),
imgMatch && React.createElement('img', {
src: imgMatch[1],
alt: 'Option Image',
style: {
maxWidth: '200px',
height: 'auto',
marginLeft: imgMatch ? '10px' : '0'
}
})
),
!isAnswered && React.createElement('button', {
className: 'eliminate-button',
onClick: (e) => handleElimination(option, e),
style: {
position: 'absolute',
right: '10px', // Adjust the right offset to place it as you need
top: '50%', // Center the button vertically within the option
transform: 'translateY(-50%)', // Vertically center the button
backgroundColor: 'transparent', // Make the button background transparent (optional)
border: 'none', // Optional: Remove the border if desired
padding: '5px 10px', // Optional: Add padding for better clickability
cursor: 'pointer' // Change the cursor on hover
},
title: eliminatedOptions.has(option) ? 'Restore option' : 'Eliminate option'
}, eliminatedOptions.has(option) ? '↺' : '×')
);
})
) :
React.createElement('div', {
style: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}
},
React.createElement('textarea', {
value: textAnswer,
onChange: (e) => setTextAnswer(e.target.value),
disabled: isAnswered,
placeholder: 'Type your answer here...',
style: { flex: 1 } // Limit width of textarea
}),
React.createElement('button', {
className: 'pi-input-button',
onClick: () => setTextAnswer(prev => prev + 'π'),
style: { marginLeft: '10px' } // Add some spacing between textarea and button
}, 'π')
),
// Centered submit button
React.createElement('button', {
className: 'submit-button',
onClick: handleSubmit,
disabled: isAnswered,
style: { marginTop: '20px' }
}, 'Submit'),
feedback && React.createElement('div', {
className: `feedback ${feedback.includes('Correct') ? 'correct' : 'incorrect'}`,
style: { marginTop: '20px' }
}, feedback),
React.createElement('div', { className: 'attempts', style: { marginTop: '10px' } },
`Attempts: ${attempts}/` +
(selectedQuestion.Options
? (selectedQuestion.Options.split('\n').length <= 3 ? 1
: (selectedQuestion.Options.split('\n').length === 4 ? 2 : 3))
: 3)
)
),
// Navigation arrows
React.createElement('div', { className: 'modal-navigation',