catchup-library-web 2.2.2 → 2.2.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.mjs CHANGED
@@ -4348,19 +4348,20 @@ var DropdownActivityMaterialContent = ({
4348
4348
  isPreview,
4349
4349
  showCorrectAnswer
4350
4350
  }) => {
4351
- const [updated, setUpdated] = useState15(false);
4351
+ const [displayAnswerMap, setDisplayAnswerMap] = useState15(answerMap);
4352
4352
  useEffect6(() => {
4353
- if (!showCorrectAnswer) return;
4354
- answerMap = Object.keys(materialMap).map(
4355
- (materialMapKey, index) => Object.keys(materialMap[materialMapKey])[0]
4356
- );
4357
- onChange(answerMap, 0, Object.keys(materialMap[0])[0]);
4358
- setUpdated(true);
4359
- }, [showCorrectAnswer]);
4360
- useEffect6(() => {
4361
- if (!updated) return;
4362
- setUpdated(false);
4363
- }, [updated]);
4353
+ if (showCorrectAnswer) {
4354
+ const correctAnswerMap = {};
4355
+ Object.keys(materialMap).forEach((materialMapKey) => {
4356
+ correctAnswerMap[materialMapKey] = Object.keys(
4357
+ materialMap[materialMapKey]
4358
+ )[0];
4359
+ });
4360
+ setDisplayAnswerMap(correctAnswerMap);
4361
+ } else {
4362
+ setDisplayAnswerMap(answerMap);
4363
+ }
4364
+ }, [showCorrectAnswer, answerMap, materialMap]);
4364
4365
  const checkAnswerState = (correctAnswer, learnerAnswer) => {
4365
4366
  if (!isPreview) return null;
4366
4367
  if (correctAnswer === learnerAnswer) {
@@ -4371,66 +4372,66 @@ var DropdownActivityMaterialContent = ({
4371
4372
  return /* @__PURE__ */ jsxs15("div", { className: "flex flex-row flex-wrap items-center", children: [
4372
4373
  /* @__PURE__ */ jsx25("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx25("span", { className: "font-semibold text-xl opacity-60", children: i18n_default.t("please_select_dropdown_text") }) }),
4373
4374
  /* @__PURE__ */ jsx25("div", { className: "hidden md:contents", children: /* @__PURE__ */ jsx25(DividerLine_default, {}) }),
4374
- /* @__PURE__ */ jsx25("div", { className: "w-full flex flex-row flex-wrap", children: Object.keys(answerMap).map((materialKey, index) => {
4375
- const answerKey = Object.keys(materialMap[materialKey])[0];
4376
- const learnerAnswerState = checkAnswerState(
4377
- answerKey,
4378
- answerMap[materialKey]
4379
- );
4380
- return /* @__PURE__ */ jsx25("div", { className: "w-full md:w-1/2", children: /* @__PURE__ */ jsx25("div", { className: "mx-2", children: /* @__PURE__ */ jsxs15("div", { className: "w-full flex flex-row my-2 gap-x-2", children: [
4381
- /* @__PURE__ */ jsx25("div", { className: "my-auto", children: /* @__PURE__ */ jsxs15("p", { className: "text-xl", children: [
4382
- parseFloat(materialKey) + 1,
4383
- "."
4384
- ] }) }),
4385
- /* @__PURE__ */ jsxs15("div", { className: "w-full relative", children: [
4386
- /* @__PURE__ */ jsx25("div", { className: "flex-1", children: checkCanAnswerQuestion() ? contentMap.type === "TEXT" ? /* @__PURE__ */ jsx25("div", { className: "flex-1", children: /* @__PURE__ */ jsx25(
4387
- InputGroup_default,
4388
- {
4389
- type: "select",
4390
- value: answerMap[materialKey],
4391
- optionList: shuffleArray(
4392
- materialMap[materialKey][answerKey]
4393
- ).map((materialOption) => ({
4394
- text: /* @__PURE__ */ jsx25("span", { className: "text-xl whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
4395
- materialOption
4396
- ).map((inputPart, index2) => /* @__PURE__ */ jsx25(
4397
- "span",
4375
+ /* @__PURE__ */ jsx25("div", { className: "w-full flex flex-row flex-wrap", children: Object.keys(displayAnswerMap).map(
4376
+ (materialKey, index) => {
4377
+ const answerKey = Object.keys(materialMap[materialKey])[0];
4378
+ const learnerAnswerState = checkAnswerState(
4379
+ answerKey,
4380
+ displayAnswerMap[materialKey]
4381
+ );
4382
+ return /* @__PURE__ */ jsx25("div", { className: "w-full md:w-1/2", children: /* @__PURE__ */ jsx25("div", { className: "mx-2", children: /* @__PURE__ */ jsxs15("div", { className: "w-full flex flex-row my-2 gap-x-2", children: [
4383
+ /* @__PURE__ */ jsx25("div", { className: "my-auto", children: /* @__PURE__ */ jsxs15("p", { className: "text-xl", children: [
4384
+ parseFloat(materialKey) + 1,
4385
+ "."
4386
+ ] }) }),
4387
+ /* @__PURE__ */ jsxs15("div", { className: "w-full relative", children: [
4388
+ /* @__PURE__ */ jsx25("div", { className: "flex-1", children: checkCanAnswerQuestion() ? contentMap.type === "TEXT" ? /* @__PURE__ */ jsx25("div", { className: "flex-1", children: /* @__PURE__ */ jsx25(
4389
+ InputGroup_default,
4390
+ {
4391
+ type: "select",
4392
+ value: displayAnswerMap[materialKey],
4393
+ optionList: shuffleArray(
4394
+ materialMap[materialKey][answerKey]
4395
+ ).map((materialOption) => ({
4396
+ text: /* @__PURE__ */ jsx25("span", { className: "text-xl whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
4397
+ materialOption
4398
+ ).map((inputPart, index2) => /* @__PURE__ */ jsx25(
4399
+ "span",
4400
+ {
4401
+ className: `${inputPart.isBold ? "font-bold" : ""} ${inputPart.isUnderline ? "underline" : ""}`,
4402
+ children: inputPart.isEquation ? /* @__PURE__ */ jsx25("span", { className: "text-xl", children: /* @__PURE__ */ jsx25(
4403
+ InlineMath2,
4404
+ {
4405
+ math: inputPart.value
4406
+ }
4407
+ ) }) : inputPart.value
4408
+ },
4409
+ index2
4410
+ )) }),
4411
+ value: materialOption
4412
+ })),
4413
+ onChange: (e) => {
4414
+ onChange(
4415
+ answerMap,
4416
+ materialKey,
4417
+ e.target.value
4418
+ );
4419
+ }
4420
+ }
4421
+ ) }) : /* @__PURE__ */ jsx25(
4422
+ MediaDropdown_default,
4423
+ {
4424
+ id: materialKey,
4425
+ answer: displayAnswerMap[materialKey] === "DEFAULT_OPTION" ? /* @__PURE__ */ jsx25("div", { className: "w-catchup-activity-media-box-item h-catchup-activity-media-box-item border rounded-catchup-xlarge border-dashed border-catchup-blue", children: /* @__PURE__ */ jsx25("div", { className: "h-full flex flex-col items-center justify-center px-4 py-2", children: /* @__PURE__ */ jsx25("span", { className: "italic", children: i18n_default.t("please_select") }) }) }) : /* @__PURE__ */ jsx25(
4426
+ ShowMaterialMediaByContentType_default,
4398
4427
  {
4399
- className: `${inputPart.isBold ? "font-bold" : ""} ${inputPart.isUnderline ? "underline" : ""}`,
4400
- children: inputPart.isEquation ? /* @__PURE__ */ jsx25("span", { className: "text-xl", children: /* @__PURE__ */ jsx25(
4401
- InlineMath2,
4402
- {
4403
- math: inputPart.value
4404
- }
4405
- ) }) : inputPart.value
4428
+ contentType: contentMap.type,
4429
+ src: displayAnswerMap[materialKey],
4430
+ canFullScreen: false
4406
4431
  },
4407
- index2
4408
- )) }),
4409
- value: materialOption
4410
- })),
4411
- onChange: (e) => {
4412
- onChange(
4413
- answerMap,
4414
- materialKey,
4415
- e.target.value
4416
- );
4417
- }
4418
- }
4419
- ) }) : /* @__PURE__ */ jsx25(
4420
- MediaDropdown_default,
4421
- {
4422
- id: materialKey,
4423
- answer: answerMap[materialKey] === "DEFAULT_OPTION" ? /* @__PURE__ */ jsx25("div", { className: "w-catchup-activity-media-box-item h-catchup-activity-media-box-item border rounded-catchup-xlarge border-dashed border-catchup-blue", children: /* @__PURE__ */ jsx25("div", { className: "h-full flex flex-col items-center justify-center px-4 py-2", children: /* @__PURE__ */ jsx25("span", { className: "italic", children: i18n_default.t("please_select") }) }) }) : /* @__PURE__ */ jsx25(
4424
- ShowMaterialMediaByContentType_default,
4425
- {
4426
- contentType: contentMap.type,
4427
- src: answerMap[materialKey],
4428
- canFullScreen: false
4429
- },
4430
- `${uniqueValue}-${index}`
4431
- ),
4432
- optionList: materialMap[materialKey][answerKey].map(
4433
- (materialOption, index2) => ({
4432
+ `${uniqueValue}-${index}`
4433
+ ),
4434
+ optionList: materialMap[materialKey][answerKey].map((materialOption, index2) => ({
4434
4435
  id: index2,
4435
4436
  media: /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(
4436
4437
  ShowMaterialMediaByContentType_default,
@@ -4448,37 +4449,37 @@ var DropdownActivityMaterialContent = ({
4448
4449
  e.target.currentSrc
4449
4450
  );
4450
4451
  }
4451
- })
4452
- )
4453
- }
4454
- ) : /* @__PURE__ */ jsx25("p", { className: "text-xl whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
4455
- answerMap[materialKey]
4456
- ).map((inputPart, index2) => /* @__PURE__ */ jsx25(
4457
- "span",
4458
- {
4459
- className: `${inputPart.isBold ? "font-bold" : ""} ${inputPart.isUnderline ? "underline" : ""}`,
4460
- children: inputPart.isEquation ? /* @__PURE__ */ jsx25("span", { className: "text-xl", children: /* @__PURE__ */ jsx25(InlineMath2, { math: inputPart.value }) }) : inputPart.value
4461
- },
4462
- index2
4463
- )) }) }),
4464
- learnerAnswerState === "CORRECT" ? /* @__PURE__ */ jsx25("div", { className: "absolute -top-2 right-3 bg-catchup-white", children: /* @__PURE__ */ jsx25(
4465
- BaseImage_default,
4466
- {
4467
- src: "/icons/checkbox.webp",
4468
- alt: "chekbbox",
4469
- size: "small"
4470
- }
4471
- ) }) : learnerAnswerState === "INCORRECT" ? /* @__PURE__ */ jsx25("div", { className: "absolute -top-2 right-3 bg-catchup-white", children: /* @__PURE__ */ jsx25(
4472
- BaseImage_default,
4473
- {
4474
- src: "/icons/cross-red.webp",
4475
- alt: "cross-red",
4476
- size: "small"
4477
- }
4478
- ) }) : null
4479
- ] })
4480
- ] }) }) }, index);
4481
- }) })
4452
+ }))
4453
+ }
4454
+ ) : /* @__PURE__ */ jsx25("p", { className: "text-xl whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
4455
+ displayAnswerMap[materialKey]
4456
+ ).map((inputPart, index2) => /* @__PURE__ */ jsx25(
4457
+ "span",
4458
+ {
4459
+ className: `${inputPart.isBold ? "font-bold" : ""} ${inputPart.isUnderline ? "underline" : ""}`,
4460
+ children: inputPart.isEquation ? /* @__PURE__ */ jsx25("span", { className: "text-xl", children: /* @__PURE__ */ jsx25(InlineMath2, { math: inputPart.value }) }) : inputPart.value
4461
+ },
4462
+ index2
4463
+ )) }) }),
4464
+ learnerAnswerState === "CORRECT" ? /* @__PURE__ */ jsx25("div", { className: "absolute -top-2 right-3 bg-catchup-white", children: /* @__PURE__ */ jsx25(
4465
+ BaseImage_default,
4466
+ {
4467
+ src: "/icons/checkbox.webp",
4468
+ alt: "chekbbox",
4469
+ size: "small"
4470
+ }
4471
+ ) }) : learnerAnswerState === "INCORRECT" ? /* @__PURE__ */ jsx25("div", { className: "absolute -top-2 right-3 bg-catchup-white", children: /* @__PURE__ */ jsx25(
4472
+ BaseImage_default,
4473
+ {
4474
+ src: "/icons/cross-red.webp",
4475
+ alt: "cross-red",
4476
+ size: "small"
4477
+ }
4478
+ ) }) : null
4479
+ ] })
4480
+ ] }) }) }, index);
4481
+ }
4482
+ ) })
4482
4483
  ] });
4483
4484
  };
4484
4485
  var DropdownActivityMaterialContent_default = DropdownActivityMaterialContent;
@@ -4585,6 +4586,7 @@ var FillInTheBlanksActivityMaterialContent = ({
4585
4586
  const [draggedElement, setDraggedElement] = useState17(
4586
4587
  null
4587
4588
  );
4589
+ const [displayAnswerMap, setDisplayAnswerMap] = useState17(answerMap);
4588
4590
  const dragElementRef = useRef4(null);
4589
4591
  const [mousePosition, setMousePosition] = useState17({
4590
4592
  x: 0,
@@ -4598,12 +4600,18 @@ var FillInTheBlanksActivityMaterialContent = ({
4598
4600
  setShuffleOptionList(shuffleArray(optionList));
4599
4601
  }, [optionList]);
4600
4602
  useEffect8(() => {
4601
- if (!showCorrectAnswer) return;
4602
- answerMap = Object.keys(materialMap).map(
4603
- (materialMapKey) => JSON.parse(materialMap[materialMapKey])[0]
4604
- );
4605
- onChange(answerMap, 0, JSON.parse(materialMap[0])[0]);
4606
- }, [showCorrectAnswer]);
4603
+ if (showCorrectAnswer) {
4604
+ const correctAnswerMap = {};
4605
+ Object.keys(materialMap).forEach((materialMapKey) => {
4606
+ correctAnswerMap[materialMapKey] = JSON.parse(
4607
+ materialMap[materialMapKey]
4608
+ )[0];
4609
+ });
4610
+ setDisplayAnswerMap(correctAnswerMap);
4611
+ } else {
4612
+ setDisplayAnswerMap(answerMap);
4613
+ }
4614
+ }, [showCorrectAnswer, answerMap, materialMap]);
4607
4615
  const checkAnswerState = (correctAnswerList, learnerAnswer) => {
4608
4616
  if (!isPreview) return null;
4609
4617
  const foundIndex = correctAnswerList.findIndex(
@@ -4614,8 +4622,10 @@ var FillInTheBlanksActivityMaterialContent = ({
4614
4622
  }
4615
4623
  return "INCORRECT";
4616
4624
  };
4617
- const checkAnswerProvided = (answerMap2, option) => {
4618
- return Object.keys(answerMap2).findIndex((key) => answerMap2[key] === option) !== -1;
4625
+ const checkAnswerProvided = (currentAnswerMap, option) => {
4626
+ return Object.keys(currentAnswerMap).findIndex(
4627
+ (key) => currentAnswerMap[key] === option
4628
+ ) !== -1;
4619
4629
  };
4620
4630
  const handleMouseDown = (e, option) => {
4621
4631
  e.preventDefault();
@@ -4747,7 +4757,7 @@ var FillInTheBlanksActivityMaterialContent = ({
4747
4757
  }
4748
4758
  ),
4749
4759
  /* @__PURE__ */ jsx28("div", { className: "w-full flex flex-row flex-wrap gap-x-2 gap-y-2 my-2", children: shuffleOptionList.map(
4750
- (option, index) => checkAnswerProvided(answerMap, option) ? /* @__PURE__ */ jsx28(
4760
+ (option, index) => checkAnswerProvided(displayAnswerMap, option) ? /* @__PURE__ */ jsx28(
4751
4761
  ShowMaterialMediaByContentType_default,
4752
4762
  {
4753
4763
  contentType: contentMap.type,
@@ -4797,10 +4807,10 @@ var FillInTheBlanksActivityMaterialContent = ({
4797
4807
  index
4798
4808
  )
4799
4809
  ) }),
4800
- /* @__PURE__ */ jsx28("div", { className: "w-full flex flex-row flex-wrap", children: Object.keys(answerMap).map((materialKey, index) => {
4810
+ /* @__PURE__ */ jsx28("div", { className: "w-full flex flex-row flex-wrap", children: Object.keys(displayAnswerMap).map((materialKey, index) => {
4801
4811
  const learnerAnswerState = checkAnswerState(
4802
4812
  JSON.parse(materialMap[materialKey]),
4803
- answerMap[materialKey]
4813
+ displayAnswerMap[materialKey]
4804
4814
  );
4805
4815
  return /* @__PURE__ */ jsx28("div", { className: "w-full md:w-1/2", children: /* @__PURE__ */ jsx28("div", { className: "mx-2", children: /* @__PURE__ */ jsx28(
4806
4816
  "div",
@@ -4819,17 +4829,17 @@ var FillInTheBlanksActivityMaterialContent = ({
4819
4829
  /* @__PURE__ */ jsx28("div", { className: "flex-1", children: /* @__PURE__ */ jsx28(
4820
4830
  "div",
4821
4831
  {
4822
- className: `w-full min-h-[44px] border rounded-lg ${answerMap[materialKey] ? "border-catchup-blue-400 px-2 cursor-pointer" : "bg-catchup-gray-50 border-catchup-gray-200 border-dashed py-2 px-4"}`,
4832
+ className: `w-full min-h-[44px] border rounded-lg ${displayAnswerMap[materialKey] ? "border-catchup-blue-400 px-2 cursor-pointer" : "bg-catchup-gray-50 border-catchup-gray-200 border-dashed py-2 px-4"}`,
4823
4833
  onClick: (e) => {
4824
- if (answerMap[materialKey]) {
4834
+ if (displayAnswerMap[materialKey]) {
4825
4835
  e.stopPropagation();
4826
4836
  onChange(answerMap, materialKey, "");
4827
4837
  }
4828
4838
  },
4829
- children: answerMap[materialKey] ? /* @__PURE__ */ jsx28(
4839
+ children: displayAnswerMap[materialKey] ? /* @__PURE__ */ jsx28(
4830
4840
  InputWithSpecialExpression_default,
4831
4841
  {
4832
- value: answerMap[materialKey],
4842
+ value: displayAnswerMap[materialKey],
4833
4843
  showSpecialOnly: false
4834
4844
  }
4835
4845
  ) : null
@@ -4850,7 +4860,7 @@ var FillInTheBlanksActivityMaterialContent = ({
4850
4860
  size: "small"
4851
4861
  }
4852
4862
  ) }) : null
4853
- ] }) : answerMap[materialKey] === "" ? /* @__PURE__ */ jsx28(
4863
+ ] }) : displayAnswerMap[materialKey] === "" ? /* @__PURE__ */ jsx28(
4854
4864
  "div",
4855
4865
  {
4856
4866
  className: `w-catchup-activity-media-box-item h-catchup-activity-media-box-item border rounded-catchup-xlarge border-dashed ${learnerAnswerState === "CORRECT" ? "border-catchup-green" : learnerAnswerState === "INCORRECT" ? "border-catchup-red" : "border-catchup-blue"}`,
@@ -4868,14 +4878,14 @@ var FillInTheBlanksActivityMaterialContent = ({
4868
4878
  ShowMaterialMediaByContentType_default,
4869
4879
  {
4870
4880
  contentType: contentMap.type,
4871
- src: answerMap[materialKey],
4881
+ src: displayAnswerMap[materialKey],
4872
4882
  canFullScreen: true
4873
4883
  },
4874
4884
  `${uniqueValue}-${index}`
4875
4885
  )
4876
4886
  }
4877
4887
  ) : /* @__PURE__ */ jsx28("p", { className: "text-xl", children: constructInputWithSpecialExpressionList(
4878
- answerMap[materialKey]
4888
+ displayAnswerMap[materialKey]
4879
4889
  ).map((inputPart, index2) => /* @__PURE__ */ jsx28(
4880
4890
  "span",
4881
4891
  {
@@ -4995,6 +5005,7 @@ var GroupingActivityMaterialContent = ({
4995
5005
  null
4996
5006
  );
4997
5007
  const [shuffledMaterialList, setShuffledMaterialList] = useState19([]);
5008
+ const [displayAnswerMap, setDisplayAnswerMap] = useState19(answerMap);
4998
5009
  const dragElementRef = useRef5(null);
4999
5010
  const [mousePosition, setMousePosition] = useState19({
5000
5011
  x: 0,
@@ -5027,8 +5038,11 @@ var GroupingActivityMaterialContent = ({
5027
5038
  hasShuffledRef.current = true;
5028
5039
  }, [materialMap]);
5029
5040
  useEffect10(() => {
5030
- if (!showCorrectAnswer) return;
5031
- answerMap = materialMap;
5041
+ if (showCorrectAnswer) {
5042
+ setDisplayAnswerMap(materialMap);
5043
+ } else {
5044
+ setDisplayAnswerMap(answerMap);
5045
+ }
5032
5046
  }, [showCorrectAnswer, answerMap, materialMap]);
5033
5047
  useEffect10(() => {
5034
5048
  if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
@@ -5074,10 +5088,10 @@ var GroupingActivityMaterialContent = ({
5074
5088
  };
5075
5089
  requestAnimationFrame(animate);
5076
5090
  }, [dropTargetKey]);
5077
- const retrieveFilteredMaterialList = (answerMap2) => {
5091
+ const retrieveFilteredMaterialList = (currentAnswerMap) => {
5078
5092
  const selectedValueList = [];
5079
- Object.keys(answerMap2).forEach((key) => {
5080
- answerMap2[key].forEach((value) => {
5093
+ Object.keys(currentAnswerMap).forEach((key) => {
5094
+ currentAnswerMap[key].forEach((value) => {
5081
5095
  selectedValueList.push(value);
5082
5096
  });
5083
5097
  });
@@ -5168,7 +5182,7 @@ var GroupingActivityMaterialContent = ({
5168
5182
  setSelectedValue(null);
5169
5183
  }
5170
5184
  };
5171
- const filteredMaterialList = retrieveFilteredMaterialList(answerMap);
5185
+ const filteredMaterialList = retrieveFilteredMaterialList(displayAnswerMap);
5172
5186
  return /* @__PURE__ */ jsxs19("div", { onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, children: [
5173
5187
  draggedValue && mousePosition.x > 0 && /* @__PURE__ */ jsx30(
5174
5188
  "div",
@@ -5270,7 +5284,7 @@ var GroupingActivityMaterialContent = ({
5270
5284
  }) }),
5271
5285
  /* @__PURE__ */ jsx30(DividerLine_default, {})
5272
5286
  ] }) : null,
5273
- Object.keys(answerMap).map((answerMapKey, index) => /* @__PURE__ */ jsxs19("div", { className: "flex flex-row w-full", children: [
5287
+ Object.keys(displayAnswerMap).map((answerMapKey, index) => /* @__PURE__ */ jsxs19("div", { className: "flex flex-row w-full", children: [
5274
5288
  /* @__PURE__ */ jsx30("div", { className: "w-1/3", children: /* @__PURE__ */ jsx30(
5275
5289
  "div",
5276
5290
  {
@@ -5297,7 +5311,7 @@ var GroupingActivityMaterialContent = ({
5297
5311
  onMouseLeave: () => setDropTargetKey(null),
5298
5312
  onClick: () => handleDropZoneClick(answerMapKey),
5299
5313
  className: `${dropTargetKey === answerMapKey ? "bg-catchup-light-blue ring-2 ring-blue-400" : ""} flex-1 border-catchup-blue rounded-catchup-xlarge border-2 h-full p-1 transition-all duration-200`,
5300
- children: /* @__PURE__ */ jsx30("div", { className: "h-full w-full overflow-x-auto", children: /* @__PURE__ */ jsx30("div", { className: "flex flex-row items-center gap-2 w-max h-full", children: answerMap[answerMapKey].map(
5314
+ children: /* @__PURE__ */ jsx30("div", { className: "h-full w-full overflow-x-auto", children: /* @__PURE__ */ jsx30("div", { className: "flex flex-row items-center gap-2 w-max h-full", children: displayAnswerMap[answerMapKey].map(
5301
5315
  (answerMapValue, answerMapIndex) => {
5302
5316
  const learnerAnswerState = checkAnswerState(
5303
5317
  materialMap[answerMapKey],
@@ -5428,6 +5442,7 @@ var MatchingActivityMaterialContent = ({
5428
5442
  null
5429
5443
  );
5430
5444
  const [shuffledMaterialList, setShuffledMaterialList] = useState20([]);
5445
+ const [displayAnswerMap, setDisplayAnswerMap] = useState20(answerMap);
5431
5446
  const dragElementRef = useRef6(null);
5432
5447
  const [mousePosition, setMousePosition] = useState20({
5433
5448
  x: 0,
@@ -5458,9 +5473,12 @@ var MatchingActivityMaterialContent = ({
5458
5473
  hasShuffledRef.current = true;
5459
5474
  }, [materialMap]);
5460
5475
  useEffect11(() => {
5461
- if (!showCorrectAnswer) return;
5462
- answerMap = materialMap;
5463
- }, [showCorrectAnswer]);
5476
+ if (showCorrectAnswer) {
5477
+ setDisplayAnswerMap(materialMap);
5478
+ } else {
5479
+ setDisplayAnswerMap(answerMap);
5480
+ }
5481
+ }, [showCorrectAnswer, answerMap, materialMap]);
5464
5482
  useEffect11(() => {
5465
5483
  if (!dropTargetKey || !dropZoneRefs.current[dropTargetKey]) return;
5466
5484
  const dropZoneElement = dropZoneRefs.current[dropTargetKey];
@@ -5505,10 +5523,10 @@ var MatchingActivityMaterialContent = ({
5505
5523
  };
5506
5524
  requestAnimationFrame(animate);
5507
5525
  }, [dropTargetKey]);
5508
- const retrieveFilteredMaterialList = (answerMap2) => {
5526
+ const retrieveFilteredMaterialList = (currentAnswerMap) => {
5509
5527
  const selectedValueList = [];
5510
- Object.keys(answerMap2).forEach((key) => {
5511
- selectedValueList.push(answerMap2[key]);
5528
+ Object.keys(currentAnswerMap).forEach((key) => {
5529
+ selectedValueList.push(currentAnswerMap[key]);
5512
5530
  });
5513
5531
  return shuffledMaterialList.filter(
5514
5532
  (material) => selectedValueList.findIndex((value) => material === value) === -1
@@ -5593,7 +5611,7 @@ var MatchingActivityMaterialContent = ({
5593
5611
  setSelectedValue(null);
5594
5612
  }
5595
5613
  };
5596
- const filteredMaterialList = retrieveFilteredMaterialList(answerMap);
5614
+ const filteredMaterialList = retrieveFilteredMaterialList(displayAnswerMap);
5597
5615
  return /* @__PURE__ */ jsxs21("div", { onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, children: [
5598
5616
  draggedValue && mousePosition.x > 0 && /* @__PURE__ */ jsx32(
5599
5617
  "div",
@@ -5700,10 +5718,10 @@ var MatchingActivityMaterialContent = ({
5700
5718
  ),
5701
5719
  /* @__PURE__ */ jsx32("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx32(DividerLine_default, {}) })
5702
5720
  ] }) : null,
5703
- Object.keys(answerMap).map((answerMapKey, index) => {
5721
+ Object.keys(displayAnswerMap).map((answerMapKey, index) => {
5704
5722
  const learnerAnswerState = checkAnswerState(
5705
5723
  materialMap[answerMapKey],
5706
- answerMap[answerMapKey]
5724
+ displayAnswerMap[answerMapKey]
5707
5725
  );
5708
5726
  return /* @__PURE__ */ jsxs21("div", { className: "flex flex-row w-full", children: [
5709
5727
  /* @__PURE__ */ jsx32("div", { className: "w-1/3", children: /* @__PURE__ */ jsx32(
@@ -5738,13 +5756,13 @@ var MatchingActivityMaterialContent = ({
5738
5756
  className: "h-full flex-1 flex flex-row items-center justify-center px-4",
5739
5757
  onClick: (e) => {
5740
5758
  e.stopPropagation();
5741
- if (checkCanAnswerQuestion() && answerMap[answerMapKey]) {
5759
+ if (checkCanAnswerQuestion() && displayAnswerMap[answerMapKey]) {
5742
5760
  onChange(answerMap, answerMapKey, null);
5743
5761
  setSelectedValue(null);
5744
5762
  }
5745
5763
  },
5746
- children: answerMap[answerMapKey] ? contentMap.type === "TEXT" ? /* @__PURE__ */ jsx32("p", { className: "text-lg whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
5747
- answerMap[answerMapKey]
5764
+ children: displayAnswerMap[answerMapKey] ? contentMap.type === "TEXT" ? /* @__PURE__ */ jsx32("p", { className: "text-lg whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
5765
+ displayAnswerMap[answerMapKey]
5748
5766
  ).map((inputPart, index2) => /* @__PURE__ */ jsx32(
5749
5767
  "span",
5750
5768
  {
@@ -5756,7 +5774,7 @@ var MatchingActivityMaterialContent = ({
5756
5774
  ShowMaterialMediaByContentType_default,
5757
5775
  {
5758
5776
  contentType: contentMap.type,
5759
- src: answerMap[answerMapKey],
5777
+ src: displayAnswerMap[answerMapKey],
5760
5778
  canFullScreen: false
5761
5779
  },
5762
5780
  `${uniqueValue}-${index}`
@@ -5816,6 +5834,7 @@ var MatchingActivityContent = ({
5816
5834
  var MatchingActivityContent_default = MatchingActivityContent;
5817
5835
 
5818
5836
  // src/components/activities/material-contents/MCMAActivityMaterialContent.tsx
5837
+ import { useEffect as useEffect12, useState as useState21 } from "react";
5819
5838
  import { InlineMath as InlineMath7 } from "react-katex";
5820
5839
  import { jsx as jsx34, jsxs as jsxs23 } from "react/jsx-runtime";
5821
5840
  var MCMAActivityMaterialContent = ({
@@ -5825,8 +5844,21 @@ var MCMAActivityMaterialContent = ({
5825
5844
  contentMap,
5826
5845
  checkCanAnswerQuestion,
5827
5846
  onChange,
5828
- isPreview
5847
+ isPreview,
5848
+ showCorrectAnswer
5829
5849
  }) => {
5850
+ const [displayAnswerMap, setDisplayAnswerMap] = useState21(answerMap);
5851
+ useEffect12(() => {
5852
+ if (showCorrectAnswer) {
5853
+ const correctAnswerMap = {};
5854
+ Object.keys(materialMap).forEach((materialKey) => {
5855
+ correctAnswerMap[materialKey] = JSON.parse(materialKey);
5856
+ });
5857
+ setDisplayAnswerMap(correctAnswerMap);
5858
+ } else {
5859
+ setDisplayAnswerMap(answerMap);
5860
+ }
5861
+ }, [showCorrectAnswer, answerMap, materialMap]);
5830
5862
  const retrieveCorrectAnswerList = () => {
5831
5863
  return JSON.parse(Object.keys(materialMap)[0]);
5832
5864
  };
@@ -5848,7 +5880,7 @@ var MCMAActivityMaterialContent = ({
5848
5880
  /* @__PURE__ */ jsx34("div", { className: "hidden md:contents", children: /* @__PURE__ */ jsx34(DividerLine_default, {}) }),
5849
5881
  checkCanAnswerQuestion() ? /* @__PURE__ */ jsx34("div", { className: "flex flex-row w-full flex-wrap ", children: materialMap[materialKey].map(
5850
5882
  (materialSubKey, index2) => {
5851
- const foundAnswer = answerMap[materialKey].find(
5883
+ const foundAnswer = displayAnswerMap[materialKey].find(
5852
5884
  (learnerAnswer) => learnerAnswer === materialSubKey
5853
5885
  );
5854
5886
  const learnerAnswerState = checkAnswerState(
@@ -5870,7 +5902,7 @@ var MCMAActivityMaterialContent = ({
5870
5902
  /* @__PURE__ */ jsx34(
5871
5903
  BaseImage_default,
5872
5904
  {
5873
- src: answerMap[materialKey].includes(materialSubKey) ? "/icons/checkbox.webp" : "/icons/checkbox-empty.webp",
5905
+ src: displayAnswerMap[materialKey].includes(materialSubKey) ? "/icons/checkbox.webp" : "/icons/checkbox-empty.webp",
5874
5906
  alt: "checkbox",
5875
5907
  size: "small",
5876
5908
  onClick: () => {
@@ -5901,7 +5933,7 @@ var MCMAActivityMaterialContent = ({
5901
5933
  );
5902
5934
  }
5903
5935
  ) }) : /* @__PURE__ */ jsx34("p", { className: "text-xl", children: constructInputWithSpecialExpressionList(
5904
- answerMap[materialKey]
5936
+ displayAnswerMap[materialKey]
5905
5937
  ).map((inputPart, index2) => /* @__PURE__ */ jsx34(
5906
5938
  "span",
5907
5939
  {
@@ -5923,6 +5955,7 @@ var MCMAActivityContent = ({
5923
5955
  canAnswerQuestion,
5924
5956
  changeAnswer,
5925
5957
  isPreview,
5958
+ showCorrectAnswer,
5926
5959
  isFullScreen
5927
5960
  }) => {
5928
5961
  const contentMap = parseContentMapFromData(data);
@@ -5953,7 +5986,8 @@ var MCMAActivityContent = ({
5953
5986
  contentMap,
5954
5987
  checkCanAnswerQuestion: canAnswerQuestion,
5955
5988
  onChange: handleMCMAAnswerOnChange,
5956
- isPreview
5989
+ isPreview,
5990
+ showCorrectAnswer
5957
5991
  }
5958
5992
  ) })
5959
5993
  ] });
@@ -5961,6 +5995,7 @@ var MCMAActivityContent = ({
5961
5995
  var MCMAActivityContent_default = MCMAActivityContent;
5962
5996
 
5963
5997
  // src/components/activities/material-contents/MCSAActivityMaterialContent.tsx
5998
+ import { useEffect as useEffect13, useState as useState22 } from "react";
5964
5999
  import { InlineMath as InlineMath8 } from "react-katex";
5965
6000
  import { jsx as jsx36, jsxs as jsxs25 } from "react/jsx-runtime";
5966
6001
  var MCSAActivityMaterialContent = ({
@@ -5970,8 +6005,21 @@ var MCSAActivityMaterialContent = ({
5970
6005
  contentMap,
5971
6006
  checkCanAnswerQuestion,
5972
6007
  onChange,
5973
- isPreview
6008
+ isPreview,
6009
+ showCorrectAnswer
5974
6010
  }) => {
6011
+ const [displayAnswerMap, setDisplayAnswerMap] = useState22(answerMap);
6012
+ useEffect13(() => {
6013
+ if (showCorrectAnswer) {
6014
+ const correctAnswerMap = {};
6015
+ Object.keys(materialMap).forEach((materialKey) => {
6016
+ correctAnswerMap[materialKey] = materialMap[materialKey][0];
6017
+ });
6018
+ setDisplayAnswerMap(correctAnswerMap);
6019
+ } else {
6020
+ setDisplayAnswerMap(answerMap);
6021
+ }
6022
+ }, [showCorrectAnswer, answerMap, materialMap]);
5975
6023
  const retrieveCorrectAnswer = () => {
5976
6024
  return Object.keys(materialMap)[0];
5977
6025
  };
@@ -5997,7 +6045,7 @@ var MCSAActivityMaterialContent = ({
5997
6045
  const learnerAnswerState = checkAnswerState(
5998
6046
  correctAnswer,
5999
6047
  materialSubKey,
6000
- answerMap[materialKey]
6048
+ displayAnswerMap[materialKey]
6001
6049
  );
6002
6050
  return /* @__PURE__ */ jsxs25(
6003
6051
  "div",
@@ -6010,7 +6058,7 @@ var MCSAActivityMaterialContent = ({
6010
6058
  /* @__PURE__ */ jsx36(
6011
6059
  BaseImage_default,
6012
6060
  {
6013
- src: answerMap[materialKey] === materialSubKey ? "/icons/item-element.webp" : "/icons/not-selected-item-element.webp",
6061
+ src: displayAnswerMap[materialKey] === materialSubKey ? "/icons/item-element.webp" : "/icons/not-selected-item-element.webp",
6014
6062
  alt: "circle",
6015
6063
  size: "small",
6016
6064
  onClick: () => {
@@ -6043,7 +6091,7 @@ var MCSAActivityMaterialContent = ({
6043
6091
  )
6044
6092
  }
6045
6093
  ) : /* @__PURE__ */ jsx36("p", { className: "text-xl whitespace-pre-wrap", children: constructInputWithSpecialExpressionList(
6046
- answerMap[materialKey]
6094
+ displayAnswerMap[materialKey]
6047
6095
  ).map((inputPart, index2) => /* @__PURE__ */ jsx36(
6048
6096
  "span",
6049
6097
  {
@@ -6065,6 +6113,7 @@ var MCSAActivityContent = ({
6065
6113
  canAnswerQuestion,
6066
6114
  changeAnswer,
6067
6115
  isPreview,
6116
+ showCorrectAnswer,
6068
6117
  isFullScreen
6069
6118
  }) => {
6070
6119
  const contentMap = parseContentMapFromData(data);
@@ -6088,6 +6137,7 @@ var MCSAActivityContent = ({
6088
6137
  contentMap,
6089
6138
  checkCanAnswerQuestion: canAnswerQuestion,
6090
6139
  onChange: handleMCSAAnswerOnChange,
6140
+ showCorrectAnswer,
6091
6141
  isPreview
6092
6142
  }
6093
6143
  ) })
@@ -6268,21 +6318,21 @@ var OpenEndedActivityContent = ({
6268
6318
  var OpenEndedActivityContent_default = OpenEndedActivityContent;
6269
6319
 
6270
6320
  // src/components/activities/material-contents/OrderingActivityMaterialContent.tsx
6271
- import { useEffect as useEffect13, useState as useState22, useRef as useRef7 } from "react";
6321
+ import { useEffect as useEffect15, useState as useState24, useRef as useRef7 } from "react";
6272
6322
  import { InlineMath as InlineMath9 } from "react-katex";
6273
6323
 
6274
6324
  // src/hooks/useScreenSize.ts
6275
- import { useState as useState21, useEffect as useEffect12 } from "react";
6325
+ import { useState as useState23, useEffect as useEffect14 } from "react";
6276
6326
  var useScreenSize = () => {
6277
- const [containerSize, setContainerSize] = useState21({
6327
+ const [containerSize, setContainerSize] = useState23({
6278
6328
  width: 0,
6279
6329
  height: 0
6280
6330
  });
6281
- const [screenSize, setScreenSize] = useState21({
6331
+ const [screenSize, setScreenSize] = useState23({
6282
6332
  width: window.innerWidth,
6283
6333
  height: window.innerHeight
6284
6334
  });
6285
- useEffect12(() => {
6335
+ useEffect14(() => {
6286
6336
  const handleResize = () => {
6287
6337
  setScreenSize({
6288
6338
  width: window.innerWidth,
@@ -6318,25 +6368,25 @@ var OrderingActivityMaterialContent = ({
6318
6368
  isPreview,
6319
6369
  showCorrectAnswer
6320
6370
  }) => {
6321
- const [selectedKey, setSelectedKey] = useState22(null);
6322
- const [draggedKey, setDraggedKey] = useState22(null);
6323
- const [dropTargetKey, setDropTargetKey] = useState22(null);
6324
- const [draggedElement, setDraggedElement] = useState22(
6371
+ const [selectedKey, setSelectedKey] = useState24(null);
6372
+ const [draggedKey, setDraggedKey] = useState24(null);
6373
+ const [dropTargetKey, setDropTargetKey] = useState24(null);
6374
+ const [draggedElement, setDraggedElement] = useState24(
6325
6375
  null
6326
6376
  );
6327
6377
  const dragElementRef = useRef7(null);
6328
- const [mousePosition, setMousePosition] = useState22({
6378
+ const [mousePosition, setMousePosition] = useState24({
6329
6379
  x: 0,
6330
6380
  y: 0
6331
6381
  });
6332
- const [touchPosition, setTouchPosition] = useState22({
6382
+ const [touchPosition, setTouchPosition] = useState24({
6333
6383
  x: 0,
6334
6384
  y: 0
6335
6385
  });
6336
6386
  const { screenSize } = useScreenSize_default();
6337
- const [view, setView] = useState22("PC");
6338
- const [displayAnswerMap, setDisplayAnswerMap] = useState22(answerMap);
6339
- useEffect13(() => {
6387
+ const [view, setView] = useState24("PC");
6388
+ const [displayAnswerMap, setDisplayAnswerMap] = useState24(answerMap);
6389
+ useEffect15(() => {
6340
6390
  if (!screenSize) return;
6341
6391
  if (screenSize.width <= 1024) {
6342
6392
  setView("TABLET");
@@ -6344,7 +6394,7 @@ var OrderingActivityMaterialContent = ({
6344
6394
  setView("PC");
6345
6395
  }
6346
6396
  }, [screenSize]);
6347
- useEffect13(() => {
6397
+ useEffect15(() => {
6348
6398
  if (showCorrectAnswer) {
6349
6399
  const correctAnswerMap = {};
6350
6400
  Object.keys(answerMap).forEach((answerKey, index) => {
@@ -6635,7 +6685,7 @@ var OrderingActivityContent = ({
6635
6685
  var OrderingActivityContent_default = OrderingActivityContent;
6636
6686
 
6637
6687
  // src/components/activities/material-contents/TrueFalseActivityMaterialContent.tsx
6638
- import { useEffect as useEffect14, useState as useState23 } from "react";
6688
+ import { useEffect as useEffect16, useState as useState25 } from "react";
6639
6689
  import { InlineMath as InlineMath10 } from "react-katex";
6640
6690
  import { Fragment as Fragment10, jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
6641
6691
  var TrueFalseActivityMaterialContent = ({
@@ -6648,9 +6698,9 @@ var TrueFalseActivityMaterialContent = ({
6648
6698
  isPreview,
6649
6699
  showCorrectAnswer
6650
6700
  }) => {
6651
- const [shuffleOptionList, setShuffleOptionList] = useState23([]);
6652
- const [displayAnswerMap, setDisplayAnswerMap] = useState23(answerMap);
6653
- useEffect14(() => {
6701
+ const [shuffleOptionList, setShuffleOptionList] = useState25([]);
6702
+ const [displayAnswerMap, setDisplayAnswerMap] = useState25(answerMap);
6703
+ useEffect16(() => {
6654
6704
  const optionList = [];
6655
6705
  optionList.push(...materialMap.trueList);
6656
6706
  optionList.push(...materialMap.falseList);
@@ -6660,7 +6710,7 @@ var TrueFalseActivityMaterialContent = ({
6660
6710
  setShuffleOptionList(shuffleArray(optionList));
6661
6711
  }
6662
6712
  }, []);
6663
- useEffect14(() => {
6713
+ useEffect16(() => {
6664
6714
  if (showCorrectAnswer) {
6665
6715
  setDisplayAnswerMap(materialMap);
6666
6716
  } else {
@@ -6949,7 +6999,7 @@ var ActivityEvaluationRubricContent = ({
6949
6999
  var ActivityEvaluationRubricContent_default = ActivityEvaluationRubricContent;
6950
7000
 
6951
7001
  // src/components/activities/ActivityPreviewByData.tsx
6952
- import { useEffect as useEffect15, useState as useState24 } from "react";
7002
+ import { useEffect as useEffect17, useState as useState26 } from "react";
6953
7003
 
6954
7004
  // src/components/boxes/SelectionBox.tsx
6955
7005
  import { jsx as jsx46, jsxs as jsxs35 } from "react/jsx-runtime";
@@ -7016,11 +7066,11 @@ var ActivityPreviewByData = ({
7016
7066
  isFullScreen = false,
7017
7067
  showCorrectAnswer = false
7018
7068
  }) => {
7019
- const [selectedType, setSelectedType] = useState24(null);
7020
- const [optionList, setOptionList] = useState24([]);
7021
- const [answerMapMap, setAnswerMapMap] = useState24({});
7022
- const [activityTemplateTypeList, setActivityTemplateTypeList] = useState24([]);
7023
- useEffect15(() => {
7069
+ const [selectedType, setSelectedType] = useState26(null);
7070
+ const [optionList, setOptionList] = useState26([]);
7071
+ const [answerMapMap, setAnswerMapMap] = useState26({});
7072
+ const [activityTemplateTypeList, setActivityTemplateTypeList] = useState26([]);
7073
+ useEffect17(() => {
7024
7074
  if (!data) return;
7025
7075
  let currentActivityTemplateMapList = JSON.parse(
7026
7076
  JSON.stringify(ACTIVITY_TEMPLATE_LIST)
@@ -7038,7 +7088,7 @@ var ActivityPreviewByData = ({
7038
7088
  }
7039
7089
  setActivityTemplateTypeList(currentActivityTemplateMapList);
7040
7090
  }, [data, answerType, typeList]);
7041
- useEffect15(() => {
7091
+ useEffect17(() => {
7042
7092
  if (activityTemplateTypeList.length === 0) return;
7043
7093
  const currentOptionList = [];
7044
7094
  for (const activityTemplateType of activityTemplateTypeList) {
@@ -7058,11 +7108,11 @@ var ActivityPreviewByData = ({
7058
7108
  }
7059
7109
  setOptionList(currentOptionList);
7060
7110
  }, [activityTemplateTypeList, showDifficulty]);
7061
- useEffect15(() => {
7111
+ useEffect17(() => {
7062
7112
  if (optionList.length === 0) return;
7063
7113
  setSelectedType(optionList[0].id);
7064
7114
  }, [optionList]);
7065
- useEffect15(() => {
7115
+ useEffect17(() => {
7066
7116
  if (activityTemplateTypeList.length === 0) return;
7067
7117
  const currentAnswerMapMap = {};
7068
7118
  for (const activityTemplateMap of activityTemplateTypeList) {
@@ -7146,6 +7196,7 @@ var ActivityPreviewByData = ({
7146
7196
  }
7147
7197
  };
7148
7198
  if (!data) return null;
7199
+ console.log(optionList);
7149
7200
  return /* @__PURE__ */ jsxs36("div", { children: [
7150
7201
  showType && optionList.length > 0 ? /* @__PURE__ */ jsxs36(Fragment11, { children: [
7151
7202
  /* @__PURE__ */ jsxs36("div", { className: "mb-4", children: [
@@ -7245,7 +7296,7 @@ var LeftTextRightInputGroup = ({
7245
7296
  var LeftTextRightInputGroup_default = LeftTextRightInputGroup;
7246
7297
 
7247
7298
  // src/components/groups/PageTravelGroup.tsx
7248
- import { useEffect as useEffect16, useState as useState25 } from "react";
7299
+ import { useEffect as useEffect18, useState as useState27 } from "react";
7249
7300
  import { jsx as jsx51, jsxs as jsxs39 } from "react/jsx-runtime";
7250
7301
  var PageTravelGroup = ({
7251
7302
  isImageProcessing,
@@ -7255,13 +7306,13 @@ var PageTravelGroup = ({
7255
7306
  setPageNumber,
7256
7307
  setImageReady
7257
7308
  }) => {
7258
- const [totalPageNumber, setTotalPageNumber] = useState25(0);
7259
- const [newPageNumber, setNewPageNumber] = useState25(0);
7260
- useEffect16(() => {
7309
+ const [totalPageNumber, setTotalPageNumber] = useState27(0);
7310
+ const [newPageNumber, setNewPageNumber] = useState27(0);
7311
+ useEffect18(() => {
7261
7312
  if (!initialTotalPageNumber) return;
7262
7313
  setTotalPageNumber(initialTotalPageNumber);
7263
7314
  }, [initialTotalPageNumber]);
7264
- useEffect16(() => {
7315
+ useEffect18(() => {
7265
7316
  setNewPageNumber(pageNumber + 1);
7266
7317
  }, [pageNumber]);
7267
7318
  return /* @__PURE__ */ jsxs39("div", { className: "flex-1 flex flex-row justify-center items-center flex-wrap", children: [