catchup-library-web 1.5.3 → 1.5.5
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +342 -328
- package/dist/index.mjs +342 -328
- package/package.json +1 -1
- package/src/components/activities/body-content/ActivityBodyContent.tsx +92 -91
- package/src/components/activities/body-content/ShowBodyMediaByContentType.tsx +329 -264
- package/src/components/activities/solution-content/ActivitySolutionContent.tsx +1 -1
package/package.json
CHANGED
|
@@ -7,100 +7,101 @@ const ActivityBodyContent = ({
|
|
|
7
7
|
contentMap,
|
|
8
8
|
answerMap,
|
|
9
9
|
}: IActivityBodyContentProps) => {
|
|
10
|
-
|
|
10
|
+
if (!bodyMap || !contentMap) return null;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
answerMap[currentQQIndex].trim() === "" ||
|
|
20
|
-
answerMap[currentQQIndex].trim() === "DEFAULT_OPTION"
|
|
21
|
-
) {
|
|
22
|
-
body.value = body.value.replace(
|
|
23
|
-
"@@",
|
|
24
|
-
`----(${currentQQIndex + 1})----`
|
|
25
|
-
);
|
|
26
|
-
} else {
|
|
27
|
-
if (contentMap["type"] === "TEXT") {
|
|
28
|
-
body.value = body.value.replace(
|
|
29
|
-
"@@",
|
|
30
|
-
`--TEXT--${answerMap[currentQQIndex]}--TEXT--`
|
|
31
|
-
);
|
|
32
|
-
} else if (contentMap["type"] === "IMAGE") {
|
|
33
|
-
body.value = body.value.replace(
|
|
34
|
-
"@@",
|
|
35
|
-
`--IMAGE--${answerMap[currentQQIndex]}--IMAGE--`
|
|
36
|
-
);
|
|
37
|
-
} else if (contentMap["type"] === "VIDEO") {
|
|
38
|
-
body.value = body.value.replace(
|
|
39
|
-
"@@",
|
|
40
|
-
`--VIDEO--${answerMap[currentQQIndex]}--VIDEO--`
|
|
41
|
-
);
|
|
42
|
-
} else if (contentMap["type"] === "AUDIO") {
|
|
43
|
-
body.value = body.value.replace(
|
|
44
|
-
"@@",
|
|
45
|
-
`--AUDIO--${answerMap[currentQQIndex]}--AUDIO--`
|
|
46
|
-
);
|
|
47
|
-
} else {
|
|
48
|
-
body.value = body.value.replace(
|
|
49
|
-
"@@",
|
|
50
|
-
answerMap[currentQQIndex]
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
currentQQIndex++;
|
|
55
|
-
}
|
|
56
|
-
} else if (templateType === "FILL_IN_THE_BLANKS") {
|
|
57
|
-
while (body.value.includes("@@")) {
|
|
58
|
-
if (answerMap[currentQQIndex].trim() === "") {
|
|
59
|
-
body.value = body.value.replace(
|
|
60
|
-
"@@",
|
|
61
|
-
`----(${currentQQIndex + 1})----`
|
|
62
|
-
);
|
|
63
|
-
} else {
|
|
64
|
-
if (contentMap["type"] === "TEXT") {
|
|
65
|
-
body.value = body.value.replace(
|
|
66
|
-
"@@",
|
|
67
|
-
`--TEXT--${answerMap[currentQQIndex]}--TEXT--`
|
|
68
|
-
);
|
|
69
|
-
} else if (contentMap["type"] === "IMAGE") {
|
|
70
|
-
body.value = body.value.replace(
|
|
71
|
-
"@@",
|
|
72
|
-
`--IMAGE--${answerMap[currentQQIndex]}--IMAGE--`
|
|
73
|
-
);
|
|
74
|
-
} else if (contentMap["type"] === "VIDEO") {
|
|
75
|
-
body.value = body.value.replace(
|
|
76
|
-
"@@",
|
|
77
|
-
`--VIDEO--${answerMap[currentQQIndex]}--VIDEO--`
|
|
78
|
-
);
|
|
79
|
-
} else if (contentMap["type"] === "AUDIO") {
|
|
80
|
-
body.value = body.value.replace(
|
|
81
|
-
"@@",
|
|
82
|
-
`--AUDIO--${answerMap[currentQQIndex]}--AUDIO--`
|
|
83
|
-
);
|
|
84
|
-
} else {
|
|
85
|
-
body.value = body.value.replace(
|
|
86
|
-
"@@",
|
|
87
|
-
answerMap[currentQQIndex]
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
currentQQIndex++;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
12
|
+
const processBodyValue = (
|
|
13
|
+
bodyValue: string,
|
|
14
|
+
contentType: string,
|
|
15
|
+
answerMap: string[]
|
|
16
|
+
) => {
|
|
17
|
+
let currentQQIndex = 0;
|
|
18
|
+
let processedValue = bodyValue;
|
|
94
19
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
20
|
+
while (processedValue.includes("@@")) {
|
|
21
|
+
const answer = answerMap[currentQQIndex]?.trim() || "";
|
|
22
|
+
|
|
23
|
+
// Handle empty or default answers
|
|
24
|
+
if (answer === "" || answer === "DEFAULT_OPTION") {
|
|
25
|
+
processedValue = processedValue.replace(
|
|
26
|
+
"@@",
|
|
27
|
+
`----(${currentQQIndex + 1})----`
|
|
102
28
|
);
|
|
103
|
-
}
|
|
29
|
+
} else {
|
|
30
|
+
// Handle different content types
|
|
31
|
+
switch (contentType) {
|
|
32
|
+
case "TEXT":
|
|
33
|
+
processedValue = processedValue.replace(
|
|
34
|
+
"@@",
|
|
35
|
+
`--TEXT--${answer}--TEXT--`
|
|
36
|
+
);
|
|
37
|
+
break;
|
|
38
|
+
case "IMAGE":
|
|
39
|
+
processedValue = processedValue.replace(
|
|
40
|
+
"@@",
|
|
41
|
+
`--IMAGE--${answer}--IMAGE--`
|
|
42
|
+
);
|
|
43
|
+
break;
|
|
44
|
+
case "VIDEO":
|
|
45
|
+
processedValue = processedValue.replace(
|
|
46
|
+
"@@",
|
|
47
|
+
`--VIDEO--${answer}--VIDEO--`
|
|
48
|
+
);
|
|
49
|
+
break;
|
|
50
|
+
case "AUDIO":
|
|
51
|
+
processedValue = processedValue.replace(
|
|
52
|
+
"@@",
|
|
53
|
+
`--AUDIO--${answer}--AUDIO--`
|
|
54
|
+
);
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
processedValue = processedValue.replace("@@", answer);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
currentQQIndex++;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
processedValue,
|
|
65
|
+
currentQQIndex,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// Process all bodies and their values
|
|
70
|
+
const processedBodies = Object.keys(bodyMap)
|
|
71
|
+
.map((key) => {
|
|
72
|
+
let body;
|
|
73
|
+
try {
|
|
74
|
+
body = JSON.parse(bodyMap[key]);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error(`Error parsing body at key ${key}:`, error);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Only process value if needed for certain template types
|
|
81
|
+
if (["DROPDOWN", "FILL_IN_THE_BLANKS"].includes(templateType)) {
|
|
82
|
+
const contentType = contentMap["type"];
|
|
83
|
+
const result = processBodyValue(body.value, contentType, answerMap);
|
|
84
|
+
body.value = result.processedValue;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
...body,
|
|
89
|
+
key,
|
|
90
|
+
};
|
|
91
|
+
})
|
|
92
|
+
.filter(Boolean);
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="flex flex-col justify-center items-center">
|
|
96
|
+
{processedBodies.map((body, index) => (
|
|
97
|
+
<ShowBodyMediaByContentType
|
|
98
|
+
key={`body-${body.key}-${index}`}
|
|
99
|
+
index={index}
|
|
100
|
+
type={body.type}
|
|
101
|
+
value={body.value}
|
|
102
|
+
size={body.size}
|
|
103
|
+
/>
|
|
104
|
+
))}
|
|
104
105
|
</div>
|
|
105
106
|
);
|
|
106
107
|
};
|