@nualang/nualang-ui-components 0.1.1237 → 0.1.1239

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.
@@ -28,10 +28,17 @@ function AssignmentCard({
28
28
  getCourses,
29
29
  deleteAssignment,
30
30
  handleEditAssignment,
31
+ progressHelpers,
32
+ preferred_username,
33
+ memberId,
34
+ fetchMemberCourseCompletions,
31
35
  lastClickedExerciseId,
32
36
  handleViewProgress
33
37
  }) {
34
38
  const [confirm] = (0, _useConfirm.default)(t);
39
+ const {
40
+ useQuery
41
+ } = _Queries.ReactQuery;
35
42
  const handleDeleteAssignment = async (classroomId, assignmentId) => {
36
43
  const confirmed = await confirm(t("delete_assignment"), t("delete_assignment_confirmation"));
37
44
  if (confirmed) {
@@ -96,6 +103,15 @@ function AssignmentCard({
96
103
  ...assignment,
97
104
  courses
98
105
  };
106
+ const memberCourseCompletionsQuery = useQuery({
107
+ queryKey: ["memberAssignmentCourseProgress", memberId, uniqueCourses],
108
+ queryFn: async () => {
109
+ const memberCourseCompletions = await fetchMemberCourseCompletions(memberId, uniqueCourses);
110
+ return memberCourseCompletions.Items;
111
+ },
112
+ staleTime: 500000
113
+ });
114
+ const memberCourseCompletions = (0, _react.useMemo)(() => memberCourseCompletionsQuery.isSuccess && memberCourseCompletionsQuery.data ? memberCourseCompletionsQuery.data : {}, [memberCourseCompletionsQuery.data, memberCourseCompletionsQuery.isSuccess]);
99
115
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Card, {
100
116
  sx: {
101
117
  display: "flex",
@@ -110,39 +126,16 @@ function AssignmentCard({
110
126
  container: true,
111
127
  spacing: 2,
112
128
  alignItems: "center",
113
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
129
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
114
130
  item: true,
115
131
  xs: true,
116
132
  flexDirection: "column",
117
133
  display: "flex",
118
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
134
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
119
135
  variant: "body1",
120
136
  component: "div",
121
137
  children: assignment.title
122
- }), !isCreator && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
123
- sx: {
124
- display: "flex",
125
- alignItems: "center"
126
- },
127
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
128
- variant: "determinate",
129
- value: assignment.completed / assignment.assignedStudents.length * 100 //change this to the actual value of student completed
130
- ,
131
- sx: {
132
- height: 10,
133
- borderRadius: 5,
134
- width: "25%"
135
- },
136
- color: "success"
137
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
138
- variant: "body2",
139
- sx: {
140
- color: "text.secondary",
141
- marginLeft: 1
142
- },
143
- children: `${Math.round(assignment.completed / assignment.assignedStudents.length * 100)}%`
144
- })]
145
- })]
138
+ })
146
139
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
147
140
  item: true,
148
141
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
@@ -199,6 +192,9 @@ function AssignmentCard({
199
192
  isCreator: isCreator,
200
193
  viewOnly: true,
201
194
  useCase: isCreator ? "assignment-view" : "assignment-start",
195
+ preferred_username: preferred_username,
196
+ progressHelpers: progressHelpers,
197
+ memberCourseCompletions: memberCourseCompletions,
202
198
  lastClickedExerciseId: lastClickedExerciseId
203
199
  })
204
200
  })]
@@ -26,6 +26,11 @@ const AssignmentCardsList = ({
26
26
  deleteAssignment,
27
27
  handleEditAssignment,
28
28
  refreshAssignments,
29
+ username,
30
+ preferred_username,
31
+ progressHelpers,
32
+ fetchMemberCourseCompletions,
33
+ memberId,
29
34
  handleViewProgress
30
35
  }) => {
31
36
  const [lastClickedExerciseId, setLastClickedExerciseId] = (0, _react.useState)(null);
@@ -48,7 +53,7 @@ const AssignmentCardsList = ({
48
53
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
49
54
  alignItems: "center",
50
55
  sx: {
51
- mb: 1
56
+ my: 2
52
57
  },
53
58
  display: "flex",
54
59
  flexDirection: "column",
@@ -137,6 +142,11 @@ const AssignmentCardsList = ({
137
142
  deleteAssignment: deleteAssignment,
138
143
  handleEditAssignment: handleEditAssignment,
139
144
  lastClickedExerciseId: lastClickedExerciseId,
145
+ progressHelpers: progressHelpers,
146
+ fetchMemberCourseCompletions: fetchMemberCourseCompletions,
147
+ username: username,
148
+ preferred_username: preferred_username,
149
+ memberId: memberId,
140
150
  handleViewProgress: handleViewProgress
141
151
  }, assignment.assignmentId))]
142
152
  })
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _material = require("@mui/material");
9
+ var _ColorLinearProgress = _interopRequireDefault(require("../../Misc/ColorLinearProgress/ColorLinearProgress"));
9
10
  var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
