@nualang/nualang-ui-components 0.1.1372 → 0.1.1376

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.
@@ -105,7 +105,8 @@ function Exercise({
105
105
  const noBots = name.toLowerCase() === "bots" && bots?.length === 0;
106
106
  const [botsOpen, setBotsOpen] = useState(noBots ? false : true);
107
107
  // Phrase lists aren't currently available to check during the first render so using the phrases instead
108
- const [phraseListsOpen, setPhraseListsOpen] = useState(phrases && phrases.length > 0 ? true : false);
108
+ const noPhrases = name.toLowerCase() === "phrases" && phrases?.length === 0;
109
+ const [phraseListsOpen, setPhraseListsOpen] = useState(noPhrases ? false : true);
109
110
  const navigate = useNavigate();
110
111
  const params = useParams();
111
112
  const {
@@ -1145,6 +1145,7 @@ function CourseOutline({
1145
1145
  isClassroomArchived = false,
1146
1146
  classroomId,
1147
1147
  isChallengeModeStudent = false,
1148
+ isReadWriteModeStudent = false,
1148
1149
  ...otherProps
1149
1150
  }) {
1150
1151
  const [percentageCompletion, setPercentageCompletion] = useState({
@@ -1155,7 +1156,7 @@ function CourseOutline({
1155
1156
  const [sects, setSects] = useState([]);
1156
1157
  useEffect(() => {
1157
1158
  if (isMember) {
1158
- const sectionsWithProgress = calcCompletions(sections, completions, null, isChallengeModeStudent);
1159
+ const sectionsWithProgress = calcCompletions(sections, completions, null, isChallengeModeStudent, isReadWriteModeStudent);
1159
1160
  const percentCompletion = calcPercentageCompletion(sectionsWithProgress);
1160
1161
  setSects(sectionsWithProgress);
1161
1162
  setPercentageCompletion(percentCompletion);
@@ -1167,7 +1168,7 @@ function CourseOutline({
1167
1168
  percentage: 0
1168
1169
  });
1169
1170
  }
1170
- }, [isMember, isChallengeModeStudent, JSON.stringify(sections), JSON.stringify(completions)]);
1171
+ }, [isMember, isChallengeModeStudent, isReadWriteModeStudent, JSON.stringify(sections), JSON.stringify(completions)]);
1171
1172
  const moveSection = useCallback((dragIndex, hoverIndex) => {
1172
1173
  const dragSection = sects[dragIndex];
1173
1174
  const newSections = update(sects, {
@@ -508,6 +508,7 @@ function Classroom({
508
508
  email,
509
509
  isLoadingAssignments,
510
510
  isChallengeModeStudent,
511
+ isReadWriteModeStudent,
511
512
  makeChatGptApiRequest,
512
513
  siteLanguage
513
514
  }) {
@@ -1000,7 +1001,8 @@ function Classroom({
1000
1001
  completionHelpers: completionHelpers,
1001
1002
  preferred_username: preferred_username,
1002
1003
  isLoadingAssignments: isLoadingAssignments,
1003
- isChallengeModeStudent: isChallengeModeStudent
1004
+ isChallengeModeStudent: isChallengeModeStudent,
1005
+ isReadWriteModeStudent: isReadWriteModeStudent
1004
1006
  })
1005
1007
  }, `tab-content-assignments`)
1006
1008
  }, ...(isVideoChatEnabled && isNualangLiveEnabled && (isMember && isVideoChatEnabledInSettings || isCreator) ? [{
@@ -1714,6 +1716,7 @@ export default function ViewClassroom({
1714
1716
  createdGame,
1715
1717
  isNualangLiveEnabled,
1716
1718
  isChallengeModeStudent,
1719
+ isReadWriteModeStudent,
1717
1720
  handleCreateAssignment,
1718
1721
  handleEditAssignment,
1719
1722
  assignments,
@@ -1804,6 +1807,7 @@ export default function ViewClassroom({
1804
1807
  createdGame: createdGame,
1805
1808
  isNualangLiveEnabled: isNualangLiveEnabled,
1806
1809
  isChallengeModeStudent: isChallengeModeStudent,
1810
+ isReadWriteModeStudent: isReadWriteModeStudent,
1807
1811
  handleCreateAssignment: handleCreateAssignment,
1808
1812
  handleEditAssignment: handleEditAssignment,
1809
1813
  assignments: assignments,
@@ -324,6 +324,7 @@ function Course({
324
324
  loading,
325
325
  featureFlags,
326
326
  isChallengeModeStudent,
327
+ isReadWriteModeStudent,
327
328
  ...otherProps
328
329
  }) {
329
330
  const {
@@ -644,7 +645,8 @@ function Course({
644
645
  courseSettings: courseSettings,
645
646
  verificationStatus: verificationStatus,
646
647
  handleDeletePDF: handleDeleteSectionPDF,
647
- isChallengeModeStudent: isChallengeModeStudent
648
+ isChallengeModeStudent: isChallengeModeStudent,
649
+ isReadWriteModeStudent: isReadWriteModeStudent
648
650
  })
649
651
  })
650
652
  }), !isLoading && !isSectionsLoading && sections.length === 0 && /*#__PURE__*/_jsx(SectionsNotFound, {
@@ -1010,6 +1012,8 @@ export default function ViewCourse({
1010
1012
  addCourseToClassroom,
1011
1013
  openSnackbar,
1012
1014
  handleDeleteCourseVideo,
1015
+ isChallengeModeStudent,
1016
+ isReadWriteModeStudent,
1013
1017
  ...otherProps
1014
1018
  }) {
1015
1019
  const {
@@ -1034,6 +1038,8 @@ export default function ViewCourse({
1034
1038
  addCourseToClassroom: addCourseToClassroom,
1035
1039
  openSnackbar: openSnackbar,
1036
1040
  isStudent: isStudent,
1041
+ isChallengeModeStudent: isChallengeModeStudent,
1042
+ isReadWriteModeStudent: isReadWriteModeStudent,
1037
1043
  ...otherProps
1038
1044
  })
1039
1045
  }), !isLoading && Object.keys(safeCourse).length === 0 && /*#__PURE__*/_jsx(CourseNotFound, {
@@ -100,7 +100,6 @@ const useStyles = makeStyles()(theme => ({
100
100
  position: "relative"
101
101
  }
102
102
  }));
103
- console.log("ViewTopic render");
104
103
  function OverflowMenu({
105
104
  t,
106
105
  topicId,
@@ -510,14 +509,14 @@ function Topic({
510
509
  const handleCloseViewPdf = () => setIsViewPdfOpen(false);
511
510
  const topicCompletion = useMemo(() => {
512
511
  if (isMember && topic?.topicId && topic?.completions?.length) {
513
- return calcTopicCompletions(topic, topic.completions, false, null, isChallengeModeStudent).completion;
512
+ return calcTopicCompletions(topic, topic.completions, false, null, isChallengeModeStudent, isReadWriteModeStudent).completion;
514
513
  }
515
514
  return {
516
515
  completed: 0,
517
516
  total: 0,
518
517
  percentage: 0
519
518
  };
520
- }, [isMember, topic?.topicId, topic?.completions?.length, isChallengeModeStudent]);
519
+ }, [isMember, topic?.topicId, topic?.completions?.length, isChallengeModeStudent, isReadWriteModeStudent]);
521
520
  const {
522
521
  percentage,
523
522
  completed,
@@ -17,6 +17,7 @@ export default function useClassroomState({
17
17
  const classroomMemberData = queryClient.getQueryData(classrooms.classroomKeys.itemMember(classroomId, username, memberId));
18
18
  const [isMember, setIsMember] = useState(classroomMemberData?.Item ? true : false);
19
19
  const [isChallengeModeStudent, setisChallengeModeStudent] = useState(classroomMemberData?.Item?.assignedLabels && classroomMemberData?.Item?.assignedLabels.isChallengeModeStudent === true);
20
+ const [isReadWriteModeStudent, setIsReadWriteModeStudent] = useState(classroomMemberData?.Item?.assignedLabels && classroomMemberData?.Item?.assignedLabels.isReadWriteModeStudent === true);
20
21
  let filters = {
21
22
  limit: config.limits.classroomMembers
22
23
  };
@@ -38,14 +39,17 @@ export default function useClassroomState({
38
39
  if (memberQuery.isSuccess) {
39
40
  const isClassroomMember = memberQuery.data && memberQuery.data.Item ? true : false;
40
41
  const isChallengeModeStudent = memberQuery.data?.Item?.assignedLabels && memberQuery.data?.Item?.assignedLabels.isChallengeModeStudent === true;
42
+ const isReadWriteModeStudent = memberQuery.data?.Item?.assignedLabels && memberQuery.data?.Item?.assignedLabels.isReadWriteModeStudent === true;
41
43
  setIsMember(isClassroomMember);
42
44
  setisChallengeModeStudent(isChallengeModeStudent);
45
+ setIsReadWriteModeStudent(isReadWriteModeStudent);
43
46
  }
44
47
  }, [memberQuery.data, memberQuery.isSuccess, memberId]);
45
48
  return {
46
49
  isMember,
47
50
  membersQuery,
48
51
  memberQuery,
49
- isChallengeModeStudent
52
+ isChallengeModeStudent,
53
+ isReadWriteModeStudent
50
54
  };
51
55
  }
@@ -126,7 +126,7 @@ export const getScoreValues = (type, id, completions) => {
126
126
  }, avgPronunciationScore];
127
127
  }
128
128
  };
129
- export const calcTopicCompletions = (topic, completions = [], isSectionHidden, assignmentExercises, includeChallengeBots = false) => {
129
+ export const calcTopicCompletions = (topic, completions = [], isSectionHidden, assignmentExercises, includeChallengeBots = false, isReadWriteModeStudent = false) => {
130
130
  let isRoleplaysHidden;
131
131
  let isPronunciationHidden;
132
132
  let isBotsHidden;
@@ -212,7 +212,16 @@ export const calcTopicCompletions = (topic, completions = [], isSectionHidden, a
212
212
  let numberOfCompletedRoleplayExercises = 0;
213
213
 
214
214
  // Define all possible roleplay exercises and their config
215
- const roleplayExercises = [{
215
+ const roleplayExercises = isReadWriteModeStudent ? [{
216
+ name: "roleplay-story",
217
+ hiddenKey: null
218
+ }, {
219
+ name: "roleplay-fill-in-the-blanks",
220
+ hiddenKey: "isFillInTheBlanksHidden"
221
+ }, {
222
+ name: "roleplay-act-it-out",
223
+ hiddenKey: "isActItOutHidden"
224
+ }] : [{
216
225
  name: "roleplay-story",
217
226
  hiddenKey: null
218
227
  }, {
@@ -330,9 +339,9 @@ export const calcTopicCompletions = (topic, completions = [], isSectionHidden, a
330
339
  }
331
340
  };
332
341
  };
333
- export const calcCompletions = (sections = [], completions = [], assignmentExercises, includeChallengeBots = false) => sections.map(section => {
342
+ export const calcCompletions = (sections = [], completions = [], assignmentExercises, includeChallengeBots = false, isReadWriteModeStudent = false) => sections.map(section => {
334
343
  const topics = section.topics.map(topic => {
335
- return calcTopicCompletions(topic, completions, section.isHidden, assignmentExercises?.filter(e => e.courseSectionTopicId === `${topic.courseSectionId}|${topic.topicId}`), includeChallengeBots);
344
+ return calcTopicCompletions(topic, completions, section.isHidden, assignmentExercises?.filter(e => e.courseSectionTopicId === `${topic.courseSectionId}|${topic.topicId}`), includeChallengeBots, isReadWriteModeStudent);
336
345
  });
337
346
  const sectionExerciseCount = topics.reduce((currentValue, topic) => topic.completion.total + currentValue, 0);
338
347
  const sectionCompletedExerciseCount = topics.reduce((currentValue, topic) => topic.completion.completed + currentValue, 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nualang/nualang-ui-components",
3
- "version": "0.1.1372",
3
+ "version": "0.1.1376",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [