@nualang/nualang-ui-components 0.1.1279 → 0.1.1281

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.
@@ -32,7 +32,8 @@ const AssignmentCardsList = ({
32
32
  memberId,
33
33
  handleViewProgress,
34
34
  lastAssignmentFetch,
35
- assignmentMembersById
35
+ assignmentMembersById = {},
36
+ isLoadingAssignments
36
37
  }) => {
37
38
  const [lastClickedExerciseId, setLastClickedExerciseId] = (0, _react.useState)(null);
38
39
  (0, _react.useEffect)(() => {
@@ -48,9 +49,81 @@ const AssignmentCardsList = ({
48
49
  }
49
50
  }
50
51
  }, []);
51
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
52
- mb: 1,
53
- children: assignments.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
52
+ if (isLoadingAssignments) {
53
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
54
+ mb: 1,
55
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
56
+ display: "flex",
57
+ justifyContent: "space-between",
58
+ alignItems: "center",
59
+ sx: {
60
+ mb: 2
61
+ },
62
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
63
+ variant: "text",
64
+ width: 160,
65
+ height: 36
66
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
67
+ variant: "circular",
68
+ width: 40,
69
+ height: 40
70
+ })]
71
+ }), Array.from({
72
+ length: 3
73
+ }).map((_, idx) => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
74
+ sx: {
75
+ border: "1px solid",
76
+ borderColor: "divider",
77
+ borderRadius: 2,
78
+ p: 2,
79
+ mb: 2
80
+ },
81
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
82
+ variant: "text",
83
+ width: "30%",
84
+ height: 28
85
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
86
+ variant: "text",
87
+ width: "55%"
88
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
89
+ variant: "rectangular",
90
+ height: 80,
91
+ sx: {
92
+ my: 1.5,
93
+ borderRadius: 1
94
+ }
95
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
96
+ display: "flex",
97
+ gap: 1,
98
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
99
+ variant: "rectangular",
100
+ width: 120,
101
+ height: 36,
102
+ sx: {
103
+ borderRadius: 1
104
+ }
105
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
106
+ variant: "rectangular",
107
+ width: 120,
108
+ height: 36,
109
+ sx: {
110
+ borderRadius: 1
111
+ }
112
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Skeleton, {
113
+ variant: "rectangular",
114
+ width: 80,
115
+ height: 36,
116
+ sx: {
117
+ borderRadius: 1
118
+ }
119
+ })]
120
+ })]
121
+ }, idx))]
122
+ });
123
+ }
124
+ if (assignments.length === 0) {
125
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
126
+ mb: 1,
54
127
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
55
128
  alignItems: "center",
56
129
  sx: {
@@ -126,61 +199,65 @@ const AssignmentCardsList = ({
126
199
  })
127
200
  })]
128
201
  })
