catchup-library-web 2.0.7 → 2.0.8

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 (27) hide show
  1. package/dist/index.d.mts +22 -22
  2. package/dist/index.d.ts +22 -22
  3. package/dist/index.js +285 -471
  4. package/dist/index.mjs +285 -471
  5. package/package.json +1 -1
  6. package/src/components/activities/ActivityPreviewByAnswerData.tsx +118 -121
  7. package/src/components/activities/ActivityPreviewByData.tsx +10 -10
  8. package/src/components/activities/DropdownActivityContent.tsx +9 -35
  9. package/src/components/activities/FillInTheBlanksActivityContent.tsx +9 -34
  10. package/src/components/activities/GroupingActivityContent.tsx +4 -8
  11. package/src/components/activities/MCMAActivityContent.tsx +8 -8
  12. package/src/components/activities/MCSAActivityContent.tsx +8 -8
  13. package/src/components/activities/MatchingActivityContent.tsx +4 -8
  14. package/src/components/activities/OpenEndedActivityContent.tsx +4 -8
  15. package/src/components/activities/OrderingActivityContent.tsx +4 -8
  16. package/src/components/activities/TrueFalseActivityContent.tsx +4 -12
  17. package/src/components/activities/material-contents/DropdownActivityMaterialContent.tsx +9 -19
  18. package/src/components/activities/material-contents/FillInTheBlanksActivityMaterialContent.tsx +9 -24
  19. package/src/components/activities/material-contents/GroupingActivityMaterialContent.tsx +7 -18
  20. package/src/components/activities/material-contents/MCMAActivityMaterialContent.tsx +2 -10
  21. package/src/components/activities/material-contents/MCSAActivityMaterialContent.tsx +2 -10
  22. package/src/components/activities/material-contents/MatchingActivityMaterialContent.tsx +7 -17
  23. package/src/components/activities/material-contents/OpenEndedActivityMaterialContent.tsx +2 -21
  24. package/src/components/activities/material-contents/OrderingActivityMaterialContent.tsx +4 -16
  25. package/src/components/activities/material-contents/TrueFalseActivityMaterialContent.tsx +4 -27
  26. package/src/properties/ActivityProperties.ts +21 -20
  27. package/src/utilization/CatchtivityUtilization.ts +49 -84
@@ -7,7 +7,7 @@ import { IOrderingActivityMaterialProps } from "../../../properties/ActivityProp
7
7
 