10
11
  var _ExpandLess = _interopRequireDefault(require("@mui/icons-material/ExpandLess"));
11
12
  var _AssignmentExerciseSelection = _interopRequireDefault(require("../AssignmentExerciseSelection/AssignmentExerciseSelection"));
12
13
  var _Queries = require("@nualang/nualang-api-and-queries/Queries");
14
+ var _utils = require("../../utils");
13
15
  var _jsxRuntime = require("react/jsx-runtime");
14
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
17
  function Course({
@@ -29,12 +31,16 @@ function Course({
29
31
  handleStartExercise,
30
32
  isCreator,
31
33
  viewOnly,
34
+ preferred_username,
35
+ progressHelpers,
36
+ memberCourseCompletions,
32
37
  lastClickedExerciseId
33
38
  }) {
34
39
  const numOfIds = lastClickedExerciseId ? lastClickedExerciseId.split('|') : [];
35
40
  const [open, setOpen] = (0, _react.useState)(lastClickedExerciseId && (numOfIds.length === 4 && lastClickedExerciseId.endsWith(`|${assignment.assignmentId}`) || numOfIds.length === 5 && lastClickedExerciseId.split('|')[3] === assignment.assignmentId));
36
41
  const [selectedSectionIds, setSelectedSectionIds] = (0, _react.useState)([]);
37
42
  const [filteredSections, setFilteredSections] = (0, _react.useState)([]);
43
+ const [courseSectionCompletion, setCourseSectionCompletion] = (0, _react.useState)(null);
38
44
  const sectionsQuery = _Queries.courses.useCourseSections(async (courseId, filters) => {
39
45
  const response = await getCourseSections(courseId, filters);
40
46
  return response;
@@ -70,6 +76,13 @@ function Course({
70
76
  setFilteredSections(courseSections.filter(section => selectedSectionIds.includes(section.sectionId)));
71
77
  }
72
78
  }, [courseSections, selectedSectionIds, viewOnly]);
79
+ (0, _react.useEffect)(() => {
80
+ if (courseSections && memberCourseCompletions && selectedExercises) {
81
+ const sectionsWithProgress = (0, _utils.calcCompletions)(courseSections, memberCourseCompletions, selectedExercises);
82
+ const percentCompletion = (0, _utils.calcPercentageCompletion)(sectionsWithProgress);
83
+ setCourseSectionCompletion(percentCompletion);
84
+ }
85
+ }, [courseSections, memberCourseCompletions, selectedExercises]);
73
86
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.List, {
74
87
  disablePadding: true,
75
88
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
@@ -92,7 +105,22 @@ function Course({
92
105
  alt: ""
93
106
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
94
107
  primary: course.courseName,
95
- secondary: course.description,
108
+ secondary: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
109
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
110
+ variant: "body2",
111
+ color: "textSecondary",
112
+ children: course.description
113
+ }), !isCreator && courseSectionCompletion && courseSectionCompletion !== null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
114
+ mt: 1,
115
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
116
+ title: `Completed ${courseSectionCompletion.completed} / ${courseSectionCompletion.total} exercises`,
117
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorLinearProgress.default, {
118
+ variant: "determinate",
119
+ value: courseSectionCompletion.percentage
120
+ })
121
+ })
122
+ })]
123
+ }),
96
124
  sx: {
97
125
  marginLeft: 2
98
126
  }
