@nualang/nualang-ui-components 0.1.1237 → 0.1.1238
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 +22 -26
- package/dist/Assignments/AssignmentCardsList/AssignmentCardsList.js +11 -1
- package/dist/Assignments/AssignmentCourseSelection/AssignmentCourseSelection.js +39 -1
- package/dist/Assignments/AssignmentExerciseSelection/AssignmentExerciseSelection.js +194 -30
- package/dist/Assignments/AssignmentExerciseSelector/AssignmentExerciseSelector.js +6 -0
- package/dist/Assignments/AssignmentRoleplaySelection/AssignmentRoleplaySelection.js +108 -18
- package/dist/Assignments/AssignmentSelectExercise/AssignmentSelectExercise.js +10 -2
- package/dist/Assignments/CreateAssignmentDialog/CreateAssignmentDialog.js +1 -1
- package/dist/Lists/CourseOutline/CourseOutline.js +3 -15
- package/dist/Lists/Exercises/Exercises.js +2 -0
- package/dist/Misc/ColorLinearProgress/ColorLinearProgress.js +35 -0
- package/dist/Misc/ColorLinearProgress/package.json +6 -0
- package/dist/Screens/Classrooms/ViewClassroom/ViewClassroom.js +28 -24
- package/dist/Screens/Courses/ViewCourse/ViewTopic/ViewTopic.js +2 -14
- package/dist/Tables/Progress/Progress.js +18 -37
- package/dist/Tables/Progress/ProgressList.js +4 -4
- package/dist/Tables/Progress/ProgressTable.js +166 -21
- package/dist/Tables/Progress/utils.js +43 -2
- package/dist/utils/index.js +27 -25
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactRouterDom = require("react-router-dom");
|
|
9
|
+
var _luxon = require("luxon");
|
|
9
10
|
var _Queries = require("@nualang/nualang-api-and-queries/Queries");
|
|
10
11
|
var _Timeline = _interopRequireDefault(require("@mui/icons-material/Timeline"));
|
|
11
12
|
var _ArrowBack = _interopRequireDefault(require("@mui/icons-material/ArrowBack"));
|
|
@@ -159,6 +160,8 @@ function DataCell({
|
|
|
159
160
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HtmlTooltip, {
|
|
160
161
|
tabIndex: `${index + 1}`,
|
|
161
162
|
open: tooltipOpen,
|
|
163
|
+
disableHoverListener: !type,
|
|
164
|
+
disableFocusListener: !type,
|
|
162
165
|
onOpen: () => setTooltipOpen(true),
|
|
163
166
|
onClose: () => setTooltipOpen(false),
|
|
164
167
|
title: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -219,6 +222,7 @@ function ExerciseCell({
|
|
|
219
222
|
function DataCellContainer({
|
|
220
223
|
t,
|
|
221
224
|
isLoading,
|
|
225
|
+
isNotAssigned,
|
|
222
226
|
error,
|
|
223
227
|
data,
|
|
224
228
|
memberActivityLink,
|
|
@@ -236,6 +240,12 @@ function DataCellContainer({
|
|
|
236
240
|
data: "A problem has occurred.",
|
|
237
241
|
index: index
|
|
238
242
|
});
|
|
243
|
+
} else if (isNotAssigned) {
|
|
244
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DataCell, {
|
|
245
|
+
t: t,
|
|
246
|
+
data: t('not_assigned'),
|
|
247
|
+
index: index
|
|
248
|
+
});
|
|
239
249
|
} else if (data === null || data === undefined || data.percentage === null || data.percentage === undefined || isNaN(data.percentage)) {
|
|
240
250
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DataCell, {
|
|
241
251
|
t: t,
|
|
@@ -325,6 +335,39 @@ function DataCellContainer({
|
|
|
325
335
|
index: index
|
|
326
336
|
});
|
|
327
337
|
}
|
|
338
|
+
function AssignmentCellData({
|
|
339
|
+
t,
|
|
340
|
+
data,
|
|
341
|
+
isLoading,
|
|
342
|
+
isNotAssigned,
|
|
343
|
+
error,
|
|
344
|
+
memberActivityLink,
|
|
345
|
+
filter,
|
|
346
|
+
index
|
|
347
|
+
}) {
|
|
348
|
+
let cellData = null;
|
|
349
|
+
if (data) {
|
|
350
|
+
if (filter === "percentage_complete" && data.percentComplete) {
|
|
351
|
+
cellData = data.percentComplete;
|
|
352
|
+
cellData.type = "percent";
|
|
353
|
+
} else if (filter === "correct_answer_percentage" && data.percentCorrect) {
|
|
354
|
+
cellData = data.percentCorrect;
|
|
355
|
+
cellData.type = "correct";
|
|
356
|
+
} else if (filter === "avg_pronunciation_score" && data.avgPronunciationScore) {
|
|
357
|
+
cellData = data.avgPronunciationScore;
|
|
358
|
+
cellData.type = "avgPronuc";
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(DataCellContainer, {
|
|
362
|
+
t: t,
|
|
363
|
+
data: cellData,
|
|
364
|
+
isLoading: isLoading,
|
|
365
|
+
error: error,
|
|
366
|
+
memberActivityLink: memberActivityLink,
|
|
367
|
+
index: index,
|
|
368
|
+
isNotAssigned: isNotAssigned
|
|
369
|
+
});
|
|
370
|
+
}
|
|
328
371
|
function CourseCellData({
|
|
329
372
|
t,
|
|
330
373
|
data,
|
|
@@ -546,7 +589,8 @@ function TableRow({
|
|
|
546
589
|
tableRoleplays,
|
|
547
590
|
tableRoleplayGames,
|
|
548
591
|
tableBots,
|
|
549
|
-
tableTopics
|
|
592
|
+
tableTopics,
|
|
593
|
+
assignments
|
|
550
594
|
}) {
|
|
551
595
|
const {
|
|
552
596
|
memberId
|
|
@@ -564,7 +608,8 @@ function TableRow({
|
|
|
564
608
|
error,
|
|
565
609
|
isLoading
|
|
566
610
|
} = memberCourseCompletionsQuery;
|
|
567
|
-
const tableData = (0, _react.useMemo)(() => memberCourseCompletionsQuery.isSuccess && Array.isArray(memberCourseCompletionsQuery.data.Items) && memberCourseCompletionsQuery.data.Items.length ? (0, _utils.formatMemberCourseCompletions)(courses, memberCourseCompletionsQuery.data.Items, reportType === "assignments" ? selectedAssignment?.exercises : null) : [], [memberCourseCompletionsQuery.data, memberCourseCompletionsQuery.isSuccess, reportType]);
|
|
611
|
+
const tableData = (0, _react.useMemo)(() => memberCourseCompletionsQuery.isSuccess && Array.isArray(memberCourseCompletionsQuery.data.Items) && memberCourseCompletionsQuery.data.Items.length ? (0, _utils.formatMemberCourseCompletions)(courses, memberCourseCompletionsQuery.data.Items, reportType === "assignments" && selectedAssignment ? selectedAssignment?.exercises : null) : [], [memberCourseCompletionsQuery.data, memberCourseCompletionsQuery.isSuccess, reportType, selectedAssignment]);
|
|
612
|
+
const assignmentsTableData = (0, _react.useMemo)(() => memberCourseCompletionsQuery.isSuccess && Array.isArray(memberCourseCompletionsQuery.data.Items) && memberCourseCompletionsQuery.data.Items.length && assignments && assignments.length ? (0, _utils.formatMemberAssignmentCompletions)(assignments, courses, memberCourseCompletionsQuery.data.Items) : [], [memberCourseCompletionsQuery.data, memberCourseCompletionsQuery.isSuccess, assignments]);
|
|
568
613
|
let memberActivityLink = `/classrooms/${classroomId}/activity/member/${member.memberId}`;
|
|
569
614
|
if (currentView === "course") {
|
|
570
615
|
memberActivityLink = `${memberActivityLink}/${selectedCourse.courseId}`;
|
|
@@ -719,7 +764,7 @@ function TableRow({
|
|
|
719
764
|
data: data,
|
|
720
765
|
isLoading: isLoading,
|
|
721
766
|
error: error,
|
|
722
|
-
memberActivityLink: `${memberActivityLink}/${tpc.topicId}`,
|
|
767
|
+
memberActivityLink: `${memberActivityLink}/${currentView === "section" ? tpc.topicId : ""}`,
|
|
723
768
|
filter: filter,
|
|
724
769
|
index: index * 2 * tableTopics.length + i * 2 + 1
|
|
725
770
|
}, `student-progress-data-cell-${i}`);
|
|
@@ -783,6 +828,19 @@ function TableRow({
|
|
|
783
828
|
index: index * 2 * tableRoleplayGames.length + i * 2 + 1,
|
|
784
829
|
roleplayCompletion: tableData[courseId]?.sections[sectionId]?.topics[selectedTopic.topicId].completions.filter(completion => completion.roleplayId === selectedRoleplay?.roleplayId && completion.exercise.replace("roleplay-", "") === roleplay)[0]
|
|
785
830
|
}, i);
|
|
831
|
+
}), reportType === "assignments" && currentView === "assignments" && assignments.map((a, i) => {
|
|
832
|
+
const data = assignmentsTableData[a.assignmentId];
|
|
833
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AssignmentCellData, {
|
|
834
|
+
t: t,
|
|
835
|
+
data: data,
|
|
836
|
+
isLoading: isLoading,
|
|
837
|
+
isNotAssigned: !a?.assignedStudents.includes(memberId),
|
|
838
|
+
error: error,
|
|
839
|
+
memberActivityLink: `${memberActivityLink}`,
|
|
840
|
+
index: index // used to set tabindex for keyboard accessibility
|
|
841
|
+
,
|
|
842
|
+
filter: filter
|
|
843
|
+
}, `student-progress-data-cell-${i}`);
|
|
786
844
|
})]
|
|
787
845
|
});
|
|
788
846
|
}
|
|
@@ -791,13 +849,13 @@ function ProgressTable({
|
|
|
791
849
|
classroomId,
|
|
792
850
|
courses = [],
|
|
793
851
|
members = [],
|
|
794
|
-
classroomMembers2 = [],
|
|
795
852
|
fetchMemberCourseCompletions = () => {},
|
|
796
853
|
currentView,
|
|
797
854
|
filter,
|
|
798
855
|
selectedCourse,
|
|
799
856
|
setSelectedCourse,
|
|
800
857
|
deleteCourseId,
|
|
858
|
+
deleteAssignmentId,
|
|
801
859
|
selectedSection,
|
|
802
860
|
setSelectedSection,
|
|
803
861
|
selectedTopic,
|
|
@@ -805,6 +863,8 @@ function ProgressTable({
|
|
|
805
863
|
selectedRoleplay,
|
|
806
864
|
setSelectedRoleplay,
|
|
807
865
|
selectedAssignment,
|
|
866
|
+
setSelectedAssignment,
|
|
867
|
+
assignments,
|
|
808
868
|
hideSorting,
|
|
809
869
|
roleplays,
|
|
810
870
|
bots,
|
|
@@ -849,10 +909,15 @@ function ProgressTable({
|
|
|
849
909
|
} else {
|
|
850
910
|
const aCompletions = queryClient.getQueryData(["memberCourseProgress", a.memberId, courseIds]).Items;
|
|
851
911
|
const bCompletions = queryClient.getQueryData(["memberCourseProgress", b.memberId, courseIds]).Items;
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
912
|
+
if (currentView === "assignments") {
|
|
913
|
+
a.completions = (0, _utils.formatMemberAssignmentCompletions)(courses, aCompletions, assignmentExercises);
|
|
914
|
+
b.completions = (0, _utils.formatMemberAssignmentCompletions)(courses, bCompletions, assignmentExercises);
|
|
915
|
+
} else {
|
|
916
|
+
const assignmentExercises = reportType === "assignments" && selectedAssignment ? selectedAssignment?.exercises : null;
|
|
917
|
+
a.completions = (0, _utils.formatMemberCourseCompletions)(courses, aCompletions, assignmentExercises);
|
|
918
|
+
b.completions = (0, _utils.formatMemberCourseCompletions)(courses, bCompletions, assignmentExercises);
|
|
919
|
+
}
|
|
920
|
+
if (currentView === "all_courses" || currentView === "assignments") {
|
|
856
921
|
a1 = a.completions[property][percentageAccessor].percentage;
|
|
857
922
|
b1 = b.completions[property][percentageAccessor].percentage;
|
|
858
923
|
} else if (currentView === "course") {
|
|
@@ -923,7 +988,7 @@ function ProgressTable({
|
|
|
923
988
|
sx: {
|
|
924
989
|
fontWeight: "bold"
|
|
925
990
|
},
|
|
926
|
-
children: t("
|
|
991
|
+
children: t("courses")
|
|
927
992
|
})
|
|
928
993
|
})
|
|
929
994
|
}), currentView === "course" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
@@ -961,7 +1026,7 @@ function ProgressTable({
|
|
|
961
1026
|
sx: {
|
|
962
1027
|
fontWeight: "bold"
|
|
963
1028
|
},
|
|
964
|
-
children: t("
|
|
1029
|
+
children: t("courses")
|
|
965
1030
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
966
1031
|
variant: "subtitle1",
|
|
967
1032
|
component: "div",
|
|
@@ -1008,7 +1073,7 @@ function ProgressTable({
|
|
|
1008
1073
|
sx: {
|
|
1009
1074
|
fontWeight: "bold"
|
|
1010
1075
|
},
|
|
1011
|
-
children: [t("
|
|
1076
|
+
children: [t("courses"), " | ", selectedCourse.courseName]
|
|
1012
1077
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
1013
1078
|
variant: "subtitle1",
|
|
1014
1079
|
component: "div",
|
|
@@ -1048,7 +1113,7 @@ function ProgressTable({
|
|
|
1048
1113
|
sx: {
|
|
1049
1114
|
fontWeight: "bold"
|
|
1050
1115
|
},
|
|
1051
|
-
children: [t("
|
|
1116
|
+
children: [t("courses"), " | ", selectedCourse.courseName]
|
|
1052
1117
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
|
|
1053
1118
|
variant: "subtitle1",
|
|
1054
1119
|
component: "div",
|
|
@@ -1096,8 +1161,31 @@ function ProgressTable({
|
|
|
1096
1161
|
})]
|
|
1097
1162
|
})]
|
|
1098
1163
|
})
|
|
1099
|
-
}), reportType === "assignments" && currentView === "
|
|
1164
|
+
}), reportType === "assignments" && currentView === "assignments" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
1100
1165
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
1166
|
+
sx: () => ({
|
|
1167
|
+
width: "100%",
|
|
1168
|
+
justifyContent: "center"
|
|
1169
|
+
}),
|
|
1170
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableSortLabel, {
|
|
1171
|
+
active: sortColumn === "student" && !hideSorting,
|
|
1172
|
+
direction: sortDirection || "asc",
|
|
1173
|
+
onClick: () => {
|
|
1174
|
+
handleSort("student");
|
|
1175
|
+
},
|
|
1176
|
+
disabled: hideSorting,
|
|
1177
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
1178
|
+
variant: "subtitle1",
|
|
1179
|
+
component: "div",
|
|
1180
|
+
sx: {
|
|
1181
|
+
fontWeight: "bold"
|
|
1182
|
+
},
|
|
1183
|
+
children: t("assignments")
|
|
1184
|
+
})
|
|
1185
|
+
})
|
|
1186
|
+
})
|
|
1187
|
+
}), reportType === "assignments" && currentView === "assignment-topics" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
1188
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
1101
1189
|
sx: () => ({
|
|
1102
1190
|
display: "flex",
|
|
1103
1191
|
// padding: `${theme.spacing(2)} !important`,
|
|
@@ -1105,7 +1193,15 @@ function ProgressTable({
|
|
|
1105
1193
|
textAlign: "left",
|
|
1106
1194
|
alignItems: "center"
|
|
1107
1195
|
}),
|
|
1108
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
1196
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
1197
|
+
sx: {
|
|
1198
|
+
minWidth: 56
|
|
1199
|
+
},
|
|
1200
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
|
|
1201
|
+
onClick: () => deleteAssignmentId(),
|
|
1202
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowBack.default, {})
|
|
1203
|
+
})
|
|
1204
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableSortLabel, {
|
|
1109
1205
|
active: sortColumn === "student" && !hideSorting,
|
|
1110
1206
|
direction: sortDirection || "asc",
|
|
1111
1207
|
onClick: () => {
|
|
@@ -1118,12 +1214,10 @@ function ProgressTable({
|
|
|
1118
1214
|
textAlign: "left"
|
|
1119
1215
|
},
|
|
1120
1216
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
1121
|
-
variant:
|
|
1217
|
+
variant: "caption",
|
|
1122
1218
|
component: "div",
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
},
|
|
1126
|
-
children: t("student_progress")
|
|
1219
|
+
children: `${selectedAssignment?.assignedStudents.length}
|
|
1220
|
+
${t("assigned")} | ${t("due_date")} ${_luxon.DateTime.fromISO(selectedAssignment?.dueDate).toLocaleString(_luxon.DateTime.DATE_MED)}`
|
|
1127
1221
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
1128
1222
|
variant: "subtitle1",
|
|
1129
1223
|
component: "div",
|
|
@@ -1133,7 +1227,7 @@ function ProgressTable({
|
|
|
1133
1227
|
children: selectedAssignment?.title
|
|
1134
1228
|
})]
|
|
1135
1229
|
})
|
|
1136
|
-
})
|
|
1230
|
+
})]
|
|
1137
1231
|
})
|
|
1138
1232
|
}), reportType === "assignments" && currentView === "assignment-topic" && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
1139
1233
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
@@ -1388,6 +1482,56 @@ function ProgressTable({
|
|
|
1388
1482
|
},
|
|
1389
1483
|
children: t(roleplay.replaceAll("-", "_"))
|
|
1390
1484
|
})
|
|
1485
|
+
}, i)), currentView === "assignments" && assignments.map((assignment, i) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("th", {
|
|
1486
|
+
scope: "col",
|
|
1487
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
1488
|
+
sx: {
|
|
1489
|
+
width: "100%",
|
|
1490
|
+
justifyContent: "center"
|
|
1491
|
+
},
|
|
1492
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.TableSortLabel, {
|
|
1493
|
+
active: sortColumn === assignment.assignmentId,
|
|
1494
|
+
direction: sortDirection || "asc",
|
|
1495
|
+
onClick: () => {
|
|
1496
|
+
handleSort(assignment.assignmentId);
|
|
1497
|
+
},
|
|
1498
|
+
disabled: hideSorting,
|
|
1499
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
1500
|
+
sx: {
|
|
1501
|
+
flex: "1 1 auto"
|
|
1502
|
+
},
|
|
1503
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
1504
|
+
variant: "caption",
|
|
1505
|
+
component: "div",
|
|
1506
|
+
sx: {
|
|
1507
|
+
marginLeft: "20px"
|
|
1508
|
+
},
|
|
1509
|
+
children: `${_luxon.DateTime.fromISO(assignment?.dueDate).toLocaleString(_luxon.DateTime.DATE_MED)}`
|
|
1510
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
1511
|
+
variant: "subtitle1",
|
|
1512
|
+
component: "div",
|
|
1513
|
+
sx: {
|
|
1514
|
+
fontWeight: "bold",
|
|
1515
|
+
marginLeft: "20px"
|
|
1516
|
+
},
|
|
1517
|
+
children: assignment.title
|
|
1518
|
+
})]
|
|
1519
|
+
})
|
|
1520
|
+
})
|
|
1521
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_DefaultColourButton.default, {
|
|
1522
|
+
"aria-expanded": Boolean(currentView === "assignments"),
|
|
1523
|
+
tabIndex: 0,
|
|
1524
|
+
endIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowForward.default, {}),
|
|
1525
|
+
size: "small",
|
|
1526
|
+
onClick: () => setSelectedAssignment(assignment),
|
|
1527
|
+
sx: {
|
|
1528
|
+
fontSize: "0.75rem",
|
|
1529
|
+
"@media print": {
|
|
1530
|
+
display: "none"
|
|
1531
|
+
}
|
|
1532
|
+
},
|
|
1533
|
+
children: t("view_assignment")
|
|
1534
|
+
})]
|
|
1391
1535
|
}, i))]
|
|
1392
1536
|
})
|
|
1393
1537
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(TableBody, {
|
|
@@ -1412,7 +1556,8 @@ function ProgressTable({
|
|
|
1412
1556
|
tableRoleplays: tableRoleplays,
|
|
1413
1557
|
tableRoleplayGames: tableRoleplayGames,
|
|
1414
1558
|
tableBots: tableBots,
|
|
1415
|
-
tableTopics: tableTopics
|
|
1559
|
+
tableTopics: tableTopics,
|
|
1560
|
+
assignments: assignments
|
|
1416
1561
|
}, `student-progress-table-row-${i}`))
|
|
1417
1562
|
})]
|
|
1418
1563
|
})
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.formatMemberCourseCompletions = void 0;
|
|
6
|
+
exports.formatMemberCourseCompletions = exports.formatMemberAssignmentCompletions = void 0;
|
|
7
7
|
var _utils = require("../../utils");
|
|
8
8
|
const formatMemberCourseCompletions = (courses = [], completions = [], assignmentExercises) => {
|
|
9
9
|
const initialStatsObject = courses.reduce((obj, v) => {
|
|
@@ -87,4 +87,45 @@ const formatMemberCourseCompletions = (courses = [], completions = [], assignmen
|
|
|
87
87
|
}, initialStatsObject);
|
|
88
88
|
return stats;
|
|
89
89
|
};
|
|
90
|
-
exports.formatMemberCourseCompletions = formatMemberCourseCompletions;
|
|
90
|
+
exports.formatMemberCourseCompletions = formatMemberCourseCompletions;
|
|
91
|
+
const formatMemberAssignmentCompletions = (assignments = [], courses = [], completions = []) => {
|
|
92
|
+
const stats = assignments.reduce((obj, v) => {
|
|
93
|
+
const assignmentCourseCompletions = formatMemberCourseCompletions(courses, completions, v?.exercises);
|
|
94
|
+
const result = Object.values(assignmentCourseCompletions).reduce((a, course) => {
|
|
95
|
+
if (a && course && course.percentComplete) {
|
|
96
|
+
a.percentComplete.completed += course.percentComplete.completed;
|
|
97
|
+
a.percentComplete.total += course.percentComplete.total;
|
|
98
|
+
a.percentComplete.percentage = Math.floor(a.percentComplete.completed / a.percentComplete.total * 100);
|
|
99
|
+
}
|
|
100
|
+
if (a && course && course.percentCorrect) {
|
|
101
|
+
a.percentCorrect.completed += course.percentCorrect.completed;
|
|
102
|
+
a.percentCorrect.total += course.percentCorrect.total;
|
|
103
|
+
a.percentCorrect.percentage = Math.floor(a.percentCorrect.completed / a.percentCorrect.total * 100);
|
|
104
|
+
}
|
|
105
|
+
if (a && course && course.avgPronunciationScore && course.avgPronunciationScore.percentage > 0) {
|
|
106
|
+
a.avgPronunciationScore.total += 1;
|
|
107
|
+
a.avgPronunciationScore.percentage = Math.floor(course.avgPronunciationScore.percentage / a.avgPronunciationScore.total);
|
|
108
|
+
}
|
|
109
|
+
return a;
|
|
110
|
+
}, {
|
|
111
|
+
percentComplete: {
|
|
112
|
+
completed: 0,
|
|
113
|
+
total: 0,
|
|
114
|
+
percentage: 0
|
|
115
|
+
},
|
|
116
|
+
percentCorrect: {
|
|
117
|
+
completed: 0,
|
|
118
|
+
total: 0,
|
|
119
|
+
percentage: 0
|
|
120
|
+
},
|
|
121
|
+
avgPronunciationScore: {
|
|
122
|
+
total: 0,
|
|
123
|
+
percentage: 0
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
obj[v.assignmentId] = result;
|
|
127
|
+
return obj;
|
|
128
|
+
}, {});
|
|
129
|
+
return stats;
|
|
130
|
+
};
|
|
131
|
+
exports.formatMemberAssignmentCompletions = formatMemberAssignmentCompletions;
|
package/dist/utils/index.js
CHANGED
|
@@ -118,26 +118,28 @@ const getScoreValues = (type, id, completions) => {
|
|
|
118
118
|
total: 0,
|
|
119
119
|
percentage: 0
|
|
120
120
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (idMatches) {
|
|
131
|
-
if (!invalidExercisesCorrectness.includes(c.exercise)) {
|
|
132
|
-
totalAnswers += c.totalAnswers;
|
|
133
|
-
totalAnswersCorrect += c.totalAnswersCorrect;
|
|
121
|
+
if (Array.isArray(completions)) {
|
|
122
|
+
completions.forEach(c => {
|
|
123
|
+
let idMatches = false;
|
|
124
|
+
if (type === "course") {
|
|
125
|
+
idMatches = id === c.courseId;
|
|
126
|
+
} else if (type === "section") {
|
|
127
|
+
idMatches = `${c.courseId}|${id}` === c.courseSectionId;
|
|
128
|
+
} else if (type === "topic") {
|
|
129
|
+
idMatches = `${c.courseSectionId}|${id}` === c.courseSectionTopicId;
|
|
134
130
|
}
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
if (idMatches) {
|
|
132
|
+
if (!invalidExercisesCorrectness.includes(c.exercise)) {
|
|
133
|
+
totalAnswers += c.totalAnswers;
|
|
134
|
+
totalAnswersCorrect += c.totalAnswersCorrect;
|
|
135
|
+
}
|
|
136
|
+
if (validExercisesPronunciation.includes(c.exercise) && c.avgPronunciationScore !== -1) {
|
|
137
|
+
totalPronunciationScore += c.avgPronunciationScore;
|
|
138
|
+
pronunciationScoreCount++;
|
|
139
|
+
}
|
|
138
140
|
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
141
143
|
percentCorrect.completed = totalAnswersCorrect;
|
|
142
144
|
percentCorrect.total = totalAnswers;
|
|
143
145
|
percentCorrect.percentage = totalAnswers > 0 ? Math.floor(totalAnswersCorrect / totalAnswers * 100) : 0;
|
|
@@ -208,9 +210,9 @@ const calcTopicCompletions = (topic, completions = [], isSectionHidden, assignme
|
|
|
208
210
|
totalExercises++;
|
|
209
211
|
}
|
|
210
212
|
}
|
|
211
|
-
const completedPronunciation = completions.filter(c => c.topicId === topic.topicId && c.exercise === "pronunciation").length;
|
|
212
|
-
const completedTranslation = completions.filter(c => c.topicId === topic.topicId && c.exercise === "translation").length;
|
|
213
|
-
const completedListening = completions.filter(c => c.topicId === topic.topicId && c.exercise === "listening").length;
|
|
213
|
+
const completedPronunciation = Array.isArray(completions) ? completions.filter(c => c.topicId === topic.topicId && c.exercise === "pronunciation").length : 0;
|
|
214
|
+
const completedTranslation = Array.isArray(completions) ? completions.filter(c => c.topicId === topic.topicId && c.exercise === "translation").length : 0;
|
|
215
|
+
const completedListening = Array.isArray(completions) ? completions.filter(c => c.topicId === topic.topicId && c.exercise === "listening").length : 0;
|
|
214
216
|
completedExerciseCount += !isPronunciationHidden && completedPronunciation > 0 ? 1 : 0;
|
|
215
217
|
completedExerciseCount += !isTranslationHidden && completedTranslation > 0 ? 1 : 0;
|
|
216
218
|
completedExerciseCount += !isListeningHidden && completedListening > 0 ? 1 : 0;
|
|
@@ -224,12 +226,12 @@ const calcTopicCompletions = (topic, completions = [], isSectionHidden, assignme
|
|
|
224
226
|
completedCount: 0
|
|
225
227
|
};
|
|
226
228
|
}
|
|
227
|
-
const completedCount = completions.reduce((acc, completion) => {
|
|
229
|
+
const completedCount = Array.isArray(completions) ? completions.reduce((acc, completion) => {
|
|
228
230
|
if (completion && completion.topicId === topic.topicId && completion.exercise.startsWith("roleplay") && completion.roleplayId === roleplay.roleplayId) {
|
|
229
231
|
acc++;
|
|
230
232
|
}
|
|
231
233
|
return acc;
|
|
232
|
-
}, 0);
|
|
234
|
+
}, 0) : 0;
|
|
233
235
|
if (completedCount > 0) {
|
|
234
236
|
completedRoleplays++;
|
|
235
237
|
completedExerciseCount++;
|
|
@@ -248,12 +250,12 @@ const calcTopicCompletions = (topic, completions = [], isSectionHidden, assignme
|
|
|
248
250
|
completedCount: 0
|
|
249
251
|
};
|
|
250
252
|
}
|
|
251
|
-
const completedCount = completions.reduce((acc, completion) => {
|
|
253
|
+
const completedCount = Array.isArray(completions) ? completions.reduce((acc, completion) => {
|
|
252
254
|
if (completion && completion.exercise === "bot" && completion.botId === bot.botId) {
|
|
253
255
|
acc++;
|
|
254
256
|
}
|
|
255
257
|
return acc;
|
|
256
|
-
}, 0);
|
|
258
|
+
}, 0) : 0;
|
|
257
259
|
if (completedCount > 0) {
|
|
258
260
|
completedBots++;
|
|
259
261
|
completedExerciseCount++;
|