129
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
130
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
131
- display: "flex",
132
- justifyContent: "space-between",
133
- alignItems: "center",
134
- sx: {
135
- mb: 2
136
- },
137
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
138
- variant: "h5",
139
- children: t("assignments")
140
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
141
- placement: "left",
142
- title: t("refresh_assignments"),
143
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
144
- onClick: refreshAssignments,
145
- "aria-label": "refresh",
146
- size: "large",
147
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Refresh.default, {})
148
- })
149
- })]
150
- }), assignments.filter(assignment => {
151
- if (isCreator) return true;
152
- if (Array.isArray(assignment.assignedStudents) && !assignment.assignedStudents.includes(memberId)) {
153
- return false;
154
- }
155
- if (!assignment.scheduleDate) return true;
156
- return new Date(assignment.scheduleDate) <= new Date();
157
- }).map((assignment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentCard.default, {
158
- index: index,
159
- lastAssignmentFetch: lastAssignmentFetch,
160
- assignment: assignment,
161
- t: t,
162
- isCreator: isCreator,
163
- getCourses: getCourses,
164
- getCourseSections: getCourseSections,
165
- getRoleplays: getRoleplays,
166
- deleteAssignment: deleteAssignment,
167
- handleEditAssignment: handleEditAssignment,
168
- lastClickedExerciseId: lastClickedExerciseId,
169
- progressHelpers: progressHelpers,
170
- fetchMemberCourseCompletions: fetchMemberCourseCompletions,
171
- username: username,
172
- preferred_username: preferred_username,
173
- memberId: memberId,
174
- handleViewProgress: handleViewProgress,
175
- assignedStudents: assignmentMembersById[assignment.assignmentId] || []
176
- }, assignment.assignmentId))]
177
- })
202
+ });
203
+ }
204
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
205
+ mb: 1,
206
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Box, {
207
+ display: "flex",
208
+ justifyContent: "space-between",
209
+ alignItems: "center",
210
+ sx: {
211
+ mb: 2
212
+ },
213
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Typography, {
214
+ variant: "h5",
215
+ children: t("assignments")
216
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
217
+ placement: "left",
218
+ title: t("refresh_assignments"),
219
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
220
+ onClick: refreshAssignments,
221
+ "aria-label": "refresh",
222
+ size: "large",
223
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Refresh.default, {})
224
+ })
225
+ })]
226
+ }), assignments.filter(assignment => {
227
+ if (isCreator) return true;
228
+ if (Array.isArray(assignment.assignedStudents) && !assignment.assignedStudents.includes(memberId)) {
229
+ return false;
230
+ }
231
+ if (!assignment.scheduleDate) return true;
232
+ return new Date(assignment.scheduleDate) <= new Date();
233
+ }).map((assignment, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_AssignmentCard.default, {
234
+ index: index,
235
+ lastAssignmentFetch: lastAssignmentFetch,
236
+ assignment: assignment,
237
+ t: t,
238
+ isCreator: isCreator,
239
+ getCourses: getCourses,
240
+ getCourseSections: getCourseSections,
241
+ getRoleplays: getRoleplays,
242
+ deleteAssignment: deleteAssignment,
243
+ handleEditAssignment: handleEditAssignment,
244
+ lastClickedExerciseId: lastClickedExerciseId,
245
+ progressHelpers: progressHelpers,
246
+ fetchMemberCourseCompletions: fetchMemberCourseCompletions,
247
+ username: username,
248
+ preferred_username: preferred_username,
249
+ memberId: memberId,
250
+ handleViewProgress: handleViewProgress,
251
+ assignedStudents: assignmentMembersById[assignment.assignmentId] || []
252
+ }, assignment.assignmentId))]
178
253
  });
179
254
  };
180
255
  AssignmentCardsList.propTypes = {
181
256
  t: _propTypes.default.func,
182
257
  assignments: _propTypes.default.array,
183
258
  isCreator: _propTypes.default.bool,
184
- onRefresh: _propTypes.default.func
259
+ onRefresh: _propTypes.default.func,
260
+ isLoadingAssignments: _propTypes.default.bool,
261
+ assignmentMembersById: _propTypes.default.object
185
262
  };
186
263
  var _default = exports.default = AssignmentCardsList;
@@ -80,7 +80,7 @@ function DynamicAIWarning({
80
80
  })]
81
81
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
82
82
  component: "a",
83
- href: "https://nualang.com/",
83
+ href: "https://www.waysidepublishing.com/teaching-resources/ai-enhanced-nualang-chatbot",
84
84
  target: "_blank",
85
85
  rel: "noopener noreferrer",
86
86
  display: "flex",
@@ -95,7 +95,7 @@ function DynamicAIWarning({
95
95
  boxShadow: 1,
96
96
  overflow: "hidden",
97
97
  textDecoration: "none",
98
- color: "inherit",
98
+ color: "black",
99
99
  cursor: "pointer",
100
100
  transition: "0.3s",
101
101
  "&:hover": {
@@ -103,18 +103,14 @@ function DynamicAIWarning({
103
103
  backgroundColor: "#f3e5f5"
104
104
  }
105
105
  },
106
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
106
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
107
107
  flex: 2,
108
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
108
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
109
109
  variant: "body1",
110
110
  gutterBottom: true,
111
111
  ml: 1,
112
112
  children: t("chatbot_now_ai")
113
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
114
- variant: "body2",
115
- ml: 1,
116
- children: "Link to a blog on AI Chatbots"
117
- })]
113
+ })
118
114
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
119
115
  flex: 1,
120
116
  display: "flex",