@@ -130,6 +158,10 @@ function Course({
130
158
  handleStartExercise: handleStartExercise,
131
159
  isCreator: isCreator,
132
160
  viewOnly: viewOnly,
161
+ username: username,
162
+ preferred_username: preferred_username,
163
+ progressHelpers: progressHelpers,
164
+ memberCourseCompletions: memberCourseCompletions,
133
165
  lastClickedExerciseId: lastClickedExerciseId
134
166
  })
135
167
  })
@@ -151,6 +183,9 @@ function AssignmentCourseSelection({
151
183
  handleStartExercise,
152
184
  isCreator,
153
185
  viewOnly,
186
+ preferred_username,
187
+ progressHelpers,
188
+ memberCourseCompletions,
154
189
  lastClickedExerciseId,
155
190
  ...otherProps
156
191
  }) {
@@ -171,6 +206,9 @@ function AssignmentCourseSelection({
171
206
  handleStartExercise: handleStartExercise,
172
207
  isCreator: isCreator,
173
208
  viewOnly: viewOnly,
209
+ preferred_username: preferred_username,
210
+ memberCourseCompletions: memberCourseCompletions,
211
+ progressHelpers: progressHelpers,
174
212
  lastClickedExerciseId: lastClickedExerciseId
175
213
  }))
176
214
  });
@@ -9,7 +9,6 @@ var _material = require("@mui/material");
9
9
  var _styles = require("@mui/material/styles");
10
10
  var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
11
11
  var _ImageSearch = _interopRequireDefault(require("@mui/icons-material/ImageSearch"));
12
- var _PlayCircleOutline = _interopRequireDefault(require("@mui/icons-material/PlayCircleOutline"));
13
12
  var _Hearing = _interopRequireDefault(require("@mui/icons-material/Hearing"));
14
13
  var _SwapHoriz = _interopRequireDefault(require("@mui/icons-material/SwapHoriz"));
15
14
  var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
@@ -19,7 +18,13 @@ var _Forum = _interopRequireDefault(require("@mui/icons-material/Forum"));
19
18
  var _OndemandVideo = _interopRequireDefault(require("@mui/icons-material/OndemandVideo"));
20
19
  var _AssignmentRoleplaySelection = _interopRequireDefault(require("../AssignmentRoleplaySelection/AssignmentRoleplaySelection"));
21
20
  var _CardElements = require("../../Cards/CardElements");
21
+ var _Progress = require("@nualang/nualang-api-and-queries/APIs/Progress");
22
+ var _mui = require("tss-react/mui");
23
+ var _Queries = require("@nualang/nualang-api-and-queries/Queries");
22
24
  var _reactRouterDom = require("react-router-dom");
25
+ var _Exercises = require("../../Lists/Exercises/Exercises");
26
+ var _ColorLinearProgress = _interopRequireDefault(require("../../Misc/ColorLinearProgress/ColorLinearProgress"));
27
+ var _utils = require("../../utils");
23
28
  var _jsxRuntime = require("react/jsx-runtime");
