catchup-library-web 2.2.1 → 2.2.3
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +253 -197
- package/dist/index.mjs +252 -196
- package/package.json +1 -1
- package/src/components/activities/MCMAActivityContent.tsx +2 -0
- package/src/components/activities/MCSAActivityContent.tsx +2 -0
- package/src/components/activities/material-contents/DropdownActivityMaterialContent.tsx +146 -142
- package/src/components/activities/material-contents/FillInTheBlanksActivityMaterialContent.tsx +28 -19
- package/src/components/activities/material-contents/GroupingActivityMaterialContent.tsx +12 -8
- package/src/components/activities/material-contents/MCMAActivityMaterialContent.tsx +21 -3
- package/src/components/activities/material-contents/MCSAActivityMaterialContent.tsx +20 -3
- package/src/components/activities/material-contents/MatchingActivityMaterialContent.tsx +20 -13
- package/src/components/activities/material-contents/OrderingActivityMaterialContent.tsx +19 -13
- package/src/components/activities/material-contents/TrueFalseActivityMaterialContent.tsx +1 -1
- package/src/properties/ActivityProperties.ts +2 -0
|
@@ -22,6 +22,7 @@ const MatchingActivityMaterialContent = ({
|
|
|
22
22
|
null
|
|
23
23
|
);
|
|
24
24
|
const [shuffledMaterialList, setShuffledMaterialList] = useState<any[]>([]);
|
|
25
|
+
const [displayAnswerMap, setDisplayAnswerMap] = useState<any>(answerMap);
|
|
25
26
|
const dragElementRef = useRef<HTMLDivElement>(null);
|
|
26
27
|
const [mousePosition, setMousePosition] = useState<{ x: number; y: number }>({
|
|
27
28
|
x: 0,
|
|
@@ -58,9 +59,12 @@ const MatchingActivityMaterialContent = ({
|
|
|
58
59
|
}, [materialMap]);
|
|
59
60
|
|
|
60
61
|
useEffect(() => {
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
if (showCorrectAnswer) {
|
|
63
|
+
setDisplayAnswerMap(materialMap);
|
|
64
|
+
} else {
|
|
65
|
+
setDisplayAnswerMap(answerMap);
|
|
66
|
+
}
|
|
67
|
+
}, [showCorrectAnswer, answerMap, materialMap]);
|
|
64
68
|
|
|
65
69
|
useEffect(() => {
|
|
66
70
|
if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
|
|
@@ -127,10 +131,10 @@ const MatchingActivityMaterialContent = ({
|
|
|
127
131
|
requestAnimationFrame(animate);
|
|
128
132
|
}, [dropTargetKey]);
|
|
129
133
|
|
|
130
|
-
const retrieveFilteredMaterialList = (
|
|
134
|
+
const retrieveFilteredMaterialList = (currentAnswerMap: any) => {
|
|
131
135
|
const selectedValueList: any = [];
|
|
132
|
-
Object.keys(
|
|
133
|
-
selectedValueList.push(
|
|
136
|
+
Object.keys(currentAnswerMap).forEach((key) => {
|
|
137
|
+
selectedValueList.push(currentAnswerMap[key]);
|
|
134
138
|
});
|
|
135
139
|
|
|
136
140
|
return shuffledMaterialList.filter(
|
|
@@ -246,7 +250,7 @@ const MatchingActivityMaterialContent = ({
|
|
|
246
250
|
}
|
|
247
251
|
};
|
|
248
252
|
|
|
249
|
-
const filteredMaterialList = retrieveFilteredMaterialList(
|
|
253
|
+
const filteredMaterialList = retrieveFilteredMaterialList(displayAnswerMap);
|
|
250
254
|
|
|
251
255
|
return (
|
|
252
256
|
<div onMouseMove={handleMouseMove} onMouseUp={handleMouseUp}>
|
|
@@ -421,10 +425,10 @@ const MatchingActivityMaterialContent = ({
|
|
|
421
425
|
</>
|
|
422
426
|
) : null}
|
|
423
427
|
|
|
424
|
-
{Object.keys(
|
|
428
|
+
{Object.keys(displayAnswerMap).map((answerMapKey, index) => {
|
|
425
429
|
const learnerAnswerState = checkAnswerState(
|
|
426
430
|
materialMap[answerMapKey],
|
|
427
|
-
|
|
431
|
+
displayAnswerMap[answerMapKey]
|
|
428
432
|
);
|
|
429
433
|
|
|
430
434
|
return (
|
|
@@ -501,17 +505,20 @@ const MatchingActivityMaterialContent = ({
|
|
|
501
505
|
className="h-full flex-1 flex flex-row items-center justify-center px-4"
|
|
502
506
|
onClick={(e) => {
|
|
503
507
|
e.stopPropagation();
|
|
504
|
-
if (
|
|
508
|
+
if (
|
|
509
|
+
checkCanAnswerQuestion() &&
|
|
510
|
+
displayAnswerMap[answerMapKey]
|
|
511
|
+
) {
|
|
505
512
|
onChange(answerMap, answerMapKey, null);
|
|
506
513
|
setSelectedValue(null);
|
|
507
514
|
}
|
|
508
515
|
}}
|
|
509
516
|
>
|
|
510
|
-
{
|
|
517
|
+
{displayAnswerMap[answerMapKey] ? (
|
|
511
518
|
contentMap.type === "TEXT" ? (
|
|
512
519
|
<p className="text-lg whitespace-pre-wrap">
|
|
513
520
|
{constructInputWithSpecialExpressionList(
|
|
514
|
-
|
|
521
|
+
displayAnswerMap[answerMapKey]
|
|
515
522
|
).map((inputPart, index) => (
|
|
516
523
|
<span
|
|
517
524
|
key={index}
|
|
@@ -533,7 +540,7 @@ const MatchingActivityMaterialContent = ({
|
|
|
533
540
|
<ShowMaterialMediaByContentType
|
|
534
541
|
key={`${uniqueValue}-${index}`}
|
|
535
542
|
contentType={contentMap.type}
|
|
536
|
-
src={
|
|
543
|
+
src={displayAnswerMap[answerMapKey]}
|
|
537
544
|
canFullScreen={false}
|
|
538
545
|
/>
|
|
539
546
|
)
|
|
@@ -32,6 +32,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
32
32
|
});
|
|
33
33
|
const { screenSize } = useScreenSize();
|
|
34
34
|
const [view, setView] = useState("PC");
|
|
35
|
+
const [displayAnswerMap, setDisplayAnswerMap] = useState<any>(answerMap);
|
|
35
36
|
|
|
36
37
|
useEffect(() => {
|
|
37
38
|
if (!screenSize) return;
|
|
@@ -43,11 +44,16 @@ const OrderingActivityMaterialContent = ({
|
|
|
43
44
|
}, [screenSize]);
|
|
44
45
|
|
|
45
46
|
useEffect(() => {
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
answerMap
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
if (showCorrectAnswer) {
|
|
48
|
+
const correctAnswerMap: any = {};
|
|
49
|
+
Object.keys(answerMap).forEach((answerKey, index) => {
|
|
50
|
+
correctAnswerMap[answerKey] = index;
|
|
51
|
+
});
|
|
52
|
+
setDisplayAnswerMap(correctAnswerMap);
|
|
53
|
+
} else {
|
|
54
|
+
setDisplayAnswerMap(answerMap);
|
|
55
|
+
}
|
|
56
|
+
}, [showCorrectAnswer, answerMap]);
|
|
51
57
|
|
|
52
58
|
const checkAnswerState = (correctAnswer: string, learnerAnswer: string) => {
|
|
53
59
|
if (!isPreview) return null;
|
|
@@ -197,7 +203,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
197
203
|
<div className="border-catchup-blue border-2 px-3 py-2 rounded-catchup-xlarge bg-white shadow-lg">
|
|
198
204
|
<p className="text-xl whitespace-pre-wrap">
|
|
199
205
|
{constructInputWithSpecialExpressionList(
|
|
200
|
-
materialMap[
|
|
206
|
+
materialMap[displayAnswerMap[draggedKey]]
|
|
201
207
|
).map((inputPart, index) => (
|
|
202
208
|
<span
|
|
203
209
|
key={index}
|
|
@@ -221,7 +227,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
221
227
|
<ShowMaterialMediaByContentType
|
|
222
228
|
key={`${uniqueValue}-drag-mouse`}
|
|
223
229
|
contentType={contentMap.type}
|
|
224
|
-
src={materialMap[
|
|
230
|
+
src={materialMap[displayAnswerMap[draggedKey]]}
|
|
225
231
|
canFullScreen={false}
|
|
226
232
|
/>
|
|
227
233
|
</div>
|
|
@@ -242,7 +248,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
242
248
|
<div className="border-catchup-blue border-2 px-3 py-2 rounded-catchup-xlarge bg-white shadow-lg">
|
|
243
249
|
<p className="text-xl whitespace-pre-wrap">
|
|
244
250
|
{constructInputWithSpecialExpressionList(
|
|
245
|
-
materialMap[
|
|
251
|
+
materialMap[displayAnswerMap[draggedKey]]
|
|
246
252
|
).map((inputPart, index) => (
|
|
247
253
|
<span
|
|
248
254
|
key={index}
|
|
@@ -266,7 +272,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
266
272
|
<ShowMaterialMediaByContentType
|
|
267
273
|
key={`${uniqueValue}-drag-touch`}
|
|
268
274
|
contentType={contentMap.type}
|
|
269
|
-
src={materialMap[
|
|
275
|
+
src={materialMap[displayAnswerMap[draggedKey]]}
|
|
270
276
|
canFullScreen={false}
|
|
271
277
|
/>
|
|
272
278
|
</div>
|
|
@@ -274,9 +280,9 @@ const OrderingActivityMaterialContent = ({
|
|
|
274
280
|
</div>
|
|
275
281
|
)}
|
|
276
282
|
|
|
277
|
-
{Object.keys(
|
|
283
|
+
{Object.keys(displayAnswerMap).map((materialKey, index) => {
|
|
278
284
|
const learnerAnswerState = checkAnswerState(
|
|
279
|
-
|
|
285
|
+
displayAnswerMap[materialKey] + "",
|
|
280
286
|
index + ""
|
|
281
287
|
);
|
|
282
288
|
return (
|
|
@@ -348,7 +354,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
348
354
|
{contentMap.type === "TEXT" ? (
|
|
349
355
|
<p className="text-xl whitespace-pre-wrap">
|
|
350
356
|
{constructInputWithSpecialExpressionList(
|
|
351
|
-
materialMap[
|
|
357
|
+
materialMap[displayAnswerMap[materialKey]]
|
|
352
358
|
).map((inputPart, index) => (
|
|
353
359
|
<span
|
|
354
360
|
key={index}
|
|
@@ -370,7 +376,7 @@ const OrderingActivityMaterialContent = ({
|
|
|
370
376
|
<ShowMaterialMediaByContentType
|
|
371
377
|
key={`${uniqueValue}-${index}`}
|
|
372
378
|
contentType={contentMap.type}
|
|
373
|
-
src={materialMap[
|
|
379
|
+
src={materialMap[displayAnswerMap[materialKey]]}
|
|
374
380
|
canFullScreen={true}
|
|
375
381
|
/>
|
|
376
382
|
)}
|
|
@@ -78,6 +78,7 @@ export interface IMCSAActivityMaterialProps {
|
|
|
78
78
|
checkCanAnswerQuestion: () => boolean;
|
|
79
79
|
onChange: (e1: any, e2: any, e3: string) => void;
|
|
80
80
|
isPreview: boolean;
|
|
81
|
+
showCorrectAnswer: boolean;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
export interface IMCMAActivityProps {
|
|
@@ -98,6 +99,7 @@ export interface IMCMAActivityMaterialProps {
|
|
|
98
99
|
checkCanAnswerQuestion: () => boolean;
|
|
99
100
|
onChange: (e1: any, e2: any, e3: string) => void;
|
|
100
101
|
isPreview: boolean;
|
|
102
|
+
showCorrectAnswer: boolean;
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
export interface IGroupingActivityProps {
|