8
8
  const OrderingActivityMaterialContent = ({
9
9
  uniqueValue,
10
- answer,
10
+ answerMap,
11
11
  materialMap,
12
12
  contentMap,
13
13
  checkCanAnswerQuestion,
@@ -44,21 +44,11 @@ const OrderingActivityMaterialContent = ({
44
44
 
45
45
  useEffect(() => {
46
46
  if (!showCorrectAnswer) return;
47
- const answerMap = answer.data.find(
48
- (answerData: any) => answerData.type === "ORDERING"
49
- ).answerMap;
50
47
  Object.keys(answerMap).forEach((answerKey, index) => {
51
48
  answerMap[answerKey] = index;
52
49
  });
53
50
  }, [showCorrectAnswer]);
54
51
 
55
- const retrieveAnswerMap = () => {
56
- const foundIndex = answer.data.findIndex(
57
- (answerData: any) => answerData.type === "ORDERING"
58
- );
59
- return answer.data[foundIndex].answerMap;
60
- };
61
-
62
52
  const checkAnswerState = (correctAnswer: string, learnerAnswer: string) => {
63
53
  if (!isPreview) return null;
64
54
  if (correctAnswer === learnerAnswer) {
@@ -120,7 +110,7 @@ const OrderingActivityMaterialContent = ({
120
110
  draggedKey !== null &&
121
111
  dropTargetKey !== draggedKey
122
112
  ) {
123
- onChange(answer, draggedKey, dropTargetKey);
113
+ onChange(answerMap, draggedKey, dropTargetKey);
124
114
  }
125
115
  setDraggedKey(null);
126
116
  setDropTargetKey(null);
@@ -168,7 +158,7 @@ const OrderingActivityMaterialContent = ({
168
158
  draggedKey !== null &&
169
159
  dropTargetKey !== draggedKey
170
160
  ) {
171
- onChange(answer, draggedKey, dropTargetKey);
161
+ onChange(answerMap, draggedKey, dropTargetKey);
172
162
  }
173
163
  setDraggedKey(null);
174
164
  setDropTargetKey(null);
@@ -185,14 +175,12 @@ const OrderingActivityMaterialContent = ({
185
175
  } else if (selectedKey === materialKey) {
186
176
  setSelectedKey(null);
187
177
  } else {
188
- onChange(answer, selectedKey, materialKey);
178
+ onChange(answerMap, selectedKey, materialKey);
189
179
  setSelectedKey(null);
190
180
  }
191
181
  setDraggedKey(null);
192
182
  };
193
183
 
194
- const answerMap = retrieveAnswerMap();
195
-
196
184
  return (
197
185
  <div
198
186
  className="flex flex-row flex-wrap"
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useState } from "react";
2
- import useScreenSize from "../../../hooks/useScreenSize";
3
2
  import i18n from "../../../language/i18n";
4
3
  import ShowMaterialMediaByContentType from "./ShowMaterialMediaByContentType";
5
4
  import { InlineMath } from "react-katex";
@@ -11,7 +10,7 @@ import { shuffleArray } from "../../../utilization/AppUtilization";
11
10
 
12
11
  const TrueFalseActivityMaterialContent = ({
13
12
  uniqueValue,
14
- answer,
13
+ answerMap,
15
14
  materialMap,
16
15
  contentMap,
17
16
  checkCanAnswerQuestion,
@@ -19,7 +18,6 @@ const TrueFalseActivityMaterialContent = ({
19
18
  isPreview,
20
19
  showCorrectAnswer,
21
20
  }: ITrueFalseActivityMaterialProps) => {
22
- const { screenSize } = useScreenSize();
23
21
  const [shuffleOptionList, setShuffleOptionList] = useState<any[]>([]);
24
22
 
25
23
  useEffect(() => {
@@ -35,29 +33,9 @@ const TrueFalseActivityMaterialContent = ({
35
33
 
36
34
  useEffect(() => {
37
35
  if (!showCorrectAnswer) return;
38
- answer.data.find(
39
- (answerData: any) => answerData.type === "TRUE_FALSE"
40
- ).answerMap = materialMap;
36
+ answerMap = materialMap;
41
37
  }, [showCorrectAnswer]);
42
38
 
43
- const retrieveAnswer = () => {
44
- if (!answer)
45
- return {
46
- answerMap: {
47
- trueList: [],
48
- falseList: [],
49
- },
50
- };
51
- return answer.data.find(
52
- (answerData: any) => answerData.type === "TRUE_FALSE"
53
- );
54
- };
55
-
56
- const retrieveAnswerMap = () => {
57
- const { answerMap } = retrieveAnswer();
58
- return answerMap;
59
- };
60
-
61
39
  const checkAnswerState = (correctAnswer: string, learnerAnswer: string) => {
62
40
  if (!isPreview) return null;
63
41
  if (correctAnswer === learnerAnswer) {
@@ -66,7 +44,6 @@ const TrueFalseActivityMaterialContent = ({
66
44
  return "INCORRECT";
67
45
  };
68
46
 
69
- const answerMap = retrieveAnswerMap();
70
47
  return (
71
48
  <div className="">
72
49
  <div className="hidden md:block">
@@ -160,7 +137,7 @@ const TrueFalseActivityMaterialContent = ({
160
137
  alt="checkbox"
161
138
  size="small"
162
139
  onClick={() => {
163
- onChange(answer, "TRUE", shuffleOption);
140
+ onChange(answerMap, "TRUE", shuffleOption);
164
141
  }}
165
142
  />
166
143
  </div>
@@ -176,7 +153,7 @@ const TrueFalseActivityMaterialContent = ({
176
153
  alt="checkbox"
177
154
  size="small"
178
155
  onClick={() => {
179
- onChange(answer, "FALSE", shuffleOption);
156
+ onChange(answerMap, "FALSE", shuffleOption);
180
157
  }}
181
158
  />
182
159
  </div>
@@ -20,7 +20,7 @@ export interface IActivityBodyContentProps {
20
20
  }
21
21
 
22
22
  export interface IOrderingActivityProps {
23
- answer: any;
23
+ answerMap: any;
24
24
  data: any;
25
25
  canAnswerQuestion: () => boolean;
26
26
  changeAnswer: (e: any) => void;
@@ -31,7 +31,7 @@ export interface IOrderingActivityProps {
31
31
 
32
32
  export interface IOrderingActivityMaterialProps {
33
33
  uniqueValue: string;
34
- answer: any;
34
+ answerMap: any;
35
35
  materialMap: any;
36
36
  contentMap: any;
37
37
  checkCanAnswerQuestion: () => boolean;
@@ -41,7 +41,7 @@ export interface IOrderingActivityMaterialProps {
41
41
  }
42
42
 
43
43
  export interface IDropdownActivityProps {
44
- answer: any;
44
+ answerMap: any;
45
45
  data: any;
46
46
  canAnswerQuestion: () => boolean;
47
47
  changeAnswer: (e: any) => void;
@@ -52,7 +52,7 @@ export interface IDropdownActivityProps {
52
52
 
53
53
  export interface IDropdownActivityMaterialProps {
54
54
  uniqueValue: string;
55
- answer: any;
55
+ answerMap: any;
56
56
  materialMap: any;
57
57
  contentMap: any;
58
58
  checkCanAnswerQuestion: () => boolean;
@@ -62,7 +62,7 @@ export interface IDropdownActivityMaterialProps {
62
62
  }
63
63
 
64
64
  export interface IMCSAActivityProps {
65
- answer: any;
65
+ answerMap: any;
66
66
  data: any;
67
67
  canAnswerQuestion: () => boolean;
68
68
  changeAnswer: (e: any) => void;
@@ -73,7 +73,7 @@ export interface IMCSAActivityProps {
73
73
 
74
74
  export interface IMCSAActivityMaterialProps {
75
75
  uniqueValue: string;
76
- answer: any;
76
+ answerMap: any;
77
77
  materialMap: any;
78
78
  contentMap: any;
79
79
  checkCanAnswerQuestion: () => boolean;
@@ -82,7 +82,7 @@ export interface IMCSAActivityMaterialProps {
82
82
  }
83
83
 
84
84
  export interface IMCMAActivityProps {
85
- answer: any;
85
+ answerMap: any;
86
86
  data: any;
87
87
  canAnswerQuestion: () => boolean;
88
88
  changeAnswer: (e: any) => void;
@@ -93,7 +93,7 @@ export interface IMCMAActivityProps {
93
93
 
94
94
  export interface IMCMAActivityMaterialProps {
95
95
  uniqueValue: string;
96
- answer: any;
96
+ answerMap: any;
97
97
  materialMap: any;
98
98
  contentMap: any;
99
99
  checkCanAnswerQuestion: () => boolean;
@@ -102,7 +102,7 @@ export interface IMCMAActivityMaterialProps {
102
102
  }
103
103
 
104
104
  export interface IGroupingActivityProps {
105
- answer: any;
105
+ answerMap: any;
106
106
  data: any;
107
107
  canAnswerQuestion: () => boolean;
108
108
  changeAnswer: (e: any) => void;
@@ -112,7 +112,7 @@ export interface IGroupingActivityProps {
112
112
 
113
113
  export interface IGroupingActivityMaterialProps {
114
114
  uniqueValue: string;
115
- answer: any;
115
+ answerMap: any;
116
116
  materialMap: any;
117
117
  contentMap: any;
118
118
  checkCanAnswerQuestion: () => boolean;
@@ -122,7 +122,7 @@ export interface IGroupingActivityMaterialProps {
122
122
  }
123
123
 
124
124
  export interface IMatchingActivityProps {
125
- answer: any;
125
+ answerMap: any;
126
126
  data: any;
127
127
  canAnswerQuestion: () => boolean;
128
128
  changeAnswer: (e: any) => void;
@@ -132,7 +132,7 @@ export interface IMatchingActivityProps {
132
132
 
133
133
  export interface IMatchingActivityMaterialProps {
134
134
  uniqueValue: string;
135
- answer: any;
135
+ answerMap: any;
136
136
  materialMap: any;
137
137
  contentMap: any;
138
138
  checkCanAnswerQuestion: () => boolean;
@@ -142,7 +142,7 @@ export interface IMatchingActivityMaterialProps {
142
142
  }
143
143
 
144
144
  export interface IFillInTheBlanksActivityProps {
145
- answer: any;
145
+ answerMap: any;
146
146
  data: any;
147
147
  canAnswerQuestion: () => boolean;
148
148
  changeAnswer: (e: any) => void;
@@ -153,7 +153,7 @@ export interface IFillInTheBlanksActivityProps {
153
153
 
154
154
  export interface IFillInTheBlanksActivityMaterialProps {
155
155
  uniqueValue: string;
156
- answer: any;
156
+ answerMap: any;
157
157
  optionList: any;
158
158
  materialMap: any;
159
159
  contentMap: any;
@@ -164,7 +164,7 @@ export interface IFillInTheBlanksActivityMaterialProps {
164
164
  }
165
165
 
166
166
  export interface IOpenEndedActivityProps {
167
- answer: any;
167
+ answerMap: any;
168
168
  data: any;
169
169
  changeAnswer: (e: any) => void;
170
170
  canAnswerQuestion: () => boolean;
@@ -174,14 +174,14 @@ export interface IOpenEndedActivityProps {
174
174
  }
175
175
 
176
176
  export interface IOpenEndedActivityMaterialProps {
177
- answer: any;
177
+ answerMap: any;
178
178
  contentMap: any;
179
179
  checkCanAnswerQuestion: () => boolean;
180
180
  onChange: (e1: any, e2: any) => void;
181
181
  }
182
182
 
183
183
  export interface ITrueFalseActivityProps {
184
- answer: any;
184
+ answerMap: any;
185
185
  data: any;
186
186
  canAnswerQuestion: () => boolean;
187
187
  changeAnswer: (e: any) => void;
@@ -192,7 +192,7 @@ export interface ITrueFalseActivityProps {
192
192
 
193
193
  export interface ITrueFalseActivityMaterialProps {
194
194
  uniqueValue: string;
195
- answer: any;
195
+ answerMap: any;
196
196
  materialMap: any;
197
197
  contentMap: any;
198
198
  checkCanAnswerQuestion: () => boolean;
@@ -232,10 +232,11 @@ export interface IActivityPreviewByDataProps {
232
232
 
233
233
  export interface IActivityPreviewByAnswerDataProps {
234
234
  data: any;
235
+ answerType?: string | null;
235
236
  showType?: boolean;
236
237
  showDescription?: boolean;
237
- lockedType?: string | null;
238
- typeOptionList?: any[];
238
+ lockedTypeList?: any[];
239
+ // typeOptionList?: any[];
239
240
  showSolution?: boolean;
240
241
  showEvaluationRubric?: boolean;
241
242
  showDifficulty?: boolean;
@@ -1178,47 +1178,31 @@ const retrieveDefaultTrueFalseMap = () => {
1178
1178
  };
1179
1179
 
1180
1180
  export const retrieveCurrentDefaultDataMap = (
1181
- activityTemplate: any,
1181
+ activityTemplateType: any,
1182
1182
  activityData: any
1183
1183
  ) => {
1184
- const defaultDataMap: any = {
1185
- activityTemplateId: activityTemplate.id,
1186
- type: activityTemplate.type,
1187
- };
1188
- if (activityTemplate.type === "ORDERING") {
1189
- defaultDataMap.answerMap = retrieveDefaultOrderingDataMap(
1190
- activityData.orderingMaterialMap
1191
- );
1192
- } else if (activityTemplate.type === "DROPDOWN") {
1193
- defaultDataMap.answerMap = retrieveDefaultDropdownMap(
1194
- activityData.dropdownMaterialMap
1195
- );
1196
- } else if (activityTemplate.type === "MCSA") {
1197
- defaultDataMap.answerMap = retrieveDefaultMCSAMap(
1198
- activityData.MCSAMaterialMap
1199
- );
1200
- } else if (activityTemplate.type === "MCMA") {
1201
- defaultDataMap.answerMap = retrieveDefaultMCMAMap(
1202
- activityData.MCMAMaterialMap
1203
- );
1204
- } else if (activityTemplate.type === "MATCHING") {
1205
- defaultDataMap.answerMap = retrieveDefaultMatchingMap(
1206
- activityData.matchingMaterialMap
1207
- );
1208
- } else if (activityTemplate.type === "GROUPING") {
1209
- defaultDataMap.answerMap = retrieveDefaultGroupingMap(
1210
- activityData.groupingMaterialMap
1211
- );
1212
- } else if (activityTemplate.type === "FILL_IN_THE_BLANKS") {
1213
- defaultDataMap.answerMap = retrieveDefaultFillInTheBlanksMap(
1184
+ if (activityTemplateType === "ORDERING") {
1185
+ return retrieveDefaultOrderingDataMap(activityData.orderingMaterialMap);
1186
+ } else if (activityTemplateType === "DROPDOWN") {
1187
+ return retrieveDefaultDropdownMap(activityData.dropdownMaterialMap);
1188
+ } else if (activityTemplateType === "MCSA") {
1189
+ return retrieveDefaultMCSAMap(activityData.MCSAMaterialMap);
1190
+ } else if (activityTemplateType === "MCMA") {
1191
+ return retrieveDefaultMCMAMap(activityData.MCMAMaterialMap);
1192
+ } else if (activityTemplateType === "MATCHING") {
1193
+ return retrieveDefaultMatchingMap(activityData.matchingMaterialMap);
1194
+ } else if (activityTemplateType === "GROUPING") {
1195
+ return retrieveDefaultGroupingMap(activityData.groupingMaterialMap);
1196
+ } else if (activityTemplateType === "FILL_IN_THE_BLANKS") {
1197
+ return retrieveDefaultFillInTheBlanksMap(
1214
1198
  activityData.fillInTheBlanksMaterialMap
1215
1199
  );
1216
- } else if (activityTemplate.type === "OPEN_ENDED") {
1217
- defaultDataMap.answerMap = retrieveDefaultOpenEndedMap();
1218
- } else if (activityTemplate.type === "TRUE_FALSE") {
1219
- defaultDataMap.answerMap = retrieveDefaultTrueFalseMap();
1200
+ } else if (activityTemplateType === "OPEN_ENDED") {
1201
+ return retrieveDefaultOpenEndedMap();
1202
+ } else if (activityTemplateType === "TRUE_FALSE") {
1203
+ return retrieveDefaultTrueFalseMap();
1220
1204
  }
1221
- return defaultDataMap;
1205
+ return {};
1222
1206
  };
1223
1207
 
1224
1208
  export const constructActivityAnswerMap = (
@@ -1254,7 +1238,7 @@ export const constructActivityAnswerMap = (
1254
1238
  } else if (activityTemplate.type === "TRUE_FALSE") {
1255
1239
  activityData.trueFalseMaterialMap = { trueList: [], falseList: [] };
1256
1240
  }
1257
- return retrieveCurrentDefaultDataMap(activityTemplate, activityData);
1241
+ return retrieveCurrentDefaultDataMap(activityTemplate.type, activityData);
1258
1242
  };
1259
1243
 
1260
1244
  export const ignoreMathematicalExpression = (inputText: string) => {
@@ -1997,53 +1981,40 @@ export const constructActivityData = (
1997
1981
  };
1998
1982
 
1999
1983
  export const constructAnswerBasedOnData = (data: any) => {
2000
- const answer: any = { data: [] };
2001
1984
  if (Object.keys(data).find((dataKey) => dataKey === "orderingMaterialMap")) {
2002
- answer.data.push(
2003
- constructActivityAnswerMap(
2004
- { type: "ORDERING" },
2005
- JSON.parse(JSON.stringify(data))
2006
- )
1985
+ return constructActivityAnswerMap(
1986
+ { type: "ORDERING" },
1987
+ JSON.parse(JSON.stringify(data))
2007
1988
  );
2008
1989
  }
2009
1990
  if (Object.keys(data).find((dataKey) => dataKey === "dropdownMaterialMap")) {
2010
- answer.data.push(
2011
- constructActivityAnswerMap(
2012
- { type: "DROPDOWN" },
2013
- JSON.parse(JSON.stringify(data))
2014
- )
1991
+ return constructActivityAnswerMap(
1992
+ { type: "DROPDOWN" },
1993
+ JSON.parse(JSON.stringify(data))
2015
1994
  );
2016
1995
  }
2017
1996
  if (Object.keys(data).find((dataKey) => dataKey === "MCSAMaterialMap")) {
2018
- answer.data.push(
2019
- constructActivityAnswerMap(
2020
- { type: "MCSA" },
2021
- JSON.parse(JSON.stringify(data))
2022
- )
1997
+ return constructActivityAnswerMap(
1998
+ { type: "MCSA" },
1999
+ JSON.parse(JSON.stringify(data))
2023
2000
  );
2024
2001
  }
2025
2002
  if (Object.keys(data).find((dataKey) => dataKey === "MCMAMaterialMap")) {
2026
- answer.data.push(
2027
- constructActivityAnswerMap(
2028
- { type: "MCMA" },
2029
- JSON.parse(JSON.stringify(data))
2030
- )
2003
+ return constructActivityAnswerMap(
2004
+ { type: "MCMA" },
2005
+ JSON.parse(JSON.stringify(data))
2031
2006
  );
2032
2007
  }
2033
2008
  if (Object.keys(data).find((dataKey) => dataKey === "matchingMaterialMap")) {
2034
- answer.data.push(
2035
- constructActivityAnswerMap(
2036
- { type: "MATCHING" },
2037
- JSON.parse(JSON.stringify(data))
2038
- )
2009
+ return constructActivityAnswerMap(
2010
+ { type: "MATCHING" },
2011
+ JSON.parse(JSON.stringify(data))
2039
2012
  );
2040
2013
  }
2041
2014
  if (Object.keys(data).find((dataKey) => dataKey === "groupingMaterialMap")) {
2042
- answer.data.push(
2043
- constructActivityAnswerMap(
2044
- { type: "GROUPING" },
2045
- JSON.parse(JSON.stringify(data))
2046
- )
2015
+ return constructActivityAnswerMap(
2016
+ { type: "GROUPING" },
2017
+ JSON.parse(JSON.stringify(data))
2047
2018
  );
2048
2019
  }
2049
2020
  if (
@@ -2051,30 +2022,24 @@ export const constructAnswerBasedOnData = (data: any) => {
2051
2022
  (dataKey) => dataKey === "fillInTheBlanksMaterialMap"
2052
2023
  )
2053
2024
  ) {
2054
- answer.data.push(
2055
- constructActivityAnswerMap(
2056
- { type: "FILL_IN_THE_BLANKS" },
2057
- JSON.parse(JSON.stringify(data))
2058
- )
2025
+ return constructActivityAnswerMap(
2026
+ { type: "FILL_IN_THE_BLANKS" },
2027
+ JSON.parse(JSON.stringify(data))
2059
2028
  );
2060
2029
  }
2061
2030
  if (Object.keys(data).find((dataKey) => dataKey === "openEndedMaterialMap")) {
2062
- answer.data.push(
2063
- constructActivityAnswerMap(
2064
- { type: "OPEN_ENDED" },
2065
- JSON.parse(JSON.stringify(data))
2066
- )
2031
+ return constructActivityAnswerMap(
2032
+ { type: "OPEN_ENDED" },
2033
+ JSON.parse(JSON.stringify(data))
2067
2034
  );
2068
2035
  }
2069
2036
  if (Object.keys(data).find((dataKey) => dataKey === "trueFalseMaterialMap")) {
2070
- answer.data.push(
2071
- constructActivityAnswerMap(
2072
- { type: "TRUE_FALSE" },
2073
- JSON.parse(JSON.stringify(data))
2074
- )
2037
+ return constructActivityAnswerMap(
2038
+ { type: "TRUE_FALSE" },
2039
+ JSON.parse(JSON.stringify(data))
2075
2040
  );
2076
2041
  }
2077
- return answer;
2042
+ return {};
2078
2043
  };
2079
2044
 
2080
2045
  export const constructActivityItemListBodyOnly = (bodyMap: any) => {