24
29
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
30
  function Exercise({
@@ -35,11 +40,69 @@ function Exercise({
35
40
  selectedExercises,
36
41
  useCase,
37
42
  assignment,
43
+ progressHelpers,
44
+ username,
45
+ preferred_username,
46
+ isCreator,
47
+ memberCourseCompletions,
48
+ completion,
38
49
  lastClickedExerciseId
39
50
  }) {
40
51
  const [listeningHidden, setListeningHidden] = (0, _react.useState)(false);
41
52
  const [translationHidden, setTranslationHidden] = (0, _react.useState)(false);
42
53
  const [pronunciationHidden, setPronunciationHidden] = (0, _react.useState)(false);
54
+
55
+ //progress
56
+ const [pronunciationProgress, setPronunciationProgress] = (0, _react.useState)(null);
57
+ const [translationProgress, setTranslationProgress] = (0, _react.useState)(null);
58
+ const [listeningProgress, setListeningProgress] = (0, _react.useState)(null);
59
+ const [courseId, sectionId, topicId] = courseSectionTopicId.split("|");
60
+ const {
61
+ translation,
62
+ listening,
63
+ pronunciation
64
+ } = completion;
65
+ const courseSectionTopicProgressQuery = _Queries.progress.useTopicMemberProgress(async (courseId, sectionId, topicId, memberId, returnvalues) => {
66
+ const memberProgress = await (0, _Progress.getCourseSectionTopicProgress)(courseId, sectionId, topicId, memberId, returnvalues);
67
+ const formattedProgress = await progressHelpers.formatProgress(memberProgress.Items, username, preferred_username);
68
+ return formattedProgress;
69
+ }, {
70
+ courseId: courseId,
71
+ sectionId: sectionId,
72
+ topicId: topicId,
73
+ memberId: username,
74
+ returnvalues: null
75
+ }, {
76
+ enabled: !!username
77
+ });
78
+ const topicProgress = courseSectionTopicProgressQuery.isSuccess && Array.isArray(courseSectionTopicProgressQuery.data) && courseSectionTopicProgressQuery.data.length ? courseSectionTopicProgressQuery.data : [];
79
+ const getExerciseProgress = async exercise => {
80
+ const exerciseIndex = topicProgress.findIndex(p => p.exercise === exercise);
81
+ if (exerciseIndex > -1) {
82
+ return {
83
+ remainingQuestions: topicProgress[exerciseIndex].remainingQuestions,
84
+ existingAnswerAttempts: topicProgress[exerciseIndex].answerAttempts,
85
+ exerciseStartTime: topicProgress[exerciseIndex].exerciseStartTime
86
+ };
87
+ }
88
+ return {
89
+ remainingQuestions: null,
90
+ existingAnswerAttempts: null,
91
+ exerciseStartTime: null
92
+ };
93
+ };
94
+ (0, _react.useEffect)(() => {
95
+ if (!topicProgress || topicProgress.length === 0 || isCreator) return;
96
+ const fetchProgress = async () => {
97
+ const pronuncialtionResult = await getExerciseProgress("pronunciation");
98
+ setPronunciationProgress(pronuncialtionResult);
99
+ const translationResult = await getExerciseProgress("translation");
100
+ setTranslationProgress(translationResult);
101
+ const listeningProgress = await getExerciseProgress("listening");
102
+ setListeningProgress(listeningProgress);
103
+ };
104
+ fetchProgress();
105
+ }, [topicProgress, isCreator]);
43
106
  const isAssignmentExerciseSelected = selectedExercises?.some(e => e.name === name && e.courseSectionTopicId === courseSectionTopicId);
44
107
  const noRoleplays = name.toLowerCase() === "roleplays" && roleplays.length === 0;
45
108
  const [roleplaysOpen, setRoleplaysOpen] = (0, _react.useState)(noRoleplays ? false : true);
@@ -48,13 +111,11 @@ function Exercise({
48
111
  const {
49
112
  classroomId
50
113
  } = params;
51
- const [courseId, sectionId, topicId] = courseSectionTopicId.split("|");
52
114
  const addSearchParams = () => {
53
115
  const lastClickedExercise = {
54
116
  courseSectionTopicId: `${courseSectionTopicId}|${assignment.assignmentId}`
55
117
  };
56
118
  localStorage.setItem("lastClickedExercise", JSON.stringify(lastClickedExercise));
57
- const assignmentParam = encodeURIComponent(JSON.stringify(assignment));
58
119
  navigate(`/classrooms/${classroomId}/${courseId}/${sectionId}/${topicId}?exercise=${name}&assignmentId=${assignment.assignmentId}`);
59
120
  };
60
121
  const handleToggleRoleplays = () => {
@@ -124,8 +185,24 @@ function Exercise({
124
185
  courseSectionTopicId
125
186
  }]);
126
187
  }
127
- }), useCase === "assignment-view" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {}), useCase === "assignment-start" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PlayCircleOutline.default, {
128
- color: "primary"
188
+ }), useCase === "assignment-view" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {}), !isCreator && name.toLowerCase() === "pronunciation" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
189
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Exercises.InProgressBadge, {
190
+ progressCount: pronunciationProgress && pronunciationProgress.remainingQuestions?.length || 0
191
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Exercises.ProgressBadge, {
192
+ completions: pronunciation && pronunciation.completedCount ? pronunciation.completedCount : 0
193
+ })]
194
+ }), !isCreator && name.toLowerCase() === "translation" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
195
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Exercises.InProgressBadge, {
196
+ progressCount: translationProgress && translationProgress.remainingQuestions?.length || 0
197
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Exercises.ProgressBadge, {
198
+ completions: translation && translation.completedCount ? translation.completedCount : 0
199
+ })]
200
+ }), !isCreator && name.toLowerCase() === "listening" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
201
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Exercises.InProgressBadge, {
202
+ progressCount: listeningProgress && listeningProgress.remainingQuestions?.length || 0
203
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Exercises.ProgressBadge, {
204
+ completions: listening && listening.completedCount ? listening.completedCount : 0
205
+ })]
129
206
  })]
