catchup-library-web 2.1.1 → 2.1.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 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.js +45 -57
- package/dist/index.mjs +45 -57
- package/package.json +1 -1
- package/src/components/activities/ActivityPreviewByData.tsx +2 -2
- package/src/components/activities/OrderingActivityContent.tsx +0 -1
- package/src/components/activities/material-contents/GroupingActivityMaterialContent.tsx +12 -17
- package/src/components/activities/material-contents/OrderingActivityMaterialContent.tsx +0 -5
- package/src/properties/ActivityProperties.ts +0 -1
- package/src/utilization/CatchtivityUtilization.ts +62 -44
package/dist/index.d.mts
CHANGED
|
@@ -135,7 +135,6 @@ interface IOrderingActivityProps {
|
|
|
135
135
|
changeAnswer: (e: any) => void;
|
|
136
136
|
isPreview: boolean;
|
|
137
137
|
showCorrectAnswer: boolean;
|
|
138
|
-
isFullScreen: boolean;
|
|
139
138
|
}
|
|
140
139
|
interface IDropdownActivityProps {
|
|
141
140
|
answerMap: any;
|
|
@@ -255,7 +254,7 @@ declare const MCSAActivityContent: ({ answerMap, data, canAnswerQuestion, change
|
|
|
255
254
|
|
|
256
255
|
declare const OpenEndedActivityContent: ({ answerMap, data, changeAnswer, canAnswerQuestion, showMaterialContent, isPreview, isFullScreen, }: IOpenEndedActivityProps) => react_jsx_runtime.JSX.Element;
|
|
257
256
|
|
|
258
|
-
declare const OrderingActivityContent: ({ answerMap, data, canAnswerQuestion, changeAnswer, isPreview, showCorrectAnswer,
|
|
257
|
+
declare const OrderingActivityContent: ({ answerMap, data, canAnswerQuestion, changeAnswer, isPreview, showCorrectAnswer, }: IOrderingActivityProps) => react_jsx_runtime.JSX.Element;
|
|
259
258
|
|
|
260
259
|
declare const TrueFalseActivityContent: ({ answerMap, data, canAnswerQuestion, changeAnswer, isPreview, showCorrectAnswer, isFullScreen, }: ITrueFalseActivityProps) => react_jsx_runtime.JSX.Element;
|
|
261
260
|
|
|
@@ -597,7 +596,7 @@ declare const convertToBodyMapString: (type: string, bodyMap: any) => any;
|
|
|
597
596
|
declare const convertToSolutionMapString: (type: string, solutionMap: any) => any;
|
|
598
597
|
declare const convertToEvaluationRubricMapString: (type: string, evaluationRubricMap: any) => any;
|
|
599
598
|
declare const constructActivityData: (activityTemplateType: string, contentMap: any, bodyMap: any, materialMap: any, solutionMap: any, difficulty: string, evaluationRubricMap: any) => any;
|
|
600
|
-
declare const constructAnswerBasedOnData: (data: any) => any;
|
|
599
|
+
declare const constructAnswerBasedOnData: (type: string, data: any) => any;
|
|
601
600
|
declare const constructActivityItemListBodyOnly: (bodyMap: any) => any;
|
|
602
601
|
declare const constructActivityItemListMaterialOnly: (materialMap: any, type: string) => {
|
|
603
602
|
type: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -135,7 +135,6 @@ interface IOrderingActivityProps {
|
|
|
135
135
|
changeAnswer: (e: any) => void;
|
|
136
136
|
isPreview: boolean;
|
|
137
137
|
showCorrectAnswer: boolean;
|
|
138
|
-
isFullScreen: boolean;
|
|
139
138
|
}
|
|
140
139
|
interface IDropdownActivityProps {
|
|
141
140
|
answerMap: any;
|
|
@@ -255,7 +254,7 @@ declare const MCSAActivityContent: ({ answerMap, data, canAnswerQuestion, change
|
|
|
255
254
|
|
|
256
255
|
declare const OpenEndedActivityContent: ({ answerMap, data, changeAnswer, canAnswerQuestion, showMaterialContent, isPreview, isFullScreen, }: IOpenEndedActivityProps) => react_jsx_runtime.JSX.Element;
|
|
257
256
|
|
|
258
|
-
declare const OrderingActivityContent: ({ answerMap, data, canAnswerQuestion, changeAnswer, isPreview, showCorrectAnswer,
|
|
257
|
+
declare const OrderingActivityContent: ({ answerMap, data, canAnswerQuestion, changeAnswer, isPreview, showCorrectAnswer, }: IOrderingActivityProps) => react_jsx_runtime.JSX.Element;
|
|
259
258
|
|
|
260
259
|
declare const TrueFalseActivityContent: ({ answerMap, data, canAnswerQuestion, changeAnswer, isPreview, showCorrectAnswer, isFullScreen, }: ITrueFalseActivityProps) => react_jsx_runtime.JSX.Element;
|
|
261
260
|
|
|
@@ -597,7 +596,7 @@ declare const convertToBodyMapString: (type: string, bodyMap: any) => any;
|
|
|
597
596
|
declare const convertToSolutionMapString: (type: string, solutionMap: any) => any;
|
|
598
597
|
declare const convertToEvaluationRubricMapString: (type: string, evaluationRubricMap: any) => any;
|
|
599
598
|
declare const constructActivityData: (activityTemplateType: string, contentMap: any, bodyMap: any, materialMap: any, solutionMap: any, difficulty: string, evaluationRubricMap: any) => any;
|
|
600
|
-
declare const constructAnswerBasedOnData: (data: any) => any;
|
|
599
|
+
declare const constructAnswerBasedOnData: (type: string, data: any) => any;
|
|
601
600
|
declare const constructActivityItemListBodyOnly: (bodyMap: any) => any;
|
|
602
601
|
declare const constructActivityItemListMaterialOnly: (materialMap: any, type: string) => {
|
|
603
602
|
type: string;
|
package/dist/index.js
CHANGED
|
@@ -2298,7 +2298,19 @@ var retrieveActivityTemplateDTOOptionList = (activityTemplateSet) => {
|
|
|
2298
2298
|
};
|
|
2299
2299
|
var retrieveDefaultOrderingDataMap = (orderingMaterialMap) => {
|
|
2300
2300
|
const dataMap = {};
|
|
2301
|
-
Object.keys(orderingMaterialMap)
|
|
2301
|
+
const originalKeys = Object.keys(orderingMaterialMap);
|
|
2302
|
+
const shuffledKeys = [...originalKeys];
|
|
2303
|
+
for (let i = shuffledKeys.length - 1; i > 0; i--) {
|
|
2304
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
2305
|
+
[shuffledKeys[i], shuffledKeys[j]] = [shuffledKeys[j], shuffledKeys[i]];
|
|
2306
|
+
}
|
|
2307
|
+
const isSameOrder = shuffledKeys.every(
|
|
2308
|
+
(key, index) => key === originalKeys[index]
|
|
2309
|
+
);
|
|
2310
|
+
if (isSameOrder && shuffledKeys.length >= 2) {
|
|
2311
|
+
[shuffledKeys[0], shuffledKeys[1]] = [shuffledKeys[1], shuffledKeys[0]];
|
|
2312
|
+
}
|
|
2313
|
+
shuffledKeys.forEach((key, index) => {
|
|
2302
2314
|
dataMap[index] = key;
|
|
2303
2315
|
});
|
|
2304
2316
|
return dataMap;
|
|
@@ -2967,56 +2979,35 @@ var constructActivityData = (activityTemplateType, contentMap, bodyMap, material
|
|
|
2967
2979
|
}
|
|
2968
2980
|
return constructedData;
|
|
2969
2981
|
};
|
|
2970
|
-
var constructAnswerBasedOnData = (data) => {
|
|
2971
|
-
if (Object.keys(data).find((dataKey) => dataKey === "orderingMaterialMap")) {
|
|
2972
|
-
return constructActivityAnswerMap(
|
|
2973
|
-
"ORDERING",
|
|
2974
|
-
JSON.parse(JSON.stringify(data))
|
|
2975
|
-
);
|
|
2982
|
+
var constructAnswerBasedOnData = (type, data) => {
|
|
2983
|
+
if (type === "ORDERING" && Object.keys(data).find((dataKey) => dataKey === "orderingMaterialMap")) {
|
|
2984
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2976
2985
|
}
|
|
2977
|
-
if (Object.keys(data).find((dataKey) => dataKey === "dropdownMaterialMap")) {
|
|
2978
|
-
return constructActivityAnswerMap(
|
|
2979
|
-
"DROPDOWN",
|
|
2980
|
-
JSON.parse(JSON.stringify(data))
|
|
2981
|
-
);
|
|
2986
|
+
if (type === "DROPDOWN" && Object.keys(data).find((dataKey) => dataKey === "dropdownMaterialMap")) {
|
|
2987
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2982
2988
|
}
|
|
2983
|
-
if (Object.keys(data).find((dataKey) => dataKey === "MCSAMaterialMap")) {
|
|
2984
|
-
return constructActivityAnswerMap(
|
|
2989
|
+
if (type === "MCSA" && Object.keys(data).find((dataKey) => dataKey === "MCSAMaterialMap")) {
|
|
2990
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2985
2991
|
}
|
|
2986
|
-
if (Object.keys(data).find((dataKey) => dataKey === "MCMAMaterialMap")) {
|
|
2987
|
-
return constructActivityAnswerMap(
|
|
2992
|
+
if (type === "MCMA" && Object.keys(data).find((dataKey) => dataKey === "MCMAMaterialMap")) {
|
|
2993
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2988
2994
|
}
|
|
2989
|
-
if (Object.keys(data).find((dataKey) => dataKey === "matchingMaterialMap")) {
|
|
2990
|
-
return constructActivityAnswerMap(
|
|
2991
|
-
"MATCHING",
|
|
2992
|
-
JSON.parse(JSON.stringify(data))
|
|
2993
|
-
);
|
|
2995
|
+
if (type === "MATCHING" && Object.keys(data).find((dataKey) => dataKey === "matchingMaterialMap")) {
|
|
2996
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2994
2997
|
}
|
|
2995
|
-
if (Object.keys(data).find((dataKey) => dataKey === "groupingMaterialMap")) {
|
|
2996
|
-
return constructActivityAnswerMap(
|
|
2997
|
-
"GROUPING",
|
|
2998
|
-
JSON.parse(JSON.stringify(data))
|
|
2999
|
-
);
|
|
2998
|
+
if (type === "GROUPING" && Object.keys(data).find((dataKey) => dataKey === "groupingMaterialMap")) {
|
|
2999
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
3000
3000
|
}
|
|
3001
|
-
if (Object.keys(data).find(
|
|
3001
|
+
if (type === "FILL_IN_THE_BLANKS" && Object.keys(data).find(
|
|
3002
3002
|
(dataKey) => dataKey === "fillInTheBlanksMaterialMap"
|
|
3003
3003
|
)) {
|
|
3004
|
-
return constructActivityAnswerMap(
|
|
3005
|
-
"FILL_IN_THE_BLANKS",
|
|
3006
|
-
JSON.parse(JSON.stringify(data))
|
|
3007
|
-
);
|
|
3004
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
3008
3005
|
}
|
|
3009
|
-
if (Object.keys(data).find((dataKey) => dataKey === "openEndedMaterialMap")) {
|
|
3010
|
-
return constructActivityAnswerMap(
|
|
3011
|
-
"OPEN_ENDED",
|
|
3012
|
-
JSON.parse(JSON.stringify(data))
|
|
3013
|
-
);
|
|
3006
|
+
if (type === "OPEN_ENDED" && Object.keys(data).find((dataKey) => dataKey === "openEndedMaterialMap")) {
|
|
3007
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
3014
3008
|
}
|
|
3015
|
-
if (Object.keys(data).find((dataKey) => dataKey === "trueFalseMaterialMap")) {
|
|
3016
|
-
return constructActivityAnswerMap(
|
|
3017
|
-
"TRUE_FALSE",
|
|
3018
|
-
JSON.parse(JSON.stringify(data))
|
|
3019
|
-
);
|
|
3009
|
+
if (type === "TRUE_FALSE" && Object.keys(data).find((dataKey) => dataKey === "trueFalseMaterialMap")) {
|
|
3010
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
3020
3011
|
}
|
|
3021
3012
|
return {};
|
|
3022
3013
|
};
|
|
@@ -5227,7 +5218,6 @@ var GroupingActivityMaterialContent = ({
|
|
|
5227
5218
|
const [draggedElement, setDraggedElement] = (0, import_react20.useState)(
|
|
5228
5219
|
null
|
|
5229
5220
|
);
|
|
5230
|
-
const [isShuffled, setIsShuffled] = (0, import_react20.useState)(false);
|
|
5231
5221
|
const [shuffledMaterialList, setShuffledMaterialList] = (0, import_react20.useState)([]);
|
|
5232
5222
|
const dragElementRef = (0, import_react20.useRef)(null);
|
|
5233
5223
|
const [mousePosition, setMousePosition] = (0, import_react20.useState)({
|
|
@@ -5240,18 +5230,16 @@ var GroupingActivityMaterialContent = ({
|
|
|
5240
5230
|
});
|
|
5241
5231
|
const ref = (0, import_react20.useRef)(null);
|
|
5242
5232
|
const dropZoneRefs = (0, import_react20.useRef)({});
|
|
5233
|
+
const hasShuffledRef = (0, import_react20.useRef)(false);
|
|
5243
5234
|
(0, import_react20.useEffect)(() => {
|
|
5235
|
+
if (hasShuffledRef.current) return;
|
|
5244
5236
|
const shuffleArray2 = (array) => {
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
[copyArray[i], copyArray[j]] = [copyArray[j], copyArray[i]];
|
|
5250
|
-
}
|
|
5251
|
-
setIsShuffled(true);
|
|
5252
|
-
return copyArray;
|
|
5237
|
+
const copyArray = JSON.parse(JSON.stringify(array));
|
|
5238
|
+
for (let i = copyArray.length - 1; i > 0; i--) {
|
|
5239
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
5240
|
+
[copyArray[i], copyArray[j]] = [copyArray[j], copyArray[i]];
|
|
5253
5241
|
}
|
|
5254
|
-
return
|
|
5242
|
+
return copyArray;
|
|
5255
5243
|
};
|
|
5256
5244
|
const materialList = [];
|
|
5257
5245
|
Object.keys(materialMap).forEach((materialKey) => {
|
|
@@ -5260,7 +5248,8 @@ var GroupingActivityMaterialContent = ({
|
|
|
5260
5248
|
}
|
|
5261
5249
|
});
|
|
5262
5250
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
5263
|
-
|
|
5251
|
+
hasShuffledRef.current = true;
|
|
5252
|
+
}, [materialMap]);
|
|
5264
5253
|
(0, import_react20.useEffect)(() => {
|
|
5265
5254
|
if (!showCorrectAnswer) return;
|
|
5266
5255
|
answerMap = materialMap;
|
|
@@ -6825,8 +6814,7 @@ var OrderingActivityContent = ({
|
|
|
6825
6814
|
canAnswerQuestion,
|
|
6826
6815
|
changeAnswer,
|
|
6827
6816
|
isPreview,
|
|
6828
|
-
showCorrectAnswer
|
|
6829
|
-
isFullScreen
|
|
6817
|
+
showCorrectAnswer
|
|
6830
6818
|
}) => {
|
|
6831
6819
|
const contentMap = parseContentMapFromData(data);
|
|
6832
6820
|
const orderingBodyMap = parseBodyMapFromData(data, "ORDERING");
|
|
@@ -7272,7 +7260,8 @@ var ActivityPreviewByData = ({
|
|
|
7272
7260
|
}
|
|
7273
7261
|
}, [data, lockedType, typeOptionList, showDifficulty]);
|
|
7274
7262
|
if (!data) return;
|
|
7275
|
-
|
|
7263
|
+
if (!selectedType) return;
|
|
7264
|
+
const answerMap = constructAnswerBasedOnData(selectedType, data);
|
|
7276
7265
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { children: [
|
|
7277
7266
|
showType ? /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_jsx_runtime47.Fragment, { children: [
|
|
7278
7267
|
/* @__PURE__ */ (0, import_jsx_runtime47.jsxs)("div", { className: "mb-4", children: [
|
|
@@ -7301,8 +7290,7 @@ var ActivityPreviewByData = ({
|
|
|
7301
7290
|
},
|
|
7302
7291
|
data,
|
|
7303
7292
|
isPreview: true,
|
|
7304
|
-
showCorrectAnswer: true
|
|
7305
|
-
isFullScreen
|
|
7293
|
+
showCorrectAnswer: true
|
|
7306
7294
|
}
|
|
7307
7295
|
) : selectedType === "DROPDOWN" && data["dropdownBodyMap"] != null && data["dropdownMaterialMap"] != null ? /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
7308
7296
|
DropdownActivityContent_default,
|
package/dist/index.mjs
CHANGED
|
@@ -2074,7 +2074,19 @@ var retrieveActivityTemplateDTOOptionList = (activityTemplateSet) => {
|
|
|
2074
2074
|
};
|
|
2075
2075
|
var retrieveDefaultOrderingDataMap = (orderingMaterialMap) => {
|
|
2076
2076
|
const dataMap = {};
|
|
2077
|
-
Object.keys(orderingMaterialMap)
|
|
2077
|
+
const originalKeys = Object.keys(orderingMaterialMap);
|
|
2078
|
+
const shuffledKeys = [...originalKeys];
|
|
2079
|
+
for (let i = shuffledKeys.length - 1; i > 0; i--) {
|
|
2080
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
2081
|
+
[shuffledKeys[i], shuffledKeys[j]] = [shuffledKeys[j], shuffledKeys[i]];
|
|
2082
|
+
}
|
|
2083
|
+
const isSameOrder = shuffledKeys.every(
|
|
2084
|
+
(key, index) => key === originalKeys[index]
|
|
2085
|
+
);
|
|
2086
|
+
if (isSameOrder && shuffledKeys.length >= 2) {
|
|
2087
|
+
[shuffledKeys[0], shuffledKeys[1]] = [shuffledKeys[1], shuffledKeys[0]];
|
|
2088
|
+
}
|
|
2089
|
+
shuffledKeys.forEach((key, index) => {
|
|
2078
2090
|
dataMap[index] = key;
|
|
2079
2091
|
});
|
|
2080
2092
|
return dataMap;
|
|
@@ -2743,56 +2755,35 @@ var constructActivityData = (activityTemplateType, contentMap, bodyMap, material
|
|
|
2743
2755
|
}
|
|
2744
2756
|
return constructedData;
|
|
2745
2757
|
};
|
|
2746
|
-
var constructAnswerBasedOnData = (data) => {
|
|
2747
|
-
if (Object.keys(data).find((dataKey) => dataKey === "orderingMaterialMap")) {
|
|
2748
|
-
return constructActivityAnswerMap(
|
|
2749
|
-
"ORDERING",
|
|
2750
|
-
JSON.parse(JSON.stringify(data))
|
|
2751
|
-
);
|
|
2758
|
+
var constructAnswerBasedOnData = (type, data) => {
|
|
2759
|
+
if (type === "ORDERING" && Object.keys(data).find((dataKey) => dataKey === "orderingMaterialMap")) {
|
|
2760
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2752
2761
|
}
|
|
2753
|
-
if (Object.keys(data).find((dataKey) => dataKey === "dropdownMaterialMap")) {
|
|
2754
|
-
return constructActivityAnswerMap(
|
|
2755
|
-
"DROPDOWN",
|
|
2756
|
-
JSON.parse(JSON.stringify(data))
|
|
2757
|
-
);
|
|
2762
|
+
if (type === "DROPDOWN" && Object.keys(data).find((dataKey) => dataKey === "dropdownMaterialMap")) {
|
|
2763
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2758
2764
|
}
|
|
2759
|
-
if (Object.keys(data).find((dataKey) => dataKey === "MCSAMaterialMap")) {
|
|
2760
|
-
return constructActivityAnswerMap(
|
|
2765
|
+
if (type === "MCSA" && Object.keys(data).find((dataKey) => dataKey === "MCSAMaterialMap")) {
|
|
2766
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2761
2767
|
}
|
|
2762
|
-
if (Object.keys(data).find((dataKey) => dataKey === "MCMAMaterialMap")) {
|
|
2763
|
-
return constructActivityAnswerMap(
|
|
2768
|
+
if (type === "MCMA" && Object.keys(data).find((dataKey) => dataKey === "MCMAMaterialMap")) {
|
|
2769
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2764
2770
|
}
|
|
2765
|
-
if (Object.keys(data).find((dataKey) => dataKey === "matchingMaterialMap")) {
|
|
2766
|
-
return constructActivityAnswerMap(
|
|
2767
|
-
"MATCHING",
|
|
2768
|
-
JSON.parse(JSON.stringify(data))
|
|
2769
|
-
);
|
|
2771
|
+
if (type === "MATCHING" && Object.keys(data).find((dataKey) => dataKey === "matchingMaterialMap")) {
|
|
2772
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2770
2773
|
}
|
|
2771
|
-
if (Object.keys(data).find((dataKey) => dataKey === "groupingMaterialMap")) {
|
|
2772
|
-
return constructActivityAnswerMap(
|
|
2773
|
-
"GROUPING",
|
|
2774
|
-
JSON.parse(JSON.stringify(data))
|
|
2775
|
-
);
|
|
2774
|
+
if (type === "GROUPING" && Object.keys(data).find((dataKey) => dataKey === "groupingMaterialMap")) {
|
|
2775
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2776
2776
|
}
|
|
2777
|
-
if (Object.keys(data).find(
|
|
2777
|
+
if (type === "FILL_IN_THE_BLANKS" && Object.keys(data).find(
|
|
2778
2778
|
(dataKey) => dataKey === "fillInTheBlanksMaterialMap"
|
|
2779
2779
|
)) {
|
|
2780
|
-
return constructActivityAnswerMap(
|
|
2781
|
-
"FILL_IN_THE_BLANKS",
|
|
2782
|
-
JSON.parse(JSON.stringify(data))
|
|
2783
|
-
);
|
|
2780
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2784
2781
|
}
|
|
2785
|
-
if (Object.keys(data).find((dataKey) => dataKey === "openEndedMaterialMap")) {
|
|
2786
|
-
return constructActivityAnswerMap(
|
|
2787
|
-
"OPEN_ENDED",
|
|
2788
|
-
JSON.parse(JSON.stringify(data))
|
|
2789
|
-
);
|
|
2782
|
+
if (type === "OPEN_ENDED" && Object.keys(data).find((dataKey) => dataKey === "openEndedMaterialMap")) {
|
|
2783
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2790
2784
|
}
|
|
2791
|
-
if (Object.keys(data).find((dataKey) => dataKey === "trueFalseMaterialMap")) {
|
|
2792
|
-
return constructActivityAnswerMap(
|
|
2793
|
-
"TRUE_FALSE",
|
|
2794
|
-
JSON.parse(JSON.stringify(data))
|
|
2795
|
-
);
|
|
2785
|
+
if (type === "TRUE_FALSE" && Object.keys(data).find((dataKey) => dataKey === "trueFalseMaterialMap")) {
|
|
2786
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
2796
2787
|
}
|
|
2797
2788
|
return {};
|
|
2798
2789
|
};
|
|
@@ -5003,7 +4994,6 @@ var GroupingActivityMaterialContent = ({
|
|
|
5003
4994
|
const [draggedElement, setDraggedElement] = useState19(
|
|
5004
4995
|
null
|
|
5005
4996
|
);
|
|
5006
|
-
const [isShuffled, setIsShuffled] = useState19(false);
|
|
5007
4997
|
const [shuffledMaterialList, setShuffledMaterialList] = useState19([]);
|
|
5008
4998
|
const dragElementRef = useRef5(null);
|
|
5009
4999
|
const [mousePosition, setMousePosition] = useState19({
|
|
@@ -5016,18 +5006,16 @@ var GroupingActivityMaterialContent = ({
|
|
|
5016
5006
|
});
|
|
5017
5007
|
const ref = useRef5(null);
|
|
5018
5008
|
const dropZoneRefs = useRef5({});
|
|
5009
|
+
const hasShuffledRef = useRef5(false);
|
|
5019
5010
|
useEffect10(() => {
|
|
5011
|
+
if (hasShuffledRef.current) return;
|
|
5020
5012
|
const shuffleArray2 = (array) => {
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
[copyArray[i], copyArray[j]] = [copyArray[j], copyArray[i]];
|
|
5026
|
-
}
|
|
5027
|
-
setIsShuffled(true);
|
|
5028
|
-
return copyArray;
|
|
5013
|
+
const copyArray = JSON.parse(JSON.stringify(array));
|
|
5014
|
+
for (let i = copyArray.length - 1; i > 0; i--) {
|
|
5015
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
5016
|
+
[copyArray[i], copyArray[j]] = [copyArray[j], copyArray[i]];
|
|
5029
5017
|
}
|
|
5030
|
-
return
|
|
5018
|
+
return copyArray;
|
|
5031
5019
|
};
|
|
5032
5020
|
const materialList = [];
|
|
5033
5021
|
Object.keys(materialMap).forEach((materialKey) => {
|
|
@@ -5036,7 +5024,8 @@ var GroupingActivityMaterialContent = ({
|
|
|
5036
5024
|
}
|
|
5037
5025
|
});
|
|
5038
5026
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
5039
|
-
|
|
5027
|
+
hasShuffledRef.current = true;
|
|
5028
|
+
}, [materialMap]);
|
|
5040
5029
|
useEffect10(() => {
|
|
5041
5030
|
if (!showCorrectAnswer) return;
|
|
5042
5031
|
answerMap = materialMap;
|
|
@@ -6601,8 +6590,7 @@ var OrderingActivityContent = ({
|
|
|
6601
6590
|
canAnswerQuestion,
|
|
6602
6591
|
changeAnswer,
|
|
6603
6592
|
isPreview,
|
|
6604
|
-
showCorrectAnswer
|
|
6605
|
-
isFullScreen
|
|
6593
|
+
showCorrectAnswer
|
|
6606
6594
|
}) => {
|
|
6607
6595
|
const contentMap = parseContentMapFromData(data);
|
|
6608
6596
|
const orderingBodyMap = parseBodyMapFromData(data, "ORDERING");
|
|
@@ -7048,7 +7036,8 @@ var ActivityPreviewByData = ({
|
|
|
7048
7036
|
}
|
|
7049
7037
|
}, [data, lockedType, typeOptionList, showDifficulty]);
|
|
7050
7038
|
if (!data) return;
|
|
7051
|
-
|
|
7039
|
+
if (!selectedType) return;
|
|
7040
|
+
const answerMap = constructAnswerBasedOnData(selectedType, data);
|
|
7052
7041
|
return /* @__PURE__ */ jsxs36("div", { children: [
|
|
7053
7042
|
showType ? /* @__PURE__ */ jsxs36(Fragment11, { children: [
|
|
7054
7043
|
/* @__PURE__ */ jsxs36("div", { className: "mb-4", children: [
|
|
@@ -7077,8 +7066,7 @@ var ActivityPreviewByData = ({
|
|
|
7077
7066
|
},
|
|
7078
7067
|
data,
|
|
7079
7068
|
isPreview: true,
|
|
7080
|
-
showCorrectAnswer: true
|
|
7081
|
-
isFullScreen
|
|
7069
|
+
showCorrectAnswer: true
|
|
7082
7070
|
}
|
|
7083
7071
|
) : selectedType === "DROPDOWN" && data["dropdownBodyMap"] != null && data["dropdownMaterialMap"] != null ? /* @__PURE__ */ jsx47(
|
|
7084
7072
|
DropdownActivityContent_default,
|
package/package.json
CHANGED
|
@@ -80,7 +80,8 @@ const ActivityPreviewByData = ({
|
|
|
80
80
|
}, [data, lockedType, typeOptionList, showDifficulty]);
|
|
81
81
|
|
|
82
82
|
if (!data) return;
|
|
83
|
-
|
|
83
|
+
if (!selectedType) return;
|
|
84
|
+
const answerMap = constructAnswerBasedOnData(selectedType, data);
|
|
84
85
|
|
|
85
86
|
return (
|
|
86
87
|
<div key={key}>
|
|
@@ -120,7 +121,6 @@ const ActivityPreviewByData = ({
|
|
|
120
121
|
data={data}
|
|
121
122
|
isPreview={true}
|
|
122
123
|
showCorrectAnswer={true}
|
|
123
|
-
isFullScreen={isFullScreen}
|
|
124
124
|
/>
|
|
125
125
|
) : selectedType === "DROPDOWN" &&
|
|
126
126
|
data["dropdownBodyMap"] != null &&
|
|
@@ -21,7 +21,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
21
21
|
const [draggedElement, setDraggedElement] = useState<HTMLElement | null>(
|
|
22
22
|
null
|
|
23
23
|
);
|
|
24
|
-
const [isShuffled, setIsShuffled] = useState(false);
|
|
25
24
|
const [shuffledMaterialList, setShuffledMaterialList] = useState<any[]>([]);
|
|
26
25
|
const dragElementRef = useRef<HTMLDivElement>(null);
|
|
27
26
|
const [mousePosition, setMousePosition] = useState<{ x: number; y: number }>({
|
|
@@ -34,28 +33,30 @@ const GroupingActivityMaterialContent = ({
|
|
|
34
33
|
});
|
|
35
34
|
const ref = useRef<HTMLDivElement>(null);
|
|
36
35
|
const dropZoneRefs = useRef<{ [key: string]: HTMLDivElement | null }>({});
|
|
36
|
+
const hasShuffledRef = useRef<boolean>(false);
|
|
37
37
|
|
|
38
38
|
useEffect(() => {
|
|
39
|
+
if (hasShuffledRef.current) return;
|
|
40
|
+
|
|
39
41
|
const shuffleArray = (array: any) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
[copyArray[i], copyArray[j]] = [copyArray[j], copyArray[i]];
|
|
45
|
-
}
|
|
46
|
-
setIsShuffled(true);
|
|
47
|
-
return copyArray;
|
|
42
|
+
const copyArray = JSON.parse(JSON.stringify(array));
|
|
43
|
+
for (let i = copyArray.length - 1; i > 0; i--) {
|
|
44
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
45
|
+
[copyArray[i], copyArray[j]] = [copyArray[j], copyArray[i]];
|
|
48
46
|
}
|
|
49
|
-
return
|
|
47
|
+
return copyArray;
|
|
50
48
|
};
|
|
49
|
+
|
|
51
50
|
const materialList: any = [];
|
|
52
51
|
Object.keys(materialMap).forEach((materialKey) => {
|
|
53
52
|
for (const materialValue of materialMap[materialKey]) {
|
|
54
53
|
materialList.push(materialValue);
|
|
55
54
|
}
|
|
56
55
|
});
|
|
56
|
+
|
|
57
57
|
setShuffledMaterialList(shuffleArray(materialList));
|
|
58
|
-
|
|
58
|
+
hasShuffledRef.current = true;
|
|
59
|
+
}, [materialMap]);
|
|
59
60
|
|
|
60
61
|
useEffect(() => {
|
|
61
62
|
if (!showCorrectAnswer) return;
|
|
@@ -68,7 +69,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
68
69
|
const dropZoneElement = dropZoneRefs.current[dropTargetKey];
|
|
69
70
|
if (!dropZoneElement) return;
|
|
70
71
|
|
|
71
|
-
// Find the scrollable parent container
|
|
72
72
|
const findScrollableParent = (element: HTMLElement): HTMLElement | null => {
|
|
73
73
|
let parent = element.parentElement;
|
|
74
74
|
|
|
@@ -155,7 +155,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
155
155
|
return "INCORRECT";
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
// Mouse drag handlers
|
|
159
158
|
const handleMouseDown = (
|
|
160
159
|
e: React.MouseEvent,
|
|
161
160
|
materialValue: string
|
|
@@ -172,7 +171,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
172
171
|
|
|
173
172
|
setMousePosition({ x: e.clientX, y: e.clientY });
|
|
174
173
|
|
|
175
|
-
// Find the element under the mouse point
|
|
176
174
|
const elementUnder = document.elementFromPoint(e.clientX, e.clientY);
|
|
177
175
|
const dropZone = elementUnder?.closest("[data-grouping-drop-zone]");
|
|
178
176
|
|
|
@@ -193,7 +191,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
193
191
|
setMousePosition({ x: 0, y: 0 });
|
|
194
192
|
};
|
|
195
193
|
|
|
196
|
-
// Touch drag handlers
|
|
197
194
|
const handleTouchStart = (
|
|
198
195
|
e: React.TouchEvent,
|
|
199
196
|
materialValue: string,
|
|
@@ -213,7 +210,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
213
210
|
const touch = e.touches[0];
|
|
214
211
|
setTouchPosition({ x: touch.clientX, y: touch.clientY });
|
|
215
212
|
|
|
216
|
-
// Find the element under the touch point
|
|
217
213
|
const elementUnder = document.elementFromPoint(
|
|
218
214
|
touch.clientX,
|
|
219
215
|
touch.clientY
|
|
@@ -238,7 +234,6 @@ const GroupingActivityMaterialContent = ({
|
|
|
238
234
|
setTouchPosition({ x: 0, y: 0 });
|
|
239
235
|
};
|
|
240
236
|
|
|
241
|
-
// Click/tap to select (for easier mobile interaction)
|
|
242
237
|
const handleSelectItem = (materialValue: string): void => {
|
|
243
238
|
if (!checkCanAnswerQuestion()) return;
|
|
244
239
|
setSelectedValue(materialValue);
|
|
@@ -78,7 +78,6 @@ const OrderingActivityMaterialContent = ({
|
|
|
78
78
|
return 0;
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
// Mouse drag handlers
|
|
82
81
|
const handleMouseDown = (e: React.MouseEvent, materialKey: string): void => {
|
|
83
82
|
if (!checkCanAnswerQuestion()) return;
|
|
84
83
|
e.preventDefault();
|
|
@@ -117,7 +116,6 @@ const OrderingActivityMaterialContent = ({
|
|
|
117
116
|
setMousePosition({ x: 0, y: 0 });
|
|
118
117
|
};
|
|
119
118
|
|
|
120
|
-
// Touch drag handlers
|
|
121
119
|
const handleTouchStart = (
|
|
122
120
|
e: React.TouchEvent,
|
|
123
121
|
materialKey: string,
|
|
@@ -166,7 +164,6 @@ const OrderingActivityMaterialContent = ({
|
|
|
166
164
|
setTouchPosition({ x: 0, y: 0 });
|
|
167
165
|
};
|
|
168
166
|
|
|
169
|
-
// Click/tap to select (for easier mobile interaction)
|
|
170
167
|
const handleSelectItem = (materialKey: string): void => {
|
|
171
168
|
if (!checkCanAnswerQuestion()) return;
|
|
172
169
|
|
|
@@ -187,7 +184,6 @@ const OrderingActivityMaterialContent = ({
|
|
|
187
184
|
onMouseMove={handleMouseMove}
|
|
188
185
|
onMouseUp={handleMouseUp}
|
|
189
186
|
>
|
|
190
|
-
{/* Floating drag preview for mouse */}
|
|
191
187
|
{draggedKey && mousePosition.x > 0 && (
|
|
192
188
|
<div
|
|
193
189
|
className="fixed pointer-events-none z-50 opacity-80"
|
|
@@ -233,7 +229,6 @@ const OrderingActivityMaterialContent = ({
|
|
|
233
229
|
</div>
|
|
234
230
|
)}
|
|
235
231
|
|
|
236
|
-
{/* Floating drag preview for touch */}
|
|
237
232
|
{draggedKey && touchPosition.x > 0 && (
|
|
238
233
|
<div
|
|
239
234
|
className="fixed pointer-events-none z-50 opacity-80"
|
|
@@ -1112,11 +1112,25 @@ export const retrieveActivityTemplateDTOOptionList = (
|
|
|
1112
1112
|
|
|
1113
1113
|
const retrieveDefaultOrderingDataMap = (orderingMaterialMap: any) => {
|
|
1114
1114
|
const dataMap: any = {};
|
|
1115
|
-
Object.keys(orderingMaterialMap)
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1115
|
+
const originalKeys = Object.keys(orderingMaterialMap);
|
|
1116
|
+
const shuffledKeys = [...originalKeys];
|
|
1117
|
+
|
|
1118
|
+
for (let i = shuffledKeys.length - 1; i > 0; i--) {
|
|
1119
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
1120
|
+
[shuffledKeys[i], shuffledKeys[j]] = [shuffledKeys[j], shuffledKeys[i]];
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
const isSameOrder = shuffledKeys.every(
|
|
1124
|
+
(key, index) => key === originalKeys[index]
|
|
1125
|
+
);
|
|
1126
|
+
|
|
1127
|
+
if (isSameOrder && shuffledKeys.length >= 2) {
|
|
1128
|
+
[shuffledKeys[0], shuffledKeys[1]] = [shuffledKeys[1], shuffledKeys[0]];
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
shuffledKeys.forEach((key, index) => {
|
|
1132
|
+
dataMap[index] = key;
|
|
1133
|
+
});
|
|
1120
1134
|
|
|
1121
1135
|
return dataMap;
|
|
1122
1136
|
};
|
|
@@ -1914,58 +1928,62 @@ export const constructActivityData = (
|
|
|
1914
1928
|
return constructedData;
|
|
1915
1929
|
};
|
|
1916
1930
|
|
|
1917
|
-
export const constructAnswerBasedOnData = (data: any) => {
|
|
1918
|
-
if (
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
);
|
|
1931
|
+
export const constructAnswerBasedOnData = (type: string, data: any) => {
|
|
1932
|
+
if (
|
|
1933
|
+
type === "ORDERING" &&
|
|
1934
|
+
Object.keys(data).find((dataKey) => dataKey === "orderingMaterialMap")
|
|
1935
|
+
) {
|
|
1936
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1923
1937
|
}
|
|
1924
|
-
if (
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
);
|
|
1938
|
+
if (
|
|
1939
|
+
type === "DROPDOWN" &&
|
|
1940
|
+
Object.keys(data).find((dataKey) => dataKey === "dropdownMaterialMap")
|
|
1941
|
+
) {
|
|
1942
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1929
1943
|
}
|
|
1930
|
-
if (
|
|
1931
|
-
|
|
1944
|
+
if (
|
|
1945
|
+
type === "MCSA" &&
|
|
1946
|
+
Object.keys(data).find((dataKey) => dataKey === "MCSAMaterialMap")
|
|
1947
|
+
) {
|
|
1948
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1932
1949
|
}
|
|
1933
|
-
if (
|
|
1934
|
-
|
|
1950
|
+
if (
|
|
1951
|
+
type === "MCMA" &&
|
|
1952
|
+
Object.keys(data).find((dataKey) => dataKey === "MCMAMaterialMap")
|
|
1953
|
+
) {
|
|
1954
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1935
1955
|
}
|
|
1936
|
-
if (
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
);
|
|
1956
|
+
if (
|
|
1957
|
+
type === "MATCHING" &&
|
|
1958
|
+
Object.keys(data).find((dataKey) => dataKey === "matchingMaterialMap")
|
|
1959
|
+
) {
|
|
1960
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1941
1961
|
}
|
|
1942
|
-
if (
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
);
|
|
1962
|
+
if (
|
|
1963
|
+
type === "GROUPING" &&
|
|
1964
|
+
Object.keys(data).find((dataKey) => dataKey === "groupingMaterialMap")
|
|
1965
|
+
) {
|
|
1966
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1947
1967
|
}
|
|
1948
1968
|
if (
|
|
1969
|
+
type === "FILL_IN_THE_BLANKS" &&
|
|
1949
1970
|
Object.keys(data).find(
|
|
1950
1971
|
(dataKey) => dataKey === "fillInTheBlanksMaterialMap"
|
|
1951
1972
|
)
|
|
1952
1973
|
) {
|
|
1953
|
-
return constructActivityAnswerMap(
|
|
1954
|
-
"FILL_IN_THE_BLANKS",
|
|
1955
|
-
JSON.parse(JSON.stringify(data))
|
|
1956
|
-
);
|
|
1974
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1957
1975
|
}
|
|
1958
|
-
if (
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
);
|
|
1976
|
+
if (
|
|
1977
|
+
type === "OPEN_ENDED" &&
|
|
1978
|
+
Object.keys(data).find((dataKey) => dataKey === "openEndedMaterialMap")
|
|
1979
|
+
) {
|
|
1980
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1963
1981
|
}
|
|
1964
|
-
if (
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
);
|
|
1982
|
+
if (
|
|
1983
|
+
type === "TRUE_FALSE" &&
|
|
1984
|
+
Object.keys(data).find((dataKey) => dataKey === "trueFalseMaterialMap")
|
|
1985
|
+
) {
|
|
1986
|
+
return constructActivityAnswerMap(type, JSON.parse(JSON.stringify(data)));
|
|
1969
1987
|
}
|
|
1970
1988
|
return {};
|
|
1971
1989
|
};
|