catchup-library-web 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/index.d.mts +239 -2
  2. package/dist/index.d.ts +239 -2
  3. package/dist/index.js +4686 -2
  4. package/dist/index.mjs +4621 -1
  5. package/package.json +10 -2
  6. package/src/components/activities/DropdownActivityContent.tsx +73 -0
  7. package/src/components/activities/FillInTheBlanksActivityContent.tsx +102 -0
  8. package/src/components/activities/GroupingActivityContent.tsx +62 -0
  9. package/src/components/activities/MCMAActivityContent.tsx +65 -0
  10. package/src/components/activities/MCSAActivityContent.tsx +58 -0
  11. package/src/components/activities/MatchingActivityContent.tsx +57 -0
  12. package/src/components/activities/OpenEndedActivityContent.tsx +92 -0
  13. package/src/components/activities/OrderingActivityContent.tsx +59 -0
  14. package/src/components/activities/TrueFalseActivityContent.tsx +98 -0
  15. package/src/components/activities/body-content/ActivityBodyContent.tsx +108 -0
  16. package/src/components/activities/body-content/ShowBodyMediaByContentType.tsx +404 -0
  17. package/src/components/activities/empty-content/ActivityEmptyContent.tsx +15 -0
  18. package/src/components/activities/material-content/DropdownActivityMaterialContent.tsx +227 -0
  19. package/src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx +270 -0
  20. package/src/components/activities/material-content/GroupingActivityMaterialContent.tsx +359 -0
  21. package/src/components/activities/material-content/MCMAActivityMaterialContent.tsx +166 -0
  22. package/src/components/activities/material-content/MCSAActivityMaterialContent.tsx +165 -0
  23. package/src/components/activities/material-content/MatchingActivityMaterialContent.tsx +332 -0
  24. package/src/components/activities/material-content/OpenEndedActivityMaterialContent.tsx +818 -0
  25. package/src/components/activities/material-content/OrderingActivityMaterialContent.tsx +216 -0
  26. package/src/components/activities/material-content/ShowMaterialMediaByContentType.tsx +172 -0
  27. package/src/components/activities/material-content/TrueFalseActivityMaterialContent.tsx +217 -0
  28. package/src/components/activities/solution-content/ActivitySolutionContent.tsx +86 -0
  29. package/src/components/dividers/BlueVerticalDividerLine.tsx +13 -0
  30. package/src/components/dividers/DividerLine.tsx +5 -0
  31. package/src/components/dividers/VerticalDividerLine.tsx +5 -0
  32. package/src/components/dnds/DraggableDroppableItem.tsx +62 -0
  33. package/src/components/dnds/DraggableItem.tsx +41 -0
  34. package/src/components/dnds/DroppableItem.tsx +38 -0
  35. package/src/components/dropdowns/MediaDropdown.tsx +51 -0
  36. package/src/components/groups/InputGroup.tsx +330 -0
  37. package/src/hooks/useScreenSize.ts +40 -0
  38. package/src/index.ts +24 -0
  39. package/src/language/i18n.ts +10 -0
  40. package/src/properties/ActivityProperties.ts +204 -0
  41. package/src/properties/ButtonProperties.ts +1 -1
  42. package/src/properties/CommonProperties.ts +1 -1
  43. package/src/properties/DividerLineProperties.ts +3 -0
  44. package/src/properties/DnDProperties.ts +28 -0
  45. package/src/properties/DropdownProperties.ts +5 -0
  46. package/src/properties/EnumProperties.ts +11 -0
  47. package/src/properties/GroupProperties.ts +19 -0
  48. package/src/utilization/AppUtilization.ts +56 -0
  49. package/src/utilization/CatchtivityUtilization.ts +1566 -0
  50. package/src/utilization/StorageUtilization.ts +35 -0
  51. package/tsconfig.json +2 -1
