catchup-library-web 1.9.5 → 1.10.1
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.
- package/dist/index.js +21 -13
- package/dist/index.mjs +21 -13
- package/package.json +1 -1
- package/src/components/activities/body-content/ActivityBodyContent.tsx +31 -11
- package/src/components/activities/material-content/DropdownActivityMaterialContent.tsx +1 -0
- package/src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx +1 -2
package/dist/index.js
CHANGED
|
@@ -3487,45 +3487,46 @@ var ActivityBodyContent = ({
|
|
|
3487
3487
|
answerMap
|
|
3488
3488
|
}) => {
|
|
3489
3489
|
if (!bodyMap) return null;
|
|
3490
|
-
const processBodyValue = (bodyValue, contentType, answerMap2) => {
|
|
3491
|
-
|
|
3492
|
-
let currentQQIndex = 0;
|
|
3490
|
+
const processBodyValue = (bodyValue, contentType, answerMap2, startIndex) => {
|
|
3491
|
+
let currentQQIndex = startIndex;
|
|
3493
3492
|
let processedValue = bodyValue;
|
|
3494
3493
|
while (processedValue.includes("@@")) {
|
|
3495
|
-
const answer =
|
|
3496
|
-
|
|
3494
|
+
const answer = answerMap2[currentQQIndex];
|
|
3495
|
+
const isEmpty = answer === void 0 || answer === null || answer === "" || answer === "DEFAULT_OPTION" || typeof answer === "string" && answer.trim() === "";
|
|
3496
|
+
if (isEmpty) {
|
|
3497
3497
|
processedValue = processedValue.replace(
|
|
3498
3498
|
"@@",
|
|
3499
3499
|
`----(${currentQQIndex + 1})----`
|
|
3500
3500
|
);
|
|
3501
3501
|
} else {
|
|
3502
|
+
const trimmedAnswer = typeof answer === "string" ? answer.trim() : String(answer);
|
|
3502
3503
|
switch (contentType) {
|
|
3503
3504
|
case "TEXT":
|
|
3504
3505
|
processedValue = processedValue.replace(
|
|
3505
3506
|
"@@",
|
|
3506
|
-
`--TEXT--${
|
|
3507
|
+
`--TEXT--${trimmedAnswer}--TEXT--`
|
|
3507
3508
|
);
|
|
3508
3509
|
break;
|
|
3509
3510
|
case "IMAGE":
|
|
3510
3511
|
processedValue = processedValue.replace(
|
|
3511
3512
|
"@@",
|
|
3512
|
-
`--IMAGE--${
|
|
3513
|
+
`--IMAGE--${trimmedAnswer}--IMAGE--`
|
|
3513
3514
|
);
|
|
3514
3515
|
break;
|
|
3515
3516
|
case "VIDEO":
|
|
3516
3517
|
processedValue = processedValue.replace(
|
|
3517
3518
|
"@@",
|
|
3518
|
-
`--VIDEO--${
|
|
3519
|
+
`--VIDEO--${trimmedAnswer}--VIDEO--`
|
|
3519
3520
|
);
|
|
3520
3521
|
break;
|
|
3521
3522
|
case "AUDIO":
|
|
3522
3523
|
processedValue = processedValue.replace(
|
|
3523
3524
|
"@@",
|
|
3524
|
-
`--AUDIO--${
|
|
3525
|
+
`--AUDIO--${trimmedAnswer}--AUDIO--`
|
|
3525
3526
|
);
|
|
3526
3527
|
break;
|
|
3527
3528
|
default:
|
|
3528
|
-
processedValue = processedValue.replace("@@",
|
|
3529
|
+
processedValue = processedValue.replace("@@", trimmedAnswer);
|
|
3529
3530
|
}
|
|
3530
3531
|
}
|
|
3531
3532
|
currentQQIndex++;
|
|
@@ -3535,6 +3536,7 @@ var ActivityBodyContent = ({
|
|
|
3535
3536
|
currentQQIndex
|
|
3536
3537
|
};
|
|
3537
3538
|
};
|
|
3539
|
+
let globalAnswerIndex = 0;
|
|
3538
3540
|
const processedBodies = Object.keys(bodyMap).map((key) => {
|
|
3539
3541
|
let body;
|
|
3540
3542
|
try {
|
|
@@ -3545,8 +3547,14 @@ var ActivityBodyContent = ({
|
|
|
3545
3547
|
}
|
|
3546
3548
|
if (["DROPDOWN", "FILL_IN_THE_BLANKS"].includes(templateType)) {
|
|
3547
3549
|
const contentType = contentMap["type"];
|
|
3548
|
-
const result = processBodyValue(
|
|
3550
|
+
const result = processBodyValue(
|
|
3551
|
+
body.value,
|
|
3552
|
+
contentType,
|
|
3553
|
+
answerMap,
|
|
3554
|
+
globalAnswerIndex
|
|
3555
|
+
);
|
|
3549
3556
|
body.value = result.processedValue;
|
|
3557
|
+
globalAnswerIndex = result.currentQQIndex;
|
|
3550
3558
|
}
|
|
3551
3559
|
return __spreadProps(__spreadValues({}, body), {
|
|
3552
3560
|
key
|
|
@@ -4157,6 +4165,7 @@ var DropdownActivityMaterialContent = ({
|
|
|
4157
4165
|
(answerData) => answerData.type === "DROPDOWN"
|
|
4158
4166
|
);
|
|
4159
4167
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4168
|
+
if (Object.keys(materialMap).length === 0) return;
|
|
4160
4169
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
4161
4170
|
(materialMapKey, index) => Object.keys(materialMap[materialMapKey])[0]
|
|
4162
4171
|
);
|
|
@@ -4455,7 +4464,6 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4455
4464
|
const foundAnswer = answer.data.find(
|
|
4456
4465
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4457
4466
|
);
|
|
4458
|
-
console.log("found answer: ", foundAnswer);
|
|
4459
4467
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4460
4468
|
if (Object.keys(materialMap).length === 0) return;
|
|
4461
4469
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
@@ -4496,7 +4504,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4496
4504
|
canFullScreen: true
|
|
4497
4505
|
},
|
|
4498
4506
|
`${uniqueValue}-${index}`
|
|
4499
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
4507
|
+
) }, index) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
4500
4508
|
DraggableItem_default,
|
|
4501
4509
|
{
|
|
4502
4510
|
item: { index: option },
|
package/dist/index.mjs
CHANGED
|
@@ -3288,45 +3288,46 @@ var ActivityBodyContent = ({
|
|
|
3288
3288
|
answerMap
|
|
3289
3289
|
}) => {
|
|
3290
3290
|
if (!bodyMap) return null;
|
|
3291
|
-
const processBodyValue = (bodyValue, contentType, answerMap2) => {
|
|
3292
|
-
|
|
3293
|
-
let currentQQIndex = 0;
|
|
3291
|
+
const processBodyValue = (bodyValue, contentType, answerMap2, startIndex) => {
|
|
3292
|
+
let currentQQIndex = startIndex;
|
|
3294
3293
|
let processedValue = bodyValue;
|
|
3295
3294
|
while (processedValue.includes("@@")) {
|
|
3296
|
-
const answer =
|
|
3297
|
-
|
|
3295
|
+
const answer = answerMap2[currentQQIndex];
|
|
3296
|
+
const isEmpty = answer === void 0 || answer === null || answer === "" || answer === "DEFAULT_OPTION" || typeof answer === "string" && answer.trim() === "";
|
|
3297
|
+
if (isEmpty) {
|
|
3298
3298
|
processedValue = processedValue.replace(
|
|
3299
3299
|
"@@",
|
|
3300
3300
|
`----(${currentQQIndex + 1})----`
|
|
3301
3301
|
);
|
|
3302
3302
|
} else {
|
|
3303
|
+
const trimmedAnswer = typeof answer === "string" ? answer.trim() : String(answer);
|
|
3303
3304
|
switch (contentType) {
|
|
3304
3305
|
case "TEXT":
|
|
3305
3306
|
processedValue = processedValue.replace(
|
|
3306
3307
|
"@@",
|
|
3307
|
-
`--TEXT--${
|
|
3308
|
+
`--TEXT--${trimmedAnswer}--TEXT--`
|
|
3308
3309
|
);
|
|
3309
3310
|
break;
|
|
3310
3311
|
case "IMAGE":
|
|
3311
3312
|
processedValue = processedValue.replace(
|
|
3312
3313
|
"@@",
|
|
3313
|
-
`--IMAGE--${
|
|
3314
|
+
`--IMAGE--${trimmedAnswer}--IMAGE--`
|
|
3314
3315
|
);
|
|
3315
3316
|
break;
|
|
3316
3317
|
case "VIDEO":
|
|
3317
3318
|
processedValue = processedValue.replace(
|
|
3318
3319
|
"@@",
|
|
3319
|
-
`--VIDEO--${
|
|
3320
|
+
`--VIDEO--${trimmedAnswer}--VIDEO--`
|
|
3320
3321
|
);
|
|
3321
3322
|
break;
|
|
3322
3323
|
case "AUDIO":
|
|
3323
3324
|
processedValue = processedValue.replace(
|
|
3324
3325
|
"@@",
|
|
3325
|
-
`--AUDIO--${
|
|
3326
|
+
`--AUDIO--${trimmedAnswer}--AUDIO--`
|
|
3326
3327
|
);
|
|
3327
3328
|
break;
|
|
3328
3329
|
default:
|
|
3329
|
-
processedValue = processedValue.replace("@@",
|
|
3330
|
+
processedValue = processedValue.replace("@@", trimmedAnswer);
|
|
3330
3331
|
}
|
|
3331
3332
|
}
|
|
3332
3333
|
currentQQIndex++;
|
|
@@ -3336,6 +3337,7 @@ var ActivityBodyContent = ({
|
|
|
3336
3337
|
currentQQIndex
|
|
3337
3338
|
};
|
|
3338
3339
|
};
|
|
3340
|
+
let globalAnswerIndex = 0;
|
|
3339
3341
|
const processedBodies = Object.keys(bodyMap).map((key) => {
|
|
3340
3342
|
let body;
|
|
3341
3343
|
try {
|
|
@@ -3346,8 +3348,14 @@ var ActivityBodyContent = ({
|
|
|
3346
3348
|
}
|
|
3347
3349
|
if (["DROPDOWN", "FILL_IN_THE_BLANKS"].includes(templateType)) {
|
|
3348
3350
|
const contentType = contentMap["type"];
|
|
3349
|
-
const result = processBodyValue(
|
|
3351
|
+
const result = processBodyValue(
|
|
3352
|
+
body.value,
|
|
3353
|
+
contentType,
|
|
3354
|
+
answerMap,
|
|
3355
|
+
globalAnswerIndex
|
|
3356
|
+
);
|
|
3350
3357
|
body.value = result.processedValue;
|
|
3358
|
+
globalAnswerIndex = result.currentQQIndex;
|
|
3351
3359
|
}
|
|
3352
3360
|
return __spreadProps(__spreadValues({}, body), {
|
|
3353
3361
|
key
|
|
@@ -3958,6 +3966,7 @@ var DropdownActivityMaterialContent = ({
|
|
|
3958
3966
|
(answerData) => answerData.type === "DROPDOWN"
|
|
3959
3967
|
);
|
|
3960
3968
|
if (foundAnswer.answerMap.length === 0) return;
|
|
3969
|
+
if (Object.keys(materialMap).length === 0) return;
|
|
3961
3970
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
3962
3971
|
(materialMapKey, index) => Object.keys(materialMap[materialMapKey])[0]
|
|
3963
3972
|
);
|
|
@@ -4256,7 +4265,6 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4256
4265
|
const foundAnswer = answer.data.find(
|
|
4257
4266
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4258
4267
|
);
|
|
4259
|
-
console.log("found answer: ", foundAnswer);
|
|
4260
4268
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4261
4269
|
if (Object.keys(materialMap).length === 0) return;
|
|
4262
4270
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
@@ -4297,7 +4305,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4297
4305
|
canFullScreen: true
|
|
4298
4306
|
},
|
|
4299
4307
|
`${uniqueValue}-${index}`
|
|
4300
|
-
) }) : /* @__PURE__ */ jsx23(
|
|
4308
|
+
) }, index) : /* @__PURE__ */ jsx23(
|
|
4301
4309
|
DraggableItem_default,
|
|
4302
4310
|
{
|
|
4303
4311
|
item: { index: option },
|
package/package.json
CHANGED
|
@@ -12,49 +12,60 @@ const ActivityBodyContent = ({
|
|
|
12
12
|
const processBodyValue = (
|
|
13
13
|
bodyValue: string,
|
|
14
14
|
contentType: string,
|
|
15
|
-
answerMap: string[]
|
|
15
|
+
answerMap: string[],
|
|
16
|
+
startIndex: number
|
|
16
17
|
) => {
|
|
17
|
-
let currentQQIndex =
|
|
18
|
+
let currentQQIndex = startIndex;
|
|
18
19
|
let processedValue = bodyValue;
|
|
19
20
|
|
|
20
21
|
while (processedValue.includes("@@")) {
|
|
21
|
-
const answer = answerMap[currentQQIndex]
|
|
22
|
+
const answer = answerMap[currentQQIndex];
|
|
22
23
|
|
|
23
|
-
//
|
|
24
|
-
|
|
24
|
+
// More specific check for empty/undefined answers
|
|
25
|
+
const isEmpty =
|
|
26
|
+
answer === undefined ||
|
|
27
|
+
answer === null ||
|
|
28
|
+
answer === "" ||
|
|
29
|
+
answer === "DEFAULT_OPTION" ||
|
|
30
|
+
(typeof answer === "string" && answer.trim() === "");
|
|
31
|
+
|
|
32
|
+
if (isEmpty) {
|
|
25
33
|
processedValue = processedValue.replace(
|
|
26
34
|
"@@",
|
|
27
35
|
`----(${currentQQIndex + 1})----`
|
|
28
36
|
);
|
|
29
37
|
} else {
|
|
30
38
|
// Handle different content types
|
|
39
|
+
const trimmedAnswer =
|
|
40
|
+
typeof answer === "string" ? answer.trim() : String(answer);
|
|
41
|
+
|
|
31
42
|
switch (contentType) {
|
|
32
43
|
case "TEXT":
|
|
33
44
|
processedValue = processedValue.replace(
|
|
34
45
|
"@@",
|
|
35
|
-
`--TEXT--${
|
|
46
|
+
`--TEXT--${trimmedAnswer}--TEXT--`
|
|
36
47
|
);
|
|
37
48
|
break;
|
|
38
49
|
case "IMAGE":
|
|
39
50
|
processedValue = processedValue.replace(
|
|
40
51
|
"@@",
|
|
41
|
-
`--IMAGE--${
|
|
52
|
+
`--IMAGE--${trimmedAnswer}--IMAGE--`
|
|
42
53
|
);
|
|
43
54
|
break;
|
|
44
55
|
case "VIDEO":
|
|
45
56
|
processedValue = processedValue.replace(
|
|
46
57
|
"@@",
|
|
47
|
-
`--VIDEO--${
|
|
58
|
+
`--VIDEO--${trimmedAnswer}--VIDEO--`
|
|
48
59
|
);
|
|
49
60
|
break;
|
|
50
61
|
case "AUDIO":
|
|
51
62
|
processedValue = processedValue.replace(
|
|
52
63
|
"@@",
|
|
53
|
-
`--AUDIO--${
|
|
64
|
+
`--AUDIO--${trimmedAnswer}--AUDIO--`
|
|
54
65
|
);
|
|
55
66
|
break;
|
|
56
67
|
default:
|
|
57
|
-
processedValue = processedValue.replace("@@",
|
|
68
|
+
processedValue = processedValue.replace("@@", trimmedAnswer);
|
|
58
69
|
}
|
|
59
70
|
}
|
|
60
71
|
currentQQIndex++;
|
|
@@ -66,6 +77,9 @@ const ActivityBodyContent = ({
|
|
|
66
77
|
};
|
|
67
78
|
};
|
|
68
79
|
|
|
80
|
+
// Track the global answer index across all bodies
|
|
81
|
+
let globalAnswerIndex = 0;
|
|
82
|
+
|
|
69
83
|
// Process all bodies and their values
|
|
70
84
|
const processedBodies = Object.keys(bodyMap)
|
|
71
85
|
.map((key) => {
|
|
@@ -80,8 +94,14 @@ const ActivityBodyContent = ({
|
|
|
80
94
|
// Only process value if needed for certain template types
|
|
81
95
|
if (["DROPDOWN", "FILL_IN_THE_BLANKS"].includes(templateType)) {
|
|
82
96
|
const contentType = contentMap["type"];
|
|
83
|
-
const result = processBodyValue(
|
|
97
|
+
const result = processBodyValue(
|
|
98
|
+
body.value,
|
|
99
|
+
contentType,
|
|
100
|
+
answerMap,
|
|
101
|
+
globalAnswerIndex
|
|
102
|
+
);
|
|
84
103
|
body.value = result.processedValue;
|
|
104
|
+
globalAnswerIndex = result.currentQQIndex;
|
|
85
105
|
}
|
|
86
106
|
|
|
87
107
|
return {
|
|
@@ -29,6 +29,7 @@ const DropdownActivityMaterialContent = ({
|
|
|
29
29
|
(answerData: any) => answerData.type === "DROPDOWN"
|
|
30
30
|
);
|
|
31
31
|
if (foundAnswer.answerMap.length === 0) return;
|
|
32
|
+
if (Object.keys(materialMap).length === 0) return;
|
|
32
33
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
33
34
|
(materialMapKey, index) => Object.keys(materialMap[materialMapKey])[0]
|
|
34
35
|
);
|
package/src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx
CHANGED
|
@@ -45,7 +45,6 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
45
45
|
const foundAnswer = answer.data.find(
|
|
46
46
|
(answerData: any) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
47
47
|
);
|
|
48
|
-
console.log("found answer: ", foundAnswer);
|
|
49
48
|
if (foundAnswer.answerMap.length === 0) return;
|
|
50
49
|
if (Object.keys(materialMap).length === 0) return;
|
|
51
50
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
@@ -96,7 +95,7 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
96
95
|
<div className="w-full flex flex-row flex-wrap gap-x-2 gap-y-2 my-2">
|
|
97
96
|
{shuffleOptionList.map((option, index) =>
|
|
98
97
|
checkAnswerProvided(answerMap, option) ? (
|
|
99
|
-
<div className="opacity-30">
|
|
98
|
+
<div className="opacity-30" key={index}>
|
|
100
99
|
<ShowMaterialMediaByContentType
|
|
101
100
|
key={`${uniqueValue}-${index}`}
|
|
102
101
|
contentType={contentMap.type}
|