@@ -126,8 +122,8 @@ function DynamicAIWarning({
126
122
  src: _owl.default,
127
123
  alt: "AI Illustration",
128
124
  sx: {
129
- height: 90,
130
- width: 90,
125
+ height: 60,
126
+ width: 60,
131
127
  objectFit: "cover",
132
128
  objectPosition: "center",
133
129
  borderTopRightRadius: 8,
@@ -151,7 +151,8 @@ function Bot({
151
151
  toggleListen(learnLang, speechContexts, model);
152
152
  };
153
153
  let isDynamicResponsesClassroomEnabled = isDynamicResponsesEnabled;
154
- if (parentClassroom?.isDynamicResponsesEnabled === "enabled") {
154
+ const parentClassroomDynamicResponsesEnabled = parentClassroom?.isDynamicResponsesEnabled === undefined || parentClassroom?.isDynamicResponsesEnabled === "enabled";
155
+ if (parentClassroomDynamicResponsesEnabled) {
155
156
  if (courseSettings?.isDynamicResponsesEnabled === "enabled") {
156
157
  isDynamicResponsesClassroomEnabled = "enable";
157
158
  } else if (courseSettings?.isDynamicResponsesEnabled === "disabled") {
@@ -480,7 +480,7 @@ function Attempt({
480
480
  const hasInappropriate = (0, _react.useMemo)(() => (messages || []).some(m => m.studentInappropriate), [messages]);
481
481
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
482
482
  className: classes.root,
483
- children: [hasInappropriate && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
483
+ children: [hasInappropriate && isCreator && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
484
484
  style: {
485
485
  backgroundColor: "#ffcccc",
486
486
  padding: "10px",
@@ -501,6 +501,7 @@ function Classroom({
501
501
  assignedCourses,
502
502
  assignmentMembersById,
503
503
  email,
504
+ isLoadingAssignments,
504
505
  ...otherProps
505
506
  }) {
506
507
  const {
@@ -962,7 +963,8 @@ function Classroom({
962
963
  getCourses: getCourses,
963
964
  refreshAssignments: refreshAssignments,
964
965
  progressHelpers: progressHelpers,
965
- preferred_username: preferred_username
966
+ preferred_username: preferred_username,
967
+ isLoadingAssignments: isLoadingAssignments
966
968
  })
967
969
  }, `tab-content-assignments`)
968
970
  }, ...(isVideoChatEnabled && isNualangLiveEnabled && (isMember && isVideoChatEnabledInSettings || isCreator) ? [{
@@ -1350,10 +1350,12 @@ function useExerciseState({
1350
1350
  setIsWordBankAttemptChanged(false);
1351
1351
  };
1352
1352
  const formatBotMessages = async botMessages => {
1353
+ // to remove baseprompt from conversation history
1354
+ const updatedConversationHistory = conversationHistory.slice(1);
1353
1355
  const responses = await Promise.all(botMessages.map(async (m, i) => {
1354
1356
  const updatedMessage = {
1355
1357
  ...m,
1356
- studentInappropriate: conversationHistory[i]?.studentInappropriate || false
1358
+ studentInappropriate: m?.studentInappropriate === true || updatedConversationHistory[i]?.studentInappropriate === true ? true : false
1357
1359
  };
1358
1360
  if (updatedMessage.audioBlob) {
1359
1361
  delete updatedMessage.audioBlob;
@@ -1577,7 +1579,7 @@ function useExerciseState({
1577
1579
  };
1578
1580
  const response = await handleMessageBot(bot.botId, body);
1579
1581
  if (response.errorMessage) {
1580
- openSnackbar("problem_getting_reply", "error");
1582
+ openSnackbar(t("problem_getting_reply"), "error");
1581
1583
  } else if (typeof response === "string" && response.startsWith("Syntax error:")) {
1582
1584
  openSnackbar(response, "error");
1583
1585
  }
@@ -1596,7 +1598,7 @@ function useExerciseState({
1596
1598
  }
1597
1599
  } catch (error) {
1598
1600
  console.error(error);
1599
- openSnackbar("problem_getting_reply", "error");
1601
+ openSnackbar(t("problem_getting_reply"), "error");
1600
1602
  setBotMessages(prevMessages => prevMessages.filter(message => message.isLoading !== true));
1601
1603
  }
1602
1604
  };
@@ -1687,7 +1689,7 @@ function useExerciseState({
1687
1689
  if (responseFromMisuse && responseFromMisuse.error) {
1688
1690
  openSnackbar(responseFromMisuse.error, "error");
1689
1691
  } else {
1690
- openSnackbar("student_misuse_reported", "info");
1692
+ openSnackbar(t("student_misuse_reported"), "info");
1691
1693
  }
1692
1694
  }
1693
1695
  } else if (exerciseName === "roleplay") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1279",
3
+ "version": "0.1.1281",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist",