@nualang/nualang-ui-components 0.1.1225 → 0.1.1226
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/Assignments/AssignmentCard/AssignmentCard.js +63 -24
- package/dist/Assignments/AssignmentCardsList/AssignmentCardsList.js +14 -4
- package/dist/Assignments/AssignmentCourseSelection/AssignmentCourseSelection.js +34 -15
- package/dist/Assignments/AssignmentExerciseSelection/AssignmentExerciseSelection.js +140 -85
- package/dist/Assignments/AssignmentExerciseSelector/AssignmentExerciseSelector.js +8 -4
- package/dist/Assignments/AssignmentRoleplaySelection/AssignmentRoleplaySelection.js +32 -32
- package/dist/Assignments/AssignmentSelectExercise/AssignmentSelectExercise.js +79 -0
- package/dist/Assignments/CreateAssignmentDialog/CreateAssignmentDialog.js +34 -15
- package/dist/Screens/Classrooms/ViewClassroom/ViewClassroom.js +9 -2
- package/package.json +1 -1
|
@@ -6,27 +6,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = AssignmentCard;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
9
|
-
var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
|
|
10
9
|
var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
|
|
11
10
|
var _ExpandLess = _interopRequireDefault(require("@mui/icons-material/ExpandLess"));
|
|
12
11
|
var _material = require("@mui/material");
|
|
13
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
-
var _AssignmentExerciseSelector = _interopRequireDefault(require("
|
|
13
|
+
var _AssignmentExerciseSelector = _interopRequireDefault(require("../AssignmentExerciseSelector/AssignmentExerciseSelector"));
|
|
14
|
+
var _Queries = require("@nualang/nualang-api-and-queries/Queries");
|
|
15
|
+
var _useConfirm = _interopRequireDefault(require("../../hooks/useConfirm"));
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
20
|
function AssignmentCard({
|
|
20
|
-
t,
|
|
21
|
+
t = text => text,
|
|
21
22
|
assignment,
|
|
22
23
|
handleStartExercise,
|
|
23
24
|
username,
|
|
24
25
|
getCourseSections,
|
|
25
26
|
getRoleplays,
|
|
26
|
-
isCreator
|
|
27
|
+
isCreator,
|
|
28
|
+
getCourses,
|
|
29
|
+
deleteAssignment,
|
|
30
|
+
handleEditAssignment
|
|
27
31
|
}) {
|
|
28
|
-
t = text => text;
|
|
29
32
|
const [expanded, setExpanded] = (0, _react.useState)(false);
|
|
33
|
+
const [confirm] = (0, _useConfirm.default)(t);
|
|
34
|
+
const handleDeleteAssignment = async (classroomId, assignmentId) => {
|
|
35
|
+
const confirmed = await confirm(t('delete_assignment'), t('delete_assignment_confirmation'));
|
|
36
|
+
if (confirmed) {
|
|
37
|
+
await deleteAssignment(classroomId, assignmentId);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
30
40
|
const calculateDaysUntilDue = dueDate => {
|
|
31
41
|
const now = new Date();
|
|
32
42
|
const due = new Date(dueDate);
|
|
@@ -46,6 +56,38 @@ function AssignmentCard({
|
|
|
46
56
|
event.stopPropagation();
|
|
47
57
|
setExpanded(prev => !prev);
|
|
48
58
|
};
|
|
59
|
+
const {
|
|
60
|
+
uniqueCourses
|
|
61
|
+
} = (0, _react.useMemo)(() => {
|
|
62
|
+
const courses = new Set();
|
|
63
|
+
assignment?.exercises?.forEach(({
|
|
64
|
+
courseSectionTopicId,
|
|
65
|
+
name
|
|
66
|
+
}) => {
|
|
67
|
+
if (courseSectionTopicId) {
|
|
68
|
+
const [courseId, sectionId, topicId] = courseSectionTopicId.split("|");
|
|
69
|
+
courses.add(courseId);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
uniqueCourses: [...courses]
|
|
74
|
+
};
|
|
75
|
+
}, [assignment?.exercises]);
|
|
76
|
+
const coursesQuery = _Queries.courses.useCourses(async filters => {
|
|
77
|
+
const response = await getCourses(filters);
|
|
78
|
+
return response;
|
|
79
|
+
}, {
|
|
80
|
+
filters: {
|
|
81
|
+
courseIds: uniqueCourses?.toString()
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
enabled: !!uniqueCourses?.length
|
|
85
|
+
});
|
|
86
|
+
const courses = (0, _react.useMemo)(() => coursesQuery.isSuccess && Array.isArray(coursesQuery.data.Items) && coursesQuery.data.Items.length ? coursesQuery.data.Items : [], [coursesQuery.data, coursesQuery.isSuccess]);
|
|
87
|
+
assignment = {
|
|
88
|
+
...assignment,
|
|
89
|
+
courses
|
|
90
|
+
};
|
|
49
91
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Card, {
|
|
50
92
|
sx: {
|
|
51
93
|
display: "flex",
|
|
@@ -60,16 +102,7 @@ function AssignmentCard({
|
|
|
60
102
|
container: true,
|
|
61
103
|
spacing: 2,
|
|
62
104
|
alignItems: "center",
|
|
63
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
64
|
-
item: true,
|
|
65
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
66
|
-
sx: {
|
|
67
|
-
width: 50,
|
|
68
|
-
height: 50
|
|
69
|
-
},
|
|
70
|
-
src: assignment.image
|
|
71
|
-
})
|
|
72
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
105
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
73
106
|
item: true,
|
|
74
107
|
xs: true,
|
|
75
108
|
flexDirection: "column",
|
|
@@ -85,7 +118,7 @@ function AssignmentCard({
|
|
|
85
118
|
},
|
|
86
119
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.LinearProgress, {
|
|
87
120
|
variant: "determinate",
|
|
88
|
-
value: assignment.completed / assignment.
|
|
121
|
+
value: assignment.completed / assignment.assignedStudents.length * 100 //change this to the actual value of student completed
|
|
89
122
|
,
|
|
90
123
|
sx: {
|
|
91
124
|
height: 10,
|
|
@@ -99,17 +132,21 @@ function AssignmentCard({
|
|
|
99
132
|
color: "text.secondary",
|
|
100
133
|
marginLeft: 1
|
|
101
134
|
},
|
|
102
|
-
children: `${Math.round(assignment.completed / assignment.
|
|
135
|
+
children: `${Math.round(assignment.completed / assignment.assignedStudents.length * 100)}%`
|
|
103
136
|
})]
|
|
104
137
|
})]
|
|
105
138
|
}), isCreator && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
106
139
|
item: true,
|
|
107
140
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
141
|
+
onClick: () => handleEditAssignment(assignment),
|
|
108
142
|
color: "primary",
|
|
109
143
|
children: t("edit")
|
|
110
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
144
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Button, {
|
|
111
145
|
color: "primary",
|
|
112
|
-
|
|
146
|
+
onClick: () => {
|
|
147
|
+
handleDeleteAssignment(assignment.classroomId, assignment.assignmentId);
|
|
148
|
+
},
|
|
149
|
+
children: [t("delete"), " "]
|
|
113
150
|
})]
|
|
114
151
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Grid, {
|
|
115
152
|
item: true,
|
|
@@ -140,7 +177,7 @@ function AssignmentCard({
|
|
|
140
177
|
md: 9.5,
|
|
141
178
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
142
179
|
variant: "body2",
|
|
143
|
-
children: assignment.
|
|
180
|
+
children: assignment.instructions
|
|
144
181
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
145
182
|
mt: 2,
|
|
146
183
|
width: "80%",
|
|
@@ -151,8 +188,9 @@ function AssignmentCard({
|
|
|
151
188
|
username: username,
|
|
152
189
|
getCourseSections: getCourseSections,
|
|
153
190
|
getRoleplays: getRoleplays,
|
|
154
|
-
|
|
155
|
-
|
|
191
|
+
isCreator: isCreator,
|
|
192
|
+
viewOnly: true,
|
|
193
|
+
useCase: isCreator ? "assignment-view" : "assignment-start"
|
|
156
194
|
})
|
|
157
195
|
})]
|
|
158
196
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
@@ -169,7 +207,7 @@ function AssignmentCard({
|
|
|
169
207
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
170
208
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
171
209
|
variant: "h4",
|
|
172
|
-
children:
|
|
210
|
+
children: "2"
|
|
173
211
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
174
212
|
variant: "body2",
|
|
175
213
|
color: "text.secondary",
|
|
@@ -186,7 +224,7 @@ function AssignmentCard({
|
|
|
186
224
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
187
225
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
188
226
|
variant: "h4",
|
|
189
|
-
children: assignment.
|
|
227
|
+
children: assignment.assignedStudents.length
|
|
190
228
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
191
229
|
variant: "body2",
|
|
192
230
|
color: "text.secondary",
|
|
@@ -215,6 +253,7 @@ AssignmentCard.propTypes = {
|
|
|
215
253
|
dueDate: _propTypes.default.string.isRequired,
|
|
216
254
|
completed: _propTypes.default.number,
|
|
217
255
|
assigned: _propTypes.default.number,
|
|
256
|
+
assignedStudents: _propTypes.default.array,
|
|
218
257
|
t: _propTypes.default.func
|
|
219
258
|
}).isRequired
|
|
220
259
|
};
|
|
@@ -17,8 +17,13 @@ const AssignmentCardsList = ({
|
|
|
17
17
|
t = text => text,
|
|
18
18
|
assignments = [],
|
|
19
19
|
isCreator,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
handleCreateAssignment,
|
|
21
|
+
getCourses,
|
|
22
|
+
getCourseSections,
|
|
23
|
+
getRoleplays,
|
|
24
|
+
deleteAssignment,
|
|
25
|
+
handleEditAssignment,
|
|
26
|
+
refreshAssignments
|
|
22
27
|
}) => {
|
|
23
28
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
|
|
24
29
|
mt: 3,
|
|
@@ -95,7 +100,7 @@ const AssignmentCardsList = ({
|
|
|
95
100
|
placement: "left",
|
|
96
101
|
title: t("refresh_assignments"),
|
|
97
102
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
98
|
-
onClick:
|
|
103
|
+
onClick: refreshAssignments,
|
|
99
104
|
"aria-label": "refresh",
|
|
100
105
|
size: "large",
|
|
101
106
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Refresh.default, {})
|
|
@@ -104,7 +109,12 @@ const AssignmentCardsList = ({
|
|
|
104
109
|
}), assignments.map(assignment => /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentCard.default, {
|
|
105
110
|
assignment: assignment,
|
|
106
111
|
t: t,
|
|
107
|
-
isCreator: isCreator
|
|
112
|
+
isCreator: isCreator,
|
|
113
|
+
getCourses: getCourses,
|
|
114
|
+
getCourseSections: getCourseSections,
|
|
115
|
+
getRoleplays: getRoleplays,
|
|
116
|
+
deleteAssignment: deleteAssignment,
|
|
117
|
+
handleEditAssignment: handleEditAssignment
|
|
108
118
|
}, assignment.id))]
|
|
109
119
|
})
|
|
110
120
|
});
|
|
@@ -18,8 +18,7 @@ function Course({
|
|
|
18
18
|
getCourseSections,
|
|
19
19
|
getRoleplays,
|
|
20
20
|
username,
|
|
21
|
-
|
|
22
|
-
t,
|
|
21
|
+
t = text => text,
|
|
23
22
|
isExerciseSelected,
|
|
24
23
|
setIsExerciseSelected,
|
|
25
24
|
isDialogOpen,
|
|
@@ -28,10 +27,12 @@ function Course({
|
|
|
28
27
|
useCase,
|
|
29
28
|
assignment,
|
|
30
29
|
handleStartExercise,
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
isCreator,
|
|
31
|
+
viewOnly
|
|
33
32
|
}) {
|
|
34
33
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
34
|
+
const [selectedSectionIds, setSelectedSectionIds] = (0, _react.useState)([]);
|
|
35
|
+
const [filteredSections, setFilteredSections] = (0, _react.useState)([]);
|
|
35
36
|
const sectionsQuery = _Queries.courses.useCourseSections(async (courseId, filters) => {
|
|
36
37
|
const response = await getCourseSections(courseId, filters);
|
|
37
38
|
return response;
|
|
@@ -44,8 +45,29 @@ function Course({
|
|
|
44
45
|
}, {
|
|
45
46
|
enabled: !!course.courseId && isDialogOpen
|
|
46
47
|
});
|
|
48
|
+
(0, _react.useEffect)(() => {
|
|
49
|
+
assignment?.exercises?.forEach(exercise => {
|
|
50
|
+
if (exercise.courseSectionTopicId) {
|
|
51
|
+
const sectionId = exercise.courseSectionTopicId.split("|")[1];
|
|
52
|
+
setSelectedSectionIds(prev => [...prev, sectionId]);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}, [selectedExercises]);
|
|
56
|
+
(0, _react.useEffect)(() => {
|
|
57
|
+
selectedExercises?.forEach(exercise => {
|
|
58
|
+
if (exercise.courseSectionTopicId) {
|
|
59
|
+
const sectionId = exercise.courseSectionTopicId.split("|")[1];
|
|
60
|
+
setSelectedSectionIds(prev => [...prev, sectionId]);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}, [selectedExercises]);
|
|
47
64
|
const courseSections = (0, _react.useMemo)(() => sectionsQuery.isSuccess && Array.isArray(sectionsQuery.data.Items) && sectionsQuery.data.Items.length ? sectionsQuery.data.Items : [], [sectionsQuery.data, sectionsQuery.isSuccess]);
|
|
48
65
|
const isCourseEmpty = courseSections.length === 0 && !sectionsQuery.isLoading ? true : false;
|
|
66
|
+
(0, _react.useEffect)(() => {
|
|
67
|
+
if (viewOnly) {
|
|
68
|
+
setFilteredSections(courseSections.filter(section => selectedSectionIds.includes(section.sectionId)));
|
|
69
|
+
}
|
|
70
|
+
}, [courseSections, selectedSectionIds, viewOnly]);
|
|
49
71
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.List, {
|
|
50
72
|
disablePadding: true,
|
|
51
73
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
@@ -93,9 +115,8 @@ function Course({
|
|
|
93
115
|
ml: 3.5,
|
|
94
116
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentExerciseSelection.default, {
|
|
95
117
|
t: t,
|
|
96
|
-
sections: courseSections,
|
|
118
|
+
sections: viewOnly ? filteredSections : courseSections,
|
|
97
119
|
isLoading: sectionsQuery.isLoading,
|
|
98
|
-
handleCreateGame: handleCreateGame,
|
|
99
120
|
courseId: course.courseId,
|
|
100
121
|
isExerciseSelected: isExerciseSelected,
|
|
101
122
|
setIsExerciseSelected: setIsExerciseSelected,
|
|
@@ -105,8 +126,8 @@ function Course({
|
|
|
105
126
|
useCase: useCase,
|
|
106
127
|
assignment: assignment,
|
|
107
128
|
handleStartExercise: handleStartExercise,
|
|
108
|
-
|
|
109
|
-
|
|
129
|
+
isCreator: isCreator,
|
|
130
|
+
viewOnly: viewOnly
|
|
110
131
|
})
|
|
111
132
|
})
|
|
112
133
|
})]
|
|
@@ -117,8 +138,7 @@ function AssignmentCourseSelection({
|
|
|
117
138
|
getCourseSections,
|
|
118
139
|
getRoleplays,
|
|
119
140
|
username,
|
|
120
|
-
|
|
121
|
-
t,
|
|
141
|
+
t = text => text,
|
|
122
142
|
isExerciseSelected,
|
|
123
143
|
setIsExerciseSelected,
|
|
124
144
|
handleSelectExercise,
|
|
@@ -126,8 +146,8 @@ function AssignmentCourseSelection({
|
|
|
126
146
|
useCase,
|
|
127
147
|
assignment,
|
|
128
148
|
handleStartExercise,
|
|
129
|
-
isAssignment,
|
|
130
149
|
isCreator,
|
|
150
|
+
viewOnly,
|
|
131
151
|
...otherProps
|
|
132
152
|
}) {
|
|
133
153
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
@@ -137,17 +157,16 @@ function AssignmentCourseSelection({
|
|
|
137
157
|
getCourseSections: getCourseSections,
|
|
138
158
|
getRoleplays: getRoleplays,
|
|
139
159
|
username: username,
|
|
140
|
-
handleCreateGame: handleCreateGame,
|
|
141
160
|
t: t,
|
|
142
161
|
isExerciseSelected: isExerciseSelected,
|
|
143
162
|
setIsExerciseSelected: setIsExerciseSelected,
|
|
144
163
|
handleSelectExercise: handleSelectExercise,
|
|
145
|
-
selectedExercises: selectedExercises,
|
|
164
|
+
selectedExercises: assignment ? assignment.exercises?.filter(exercise => exercise?.roleplayId || exercise?.courseSectionTopicId?.split("|")[0] === course?.courseId) : selectedExercises?.filter(exercise => exercise?.roleplayId || exercise?.courseSectionTopicId?.split("|")[0] === course?.courseId),
|
|
146
165
|
useCase: useCase,
|
|
147
166
|
assignment: assignment,
|
|
148
167
|
handleStartExercise: handleStartExercise,
|
|
149
|
-
|
|
150
|
-
|
|
168
|
+
isCreator: isCreator,
|
|
169
|
+
viewOnly: viewOnly
|
|
151
170
|
}))
|
|
152
171
|
});
|
|
153
172
|
}
|
|
@@ -19,14 +19,13 @@ var _Forum = _interopRequireDefault(require("@mui/icons-material/Forum"));
|
|
|
19
19
|
var _OndemandVideo = _interopRequireDefault(require("@mui/icons-material/OndemandVideo"));
|
|
20
20
|
var _AssignmentRoleplaySelection = _interopRequireDefault(require("../AssignmentRoleplaySelection/AssignmentRoleplaySelection"));
|
|
21
21
|
var _CardElements = require("../../Cards/CardElements");
|
|
22
|
-
var
|
|
22
|
+
var _reactRouterDom = require("react-router-dom");
|
|
23
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
24
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
25
25
|
function Exercise({
|
|
26
26
|
name,
|
|
27
27
|
description,
|
|
28
28
|
courseSectionTopicId,
|
|
29
|
-
handleCreateGame,
|
|
30
29
|
section,
|
|
31
30
|
t,
|
|
32
31
|
isExerciseSelected,
|
|
@@ -35,30 +34,26 @@ function Exercise({
|
|
|
35
34
|
phrases,
|
|
36
35
|
handleSelectExercise = null,
|
|
37
36
|
selectedExercises,
|
|
38
|
-
useCase
|
|
39
|
-
assignment,
|
|
40
|
-
handleStartExercise,
|
|
41
|
-
isAssignment,
|
|
42
|
-
isCreator
|
|
37
|
+
useCase
|
|
43
38
|
}) {
|
|
44
39
|
const [listeningHidden, setListeningHidden] = (0, _react.useState)(false);
|
|
45
40
|
const [translationHidden, setTranslationHidden] = (0, _react.useState)(false);
|
|
46
41
|
const [pronunciationHidden, setPronunciationHidden] = (0, _react.useState)(false);
|
|
47
|
-
const isAssignmentExerciseSelected = selectedExercises
|
|
42
|
+
const isAssignmentExerciseSelected = selectedExercises?.some(e => e.name === name && e.courseSectionTopicId === courseSectionTopicId);
|
|
48
43
|
const noRoleplays = name.toLowerCase() === "roleplays" && roleplays.length === 0;
|
|
49
44
|
const [roleplaysOpen, setRoleplaysOpen] = (0, _react.useState)(noRoleplays ? false : true);
|
|
45
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
46
|
+
const params = (0, _reactRouterDom.useParams)();
|
|
47
|
+
const {
|
|
48
|
+
classroomId
|
|
49
|
+
} = params;
|
|
50
|
+
const [courseId, sectionId, topicId] = courseSectionTopicId.split("|");
|
|
51
|
+
const addSearchParams = () => {
|
|
52
|
+
navigate(`/classrooms/${classroomId}/${courseId}/${sectionId}/${topicId}?exercise=${name}`);
|
|
53
|
+
};
|
|
50
54
|
const handleToggleRoleplays = () => {
|
|
51
55
|
setRoleplaysOpen(!roleplaysOpen);
|
|
52
56
|
};
|
|
53
|
-
const handleExerciseSelected = () => {
|
|
54
|
-
setIsExerciseSelected(true);
|
|
55
|
-
handleCreateGame({
|
|
56
|
-
courseSectionTopicId: courseSectionTopicId,
|
|
57
|
-
exercise: name,
|
|
58
|
-
timer: 30,
|
|
59
|
-
answerOption: 0
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
57
|
(0, _react.useEffect)(() => {
|
|
63
58
|
section.topics.forEach(topic => {
|
|
64
59
|
if (topic.hiddenExercises && topic.hiddenExercises.includes("listening")) {
|
|
@@ -80,10 +75,10 @@ function Exercise({
|
|
|
80
75
|
title: name === "roleplays" && noRoleplays ? t("topic_no_roleplays") : !isValidExercise ? t("minimum_two_phrases") : "",
|
|
81
76
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ListItemButton, {
|
|
82
77
|
onClick: () => {
|
|
83
|
-
name.toLowerCase() === "roleplays" ? handleToggleRoleplays() : useCase === "assignment" ? handleSelectExercise([{
|
|
78
|
+
name.toLowerCase() === "roleplays" ? handleToggleRoleplays() : useCase === "assignment-select" ? handleSelectExercise([{
|
|
84
79
|
name,
|
|
85
80
|
courseSectionTopicId
|
|
86
|
-
}]) :
|
|
81
|
+
}]) : useCase === "assignment-start" ? addSearchParams() : null;
|
|
87
82
|
},
|
|
88
83
|
display: "flex",
|
|
89
84
|
alignItems: "center",
|
|
@@ -110,8 +105,8 @@ function Exercise({
|
|
|
110
105
|
})
|
|
111
106
|
}), name.toLowerCase() === "roleplays" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
112
107
|
children: roleplaysOpen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})
|
|
113
|
-
}), (name.toLowerCase() === "listening" || name.toLowerCase() === "translation" || name.toLowerCase() === "pronunciation") && /*#__PURE__*/(0, _jsxRuntime.
|
|
114
|
-
children:
|
|
108
|
+
}), (name.toLowerCase() === "listening" || name.toLowerCase() === "translation" || name.toLowerCase() === "pronunciation") && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ListItemIcon, {
|
|
109
|
+
children: [useCase === "assignment-select" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
115
110
|
checked: isAssignmentExerciseSelected,
|
|
116
111
|
onClick: event => {
|
|
117
112
|
event.stopPropagation();
|
|
@@ -123,14 +118,9 @@ function Exercise({
|
|
|
123
118
|
courseSectionTopicId
|
|
124
119
|
}]);
|
|
125
120
|
}
|
|
126
|
-
})
|
|
127
|
-
/*#__PURE__*/
|
|
128
|
-
//add check to see if the exercise is completed
|
|
129
|
-
(0, _jsxRuntime.jsx)(_CheckCircle.default, {
|
|
130
|
-
color: "success"
|
|
131
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_PlayCircleOutline.default, {
|
|
121
|
+
}), useCase === "assignment-view" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {}), useCase === "assignment-start" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PlayCircleOutline.default, {
|
|
132
122
|
color: "primary"
|
|
133
|
-
})
|
|
123
|
+
})]
|
|
134
124
|
})]
|
|
135
125
|
}), name.toLowerCase() === "roleplays" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Collapse, {
|
|
136
126
|
in: roleplaysOpen,
|
|
@@ -140,7 +130,6 @@ function Exercise({
|
|
|
140
130
|
ml: 7,
|
|
141
131
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentRoleplaySelection.default, {
|
|
142
132
|
roleplays: roleplays,
|
|
143
|
-
handleCreateGame: handleCreateGame,
|
|
144
133
|
courseSectionTopicId: courseSectionTopicId,
|
|
145
134
|
t: t,
|
|
146
135
|
isExerciseSelected: isExerciseSelected,
|
|
@@ -159,7 +148,6 @@ function ExerciseList({
|
|
|
159
148
|
courseId,
|
|
160
149
|
sectionId,
|
|
161
150
|
topicId,
|
|
162
|
-
handleCreateGame,
|
|
163
151
|
section,
|
|
164
152
|
isExerciseSelected,
|
|
165
153
|
setIsExerciseSelected,
|
|
@@ -170,7 +158,6 @@ function ExerciseList({
|
|
|
170
158
|
useCase,
|
|
171
159
|
assignment,
|
|
172
160
|
handleStartExercise,
|
|
173
|
-
isAssignment,
|
|
174
161
|
isCreator,
|
|
175
162
|
...otherProps
|
|
176
163
|
}) {
|
|
@@ -185,7 +172,6 @@ function ExerciseList({
|
|
|
185
172
|
...exercise,
|
|
186
173
|
isMember: isMember,
|
|
187
174
|
courseSectionTopicId: courseSectionTopicId,
|
|
188
|
-
handleCreateGame: handleCreateGame,
|
|
189
175
|
section: section,
|
|
190
176
|
isExerciseSelected: isExerciseSelected,
|
|
191
177
|
setIsExerciseSelected: setIsExerciseSelected,
|
|
@@ -199,7 +185,6 @@ function ExerciseList({
|
|
|
199
185
|
useCase: useCase,
|
|
200
186
|
assignment: assignment,
|
|
201
187
|
handleStartExercise: handleStartExercise,
|
|
202
|
-
isAssignment: isAssignment,
|
|
203
188
|
isCreator: isCreator,
|
|
204
189
|
...otherProps
|
|
205
190
|
}, keyId);
|
|
@@ -228,7 +213,6 @@ function Topic({
|
|
|
228
213
|
index,
|
|
229
214
|
moveTopic,
|
|
230
215
|
onDropSection,
|
|
231
|
-
handleCreateGame,
|
|
232
216
|
phrases,
|
|
233
217
|
section,
|
|
234
218
|
isExerciseSelected,
|
|
@@ -239,7 +223,6 @@ function Topic({
|
|
|
239
223
|
useCase,
|
|
240
224
|
assignment,
|
|
241
225
|
handleStartExercise,
|
|
242
|
-
isAssignment,
|
|
243
226
|
isCreator,
|
|
244
227
|
...otherProps
|
|
245
228
|
}) {
|
|
@@ -247,32 +230,70 @@ function Topic({
|
|
|
247
230
|
const isLargeScreen = (0, _useMediaQuery.default)(theme.breakpoints.up("sm"));
|
|
248
231
|
const [isExerciseListOpen, setExerciseListOpen] = (0, _react.useState)(false);
|
|
249
232
|
const [isWholeTopicSelected, setIsWholeTopicSelected] = (0, _react.useState)(false);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
233
|
+
let exercises;
|
|
234
|
+
switch (useCase) {
|
|
235
|
+
case "assignment-select":
|
|
236
|
+
exercises = [{
|
|
237
|
+
name: "translation",
|
|
238
|
+
description: `translation_exercise_desc`
|
|
239
|
+
}, {
|
|
240
|
+
name: "listening",
|
|
241
|
+
description: `listening_exercise_desc`
|
|
242
|
+
}, {
|
|
243
|
+
name: "pronunciation",
|
|
244
|
+
description: `pronunciation_exercise_desc`
|
|
245
|
+
}, {
|
|
246
|
+
name: "roleplays",
|
|
247
|
+
description: `roleplay_exercise_desc`
|
|
248
|
+
}];
|
|
249
|
+
break;
|
|
250
|
+
case "assignment-view":
|
|
251
|
+
exercises = [{
|
|
252
|
+
name: "translation",
|
|
253
|
+
description: `translation_exercise_desc`
|
|
254
|
+
}, {
|
|
255
|
+
name: "listening",
|
|
256
|
+
description: `listening_exercise_desc`
|
|
257
|
+
}, {
|
|
258
|
+
name: "pronunciation",
|
|
259
|
+
description: `pronunciation_exercise_desc`
|
|
260
|
+
}, {
|
|
261
|
+
name: "roleplays",
|
|
262
|
+
description: `roleplay_exercise_desc`
|
|
263
|
+
}].filter(exercise => selectedExercises?.some(e => e.name === exercise.name || exercise.name === "roleplays" && e.roleplayId));
|
|
264
|
+
break;
|
|
265
|
+
case "assignment-start":
|
|
266
|
+
exercises = [{
|
|
267
|
+
name: "translation",
|
|
268
|
+
description: `translation_exercise_desc`
|
|
269
|
+
}, {
|
|
270
|
+
name: "listening",
|
|
271
|
+
description: `listening_exercise_desc`
|
|
272
|
+
}, {
|
|
273
|
+
name: "pronunciation",
|
|
274
|
+
description: `pronunciation_exercise_desc`
|
|
275
|
+
}, {
|
|
276
|
+
name: "roleplays",
|
|
277
|
+
description: `roleplay_exercise_desc`
|
|
278
|
+
}].filter(exercise => selectedExercises?.some(e => e.name === exercise.name || exercise.name === "roleplays" && e.roleplayId));
|
|
279
|
+
break;
|
|
280
|
+
default:
|
|
281
|
+
exercises = [];
|
|
282
|
+
}
|
|
283
|
+
let games;
|
|
284
|
+
switch (useCase) {
|
|
285
|
+
case "assignment-view":
|
|
286
|
+
games = ["roleplay-story", "roleplay-fill-in-the-blanks", "roleplay-act-it-out", "roleplay-act-it-out-listening", "roleplay-act-it-out-speaking", "roleplay-act-it-out-listening-speaking"].filter(game => selectedExercises.some(e => e.game === game));
|
|
287
|
+
break;
|
|
288
|
+
case "assignment-start":
|
|
289
|
+
games = ["roleplay-story", "roleplay-fill-in-the-blanks", "roleplay-act-it-out", "roleplay-act-it-out-listening", "roleplay-act-it-out-speaking", "roleplay-act-it-out-listening-speaking"].filter(game => selectedExercises.some(e => e.game === game));
|
|
290
|
+
break;
|
|
291
|
+
default:
|
|
292
|
+
games = ["roleplay-story", "roleplay-fill-in-the-blanks", "roleplay-act-it-out", "roleplay-act-it-out-listening", "roleplay-act-it-out-speaking", "roleplay-act-it-out-listening-speaking"];
|
|
293
|
+
}
|
|
273
294
|
(0, _react.useEffect)(() => {
|
|
274
|
-
const exerciseCount = selectedExercises
|
|
275
|
-
const roleplayCount = selectedExercises
|
|
295
|
+
const exerciseCount = selectedExercises?.filter(exercise => exercise.courseSectionTopicId === `${courseId}|${sectionId}|${topicId}`).length;
|
|
296
|
+
const roleplayCount = selectedExercises?.filter(exercise => exercise.roleplayId && roleplays?.some(roleplay => roleplay.roleplayId === exercise.roleplayId)).length;
|
|
276
297
|
const total = roleplays.length * 6 + 3;
|
|
277
298
|
if (exerciseCount + roleplayCount === total) {
|
|
278
299
|
setIsWholeTopicSelected(true);
|
|
@@ -282,12 +303,12 @@ function Topic({
|
|
|
282
303
|
}, [selectedExercises]);
|
|
283
304
|
const handleSelectAll = () => {
|
|
284
305
|
if (isWholeTopicSelected) {
|
|
285
|
-
const removeExercises = selectedExercises
|
|
306
|
+
const removeExercises = selectedExercises?.filter(exercise => exercise.courseSectionTopicId === `${courseId}|${sectionId}|${topicId}` || exercise.roleplayId && roleplays?.some(roleplay => roleplay.roleplayId === exercise.roleplayId));
|
|
286
307
|
handleSelectExercise(removeExercises);
|
|
287
308
|
} else {
|
|
288
309
|
let exercisesToAdd = [];
|
|
289
|
-
exercises
|
|
290
|
-
if (!selectedExercises
|
|
310
|
+
exercises?.filter(e => e.name !== "roleplays").forEach(exercise => {
|
|
311
|
+
if (!selectedExercises?.some(e => e.courseSectionTopicId === `${courseId}|${sectionId}|${topicId}` && e.name === exercise.name)) {
|
|
291
312
|
exercisesToAdd = [...exercisesToAdd, {
|
|
292
313
|
courseSectionTopicId: `${courseId}|${sectionId}|${topicId}`,
|
|
293
314
|
name: exercise.name
|
|
@@ -296,7 +317,7 @@ function Topic({
|
|
|
296
317
|
});
|
|
297
318
|
roleplays.forEach(roleplay => {
|
|
298
319
|
games.forEach(game => {
|
|
299
|
-
if (!selectedExercises
|
|
320
|
+
if (!selectedExercises?.some(e => e.roleplayId === roleplay.roleplayId && e.game === game)) {
|
|
300
321
|
exercisesToAdd = [...exercisesToAdd, {
|
|
301
322
|
roleplayId: roleplay.roleplayId,
|
|
302
323
|
game
|
|
@@ -310,7 +331,7 @@ function Topic({
|
|
|
310
331
|
const toggleExerciseList = () => {
|
|
311
332
|
setExerciseListOpen(!isExerciseListOpen);
|
|
312
333
|
};
|
|
313
|
-
const hasNonEmptyRoleplay = roleplays
|
|
334
|
+
const hasNonEmptyRoleplay = roleplays?.some(roleplay => roleplay?.script?.length !== 0 && roleplay?.script?.some(line => line.text !== undefined));
|
|
314
335
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
315
336
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Tooltip, {
|
|
316
337
|
title: phrases.length === 0 ? t("topic_no_phrases") : "",
|
|
@@ -373,7 +394,7 @@ function Topic({
|
|
|
373
394
|
})]
|
|
374
395
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
375
396
|
children: isExerciseListOpen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandLess.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ExpandMore.default, {})
|
|
376
|
-
}), useCase === "assignment" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
397
|
+
}), useCase === "assignment-select" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
377
398
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
378
399
|
checked: isWholeTopicSelected,
|
|
379
400
|
onClick: event => {
|
|
@@ -397,18 +418,16 @@ function Topic({
|
|
|
397
418
|
courseId: courseId,
|
|
398
419
|
sectionId: sectionId,
|
|
399
420
|
topicId: topicId,
|
|
400
|
-
handleCreateGame: handleCreateGame,
|
|
401
421
|
section: section,
|
|
402
422
|
isExerciseSelected: isExerciseSelected,
|
|
403
423
|
setIsExerciseSelected: setIsExerciseSelected,
|
|
404
|
-
roleplays: roleplays,
|
|
424
|
+
roleplays: useCase === "assignment-select" ? selectedExercises?.length > 0 ? roleplays.filter(r => selectedExercises.some(e => e.roleplayId === r.roleplayId)) : roleplays : roleplays,
|
|
405
425
|
phrases: phrases,
|
|
406
426
|
handleSelectExercise: handleSelectExercise,
|
|
407
427
|
selectedExercises: selectedExercises,
|
|
408
428
|
useCase: useCase,
|
|
409
429
|
assignment: assignment,
|
|
410
430
|
handleStartExercise: handleStartExercise,
|
|
411
|
-
isAssignment: isAssignment,
|
|
412
431
|
isCreator: isCreator,
|
|
413
432
|
...otherProps
|
|
414
433
|
})
|
|
@@ -423,7 +442,6 @@ function Section({
|
|
|
423
442
|
sectionName,
|
|
424
443
|
isHidden,
|
|
425
444
|
topics = [],
|
|
426
|
-
handleCreateGame,
|
|
427
445
|
section,
|
|
428
446
|
isExerciseSelected,
|
|
429
447
|
setIsExerciseSelected,
|
|
@@ -433,13 +451,36 @@ function Section({
|
|
|
433
451
|
useCase,
|
|
434
452
|
assignment,
|
|
435
453
|
handleStartExercise,
|
|
436
|
-
isAssignment,
|
|
437
454
|
isCreator,
|
|
455
|
+
viewOnly,
|
|
438
456
|
...otherProps
|
|
439
457
|
}) {
|
|
440
458
|
const root = {
|
|
441
459
|
width: "100%"
|
|
442
460
|
};
|
|
461
|
+
const [selectedTopicIds, setSelectedTopicIds] = (0, _react.useState)([]);
|
|
462
|
+
const [filteredTopics, setFilteredTopics] = (0, _react.useState)([]);
|
|
463
|
+
(0, _react.useEffect)(() => {
|
|
464
|
+
assignment?.exercises?.forEach(exercise => {
|
|
465
|
+
if (exercise.courseSectionTopicId) {
|
|
466
|
+
const topicId = exercise.courseSectionTopicId.split("|")[2];
|
|
467
|
+
setSelectedTopicIds(prev => [...prev, topicId]);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}, [selectedExercises]);
|
|
471
|
+
(0, _react.useEffect)(() => {
|
|
472
|
+
selectedExercises?.forEach(exercise => {
|
|
473
|
+
if (exercise.courseSectionTopicId) {
|
|
474
|
+
const topicId = exercise.courseSectionTopicId.split("|")[2];
|
|
475
|
+
setSelectedTopicIds(prev => [...prev, topicId]);
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}, [selectedExercises]);
|
|
479
|
+
(0, _react.useEffect)(() => {
|
|
480
|
+
if (viewOnly) {
|
|
481
|
+
setFilteredTopics(topics.filter(topic => selectedTopicIds.includes(topic.topicId)));
|
|
482
|
+
}
|
|
483
|
+
}, [topics, selectedTopicIds, viewOnly]);
|
|
443
484
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
444
485
|
children: !isHidden && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.List, {
|
|
445
486
|
subheader: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListSubheader, {
|
|
@@ -453,12 +494,32 @@ function Section({
|
|
|
453
494
|
children: sectionName
|
|
454
495
|
}),
|
|
455
496
|
sx: root,
|
|
456
|
-
children:
|
|
497
|
+
children: viewOnly ? filteredTopics.map((topic, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Topic, {
|
|
498
|
+
index: i,
|
|
499
|
+
topics: topics,
|
|
500
|
+
topicLength: topics.length,
|
|
501
|
+
sectionId: sectionId,
|
|
502
|
+
courseId: courseId,
|
|
503
|
+
phrases: topic.phrases,
|
|
504
|
+
section: section,
|
|
505
|
+
t: t,
|
|
506
|
+
...topic,
|
|
507
|
+
...otherProps,
|
|
508
|
+
picture: topic.picture,
|
|
509
|
+
isExerciseSelected: isExerciseSelected,
|
|
510
|
+
setIsExerciseSelected: setIsExerciseSelected,
|
|
511
|
+
getRoleplays: getRoleplays,
|
|
512
|
+
handleSelectExercise: handleSelectExercise,
|
|
513
|
+
selectedExercises: assignment ? assignment.exercises?.filter(exercise => exercise.roleplayId || exercise.courseSectionTopicId.split("|")[2] === topic.topicId) : selectedExercises?.filter(exercise => exercise.roleplayId || exercise.courseSectionTopicId.split("|")[2] === topic.topicId),
|
|
514
|
+
useCase: useCase,
|
|
515
|
+
assignment: assignment,
|
|
516
|
+
handleStartExercise: handleStartExercise,
|
|
517
|
+
isCreator: isCreator
|
|
518
|
+
}, `${sectionId}-${topic.topicId}`)) : topics.map((topic, i) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Topic, {
|
|
457
519
|
index: i,
|
|
458
520
|
topics: topics,
|
|
459
521
|
topicLength: topics.length,
|
|
460
522
|
sectionId: sectionId,
|
|
461
|
-
handleCreateGame: handleCreateGame,
|
|
462
523
|
courseId: courseId,
|
|
463
524
|
phrases: topic.phrases,
|
|
464
525
|
section: section,
|
|
@@ -474,7 +535,6 @@ function Section({
|
|
|
474
535
|
useCase: useCase,
|
|
475
536
|
assignment: assignment,
|
|
476
537
|
handleStartExercise: handleStartExercise,
|
|
477
|
-
isAssignment: isAssignment,
|
|
478
538
|
isCreator: isCreator
|
|
479
539
|
}, `${sectionId}-${topic.topicId}`))
|
|
480
540
|
})
|
|
@@ -484,7 +544,6 @@ function SectionList({
|
|
|
484
544
|
sections = [],
|
|
485
545
|
handleFetchTopic,
|
|
486
546
|
teachClassrooms,
|
|
487
|
-
handleCreateGame,
|
|
488
547
|
courseId,
|
|
489
548
|
t,
|
|
490
549
|
isExerciseSelected,
|
|
@@ -495,8 +554,8 @@ function SectionList({
|
|
|
495
554
|
useCase,
|
|
496
555
|
assignment,
|
|
497
556
|
handleStartExercise,
|
|
498
|
-
isAssignment,
|
|
499
557
|
isCreator,
|
|
558
|
+
viewOnly,
|
|
500
559
|
...otherProps
|
|
501
560
|
}) {
|
|
502
561
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
@@ -505,7 +564,6 @@ function SectionList({
|
|
|
505
564
|
index: index,
|
|
506
565
|
handleFetchTopic: handleFetchTopic,
|
|
507
566
|
teachClassrooms: teachClassrooms,
|
|
508
|
-
handleCreateGame: handleCreateGame,
|
|
509
567
|
courseId: courseId,
|
|
510
568
|
t: t,
|
|
511
569
|
...section,
|
|
@@ -514,12 +572,12 @@ function SectionList({
|
|
|
514
572
|
section: section,
|
|
515
573
|
getRoleplays: getRoleplays,
|
|
516
574
|
handleSelectExercise: handleSelectExercise,
|
|
517
|
-
selectedExercises: selectedExercises,
|
|
575
|
+
selectedExercises: selectedExercises?.filter(exercise => exercise?.roleplayId || exercise?.courseSectionTopicId?.split("|")[1] === section.sectionId),
|
|
518
576
|
useCase: useCase,
|
|
519
577
|
assignment: assignment,
|
|
520
578
|
handleStartExercise: handleStartExercise,
|
|
521
|
-
isAssignment: isAssignment,
|
|
522
579
|
isCreator: isCreator,
|
|
580
|
+
viewOnly: viewOnly,
|
|
523
581
|
...otherProps
|
|
524
582
|
}, section.sectionId);
|
|
525
583
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
@@ -538,7 +596,6 @@ function AssignmentExerciseSelection({
|
|
|
538
596
|
handleSwitchChange,
|
|
539
597
|
isLoading,
|
|
540
598
|
teachClassrooms,
|
|
541
|
-
handleCreateGame,
|
|
542
599
|
isExerciseSelected,
|
|
543
600
|
setIsExerciseSelected,
|
|
544
601
|
getRoleplays,
|
|
@@ -547,7 +604,7 @@ function AssignmentExerciseSelection({
|
|
|
547
604
|
useCase,
|
|
548
605
|
assignment,
|
|
549
606
|
handleStartExercise,
|
|
550
|
-
|
|
607
|
+
viewOnly,
|
|
551
608
|
...otherProps
|
|
552
609
|
}) {
|
|
553
610
|
if (isLoading) {
|
|
@@ -562,13 +619,12 @@ function AssignmentExerciseSelection({
|
|
|
562
619
|
isPublic: isPublic,
|
|
563
620
|
handleSwitchChange: handleSwitchChange,
|
|
564
621
|
teachClassrooms: teachClassrooms,
|
|
565
|
-
handleCreateGame: handleCreateGame,
|
|
566
622
|
isExerciseSelected: isExerciseSelected,
|
|
567
623
|
setIsExerciseSelected: setIsExerciseSelected,
|
|
568
624
|
getRoleplays: getRoleplays,
|
|
569
625
|
assignment: assignment,
|
|
570
626
|
handleStartExercise: handleStartExercise,
|
|
571
|
-
|
|
627
|
+
viewOnly: viewOnly,
|
|
572
628
|
...otherProps
|
|
573
629
|
})
|
|
574
630
|
});
|
|
@@ -584,14 +640,13 @@ function AssignmentExerciseSelection({
|
|
|
584
640
|
isPublic: isPublic,
|
|
585
641
|
handleSwitchChange: handleSwitchChange,
|
|
586
642
|
teachClassrooms: teachClassrooms,
|
|
587
|
-
handleCreateGame: handleCreateGame,
|
|
588
643
|
isExerciseSelected: isExerciseSelected,
|
|
589
644
|
setIsExerciseSelected: setIsExerciseSelected,
|
|
590
645
|
handleSelectExercise: handleSelectExercise,
|
|
591
646
|
selectedExercises: selectedExercises,
|
|
592
647
|
useCase: useCase,
|
|
593
|
-
isAssignment: isAssignment,
|
|
594
648
|
assignment: assignment,
|
|
649
|
+
viewOnly: viewOnly,
|
|
595
650
|
...otherProps
|
|
596
651
|
})
|
|
597
652
|
});
|
|
@@ -16,8 +16,10 @@ function AssignmentExerciseSelector({
|
|
|
16
16
|
username,
|
|
17
17
|
getCourseSections,
|
|
18
18
|
getRoleplays,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
isCreator,
|
|
20
|
+
selectedExercises,
|
|
21
|
+
viewOnly,
|
|
22
|
+
useCase
|
|
21
23
|
}) {
|
|
22
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.Box, {
|
|
23
25
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentCourseSelection.default, {
|
|
@@ -28,8 +30,10 @@ function AssignmentExerciseSelector({
|
|
|
28
30
|
courses: assignment.courses,
|
|
29
31
|
getCourseSections: getCourseSections,
|
|
30
32
|
getRoleplays: getRoleplays,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
isCreator: isCreator,
|
|
34
|
+
selectedExercises: selectedExercises,
|
|
35
|
+
viewOnly: viewOnly,
|
|
36
|
+
useCase: useCase
|
|
33
37
|
})
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -12,25 +12,37 @@ var _RateReview = _interopRequireDefault(require("@mui/icons-material/RateReview
|
|
|
12
12
|
var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
|
|
13
13
|
var _ExpandLess = _interopRequireDefault(require("@mui/icons-material/ExpandLess"));
|
|
14
14
|
var _AutoStories = _interopRequireDefault(require("@mui/icons-material/AutoStories"));
|
|
15
|
+
var _reactRouterDom = require("react-router-dom");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
function Roleplay({
|
|
18
19
|
roleplay,
|
|
19
|
-
handleCreateGame,
|
|
20
20
|
courseSectionTopicId,
|
|
21
21
|
isRoleplaySelected,
|
|
22
|
-
setIsRoleplaySelected,
|
|
23
22
|
t,
|
|
24
23
|
isExerciseSelected,
|
|
25
24
|
handleSelectExercise = null,
|
|
26
25
|
selectedExercises,
|
|
27
26
|
useCase
|
|
28
27
|
}) {
|
|
28
|
+
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
29
|
+
const params = (0, _reactRouterDom.useParams)();
|
|
30
|
+
const {
|
|
31
|
+
classroomId
|
|
32
|
+
} = params;
|
|
33
|
+
const [courseId, sectionId, topicId] = courseSectionTopicId ? courseSectionTopicId.split("|") : "";
|
|
34
|
+
const addSearchParams = exercise => {
|
|
35
|
+
if (!classroomId || !courseId || !sectionId || !topicId || !roleplay?.roleplayId) {
|
|
36
|
+
console.error('Missing required parameters for navigation');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
navigate(`/classrooms/${classroomId}/${courseId}/${sectionId}/${topicId}/roleplays/${roleplay?.roleplayId}?game=${encodeURIComponent(exercise)}`);
|
|
40
|
+
};
|
|
29
41
|
const [open, setOpen] = (0, _react.useState)(false);
|
|
30
42
|
const games = ["roleplay-story", "roleplay-fill-in-the-blanks", "roleplay-act-it-out", "roleplay-act-it-out-listening", "roleplay-act-it-out-speaking", "roleplay-act-it-out-listening-speaking"];
|
|
31
43
|
const [isSelectAllChecked, setIsSelectAllChecked] = (0, _react.useState)(false);
|
|
32
44
|
(0, _react.useEffect)(() => {
|
|
33
|
-
const count = selectedExercises
|
|
45
|
+
const count = selectedExercises?.filter(exercise => exercise.roleplayId === roleplay.roleplayId).length;
|
|
34
46
|
setIsSelectAllChecked(count === games.length);
|
|
35
47
|
}, [selectedExercises, roleplay.roleplayId, games.length]);
|
|
36
48
|
const handleSelectAll = () => {
|
|
@@ -43,7 +55,7 @@ function Roleplay({
|
|
|
43
55
|
} else {
|
|
44
56
|
let gamesToAdd = [];
|
|
45
57
|
games.forEach(game => {
|
|
46
|
-
if (!selectedExercises
|
|
58
|
+
if (!selectedExercises?.some(e => e.roleplayId === roleplay.roleplayId && e.game === game)) {
|
|
47
59
|
gamesToAdd = [...gamesToAdd, {
|
|
48
60
|
roleplayId: roleplay.roleplayId,
|
|
49
61
|
game
|
|
@@ -53,16 +65,6 @@ function Roleplay({
|
|
|
53
65
|
handleSelectExercise(gamesToAdd);
|
|
54
66
|
}
|
|
55
67
|
};
|
|
56
|
-
const handleRoleplaySelected = exerciseName => () => {
|
|
57
|
-
setIsRoleplaySelected(true);
|
|
58
|
-
handleCreateGame({
|
|
59
|
-
courseSectionTopicId: courseSectionTopicId,
|
|
60
|
-
exercise: exerciseName,
|
|
61
|
-
timer: 30,
|
|
62
|
-
answerOption: 0,
|
|
63
|
-
roleplayId: roleplay.roleplayId
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
68
|
const isRoleplayEmpty = roleplay?.script?.length === 0 || !roleplay?.script?.some(line => line.text !== undefined);
|
|
67
69
|
const numberOfRoleplayQuestions = roleplay?.script?.filter(item => Object.hasOwn(item, "question")).length;
|
|
68
70
|
const numberOfRoleplayInteractions = roleplay?.script?.length - numberOfRoleplayQuestions;
|
|
@@ -71,12 +73,12 @@ function Roleplay({
|
|
|
71
73
|
const isRoleplayValid = roleplayHasInteractions && roleplayHasQuestions;
|
|
72
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
73
75
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
74
|
-
title:
|
|
76
|
+
title: !isRoleplayValid ? t("roleplay_not_valid") : "",
|
|
75
77
|
placement: "left",
|
|
76
78
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
77
79
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ListItemButton, {
|
|
78
80
|
onClick: () => setOpen(!open),
|
|
79
|
-
disabled: isRoleplaySelected || isRoleplayEmpty || isExerciseSelected
|
|
81
|
+
disabled: isRoleplaySelected || isRoleplayEmpty || isExerciseSelected,
|
|
80
82
|
sx: {
|
|
81
83
|
display: "flex",
|
|
82
84
|
alignItems: "center",
|
|
@@ -157,7 +159,7 @@ function Roleplay({
|
|
|
157
159
|
color: "#757575"
|
|
158
160
|
}
|
|
159
161
|
})
|
|
160
|
-
}), useCase === "assignment" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
162
|
+
}), useCase === "assignment-select" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
161
163
|
title: t("select_all"),
|
|
162
164
|
placement: "top",
|
|
163
165
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
@@ -176,14 +178,13 @@ function Roleplay({
|
|
|
176
178
|
in: open,
|
|
177
179
|
timeout: "auto",
|
|
178
180
|
unmountOnExit: true,
|
|
179
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
181
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
180
182
|
ml: 3.5,
|
|
181
|
-
children: useCase === "assignment"
|
|
182
|
-
onClick:
|
|
183
|
+
children: [useCase === "assignment-select" && games.map((game, index) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ListItemButton, {
|
|
184
|
+
onClick: () => handleSelectExercise([{
|
|
183
185
|
roleplayId: roleplay.roleplayId,
|
|
184
186
|
game
|
|
185
|
-
}])
|
|
186
|
-
disabled: !isRoleplayValid,
|
|
187
|
+
}]),
|
|
187
188
|
sx: {
|
|
188
189
|
display: "flex",
|
|
189
190
|
alignItems: "center",
|
|
@@ -200,12 +201,13 @@ function Roleplay({
|
|
|
200
201
|
secondary: t("story_description")
|
|
201
202
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
202
203
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, {
|
|
203
|
-
checked: selectedExercises
|
|
204
|
+
checked: selectedExercises?.some(e => e.roleplayId === roleplay.roleplayId && e.game === game)
|
|
204
205
|
})
|
|
205
206
|
})]
|
|
206
|
-
}))
|
|
207
|
-
onClick:
|
|
208
|
-
|
|
207
|
+
}, `${roleplay.roleplayId}-${game}-${index}`)), useCase === "assignment-view" || useCase === "assignment-start" ? games.map(game => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ListItemButton, {
|
|
208
|
+
onClick: () => {
|
|
209
|
+
useCase === "assignment-start" ? addSearchParams(game.replace(/roleplay-/, "")) : null;
|
|
210
|
+
},
|
|
209
211
|
sx: {
|
|
210
212
|
display: "flex",
|
|
211
213
|
alignItems: "center",
|
|
@@ -218,21 +220,20 @@ function Roleplay({
|
|
|
218
220
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
219
221
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AutoStories.default, {})
|
|
220
222
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemText, {
|
|
221
|
-
primary: t(
|
|
222
|
-
secondary: t("
|
|
223
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
223
|
+
primary: t(game.replace(/roleplay-/, "").replace(/-/g, "_")),
|
|
224
|
+
secondary: t(game.replace(/roleplay-/, "").replace(/-/g, "_") + "_description")
|
|
225
|
+
}), useCase === "assignment-start" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItemIcon, {
|
|
224
226
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PlayCircleOutline.default, {
|
|
225
227
|
color: "primary"
|
|
226
228
|
})
|
|
227
229
|
})]
|
|
228
|
-
})
|
|
230
|
+
})) : null]
|
|
229
231
|
})
|
|
230
232
|
})]
|
|
231
233
|
});
|
|
232
234
|
}
|
|
233
235
|
function AssignmentRoleplaySelection({
|
|
234
236
|
roleplays = [],
|
|
235
|
-
handleCreateGame,
|
|
236
237
|
courseSectionTopicId,
|
|
237
238
|
t,
|
|
238
239
|
isExerciseSelected,
|
|
@@ -243,7 +244,6 @@ function AssignmentRoleplaySelection({
|
|
|
243
244
|
const [isRoleplaySelected, setIsRoleplaySelected] = (0, _react.useState)(false);
|
|
244
245
|
return roleplays.map((roleplay, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Roleplay, {
|
|
245
246
|
roleplay: roleplay,
|
|
246
|
-
handleCreateGame: handleCreateGame,
|
|
247
247
|
isRoleplaySelected: isRoleplaySelected,
|
|
248
248
|
setIsRoleplaySelected: setIsRoleplaySelected,
|
|
249
249
|
courseSectionTopicId: courseSectionTopicId,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _AssignmentCourseSelection = _interopRequireDefault(require("../AssignmentCourseSelection/AssignmentCourseSelection"));
|
|
9
|
+
var _ResponsiveDialog = _interopRequireDefault(require("../../Dialogs/ResponsiveDialog/ResponsiveDialog"));
|
|
10
|
+
var _system = require("@mui/system");
|
|
11
|
+
var _material = require("@mui/material");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function AssignmentSelectExercise({
|
|
15
|
+
t = text => text,
|
|
16
|
+
open,
|
|
17
|
+
handleClose,
|
|
18
|
+
courses,
|
|
19
|
+
getCourseSections,
|
|
20
|
+
getRoleplays,
|
|
21
|
+
username,
|
|
22
|
+
useCase,
|
|
23
|
+
selectedExercises = [],
|
|
24
|
+
setSelectedExercises,
|
|
25
|
+
setSubmittedExercises
|
|
26
|
+
}) {
|
|
27
|
+
const [isExerciseSelected, setIsExerciseSelected] = (0, _react.useState)(false);
|
|
28
|
+
const handleSelectExercise = (exercises = []) => {
|
|
29
|
+
setSelectedExercises(prevSelectedExercises => {
|
|
30
|
+
let updatedExercises = [...prevSelectedExercises];
|
|
31
|
+
exercises.forEach(exercise => {
|
|
32
|
+
if (exercise.courseSectionTopicId && updatedExercises.some(e => e.courseSectionTopicId === exercise.courseSectionTopicId && e.name === exercise.name)) {
|
|
33
|
+
updatedExercises = updatedExercises.filter(e => e.courseSectionTopicId !== exercise.courseSectionTopicId || e.name !== exercise.name);
|
|
34
|
+
} else if (exercise.roleplayId && updatedExercises.some(e => e.roleplayId === exercise.roleplayId && e.game === exercise.game)) {
|
|
35
|
+
updatedExercises = updatedExercises.filter(e => !!e.courseSectionTopicId || e.roleplayId !== exercise.roleplayId || e.game !== exercise.game);
|
|
36
|
+
} else {
|
|
37
|
+
updatedExercises.push(exercise);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return updatedExercises;
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const handleSubmitExercises = () => {
|
|
44
|
+
setSelectedExercises(selectedExercises);
|
|
45
|
+
setSubmittedExercises(selectedExercises);
|
|
46
|
+
handleClose();
|
|
47
|
+
};
|
|
48
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveDialog.default, {
|
|
49
|
+
open: open,
|
|
50
|
+
handleClose: handleClose,
|
|
51
|
+
dialogTitle: t("assignment"),
|
|
52
|
+
maxWidth: "md",
|
|
53
|
+
handleSubmit: () => {
|
|
54
|
+
handleSubmitExercises();
|
|
55
|
+
},
|
|
56
|
+
submitText: t("add_exercises"),
|
|
57
|
+
isSubmitDisabled: selectedExercises.length === 0,
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.DialogContentText, {
|
|
59
|
+
children: t("assign_exercises_description")
|
|
60
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_system.Box, {
|
|
61
|
+
mt: 1,
|
|
62
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentCourseSelection.default, {
|
|
63
|
+
courses: courses,
|
|
64
|
+
getCourseSections: getCourseSections,
|
|
65
|
+
getRoleplays: getRoleplays,
|
|
66
|
+
username: username,
|
|
67
|
+
t: t,
|
|
68
|
+
isExerciseSelected: isExerciseSelected,
|
|
69
|
+
setIsExerciseSelected: setIsExerciseSelected,
|
|
70
|
+
isDialogOpen: open,
|
|
71
|
+
useCase: useCase,
|
|
72
|
+
selectedExercises: selectedExercises,
|
|
73
|
+
handleSelectExercise: useCase === "assignment-select" ? handleSelectExercise : null,
|
|
74
|
+
viewOnly: false
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
var _default = exports.default = AssignmentSelectExercise;
|
|
@@ -16,8 +16,9 @@ var _mui = require("tss-react/mui");
|
|
|
16
16
|
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
17
17
|
var _ArrowDropUp = _interopRequireDefault(require("@mui/icons-material/ArrowDropUp"));
|
|
18
18
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
19
|
-
var
|
|
19
|
+
var _AssignmentSelectExercise = _interopRequireDefault(require("../AssignmentSelectExercise/AssignmentSelectExercise"));
|
|
20
20
|
var _Queries = require("@nualang/nualang-api-and-queries/Queries");
|
|
21
|
+
var _AssignmentExerciseSelector = _interopRequireDefault(require("../AssignmentExerciseSelector/AssignmentExerciseSelector"));
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
23
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
24
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -29,7 +30,8 @@ const useStyles = (0, _mui.makeStyles)()(theme => ({
|
|
|
29
30
|
dialogContent: {
|
|
30
31
|
display: "flex",
|
|
31
32
|
gap: theme.spacing(2),
|
|
32
|
-
padding: theme.spacing(3)
|
|
33
|
+
padding: theme.spacing(3),
|
|
34
|
+
marginBottom: theme.spacing(7)
|
|
33
35
|
}
|
|
34
36
|
}));
|
|
35
37
|
function Transition(props) {
|
|
@@ -51,12 +53,15 @@ function CreateAssignmentDialog({
|
|
|
51
53
|
username,
|
|
52
54
|
getMemberDetails,
|
|
53
55
|
getClassroom,
|
|
54
|
-
getCourses
|
|
56
|
+
getCourses,
|
|
57
|
+
initialData = {},
|
|
58
|
+
dialogTitle
|
|
55
59
|
}) {
|
|
56
60
|
const {
|
|
57
61
|
classes
|
|
58
62
|
} = useStyles();
|
|
59
63
|
const [selectedExercises, setSelectedExercises] = (0, _react.useState)([]);
|
|
64
|
+
const [submittedExercises, setSubmittedExercises] = (0, _react.useState)(initialData.exercises ? initialData.exercises : []);
|
|
60
65
|
const [members, setMembers] = (0, _react.useState)([]);
|
|
61
66
|
const [assignment, setAssignment] = (0, _react.useState)({
|
|
62
67
|
classroomId: "",
|
|
@@ -66,7 +71,8 @@ function CreateAssignmentDialog({
|
|
|
66
71
|
type: "assignment",
|
|
67
72
|
scheduleDate: (0, _dayjs.default)(),
|
|
68
73
|
dueDate: (0, _dayjs.default)().add(1, "day"),
|
|
69
|
-
exercises:
|
|
74
|
+
exercises: submittedExercises,
|
|
75
|
+
...initialData
|
|
70
76
|
});
|
|
71
77
|
const classroomQuery = _Queries.classrooms.useClassroom(async classroomId => {
|
|
72
78
|
const response = await getClassroom(classroomId);
|
|
@@ -97,6 +103,13 @@ function CreateAssignmentDialog({
|
|
|
97
103
|
enabled: !!assignment.classroomId
|
|
98
104
|
});
|
|
99
105
|
const selectedCourses = (0, _react.useMemo)(() => coursesQuery.isSuccess && Array.isArray(coursesQuery.data.Items) && coursesQuery.data.Items.length ? coursesQuery.data.Items : [], [coursesQuery.data, coursesQuery.isSuccess]);
|
|
106
|
+
(0, _react.useEffect)(() => {
|
|
107
|
+
let filteredCourses = selectedCourses.filter(course => submittedExercises.some(exercise => exercise.courseSectionTopicId?.split("|")[0] === course.courseId));
|
|
108
|
+
setAssignment({
|
|
109
|
+
...assignment,
|
|
110
|
+
courses: filteredCourses
|
|
111
|
+
});
|
|
112
|
+
}, [selectedCourses, submittedExercises]);
|
|
100
113
|
const selectedMembers = (0, _react.useMemo)(() => membersQuery.isSuccess && Array.isArray(membersQuery.data.Items) && membersQuery.data.Items.length ? membersQuery.data.Items : [], [membersQuery.data, membersQuery.isSuccess]);
|
|
101
114
|
const classroomMembers = async selectedMembers => {
|
|
102
115
|
const formattedMembers = await getMemberDetails(selectedMembers);
|
|
@@ -108,9 +121,9 @@ function CreateAssignmentDialog({
|
|
|
108
121
|
(0, _react.useEffect)(() => {
|
|
109
122
|
setAssignment(prev => ({
|
|
110
123
|
...prev,
|
|
111
|
-
exercises:
|
|
124
|
+
exercises: submittedExercises
|
|
112
125
|
}));
|
|
113
|
-
}, [
|
|
126
|
+
}, [submittedExercises]);
|
|
114
127
|
(0, _react.useEffect)(() => {
|
|
115
128
|
setAssignment(prev => ({
|
|
116
129
|
...prev,
|
|
@@ -178,7 +191,7 @@ function CreateAssignmentDialog({
|
|
|
178
191
|
variant: "h5",
|
|
179
192
|
fontWeight: "bold",
|
|
180
193
|
textAlign: "center",
|
|
181
|
-
children: t(
|
|
194
|
+
children: t(dialogTitle)
|
|
182
195
|
})]
|
|
183
196
|
})
|
|
184
197
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
@@ -214,7 +227,7 @@ function CreateAssignmentDialog({
|
|
|
214
227
|
onChange: handleChange("classroomId"),
|
|
215
228
|
required: true,
|
|
216
229
|
disabled: classroom,
|
|
217
|
-
children: classrooms
|
|
230
|
+
children: classrooms?.map(classroom => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
218
231
|
value: classroom.classroomId,
|
|
219
232
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
220
233
|
sx: {
|
|
@@ -254,6 +267,14 @@ function CreateAssignmentDialog({
|
|
|
254
267
|
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Add.default, {}),
|
|
255
268
|
onClick: () => setIsSelectExerciseOpen(true),
|
|
256
269
|
children: t("add_exercise")
|
|
270
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentExerciseSelector.default, {
|
|
271
|
+
selectedExercises: submittedExercises,
|
|
272
|
+
t: t,
|
|
273
|
+
assignment: assignment,
|
|
274
|
+
getCourseSections: getCourseSections,
|
|
275
|
+
getRoleplays: getRoleplays,
|
|
276
|
+
viewOnly: true,
|
|
277
|
+
useCase: "assignment-view"
|
|
257
278
|
})]
|
|
258
279
|
})
|
|
259
280
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Card, {
|
|
@@ -286,7 +307,7 @@ function CreateAssignmentDialog({
|
|
|
286
307
|
required: true,
|
|
287
308
|
value: assignment.assignedStudents,
|
|
288
309
|
onChange: handleChange("assignedStudents"),
|
|
289
|
-
renderValue: selected => selected
|
|
310
|
+
renderValue: selected => selected?.map(memberId => members?.find(member => member.memberId === memberId))?.map(member => member?.username).join(", "),
|
|
290
311
|
children: members?.map(member => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
|
|
291
312
|
value: member.memberId,
|
|
292
313
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Avatar, {
|
|
@@ -393,7 +414,7 @@ function CreateAssignmentDialog({
|
|
|
393
414
|
})]
|
|
394
415
|
})
|
|
395
416
|
})]
|
|
396
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
417
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentSelectExercise.default, {
|
|
397
418
|
t: t,
|
|
398
419
|
open: isSelectExerciseOpen,
|
|
399
420
|
handleClose: handleCloseSelectExercise,
|
|
@@ -401,13 +422,11 @@ function CreateAssignmentDialog({
|
|
|
401
422
|
getCourseSections: getCourseSections,
|
|
402
423
|
getRoleplays: getRoleplays,
|
|
403
424
|
username: username,
|
|
404
|
-
useCase: "assignment",
|
|
425
|
+
useCase: "assignment-select",
|
|
405
426
|
selectedExercises: selectedExercises,
|
|
406
427
|
setSelectedExercises: setSelectedExercises,
|
|
407
|
-
|
|
408
|
-
})
|
|
409
|
-
children: [exercise.name ? exercise.name : exercise.game, " | ", exercise.courseSectionTopicId ? exercise.courseSectionTopicId : exercise.roleplayId]
|
|
410
|
-
}))]
|
|
428
|
+
setSubmittedExercises: setSubmittedExercises
|
|
429
|
+
})]
|
|
411
430
|
});
|
|
412
431
|
}
|
|
413
432
|
CreateAssignmentDialog.propTypes = {
|
|
@@ -55,7 +55,7 @@ var _Share = _interopRequireDefault(require("@mui/icons-material/Share"));
|
|
|
55
55
|
var _Edit = _interopRequireDefault(require("@mui/icons-material/Edit"));
|
|
56
56
|
var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
|
|
57
57
|
var _ExitToApp = _interopRequireDefault(require("@mui/icons-material/ExitToApp"));
|
|
58
|
-
var _AssignmentCardsList = _interopRequireDefault(require("../../../
|
|
58
|
+
var _AssignmentCardsList = _interopRequireDefault(require("../../../Assignments/AssignmentCardsList/AssignmentCardsList"));
|
|
59
59
|
var _Lightbulb = _interopRequireDefault(require("@mui/icons-material/Lightbulb"));
|
|
60
60
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
61
61
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -391,6 +391,9 @@ function Classroom({
|
|
|
391
391
|
assignments,
|
|
392
392
|
handleCreateAssignment,
|
|
393
393
|
deleteAssignment,
|
|
394
|
+
handleEditAssignment,
|
|
395
|
+
getCourses,
|
|
396
|
+
refreshAssignments,
|
|
394
397
|
...otherProps
|
|
395
398
|
}) {
|
|
396
399
|
const {
|
|
@@ -867,7 +870,11 @@ function Classroom({
|
|
|
867
870
|
username: username,
|
|
868
871
|
getCourseSections: getCourseSections,
|
|
869
872
|
handleCreateAssignment: handleCreateAssignment,
|
|
870
|
-
deleteAssignment: deleteAssignment
|
|
873
|
+
deleteAssignment: deleteAssignment,
|
|
874
|
+
handleEditAssignment: handleEditAssignment,
|
|
875
|
+
getRoleplays: getRoleplays,
|
|
876
|
+
getCourses: getCourses,
|
|
877
|
+
refreshAssignments: refreshAssignments
|
|
871
878
|
})
|
|
872
879
|
}, `tab-content-assignments`)
|
|
873
880
|
}] : []), ...(isWaysideClassroom && isVideoChatEnabled && isNualangLiveEnabled && (isMember && isVideoChatEnabledInSettings || isCreator) ? [{
|