130
207
  })]
131
208
  }), name.toLowerCase() === "roleplays" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Collapse, {
@@ -143,6 +220,9 @@ function Exercise({
143
220
  selectedExercises: selectedExercises,
144
221
  useCase: useCase,
145
222
  assignment: assignment,
223
+ memberCourseCompletions: memberCourseCompletions,
224
+ topicProgress: topicProgress,
225
+ isCreator: isCreator,
146
226
  lastClickedExerciseId: lastClickedExerciseId
147
227
  })
148
228
  })
@@ -167,7 +247,12 @@ function ExerciseList({
167
247
  assignment,
168
248
  handleStartExercise,
169
249
  isCreator,
250
+ progressHelpers,
251
+ memberCourseCompletions,
252
+ username,
253
+ preferred_username,
170
254
  lastClickedExerciseId,
255
+ completion,
171
256
  ...otherProps
172
257
  }) {
173
258
  const courseSectionTopicId = `${courseId}|${sectionId}|${topicId}`;
@@ -195,7 +280,12 @@ function ExerciseList({
195
280
  assignment: assignment,
196
281
  handleStartExercise: handleStartExercise,
197
282
  isCreator: isCreator,
283
+ username: username,
284
+ preferred_username: preferred_username,
285
+ progressHelpers: progressHelpers,
286
+ memberCourseCompletions: memberCourseCompletions,
198
287
  lastClickedExerciseId: lastClickedExerciseId,
288
+ completion: completion,
199
289
  ...otherProps
200
290
  }, keyId);
201
291
  })
@@ -211,30 +301,25 @@ function Topic({
211
301
  description,
212
302
  picture,
213
303
  roleplays = [],
214
- bots = [],
215
- completions = [],
304
+ // bots = [],
216
305
  isMember,
217
- nextTopic,
218
- prevTopic,
219
- handleViewCourseTopic,
220
306
  isTopicHidden,
221
- completion = {},
222
- sectionIndex,
223
- index,
224
- moveTopic,
225
- onDropSection,
226
307
  phrases,
227
308
  section,
228
309
  isExerciseSelected,
229
310
  setIsExerciseSelected,
230
- getRoleplays,
231
311
  handleSelectExercise,
232
312
  selectedExercises,
233
313
  useCase,
234
314
  assignment,
235
315
  handleStartExercise,
236
316
  isCreator,
317
+ username,
318
+ preferred_username,
319
+ progressHelpers,
320
+ memberCourseCompletions,
237
321
  lastClickedExerciseId,
322
+ completion,
238
323
  ...otherProps
239
324
  }) {
240
325
  const theme = (0, _styles.useTheme)();
@@ -402,6 +487,35 @@ function Topic({
402
487
  children: description
403
488
  })
404
489
  })
490
+ }), !isCreator && completion && completion !== null && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
491
+ display: "flex",
492
+ alignItems: "center",
493
+ justifyContent: "space-between",
494
+ mt: 1,
495
+ mb: 1,
496
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
497
+ display: "inline",
498
+ flexGrow: 1,
499
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
500
+ title: `Completed ${completion.completed} / ${completion.total} exercises`,
501
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColorLinearProgress.default, {
502
+ variant: "determinate",
503
+ value: completion.percentage
504
+ })
505
+ })
506
+ })
507
+ }), isMember && !isCreator && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
508
+ display: "flex",
509
+ alignItems: "center",
510
+ justifyContent: "space-between",
511
+ mt: 1,
512
+ width: isLargeScreen ? "40%" : "100%",
513
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
514
+ ml: 1,
515
+ fontSize: 14,
516
+ minWidth: 35,
517
+ children: [completion && completion.percentage ? completion.percentage.toFixed(0) : 0, "%"]
518
+ })
405
519
  }), videoUrl && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
406
520
  display: "flex",
