catchup-library-web 1.0.0 → 1.0.1

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.
Files changed (47) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/package.json +10 -2
  4. package/src/components/activities/DropdownActivityContent.tsx +73 -0
  5. package/src/components/activities/FillInTheBlanksActivityContent.tsx +102 -0
  6. package/src/components/activities/GroupingActivityContent.tsx +62 -0
  7. package/src/components/activities/MCMAActivityContent.tsx +65 -0
  8. package/src/components/activities/MCSAActivityContent.tsx +58 -0
  9. package/src/components/activities/MatchingActivityContent.tsx +57 -0
  10. package/src/components/activities/OpenEndedActivityContent.tsx +92 -0
  11. package/src/components/activities/OrderingActivityContent.tsx +59 -0
  12. package/src/components/activities/TrueFalseActivityContent.tsx +98 -0
  13. package/src/components/activities/body-content/ActivityBodyContent.tsx +108 -0
  14. package/src/components/activities/body-content/ShowBodyMediaByContentType.tsx +404 -0
  15. package/src/components/activities/empty-content/ActivityEmptyContent.tsx +15 -0
  16. package/src/components/activities/material-content/DropdownActivityMaterialContent.tsx +227 -0
  17. package/src/components/activities/material-content/FillInTheBlanksActivityMaterialContent.tsx +270 -0
  18. package/src/components/activities/material-content/GroupingActivityMaterialContent.tsx +359 -0
  19. package/src/components/activities/material-content/MCMAActivityMaterialContent.tsx +166 -0
  20. package/src/components/activities/material-content/MCSAActivityMaterialContent.tsx +165 -0
  21. package/src/components/activities/material-content/MatchingActivityMaterialContent.tsx +332 -0
  22. package/src/components/activities/material-content/OpenEndedActivityMaterialContent.tsx +818 -0
  23. package/src/components/activities/material-content/OrderingActivityMaterialContent.tsx +216 -0
  24. package/src/components/activities/material-content/ShowMaterialMediaByContentType.tsx +172 -0
  25. package/src/components/activities/material-content/TrueFalseActivityMaterialContent.tsx +217 -0
  26. package/src/components/activities/solution-content/ActivitySolutionContent.tsx +86 -0
  27. package/src/components/dividers/BlueVerticalDividerLine.tsx +13 -0
  28. package/src/components/dividers/DividerLine.tsx +5 -0
  29. package/src/components/dividers/VerticalDividerLine.tsx +5 -0
  30. package/src/components/dnds/DraggableDroppableItem.tsx +62 -0
  31. package/src/components/dnds/DraggableItem.tsx +41 -0
  32. package/src/components/dnds/DroppableItem.tsx +38 -0
  33. package/src/components/dropdowns/MediaDropdown.tsx +51 -0
  34. package/src/components/groups/InputGroup.tsx +329 -0
  35. package/src/hooks/useScreenSize.ts +40 -0
  36. package/src/language/i18n.ts +10 -0
  37. package/src/properties/ActivityProperties.ts +204 -0
  38. package/src/properties/ButtonProperties.ts +1 -1
  39. package/src/properties/DividerLineProperties.ts +3 -0
  40. package/src/properties/DnDProperties.ts +28 -0
  41. package/src/properties/DropdownProperties.ts +5 -0
  42. package/src/properties/EnumProperties.ts +11 -0
  43. package/src/properties/GroupProperties.ts +19 -0
  44. package/src/utilization/AppUtilization.ts +56 -0
  45. package/src/utilization/CatchtivityUtilization.ts +1566 -0
  46. package/src/utilization/StorageUtilization.ts +35 -0
  47. package/tsconfig.json +2 -1
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  interface IButtonProps {
4
4
  title: string;
5
5
  size: string;
6
- onClick: () => any;
6
+ onClick: () => void;
7
7
  disabled: boolean;
8
8
  iconPosition: string;
9
9
  textOnly: boolean;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  interface IButtonProps {
4
4
  title: string;
5
5
  size: string;
6
- onClick: () => any;
6
+ onClick: () => void;
7
7
  disabled: boolean;
8
8
  iconPosition: string;
9
9
  textOnly: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catchup-library-web",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -11,13 +11,21 @@
11
11
  "author": "",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
+ "i18next": "^24.2.2",
14
15
  "react": "^18.3.0",
16
+ "react-dnd": "^16.0.1",
15
17
  "react-dom": "^18.3.0",
16
- "react-loader-spinner": "^6.1.6"
18
+ "react-i18next": "^15.4.0",
19
+ "react-katex": "^3.0.1",
20
+ "react-loader-spinner": "^6.1.6",
21
+ "react-modal": "^3.16.3",
22
+ "react-select": "^5.10.0"
17
23
  },
18
24
  "devDependencies": {
19
25
  "@types/react": "^18.3.0",
20
26
  "@types/react-dom": "^18.3.0",
27
+ "@types/react-katex": "^3.0.4",
28
+ "@types/react-modal": "^3.16.3",
21
29
  "tsup": "^8.3.6",
22
30
  "typescript": "^5.7.3"
23
31
  }
@@ -0,0 +1,73 @@
1
+ import { IDropdownActivityProps } from "../../properties/ActivityProperties";
2
+ import {
3
+ parseBodyMapFromData,
4
+ parseContentMapFromData,
5
+ parseMaterialMapFromData,
6
+ } from "../../utilization/CatchtivityUtilization";
7
+ import DividerLine from "../dividers/DividerLine";
8
+ import VerticalDividerLine from "../dividers/VerticalDividerLine";
9
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
10
+ import DropdownActivityMaterialContent from "./material-content/DropdownActivityMaterialContent";
11
+
12
+ const DropdownActivityContent = ({
13
+ answer,
14
+ data,
15
+ canAnswerQuestion,
16
+ changeAnswer,
17
+ isPreview,
18
+ showCorrectAnswer,
19
+ }: IDropdownActivityProps) => {
20
+ const contentMap = parseContentMapFromData(data);
21
+ const dropdownBodyMap = parseBodyMapFromData(data, "DROPDOWN");
22
+ const dropdownMaterialMap = parseMaterialMapFromData(data, "DROPDOWN");
23
+
24
+ const retrieveCurrentAnswerMap = () => {
25
+ let foundIndex = answer.data.findIndex(
26
+ (answerData: any) => answerData.type === "DROPDOWN"
27
+ );
28
+ return answer.data[foundIndex].answerMap;
29
+ };
30
+
31
+ const handleDropdownAnswerOnChange = (
32
+ answer: any,
33
+ key: any,
34
+ value: string
35
+ ) => {
36
+ const answerMap = retrieveCurrentAnswerMap();
37
+ answerMap[key] = value;
38
+ changeAnswer(answer);
39
+ };
40
+
41
+ return (
42
+ <div className="flex flex-row flex-wrap">
43
+ <div className="w-full md:w-[60%]">
44
+ <ActivityBodyContent
45
+ bodyMap={dropdownBodyMap}
46
+ answerMap={retrieveCurrentAnswerMap()}
47
+ contentMap={contentMap}
48
+ templateType={"DROPDOWN"}
49
+ />
50
+ </div>
51
+ <div className="contents md:hidden">
52
+ <DividerLine />
53
+ </div>
54
+ <div className="hidden md:contents">
55
+ <VerticalDividerLine />
56
+ </div>
57
+ <div className="w-full md:flex-1">
58
+ <DropdownActivityMaterialContent
59
+ uniqueValue={JSON.stringify(data.contentMap)}
60
+ answer={answer}
61
+ materialMap={dropdownMaterialMap}
62
+ contentMap={contentMap}
63
+ checkCanAnswerQuestion={canAnswerQuestion}
64
+ onChange={handleDropdownAnswerOnChange}
65
+ isPreview={isPreview}
66
+ showCorrectAnswer={showCorrectAnswer}
67
+ />
68
+ </div>
69
+ </div>
70
+ );
71
+ };
72
+
73
+ export default DropdownActivityContent;
@@ -0,0 +1,102 @@
1
+ import {
2
+ parseBodyMapFromData,
3
+ parseContentMapFromData,
4
+ parseMaterialMapFromData,
5
+ } from "../../utilization/CatchtivityUtilization";
6
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
7
+ import FillInTheBlanksActivityMaterialContent from "./material-content/FillInTheBlanksActivityMaterialContent";
8
+ import { IFillInTheBlanksActivityProps } from "../../properties/ActivityProperties";
9
+ import DividerLine from "../dividers/DividerLine";
10
+ import VerticalDividerLine from "../dividers/VerticalDividerLine";
11
+
12
+ const FillInTheBlanksActivityContent = ({
13
+ answer,
14
+ data,
15
+ canAnswerQuestion,
16
+ changeAnswer,
17
+ isPreview,
18
+ showCorrectAnswer,
19
+ }: IFillInTheBlanksActivityProps) => {
20
+ const contentMap = parseContentMapFromData(data);
21
+ const fillInTheBlanksBodyMap = parseBodyMapFromData(
22
+ data,
23
+ "FILL_IN_THE_BLANKS"
24
+ );
25
+ const fillInTheBlanksMaterialMap = parseMaterialMapFromData(
26
+ data,
27
+ "FILL_IN_THE_BLANKS"
28
+ );
29
+ const fillInTheBlanksIncorrectList = data.fillInTheBlanksIncorrectList
30
+ ? JSON.parse(data.fillInTheBlanksIncorrectList)
31
+ : [];
32
+
33
+ const retrieveCurrentAnswerMap = () => {
34
+ let foundIndex = answer.data.findIndex(
35
+ (answerData: any) => answerData.type === "FILL_IN_THE_BLANKS"
36
+ );
37
+ return answer.data[foundIndex].answerMap;
38
+ };
39
+
40
+ const constructAnswerOptionList = () => {
41
+ const optionList: any = [];
42
+ Object.keys(fillInTheBlanksMaterialMap).forEach((key) => {
43
+ const array = JSON.parse(fillInTheBlanksMaterialMap[key]);
44
+ for (const item of array) {
45
+ const foundIndex = optionList.findIndex(
46
+ (option: string) => option === item
47
+ );
48
+ if (foundIndex === -1) {
49
+ optionList.push(item);
50
+ }
51
+ }
52
+ });
53
+ fillInTheBlanksIncorrectList.forEach((value: string) => {
54
+ optionList.push(value);
55
+ });
56
+ return optionList;
57
+ };
58
+
59
+ const handleFillInTheBlanksAnswerOnChange = (
60
+ answer: any,
61
+ key: any,
62
+ value: string | null
63
+ ) => {
64
+ const answerMap = retrieveCurrentAnswerMap();
65
+ answerMap[key] = value;
66
+ changeAnswer(answer);
67
+ };
68
+
69
+ return (
70
+ <div className="flex flex-row flex-wrap">
71
+ <div className="w-full md:w-[60%]">
72
+ <ActivityBodyContent
73
+ bodyMap={fillInTheBlanksBodyMap}
74
+ answerMap={retrieveCurrentAnswerMap()}
75
+ contentMap={contentMap}
76
+ templateType={"FILL_IN_THE_BLANKS"}
77
+ />
78
+ </div>
79
+ <div className="contents md:hidden">
80
+ <DividerLine />
81
+ </div>
82
+ <div className="hidden md:contents">
83
+ <VerticalDividerLine />
84
+ </div>
85
+ <div className="w-full md:flex-1">
86
+ <FillInTheBlanksActivityMaterialContent
87
+ uniqueValue={JSON.stringify(data.contentMap)}
88
+ answer={answer}
89
+ optionList={constructAnswerOptionList()}
90
+ materialMap={fillInTheBlanksMaterialMap}
91
+ contentMap={contentMap}
92
+ checkCanAnswerQuestion={canAnswerQuestion}
93
+ onChange={handleFillInTheBlanksAnswerOnChange}
94
+ isPreview={isPreview}
95
+ showCorrectAnswer={showCorrectAnswer}
96
+ />
97
+ </div>
98
+ </div>
99
+ );
100
+ };
101
+
102
+ export default FillInTheBlanksActivityContent;
@@ -0,0 +1,62 @@
1
+ import { IGroupingActivityProps } from "../../properties/ActivityProperties";
2
+ import {
3
+ parseBodyMapFromData,
4
+ parseContentMapFromData,
5
+ parseMaterialMapFromData,
6
+ } from "../../utilization/CatchtivityUtilization";
7
+ import DividerLine from "../dividers/DividerLine";
8
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
9
+ import GroupingActivityMaterialContent from "./material-content/GroupingActivityMaterialContent";
10
+
11
+ const GroupingActivityContent = ({
12
+ answer,
13
+ data,
14
+ canAnswerQuestion,
15
+ changeAnswer,
16
+ isPreview,
17
+ showCorrectAnswer,
18
+ }: IGroupingActivityProps) => {
19
+ const contentMap = parseContentMapFromData(data);
20
+ const groupingBodyMap = parseBodyMapFromData(data, "GROUPING");
21
+ const groupingMaterialMap = parseMaterialMapFromData(data, "GROUPING");
22
+
23
+ const handleGroupingAnswerOnChange = (
24
+ answer: any,
25
+ key: any,
26
+ value: string | null,
27
+ index: number | null
28
+ ) => {
29
+ let foundIndex = answer.data.findIndex(
30
+ (answerData: any) => answerData.type === "GROUPING"
31
+ );
32
+ const answerMap = answer.data[foundIndex].answerMap;
33
+ if (value) {
34
+ answerMap[key].push(value);
35
+ } else {
36
+ answerMap[key].splice(index, 1);
37
+ }
38
+ changeAnswer(answer);
39
+ };
40
+
41
+ return (
42
+ <>
43
+ <ActivityBodyContent
44
+ bodyMap={groupingBodyMap}
45
+ templateType={"GROUPING"}
46
+ />
47
+ <DividerLine />
48
+ <GroupingActivityMaterialContent
49
+ uniqueValue={JSON.stringify(data.contentMap)}
50
+ answer={answer}
51
+ materialMap={groupingMaterialMap}
52
+ contentMap={contentMap}
53
+ checkCanAnswerQuestion={canAnswerQuestion}
54
+ onChange={handleGroupingAnswerOnChange}
55
+ isPreview={isPreview}
56
+ showCorrectAnswer={showCorrectAnswer}
57
+ />
58
+ </>
59
+ );
60
+ };
61
+
62
+ export default GroupingActivityContent;
@@ -0,0 +1,65 @@
1
+ import {
2
+ parseBodyMapFromData,
3
+ parseContentMapFromData,
4
+ parseMaterialMapFromData,
5
+ } from "../../utilization/CatchtivityUtilization";
6
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
7
+ import MCMAActivityMaterialContent from "./material-content/MCMAActivityMaterialContent";
8
+ import { IMCMAActivityProps } from "../../properties/ActivityProperties";
9
+ import DividerLine from "../dividers/DividerLine";
10
+ import VerticalDividerLine from "../dividers/VerticalDividerLine";
11
+
12
+ const MCMAActivityContent = ({
13
+ answer,
14
+ data,
15
+ canAnswerQuestion,
16
+ changeAnswer,
17
+ isPreview,
18
+ }: IMCMAActivityProps) => {
19
+ const contentMap = parseContentMapFromData(data);
20
+ const MCMABodyMap = parseBodyMapFromData(data, "MCMA");
21
+ const MCMAMaterialMap = parseMaterialMapFromData(data, "MCMA");
22
+
23
+ const handleMCMAAnswerOnChange = (answer: any, key: any, value: string) => {
24
+ let foundIndex = answer.data.findIndex(
25
+ (answerData: any) => answerData.type === "MCMA"
26
+ );
27
+ const answerMap = answer.data[foundIndex].answerMap;
28
+ const foundSubIndex = answerMap[key].findIndex(
29
+ (answerMaterialKey: string) => answerMaterialKey === value
30
+ );
31
+ if (foundSubIndex === -1) {
32
+ answerMap[key].push(value);
33
+ } else {
34
+ answerMap[key].splice(foundSubIndex, 1);
35
+ }
36
+ changeAnswer(answer);
37
+ };
38
+
39
+ return (
40
+ <div className="flex flex-row flex-wrap">
41
+ <div className="w-full md:w-[60%]">
42
+ <ActivityBodyContent bodyMap={MCMABodyMap} templateType={"MCMA"} />
43
+ </div>
44
+ <div className="contents md:hidden">
45
+ <DividerLine />
46
+ </div>
47
+ <div className="hidden md:block">
48
+ <VerticalDividerLine />
49
+ </div>
50
+ <div className="w-full md:flex-1">
51
+ <MCMAActivityMaterialContent
52
+ uniqueValue={JSON.stringify(data.contentMap)}
53
+ answer={answer}
54
+ materialMap={MCMAMaterialMap}
55
+ contentMap={contentMap}
56
+ checkCanAnswerQuestion={canAnswerQuestion}
57
+ onChange={handleMCMAAnswerOnChange}
58
+ isPreview={isPreview}
59
+ />
60
+ </div>
61
+ </div>
62
+ );
63
+ };
64
+
65
+ export default MCMAActivityContent;
@@ -0,0 +1,58 @@
1
+ import {
2
+ parseBodyMapFromData,
3
+ parseContentMapFromData,
4
+ parseMaterialMapFromData,
5
+ } from "../../utilization/CatchtivityUtilization";
6
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
7
+ import MCSAActivityMaterialContent from "./material-content/MCSAActivityMaterialContent";
8
+ import { IMCSAActivityProps } from "../../properties/ActivityProperties";
9
+ import DividerLine from "../dividers/DividerLine";
10
+ import VerticalDividerLine from "../dividers/VerticalDividerLine";
11
+
12
+ const MCSAActivityContent = ({
13
+ answer,
14
+ data,
15
+ canAnswerQuestion,
16
+ changeAnswer,
17
+ isPreview,
18
+ }: IMCSAActivityProps) => {
19
+ const contentMap = parseContentMapFromData(data);
20
+ const MCSABodyMap = parseBodyMapFromData(data, "MCSA");
21
+ const MCSAMaterialMap = parseMaterialMapFromData(data, "MCSA");
22
+
23
+ const handleMCSAAnswerOnChange = (answer: any, key: any, value: string) => {
24
+ let foundIndex = answer.data.findIndex(
25
+ (answerData: any) => answerData.type === "MCSA"
26
+ );
27
+ const answerMap = answer.data[foundIndex].answerMap;
28
+ answerMap[key] = value;
29
+ changeAnswer(answer);
30
+ };
31
+
32
+ return (
33
+ <div className="flex flex-row flex-wrap">
34
+ <div className="w-full md:w-[60%]">
35
+ <ActivityBodyContent bodyMap={MCSABodyMap} templateType={"MCSA"} />
36
+ </div>
37
+ <div className="contents md:hidden">
38
+ <DividerLine />
39
+ </div>
40
+ <div className="hidden md:block">
41
+ <VerticalDividerLine />
42
+ </div>
43
+ <div className="w-full md:flex-1">
44
+ <MCSAActivityMaterialContent
45
+ uniqueValue={JSON.stringify(data.contentMap)}
46
+ answer={answer}
47
+ materialMap={MCSAMaterialMap}
48
+ contentMap={contentMap}
49
+ checkCanAnswerQuestion={canAnswerQuestion}
50
+ onChange={handleMCSAAnswerOnChange}
51
+ isPreview={isPreview}
52
+ />
53
+ </div>
54
+ </div>
55
+ );
56
+ };
57
+
58
+ export default MCSAActivityContent;
@@ -0,0 +1,57 @@
1
+ import { IMatchingActivityProps } from "../../properties/ActivityProperties";
2
+ import {
3
+ parseBodyMapFromData,
4
+ parseContentMapFromData,
5
+ parseMaterialMapFromData,
6
+ } from "../../utilization/CatchtivityUtilization";
7
+ import DividerLine from "../dividers/DividerLine";
8
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
9
+ import MatchingActivityMaterialContent from "./material-content/MatchingActivityMaterialContent";
10
+
11
+ const MatchingActivityContent = ({
12
+ answer,
13
+ data,
14
+ canAnswerQuestion,
15
+ changeAnswer,
16
+ isPreview,
17
+ showCorrectAnswer,
18
+ }: IMatchingActivityProps) => {
19
+ const contentMap = parseContentMapFromData(data);
20
+ const matchingBodyMap = parseBodyMapFromData(data, "MATCHING");
21
+ const matchingMaterialMap = parseMaterialMapFromData(data, "MATCHING");
22
+
23
+ const handleMatchingAnswerOnChange = (
24
+ answer: any,
25
+ key: any,
26
+ value: string | null
27
+ ) => {
28
+ let foundIndex = answer.data.findIndex(
29
+ (answerData: any) => answerData.type === "MATCHING"
30
+ );
31
+ const answerMap = answer.data[foundIndex].answerMap;
32
+ answerMap[key] = value;
33
+ changeAnswer(answer);
34
+ };
35
+
36
+ return (
37
+ <>
38
+ <ActivityBodyContent
39
+ bodyMap={matchingBodyMap}
40
+ templateType={"MATCHING"}
41
+ />
42
+ <DividerLine />
43
+ <MatchingActivityMaterialContent
44
+ uniqueValue={JSON.stringify(data.contentMap)}
45
+ answer={answer}
46
+ materialMap={matchingMaterialMap}
47
+ contentMap={contentMap}
48
+ checkCanAnswerQuestion={canAnswerQuestion}
49
+ onChange={handleMatchingAnswerOnChange}
50
+ isPreview={isPreview}
51
+ showCorrectAnswer={showCorrectAnswer}
52
+ />
53
+ </>
54
+ );
55
+ };
56
+
57
+ export default MatchingActivityContent;
@@ -0,0 +1,92 @@
1
+ import {
2
+ parseBodyMapFromData,
3
+ parseContentMapFromData,
4
+ } from "../../utilization/CatchtivityUtilization";
5
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
6
+ import OpenEndedActivityMaterialContent from "./material-content/OpenEndedActivityMaterialContent";
7
+ import { IOpenEndedActivityProps } from "../../properties/ActivityProperties";
8
+ import DividerLine from "../dividers/DividerLine";
9
+ import VerticalDividerLine from "../dividers/VerticalDividerLine";
10
+
11
+ const OpenEndedActivityContent = ({
12
+ answer,
13
+ data,
14
+ changeAnswer,
15
+ showMaterialContent,
16
+ }: IOpenEndedActivityProps) => {
17
+ // const {
18
+ // answer,
19
+ // data,
20
+ // canAnswerQuestion,
21
+ // changeAnswer,
22
+ // userId,
23
+ // userProfileId,
24
+ // catchtivityApplicationId,
25
+ // catchxamApplicationId,
26
+ // etudeId,
27
+ // activityId,
28
+ // activityTemplateId,
29
+ // showMaterialContent,
30
+ // storageStompClient,
31
+ // } = props;
32
+ const contentMap = parseContentMapFromData(data);
33
+ const openEndedBodyMap = parseBodyMapFromData(data, "OPEN_ENDED");
34
+ // const openEndedMaterialMap = JSON.parse(data.openEndedMaterialMap);
35
+
36
+ const handleOpenEndedAnswerOnChange = (answer: any, value: string) => {
37
+ let foundIndex = answer.data.findIndex(
38
+ (answerData: any) => answerData.type === "OPEN_ENDED"
39
+ );
40
+ const answerMap = answer.data[foundIndex].answerMap;
41
+ answerMap["ANSWER"] = value;
42
+ changeAnswer(answer);
43
+ };
44
+
45
+ return (
46
+ <div className="flex flex-row flex-wrap">
47
+ <div
48
+ className={`${showMaterialContent ? "w-full md:w-[40%]" : "w-full"}`}
49
+ >
50
+ <ActivityBodyContent
51
+ bodyMap={openEndedBodyMap}
52
+ templateType={"OPEN_ENDED"}
53
+ />
54
+ </div>
55
+
56
+ {showMaterialContent ? (
57
+ <>
58
+ <div className="contents md:hidden">
59
+ <DividerLine />
60
+ </div>
61
+ <div className="hidden md:block">
62
+ <VerticalDividerLine />
63
+ </div>
64
+ <div className="w-full md:flex-1">
65
+ <OpenEndedActivityMaterialContent
66
+ answer={answer}
67
+ contentMap={contentMap}
68
+ onChange={handleOpenEndedAnswerOnChange}
69
+ />
70
+ {/* <OpenEndedActivityMaterialContent
71
+ answer={answer}
72
+ bodyMap={openEndedBodyMap}
73
+ contentMap={contentMap}
74
+ checkCanAnswerQuestion={canAnswerQuestion}
75
+ onChange={handleOpenEndedAnswerOnChange}
76
+ userId={userId}
77
+ userProfileId={userProfileId}
78
+ catchtivityApplicationId={catchtivityApplicationId}
79
+ catchxamApplicationId={catchxamApplicationId}
80
+ etudeId={etudeId}
81
+ activityId={activityId}
82
+ activityTemplateId={activityTemplateId}
83
+ storageStompClient={storageStompClient}
84
+ /> */}
85
+ </div>
86
+ </>
87
+ ) : null}
88
+ </div>
89
+ );
90
+ };
91
+
92
+ export default OpenEndedActivityContent;
@@ -0,0 +1,59 @@
1
+ import { IOrderingActivityProps } from "../../properties/ActivityProperties";
2
+ import {
3
+ parseBodyMapFromData,
4
+ parseContentMapFromData,
5
+ parseMaterialMapFromData,
6
+ } from "../../utilization/CatchtivityUtilization";
7
+ import DividerLine from "../dividers/DividerLine";
8
+ import ActivityBodyContent from "./body-content/ActivityBodyContent";
9
+ import OrderingActivityMaterialContent from "./material-content/OrderingActivityMaterialContent";
10
+
11
+ const OrderingActivityContent = ({
12
+ answer,
13
+ data,
14
+ canAnswerQuestion,
15
+ changeAnswer,
16
+ isPreview,
17
+ showCorrectAnswer,
18
+ }: IOrderingActivityProps) => {
19
+ const contentMap = parseContentMapFromData(data);
20
+ const orderingBodyMap = parseBodyMapFromData(data, "ORDERING");
21
+ const orderingMaterialMap = parseMaterialMapFromData(data, "ORDERING");
22
+
23
+ const handleOrderingAnswerOnChange = (
24
+ answer: any,
25
+ primaryKey: any,
26
+ secondaryKey: any
27
+ ) => {
28
+ let foundIndex = answer.data.findIndex(
29
+ (answerData: any) => answerData.type === "ORDERING"
30
+ );
31
+ const answerMap = answer.data[foundIndex].answerMap;
32
+ const prevValue = answerMap[primaryKey];
33
+ answerMap[primaryKey] = answerMap[secondaryKey];
34
+ answerMap[secondaryKey] = prevValue;
35
+ changeAnswer(answer);
36
+ };
37
+
38
+ return (
39
+ <>
40
+ <ActivityBodyContent
41
+ bodyMap={orderingBodyMap}
42
+ templateType={"ORDERING"}
43
+ />
44
+ <DividerLine />
45
+ <OrderingActivityMaterialContent
46
+ uniqueValue={JSON.stringify(data.contentMap)}
47
+ answer={answer}
48
+ materialMap={orderingMaterialMap}
49
+ contentMap={contentMap}
50
+ checkCanAnswerQuestion={canAnswerQuestion}
51
+ onChange={handleOrderingAnswerOnChange}
52
+ isPreview={isPreview}
53
+ showCorrectAnswer={showCorrectAnswer}
54
+ />
55
+ </>
56
+ );
57
+ };
58
+
59
+ export default OrderingActivityContent;