@nualang/nualang-ui-components 0.1.1260 → 0.1.1261
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.
|
@@ -14,8 +14,6 @@ var _AdapterDayjs = require("@mui/x-date-pickers/AdapterDayjs");
|
|
|
14
14
|
var _LocalizationProvider = require("@mui/x-date-pickers/LocalizationProvider");
|
|
15
15
|
var _DatePicker = require("@mui/x-date-pickers/DatePicker");
|
|
16
16
|
var _mui = require("tss-react/mui");
|
|
17
|
-
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
18
|
-
var _ArrowDropUp = _interopRequireDefault(require("@mui/icons-material/ArrowDropUp"));
|
|
19
17
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
20
18
|
var _AssignmentSelectExercise = _interopRequireDefault(require("../AssignmentSelectExercise/AssignmentSelectExercise"));
|
|
21
19
|
var _AssignmentExerciseSelector = _interopRequireDefault(require("../AssignmentExerciseSelector/AssignmentExerciseSelector"));
|
|
@@ -57,7 +55,7 @@ function CreateAssignmentDialog({
|
|
|
57
55
|
getCourses,
|
|
58
56
|
initialData = {},
|
|
59
57
|
dialogTitle,
|
|
60
|
-
userEmail =
|
|
58
|
+
userEmail = ""
|
|
61
59
|
}) {
|
|
62
60
|
const {
|
|
63
61
|
classes
|
|
@@ -71,8 +69,8 @@ function CreateAssignmentDialog({
|
|
|
71
69
|
const [assignment, setAssignment] = (0, _react.useState)({
|
|
72
70
|
classroomId: classroom?.length > 0 ? [classroom] : [],
|
|
73
71
|
assignedStudents: members?.map(member => member.memberId),
|
|
74
|
-
title:
|
|
75
|
-
instructions: "",
|
|
72
|
+
title: initialData.title ? initialData.title : undefined,
|
|
73
|
+
instructions: initialData.instructions ? initialData.instructions : t("default_assignment_instructions"),
|
|
76
74
|
type: "assignment",
|
|
77
75
|
scheduleDate: (0, _dayjs.default)(),
|
|
78
76
|
dueDate: (0, _dayjs.default)().add(1, "day"),
|
|
@@ -182,6 +180,15 @@ function CreateAssignmentDialog({
|
|
|
182
180
|
...assignment,
|
|
183
181
|
courses: filteredCourses
|
|
184
182
|
});
|
|
183
|
+
const selectedTopicIds = new Set(submittedExercises.map(ex => ex.courseSectionTopicId));
|
|
184
|
+
const topicNames = Array.from(new Set(filteredCourses.flatMap(course => course.sections?.flatMap(section => section.topics?.flatMap(topic => {
|
|
185
|
+
const topicKey = `${course.courseId}|${section.sectionId}|${topic.topicId}`;
|
|
186
|
+
return selectedTopicIds.has(topicKey) ? topic.topicName : [];
|
|
187
|
+
}))).filter(Boolean)));
|
|
188
|
+
setAssignment(prev => ({
|
|
189
|
+
...prev,
|
|
190
|
+
title: topicNames.length ? topicNames.join(", ") : undefined
|
|
191
|
+
}));
|
|
185
192
|
}, [selectedCourses, submittedExercises]);
|
|
186
193
|
const classroomMembers = async uniqueClassroomMembers => {
|
|
187
194
|
const formattedMembers = await getMemberDetails(uniqueClassroomMembers);
|
|
@@ -212,13 +219,6 @@ function CreateAssignmentDialog({
|
|
|
212
219
|
const handleCloseSelectExercise = () => {
|
|
213
220
|
setIsSelectExerciseOpen(false);
|
|
214
221
|
};
|
|
215
|
-
const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
|
|
216
|
-
const handleMenuOpen = event => {
|
|
217
|
-
setAnchorEl(event.currentTarget);
|
|
218
|
-
};
|
|
219
|
-
const handleMenuClose = () => {
|
|
220
|
-
setAnchorEl(null);
|
|
221
|
-
};
|
|
222
222
|
const handleChange = field => event => {
|
|
223
223
|
let value = event?.target?.value ?? event;
|
|
224
224
|
setAssignment(prev => {
|
|
@@ -331,7 +331,7 @@ function CreateAssignmentDialog({
|
|
|
331
331
|
MenuProps: {
|
|
332
332
|
PaperProps: {
|
|
333
333
|
sx: {
|
|
334
|
-
width:
|
|
334
|
+
width: "auto",
|
|
335
335
|
maxWidth: 400
|
|
336
336
|
}
|
|
337
337
|
},
|
|
@@ -390,21 +390,6 @@ function CreateAssignmentDialog({
|
|
|
390
390
|
})
|
|
391
391
|
}, c.classroomId))
|
|
392
392
|
})]
|
|
393
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
394
|
-
"data-cy": "assignment-title-input",
|
|
395
|
-
label: t("assignment_title"),
|
|
396
|
-
fullWidth: true,
|
|
397
|
-
value: assignment.title,
|
|
398
|
-
onChange: handleChange("title"),
|
|
399
|
-
required: true
|
|
400
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
401
|
-
"data-cy": "assignment-description-input",
|
|
402
|
-
label: t("assignment_description"),
|
|
403
|
-
fullWidth: true,
|
|
404
|
-
multiline: true,
|
|
405
|
-
rows: 3,
|
|
406
|
-
value: assignment.instructions,
|
|
407
|
-
onChange: handleChange("instructions")
|
|
408
393
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
409
394
|
disableHoverListener: selectedCourses?.length > 0,
|
|
410
395
|
disableFocusListener: selectedCourses?.length > 0,
|
|
@@ -412,7 +397,7 @@ function CreateAssignmentDialog({
|
|
|
412
397
|
title: t("no_shared_courses"),
|
|
413
398
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
414
399
|
style: {
|
|
415
|
-
display:
|
|
400
|
+
display: "inline-block"
|
|
416
401
|
},
|
|
417
402
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
418
403
|
"data-cy": "assignment-exercise-selector-button",
|
|
@@ -453,7 +438,25 @@ function CreateAssignmentDialog({
|
|
|
453
438
|
flexDirection: "column",
|
|
454
439
|
gap: 2
|
|
455
440
|
},
|
|
456
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.
|
|
441
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
442
|
+
"data-cy": "assignment-title-input",
|
|
443
|
+
label: t("assignment_title"),
|
|
444
|
+
fullWidth: true,
|
|
445
|
+
value: assignment.title,
|
|
446
|
+
onChange: handleChange("title"),
|
|
447
|
+
required: true,
|
|
448
|
+
InputLabelProps: {
|
|
449
|
+
shrink: true
|
|
450
|
+
}
|
|
451
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TextField, {
|
|
452
|
+
"data-cy": "assignment-description-input",
|
|
453
|
+
label: t("assignment_description"),
|
|
454
|
+
fullWidth: true,
|
|
455
|
+
multiline: true,
|
|
456
|
+
rows: 3,
|
|
457
|
+
value: assignment.instructions,
|
|
458
|
+
onChange: handleChange("instructions")
|
|
459
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
457
460
|
fullWidth: true,
|
|
458
461
|
disabled: !assignment.classroomId,
|
|
459
462
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
@@ -484,17 +487,49 @@ function CreateAssignmentDialog({
|
|
|
484
487
|
})]
|
|
485
488
|
}, member.memberId))
|
|
486
489
|
})]
|
|
487
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
490
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
491
|
+
sx: {
|
|
492
|
+
display: "flex",
|
|
493
|
+
width: "100%",
|
|
494
|
+
alignItems: "center",
|
|
495
|
+
justifyContent: "space-between"
|
|
496
|
+
},
|
|
497
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_LocalizationProvider.LocalizationProvider, {
|
|
498
|
+
dateAdapter: _AdapterDayjs.AdapterDayjs,
|
|
499
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, {
|
|
500
|
+
label: t("assign_date"),
|
|
501
|
+
value: assignment.scheduleDate,
|
|
502
|
+
onChange: date => setAssignment(prev => ({
|
|
503
|
+
...prev,
|
|
504
|
+
scheduleDate: date
|
|
505
|
+
})),
|
|
506
|
+
disablePast: true,
|
|
507
|
+
maxDate: assignment.dueDate,
|
|
508
|
+
sx: {
|
|
509
|
+
width: "45%"
|
|
510
|
+
},
|
|
511
|
+
format: "DD MMM YYYY"
|
|
512
|
+
})
|
|
513
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
514
|
+
variant: "h4",
|
|
515
|
+
children: "-"
|
|
516
|
+
}), " ", /*#__PURE__*/(0, _jsxRuntime.jsx)(_LocalizationProvider.LocalizationProvider, {
|
|
517
|
+
dateAdapter: _AdapterDayjs.AdapterDayjs,
|
|
518
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, {
|
|
519
|
+
"data-cy": "assignment-date-picker",
|
|
520
|
+
label: t("due"),
|
|
521
|
+
value: assignment.dueDate,
|
|
522
|
+
disablePast: true,
|
|
523
|
+
onChange: date => setAssignment(prev => ({
|
|
524
|
+
...prev,
|
|
525
|
+
dueDate: date
|
|
526
|
+
})),
|
|
527
|
+
sx: {
|
|
528
|
+
width: "45%"
|
|
529
|
+
},
|
|
530
|
+
format: "DD MMM YYYY"
|
|
531
|
+
})
|
|
532
|
+
})]
|
|
498
533
|
})]
|
|
499
534
|
})
|
|
500
535
|
})]
|
|
@@ -517,66 +552,17 @@ function CreateAssignmentDialog({
|
|
|
517
552
|
},
|
|
518
553
|
onClick: handleClose,
|
|
519
554
|
children: t("cancel")
|
|
520
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
555
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ButtonGroup, {
|
|
521
556
|
variant: "contained",
|
|
522
557
|
color: "primary",
|
|
523
558
|
sx: {
|
|
524
559
|
borderRadius: 10
|
|
525
560
|
},
|
|
526
|
-
children:
|
|
561
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
527
562
|
"data-cy": "assignment-assign-button",
|
|
528
563
|
disabled: !assignment.assignedStudents?.length || !assignment.scheduleDate || !assignment.dueDate || !assignment.title || !assignment.classroomId || !assignment.exercises?.length,
|
|
529
564
|
onClick: async () => await handleCreateAssignment(),
|
|
530
565
|
children: t("assign")
|
|
531
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
532
|
-
color: "primary",
|
|
533
|
-
onClick: handleMenuOpen,
|
|
534
|
-
sx: {
|
|
535
|
-
minWidth: "40px",
|
|
536
|
-
padding: "6px"
|
|
537
|
-
},
|
|
538
|
-
disabled: !assignment.assignedStudents?.length || !assignment.scheduleDate || !assignment.dueDate || !assignment.title || !assignment.classroomId || !assignment.exercises?.length,
|
|
539
|
-
children: anchorEl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropUp.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropDown.default, {})
|
|
540
|
-
})]
|
|
541
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popover, {
|
|
542
|
-
anchorEl: anchorEl,
|
|
543
|
-
open: Boolean(anchorEl),
|
|
544
|
-
onClose: handleMenuClose,
|
|
545
|
-
anchorOrigin: {
|
|
546
|
-
vertical: "top",
|
|
547
|
-
horizontal: "left"
|
|
548
|
-
},
|
|
549
|
-
transformOrigin: {
|
|
550
|
-
vertical: "bottom",
|
|
551
|
-
horizontal: "left"
|
|
552
|
-
},
|
|
553
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
554
|
-
display: "flex",
|
|
555
|
-
flexDirection: "column",
|
|
556
|
-
width: "100%",
|
|
557
|
-
gap: 1,
|
|
558
|
-
padding: 2,
|
|
559
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_LocalizationProvider.LocalizationProvider, {
|
|
560
|
-
dateAdapter: _AdapterDayjs.AdapterDayjs,
|
|
561
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DatePicker.DatePicker, {
|
|
562
|
-
label: t("assign_date"),
|
|
563
|
-
value: assignment.scheduleDate,
|
|
564
|
-
onChange: date => setAssignment(prev => ({
|
|
565
|
-
...prev,
|
|
566
|
-
scheduleDate: date
|
|
567
|
-
}))
|
|
568
|
-
})
|
|
569
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Button, {
|
|
570
|
-
variant: "outlined",
|
|
571
|
-
color: "primary",
|
|
572
|
-
fullWidth: true,
|
|
573
|
-
"data-cy": "assignment-schedule-button",
|
|
574
|
-
onClick: async () => {
|
|
575
|
-
await handleCreateAssignment();
|
|
576
|
-
handleMenuClose();
|
|
577
|
-
},
|
|
578
|
-
children: t("schedule_assignment")
|
|
579
|
-
})]
|
|
580
566
|
})
|
|
581
567
|
})]
|
|
582
568
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentSelectExercise.default, {
|