@speakableio/core 1.0.12 → 1.0.13

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.
@@ -1007,6 +1007,18 @@ declare function useClearScore(): {
1007
1007
  activityId: string;
1008
1008
  }, unknown>;
1009
1009
  };
1010
+ declare function useClearScoreV2(): {
1011
+ mutationClearScore: _tanstack_react_query.UseMutationResult<{
1012
+ update: Partial<Score>;
1013
+ activityId: string;
1014
+ }, Error, {
1015
+ isAssignment: boolean;
1016
+ cardId: string;
1017
+ cardScores: PageScore;
1018
+ userId: string;
1019
+ activityId: string;
1020
+ }, unknown>;
1021
+ };
1010
1022
  declare function useSubmitAssignmentScore({ onAssignmentSubmitted, studentName, }: {
1011
1023
  onAssignmentSubmitted: (assignmentId: string) => void;
1012
1024
  studentName: string;
@@ -3242,4 +3254,4 @@ declare const createFsClientWeb: ({ db, httpsCallable, logEvent }: FsClientParam
3242
3254
  };
3243
3255
  };
3244
3256
 
3245
- export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientWeb as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getTotalCompletedCards, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
3257
+ export { ActivityPageType, type Assignment, type AssignmentAnalyticsType$1 as AssignmentAnalyticsType, type AssignmentWithId, BASE_MULTIPLE_CHOICE_FIELD_VALUES, BASE_REPEAT_FIELD_VALUES, BASE_RESPOND_FIELD_VALUES, type CreditContract, FeedbackTypesCard, FsCtx, type InstitutionSubscription, LENIENCY_OPTIONS, LeniencyCard, MULTIPLE_CHOICE_PAGE_ACTIVITY_TYPES, type Organization, type OrganizationAccess, type PageActivity, type PageActivityWithId, type PageScore, REPEAT_PAGE_ACTIVITY_TYPES, RESPOND_AUDIO_PAGE_ACTIVITY_TYPES, RESPOND_PAGE_ACTIVITY_TYPES, RESPOND_WRITE_PAGE_ACTIVITY_TYPES, type RefsCardsFiresotre, type RefsSetsFirestore, SPEAKABLE_NOTIFICATIONS, STUDENT_LEVELS_OPTIONS, type Score, type ScoreWithId, type Set, type SetWithId, type SpeakableNotificationType, SpeakableNotificationTypes, SpeakableProvider, VerificationCardStatus, assignmentQueryKeys, cardsQueryKeys, checkIsMCPage, checkIsMediaPage, checkIsRepeatPage, checkIsRespondAudioPage, checkIsRespondPage, checkIsRespondWrittenPage, checkIsShortAnswerPage, checkTypePageActivity, cleanString, createAssignmentRepo, createCardRepo, createFsClientWeb as createFsClient, createSetRepo, creditQueryKeys, debounce, getCardFromCache, getLabelPage, getPagePrompt, getPhraseLength, getRespondCardTool, getSetFromCache, getTotalCompletedCards, getWordHash, purify, refsCardsFiresotre, refsSetsFirestore, scoreQueryKeys, setsQueryKeys, updateCardInCache, updateSetInCache, useActivity, useActivityFeedbackAccess, useAssignment, useBaseOpenAI, useCards, useClearScore, useClearScoreV2, useCreateCard, useCreateCards, useCreateNotification, useGetCard, useOrganizationAccess, useScore, useSet, useSpeakableApi, useSubmitAssignmentScore, useSubmitPracticeScore, useUpdateCardScore, useUpdateScore, useUpdateStudentVocab, useUserCredits };
package/dist/index.web.js CHANGED
@@ -1143,6 +1143,39 @@ async function clearScore(params) {
1143
1143
  activityId: params.activityId
1144
1144
  };
1145
1145
  }
1146
+ async function clearScoreV2(params) {
1147
+ var _a, _b, _c, _d, _e;
1148
+ const update = {
1149
+ [`cards.${params.cardId}`]: {
1150
+ ...params.cardScores,
1151
+ attempts: ((_a = params.cardScores.attempts) != null ? _a : 1) + 1,
1152
+ correct: (_b = params.cardScores.correct) != null ? _b : 0,
1153
+ history: [
1154
+ {
1155
+ ...params.cardScores,
1156
+ attempts: (_c = params.cardScores.attempts) != null ? _c : 1,
1157
+ correct: (_d = params.cardScores.correct) != null ? _d : 0,
1158
+ retryTime: dayjs3().format("YYYY-MM-DD HH:mm:ss"),
1159
+ history: null
1160
+ },
1161
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1162
+ ...(_e = params.cardScores.history) != null ? _e : []
1163
+ ]
1164
+ }
1165
+ };
1166
+ const path = params.isAssignment ? refsAssignmentFiresotre.assignmentScores({
1167
+ id: params.activityId,
1168
+ userId: params.userId
1169
+ }) : refsScoresPractice.practiceScores({
1170
+ setId: params.activityId,
1171
+ userId: params.userId
1172
+ });
1173
+ await api.updateDoc(path, update);
1174
+ return {
1175
+ update,
1176
+ activityId: params.activityId
1177
+ };
1178
+ }
1146
1179
 
1147
1180
  // src/domains/assignment/services/submit-assignment-score.service.ts
1148
1181
  import dayjs4 from "dayjs";
@@ -1411,6 +1444,21 @@ function useClearScore() {
1411
1444
  mutationClearScore: mutation
1412
1445
  };
1413
1446
  }
1447
+ function useClearScoreV2() {
1448
+ const { queryClient } = useSpeakableApi();
1449
+ const mutation = useMutation({
1450
+ mutationFn: clearScoreV2,
1451
+ onSettled: (result) => {
1452
+ var _a;
1453
+ queryClient.invalidateQueries({
1454
+ queryKey: scoreQueryKeys.byId((_a = result == null ? void 0 : result.activityId) != null ? _a : "")
1455
+ });
1456
+ }
1457
+ });
1458
+ return {
1459
+ mutationClearScore: mutation
1460
+ };
1461
+ }
1414
1462
  function useSubmitAssignmentScore({
1415
1463
  onAssignmentSubmitted,
1416
1464
  studentName
@@ -3320,6 +3368,7 @@ export {
3320
3368
  useBaseOpenAI,
3321
3369
  useCards,
3322
3370
  useClearScore,
3371
+ useClearScoreV2,
3323
3372
  useCreateCard,
3324
3373
  useCreateCards,
3325
3374
  useCreateNotification,