@speakableio/core 1.0.11 → 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.
@@ -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,