catchup-library-web 1.10.2 → 1.10.4
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 +110 -77
- package/dist/index.mjs +104 -71
- package/package.json +1 -1
- package/src/components/activities/DropdownActivityContent.tsx +39 -7
- package/src/components/activities/FillInTheBlanksActivityContent.tsx +39 -7
- package/src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx +5 -31
- package/src/components/activities/material-content/GroupingActivityMaterialContent.tsx +1 -1
package/dist/index.js
CHANGED
|
@@ -4302,6 +4302,7 @@ var DropdownActivityMaterialContent = ({
|
|
|
4302
4302
|
var DropdownActivityMaterialContent_default = DropdownActivityMaterialContent;
|
|
4303
4303
|
|
|
4304
4304
|
// src/components/activities/DropdownActivityContent.tsx
|
|
4305
|
+
var import_react15 = require("react");
|
|
4305
4306
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4306
4307
|
var DropdownActivityContent = ({
|
|
4307
4308
|
answer,
|
|
@@ -4315,23 +4316,41 @@ var DropdownActivityContent = ({
|
|
|
4315
4316
|
const contentMap = parseContentMapFromData(data);
|
|
4316
4317
|
const dropdownBodyMap = parseBodyMapFromData(data, "DROPDOWN");
|
|
4317
4318
|
const dropdownMaterialMap = parseMaterialMapFromData(data, "DROPDOWN");
|
|
4318
|
-
const
|
|
4319
|
+
const [currentAnswerMap, setCurrentAnswerMap] = (0, import_react15.useState)(() => {
|
|
4320
|
+
return retrieveCurrentAnswerMap();
|
|
4321
|
+
});
|
|
4322
|
+
function retrieveCurrentAnswerMap() {
|
|
4319
4323
|
let foundIndex = answer.data.findIndex(
|
|
4320
4324
|
(answerData) => answerData.type === "DROPDOWN"
|
|
4321
4325
|
);
|
|
4322
4326
|
return answer.data[foundIndex].answerMap;
|
|
4323
|
-
}
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4327
|
+
}
|
|
4328
|
+
(0, import_react15.useEffect)(() => {
|
|
4329
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
4330
|
+
}, [answer]);
|
|
4331
|
+
const handleDropdownAnswerOnChange = (answerObj, key, value) => {
|
|
4332
|
+
const newAnswer = __spreadProps(__spreadValues({}, answerObj), {
|
|
4333
|
+
data: answerObj.data.map((item) => {
|
|
4334
|
+
if (item.type === "DROPDOWN") {
|
|
4335
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
4336
|
+
answerMap: __spreadProps(__spreadValues({}, item.answerMap), {
|
|
4337
|
+
[key]: value
|
|
4338
|
+
})
|
|
4339
|
+
});
|
|
4340
|
+
}
|
|
4341
|
+
return item;
|
|
4342
|
+
})
|
|
4343
|
+
});
|
|
4344
|
+
const newAnswerMap = __spreadProps(__spreadValues({}, currentAnswerMap), { [key]: value });
|
|
4345
|
+
setCurrentAnswerMap(newAnswerMap);
|
|
4346
|
+
changeAnswer(newAnswer);
|
|
4328
4347
|
};
|
|
4329
4348
|
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-row flex-wrap", children: [
|
|
4330
4349
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: `${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
4331
4350
|
ActivityBodyContent_default,
|
|
4332
4351
|
{
|
|
4333
4352
|
bodyMap: dropdownBodyMap,
|
|
4334
|
-
answerMap:
|
|
4353
|
+
answerMap: currentAnswerMap,
|
|
4335
4354
|
contentMap,
|
|
4336
4355
|
templateType: "DROPDOWN"
|
|
4337
4356
|
}
|
|
@@ -4357,8 +4376,8 @@ var DropdownActivityContent_default = DropdownActivityContent;
|
|
|
4357
4376
|
|
|
4358
4377
|
// src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx
|
|
4359
4378
|
var import_react_katex3 = require("react-katex");
|
|
4360
|
-
var import_react16 = require("react");
|
|
4361
4379
|
var import_react17 = require("react");
|
|
4380
|
+
var import_react18 = require("react");
|
|
4362
4381
|
var import_react_dnd3 = require("react-dnd");
|
|
4363
4382
|
|
|
4364
4383
|
// src/components/dnds/DraggableItem.tsx
|
|
@@ -4397,7 +4416,7 @@ var DraggableItem = ({
|
|
|
4397
4416
|
var DraggableItem_default = DraggableItem;
|
|
4398
4417
|
|
|
4399
4418
|
// src/components/dnds/DroppableItem.tsx
|
|
4400
|
-
var
|
|
4419
|
+
var import_react16 = require("react");
|
|
4401
4420
|
var import_react_dnd2 = require("react-dnd");
|
|
4402
4421
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
4403
4422
|
var DroppableItem = ({
|
|
@@ -4409,7 +4428,7 @@ var DroppableItem = ({
|
|
|
4409
4428
|
target,
|
|
4410
4429
|
setTarget
|
|
4411
4430
|
}) => {
|
|
4412
|
-
const ref = (0,
|
|
4431
|
+
const ref = (0, import_react16.useRef)(null);
|
|
4413
4432
|
const [, drop] = (0, import_react_dnd2.useDrop)({
|
|
4414
4433
|
accept: type,
|
|
4415
4434
|
hover() {
|
|
@@ -4444,9 +4463,9 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4444
4463
|
isPreview,
|
|
4445
4464
|
showCorrectAnswer
|
|
4446
4465
|
}) => {
|
|
4447
|
-
const [shuffleOptionList, setShuffleOptionList] = (0,
|
|
4448
|
-
const [selectedOption, setSelectedOption] = (0,
|
|
4449
|
-
const [pasteOptionIndex, setPasteOptionIndex] = (0,
|
|
4466
|
+
const [shuffleOptionList, setShuffleOptionList] = (0, import_react17.useState)([]);
|
|
4467
|
+
const [selectedOption, setSelectedOption] = (0, import_react17.useState)(null);
|
|
4468
|
+
const [pasteOptionIndex, setPasteOptionIndex] = (0, import_react17.useState)(null);
|
|
4450
4469
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd3.useDrop)({
|
|
4451
4470
|
accept: "FILL_IN_THE_BLANKS",
|
|
4452
4471
|
drop: () => {
|
|
@@ -4456,26 +4475,21 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4456
4475
|
canDrop: monitor.canDrop()
|
|
4457
4476
|
})
|
|
4458
4477
|
});
|
|
4459
|
-
(0,
|
|
4478
|
+
(0, import_react18.useEffect)(() => {
|
|
4460
4479
|
setShuffleOptionList(shuffleArray(optionList));
|
|
4461
4480
|
}, []);
|
|
4462
|
-
(0,
|
|
4481
|
+
(0, import_react18.useEffect)(() => {
|
|
4463
4482
|
if (!showCorrectAnswer) return;
|
|
4464
4483
|
const foundAnswer = answer.data.find(
|
|
4465
4484
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4466
4485
|
);
|
|
4467
|
-
if (!foundAnswer) return;
|
|
4468
4486
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4469
4487
|
if (Object.keys(materialMap).length === 0) return;
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
if (Object.keys(materialMap).length > 0) {
|
|
4476
|
-
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
4477
|
-
}
|
|
4478
|
-
}, [showCorrectAnswer, answer, materialMap, onChange]);
|
|
4488
|
+
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
4489
|
+
(materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
|
|
4490
|
+
);
|
|
4491
|
+
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
4492
|
+
}, [showCorrectAnswer]);
|
|
4479
4493
|
const retrieveAnswerMap = () => {
|
|
4480
4494
|
const foundIndex = answer.data.findIndex(
|
|
4481
4495
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
@@ -4642,6 +4656,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4642
4656
|
var FillInTheBlanksActivityMaterialContent_default = FillInTheBlanksActivityMaterialContent;
|
|
4643
4657
|
|
|
4644
4658
|
// src/components/activities/FillInTheBlanksActivityContent.tsx
|
|
4659
|
+
var import_react19 = require("react");
|
|
4645
4660
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4646
4661
|
var FillInTheBlanksActivityContent = ({
|
|
4647
4662
|
answer,
|
|
@@ -4662,12 +4677,18 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4662
4677
|
"FILL_IN_THE_BLANKS"
|
|
4663
4678
|
);
|
|
4664
4679
|
const fillInTheBlanksIncorrectList = data.fillInTheBlanksIncorrectList ? JSON.parse(data.fillInTheBlanksIncorrectList) : [];
|
|
4665
|
-
const
|
|
4680
|
+
const [currentAnswerMap, setCurrentAnswerMap] = (0, import_react19.useState)(() => {
|
|
4681
|
+
return retrieveCurrentAnswerMap();
|
|
4682
|
+
});
|
|
4683
|
+
function retrieveCurrentAnswerMap() {
|
|
4666
4684
|
let foundIndex = answer.data.findIndex(
|
|
4667
4685
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4668
4686
|
);
|
|
4669
4687
|
return answer.data[foundIndex].answerMap;
|
|
4670
|
-
}
|
|
4688
|
+
}
|
|
4689
|
+
(0, import_react19.useEffect)(() => {
|
|
4690
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
4691
|
+
}, [answer]);
|
|
4671
4692
|
const constructAnswerOptionList = () => {
|
|
4672
4693
|
const optionList = [];
|
|
4673
4694
|
Object.keys(fillInTheBlanksMaterialMap).forEach((key) => {
|
|
@@ -4686,17 +4707,29 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4686
4707
|
});
|
|
4687
4708
|
return optionList;
|
|
4688
4709
|
};
|
|
4689
|
-
const handleFillInTheBlanksAnswerOnChange = (
|
|
4690
|
-
const
|
|
4691
|
-
|
|
4692
|
-
|
|
4710
|
+
const handleFillInTheBlanksAnswerOnChange = (answerObj, key, value) => {
|
|
4711
|
+
const newAnswer = __spreadProps(__spreadValues({}, answerObj), {
|
|
4712
|
+
data: answerObj.data.map((item) => {
|
|
4713
|
+
if (item.type === "FILL_IN_THE_BLANKS") {
|
|
4714
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
4715
|
+
answerMap: __spreadProps(__spreadValues({}, item.answerMap), {
|
|
4716
|
+
[key]: value
|
|
4717
|
+
})
|
|
4718
|
+
});
|
|
4719
|
+
}
|
|
4720
|
+
return item;
|
|
4721
|
+
})
|
|
4722
|
+
});
|
|
4723
|
+
const newAnswerMap = __spreadProps(__spreadValues({}, currentAnswerMap), { [key]: value });
|
|
4724
|
+
setCurrentAnswerMap(newAnswerMap);
|
|
4725
|
+
changeAnswer(newAnswer);
|
|
4693
4726
|
};
|
|
4694
4727
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-row flex-wrap", children: [
|
|
4695
4728
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4696
4729
|
ActivityBodyContent_default,
|
|
4697
4730
|
{
|
|
4698
4731
|
bodyMap: fillInTheBlanksBodyMap,
|
|
4699
|
-
answerMap:
|
|
4732
|
+
answerMap: currentAnswerMap,
|
|
4700
4733
|
contentMap,
|
|
4701
4734
|
templateType: "FILL_IN_THE_BLANKS"
|
|
4702
4735
|
}
|
|
@@ -4722,22 +4755,22 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4722
4755
|
var FillInTheBlanksActivityContent_default = FillInTheBlanksActivityContent;
|
|
4723
4756
|
|
|
4724
4757
|
// src/components/activities/material-content/GroupingActivityMaterialContent.tsx
|
|
4725
|
-
var
|
|
4758
|
+
var import_react21 = require("react");
|
|
4726
4759
|
var import_react_dnd4 = require("react-dnd");
|
|
4727
4760
|
var import_react_katex4 = require("react-katex");
|
|
4728
4761
|
|
|
4729
4762
|
// src/hooks/useScreenSize.ts
|
|
4730
|
-
var
|
|
4763
|
+
var import_react20 = require("react");
|
|
4731
4764
|
var useScreenSize = () => {
|
|
4732
|
-
const [containerSize, setContainerSize] = (0,
|
|
4765
|
+
const [containerSize, setContainerSize] = (0, import_react20.useState)({
|
|
4733
4766
|
width: 0,
|
|
4734
4767
|
height: 0
|
|
4735
4768
|
});
|
|
4736
|
-
const [screenSize, setScreenSize] = (0,
|
|
4769
|
+
const [screenSize, setScreenSize] = (0, import_react20.useState)({
|
|
4737
4770
|
width: window.innerWidth,
|
|
4738
4771
|
height: window.innerHeight
|
|
4739
4772
|
});
|
|
4740
|
-
(0,
|
|
4773
|
+
(0, import_react20.useEffect)(() => {
|
|
4741
4774
|
const handleResize = () => {
|
|
4742
4775
|
setScreenSize({
|
|
4743
4776
|
width: window.innerWidth,
|
|
@@ -4773,10 +4806,10 @@ var GroupingActivityMaterialContent = ({
|
|
|
4773
4806
|
isPreview,
|
|
4774
4807
|
showCorrectAnswer
|
|
4775
4808
|
}) => {
|
|
4776
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
4777
|
-
const [selectedTargetKey, setSelectedTargetKey] = (0,
|
|
4778
|
-
const [isShuffled, setIsShuffled] = (0,
|
|
4779
|
-
const [shuffledMaterialList, setShuffledMaterialList] = (0,
|
|
4809
|
+
const [selectedValue, setSelectedValue] = (0, import_react21.useState)(null);
|
|
4810
|
+
const [selectedTargetKey, setSelectedTargetKey] = (0, import_react21.useState)(null);
|
|
4811
|
+
const [isShuffled, setIsShuffled] = (0, import_react21.useState)(false);
|
|
4812
|
+
const [shuffledMaterialList, setShuffledMaterialList] = (0, import_react21.useState)([]);
|
|
4780
4813
|
const { screenSize, containerSize } = useScreenSize_default();
|
|
4781
4814
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd4.useDrop)({
|
|
4782
4815
|
accept: "GROUPING",
|
|
@@ -4787,22 +4820,22 @@ var GroupingActivityMaterialContent = ({
|
|
|
4787
4820
|
canDrop: monitor.canDrop()
|
|
4788
4821
|
})
|
|
4789
4822
|
});
|
|
4790
|
-
const ref = (0,
|
|
4791
|
-
const itemsRef = (0,
|
|
4792
|
-
const [maxWidth, setMaxWidth] = (0,
|
|
4793
|
-
(0,
|
|
4823
|
+
const ref = (0, import_react21.useRef)(null);
|
|
4824
|
+
const itemsRef = (0, import_react21.useRef)(null);
|
|
4825
|
+
const [maxWidth, setMaxWidth] = (0, import_react21.useState)(0);
|
|
4826
|
+
(0, import_react21.useEffect)(() => {
|
|
4794
4827
|
if (!ref) return;
|
|
4795
4828
|
if (!ref.current) return;
|
|
4796
4829
|
if (!screenSize) return;
|
|
4797
4830
|
setMaxWidth(ref.current.offsetWidth - 12);
|
|
4798
4831
|
}, [ref, screenSize]);
|
|
4799
|
-
(0,
|
|
4832
|
+
(0, import_react21.useEffect)(() => {
|
|
4800
4833
|
if (!itemsRef) return;
|
|
4801
4834
|
if (!itemsRef.current) return;
|
|
4802
4835
|
if (!containerSize) return;
|
|
4803
4836
|
itemsRef.current.style.width = `${containerSize.width - 200}px`;
|
|
4804
4837
|
}, [itemsRef, containerSize]);
|
|
4805
|
-
(0,
|
|
4838
|
+
(0, import_react21.useEffect)(() => {
|
|
4806
4839
|
const shuffleArray2 = (array) => {
|
|
4807
4840
|
if (!isShuffled) {
|
|
4808
4841
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -4823,7 +4856,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
4823
4856
|
});
|
|
4824
4857
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
4825
4858
|
}, []);
|
|
4826
|
-
(0,
|
|
4859
|
+
(0, import_react21.useEffect)(() => {
|
|
4827
4860
|
if (!showCorrectAnswer) return;
|
|
4828
4861
|
answer.data.find(
|
|
4829
4862
|
(answerData) => answerData.type === "GROUPING"
|
|
@@ -4872,7 +4905,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
4872
4905
|
"div",
|
|
4873
4906
|
{
|
|
4874
4907
|
ref: itemsRef,
|
|
4875
|
-
className: "flex-1 flex flex-row gap-
|
|
4908
|
+
className: "flex-1 flex flex-row gap-4 overflow-x-auto py-2 min-w-0",
|
|
4876
4909
|
children: filteredMaterialList.map((materialValue, index) => {
|
|
4877
4910
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4878
4911
|
DraggableItem_default,
|
|
@@ -5097,7 +5130,7 @@ var GroupingActivityContent = ({
|
|
|
5097
5130
|
var GroupingActivityContent_default = GroupingActivityContent;
|
|
5098
5131
|
|
|
5099
5132
|
// src/components/activities/material-content/MatchingActivityMaterialContent.tsx
|
|
5100
|
-
var
|
|
5133
|
+
var import_react22 = require("react");
|
|
5101
5134
|
var import_react_dnd5 = require("react-dnd");
|
|
5102
5135
|
var import_react_katex5 = require("react-katex");
|
|
5103
5136
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -5111,10 +5144,10 @@ var MatchingActivityMaterialContent = ({
|
|
|
5111
5144
|
isPreview,
|
|
5112
5145
|
showCorrectAnswer
|
|
5113
5146
|
}) => {
|
|
5114
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
5115
|
-
const [selectedTargetKey, setSelectedTargetKey] = (0,
|
|
5116
|
-
const [isShuffled, setIsShuffled] = (0,
|
|
5117
|
-
const [shuffledMaterialList, setShuffledMaterialList] = (0,
|
|
5147
|
+
const [selectedValue, setSelectedValue] = (0, import_react22.useState)(null);
|
|
5148
|
+
const [selectedTargetKey, setSelectedTargetKey] = (0, import_react22.useState)(null);
|
|
5149
|
+
const [isShuffled, setIsShuffled] = (0, import_react22.useState)(false);
|
|
5150
|
+
const [shuffledMaterialList, setShuffledMaterialList] = (0, import_react22.useState)([]);
|
|
5118
5151
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd5.useDrop)({
|
|
5119
5152
|
accept: "MATCHING",
|
|
5120
5153
|
drop: () => {
|
|
@@ -5125,8 +5158,8 @@ var MatchingActivityMaterialContent = ({
|
|
|
5125
5158
|
})
|
|
5126
5159
|
});
|
|
5127
5160
|
const { containerSize } = useScreenSize_default();
|
|
5128
|
-
const itemsRef = (0,
|
|
5129
|
-
(0,
|
|
5161
|
+
const itemsRef = (0, import_react22.useRef)(null);
|
|
5162
|
+
(0, import_react22.useEffect)(() => {
|
|
5130
5163
|
const shuffleArray2 = (array) => {
|
|
5131
5164
|
if (!isShuffled) {
|
|
5132
5165
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -5145,13 +5178,13 @@ var MatchingActivityMaterialContent = ({
|
|
|
5145
5178
|
});
|
|
5146
5179
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
5147
5180
|
}, []);
|
|
5148
|
-
(0,
|
|
5181
|
+
(0, import_react22.useEffect)(() => {
|
|
5149
5182
|
if (!showCorrectAnswer) return;
|
|
5150
5183
|
answer.data.find(
|
|
5151
5184
|
(answerData) => answerData.type === "MATCHING"
|
|
5152
5185
|
).answerMap = materialMap;
|
|
5153
5186
|
}, [showCorrectAnswer]);
|
|
5154
|
-
(0,
|
|
5187
|
+
(0, import_react22.useEffect)(() => {
|
|
5155
5188
|
if (!itemsRef) return;
|
|
5156
5189
|
if (!itemsRef.current) return;
|
|
5157
5190
|
if (!containerSize) return;
|
|
@@ -5800,12 +5833,12 @@ var OpenEndedActivityContent = ({
|
|
|
5800
5833
|
var OpenEndedActivityContent_default = OpenEndedActivityContent;
|
|
5801
5834
|
|
|
5802
5835
|
// src/components/activities/material-content/OrderingActivityMaterialContent.tsx
|
|
5803
|
-
var
|
|
5836
|
+
var import_react24 = require("react");
|
|
5804
5837
|
var import_react_dnd7 = require("react-dnd");
|
|
5805
5838
|
var import_react_katex8 = require("react-katex");
|
|
5806
5839
|
|
|
5807
5840
|
// src/components/dnds/DraggableDroppableItem.tsx
|
|
5808
|
-
var
|
|
5841
|
+
var import_react23 = require("react");
|
|
5809
5842
|
var import_react_dnd6 = require("react-dnd");
|
|
5810
5843
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
5811
5844
|
var DraggableDroppableItem = ({
|
|
@@ -5818,7 +5851,7 @@ var DraggableDroppableItem = ({
|
|
|
5818
5851
|
target,
|
|
5819
5852
|
setTarget
|
|
5820
5853
|
}) => {
|
|
5821
|
-
const ref = (0,
|
|
5854
|
+
const ref = (0, import_react23.useRef)(null);
|
|
5822
5855
|
const [, drop] = (0, import_react_dnd6.useDrop)({
|
|
5823
5856
|
accept: type,
|
|
5824
5857
|
hover() {
|
|
@@ -5869,10 +5902,10 @@ var OrderingActivityMaterialContent = ({
|
|
|
5869
5902
|
isPreview,
|
|
5870
5903
|
showCorrectAnswer
|
|
5871
5904
|
}) => {
|
|
5872
|
-
const [selectedTargetKey, setSelectedTargetKey] = (0,
|
|
5873
|
-
const [selectedKey, setSelectedKey] = (0,
|
|
5905
|
+
const [selectedTargetKey, setSelectedTargetKey] = (0, import_react24.useState)(null);
|
|
5906
|
+
const [selectedKey, setSelectedKey] = (0, import_react24.useState)(null);
|
|
5874
5907
|
const { screenSize } = useScreenSize_default();
|
|
5875
|
-
const [view, setView] = (0,
|
|
5908
|
+
const [view, setView] = (0, import_react24.useState)("PC");
|
|
5876
5909
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd7.useDrop)({
|
|
5877
5910
|
accept: "ORDERING",
|
|
5878
5911
|
drop: () => {
|
|
@@ -5882,7 +5915,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5882
5915
|
canDrop: monitor.canDrop()
|
|
5883
5916
|
})
|
|
5884
5917
|
});
|
|
5885
|
-
(0,
|
|
5918
|
+
(0, import_react24.useEffect)(() => {
|
|
5886
5919
|
if (!screenSize) return;
|
|
5887
5920
|
if (screenSize.width <= 768) {
|
|
5888
5921
|
setView("TABLET");
|
|
@@ -5890,7 +5923,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5890
5923
|
setView("PC");
|
|
5891
5924
|
}
|
|
5892
5925
|
}, [screenSize]);
|
|
5893
|
-
(0,
|
|
5926
|
+
(0, import_react24.useEffect)(() => {
|
|
5894
5927
|
if (!showCorrectAnswer) return;
|
|
5895
5928
|
const answerMap2 = answer.data.find(
|
|
5896
5929
|
(answerData) => answerData.type === "ORDERING"
|
|
@@ -6067,7 +6100,7 @@ var OrderingActivityContent = ({
|
|
|
6067
6100
|
var OrderingActivityContent_default = OrderingActivityContent;
|
|
6068
6101
|
|
|
6069
6102
|
// src/components/activities/material-content/TrueFalseActivityMaterialContent.tsx
|
|
6070
|
-
var
|
|
6103
|
+
var import_react25 = require("react");
|
|
6071
6104
|
var import_react_katex9 = require("react-katex");
|
|
6072
6105
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
6073
6106
|
var TrueFalseActivityMaterialContent = ({
|
|
@@ -6081,8 +6114,8 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
6081
6114
|
showCorrectAnswer
|
|
6082
6115
|
}) => {
|
|
6083
6116
|
const { screenSize } = useScreenSize_default();
|
|
6084
|
-
const [shuffleOptionList, setShuffleOptionList] = (0,
|
|
6085
|
-
(0,
|
|
6117
|
+
const [shuffleOptionList, setShuffleOptionList] = (0, import_react25.useState)([]);
|
|
6118
|
+
(0, import_react25.useEffect)(() => {
|
|
6086
6119
|
const optionList = [];
|
|
6087
6120
|
optionList.push(...materialMap.trueList);
|
|
6088
6121
|
optionList.push(...materialMap.falseList);
|
|
@@ -6092,7 +6125,7 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
6092
6125
|
setShuffleOptionList(shuffleArray(optionList));
|
|
6093
6126
|
}
|
|
6094
6127
|
}, []);
|
|
6095
|
-
(0,
|
|
6128
|
+
(0, import_react25.useEffect)(() => {
|
|
6096
6129
|
if (!showCorrectAnswer) return;
|
|
6097
6130
|
answer.data.find(
|
|
6098
6131
|
(answerData) => answerData.type === "TRUE_FALSE"
|
|
@@ -6400,7 +6433,7 @@ var ActivityEvaluationRubricContent = ({
|
|
|
6400
6433
|
var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
|
|
6401
6434
|
|
|
6402
6435
|
// src/components/activities/ActivityPreviewByData.tsx
|
|
6403
|
-
var
|
|
6436
|
+
var import_react26 = require("react");
|
|
6404
6437
|
|
|
6405
6438
|
// src/components/boxes/SelectionBox.tsx
|
|
6406
6439
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
@@ -6452,14 +6485,14 @@ var ActivityPreviewByData = ({
|
|
|
6452
6485
|
showTaxonomy,
|
|
6453
6486
|
isFullScreen
|
|
6454
6487
|
}) => {
|
|
6455
|
-
const [key, setKey] = (0,
|
|
6456
|
-
const [selectedType, setSelectedType] = (0,
|
|
6457
|
-
const [optionList, setOptionList] = (0,
|
|
6458
|
-
(0,
|
|
6488
|
+
const [key, setKey] = (0, import_react26.useState)((/* @__PURE__ */ new Date()).getTime());
|
|
6489
|
+
const [selectedType, setSelectedType] = (0, import_react26.useState)(null);
|
|
6490
|
+
const [optionList, setOptionList] = (0, import_react26.useState)([]);
|
|
6491
|
+
(0, import_react26.useEffect)(() => {
|
|
6459
6492
|
if (!data) return;
|
|
6460
6493
|
setKey((/* @__PURE__ */ new Date()).getTime());
|
|
6461
6494
|
}, [data]);
|
|
6462
|
-
(0,
|
|
6495
|
+
(0, import_react26.useEffect)(() => {
|
|
6463
6496
|
if (!typeOptionList) return;
|
|
6464
6497
|
if (typeOptionList.length === 0) return;
|
|
6465
6498
|
let foundTypeOption;
|
|
@@ -6474,7 +6507,7 @@ var ActivityPreviewByData = ({
|
|
|
6474
6507
|
setSelectedType(typeOptionList[0].id);
|
|
6475
6508
|
}
|
|
6476
6509
|
}, [typeOptionList, lockedType]);
|
|
6477
|
-
(0,
|
|
6510
|
+
(0, import_react26.useEffect)(() => {
|
|
6478
6511
|
const retrieveTaxonomyNameByActivityTypeFromData = (type) => {
|
|
6479
6512
|
let taxonomyMap = {
|
|
6480
6513
|
name: ""
|
package/dist/index.mjs
CHANGED
|
@@ -4103,6 +4103,7 @@ var DropdownActivityMaterialContent = ({
|
|
|
4103
4103
|
var DropdownActivityMaterialContent_default = DropdownActivityMaterialContent;
|
|
4104
4104
|
|
|
4105
4105
|
// src/components/activities/DropdownActivityContent.tsx
|
|
4106
|
+
import { useState as useState13, useEffect as useEffect5 } from "react";
|
|
4106
4107
|
import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4107
4108
|
var DropdownActivityContent = ({
|
|
4108
4109
|
answer,
|
|
@@ -4116,23 +4117,41 @@ var DropdownActivityContent = ({
|
|
|
4116
4117
|
const contentMap = parseContentMapFromData(data);
|
|
4117
4118
|
const dropdownBodyMap = parseBodyMapFromData(data, "DROPDOWN");
|
|
4118
4119
|
const dropdownMaterialMap = parseMaterialMapFromData(data, "DROPDOWN");
|
|
4119
|
-
const
|
|
4120
|
+
const [currentAnswerMap, setCurrentAnswerMap] = useState13(() => {
|
|
4121
|
+
return retrieveCurrentAnswerMap();
|
|
4122
|
+
});
|
|
4123
|
+
function retrieveCurrentAnswerMap() {
|
|
4120
4124
|
let foundIndex = answer.data.findIndex(
|
|
4121
4125
|
(answerData) => answerData.type === "DROPDOWN"
|
|
4122
4126
|
);
|
|
4123
4127
|
return answer.data[foundIndex].answerMap;
|
|
4124
|
-
}
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4128
|
+
}
|
|
4129
|
+
useEffect5(() => {
|
|
4130
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
4131
|
+
}, [answer]);
|
|
4132
|
+
const handleDropdownAnswerOnChange = (answerObj, key, value) => {
|
|
4133
|
+
const newAnswer = __spreadProps(__spreadValues({}, answerObj), {
|
|
4134
|
+
data: answerObj.data.map((item) => {
|
|
4135
|
+
if (item.type === "DROPDOWN") {
|
|
4136
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
4137
|
+
answerMap: __spreadProps(__spreadValues({}, item.answerMap), {
|
|
4138
|
+
[key]: value
|
|
4139
|
+
})
|
|
4140
|
+
});
|
|
4141
|
+
}
|
|
4142
|
+
return item;
|
|
4143
|
+
})
|
|
4144
|
+
});
|
|
4145
|
+
const newAnswerMap = __spreadProps(__spreadValues({}, currentAnswerMap), { [key]: value });
|
|
4146
|
+
setCurrentAnswerMap(newAnswerMap);
|
|
4147
|
+
changeAnswer(newAnswer);
|
|
4129
4148
|
};
|
|
4130
4149
|
return /* @__PURE__ */ jsxs13("div", { className: "flex flex-row flex-wrap", children: [
|
|
4131
4150
|
/* @__PURE__ */ jsx20("div", { className: `${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`, children: /* @__PURE__ */ jsx20(
|
|
4132
4151
|
ActivityBodyContent_default,
|
|
4133
4152
|
{
|
|
4134
4153
|
bodyMap: dropdownBodyMap,
|
|
4135
|
-
answerMap:
|
|
4154
|
+
answerMap: currentAnswerMap,
|
|
4136
4155
|
contentMap,
|
|
4137
4156
|
templateType: "DROPDOWN"
|
|
4138
4157
|
}
|
|
@@ -4158,8 +4177,8 @@ var DropdownActivityContent_default = DropdownActivityContent;
|
|
|
4158
4177
|
|
|
4159
4178
|
// src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx
|
|
4160
4179
|
import { InlineMath as InlineMath3 } from "react-katex";
|
|
4161
|
-
import { useState as
|
|
4162
|
-
import { useEffect as
|
|
4180
|
+
import { useState as useState14 } from "react";
|
|
4181
|
+
import { useEffect as useEffect6 } from "react";
|
|
4163
4182
|
import { useDrop as useDrop2 } from "react-dnd";
|
|
4164
4183
|
|
|
4165
4184
|
// src/components/dnds/DraggableItem.tsx
|
|
@@ -4245,9 +4264,9 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4245
4264
|
isPreview,
|
|
4246
4265
|
showCorrectAnswer
|
|
4247
4266
|
}) => {
|
|
4248
|
-
const [shuffleOptionList, setShuffleOptionList] =
|
|
4249
|
-
const [selectedOption, setSelectedOption] =
|
|
4250
|
-
const [pasteOptionIndex, setPasteOptionIndex] =
|
|
4267
|
+
const [shuffleOptionList, setShuffleOptionList] = useState14([]);
|
|
4268
|
+
const [selectedOption, setSelectedOption] = useState14(null);
|
|
4269
|
+
const [pasteOptionIndex, setPasteOptionIndex] = useState14(null);
|
|
4251
4270
|
const [{ isOver, canDrop }, drop] = useDrop2({
|
|
4252
4271
|
accept: "FILL_IN_THE_BLANKS",
|
|
4253
4272
|
drop: () => {
|
|
@@ -4257,26 +4276,21 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4257
4276
|
canDrop: monitor.canDrop()
|
|
4258
4277
|
})
|
|
4259
4278
|
});
|
|
4260
|
-
|
|
4279
|
+
useEffect6(() => {
|
|
4261
4280
|
setShuffleOptionList(shuffleArray(optionList));
|
|
4262
4281
|
}, []);
|
|
4263
|
-
|
|
4282
|
+
useEffect6(() => {
|
|
4264
4283
|
if (!showCorrectAnswer) return;
|
|
4265
4284
|
const foundAnswer = answer.data.find(
|
|
4266
4285
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4267
4286
|
);
|
|
4268
|
-
if (!foundAnswer) return;
|
|
4269
4287
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4270
4288
|
if (Object.keys(materialMap).length === 0) return;
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
if (Object.keys(materialMap).length > 0) {
|
|
4277
|
-
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
4278
|
-
}
|
|
4279
|
-
}, [showCorrectAnswer, answer, materialMap, onChange]);
|
|
4289
|
+
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
4290
|
+
(materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
|
|
4291
|
+
);
|
|
4292
|
+
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
4293
|
+
}, [showCorrectAnswer]);
|
|
4280
4294
|
const retrieveAnswerMap = () => {
|
|
4281
4295
|
const foundIndex = answer.data.findIndex(
|
|
4282
4296
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
@@ -4443,6 +4457,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4443
4457
|
var FillInTheBlanksActivityMaterialContent_default = FillInTheBlanksActivityMaterialContent;
|
|
4444
4458
|
|
|
4445
4459
|
// src/components/activities/FillInTheBlanksActivityContent.tsx
|
|
4460
|
+
import { useState as useState15, useEffect as useEffect7 } from "react";
|
|
4446
4461
|
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4447
4462
|
var FillInTheBlanksActivityContent = ({
|
|
4448
4463
|
answer,
|
|
@@ -4463,12 +4478,18 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4463
4478
|
"FILL_IN_THE_BLANKS"
|
|
4464
4479
|
);
|
|
4465
4480
|
const fillInTheBlanksIncorrectList = data.fillInTheBlanksIncorrectList ? JSON.parse(data.fillInTheBlanksIncorrectList) : [];
|
|
4466
|
-
const
|
|
4481
|
+
const [currentAnswerMap, setCurrentAnswerMap] = useState15(() => {
|
|
4482
|
+
return retrieveCurrentAnswerMap();
|
|
4483
|
+
});
|
|
4484
|
+
function retrieveCurrentAnswerMap() {
|
|
4467
4485
|
let foundIndex = answer.data.findIndex(
|
|
4468
4486
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4469
4487
|
);
|
|
4470
4488
|
return answer.data[foundIndex].answerMap;
|
|
4471
|
-
}
|
|
4489
|
+
}
|
|
4490
|
+
useEffect7(() => {
|
|
4491
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
4492
|
+
}, [answer]);
|
|
4472
4493
|
const constructAnswerOptionList = () => {
|
|
4473
4494
|
const optionList = [];
|
|
4474
4495
|
Object.keys(fillInTheBlanksMaterialMap).forEach((key) => {
|
|
@@ -4487,17 +4508,29 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4487
4508
|
});
|
|
4488
4509
|
return optionList;
|
|
4489
4510
|
};
|
|
4490
|
-
const handleFillInTheBlanksAnswerOnChange = (
|
|
4491
|
-
const
|
|
4492
|
-
|
|
4493
|
-
|
|
4511
|
+
const handleFillInTheBlanksAnswerOnChange = (answerObj, key, value) => {
|
|
4512
|
+
const newAnswer = __spreadProps(__spreadValues({}, answerObj), {
|
|
4513
|
+
data: answerObj.data.map((item) => {
|
|
4514
|
+
if (item.type === "FILL_IN_THE_BLANKS") {
|
|
4515
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
4516
|
+
answerMap: __spreadProps(__spreadValues({}, item.answerMap), {
|
|
4517
|
+
[key]: value
|
|
4518
|
+
})
|
|
4519
|
+
});
|
|
4520
|
+
}
|
|
4521
|
+
return item;
|
|
4522
|
+
})
|
|
4523
|
+
});
|
|
4524
|
+
const newAnswerMap = __spreadProps(__spreadValues({}, currentAnswerMap), { [key]: value });
|
|
4525
|
+
setCurrentAnswerMap(newAnswerMap);
|
|
4526
|
+
changeAnswer(newAnswer);
|
|
4494
4527
|
};
|
|
4495
4528
|
return /* @__PURE__ */ jsxs15("div", { className: "flex flex-row flex-wrap", children: [
|
|
4496
4529
|
/* @__PURE__ */ jsx24("div", { className: `${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`, children: /* @__PURE__ */ jsx24(
|
|
4497
4530
|
ActivityBodyContent_default,
|
|
4498
4531
|
{
|
|
4499
4532
|
bodyMap: fillInTheBlanksBodyMap,
|
|
4500
|
-
answerMap:
|
|
4533
|
+
answerMap: currentAnswerMap,
|
|
4501
4534
|
contentMap,
|
|
4502
4535
|
templateType: "FILL_IN_THE_BLANKS"
|
|
4503
4536
|
}
|
|
@@ -4523,22 +4556,22 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4523
4556
|
var FillInTheBlanksActivityContent_default = FillInTheBlanksActivityContent;
|
|
4524
4557
|
|
|
4525
4558
|
// src/components/activities/material-content/GroupingActivityMaterialContent.tsx
|
|
4526
|
-
import { useEffect as
|
|
4559
|
+
import { useEffect as useEffect9, useRef as useRef4, useState as useState17 } from "react";
|
|
4527
4560
|
import { useDrop as useDrop3 } from "react-dnd";
|
|
4528
4561
|
import { InlineMath as InlineMath4 } from "react-katex";
|
|
4529
4562
|
|
|
4530
4563
|
// src/hooks/useScreenSize.ts
|
|
4531
|
-
import { useState as
|
|
4564
|
+
import { useState as useState16, useEffect as useEffect8 } from "react";
|
|
4532
4565
|
var useScreenSize = () => {
|
|
4533
|
-
const [containerSize, setContainerSize] =
|
|
4566
|
+
const [containerSize, setContainerSize] = useState16({
|
|
4534
4567
|
width: 0,
|
|
4535
4568
|
height: 0
|
|
4536
4569
|
});
|
|
4537
|
-
const [screenSize, setScreenSize] =
|
|
4570
|
+
const [screenSize, setScreenSize] = useState16({
|
|
4538
4571
|
width: window.innerWidth,
|
|
4539
4572
|
height: window.innerHeight
|
|
4540
4573
|
});
|
|
4541
|
-
|
|
4574
|
+
useEffect8(() => {
|
|
4542
4575
|
const handleResize = () => {
|
|
4543
4576
|
setScreenSize({
|
|
4544
4577
|
width: window.innerWidth,
|
|
@@ -4574,10 +4607,10 @@ var GroupingActivityMaterialContent = ({
|
|
|
4574
4607
|
isPreview,
|
|
4575
4608
|
showCorrectAnswer
|
|
4576
4609
|
}) => {
|
|
4577
|
-
const [selectedValue, setSelectedValue] =
|
|
4578
|
-
const [selectedTargetKey, setSelectedTargetKey] =
|
|
4579
|
-
const [isShuffled, setIsShuffled] =
|
|
4580
|
-
const [shuffledMaterialList, setShuffledMaterialList] =
|
|
4610
|
+
const [selectedValue, setSelectedValue] = useState17(null);
|
|
4611
|
+
const [selectedTargetKey, setSelectedTargetKey] = useState17(null);
|
|
4612
|
+
const [isShuffled, setIsShuffled] = useState17(false);
|
|
4613
|
+
const [shuffledMaterialList, setShuffledMaterialList] = useState17([]);
|
|
4581
4614
|
const { screenSize, containerSize } = useScreenSize_default();
|
|
4582
4615
|
const [{ isOver, canDrop }, drop] = useDrop3({
|
|
4583
4616
|
accept: "GROUPING",
|
|
@@ -4590,20 +4623,20 @@ var GroupingActivityMaterialContent = ({
|
|
|
4590
4623
|
});
|
|
4591
4624
|
const ref = useRef4(null);
|
|
4592
4625
|
const itemsRef = useRef4(null);
|
|
4593
|
-
const [maxWidth, setMaxWidth] =
|
|
4594
|
-
|
|
4626
|
+
const [maxWidth, setMaxWidth] = useState17(0);
|
|
4627
|
+
useEffect9(() => {
|
|
4595
4628
|
if (!ref) return;
|
|
4596
4629
|
if (!ref.current) return;
|
|
4597
4630
|
if (!screenSize) return;
|
|
4598
4631
|
setMaxWidth(ref.current.offsetWidth - 12);
|
|
4599
4632
|
}, [ref, screenSize]);
|
|
4600
|
-
|
|
4633
|
+
useEffect9(() => {
|
|
4601
4634
|
if (!itemsRef) return;
|
|
4602
4635
|
if (!itemsRef.current) return;
|
|
4603
4636
|
if (!containerSize) return;
|
|
4604
4637
|
itemsRef.current.style.width = `${containerSize.width - 200}px`;
|
|
4605
4638
|
}, [itemsRef, containerSize]);
|
|
4606
|
-
|
|
4639
|
+
useEffect9(() => {
|
|
4607
4640
|
const shuffleArray2 = (array) => {
|
|
4608
4641
|
if (!isShuffled) {
|
|
4609
4642
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -4624,7 +4657,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
4624
4657
|
});
|
|
4625
4658
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
4626
4659
|
}, []);
|
|
4627
|
-
|
|
4660
|
+
useEffect9(() => {
|
|
4628
4661
|
if (!showCorrectAnswer) return;
|
|
4629
4662
|
answer.data.find(
|
|
4630
4663
|
(answerData) => answerData.type === "GROUPING"
|
|
@@ -4673,7 +4706,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
4673
4706
|
"div",
|
|
4674
4707
|
{
|
|
4675
4708
|
ref: itemsRef,
|
|
4676
|
-
className: "flex-1 flex flex-row gap-
|
|
4709
|
+
className: "flex-1 flex flex-row gap-4 overflow-x-auto py-2 min-w-0",
|
|
4677
4710
|
children: filteredMaterialList.map((materialValue, index) => {
|
|
4678
4711
|
return /* @__PURE__ */ jsx25(
|
|
4679
4712
|
DraggableItem_default,
|
|
@@ -4898,7 +4931,7 @@ var GroupingActivityContent = ({
|
|
|
4898
4931
|
var GroupingActivityContent_default = GroupingActivityContent;
|
|
4899
4932
|
|
|
4900
4933
|
// src/components/activities/material-content/MatchingActivityMaterialContent.tsx
|
|
4901
|
-
import { useEffect as
|
|
4934
|
+
import { useEffect as useEffect10, useRef as useRef5, useState as useState18 } from "react";
|
|
4902
4935
|
import { useDrop as useDrop4 } from "react-dnd";
|
|
4903
4936
|
import { InlineMath as InlineMath5 } from "react-katex";
|
|
4904
4937
|
import { Fragment as Fragment3, jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -4912,10 +4945,10 @@ var MatchingActivityMaterialContent = ({
|
|
|
4912
4945
|
isPreview,
|
|
4913
4946
|
showCorrectAnswer
|
|
4914
4947
|
}) => {
|
|
4915
|
-
const [selectedValue, setSelectedValue] =
|
|
4916
|
-
const [selectedTargetKey, setSelectedTargetKey] =
|
|
4917
|
-
const [isShuffled, setIsShuffled] =
|
|
4918
|
-
const [shuffledMaterialList, setShuffledMaterialList] =
|
|
4948
|
+
const [selectedValue, setSelectedValue] = useState18(null);
|
|
4949
|
+
const [selectedTargetKey, setSelectedTargetKey] = useState18(null);
|
|
4950
|
+
const [isShuffled, setIsShuffled] = useState18(false);
|
|
4951
|
+
const [shuffledMaterialList, setShuffledMaterialList] = useState18([]);
|
|
4919
4952
|
const [{ isOver, canDrop }, drop] = useDrop4({
|
|
4920
4953
|
accept: "MATCHING",
|
|
4921
4954
|
drop: () => {
|
|
@@ -4927,7 +4960,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
4927
4960
|
});
|
|
4928
4961
|
const { containerSize } = useScreenSize_default();
|
|
4929
4962
|
const itemsRef = useRef5(null);
|
|
4930
|
-
|
|
4963
|
+
useEffect10(() => {
|
|
4931
4964
|
const shuffleArray2 = (array) => {
|
|
4932
4965
|
if (!isShuffled) {
|
|
4933
4966
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -4946,13 +4979,13 @@ var MatchingActivityMaterialContent = ({
|
|
|
4946
4979
|
});
|
|
4947
4980
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
4948
4981
|
}, []);
|
|
4949
|
-
|
|
4982
|
+
useEffect10(() => {
|
|
4950
4983
|
if (!showCorrectAnswer) return;
|
|
4951
4984
|
answer.data.find(
|
|
4952
4985
|
(answerData) => answerData.type === "MATCHING"
|
|
4953
4986
|
).answerMap = materialMap;
|
|
4954
4987
|
}, [showCorrectAnswer]);
|
|
4955
|
-
|
|
4988
|
+
useEffect10(() => {
|
|
4956
4989
|
if (!itemsRef) return;
|
|
4957
4990
|
if (!itemsRef.current) return;
|
|
4958
4991
|
if (!containerSize) return;
|
|
@@ -5601,7 +5634,7 @@ var OpenEndedActivityContent = ({
|
|
|
5601
5634
|
var OpenEndedActivityContent_default = OpenEndedActivityContent;
|
|
5602
5635
|
|
|
5603
5636
|
// src/components/activities/material-content/OrderingActivityMaterialContent.tsx
|
|
5604
|
-
import { useEffect as
|
|
5637
|
+
import { useEffect as useEffect11, useState as useState19 } from "react";
|
|
5605
5638
|
import { useDrop as useDrop6 } from "react-dnd";
|
|
5606
5639
|
import { InlineMath as InlineMath8 } from "react-katex";
|
|
5607
5640
|
|
|
@@ -5670,10 +5703,10 @@ var OrderingActivityMaterialContent = ({
|
|
|
5670
5703
|
isPreview,
|
|
5671
5704
|
showCorrectAnswer
|
|
5672
5705
|
}) => {
|
|
5673
|
-
const [selectedTargetKey, setSelectedTargetKey] =
|
|
5674
|
-
const [selectedKey, setSelectedKey] =
|
|
5706
|
+
const [selectedTargetKey, setSelectedTargetKey] = useState19(null);
|
|
5707
|
+
const [selectedKey, setSelectedKey] = useState19(null);
|
|
5675
5708
|
const { screenSize } = useScreenSize_default();
|
|
5676
|
-
const [view, setView] =
|
|
5709
|
+
const [view, setView] = useState19("PC");
|
|
5677
5710
|
const [{ isOver, canDrop }, drop] = useDrop6({
|
|
5678
5711
|
accept: "ORDERING",
|
|
5679
5712
|
drop: () => {
|
|
@@ -5683,7 +5716,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5683
5716
|
canDrop: monitor.canDrop()
|
|
5684
5717
|
})
|
|
5685
5718
|
});
|
|
5686
|
-
|
|
5719
|
+
useEffect11(() => {
|
|
5687
5720
|
if (!screenSize) return;
|
|
5688
5721
|
if (screenSize.width <= 768) {
|
|
5689
5722
|
setView("TABLET");
|
|
@@ -5691,7 +5724,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5691
5724
|
setView("PC");
|
|
5692
5725
|
}
|
|
5693
5726
|
}, [screenSize]);
|
|
5694
|
-
|
|
5727
|
+
useEffect11(() => {
|
|
5695
5728
|
if (!showCorrectAnswer) return;
|
|
5696
5729
|
const answerMap2 = answer.data.find(
|
|
5697
5730
|
(answerData) => answerData.type === "ORDERING"
|
|
@@ -5868,7 +5901,7 @@ var OrderingActivityContent = ({
|
|
|
5868
5901
|
var OrderingActivityContent_default = OrderingActivityContent;
|
|
5869
5902
|
|
|
5870
5903
|
// src/components/activities/material-content/TrueFalseActivityMaterialContent.tsx
|
|
5871
|
-
import { useEffect as
|
|
5904
|
+
import { useEffect as useEffect12, useState as useState20 } from "react";
|
|
5872
5905
|
import { InlineMath as InlineMath9 } from "react-katex";
|
|
5873
5906
|
import { Fragment as Fragment8, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5874
5907
|
var TrueFalseActivityMaterialContent = ({
|
|
@@ -5882,8 +5915,8 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
5882
5915
|
showCorrectAnswer
|
|
5883
5916
|
}) => {
|
|
5884
5917
|
const { screenSize } = useScreenSize_default();
|
|
5885
|
-
const [shuffleOptionList, setShuffleOptionList] =
|
|
5886
|
-
|
|
5918
|
+
const [shuffleOptionList, setShuffleOptionList] = useState20([]);
|
|
5919
|
+
useEffect12(() => {
|
|
5887
5920
|
const optionList = [];
|
|
5888
5921
|
optionList.push(...materialMap.trueList);
|
|
5889
5922
|
optionList.push(...materialMap.falseList);
|
|
@@ -5893,7 +5926,7 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
5893
5926
|
setShuffleOptionList(shuffleArray(optionList));
|
|
5894
5927
|
}
|
|
5895
5928
|
}, []);
|
|
5896
|
-
|
|
5929
|
+
useEffect12(() => {
|
|
5897
5930
|
if (!showCorrectAnswer) return;
|
|
5898
5931
|
answer.data.find(
|
|
5899
5932
|
(answerData) => answerData.type === "TRUE_FALSE"
|
|
@@ -6201,7 +6234,7 @@ var ActivityEvaluationRubricContent = ({
|
|
|
6201
6234
|
var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
|
|
6202
6235
|
|
|
6203
6236
|
// src/components/activities/ActivityPreviewByData.tsx
|
|
6204
|
-
import { useEffect as
|
|
6237
|
+
import { useEffect as useEffect13, useState as useState21 } from "react";
|
|
6205
6238
|
|
|
6206
6239
|
// src/components/boxes/SelectionBox.tsx
|
|
6207
6240
|
import { jsx as jsx42, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
@@ -6253,14 +6286,14 @@ var ActivityPreviewByData = ({
|
|
|
6253
6286
|
showTaxonomy,
|
|
6254
6287
|
isFullScreen
|
|
6255
6288
|
}) => {
|
|
6256
|
-
const [key, setKey] =
|
|
6257
|
-
const [selectedType, setSelectedType] =
|
|
6258
|
-
const [optionList, setOptionList] =
|
|
6259
|
-
|
|
6289
|
+
const [key, setKey] = useState21((/* @__PURE__ */ new Date()).getTime());
|
|
6290
|
+
const [selectedType, setSelectedType] = useState21(null);
|
|
6291
|
+
const [optionList, setOptionList] = useState21([]);
|
|
6292
|
+
useEffect13(() => {
|
|
6260
6293
|
if (!data) return;
|
|
6261
6294
|
setKey((/* @__PURE__ */ new Date()).getTime());
|
|
6262
6295
|
}, [data]);
|
|
6263
|
-
|
|
6296
|
+
useEffect13(() => {
|
|
6264
6297
|
if (!typeOptionList) return;
|
|
6265
6298
|
if (typeOptionList.length === 0) return;
|
|
6266
6299
|
let foundTypeOption;
|
|
@@ -6275,7 +6308,7 @@ var ActivityPreviewByData = ({
|
|
|
6275
6308
|
setSelectedType(typeOptionList[0].id);
|
|
6276
6309
|
}
|
|
6277
6310
|
}, [typeOptionList, lockedType]);
|
|
6278
|
-
|
|
6311
|
+
useEffect13(() => {
|
|
6279
6312
|
const retrieveTaxonomyNameByActivityTypeFromData = (type) => {
|
|
6280
6313
|
let taxonomyMap = {
|
|
6281
6314
|
name: ""
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import DividerLine from "../dividers/DividerLine";
|
|
|
8
8
|
import VerticalDividerLine from "../dividers/VerticalDividerLine";
|
|
9
9
|
import ActivityBodyContent from "./body-content/ActivityBodyContent";
|
|
10
10
|
import DropdownActivityMaterialContent from "./material-content/DropdownActivityMaterialContent";
|
|
11
|
+
import { useState, useEffect } from "react";
|
|
11
12
|
|
|
12
13
|
const DropdownActivityContent = ({
|
|
13
14
|
answer,
|
|
@@ -22,21 +23,52 @@ const DropdownActivityContent = ({
|
|
|
22
23
|
const dropdownBodyMap = parseBodyMapFromData(data, "DROPDOWN");
|
|
23
24
|
const dropdownMaterialMap = parseMaterialMapFromData(data, "DROPDOWN");
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
// Add state to track current answer map and force re-renders
|
|
27
|
+
const [currentAnswerMap, setCurrentAnswerMap] = useState(() => {
|
|
28
|
+
return retrieveCurrentAnswerMap();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Function to retrieve answer map
|
|
32
|
+
function retrieveCurrentAnswerMap() {
|
|
26
33
|
let foundIndex = answer.data.findIndex(
|
|
27
34
|
(answerData: any) => answerData.type === "DROPDOWN"
|
|
28
35
|
);
|
|
29
36
|
return answer.data[foundIndex].answerMap;
|
|
30
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Update local state when answer prop changes
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
42
|
+
}, [answer]);
|
|
31
43
|
|
|
32
44
|
const handleDropdownAnswerOnChange = (
|
|
33
|
-
|
|
45
|
+
answerObj: any,
|
|
34
46
|
key: any,
|
|
35
47
|
value: string
|
|
36
48
|
) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
49
|
+
// Create a new answer object to ensure React detects the change
|
|
50
|
+
const newAnswer = {
|
|
51
|
+
...answerObj,
|
|
52
|
+
data: answerObj.data.map((item: any) => {
|
|
53
|
+
if (item.type === "DROPDOWN") {
|
|
54
|
+
return {
|
|
55
|
+
...item,
|
|
56
|
+
answerMap: {
|
|
57
|
+
...item.answerMap,
|
|
58
|
+
[key]: value,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return item;
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Update local state immediately for instant UI update
|
|
67
|
+
const newAnswerMap = { ...currentAnswerMap, [key]: value };
|
|
68
|
+
setCurrentAnswerMap(newAnswerMap);
|
|
69
|
+
|
|
70
|
+
// Call the parent's changeAnswer function
|
|
71
|
+
changeAnswer(newAnswer);
|
|
40
72
|
};
|
|
41
73
|
|
|
42
74
|
return (
|
|
@@ -44,7 +76,7 @@ const DropdownActivityContent = ({
|
|
|
44
76
|
<div className={`${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`}>
|
|
45
77
|
<ActivityBodyContent
|
|
46
78
|
bodyMap={dropdownBodyMap}
|
|
47
|
-
answerMap={
|
|
79
|
+
answerMap={currentAnswerMap} // Use local state instead of function call
|
|
48
80
|
contentMap={contentMap}
|
|
49
81
|
templateType={"DROPDOWN"}
|
|
50
82
|
/>
|
|
@@ -8,6 +8,7 @@ import FillInTheBlanksActivityMaterialContent from "./material-content/FillInThe
|
|
|
8
8
|
import { IFillInTheBlanksActivityProps } from "../../properties/ActivityProperties";
|
|
9
9
|
import DividerLine from "../dividers/DividerLine";
|
|
10
10
|
import VerticalDividerLine from "../dividers/VerticalDividerLine";
|
|
11
|
+
import { useState, useEffect } from "react";
|
|
11
12
|
|
|
12
13
|
const FillInTheBlanksActivityContent = ({
|
|
13
14
|
answer,
|
|
@@ -31,12 +32,23 @@ const FillInTheBlanksActivityContent = ({
|
|
|
31
32
|
? JSON.parse(data.fillInTheBlanksIncorrectList)
|
|
32
33
|
: [];
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
// Add state to track current answer map and force re-renders
|
|
36
|
+
const [currentAnswerMap, setCurrentAnswerMap] = useState(() => {
|
|
37
|
+
return retrieveCurrentAnswerMap();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Function to retrieve answer map
|
|
41
|
+
function retrieveCurrentAnswerMap() {
|
|
35
42
|
let foundIndex = answer.data.findIndex(
|
|
36
43
|
(answerData: any) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
37
44
|
);
|
|
38
45
|
return answer.data[foundIndex].answerMap;
|
|
39
|
-
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Update local state when answer prop changes
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
51
|
+
}, [answer]);
|
|
40
52
|
|
|
41
53
|
const constructAnswerOptionList = () => {
|
|
42
54
|
const optionList: any = [];
|
|
@@ -58,13 +70,33 @@ const FillInTheBlanksActivityContent = ({
|
|
|
58
70
|
};
|
|
59
71
|
|
|
60
72
|
const handleFillInTheBlanksAnswerOnChange = (
|
|
61
|
-
|
|
73
|
+
answerObj: any,
|
|
62
74
|
key: any,
|
|
63
75
|
value: string | null
|
|
64
76
|
) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
// Create a new answer object to ensure React detects the change
|
|
78
|
+
const newAnswer = {
|
|
79
|
+
...answerObj,
|
|
80
|
+
data: answerObj.data.map((item: any) => {
|
|
81
|
+
if (item.type === "FILL_IN_THE_BLANKS") {
|
|
82
|
+
return {
|
|
83
|
+
...item,
|
|
84
|
+
answerMap: {
|
|
85
|
+
...item.answerMap,
|
|
86
|
+
[key]: value,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return item;
|
|
91
|
+
}),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Update local state immediately for instant UI update
|
|
95
|
+
const newAnswerMap = { ...currentAnswerMap, [key]: value };
|
|
96
|
+
setCurrentAnswerMap(newAnswerMap);
|
|
97
|
+
|
|
98
|
+
// Call the parent's changeAnswer function
|
|
99
|
+
changeAnswer(newAnswer);
|
|
68
100
|
};
|
|
69
101
|
|
|
70
102
|
return (
|
|
@@ -72,7 +104,7 @@ const FillInTheBlanksActivityContent = ({
|
|
|
72
104
|
<div className={`${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`}>
|
|
73
105
|
<ActivityBodyContent
|
|
74
106
|
bodyMap={fillInTheBlanksBodyMap}
|
|
75
|
-
answerMap={
|
|
107
|
+
answerMap={currentAnswerMap} // Use local state instead of function call
|
|
76
108
|
contentMap={contentMap}
|
|
77
109
|
templateType={"FILL_IN_THE_BLANKS"}
|
|
78
110
|
/>
|
package/src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx
CHANGED
|
@@ -40,45 +40,19 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
40
40
|
setShuffleOptionList(shuffleArray(optionList));
|
|
41
41
|
}, []);
|
|
42
42
|
|
|
43
|
-
// useEffect(() => {
|
|
44
|
-
// if (!showCorrectAnswer) return;
|
|
45
|
-
// const foundAnswer = answer.data.find(
|
|
46
|
-
// (answerData: any) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
47
|
-
// );
|
|
48
|
-
// if (foundAnswer.answerMap.length === 0) return;
|
|
49
|
-
// if (Object.keys(materialMap).length === 0) return;
|
|
50
|
-
// foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
51
|
-
// (materialMapKey, index) => JSON.parse(materialMap[materialMapKey])[0]
|
|
52
|
-
// );
|
|
53
|
-
|
|
54
|
-
// onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
55
|
-
// }, [showCorrectAnswer]);
|
|
56
|
-
|
|
57
43
|
useEffect(() => {
|
|
58
44
|
if (!showCorrectAnswer) return;
|
|
59
|
-
|
|
60
45
|
const foundAnswer = answer.data.find(
|
|
61
46
|
(answerData: any) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
62
47
|
);
|
|
63
|
-
|
|
64
|
-
if (!foundAnswer) return;
|
|
65
48
|
if (foundAnswer.answerMap.length === 0) return;
|
|
66
49
|
if (Object.keys(materialMap).length === 0) return;
|
|
50
|
+
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
51
|
+
(materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
|
|
52
|
+
);
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Object.keys(materialMap).forEach((materialMapKey) => {
|
|
71
|
-
newAnswerMap[materialMapKey] = JSON.parse(materialMap[materialMapKey])[0];
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Update the answer map
|
|
75
|
-
foundAnswer.answerMap = newAnswerMap;
|
|
76
|
-
|
|
77
|
-
// Trigger onChange for the first item
|
|
78
|
-
if (Object.keys(materialMap).length > 0) {
|
|
79
|
-
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
80
|
-
}
|
|
81
|
-
}, [showCorrectAnswer, answer, materialMap, onChange]);
|
|
54
|
+
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
55
|
+
}, [showCorrectAnswer]);
|
|
82
56
|
|
|
83
57
|
const retrieveAnswerMap = () => {
|
|
84
58
|
const foundIndex = answer.data.findIndex(
|
|
@@ -131,7 +131,7 @@ const GroupingActivityMaterialContent = ({
|
|
|
131
131
|
<>
|
|
132
132
|
<div
|
|
133
133
|
ref={itemsRef}
|
|
134
|
-
className="flex-1 flex flex-row gap-
|
|
134
|
+
className="flex-1 flex flex-row gap-4 overflow-x-auto py-2 min-w-0"
|
|
135
135
|
>
|
|
136
136
|
{filteredMaterialList.map((materialValue, index) => {
|
|
137
137
|
return (
|