@@ -0,0 +1,1566 @@
1
+ import i18n from "../language/i18n";
2
+
3
+ export const retrieveColorByScore = (score: number) => {
4
+ if (score <= 25) {
5
+ return "#F96666";
6
+ } else if (score > 25 && score <= 50) {
7
+ return "#f98d66";
8
+ } else if (score > 50 && score <= 75) {
9
+ return "#cbd357";
10
+ } else {
11
+ return "#ABD357";
12
+ }
13
+ };
14
+
15
+ export const retrieveContentTypeOptionList = (textOnly: boolean) => {
16
+ if (textOnly) {
17
+ return [
18
+ {
19
+ id: "TEXT",
20
+ value: "TEXT",
21
+ text: i18n.t("TEXT"),
22
+ icon: "/icons/text-gray.png",
23
+ },
24
+ ];
25
+ } else {
26
+ return [
27
+ {
28
+ id: "TEXT",
29
+ value: "TEXT",
30
+ text: i18n.t("TEXT"),
31
+ icon: "/icons/text-gray.png",
32
+ },
33
+ {
34
+ id: "IMAGE",
35
+ value: "IMAGE",
36
+ text: i18n.t("IMAGE"),
37
+ icon: "/icons/image-gray.png",
38
+ },
39
+ {
40
+ id: "VIDEO",
41
+ value: "VIDEO",
42
+ text: i18n.t("VIDEO"),
43
+ icon: "/icons/video-gray.png",
44
+ },
45
+ {
46
+ id: "AUDIO",
47
+ value: "AUDIO",
48
+ text: i18n.t("AUDIO"),
49
+ icon: "/icons/audio-gray.png",
50
+ },
51
+ ];
52
+ }
53
+ };
54
+
55
+ export const retrieveStatusOptionList = () => {
56
+ return [
57
+ {
58
+ value: "ACTIVE",
59
+ text: i18n.t("ACTIVE"),
60
+ },
61
+ {
62
+ value: "PASSIVE",
63
+ text: i18n.t("PASSIVE"),
64
+ },
65
+ ];
66
+ };
67
+
68
+ export const retrieveDurationTypeOptionList = () => {
69
+ return [
70
+ { value: "NONE", text: i18n.t("NONE") },
71
+ { value: "ALL", text: i18n.t("ALL") },
72
+ { value: "EACH", text: i18n.t("EACH") },
73
+ ];
74
+ };
75
+
76
+ export const retrieveDurationInMinutesOptionList = (durationType: string) => {
77
+ if (durationType === "ALL") {
78
+ return [
79
+ { value: 15, text: 15 },
80
+ { value: 30, text: 30 },
81
+ { value: 45, text: 45 },
82
+ { value: 60, text: 60 },
83
+ { value: 75, text: 75 },
84
+ { value: 90, text: 90 },
85
+ { value: 105, text: 105 },
86
+ { value: 120, text: 120 },
87
+ ];
88
+ } else if (durationType === "EACH") {
89
+ return [
90
+ { value: 1, text: 1 },
91
+ { value: 2, text: 2 },
92
+ { value: 3, text: 3 },
93
+ { value: 5, text: 5 },
94
+ { value: 10, text: 10 },
95
+ ];
96
+ }
97
+ return [];
98
+ };
99
+
100
+ export const retrieveDurationInSecondsOptionList = () => {
101
+ return [
102
+ { value: 15, text: `15 ${i18n.t("seconds")}` },
103
+ { value: 20, text: `20 ${i18n.t("seconds")}` },
104
+ { value: 25, text: `25 ${i18n.t("seconds")}` },
105
+ { value: 30, text: `30 ${i18n.t("seconds")}` },
106
+ { value: 35, text: `35 ${i18n.t("seconds")}` },
107
+ { value: 40, text: `40 ${i18n.t("seconds")}` },
108
+ { value: 45, text: `45 ${i18n.t("seconds")}` },
109
+ ];
110
+ };
111
+
112
+ export const retrieveTaxonomyType = () => {
113
+ return [
114
+ {
115
+ value: "BLOOM",
116
+ text: i18n.t("BLOOM"),
117
+ },
118
+ ];
119
+ };
120
+
121
+ export const retrieveTaxonomyGroupName = () => {
122
+ return [
123
+ {
124
+ type: "BLOOM",
125
+ value: "BLOOM",
126
+ text: i18n.t("BLOOM"),
127
+ },
128
+ ];
129
+ };
130
+
131
+ export const retrieveTaxonomyName = () => {
132
+ return [
133
+ {
134
+ stage: 1,
135
+ groupName: "BLOOM",
136
+ value: "REMEMBER",
137
+ text: i18n.t("REMEMBER"),
138
+ },
139
+ {
140
+ stage: 2,
141
+ groupName: "BLOOM",
142
+ value: "UNDERSTAND",
143
+ text: i18n.t("UNDERSTAND"),
144
+ },
145
+ {
146
+ stage: 3,
147
+ groupName: "BLOOM",
148
+ value: "APPLY",
149
+ text: i18n.t("APPLY"),
150
+ },
151
+ {
152
+ stage: 4,
153
+ groupName: "BLOOM",
154
+ value: "ANALYZE",
155
+ text: i18n.t("ANALYZE"),
156
+ },
157
+ {
158
+ stage: 5,
159
+ groupName: "BLOOM",
160
+ value: "EVALUATE",
161
+ text: i18n.t("EVALUATE"),
162
+ },
163
+ {
164
+ stage: 6,
165
+ groupName: "BLOOM",
166
+ value: "CREATE",
167
+ text: i18n.t("CREATE"),
168
+ },
169
+ ];
170
+ };
171
+
172
+ export const constructInputWithSpecialExpressionList = (inputText: string) => {
173
+ const inputPartList = [];
174
+ if (!inputText) return [];
175
+ const splittedBold = inputText.split("**");
176
+ let isBold = false;
177
+ for (let i = 0; i < splittedBold.length; i++) {
178
+ let isUnderline = false;
179
+ const splittedUnderline = splittedBold[i].split("__");
180
+ for (let j = 0; j < splittedUnderline.length; j++) {
181
+ let isEquation = false;
182
+ const splittedEquation = splittedUnderline[j].split("`");
183
+ for (let k = 0; k < splittedEquation.length; k++) {
184
+ inputPartList.push({
185
+ value: splittedEquation[k],
186
+ isEquation,
187
+ isUnderline,
188
+ isBold,
189
+ });
190
+ isEquation = !isEquation;
191
+ }
192
+ isUnderline = !isUnderline;
193
+ }
194
+ isBold = !isBold;
195
+ }
196
+ return inputPartList;
197
+ };
198
+
199
+ export const retrieveStandardExamTypeOptionList = () => {
200
+ return [
201
+ { value: "AYT", text: "AYT" },
202
+ { value: "TYT", text: "TYT" },
203
+ { value: "LGS", text: "LGS" },
204
+ ];
205
+ };
206
+
207
+ export const retrieveStandardExamTypeIcon = (baseReportType: string) => {
208
+ if (baseReportType === "TYT") {
209
+ return "/icons/tyt.png";
210
+ } else if (baseReportType === "AYT") {
211
+ return "/icons/ayt.png";
212
+ } else if (baseReportType === "LGS") {
213
+ return "/icons/lgs.png";
214
+ }
215
+ };
216
+
217
+ export const retrieveCoterieTypeFromStandardExamCoterieType = (
218
+ standardExamType: string,
219
+ standardExamCoterieType: string
220
+ ) => {
221
+ if (standardExamCoterieType === "TURKISH") {
222
+ return "TURKISH";
223
+ } else if (standardExamCoterieType === "SCIENCE") {
224
+ return "SCIENCE";
225
+ } else if (
226
+ (standardExamType === "TYT" || standardExamType === "AYT") &&
227
+ standardExamCoterieType === "PHYSICS"
228
+ ) {
229
+ return "PHYSICS";
230
+ } else if (
231
+ standardExamType === "LGS" &&
232
+ standardExamCoterieType === "PHYSICS"
233
+ ) {
234
+ return "SOCIAL_STUDIES";
235
+ } else if (
236
+ (standardExamType === "TYT" || standardExamType === "AYT") &&
237
+ standardExamCoterieType === "CHEMISTRY"
238
+ ) {
239
+ return "CHEMISTRY";
240
+ } else if (
241
+ standardExamType === "LGS" &&
242
+ standardExamCoterieType === "CHEMISTRY"
243
+ ) {
244
+ return "SOCIAL_STUDIES";
245
+ } else if (
246
+ (standardExamType === "TYT" || standardExamType === "AYT") &&
247
+ standardExamCoterieType === "BIOLOGY"
248
+ ) {
249
+ return "BIOLOGY";
250
+ } else if (
251
+ standardExamType === "LGS" &&
252
+ standardExamCoterieType === "BIOLOGY"
253
+ ) {
254
+ return "SOCIAL_STUDIES";
255
+ } else if (
256
+ (standardExamType === "TYT" || standardExamType === "AYT") &&
257
+ standardExamCoterieType === "HISTORY"
258
+ ) {
259
+ return "HISTORY";
260
+ } else if (
261
+ (standardExamType === "TYT" || standardExamType === "AYT") &&
262
+ standardExamCoterieType === "GEOGRAPHY"
263
+ ) {
264
+ return "GEOGRAPHY";
265
+ } else if (
266
+ (standardExamType === "LGS" && standardExamCoterieType === "HISTORY") ||
267
+ (standardExamType === "LGS" && standardExamCoterieType === "GEOGRAPHY") ||
268
+ standardExamCoterieType === "REVOLUTION_HISTORY"
269
+ ) {
270
+ return "SOCIAL_STUDIES";
271
+ } else if (
272
+ standardExamCoterieType === "HISTORY_I" ||
273
+ standardExamCoterieType === "HISTORY_II"
274
+ ) {
275
+ return "HISTORY";
276
+ } else if (
277
+ standardExamCoterieType === "GEOGRAPHY_I" ||
278
+ standardExamCoterieType === "GEOGRAPHY_II"
279
+ ) {
280
+ return "GEOGRAPHY";
281
+ } else if (
282
+ standardExamCoterieType === "MATHEMATICS" ||
283
+ standardExamCoterieType === "GEOMETRY"
284
+ ) {
285
+ return "MATHEMATICS";
286
+ } else if (
287
+ standardExamCoterieType === "PHILOSOPHY" ||
288
+ standardExamCoterieType === "PHILOSOPHY_OR_CULTURE_AND_RELIGION_KNOWLEDGE"
289
+ ) {
290
+ return "PHILOSOPHY";
291
+ } else if (
292
+ (standardExamType === "TYT" || standardExamType === "AYT") &&
293
+ standardExamCoterieType === "CULTURE_AND_RELIGION_KNOWLEDGE"
294
+ ) {
295
+ return "CULTURE_AND_RELIGION_KNOWLEDGE";
296
+ } else if (
297
+ standardExamType === "LGS" &&
298
+ standardExamCoterieType === "CULTURE_AND_RELIGION_KNOWLEDGE"
299
+ ) {
300
+ return "CULTURE_AND_RELIGION_KNOWLEDGE";
301
+ } else if (standardExamCoterieType === "ENGLISH") {
302
+ return "ENGLISH";
303
+ } else if (standardExamCoterieType === "LITERATURE") {
304
+ return "LITERATURE";
305
+ }
306
+ };
307
+
308
+ export const retrieveStandardExamCoterieTypeOptionListByStandardExamType = (
309
+ standardExamType: string
310
+ ) => {
311
+ if (standardExamType === "TYT") {
312
+ return retrieveStandardExamCoterieTypeOptionList().filter(
313
+ (item) =>
314
+ item.value === "TURKISH" ||
315
+ item.value === "HISTORY" ||
316
+ item.value === "GEOGRAPHY" ||
317
+ item.value === "PHILOSOPHY" ||
318
+ item.value === "CULTURE_AND_RELIGION_KNOWLEDGE" ||
319
+ item.value === "MATHEMATICS" ||
320
+ item.value === "GEOMETRY" ||
321
+ item.value === "PHYSICS" ||
322
+ item.value === "CHEMISTRY" ||
323
+ item.value === "BIOLOGY"
324
+ );
325
+ } else if (standardExamType === "AYT") {
326
+ return retrieveStandardExamCoterieTypeOptionList().filter(
327
+ (item) =>
328
+ item.value === "LITERATURE" ||
329
+ item.value === "HISTORY_I" ||
330
+ item.value === "HISTORY_II" ||
331
+ item.value === "GEOGRAPHY_I" ||
332
+ item.value === "GEOGRAPHY_II" ||
333
+ item.value === "PHILOSOPHY" ||
334
+ item.value === "PHILOSOPHY_OR_CULTURE_AND_RELIGION_KNOWLEDGE" ||
335
+ item.value === "MATHEMATICS" ||
336
+ item.value === "GEOMETRY" ||
337
+ item.value === "PHYSICS" ||
338
+ item.value === "CHEMISTRY" ||
339
+ item.value === "BIOLOGY" ||
340
+ item.value === "ENGLISH"
341
+ );
342
+ } else if (standardExamType === "LGS") {
343
+ return retrieveStandardExamCoterieTypeOptionList().filter(
344
+ (item) =>
345
+ item.value === "TURKISH" ||
346
+ item.value === "REVOLUTION_HISTORY" ||
347
+ item.value === "CULTURE_AND_RELIGION_KNOWLEDGE" ||
348
+ item.value === "MATHEMATICS" ||
349
+ item.value === "SCIENCE" ||
350
+ item.value === "ENGLISH"
351
+ );
352
+ } else return [];
353
+ };
354
+
355
+ const retrieveStandardExamCoterieTypeOptionList = () => {
356
+ return [
357
+ { value: "TURKISH", text: i18n.t("TURKISH") },
358
+ { value: "SCIENCE", text: i18n.t("SCIENCE") },
359
+ { value: "HISTORY", text: i18n.t("HISTORY") },
360
+ { value: "GEOGRAPHY", text: i18n.t("GEOGRAPHY") },
361
+ { value: "PHILOSOPHY", text: i18n.t("PHILOSOPHY") },
362
+ {
363
+ value: "CULTURE_AND_RELIGION_KNOWLEDGE",
364
+ text: i18n.t("CULTURE_AND_RELIGION_KNOWLEDGE"),
365
+ },
366
+ { value: "MATHEMATICS", text: i18n.t("MATHEMATICS") },
367
+ { value: "GEOMETRY", text: i18n.t("GEOMETRY") },
368
+ { value: "PHYSICS", text: i18n.t("PHYSICS") },
369
+ { value: "CHEMISTRY", text: i18n.t("CHEMISTRY") },
370
+ { value: "BIOLOGY", text: i18n.t("BIOLOGY") },
371
+ { value: "LITERATURE", text: i18n.t("LITERATURE") },
372
+ { value: "HISTORY_I", text: i18n.t("HISTORY_I") },
373
+ { value: "HISTORY_II", text: i18n.t("HISTORY_II") },
374
+ { value: "GEOGRAPHY_I", text: i18n.t("GEOGRAPHY_I") },
375
+ { value: "GEOGRAPHY_II", text: i18n.t("GEOGRAPHY_II") },
376
+ {
377
+ value: "PHILOSOPHY_OR_CULTURE_AND_RELIGION_KNOWLEDGE",
378
+ text: i18n.t("PHILOSOPHY_OR_CULTURE_AND_RELIGION_KNOWLEDGE"),
379
+ },
380
+ { value: "ENGLISH", text: i18n.t("ENGLISH") },
381
+ { value: "REVOLUTION_HISTORY", text: i18n.t("REVOLUTION_HISTORY") },
382
+ ];
383
+ };
384
+
385
+ const retrieveValidationRequirementList_AYT = () => {
386
+ return [
387
+ {
388
+ value: "LITERATURE",
389
+ count: 24,
390
+ },
391
+ {
392
+ value: "HISTORY_I",
393
+ count: 10,
394
+ },
395
+ {
396
+ value: "HISTORY_II",
397
+ count: 11,
398
+ },
399
+ {
400
+ value: "GEOGRAPHY_I",
401
+ count: 6,
402
+ },
403
+ {
404
+ value: "GEOGRAPHY_II",
405
+ count: 11,
406
+ },
407
+ {
408
+ value: "PHILOSOPHY",
409
+ count: 12,
410
+ },
411
+ {
412
+ value: "PHILOSOPHY_OR_CULTURE_AND_RELIGION_KNOWLEDGE",
413
+ count: 6,
414
+ },
415
+ {
416
+ value: "MATHEMATICS",
417
+ count: 30,
418
+ },
419
+ {
420
+ value: "GEOMETRY",
421
+ count: 10,
422
+ },
423
+ {
424
+ value: "PHYSICS",
425
+ count: 14,
426
+ },
427
+ {
428
+ value: "CHEMISTRY",
429
+ count: 13,
430
+ },
431
+ {
432
+ value: "BIOLOGY",
433
+ count: 13,
434
+ },
435
+ {
436
+ value: "ENGLISH",
437
+ count: 80,
438
+ },
439
+ ];
440
+ };
441
+
442
+ const retrieveValidationRequirementList_TYT = () => {
443
+ return [
444
+ {
445
+ value: "TURKISH",
446
+ count: 40,
447
+ },
448
+ {
449
+ value: "HISTORY",
450
+ count: 5,
451
+ },
452
+ {
453
+ value: "GEOGRAPHY",
454
+ count: 5,
455
+ },
456
+ {
457
+ value: "PHILOSOPHY",
458
+ count: 5,
459
+ },
460
+ {
461
+ value: "CULTURE_AND_RELIGION_KNOWLEDGE",
462
+ count: 5,
463
+ },
464
+ {
465
+ value: "MATHEMATICS",
466
+ count: 30,
467
+ },
468
+ {
469
+ value: "GEOMETRY",
470
+ count: 10,
471
+ },
472
+ {
473
+ value: "PHYSICS",
474
+ count: 7,
475
+ },
476
+ {
477
+ value: "CHEMISTRY",
478
+ count: 7,
479
+ },
480
+ {
481
+ value: "BIOLOGY",
482
+ count: 6,
483
+ },
484
+ ];
485
+ };
486
+
487
+ const retrieveValidationRequirementList_LGS = () => {
488
+ return [
489
+ {
490
+ value: "TURKISH",
491
+ count: 20,
492
+ },
493
+ {
494
+ value: "REVOLUTION_HISTORY",
495
+ count: 10,
496
+ },
497
+ {
498
+ value: "CULTURE_AND_RELIGION_KNOWLEDGE",
499
+ count: 10,
500
+ },
501
+ {
502
+ value: "MATHEMATICS",
503
+ count: 20,
504
+ },
505
+ {
506
+ value: "SCIENCE",
507
+ count: 20,
508
+ },
509
+ {
510
+ value: "ENGLISH",
511
+ count: 10,
512
+ },
513
+ ];
514
+ };
515
+
516
+ export const retrieveValidationRequirementList = (
517
+ selectedStandardExamType: string
518
+ ) => {
519
+ if (selectedStandardExamType === "TYT") {
520
+ return retrieveValidationRequirementList_TYT();
521
+ } else if (selectedStandardExamType === "AYT") {
522
+ return retrieveValidationRequirementList_AYT();
523
+ } else if (selectedStandardExamType === "LGS") {
524
+ return retrieveValidationRequirementList_LGS();
525
+ }
526
+ return [];
527
+ };
528
+
529
+ export const constructActivityItemListWithSolutionForAI = (
530
+ bodyMap: any,
531
+ materialMap: any,
532
+ type: string,
533
+ imageContentList: any
534
+ ) => {
535
+ const itemList = [];
536
+ Object.keys(bodyMap).forEach((key) => {
537
+ const bodyItem = bodyMap[key];
538
+ if (bodyItem.type === "IMAGE") {
539
+ if (imageContentList && imageContentList.length > 0) {
540
+ const foundImageContent = imageContentList.find(
541
+ (imageContent: any) => imageContent.url === bodyItem.value
542
+ );
543
+ itemList.push({
544
+ type: "text",
545
+ text: foundImageContent.content,
546
+ });
547
+ } else {
548
+ itemList.push({
549
+ type: "image_url",
550
+ imageUrl: bodyItem.value,
551
+ });
552
+ }
553
+ } else {
554
+ itemList.push({
555
+ type: "text",
556
+ text: bodyItem.value.replaceAll("@@", "___________"),
557
+ });
558
+ }
559
+ });
560
+ if (type === "ORDERING") {
561
+ if (Object.keys(materialMap).length > 0) {
562
+ itemList.push({
563
+ type: "text",
564
+ text: `${i18n.t("correct_order")}: `,
565
+ });
566
+ Object.keys(materialMap).forEach((key) => {
567
+ itemList.push({
568
+ type: "text",
569
+ text: materialMap[key],
570
+ });
571
+ });
572
+ }
573
+ } else if (type === "DROPDOWN") {
574
+ if (Object.keys(materialMap).length > 0) {
575
+ itemList.push({
576
+ type: "text",
577
+ text: `${i18n.t("correct_blanks")}: `,
578
+ });
579
+ Object.keys(materialMap).forEach((key, index) => {
580
+ itemList.push({
581
+ type: "text",
582
+ text: `${i18n.t("blank")} ${index + 1}: ${
583
+ Object.keys(materialMap[key])[0]
584
+ }`,
585
+ });
586
+ });
587
+ }
588
+ } else if (type === "MCSA") {
589
+ if (Object.keys(materialMap).length > 0) {
590
+ const answer = Object.keys(materialMap)[0];
591
+ materialMap[answer].forEach((option: string) => {
592
+ itemList.push({
593
+ type: "text",
594
+ text: option,
595
+ });
596
+ });
597
+ materialMap[answer].forEach((option: string) => {
598
+ if (option === answer) {
599
+ itemList.push({
600
+ type: "text",
601
+ text: `[${i18n.t("answer").toUpperCase()}]${option}`,
602
+ });
603
+ }
604
+ });
605
+ }
606
+ } else if (type === "MCMA") {
607
+ if (Object.keys(materialMap).length > 0) {
608
+ const answer = Object.keys(materialMap)[0];
609
+ materialMap[answer].forEach((option: string) => {
610
+ itemList.push({
611
+ type: "text",
612
+ text: option,
613
+ });
614
+ });
615
+ const splittedTextList = answer.split("§");
616
+ materialMap[answer].forEach((option: string) => {
617
+ if (splittedTextList.includes(option)) {
618
+ itemList.push({
619
+ type: "text",
620
+ text: `[${i18n.t("answer").toUpperCase()}]${option}`,
621
+ });
622
+ }
623
+ });
624
+ }
625
+ } else if (type === "MATCHING") {
626
+ if (Object.keys(materialMap).length > 0) {
627
+ itemList.push({
628
+ type: "text",
629
+ text: `${i18n.t("correct_matching")}: `,
630
+ });
631
+ Object.keys(materialMap).forEach((key, index) => {
632
+ const matchingKey = Object.keys(materialMap[key])[0];
633
+ const matchingValue = materialMap[key][matchingKey];
634
+ itemList.push({
635
+ type: "text",
636
+ text: `${matchingKey}: ${matchingValue}`,
637
+ });
638
+ });
639
+ }
640
+ } else if (type === "GROUPING") {
641
+ if (Object.keys(materialMap).length > 0) {
642
+ itemList.push({
643
+ type: "text",
644
+ text: `${i18n.t("correct_grouping")}: `,
645
+ });
646
+ Object.keys(materialMap).forEach((key, index) => {
647
+ let text = `${i18n.t("group")} ${index + 1}: `;
648
+ itemList.push({
649
+ type: "text",
650
+ text: text,
651
+ });
652
+
653
+ const groupName = Object.keys(materialMap[key])[0];
654
+ let currentText = "";
655
+ materialMap[key][groupName].forEach((item: string) => {
656
+ currentText += `${item}, `;
657
+ });
658
+ currentText = currentText.substring(0, currentText.length - 2);
659
+ itemList.push({
660
+ type: "text",
661
+ text: `${groupName}: ${currentText}`,
662
+ });
663
+ });
664
+ }
665
+ } else if (type === "FILL_IN_THE_BLANKS") {
666
+ if (Object.keys(materialMap).length > 0) {
667
+ itemList.push({
668
+ type: "text",
669
+ text: `${i18n.t("correct_blanks")}: `,
670
+ });
671
+ Object.keys(materialMap).forEach((key, index) => {
672
+ materialMap[key].forEach((item: string) => {
673
+ itemList.push({
674
+ type: "text",
675
+ text: `${i18n.t("blank")} ${index + 1}: ${item}`,
676
+ });
677
+ });
678
+ });
679
+ }
680
+ } else if (type === "OPEN_ENDED") {
681
+ } else if (type === "TRUE_FALSE") {
682
+ if (materialMap.trueList && Object.keys(materialMap.trueList).length > 0) {
683
+ materialMap.trueList.forEach((item: string) => {
684
+ itemList.push({
685
+ type: "text",
686
+ text: `[${i18n.t("correct").toUpperCase()}]${item}`,
687
+ });
688
+ });
689
+ }
690
+
691
+ if (
692
+ materialMap.falseList &&
693
+ Object.keys(materialMap.falseList).length > 0
694
+ ) {
695
+ materialMap.falseList.forEach((item: string) => {
696
+ itemList.push({
697
+ type: "text",
698
+ text: `[${i18n.t("incorrect").toUpperCase()}]${item}`,
699
+ });
700
+ });
701
+ }
702
+ }
703
+
704
+ return itemList;
705
+ };
706
+
707
+ export const constructActivityItemListWithAnswersForAI = (
708
+ bodyMap: any,
709
+ materialMap: any,
710
+ type: string
711
+ ) => {
712
+ const itemList = [];
713
+ if (type === "ORDERING") {
714
+ Object.keys(bodyMap).forEach((key) => {
715
+ const bodyItem = JSON.parse(bodyMap[key]);
716
+ if (bodyItem.type === "IMAGE") {
717
+ itemList.push({
718
+ type: "image_url",
719
+ imageUrl: bodyItem.value,
720
+ });
721
+ } else {
722
+ itemList.push({
723
+ type: "text",
724
+ text: bodyItem.value,
725
+ });
726
+ }
727
+ });
728
+ if (Object.keys(materialMap).length > 0) {
729
+ itemList.push({
730
+ type: "text",
731
+ text: `${i18n.t("correct_order")}: `,
732
+ });
733
+ Object.keys(materialMap).forEach((key) => {
734
+ itemList.push({
735
+ type: "text",
736
+ text: materialMap[key],
737
+ });
738
+ });
739
+ }
740
+ } else if (type === "DROPDOWN") {
741
+ Object.keys(bodyMap).forEach((key) => {
742
+ const bodyItem = JSON.parse(bodyMap[key]);
743
+ if (bodyItem.type === "IMAGE") {
744
+ itemList.push({
745
+ type: "image_url",
746
+ imageUrl: bodyItem.value,
747
+ });
748
+ } else {
749
+ itemList.push({
750
+ type: "text",
751
+ text: bodyItem.value.replaceAll("@@", "___________"),
752
+ });
753
+ }
754
+ });
755
+ if (Object.keys(materialMap).length > 0) {
756
+ itemList.push({
757
+ type: "text",
758
+ text: `${i18n.t("correct_blanks")}: `,
759
+ });
760
+ Object.keys(materialMap).forEach((key, index) => {
761
+ itemList.push({
762
+ type: "text",
763
+ text: `${index + 1}. ${Object.keys(materialMap[key])[0]}`,
764
+ });
765
+ });
766
+ }
767
+ } else if (type === "MCSA") {
768
+ Object.keys(bodyMap).forEach((key) => {
769
+ const bodyItem = JSON.parse(bodyMap[key]);
770
+ if (bodyItem.type === "IMAGE") {
771
+ itemList.push({
772
+ type: "image_url",
773
+ imageUrl: bodyItem.value,
774
+ });
775
+ } else {
776
+ itemList.push({
777
+ type: "text",
778
+ text: bodyItem.value,
779
+ });
780
+ }
781
+ });
782
+ if (Object.keys(materialMap).length > 0) {
783
+ itemList.push({
784
+ type: "text",
785
+ text: `${i18n.t("correct_answer")}: `,
786
+ });
787
+ Object.keys(materialMap).forEach((key) => {
788
+ itemList.push({
789
+ type: "text",
790
+ text: key,
791
+ });
792
+ });
793
+ }
794
+ } else if (type === "MCMA") {
795
+ Object.keys(bodyMap).forEach((key) => {
796
+ const bodyItem = JSON.parse(bodyMap[key]);
797
+ if (bodyItem.type === "IMAGE") {
798
+ itemList.push({
799
+ type: "image_url",
800
+ imageUrl: bodyItem.value,
801
+ });
802
+ } else {
803
+ itemList.push({
804
+ type: "text",
805
+ text: bodyItem.value,
806
+ });
807
+ }
808
+ });
809
+ if (Object.keys(materialMap).length > 0) {
810
+ itemList.push({
811
+ type: "text",
812
+ text: `${i18n.t("correct_answers")}: `,
813
+ });
814
+ const splittedTextList = Object.keys(materialMap)[0].split("§");
815
+ splittedTextList.forEach((item) => {
816
+ const parsedItemList = JSON.parse(item);
817
+ for (const parsedItem of parsedItemList) {
818
+ itemList.push({
819
+ type: "text",
820
+ text: parsedItem,
821
+ });
822
+ }
823
+ });
824
+ }
825
+ } else if (type === "MATCHING") {
826
+ Object.keys(bodyMap).forEach((key) => {
827
+ const bodyItem = JSON.parse(bodyMap[key]);
828
+ if (bodyItem.type === "IMAGE") {
829
+ itemList.push({
830
+ type: "image_url",
831
+ imageUrl: bodyItem.value,
832
+ });
833
+ } else {
834
+ itemList.push({
835
+ type: "text",
836
+ text: bodyItem.value,
837
+ });
838
+ }
839
+ });
840
+ if (Object.keys(materialMap).length > 0) {
841
+ itemList.push({
842
+ type: "text",
843
+ text: `${i18n.t("correct_answers")}: `,
844
+ });
845
+ Object.keys(materialMap).forEach((key, index) => {
846
+ itemList.push({
847
+ type: "text",
848
+ text: `${i18n.t("match")} ${index + 1}:`,
849
+ });
850
+ itemList.push({
851
+ type: "text",
852
+ text: `${key}: ${materialMap[key]}`,
853
+ });
854
+ });
855
+ }
856
+ } else if (type === "GROUPING") {
857
+ Object.keys(bodyMap).forEach((key) => {
858
+ const bodyItem = JSON.parse(bodyMap[key]);
859
+ if (bodyItem.type === "IMAGE") {
860
+ itemList.push({
861
+ type: "image_url",
862
+ imageUrl: bodyItem.value,
863
+ });
864
+ } else {
865
+ itemList.push({
866
+ type: "text",
867
+ text: bodyItem.value,
868
+ });
869
+ }
870
+ });
871
+ if (Object.keys(materialMap).length > 0) {
872
+ itemList.push({
873
+ type: "text",
874
+ text: `${i18n.t("correct_answers")}: `,
875
+ });
876
+ Object.keys(materialMap).forEach((key, index) => {
877
+ let text = `${i18n.t("group")} ${index + 1}: `;
878
+ itemList.push({
879
+ type: "text",
880
+ text: text,
881
+ });
882
+
883
+ const groupName = key;
884
+ let currentText = "";
885
+ materialMap[groupName].forEach((item: string) => {
886
+ currentText += `${item}, `;
887
+ });
888
+ currentText = currentText.substring(0, currentText.length - 2);
889
+ itemList.push({
890
+ type: "text",
891
+ text: `${groupName}: [${currentText}]`,
892
+ });
893
+ });
894
+ }
895
+ } else if (type === "FILL_IN_THE_BLANKS") {
896
+ Object.keys(bodyMap).forEach((key) => {
897
+ const bodyItem = JSON.parse(bodyMap[key]);
898
+ if (bodyItem.type === "IMAGE") {
899
+ itemList.push({
900
+ type: "image_url",
901
+ imageUrl: bodyItem.value,
902
+ });
903
+ } else {
904
+ itemList.push({
905
+ type: "text",
906
+ text: bodyItem.value.replaceAll("@@", "___________"),
907
+ });
908
+ }
909
+ });
910
+ if (Object.keys(materialMap).length > 0) {
911
+ itemList.push({
912
+ type: "text",
913
+ text: `${i18n.t("correct_blanks")}: `,
914
+ });
915
+ Object.keys(materialMap).forEach((key, index) => {
916
+ JSON.parse(materialMap[key]).forEach((item: string) => {
917
+ itemList.push({
918
+ type: "text",
919
+ text: `${index + 1}. ${item}`,
920
+ });
921
+ });
922
+ });
923
+ }
924
+ } else if (type === "OPEN_ENDED") {
925
+ Object.keys(bodyMap).forEach((key) => {
926
+ const bodyItem = JSON.parse(bodyMap[key]);
927
+ if (bodyItem.type === "IMAGE") {
928
+ itemList.push({
929
+ type: "image_url",
930
+ imageUrl: bodyItem.value,
931
+ });
932
+ } else {
933
+ itemList.push({
934
+ type: "text",
935
+ text: bodyItem.value,
936
+ });
937
+ }
938
+ });
939
+ } else if (type === "TRUE_FALSE") {
940
+ Object.keys(bodyMap).forEach((key) => {
941
+ const bodyItem = JSON.parse(bodyMap[key]);
942
+ if (bodyItem.type === "IMAGE") {
943
+ itemList.push({
944
+ type: "image_url",
945
+ imageUrl: bodyItem.value,
946
+ });
947
+ } else {
948
+ itemList.push({
949
+ type: "text",
950
+ text: bodyItem.value,
951
+ });
952
+ }
953
+ });
954
+ if (materialMap.trueList && Object.keys(materialMap.trueList).length > 0) {
955
+ itemList.push({
956
+ type: "text",
957
+ text: `${i18n.t("correct_answers")}: `,
958
+ });
959
+ materialMap.trueList.forEach((item: string) => {
960
+ itemList.push({
961
+ type: "text",
962
+ text: item,
963
+ });
964
+ });
965
+ }
966
+ if (
967
+ materialMap.falseList &&
968
+ Object.keys(materialMap.falseList).length > 0
969
+ ) {
970
+ itemList.push({
971
+ type: "text",
972
+ text: `${i18n.t("incorrect_answers")}: `,
973
+ });
974
+ materialMap.falseList.forEach((item: string) => {
975
+ itemList.push({
976
+ type: "text",
977
+ text: item,
978
+ });
979
+ });
980
+ }
981
+ }
982
+
983
+ return itemList;
984
+ };
985
+
986
+ export const retrieveActivityTemplateDTOOptionList = (
987
+ activityTemplateSet: any
988
+ ) => {
989
+ return activityTemplateSet.map((activityTemplateDTO: any) => ({
990
+ id: activityTemplateDTO.id,
991
+ value: activityTemplateDTO.id,
992
+ text: i18n.t(activityTemplateDTO.type),
993
+ }));
994
+ };
995
+
996
+ const retrieveDefaultOrderingDataMap = (orderingMaterialMap: any) => {
997
+ const dataMap: any = {};
998
+ Object.keys(orderingMaterialMap)
999
+ .sort(() => 0.5 - Math.random())
1000
+ .forEach((key, index) => {
1001
+ dataMap[index] = key;
1002
+ });
1003
+
1004
+ return dataMap;
1005
+ };
1006
+
1007
+ const retrieveDefaultDropdownMap = (dropdownMaterialMap: any) => {
1008
+ const dataMap: any = {};
1009
+ Object.keys(dropdownMaterialMap).forEach((key) => {
1010
+ dataMap[key] = "DEFAULT_OPTION";
1011
+ });
1012
+ return dataMap;
1013
+ };
1014
+
1015
+ const retrieveDefaultMCSAMap = (MCSAMaterialMap: any) => {
1016
+ const dataMap: any = {};
1017
+ Object.keys(MCSAMaterialMap).forEach((key, index) => {
1018
+ dataMap[key] = "ANSWER_KEY";
1019
+ });
1020
+ return dataMap;
1021
+ };
1022
+
1023
+ const retrieveDefaultMCMAMap = (MCMAMaterialMap: any) => {
1024
+ const dataMap: any = {};
1025
+ Object.keys(MCMAMaterialMap).forEach((key, index) => {
1026
+ dataMap[key] = [];
1027
+ });
1028
+ return dataMap;
1029
+ };
1030
+
1031
+ const retrieveDefaultMatchingMap = (matchingMaterialMap: any) => {
1032
+ const dataMap: any = {};
1033
+ Object.keys(matchingMaterialMap).forEach((key, index) => {
1034
+ dataMap[key] = "";
1035
+ });
1036
+ return dataMap;
1037
+ };
1038
+
1039
+ const retrieveDefaultGroupingMap = (groupingMaterialMap: any) => {
1040
+ const dataMap: any = {};
1041
+ Object.keys(groupingMaterialMap).forEach((key, index) => {
1042
+ dataMap[key] = [];
1043
+ });
1044
+ return dataMap;
1045
+ };
1046
+
1047
+ const retrieveDefaultFillInTheBlanksMap = (fillInTheBlanksMaterialMap: any) => {
1048
+ const dataMap: any = {};
1049
+ Object.keys(fillInTheBlanksMaterialMap).forEach((key) => {
1050
+ dataMap[key] = "";
1051
+ });
1052
+ return dataMap;
1053
+ };
1054
+
1055
+ const retrieveDefaultOpenEndedMap = () => {
1056
+ return { ANSWER: "" };
1057
+ };
1058
+
1059
+ const retrieveDefaultTrueFalseMap = () => {
1060
+ return { trueList: [], falseList: [] };
1061
+ };
1062
+
1063
+ export const retrieveCurrentDefaultDataMap = (
1064
+ activityTemplate: any,
1065
+ activityData: any
1066
+ ) => {
1067
+ const defaultDataMap: any = {
1068
+ activityTemplateId: activityTemplate.id,
1069
+ type: activityTemplate.type,
1070
+ };
1071
+ if (activityTemplate.type === "ORDERING") {
1072
+ defaultDataMap.answerMap = retrieveDefaultOrderingDataMap(
1073
+ activityData.orderingMaterialMap
1074
+ );
1075
+ } else if (activityTemplate.type === "DROPDOWN") {
1076
+ defaultDataMap.answerMap = retrieveDefaultDropdownMap(
1077
+ activityData.dropdownMaterialMap
1078
+ );
1079
+ } else if (activityTemplate.type === "MCSA") {
1080
+ defaultDataMap.answerMap = retrieveDefaultMCSAMap(
1081
+ activityData.MCSAMaterialMap
1082
+ );
1083
+ } else if (activityTemplate.type === "MCMA") {
1084
+ defaultDataMap.answerMap = retrieveDefaultMCMAMap(
1085
+ activityData.MCMAMaterialMap
1086
+ );
1087
+ } else if (activityTemplate.type === "MATCHING") {
1088
+ defaultDataMap.answerMap = retrieveDefaultMatchingMap(
1089
+ activityData.matchingMaterialMap
1090
+ );
1091
+ } else if (activityTemplate.type === "GROUPING") {
1092
+ defaultDataMap.answerMap = retrieveDefaultGroupingMap(
1093
+ activityData.groupingMaterialMap
1094
+ );
1095
+ } else if (activityTemplate.type === "FILL_IN_THE_BLANKS") {
1096
+ defaultDataMap.answerMap = retrieveDefaultFillInTheBlanksMap(
1097
+ activityData.fillInTheBlanksMaterialMap
1098
+ );
1099
+ } else if (activityTemplate.type === "OPEN_ENDED") {
1100
+ defaultDataMap.answerMap = retrieveDefaultOpenEndedMap();
1101
+ } else if (activityTemplate.type === "TRUE_FALSE") {
1102
+ defaultDataMap.answerMap = retrieveDefaultTrueFalseMap();
1103
+ }
1104
+ return defaultDataMap;
1105
+ };
1106
+
1107
+ export const constructActivityAnswerMap = (
1108
+ activityTemplate: any,
1109
+ activityData: any
1110
+ ) => {
1111
+ if (activityTemplate.type === "ORDERING") {
1112
+ activityData.orderingMaterialMap = JSON.parse(
1113
+ activityData.orderingMaterialMap
1114
+ );
1115
+ } else if (activityTemplate.type === "DROPDOWN") {
1116
+ activityData.dropdownMaterialMap = JSON.parse(
1117
+ activityData.dropdownMaterialMap
1118
+ );
1119
+ } else if (activityTemplate.type === "MCSA") {
1120
+ activityData.MCSAMaterialMap = JSON.parse(activityData.MCSAMaterialMap);
1121
+ } else if (activityTemplate.type === "MCMA") {
1122
+ activityData.MCMAMaterialMap = JSON.parse(activityData.MCMAMaterialMap);
1123
+ } else if (activityTemplate.type === "MATCHING") {
1124
+ activityData.matchingMaterialMap = JSON.parse(
1125
+ activityData.matchingMaterialMap
1126
+ );
1127
+ } else if (activityTemplate.type === "GROUPING") {
1128
+ activityData.groupingMaterialMap = JSON.parse(
1129
+ activityData.groupingMaterialMap
1130
+ );
1131
+ } else if (activityTemplate.type === "FILL_IN_THE_BLANKS") {
1132
+ activityData.fillInTheBlanksMaterialMap = JSON.parse(
1133
+ activityData.fillInTheBlanksMaterialMap
1134
+ );
1135
+ } else if (activityTemplate.type === "OPEN_ENDED") {
1136
+ activityData.openEndedMaterialMap = {};
1137
+ } else if (activityTemplate.type === "TRUE_FALSE") {
1138
+ activityData.trueFalseMaterialMap = { trueList: [], falseList: [] };
1139
+ }
1140
+ return retrieveCurrentDefaultDataMap(activityTemplate, activityData);
1141
+ };
1142
+
1143
+ export const ignoreMathematicalExpression = (inputText: string) => {
1144
+ return inputText
1145
+ .replaceAll("{", "")
1146
+ .replaceAll("}", "")
1147
+ .replaceAll("_", "")
1148
+ .replaceAll("^", "")
1149
+ .replaceAll("\\frac", "")
1150
+ .replaceAll("\\text", "")
1151
+ .replaceAll("\\sqrt", "");
1152
+ };
1153
+
1154
+ export const checkIfAnswerIsEmpty = (answer: any) => {
1155
+ const { data } = answer;
1156
+ if (data && data.length > 0) {
1157
+ const foundAnswer = data[0];
1158
+ const { type, answerMap } = foundAnswer;
1159
+ if (type === "ORDERING") {
1160
+ return false;
1161
+ } else if (type === "DROPDOWN") {
1162
+ for (const key of Object.keys(answerMap)) {
1163
+ if (answerMap[key] !== "DEFAULT_OPTION") {
1164
+ return false;
1165
+ }
1166
+ }
1167
+ } else if (type === "MCSA") {
1168
+ const key = Object.keys(answerMap)[0];
1169
+ if (answerMap[key] !== "ANSWER_KEY") {
1170
+ return false;
1171
+ }
1172
+ } else if (type === "MCMA") {
1173
+ const key = Object.keys(answerMap)[0];
1174
+ if (answerMap[key].length !== 0) {
1175
+ return false;
1176
+ }
1177
+ } else if (type === "MATCHING") {
1178
+ for (const key of Object.keys(answerMap)) {
1179
+ if (answerMap[key]) {
1180
+ return false;
1181
+ }
1182
+ }
1183
+ } else if (type === "GROUPING") {
1184
+ for (const key of Object.keys(answerMap)) {
1185
+ if (answerMap[key].length !== 0) {
1186
+ return false;
1187
+ }
1188
+ }
1189
+ } else if (type === "FILL_IN_THE_BLANKS") {
1190
+ for (const key of Object.keys(answerMap)) {
1191
+ if (answerMap[key]) {
1192
+ return false;
1193
+ }
1194
+ }
1195
+ } else if (type === "OPEN_ENDED") {
1196
+ const key = Object.keys(answerMap)[0];
1197
+ if (answerMap[key]) {
1198
+ return false;
1199
+ }
1200
+ } else if (type === "TRUE_FALSE") {
1201
+ return (
1202
+ answerMap.trueList.length === 0 && answerMap.falseList.length === 0
1203
+ );
1204
+ }
1205
+ }
1206
+ return true;
1207
+ };
1208
+
1209
+ export const constructActivityAnswerStateList = (
1210
+ answerList: any,
1211
+ activityList: any
1212
+ ) => {
1213
+ const stateList: any = [];
1214
+ activityList.forEach((activity: any, index: number) => {
1215
+ stateList.push({
1216
+ index,
1217
+ id: activity.id,
1218
+ state: checkActivityAnswerState(answerList, activity),
1219
+ });
1220
+ });
1221
+ return stateList;
1222
+ };
1223
+
1224
+ export const retrieveActivityAnswerFromAnswerList = (
1225
+ answerList: any,
1226
+ activity: any
1227
+ ) => {
1228
+ // if (!answerList || !activity) return;
1229
+ return answerList.find(
1230
+ (answer: any) =>
1231
+ parseFloat(answer.activityDTO.id) === parseFloat(activity.id)
1232
+ );
1233
+ };
1234
+
1235
+ export const checkActivityAnswerState = (answerList: any, activity: any) => {
1236
+ const activityAnswer = retrieveActivityAnswerFromAnswerList(
1237
+ answerList,
1238
+ activity
1239
+ );
1240
+ if (!activityAnswer) {
1241
+ return "NOT_EXISTS";
1242
+ }
1243
+ const { data } = activityAnswer;
1244
+ if (!data) return "NOT_EXISTS";
1245
+ const parsedData = JSON.parse(data);
1246
+ if (
1247
+ parsedData.filter((item: any) => !item.isEmpty).length === parsedData.length
1248
+ ) {
1249
+ return "ANSWERED";
1250
+ } else {
1251
+ return "EMPTY";
1252
+ }
1253
+ };
1254
+
1255
+ export const findBestFitActivity = (
1256
+ activity: any,
1257
+ individualModelList: any,
1258
+ outcomeModelList: any
1259
+ ) => {
1260
+ const { activityTemplateDTOList, data, coterieType, categoryIdList } =
1261
+ activity;
1262
+ const parsedData = JSON.parse(data);
1263
+ const {
1264
+ orderingTaxonomyMap,
1265
+ dropdownTaxonomyMap,
1266
+ MCSATaxonomyMap,
1267
+ MCMATaxonomyMap,
1268
+ matchingTaxonomyMap,
1269
+ groupingTaxonomyMap,
1270
+ fillInTheBlanksTaxonomyMap,
1271
+ openEndedTaxonomyMap,
1272
+ trueFalseTaxonomyMap,
1273
+ } = parsedData;
1274
+ const taxonomyMap: any = {};
1275
+ if (orderingTaxonomyMap) {
1276
+ taxonomyMap["orderingTaxonomyMap"] = JSON.parse(orderingTaxonomyMap);
1277
+ }
1278
+ if (dropdownTaxonomyMap) {
1279
+ taxonomyMap["dropdownTaxonomyMap"] = JSON.parse(dropdownTaxonomyMap);
1280
+ }
1281
+ if (MCSATaxonomyMap) {
1282
+ taxonomyMap["MCSATaxonomyMap"] = JSON.parse(MCSATaxonomyMap);
1283
+ }
1284
+ if (MCMATaxonomyMap) {
1285
+ taxonomyMap["MCMATaxonomyMap"] = JSON.parse(MCMATaxonomyMap);
1286
+ }
1287
+ if (matchingTaxonomyMap) {
1288
+ taxonomyMap["matchingTaxonomyMap"] = JSON.parse(matchingTaxonomyMap);
1289
+ }
1290
+ if (groupingTaxonomyMap) {
1291
+ taxonomyMap["groupingTaxonomyMap"] = JSON.parse(groupingTaxonomyMap);
1292
+ }
1293
+ if (fillInTheBlanksTaxonomyMap) {
1294
+ taxonomyMap["fillInTheBlanksTaxonomyMap"] = JSON.parse(
1295
+ fillInTheBlanksTaxonomyMap
1296
+ );
1297
+ }
1298
+ if (trueFalseTaxonomyMap) {
1299
+ taxonomyMap["trueFalseTaxonomyMap"] = JSON.parse(trueFalseTaxonomyMap);
1300
+ }
1301
+ if (openEndedTaxonomyMap) {
1302
+ taxonomyMap["openEndedTaxonomyMap"] = JSON.parse(openEndedTaxonomyMap);
1303
+ }
1304
+ let coterieField = "VERBAL";
1305
+ if (
1306
+ coterieType === "MATHEMATICS" ||
1307
+ coterieType === "BIOLOGY" ||
1308
+ coterieType === "PHYSICS" ||
1309
+ coterieType === "CHEMISTRY" ||
1310
+ coterieType === "SCIENCE"
1311
+ ) {
1312
+ coterieField = "NUMERIC";
1313
+ }
1314
+ let foundModel;
1315
+ let isOutcomeFound = true;
1316
+ if (categoryIdList.length > 0) {
1317
+ const categoryId = categoryIdList[0];
1318
+ foundModel = outcomeModelList.find(
1319
+ (outcomeModel: any) => outcomeModel.outcomeId === categoryId
1320
+ );
1321
+ if (!foundModel) isOutcomeFound = false;
1322
+ } else {
1323
+ isOutcomeFound = false;
1324
+ }
1325
+ if (!isOutcomeFound) {
1326
+ foundModel = individualModelList.find(
1327
+ (individualModel: any) => individualModel.coterieField === coterieField
1328
+ );
1329
+ }
1330
+
1331
+ let bestScore = Number.MAX_SAFE_INTEGER;
1332
+ let bestActivityTemplate;
1333
+ let bestActivityTemplateList = [];
1334
+ const activityTemplateValueMap: any = {};
1335
+ for (const activityTemplateDTO of activityTemplateDTOList) {
1336
+ const { type } = activityTemplateDTO;
1337
+ let currentTaxonomyMap;
1338
+ if (type === "ORDERING") {
1339
+ currentTaxonomyMap = taxonomyMap["orderingTaxonomyMap"];
1340
+ } else if (type === "DROPDOWN") {
1341
+ currentTaxonomyMap = taxonomyMap["dropdownTaxonomyMap"];
1342
+ } else if (type === "MCSA") {
1343
+ currentTaxonomyMap = taxonomyMap["MCSATaxonomyMap"];
1344
+ } else if (type === "MCMA") {
1345
+ currentTaxonomyMap = taxonomyMap["MCMATaxonomyMap"];
1346
+ } else if (type === "MATCHING") {
1347
+ currentTaxonomyMap = taxonomyMap["matchingTaxonomyMap"];
1348
+ } else if (type === "GROUPING") {
1349
+ currentTaxonomyMap = taxonomyMap["groupingTaxonomyMap"];
1350
+ } else if (type === "FILL_IN_THE_BLANKS") {
1351
+ currentTaxonomyMap = taxonomyMap["fillInTheBlanksTaxonomyMap"];
1352
+ } else if (type === "OPEN_ENDED") {
1353
+ currentTaxonomyMap = taxonomyMap["openEndedTaxonomyMap"];
1354
+ } else if (type === "TRUE_FALSE") {
1355
+ currentTaxonomyMap = taxonomyMap["trueFalseTaxonomyMap"];
1356
+ }
1357
+
1358
+ const {
1359
+ type: taxonomyType,
1360
+ groupName: taxonomyGroupName,
1361
+ name: taxonomyName,
1362
+ } = currentTaxonomyMap;
1363
+ const taxonomyString =
1364
+ taxonomyType.toLowerCase() +
1365
+ taxonomyGroupName.toLowerCase().charAt(0).toUpperCase() +
1366
+ taxonomyGroupName.toLowerCase().substring(1) +
1367
+ taxonomyName.toLowerCase().charAt(0).toUpperCase() +
1368
+ taxonomyName.toLowerCase().substring(1);
1369
+
1370
+ const currentTaxonomyScore = foundModel[taxonomyString];
1371
+ const splittedTypeList = type.split("_");
1372
+ let activityTemplateString = "";
1373
+ for (let i = 0; i < splittedTypeList.length; i++) {
1374
+ const currentType = splittedTypeList[i].toLowerCase();
1375
+ if (i === 0) {
1376
+ activityTemplateString += currentType;
1377
+ } else {
1378
+ activityTemplateString +=
1379
+ currentType.charAt(0).toUpperCase() + currentType.substring(1);
1380
+ }
1381
+ }
1382
+ const currentActivityTemplateScore = foundModel[activityTemplateString];
1383
+ const currentScore = currentTaxonomyScore * currentActivityTemplateScore;
1384
+ activityTemplateValueMap[type] = currentScore;
1385
+ if (currentScore < bestScore) {
1386
+ bestScore = currentScore;
1387
+ bestActivityTemplate = type;
1388
+ bestActivityTemplateList = [type];
1389
+ } else if (currentScore === bestScore) {
1390
+ bestActivityTemplateList.push(type);
1391
+ }
1392
+ }
1393
+
1394
+ return {
1395
+ bestScore,
1396
+ bestActivityTemplate,
1397
+ bestActivityTemplateList,
1398
+ activityTemplateValueMap,
1399
+ };
1400
+ };
1401
+
1402
+ export const retrieveContestTypeOptionList = () => {
1403
+ return [
1404
+ {
1405
+ value: "QUIZ",
1406
+ text: i18n.t("QUIZ"),
1407
+ },
1408
+ ];
1409
+ };
1410
+
1411
+ export const retrieveFrequencyTypeOptionList = () => {
1412
+ return [
1413
+ {
1414
+ value: "WEEKLY",
1415
+ text: i18n.t("WEEKLY"),
1416
+ },
1417
+ ];
1418
+ };
1419
+
1420
+ export const retrieveDistintCoterieTypeFromCatchtivityApplicationDTO = (
1421
+ catchtivityApplicationDTOList: any
1422
+ ) => {
1423
+ const coterieTypeList = [];
1424
+ for (const catchtivityApplicationDTO of catchtivityApplicationDTOList) {
1425
+ const { catchtivityDTO } = catchtivityApplicationDTO;
1426
+ const { coterieType } = catchtivityDTO;
1427
+ if (
1428
+ coterieTypeList.findIndex(
1429
+ (foundCoterieType) => foundCoterieType === coterieType
1430
+ ) === -1
1431
+ ) {
1432
+ coterieTypeList.push(coterieType);
1433
+ }
1434
+ }
1435
+ return coterieTypeList;
1436
+ };
1437
+
1438
+ export const retrieveClockTimeLeft = (
1439
+ type: string,
1440
+ value: number,
1441
+ durationType: string,
1442
+ durationInMinutes: number,
1443
+ activityProgressDTOSet: any,
1444
+ activity: any
1445
+ ) => {
1446
+ if (type === "CATCHTIVITY" || type === "CATCHXAM" || type === "CONTEST") {
1447
+ if (durationType === "ALL") {
1448
+ return durationInMinutes
1449
+ ? durationInMinutes * 60 -
1450
+ retrieveTotalTimeSpentInSeconds(activityProgressDTOSet)
1451
+ : 0;
1452
+ } else if (durationType === "EACH") {
1453
+ return durationInMinutes
1454
+ ? durationInMinutes * 60 -
1455
+ retrieveEachTimeSpentInSeconds(activityProgressDTOSet, activity)
1456
+ : 0;
1457
+ } else return 0;
1458
+ } else if (type === "ACTIVITY") {
1459
+ return (
1460
+ value - retrieveEachTimeSpentInSeconds(activityProgressDTOSet, activity)
1461
+ );
1462
+ }
1463
+ return 0;
1464
+ };
1465
+
1466
+ export const retrieveEachTimeSpentInSeconds = (
1467
+ activityProgressList: any,
1468
+ activity: any
1469
+ ) => {
1470
+ if (!activityProgressList || !activity) return 0;
1471
+ const foundActivityProgress = activityProgressList.find(
1472
+ (activityProgress: any) =>
1473
+ parseFloat(activityProgress.activityDTO.id) === parseFloat(activity.id)
1474
+ );
1475
+ if (foundActivityProgress) {
1476
+ return foundActivityProgress.timeSpent / 1000;
1477
+ }
1478
+ return 0;
1479
+ };
1480
+
1481
+ export const retrieveTotalTimeSpentInSeconds = (activityProgressList: any) => {
1482
+ let timeSpent = 0;
1483
+ if (!activityProgressList) return 0;
1484
+ activityProgressList.forEach((activityProgress: any) => {
1485
+ timeSpent += activityProgress.timeSpent;
1486
+ });
1487
+ return timeSpent / 1000;
1488
+ };
1489
+
1490
+ export const retrieveTotalTimeSpentInMinutes = (activityProgressList: any) => {
1491
+ return retrieveTotalTimeSpentInSeconds(activityProgressList) / 60;
1492
+ };
1493
+
1494
+ export const parseContentMapFromData = (data: any) => {
1495
+ return JSON.parse(data.contentMap);
1496
+ };
1497
+
1498
+ export const parseBodyMapFromData = (data: any, type: string) => {
1499
+ if (type === "ORDERING") {
1500
+ return JSON.parse(data.orderingBodyMap);
1501
+ } else if (type === "DROPDOWN") {
1502
+ return JSON.parse(data.dropdownBodyMap);
1503
+ } else if (type === "MCSA") {
1504
+ return JSON.parse(data.MCSABodyMap);
1505
+ } else if (type === "MCMA") {
1506
+ return JSON.parse(data.MCMABodyMap);
1507
+ } else if (type === "MATCHING") {
1508
+ return JSON.parse(data.matchingBodyMap);
1509
+ } else if (type === "GROUPING") {
1510
+ return JSON.parse(data.groupingBodyMap);
1511
+ } else if (type === "FILL_IN_THE_BLANKS") {
1512
+ return JSON.parse(data.fillInTheBlanksBodyMap);
1513
+ } else if (type === "OPEN_ENDED") {
1514
+ return JSON.parse(data.openEndedBodyMap);
1515
+ } else if (type === "TRUE_FALSE") {
1516
+ return JSON.parse(data.trueFalseBodyMap);
1517
+ }
1518
+ };
1519
+
1520
+ export const parseMaterialMapFromData = (data: any, type: string) => {
1521
+ if (type === "ORDERING") {
1522
+ return JSON.parse(data.orderingMaterialMap);
1523
+ } else if (type === "DROPDOWN") {
1524
+ const dropdownMaterialMap = JSON.parse(data.dropdownMaterialMap);
1525
+ Object.keys(dropdownMaterialMap).forEach((materialKey) => {
1526
+ dropdownMaterialMap[materialKey] = JSON.parse(
1527
+ dropdownMaterialMap[materialKey]
1528
+ );
1529
+ const answerKey = Object.keys(dropdownMaterialMap[materialKey])[0];
1530
+ dropdownMaterialMap[materialKey][answerKey] = JSON.parse(
1531
+ dropdownMaterialMap[materialKey][answerKey]
1532
+ );
1533
+ });
1534
+ return dropdownMaterialMap;
1535
+ } else if (type === "MCSA") {
1536
+ const MCSAMaterialMap = JSON.parse(data.MCSAMaterialMap);
1537
+ Object.keys(MCSAMaterialMap).forEach((key) => {
1538
+ MCSAMaterialMap[key] = JSON.parse(MCSAMaterialMap[key]);
1539
+ });
1540
+ return MCSAMaterialMap;
1541
+ } else if (type === "MCMA") {
1542
+ const MCMAMaterialMap = JSON.parse(data.MCMAMaterialMap);
1543
+ Object.keys(MCMAMaterialMap).forEach((key) => {
1544
+ MCMAMaterialMap[key] = JSON.parse(MCMAMaterialMap[key]);
1545
+ });
1546
+ return MCMAMaterialMap;
1547
+ } else if (type === "MATCHING") {
1548
+ return JSON.parse(data.matchingMaterialMap);
1549
+ } else if (type === "GROUPING") {
1550
+ const groupingMaterialMap = JSON.parse(data.groupingMaterialMap);
1551
+ Object.keys(groupingMaterialMap).forEach((key) => {
1552
+ groupingMaterialMap[key] = JSON.parse(groupingMaterialMap[key]);
1553
+ });
1554
+ return groupingMaterialMap;
1555
+ } else if (type === "FILL_IN_THE_BLANKS") {
1556
+ return JSON.parse(data.fillInTheBlanksMaterialMap);
1557
+ } else if (type === "OPEN_ENDED") {
1558
+ return {};
1559
+ } else if (type === "TRUE_FALSE") {
1560
+ const trueFalseMaterialMap = JSON.parse(data.trueFalseMaterialMap);
1561
+ Object.keys(trueFalseMaterialMap).forEach((key) => {
1562
+ trueFalseMaterialMap[key] = JSON.parse(trueFalseMaterialMap[key]);
1563
+ });
1564
+ return trueFalseMaterialMap;
1565
+ }
1566
+ };