catchup-library-web 1.10.1 → 1.10.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.js +105 -67
- package/dist/index.mjs +99 -61
- 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 +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,10 +4475,10 @@ 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"
|
|
@@ -4467,7 +4486,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4467
4486
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4468
4487
|
if (Object.keys(materialMap).length === 0) return;
|
|
4469
4488
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
4470
|
-
(materialMapKey
|
|
4489
|
+
(materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
|
|
4471
4490
|
);
|
|
4472
4491
|
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
4473
4492
|
}, [showCorrectAnswer]);
|
|
@@ -4637,6 +4656,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4637
4656
|
var FillInTheBlanksActivityMaterialContent_default = FillInTheBlanksActivityMaterialContent;
|
|
4638
4657
|
|
|
4639
4658
|
// src/components/activities/FillInTheBlanksActivityContent.tsx
|
|
4659
|
+
var import_react19 = require("react");
|
|
4640
4660
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
4641
4661
|
var FillInTheBlanksActivityContent = ({
|
|
4642
4662
|
answer,
|
|
@@ -4657,12 +4677,18 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4657
4677
|
"FILL_IN_THE_BLANKS"
|
|
4658
4678
|
);
|
|
4659
4679
|
const fillInTheBlanksIncorrectList = data.fillInTheBlanksIncorrectList ? JSON.parse(data.fillInTheBlanksIncorrectList) : [];
|
|
4660
|
-
const
|
|
4680
|
+
const [currentAnswerMap, setCurrentAnswerMap] = (0, import_react19.useState)(() => {
|
|
4681
|
+
return retrieveCurrentAnswerMap();
|
|
4682
|
+
});
|
|
4683
|
+
function retrieveCurrentAnswerMap() {
|
|
4661
4684
|
let foundIndex = answer.data.findIndex(
|
|
4662
4685
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4663
4686
|
);
|
|
4664
4687
|
return answer.data[foundIndex].answerMap;
|
|
4665
|
-
}
|
|
4688
|
+
}
|
|
4689
|
+
(0, import_react19.useEffect)(() => {
|
|
4690
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
4691
|
+
}, [answer]);
|
|
4666
4692
|
const constructAnswerOptionList = () => {
|
|
4667
4693
|
const optionList = [];
|
|
4668
4694
|
Object.keys(fillInTheBlanksMaterialMap).forEach((key) => {
|
|
@@ -4681,17 +4707,29 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4681
4707
|
});
|
|
4682
4708
|
return optionList;
|
|
4683
4709
|
};
|
|
4684
|
-
const handleFillInTheBlanksAnswerOnChange = (
|
|
4685
|
-
const
|
|
4686
|
-
|
|
4687
|
-
|
|
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);
|
|
4688
4726
|
};
|
|
4689
4727
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex flex-row flex-wrap", children: [
|
|
4690
4728
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4691
4729
|
ActivityBodyContent_default,
|
|
4692
4730
|
{
|
|
4693
4731
|
bodyMap: fillInTheBlanksBodyMap,
|
|
4694
|
-
answerMap:
|
|
4732
|
+
answerMap: currentAnswerMap,
|
|
4695
4733
|
contentMap,
|
|
4696
4734
|
templateType: "FILL_IN_THE_BLANKS"
|
|
4697
4735
|
}
|
|
@@ -4717,22 +4755,22 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4717
4755
|
var FillInTheBlanksActivityContent_default = FillInTheBlanksActivityContent;
|
|
4718
4756
|
|
|
4719
4757
|
// src/components/activities/material-content/GroupingActivityMaterialContent.tsx
|
|
4720
|
-
var
|
|
4758
|
+
var import_react21 = require("react");
|
|
4721
4759
|
var import_react_dnd4 = require("react-dnd");
|
|
4722
4760
|
var import_react_katex4 = require("react-katex");
|
|
4723
4761
|
|
|
4724
4762
|
// src/hooks/useScreenSize.ts
|
|
4725
|
-
var
|
|
4763
|
+
var import_react20 = require("react");
|
|
4726
4764
|
var useScreenSize = () => {
|
|
4727
|
-
const [containerSize, setContainerSize] = (0,
|
|
4765
|
+
const [containerSize, setContainerSize] = (0, import_react20.useState)({
|
|
4728
4766
|
width: 0,
|
|
4729
4767
|
height: 0
|
|
4730
4768
|
});
|
|
4731
|
-
const [screenSize, setScreenSize] = (0,
|
|
4769
|
+
const [screenSize, setScreenSize] = (0, import_react20.useState)({
|
|
4732
4770
|
width: window.innerWidth,
|
|
4733
4771
|
height: window.innerHeight
|
|
4734
4772
|
});
|
|
4735
|
-
(0,
|
|
4773
|
+
(0, import_react20.useEffect)(() => {
|
|
4736
4774
|
const handleResize = () => {
|
|
4737
4775
|
setScreenSize({
|
|
4738
4776
|
width: window.innerWidth,
|
|
@@ -4768,10 +4806,10 @@ var GroupingActivityMaterialContent = ({
|
|
|
4768
4806
|
isPreview,
|
|
4769
4807
|
showCorrectAnswer
|
|
4770
4808
|
}) => {
|
|
4771
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
4772
|
-
const [selectedTargetKey, setSelectedTargetKey] = (0,
|
|
4773
|
-
const [isShuffled, setIsShuffled] = (0,
|
|
4774
|
-
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)([]);
|
|
4775
4813
|
const { screenSize, containerSize } = useScreenSize_default();
|
|
4776
4814
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd4.useDrop)({
|
|
4777
4815
|
accept: "GROUPING",
|
|
@@ -4782,22 +4820,22 @@ var GroupingActivityMaterialContent = ({
|
|
|
4782
4820
|
canDrop: monitor.canDrop()
|
|
4783
4821
|
})
|
|
4784
4822
|
});
|
|
4785
|
-
const ref = (0,
|
|
4786
|
-
const itemsRef = (0,
|
|
4787
|
-
const [maxWidth, setMaxWidth] = (0,
|
|
4788
|
-
(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)(() => {
|
|
4789
4827
|
if (!ref) return;
|
|
4790
4828
|
if (!ref.current) return;
|
|
4791
4829
|
if (!screenSize) return;
|
|
4792
4830
|
setMaxWidth(ref.current.offsetWidth - 12);
|
|
4793
4831
|
}, [ref, screenSize]);
|
|
4794
|
-
(0,
|
|
4832
|
+
(0, import_react21.useEffect)(() => {
|
|
4795
4833
|
if (!itemsRef) return;
|
|
4796
4834
|
if (!itemsRef.current) return;
|
|
4797
4835
|
if (!containerSize) return;
|
|
4798
4836
|
itemsRef.current.style.width = `${containerSize.width - 200}px`;
|
|
4799
4837
|
}, [itemsRef, containerSize]);
|
|
4800
|
-
(0,
|
|
4838
|
+
(0, import_react21.useEffect)(() => {
|
|
4801
4839
|
const shuffleArray2 = (array) => {
|
|
4802
4840
|
if (!isShuffled) {
|
|
4803
4841
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -4818,7 +4856,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
4818
4856
|
});
|
|
4819
4857
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
4820
4858
|
}, []);
|
|
4821
|
-
(0,
|
|
4859
|
+
(0, import_react21.useEffect)(() => {
|
|
4822
4860
|
if (!showCorrectAnswer) return;
|
|
4823
4861
|
answer.data.find(
|
|
4824
4862
|
(answerData) => answerData.type === "GROUPING"
|
|
@@ -5092,7 +5130,7 @@ var GroupingActivityContent = ({
|
|
|
5092
5130
|
var GroupingActivityContent_default = GroupingActivityContent;
|
|
5093
5131
|
|
|
5094
5132
|
// src/components/activities/material-content/MatchingActivityMaterialContent.tsx
|
|
5095
|
-
var
|
|
5133
|
+
var import_react22 = require("react");
|
|
5096
5134
|
var import_react_dnd5 = require("react-dnd");
|
|
5097
5135
|
var import_react_katex5 = require("react-katex");
|
|
5098
5136
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
@@ -5106,10 +5144,10 @@ var MatchingActivityMaterialContent = ({
|
|
|
5106
5144
|
isPreview,
|
|
5107
5145
|
showCorrectAnswer
|
|
5108
5146
|
}) => {
|
|
5109
|
-
const [selectedValue, setSelectedValue] = (0,
|
|
5110
|
-
const [selectedTargetKey, setSelectedTargetKey] = (0,
|
|
5111
|
-
const [isShuffled, setIsShuffled] = (0,
|
|
5112
|
-
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)([]);
|
|
5113
5151
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd5.useDrop)({
|
|
5114
5152
|
accept: "MATCHING",
|
|
5115
5153
|
drop: () => {
|
|
@@ -5120,8 +5158,8 @@ var MatchingActivityMaterialContent = ({
|
|
|
5120
5158
|
})
|
|
5121
5159
|
});
|
|
5122
5160
|
const { containerSize } = useScreenSize_default();
|
|
5123
|
-
const itemsRef = (0,
|
|
5124
|
-
(0,
|
|
5161
|
+
const itemsRef = (0, import_react22.useRef)(null);
|
|
5162
|
+
(0, import_react22.useEffect)(() => {
|
|
5125
5163
|
const shuffleArray2 = (array) => {
|
|
5126
5164
|
if (!isShuffled) {
|
|
5127
5165
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -5140,13 +5178,13 @@ var MatchingActivityMaterialContent = ({
|
|
|
5140
5178
|
});
|
|
5141
5179
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
5142
5180
|
}, []);
|
|
5143
|
-
(0,
|
|
5181
|
+
(0, import_react22.useEffect)(() => {
|
|
5144
5182
|
if (!showCorrectAnswer) return;
|
|
5145
5183
|
answer.data.find(
|
|
5146
5184
|
(answerData) => answerData.type === "MATCHING"
|
|
5147
5185
|
).answerMap = materialMap;
|
|
5148
5186
|
}, [showCorrectAnswer]);
|
|
5149
|
-
(0,
|
|
5187
|
+
(0, import_react22.useEffect)(() => {
|
|
5150
5188
|
if (!itemsRef) return;
|
|
5151
5189
|
if (!itemsRef.current) return;
|
|
5152
5190
|
if (!containerSize) return;
|
|
@@ -5795,12 +5833,12 @@ var OpenEndedActivityContent = ({
|
|
|
5795
5833
|
var OpenEndedActivityContent_default = OpenEndedActivityContent;
|
|
5796
5834
|
|
|
5797
5835
|
// src/components/activities/material-content/OrderingActivityMaterialContent.tsx
|
|
5798
|
-
var
|
|
5836
|
+
var import_react24 = require("react");
|
|
5799
5837
|
var import_react_dnd7 = require("react-dnd");
|
|
5800
5838
|
var import_react_katex8 = require("react-katex");
|
|
5801
5839
|
|
|
5802
5840
|
// src/components/dnds/DraggableDroppableItem.tsx
|
|
5803
|
-
var
|
|
5841
|
+
var import_react23 = require("react");
|
|
5804
5842
|
var import_react_dnd6 = require("react-dnd");
|
|
5805
5843
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
5806
5844
|
var DraggableDroppableItem = ({
|
|
@@ -5813,7 +5851,7 @@ var DraggableDroppableItem = ({
|
|
|
5813
5851
|
target,
|
|
5814
5852
|
setTarget
|
|
5815
5853
|
}) => {
|
|
5816
|
-
const ref = (0,
|
|
5854
|
+
const ref = (0, import_react23.useRef)(null);
|
|
5817
5855
|
const [, drop] = (0, import_react_dnd6.useDrop)({
|
|
5818
5856
|
accept: type,
|
|
5819
5857
|
hover() {
|
|
@@ -5864,10 +5902,10 @@ var OrderingActivityMaterialContent = ({
|
|
|
5864
5902
|
isPreview,
|
|
5865
5903
|
showCorrectAnswer
|
|
5866
5904
|
}) => {
|
|
5867
|
-
const [selectedTargetKey, setSelectedTargetKey] = (0,
|
|
5868
|
-
const [selectedKey, setSelectedKey] = (0,
|
|
5905
|
+
const [selectedTargetKey, setSelectedTargetKey] = (0, import_react24.useState)(null);
|
|
5906
|
+
const [selectedKey, setSelectedKey] = (0, import_react24.useState)(null);
|
|
5869
5907
|
const { screenSize } = useScreenSize_default();
|
|
5870
|
-
const [view, setView] = (0,
|
|
5908
|
+
const [view, setView] = (0, import_react24.useState)("PC");
|
|
5871
5909
|
const [{ isOver, canDrop }, drop] = (0, import_react_dnd7.useDrop)({
|
|
5872
5910
|
accept: "ORDERING",
|
|
5873
5911
|
drop: () => {
|
|
@@ -5877,7 +5915,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5877
5915
|
canDrop: monitor.canDrop()
|
|
5878
5916
|
})
|
|
5879
5917
|
});
|
|
5880
|
-
(0,
|
|
5918
|
+
(0, import_react24.useEffect)(() => {
|
|
5881
5919
|
if (!screenSize) return;
|
|
5882
5920
|
if (screenSize.width <= 768) {
|
|
5883
5921
|
setView("TABLET");
|
|
@@ -5885,7 +5923,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5885
5923
|
setView("PC");
|
|
5886
5924
|
}
|
|
5887
5925
|
}, [screenSize]);
|
|
5888
|
-
(0,
|
|
5926
|
+
(0, import_react24.useEffect)(() => {
|
|
5889
5927
|
if (!showCorrectAnswer) return;
|
|
5890
5928
|
const answerMap2 = answer.data.find(
|
|
5891
5929
|
(answerData) => answerData.type === "ORDERING"
|
|
@@ -6062,7 +6100,7 @@ var OrderingActivityContent = ({
|
|
|
6062
6100
|
var OrderingActivityContent_default = OrderingActivityContent;
|
|
6063
6101
|
|
|
6064
6102
|
// src/components/activities/material-content/TrueFalseActivityMaterialContent.tsx
|
|
6065
|
-
var
|
|
6103
|
+
var import_react25 = require("react");
|
|
6066
6104
|
var import_react_katex9 = require("react-katex");
|
|
6067
6105
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
6068
6106
|
var TrueFalseActivityMaterialContent = ({
|
|
@@ -6076,8 +6114,8 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
6076
6114
|
showCorrectAnswer
|
|
6077
6115
|
}) => {
|
|
6078
6116
|
const { screenSize } = useScreenSize_default();
|
|
6079
|
-
const [shuffleOptionList, setShuffleOptionList] = (0,
|
|
6080
|
-
(0,
|
|
6117
|
+
const [shuffleOptionList, setShuffleOptionList] = (0, import_react25.useState)([]);
|
|
6118
|
+
(0, import_react25.useEffect)(() => {
|
|
6081
6119
|
const optionList = [];
|
|
6082
6120
|
optionList.push(...materialMap.trueList);
|
|
6083
6121
|
optionList.push(...materialMap.falseList);
|
|
@@ -6087,7 +6125,7 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
6087
6125
|
setShuffleOptionList(shuffleArray(optionList));
|
|
6088
6126
|
}
|
|
6089
6127
|
}, []);
|
|
6090
|
-
(0,
|
|
6128
|
+
(0, import_react25.useEffect)(() => {
|
|
6091
6129
|
if (!showCorrectAnswer) return;
|
|
6092
6130
|
answer.data.find(
|
|
6093
6131
|
(answerData) => answerData.type === "TRUE_FALSE"
|
|
@@ -6395,7 +6433,7 @@ var ActivityEvaluationRubricContent = ({
|
|
|
6395
6433
|
var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
|
|
6396
6434
|
|
|
6397
6435
|
// src/components/activities/ActivityPreviewByData.tsx
|
|
6398
|
-
var
|
|
6436
|
+
var import_react26 = require("react");
|
|
6399
6437
|
|
|
6400
6438
|
// src/components/boxes/SelectionBox.tsx
|
|
6401
6439
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
@@ -6447,14 +6485,14 @@ var ActivityPreviewByData = ({
|
|
|
6447
6485
|
showTaxonomy,
|
|
6448
6486
|
isFullScreen
|
|
6449
6487
|
}) => {
|
|
6450
|
-
const [key, setKey] = (0,
|
|
6451
|
-
const [selectedType, setSelectedType] = (0,
|
|
6452
|
-
const [optionList, setOptionList] = (0,
|
|
6453
|
-
(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)(() => {
|
|
6454
6492
|
if (!data) return;
|
|
6455
6493
|
setKey((/* @__PURE__ */ new Date()).getTime());
|
|
6456
6494
|
}, [data]);
|
|
6457
|
-
(0,
|
|
6495
|
+
(0, import_react26.useEffect)(() => {
|
|
6458
6496
|
if (!typeOptionList) return;
|
|
6459
6497
|
if (typeOptionList.length === 0) return;
|
|
6460
6498
|
let foundTypeOption;
|
|
@@ -6469,7 +6507,7 @@ var ActivityPreviewByData = ({
|
|
|
6469
6507
|
setSelectedType(typeOptionList[0].id);
|
|
6470
6508
|
}
|
|
6471
6509
|
}, [typeOptionList, lockedType]);
|
|
6472
|
-
(0,
|
|
6510
|
+
(0, import_react26.useEffect)(() => {
|
|
6473
6511
|
const retrieveTaxonomyNameByActivityTypeFromData = (type) => {
|
|
6474
6512
|
let taxonomyMap = {
|
|
6475
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,10 +4276,10 @@ 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"
|
|
@@ -4268,7 +4287,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4268
4287
|
if (foundAnswer.answerMap.length === 0) return;
|
|
4269
4288
|
if (Object.keys(materialMap).length === 0) return;
|
|
4270
4289
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
4271
|
-
(materialMapKey
|
|
4290
|
+
(materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
|
|
4272
4291
|
);
|
|
4273
4292
|
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|
|
4274
4293
|
}, [showCorrectAnswer]);
|
|
@@ -4438,6 +4457,7 @@ var FillInTheBlanksActivityMaterialContent = ({
|
|
|
4438
4457
|
var FillInTheBlanksActivityMaterialContent_default = FillInTheBlanksActivityMaterialContent;
|
|
4439
4458
|
|
|
4440
4459
|
// src/components/activities/FillInTheBlanksActivityContent.tsx
|
|
4460
|
+
import { useState as useState15, useEffect as useEffect7 } from "react";
|
|
4441
4461
|
import { jsx as jsx24, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4442
4462
|
var FillInTheBlanksActivityContent = ({
|
|
4443
4463
|
answer,
|
|
@@ -4458,12 +4478,18 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4458
4478
|
"FILL_IN_THE_BLANKS"
|
|
4459
4479
|
);
|
|
4460
4480
|
const fillInTheBlanksIncorrectList = data.fillInTheBlanksIncorrectList ? JSON.parse(data.fillInTheBlanksIncorrectList) : [];
|
|
4461
|
-
const
|
|
4481
|
+
const [currentAnswerMap, setCurrentAnswerMap] = useState15(() => {
|
|
4482
|
+
return retrieveCurrentAnswerMap();
|
|
4483
|
+
});
|
|
4484
|
+
function retrieveCurrentAnswerMap() {
|
|
4462
4485
|
let foundIndex = answer.data.findIndex(
|
|
4463
4486
|
(answerData) => answerData.type === "FILL_IN_THE_BLANKS"
|
|
4464
4487
|
);
|
|
4465
4488
|
return answer.data[foundIndex].answerMap;
|
|
4466
|
-
}
|
|
4489
|
+
}
|
|
4490
|
+
useEffect7(() => {
|
|
4491
|
+
setCurrentAnswerMap(retrieveCurrentAnswerMap());
|
|
4492
|
+
}, [answer]);
|
|
4467
4493
|
const constructAnswerOptionList = () => {
|
|
4468
4494
|
const optionList = [];
|
|
4469
4495
|
Object.keys(fillInTheBlanksMaterialMap).forEach((key) => {
|
|
@@ -4482,17 +4508,29 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4482
4508
|
});
|
|
4483
4509
|
return optionList;
|
|
4484
4510
|
};
|
|
4485
|
-
const handleFillInTheBlanksAnswerOnChange = (
|
|
4486
|
-
const
|
|
4487
|
-
|
|
4488
|
-
|
|
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);
|
|
4489
4527
|
};
|
|
4490
4528
|
return /* @__PURE__ */ jsxs15("div", { className: "flex flex-row flex-wrap", children: [
|
|
4491
4529
|
/* @__PURE__ */ jsx24("div", { className: `${isFullScreen ? "w-full" : "w-full md:w-[60%]"}`, children: /* @__PURE__ */ jsx24(
|
|
4492
4530
|
ActivityBodyContent_default,
|
|
4493
4531
|
{
|
|
4494
4532
|
bodyMap: fillInTheBlanksBodyMap,
|
|
4495
|
-
answerMap:
|
|
4533
|
+
answerMap: currentAnswerMap,
|
|
4496
4534
|
contentMap,
|
|
4497
4535
|
templateType: "FILL_IN_THE_BLANKS"
|
|
4498
4536
|
}
|
|
@@ -4518,22 +4556,22 @@ var FillInTheBlanksActivityContent = ({
|
|
|
4518
4556
|
var FillInTheBlanksActivityContent_default = FillInTheBlanksActivityContent;
|
|
4519
4557
|
|
|
4520
4558
|
// src/components/activities/material-content/GroupingActivityMaterialContent.tsx
|
|
4521
|
-
import { useEffect as
|
|
4559
|
+
import { useEffect as useEffect9, useRef as useRef4, useState as useState17 } from "react";
|
|
4522
4560
|
import { useDrop as useDrop3 } from "react-dnd";
|
|
4523
4561
|
import { InlineMath as InlineMath4 } from "react-katex";
|
|
4524
4562
|
|
|
4525
4563
|
// src/hooks/useScreenSize.ts
|
|
4526
|
-
import { useState as
|
|
4564
|
+
import { useState as useState16, useEffect as useEffect8 } from "react";
|
|
4527
4565
|
var useScreenSize = () => {
|
|
4528
|
-
const [containerSize, setContainerSize] =
|
|
4566
|
+
const [containerSize, setContainerSize] = useState16({
|
|
4529
4567
|
width: 0,
|
|
4530
4568
|
height: 0
|
|
4531
4569
|
});
|
|
4532
|
-
const [screenSize, setScreenSize] =
|
|
4570
|
+
const [screenSize, setScreenSize] = useState16({
|
|
4533
4571
|
width: window.innerWidth,
|
|
4534
4572
|
height: window.innerHeight
|
|
4535
4573
|
});
|
|
4536
|
-
|
|
4574
|
+
useEffect8(() => {
|
|
4537
4575
|
const handleResize = () => {
|
|
4538
4576
|
setScreenSize({
|
|
4539
4577
|
width: window.innerWidth,
|
|
@@ -4569,10 +4607,10 @@ var GroupingActivityMaterialContent = ({
|
|
|
4569
4607
|
isPreview,
|
|
4570
4608
|
showCorrectAnswer
|
|
4571
4609
|
}) => {
|
|
4572
|
-
const [selectedValue, setSelectedValue] =
|
|
4573
|
-
const [selectedTargetKey, setSelectedTargetKey] =
|
|
4574
|
-
const [isShuffled, setIsShuffled] =
|
|
4575
|
-
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([]);
|
|
4576
4614
|
const { screenSize, containerSize } = useScreenSize_default();
|
|
4577
4615
|
const [{ isOver, canDrop }, drop] = useDrop3({
|
|
4578
4616
|
accept: "GROUPING",
|
|
@@ -4585,20 +4623,20 @@ var GroupingActivityMaterialContent = ({
|
|
|
4585
4623
|
});
|
|
4586
4624
|
const ref = useRef4(null);
|
|
4587
4625
|
const itemsRef = useRef4(null);
|
|
4588
|
-
const [maxWidth, setMaxWidth] =
|
|
4589
|
-
|
|
4626
|
+
const [maxWidth, setMaxWidth] = useState17(0);
|
|
4627
|
+
useEffect9(() => {
|
|
4590
4628
|
if (!ref) return;
|
|
4591
4629
|
if (!ref.current) return;
|
|
4592
4630
|
if (!screenSize) return;
|
|
4593
4631
|
setMaxWidth(ref.current.offsetWidth - 12);
|
|
4594
4632
|
}, [ref, screenSize]);
|
|
4595
|
-
|
|
4633
|
+
useEffect9(() => {
|
|
4596
4634
|
if (!itemsRef) return;
|
|
4597
4635
|
if (!itemsRef.current) return;
|
|
4598
4636
|
if (!containerSize) return;
|
|
4599
4637
|
itemsRef.current.style.width = `${containerSize.width - 200}px`;
|
|
4600
4638
|
}, [itemsRef, containerSize]);
|
|
4601
|
-
|
|
4639
|
+
useEffect9(() => {
|
|
4602
4640
|
const shuffleArray2 = (array) => {
|
|
4603
4641
|
if (!isShuffled) {
|
|
4604
4642
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -4619,7 +4657,7 @@ var GroupingActivityMaterialContent = ({
|
|
|
4619
4657
|
});
|
|
4620
4658
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
4621
4659
|
}, []);
|
|
4622
|
-
|
|
4660
|
+
useEffect9(() => {
|
|
4623
4661
|
if (!showCorrectAnswer) return;
|
|
4624
4662
|
answer.data.find(
|
|
4625
4663
|
(answerData) => answerData.type === "GROUPING"
|
|
@@ -4893,7 +4931,7 @@ var GroupingActivityContent = ({
|
|
|
4893
4931
|
var GroupingActivityContent_default = GroupingActivityContent;
|
|
4894
4932
|
|
|
4895
4933
|
// src/components/activities/material-content/MatchingActivityMaterialContent.tsx
|
|
4896
|
-
import { useEffect as
|
|
4934
|
+
import { useEffect as useEffect10, useRef as useRef5, useState as useState18 } from "react";
|
|
4897
4935
|
import { useDrop as useDrop4 } from "react-dnd";
|
|
4898
4936
|
import { InlineMath as InlineMath5 } from "react-katex";
|
|
4899
4937
|
import { Fragment as Fragment3, jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -4907,10 +4945,10 @@ var MatchingActivityMaterialContent = ({
|
|
|
4907
4945
|
isPreview,
|
|
4908
4946
|
showCorrectAnswer
|
|
4909
4947
|
}) => {
|
|
4910
|
-
const [selectedValue, setSelectedValue] =
|
|
4911
|
-
const [selectedTargetKey, setSelectedTargetKey] =
|
|
4912
|
-
const [isShuffled, setIsShuffled] =
|
|
4913
|
-
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([]);
|
|
4914
4952
|
const [{ isOver, canDrop }, drop] = useDrop4({
|
|
4915
4953
|
accept: "MATCHING",
|
|
4916
4954
|
drop: () => {
|
|
@@ -4922,7 +4960,7 @@ var MatchingActivityMaterialContent = ({
|
|
|
4922
4960
|
});
|
|
4923
4961
|
const { containerSize } = useScreenSize_default();
|
|
4924
4962
|
const itemsRef = useRef5(null);
|
|
4925
|
-
|
|
4963
|
+
useEffect10(() => {
|
|
4926
4964
|
const shuffleArray2 = (array) => {
|
|
4927
4965
|
if (!isShuffled) {
|
|
4928
4966
|
const copyArray = JSON.parse(JSON.stringify(array));
|
|
@@ -4941,13 +4979,13 @@ var MatchingActivityMaterialContent = ({
|
|
|
4941
4979
|
});
|
|
4942
4980
|
setShuffledMaterialList(shuffleArray2(materialList));
|
|
4943
4981
|
}, []);
|
|
4944
|
-
|
|
4982
|
+
useEffect10(() => {
|
|
4945
4983
|
if (!showCorrectAnswer) return;
|
|
4946
4984
|
answer.data.find(
|
|
4947
4985
|
(answerData) => answerData.type === "MATCHING"
|
|
4948
4986
|
).answerMap = materialMap;
|
|
4949
4987
|
}, [showCorrectAnswer]);
|
|
4950
|
-
|
|
4988
|
+
useEffect10(() => {
|
|
4951
4989
|
if (!itemsRef) return;
|
|
4952
4990
|
if (!itemsRef.current) return;
|
|
4953
4991
|
if (!containerSize) return;
|
|
@@ -5596,7 +5634,7 @@ var OpenEndedActivityContent = ({
|
|
|
5596
5634
|
var OpenEndedActivityContent_default = OpenEndedActivityContent;
|
|
5597
5635
|
|
|
5598
5636
|
// src/components/activities/material-content/OrderingActivityMaterialContent.tsx
|
|
5599
|
-
import { useEffect as
|
|
5637
|
+
import { useEffect as useEffect11, useState as useState19 } from "react";
|
|
5600
5638
|
import { useDrop as useDrop6 } from "react-dnd";
|
|
5601
5639
|
import { InlineMath as InlineMath8 } from "react-katex";
|
|
5602
5640
|
|
|
@@ -5665,10 +5703,10 @@ var OrderingActivityMaterialContent = ({
|
|
|
5665
5703
|
isPreview,
|
|
5666
5704
|
showCorrectAnswer
|
|
5667
5705
|
}) => {
|
|
5668
|
-
const [selectedTargetKey, setSelectedTargetKey] =
|
|
5669
|
-
const [selectedKey, setSelectedKey] =
|
|
5706
|
+
const [selectedTargetKey, setSelectedTargetKey] = useState19(null);
|
|
5707
|
+
const [selectedKey, setSelectedKey] = useState19(null);
|
|
5670
5708
|
const { screenSize } = useScreenSize_default();
|
|
5671
|
-
const [view, setView] =
|
|
5709
|
+
const [view, setView] = useState19("PC");
|
|
5672
5710
|
const [{ isOver, canDrop }, drop] = useDrop6({
|
|
5673
5711
|
accept: "ORDERING",
|
|
5674
5712
|
drop: () => {
|
|
@@ -5678,7 +5716,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5678
5716
|
canDrop: monitor.canDrop()
|
|
5679
5717
|
})
|
|
5680
5718
|
});
|
|
5681
|
-
|
|
5719
|
+
useEffect11(() => {
|
|
5682
5720
|
if (!screenSize) return;
|
|
5683
5721
|
if (screenSize.width <= 768) {
|
|
5684
5722
|
setView("TABLET");
|
|
@@ -5686,7 +5724,7 @@ var OrderingActivityMaterialContent = ({
|
|
|
5686
5724
|
setView("PC");
|
|
5687
5725
|
}
|
|
5688
5726
|
}, [screenSize]);
|
|
5689
|
-
|
|
5727
|
+
useEffect11(() => {
|
|
5690
5728
|
if (!showCorrectAnswer) return;
|
|
5691
5729
|
const answerMap2 = answer.data.find(
|
|
5692
5730
|
(answerData) => answerData.type === "ORDERING"
|
|
@@ -5863,7 +5901,7 @@ var OrderingActivityContent = ({
|
|
|
5863
5901
|
var OrderingActivityContent_default = OrderingActivityContent;
|
|
5864
5902
|
|
|
5865
5903
|
// src/components/activities/material-content/TrueFalseActivityMaterialContent.tsx
|
|
5866
|
-
import { useEffect as
|
|
5904
|
+
import { useEffect as useEffect12, useState as useState20 } from "react";
|
|
5867
5905
|
import { InlineMath as InlineMath9 } from "react-katex";
|
|
5868
5906
|
import { Fragment as Fragment8, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
5869
5907
|
var TrueFalseActivityMaterialContent = ({
|
|
@@ -5877,8 +5915,8 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
5877
5915
|
showCorrectAnswer
|
|
5878
5916
|
}) => {
|
|
5879
5917
|
const { screenSize } = useScreenSize_default();
|
|
5880
|
-
const [shuffleOptionList, setShuffleOptionList] =
|
|
5881
|
-
|
|
5918
|
+
const [shuffleOptionList, setShuffleOptionList] = useState20([]);
|
|
5919
|
+
useEffect12(() => {
|
|
5882
5920
|
const optionList = [];
|
|
5883
5921
|
optionList.push(...materialMap.trueList);
|
|
5884
5922
|
optionList.push(...materialMap.falseList);
|
|
@@ -5888,7 +5926,7 @@ var TrueFalseActivityMaterialContent = ({
|
|
|
5888
5926
|
setShuffleOptionList(shuffleArray(optionList));
|
|
5889
5927
|
}
|
|
5890
5928
|
}, []);
|
|
5891
|
-
|
|
5929
|
+
useEffect12(() => {
|
|
5892
5930
|
if (!showCorrectAnswer) return;
|
|
5893
5931
|
answer.data.find(
|
|
5894
5932
|
(answerData) => answerData.type === "TRUE_FALSE"
|
|
@@ -6196,7 +6234,7 @@ var ActivityEvaluationRubricContent = ({
|
|
|
6196
6234
|
var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
|
|
6197
6235
|
|
|
6198
6236
|
// src/components/activities/ActivityPreviewByData.tsx
|
|
6199
|
-
import { useEffect as
|
|
6237
|
+
import { useEffect as useEffect13, useState as useState21 } from "react";
|
|
6200
6238
|
|
|
6201
6239
|
// src/components/boxes/SelectionBox.tsx
|
|
6202
6240
|
import { jsx as jsx42, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
@@ -6248,14 +6286,14 @@ var ActivityPreviewByData = ({
|
|
|
6248
6286
|
showTaxonomy,
|
|
6249
6287
|
isFullScreen
|
|
6250
6288
|
}) => {
|
|
6251
|
-
const [key, setKey] =
|
|
6252
|
-
const [selectedType, setSelectedType] =
|
|
6253
|
-
const [optionList, setOptionList] =
|
|
6254
|
-
|
|
6289
|
+
const [key, setKey] = useState21((/* @__PURE__ */ new Date()).getTime());
|
|
6290
|
+
const [selectedType, setSelectedType] = useState21(null);
|
|
6291
|
+
const [optionList, setOptionList] = useState21([]);
|
|
6292
|
+
useEffect13(() => {
|
|
6255
6293
|
if (!data) return;
|
|
6256
6294
|
setKey((/* @__PURE__ */ new Date()).getTime());
|
|
6257
6295
|
}, [data]);
|
|
6258
|
-
|
|
6296
|
+
useEffect13(() => {
|
|
6259
6297
|
if (!typeOptionList) return;
|
|
6260
6298
|
if (typeOptionList.length === 0) return;
|
|
6261
6299
|
let foundTypeOption;
|
|
@@ -6270,7 +6308,7 @@ var ActivityPreviewByData = ({
|
|
|
6270
6308
|
setSelectedType(typeOptionList[0].id);
|
|
6271
6309
|
}
|
|
6272
6310
|
}, [typeOptionList, lockedType]);
|
|
6273
|
-
|
|
6311
|
+
useEffect13(() => {
|
|
6274
6312
|
const retrieveTaxonomyNameByActivityTypeFromData = (type) => {
|
|
6275
6313
|
let taxonomyMap = {
|
|
6276
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
|
@@ -48,7 +48,7 @@ const FillInTheBlanksActivityMaterialContent = ({
|
|
|
48
48
|
if (foundAnswer.answerMap.length === 0) return;
|
|
49
49
|
if (Object.keys(materialMap).length === 0) return;
|
|
50
50
|
foundAnswer.answerMap = Object.keys(materialMap).map(
|
|
51
|
-
(materialMapKey
|
|
51
|
+
(materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
|
|
52
52
|
);
|
|
53
53
|
|
|
54
54
|
onChange(answer, 0, JSON.parse(materialMap[0])[0]);
|