407
521
  alignItems: "center",
@@ -445,7 +559,7 @@ function Topic({
445
559
  section: section,
446
560
  isExerciseSelected: isExerciseSelected,
447
561
  setIsExerciseSelected: setIsExerciseSelected,
448
- roleplays: useCase === "assignment-select" ? selectedExercises?.length > 0 ? roleplays.filter(r => selectedExercises.some(e => e.roleplayId === r.roleplayId)) : roleplays : roleplays,
562
+ roleplays: roleplays,
449
563
  phrases: phrases,
450
564
  handleSelectExercise: handleSelectExercise,
451
565
  selectedExercises: selectedExercises,
@@ -453,8 +567,13 @@ function Topic({
453
567
  assignment: assignment,
454
568
  handleStartExercise: handleStartExercise,
455
569
  isCreator: isCreator,
570
+ username: username,
571
+ preferred_username: preferred_username,
572
+ progressHelpers: progressHelpers,
573
+ memberCourseCompletions: memberCourseCompletions,
456
574
  lastClickedExerciseId: lastClickedExerciseId,
457
- ...otherProps
575
+ ...otherProps,
576
+ completion: completion
458
577
  })
459
578
  })]
460
579
  })
@@ -478,7 +597,12 @@ function Section({
478
597
  handleStartExercise,
479
598
  isCreator,
480
599
  viewOnly,
600
+ username,
601
+ preferred_username,
602
+ progressHelpers,
603
+ memberCourseCompletions,
481
604
  lastClickedExerciseId,
605
+ completion,
482
606
  ...otherProps
483
607
  }) {
484
608
  const root = {
@@ -509,15 +633,17 @@ function Section({
509
633
  }, [topics, selectedTopicIds, viewOnly]);
510
634
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
511
635
  children: !isHidden && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.List, {
512
- subheader: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListSubheader, {
513
- disableGutters: true,
514
- disableSticky: true,
515
- component: "div",
516
- id: `${sectionName}-section-list-subheader`,
517
- sx: {
518
- fontWeight: !isExerciseSelected ? "bold" : "normal"
519
- },
520
- children: sectionName
636
+ subheader: /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
637
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListSubheader, {
638
+ disableGutters: true,
639
+ disableSticky: true,
640
+ component: "div",
641
+ id: `${sectionName}-section-list-subheader`,
642
+ sx: {
643
+ fontWeight: !isExerciseSelected ? "bold" : "normal"
644
+ },
645
+ children: sectionName
646
+ })
521
647
  }),
522
648
  sx: root,
523
649
  children: viewOnly ? filteredTopics.map((topic, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Topic, {
@@ -531,6 +657,7 @@ function Section({
531
657
  t: t,
532
658
  ...topic,
533
659
  ...otherProps,
660
+ completion: topic.completion,
534
661
  picture: topic.picture,
535
662
  isExerciseSelected: isExerciseSelected,
536
663
  setIsExerciseSelected: setIsExerciseSelected,
@@ -541,7 +668,11 @@ function Section({
541
668
  assignment: assignment,
542
669
  handleStartExercise: handleStartExercise,
543
670
  isCreator: isCreator,
544
- lastClickedExerciseId: lastClickedExerciseId
671
+ lastClickedExerciseId: lastClickedExerciseId,
672
+ username: username,
673
+ preferred_username: preferred_username,
674
+ progressHelpers: progressHelpers,
675
+ memberCourseCompletions: memberCourseCompletions
545
676
  }, `${sectionId}-${topic.topicId}`)) : topics.map((topic, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Topic, {
546
677
  index: i,
547
678
  topics: topics,
@@ -553,6 +684,7 @@ function Section({
553
684
  t: t,
554
685
  ...topic,
555
686
  ...otherProps,
687
+ completion: topic.completion,
556
688
  picture: topic.picture,
557
689
  isExerciseSelected: isExerciseSelected,
558
690
  setIsExerciseSelected: setIsExerciseSelected,
@@ -563,7 +695,11 @@ function Section({
563
695
  assignment: assignment,
564
696
  handleStartExercise: handleStartExercise,
565
697
  isCreator: isCreator,
566
- lastClickedExerciseId: lastClickedExerciseId
698
+ lastClickedExerciseId: lastClickedExerciseId,
699
+ username: username,
700
+ preferred_username: preferred_username,
701
+ progressHelpers: progressHelpers,
702
+ memberCourseCompletions: memberCourseCompletions
567
703
  }, `${sectionId}-${topic.topicId}`))
568
704
  })
569
705
  });
@@ -584,11 +720,23 @@ function SectionList({
584
720
  handleStartExercise,
585
721
  isCreator,
586
722
  viewOnly,
723
+ username,
724
+ preferred_username,
725
+ progressHelpers,
726
+ memberCourseCompletions,
587
727
  lastClickedExerciseId,
588
728
  ...otherProps
589
729
  }) {
730
+ const [courseSectionWithProgress, setCourseSectionWithProgress] = (0, _react.useState)([]);
731
+ (0, _react.useEffect)(() => {
732
+ if (sections && memberCourseCompletions && selectedExercises) {
733
+ const sectionsWithProgress = (0, _utils.calcCompletions)(sections, memberCourseCompletions, selectedExercises);
734
+ setCourseSectionWithProgress(sectionsWithProgress);
735
+ }
736
+ }, [sections, memberCourseCompletions, selectedExercises]);
737
+ const courseSections = courseSectionWithProgress && courseSectionWithProgress.length ? courseSectionWithProgress : sections;
590
738
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
591
- children: sections.length > 0 ? sections.map((section, index) => {
739
+ children: courseSections.length > 0 ? courseSections.map((section, index) => {
592
740
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Section, {
593
741
  index: index,
594
742
  handleFetchTopic: handleFetchTopic,
@@ -607,6 +755,10 @@ function SectionList({
607
755
  handleStartExercise: handleStartExercise,
608
756
  isCreator: isCreator,
609
757
  viewOnly: viewOnly,
758
+ username: username,
759
+ preferred_username: preferred_username,
760
+ progressHelpers: progressHelpers,
761
+ memberCourseCompletions: memberCourseCompletions,
610
762
  lastClickedExerciseId: lastClickedExerciseId,
611
763
  ...otherProps
612
764
  }, section.sectionId);
@@ -635,6 +787,10 @@ function AssignmentExerciseSelection({
635
787
  assignment,
636
788
  handleStartExercise,
637
789
  viewOnly,
790
+ username,
791
+ preferred_username,
792
+ progressHelpers,
793
+ memberCourseCompletions,
638
794
  lastClickedExerciseId,
639
795
  ...otherProps
640
796
  }) {
@@ -656,6 +812,10 @@ function AssignmentExerciseSelection({
656
812
  assignment: assignment,
657
813
  handleStartExercise: handleStartExercise,
658
814
  viewOnly: viewOnly,
815
+ username: username,
816
+ preferred_username: preferred_username,
817
+ progressHelpers: progressHelpers,
818
+ memberCourseCompletions: memberCourseCompletions,
659
819
  lastClickedExerciseId: lastClickedExerciseId,
660
820
  ...otherProps
661
821
  })
@@ -679,6 +839,10 @@ function AssignmentExerciseSelection({
679
839
  useCase: useCase,
680
840
  assignment: assignment,
681
841
  viewOnly: viewOnly,
842
+ username: username,
843
+ preferred_username: preferred_username,
844
+ progressHelpers: progressHelpers,
845
+ memberCourseCompletions: memberCourseCompletions,
682
846
  lastClickedExerciseId: lastClickedExerciseId,
683
847
  ...otherProps
684
848
  })
@@ -20,6 +20,9 @@ function AssignmentExerciseSelector({
20
20
  selectedExercises,
21
21
  viewOnly,
22
22
  useCase,
23
+ preferred_username,
24
+ progressHelpers,
25
+ memberCourseCompletions,
23
26
  lastClickedExerciseId
24
27
  }) {
25
28
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.Box, {
@@ -35,6 +38,9 @@ function AssignmentExerciseSelector({
35
38
  selectedExercises: selectedExercises,
36
39
  viewOnly: viewOnly,
37
40
  useCase: useCase,
41
+ preferred_username: preferred_username,
42
+ progressHelpers: progressHelpers,
43
+ memberCourseCompletions: memberCourseCompletions,
38
44
  lastClickedExerciseId: lastClickedExerciseId
39
45
  })
40
46
  });