@speakableio/core 0.1.29 → 0.1.31

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.
@@ -65,6 +65,9 @@ interface Assignment {
65
65
  isAssessment: boolean;
66
66
  isAvailable: boolean;
67
67
  ltiDeeplink?: string;
68
+ content?: string[];
69
+ weights?: Record<string, number>;
70
+ language?: string;
68
71
  }
69
72
  interface AssignmentWithId extends Assignment {
70
73
  id: string;
@@ -214,6 +217,9 @@ declare const createAssignmentRepo: () => {
214
217
  courseId: string;
215
218
  isAssessment: boolean;
216
219
  ltiDeeplink?: string;
220
+ content?: string[];
221
+ weights?: Record<string, number>;
222
+ language?: string;
217
223
  } | null>;
218
224
  attachScoresAssignment: (args_0: {
219
225
  assignments: AssignmentWithId[];
@@ -258,6 +264,9 @@ declare const createAssignmentRepo: () => {
258
264
  courseId: string;
259
265
  isAssessment: boolean;
260
266
  ltiDeeplink?: string;
267
+ content?: string[];
268
+ weights?: Record<string, number>;
269
+ language?: string;
261
270
  }[]>;
262
271
  getAssignmentScores: (args_0: {
263
272
  assignmentId: string;
@@ -319,6 +328,9 @@ declare function useAssignment({ assignmentId, enabled, analyticType, userId, }:
319
328
  courseId: string;
320
329
  isAssessment: boolean;
321
330
  ltiDeeplink?: string;
331
+ content?: string[];
332
+ weights?: Record<string, number>;
333
+ language?: string;
322
334
  } | null, Error>;
323
335
 
324
336
  declare const enum FeedbackTypesCard {
@@ -749,6 +761,7 @@ declare const useCreateNotification: () => {
749
761
  };
750
762
 
751
763
  type FsClient = ReturnType<typeof createFsClientBase>;
764
+ type FsClientParams = Omit<Parameters<typeof createFsClientBase>[0], 'helpers'>;
752
765
  declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
753
766
  db: FirebaseInstance;
754
767
  helpers: FirestoreHelpers;
@@ -799,6 +812,9 @@ declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
799
812
  courseId: string;
800
813
  isAssessment: boolean;
801
814
  ltiDeeplink?: string;
815
+ content?: string[];
816
+ weights?: Record<string, number>;
817
+ language?: string;
802
818
  } | null>;
803
819
  attachScoresAssignment: (args_0: {
804
820
  assignments: AssignmentWithId[];
@@ -843,6 +859,9 @@ declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
843
859
  courseId: string;
844
860
  isAssessment: boolean;
845
861
  ltiDeeplink?: string;
862
+ content?: string[];
863
+ weights?: Record<string, number>;
864
+ language?: string;
846
865
  }[]>;
847
866
  getAssignmentScores: (args_0: {
848
867
  assignmentId: string;
@@ -1057,6 +1076,9 @@ declare function useActivity({ id, isAssignment, onAssignmentSubmitted, ltiData,
1057
1076
  courseId: string;
1058
1077
  isAssessment: boolean;
1059
1078
  ltiDeeplink?: string;
1079
+ content?: string[];
1080
+ weights?: Record<string, number>;
1081
+ language?: string;
1060
1082
  } | null | undefined;
1061
1083
  query: _tanstack_react_query.UseQueryResult<AssignmentWithId | {
1062
1084
  scores: any;
@@ -1096,6 +1118,9 @@ declare function useActivity({ id, isAssignment, onAssignmentSubmitted, ltiData,
1096
1118
  courseId: string;
1097
1119
  isAssessment: boolean;
1098
1120
  ltiDeeplink?: string;
1121
+ content?: string[];
1122
+ weights?: Record<string, number>;
1123
+ language?: string;
1099
1124
  } | null, Error>;
1100
1125
  };
1101
1126
  scores: {
@@ -1129,7 +1154,7 @@ declare function useActivity({ id, isAssignment, onAssignmentSubmitted, ltiData,
1129
1154
  };
1130
1155
  };
1131
1156
 
1132
- declare const createFsClientNative: ({ db, httpsCallable, logEvent, }: Parameters<typeof createFsClientBase>[0]) => {
1157
+ declare const createFsClientNative: ({ db, httpsCallable, logEvent }: FsClientParams) => {
1133
1158
  assignmentRepo: {
1134
1159
  getAssignment: (params: {
1135
1160
  assignmentId: string;
@@ -1174,6 +1199,9 @@ declare const createFsClientNative: ({ db, httpsCallable, logEvent, }: Parameter
1174
1199
  courseId: string;
1175
1200
  isAssessment: boolean;
1176
1201
  ltiDeeplink?: string;
1202
+ content?: string[];
1203
+ weights?: Record<string, number>;
1204
+ language?: string;
1177
1205
  } | null>;
1178
1206
  attachScoresAssignment: (args_0: {
1179
1207
  assignments: AssignmentWithId[];
@@ -1218,6 +1246,9 @@ declare const createFsClientNative: ({ db, httpsCallable, logEvent, }: Parameter
1218
1246
  courseId: string;
1219
1247
  isAssessment: boolean;
1220
1248
  ltiDeeplink?: string;
1249
+ content?: string[];
1250
+ weights?: Record<string, number>;
1251
+ language?: string;
1221
1252
  }[]>;
1222
1253
  getAssignmentScores: (args_0: {
1223
1254
  assignmentId: string;
@@ -1528,7 +1528,7 @@ import dayjs4 from "dayjs";
1528
1528
  async function _submitAssignmentScore({
1529
1529
  cardIds,
1530
1530
  assignment,
1531
- setWeights,
1531
+ weights,
1532
1532
  userId,
1533
1533
  status,
1534
1534
  studentName
@@ -1546,7 +1546,7 @@ async function _submitAssignmentScore({
1546
1546
  assignment,
1547
1547
  userId,
1548
1548
  cardIds,
1549
- setWeights,
1549
+ weights,
1550
1550
  fieldsUpdated,
1551
1551
  studentName
1552
1552
  );
@@ -1561,14 +1561,14 @@ var submitAssignmentScore = withErrorHandler(
1561
1561
  _submitAssignmentScore,
1562
1562
  "submitAssignmentScore"
1563
1563
  );
1564
- async function handleAssessment(assignment, userId, cardIds, setWeights, fieldsUpdated, studentName) {
1564
+ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpdated, studentName) {
1565
1565
  var _a, _b;
1566
1566
  const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
1567
1567
  const response = await api.getDoc(path);
1568
1568
  if (!response.data) {
1569
1569
  throw new Error("Score not found");
1570
1570
  }
1571
- const { score: scoreCalculated } = calculateScoreAndProgress_default(response.data, cardIds, setWeights);
1571
+ const { score: scoreCalculated } = calculateScoreAndProgress_default(response.data, cardIds, weights);
1572
1572
  await api.updateDoc(path, { score: scoreCalculated, status: "PENDING_REVIEW" });
1573
1573
  await ((_b = (_a = SpeakableFirebaseFunctions).submitAssessment) == null ? void 0 : _b.call(_a, {
1574
1574
  assignmentId: assignment.id,
@@ -1664,7 +1664,8 @@ function useUpdateCardScore({
1664
1664
  isAssignment,
1665
1665
  activityId,
1666
1666
  userId,
1667
- set
1667
+ cardIds,
1668
+ weights
1668
1669
  }) {
1669
1670
  const { queryClient } = useSpeakableApi();
1670
1671
  const queryKey = scoreQueryKeys.byId(activityId);
@@ -1674,8 +1675,9 @@ function useUpdateCardScore({
1674
1675
  const { progress, score, newScoreUpdated, updatedCardScore } = getScoreUpdated({
1675
1676
  previousScores: previousScores != null ? previousScores : {},
1676
1677
  cardId,
1677
- set,
1678
- cardScore
1678
+ cardScore,
1679
+ cardIds,
1680
+ weights
1679
1681
  });
1680
1682
  await updateCardScore({
1681
1683
  userId,
@@ -1696,7 +1698,8 @@ function useUpdateCardScore({
1696
1698
  score: previousScore,
1697
1699
  cardId,
1698
1700
  cardScore,
1699
- set
1701
+ cardIds,
1702
+ weights
1700
1703
  });
1701
1704
  return {
1702
1705
  ...previousScore,
@@ -1721,9 +1724,10 @@ var getScoreUpdated = ({
1721
1724
  cardId,
1722
1725
  cardScore,
1723
1726
  previousScores,
1724
- set
1727
+ cardIds,
1728
+ weights
1725
1729
  }) => {
1726
- var _a, _b, _c, _d;
1730
+ var _a, _b;
1727
1731
  const previousCard = (_a = previousScores.cards) == null ? void 0 : _a[cardId];
1728
1732
  const newCardScore = {
1729
1733
  ...previousCard != null ? previousCard : {},
@@ -1736,11 +1740,7 @@ var getScoreUpdated = ({
1736
1740
  [cardId]: newCardScore
1737
1741
  }
1738
1742
  };
1739
- const { score, progress } = calculateScoreAndProgress_default(
1740
- newScores,
1741
- (_c = set == null ? void 0 : set.content) != null ? _c : [],
1742
- (_d = set == null ? void 0 : set.weights) != null ? _d : {}
1743
- );
1743
+ const { score, progress } = calculateScoreAndProgress_default(newScores, cardIds, weights);
1744
1744
  return {
1745
1745
  newScoreUpdated: newScores,
1746
1746
  updatedCardScore: cardScore,
@@ -1752,9 +1752,10 @@ var handleOptimisticScore = ({
1752
1752
  score,
1753
1753
  cardId,
1754
1754
  cardScore,
1755
- set
1755
+ cardIds,
1756
+ weights
1756
1757
  }) => {
1757
- var _a, _b, _c;
1758
+ var _a;
1758
1759
  let cards = { ...(_a = score == null ? void 0 : score.cards) != null ? _a : {} };
1759
1760
  cards = {
1760
1761
  ...cards,
@@ -1769,8 +1770,8 @@ var handleOptimisticScore = ({
1769
1770
  ...score != null ? score : {},
1770
1771
  cards
1771
1772
  },
1772
- (_b = set == null ? void 0 : set.content) != null ? _b : [],
1773
- (_c = set == null ? void 0 : set.weights) != null ? _c : {}
1773
+ cardIds,
1774
+ weights
1774
1775
  );
1775
1776
  return { cards, score: scoreValue, progress };
1776
1777
  };
@@ -1802,7 +1803,7 @@ function useSubmitAssignmentScore({
1802
1803
  assignment,
1803
1804
  userId,
1804
1805
  cardIds,
1805
- setWeights,
1806
+ weights,
1806
1807
  scores,
1807
1808
  status
1808
1809
  }) => {
@@ -1811,7 +1812,7 @@ function useSubmitAssignmentScore({
1811
1812
  assignment,
1812
1813
  userId,
1813
1814
  cardIds,
1814
- setWeights,
1815
+ weights,
1815
1816
  status,
1816
1817
  studentName
1817
1818
  });
@@ -1907,7 +1908,7 @@ function useActivityTracker({ userId }) {
1907
1908
  }) => {
1908
1909
  if (userId) {
1909
1910
  const { doc: doc2, serverTimestamp: serverTimestamp2, setDoc: setDoc2 } = api.accessHelpers();
1910
- const activityRef = doc2(`users/${userId}/activity${id}`);
1911
+ const activityRef = doc2(`users/${userId}/activity/${id}`);
1911
1912
  const timestamp = serverTimestamp2();
1912
1913
  await setDoc2(activityRef, {
1913
1914
  name: activityName,
@@ -1930,7 +1931,7 @@ function useActivity({
1930
1931
  onAssignmentSubmitted,
1931
1932
  ltiData
1932
1933
  }) {
1933
- var _a, _b, _c, _d;
1934
+ var _a, _b;
1934
1935
  const { queryClient, user } = useSpeakableApi();
1935
1936
  const userId = user.auth.uid;
1936
1937
  const assignmentQuery = useAssignment({
@@ -1942,9 +1943,15 @@ function useActivity({
1942
1943
  const setId = isAssignment ? (_a = activeAssignment == null ? void 0 : activeAssignment.setId) != null ? _a : "" : id;
1943
1944
  const querySet = useSet({ setId });
1944
1945
  const setData = querySet.data;
1946
+ const assignmentContent = activeAssignment == null ? void 0 : activeAssignment.content;
1947
+ const assignmentWeights = activeAssignment == null ? void 0 : activeAssignment.weights;
1948
+ const setContent = setData == null ? void 0 : setData.content;
1949
+ const setWeights = setData == null ? void 0 : setData.weights;
1950
+ const contentCardsToUse = isAssignment ? assignmentContent != null ? assignmentContent : setContent : setContent;
1951
+ const weightsToUse = isAssignment ? assignmentWeights != null ? assignmentWeights : setWeights : setWeights;
1945
1952
  const activityId = isAssignment ? (_b = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b : "" : setId;
1946
1953
  const { cardsObject, cardsQueries, cards } = useCards({
1947
- cardIds: (_c = setData == null ? void 0 : setData.content) != null ? _c : [],
1954
+ cardIds: contentCardsToUse != null ? contentCardsToUse : [],
1948
1955
  enabled: querySet.isSuccess,
1949
1956
  asObject: true
1950
1957
  });
@@ -1961,7 +1968,8 @@ function useActivity({
1961
1968
  activityId,
1962
1969
  isAssignment,
1963
1970
  userId,
1964
- set: (_d = querySet.data) != null ? _d : void 0
1971
+ cardIds: contentCardsToUse != null ? contentCardsToUse : [],
1972
+ weights: weightsToUse != null ? weightsToUse : {}
1965
1973
  });
1966
1974
  const { mutationClearScore } = useClearScore();
1967
1975
  const { submitAssignmentScore: submitAssignmentScore2 } = useSubmitAssignmentScore({
@@ -2001,7 +2009,7 @@ function useActivity({
2001
2009
  });
2002
2010
  };
2003
2011
  const onSubmitScore = async () => {
2004
- var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l;
2012
+ var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
2005
2013
  try {
2006
2014
  let results;
2007
2015
  if (isAssignment) {
@@ -2012,23 +2020,23 @@ function useActivity({
2012
2020
  results = await submitAssignmentScore2({
2013
2021
  assignment: assignmentQuery.data,
2014
2022
  userId,
2015
- cardIds: (_b2 = setData == null ? void 0 : setData.content) != null ? _b2 : [],
2023
+ cardIds: contentCardsToUse != null ? contentCardsToUse : [],
2016
2024
  scores: scoreQuery.data,
2017
- setWeights: (_c2 = setData == null ? void 0 : setData.weights) != null ? _c2 : {},
2025
+ weights: weightsToUse != null ? weightsToUse : {},
2018
2026
  status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
2019
2027
  });
2020
- if ((_d2 = assignmentQuery.data) == null ? void 0 : _d2.ltiDeeplink) {
2028
+ if ((_b2 = assignmentQuery.data) == null ? void 0 : _b2.ltiDeeplink) {
2021
2029
  submitLTIScore({
2022
- maxPoints: (_e = assignmentQuery.data) == null ? void 0 : _e.maxPoints,
2023
- score: (_g = (_f = scoreQuery.data) == null ? void 0 : _f.score) != null ? _g : 0,
2024
- SERVICE_KEY: (_h = ltiData == null ? void 0 : ltiData.serviceKey) != null ? _h : "",
2025
- lineItemId: (_i = ltiData == null ? void 0 : ltiData.lineItemId) != null ? _i : "",
2026
- lti_id: (_j = ltiData == null ? void 0 : ltiData.lti_id) != null ? _j : ""
2030
+ maxPoints: (_c = assignmentQuery.data) == null ? void 0 : _c.maxPoints,
2031
+ score: (_e = (_d = scoreQuery.data) == null ? void 0 : _d.score) != null ? _e : 0,
2032
+ SERVICE_KEY: (_f = ltiData == null ? void 0 : ltiData.serviceKey) != null ? _f : "",
2033
+ lineItemId: (_g = ltiData == null ? void 0 : ltiData.lineItemId) != null ? _g : "",
2034
+ lti_id: (_h = ltiData == null ? void 0 : ltiData.lti_id) != null ? _h : ""
2027
2035
  });
2028
2036
  }
2029
2037
  } else {
2030
2038
  results = await submitPracticeScore2({
2031
- setId: (_l = (_k = querySet.data) == null ? void 0 : _k.id) != null ? _l : "",
2039
+ setId: (_j = (_i = querySet.data) == null ? void 0 : _i.id) != null ? _j : "",
2032
2040
  userId,
2033
2041
  scores: scoreQuery.data
2034
2042
  });
@@ -2046,7 +2054,7 @@ function useActivity({
2046
2054
  gradingStandard,
2047
2055
  type
2048
2056
  }) => {
2049
- var _a2, _b2, _c2, _d2, _e, _f, _g, _h;
2057
+ var _a2, _b2, _c, _d, _e, _f, _g, _h;
2050
2058
  const card = cardsObject == null ? void 0 : cardsObject[cardId];
2051
2059
  const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
2052
2060
  const cardScore = (_a2 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a2[cardId];
@@ -2054,8 +2062,8 @@ function useActivity({
2054
2062
  addGradingStandardLog(
2055
2063
  {
2056
2064
  assignmentId: (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "",
2057
- courseId: (_c2 = activeAssignment == null ? void 0 : activeAssignment.courseId) != null ? _c2 : "",
2058
- teacherId: (_d2 = activeAssignment == null ? void 0 : activeAssignment.owners[0]) != null ? _d2 : "",
2065
+ courseId: (_c = activeAssignment == null ? void 0 : activeAssignment.courseId) != null ? _c : "",
2066
+ teacherId: (_d = activeAssignment == null ? void 0 : activeAssignment.owners[0]) != null ? _d : "",
2059
2067
  setId: (_e = setData == null ? void 0 : setData.id) != null ? _e : "",
2060
2068
  cardId,
2061
2069
  level: gradingStandard.level,
@@ -2225,11 +2233,7 @@ function createFsClientBase({
2225
2233
  }
2226
2234
 
2227
2235
  // src/lib/create-firebase-client-native.ts
2228
- var createFsClientNative = ({
2229
- db,
2230
- httpsCallable,
2231
- logEvent
2232
- }) => {
2236
+ var createFsClientNative = ({ db, httpsCallable, logEvent }) => {
2233
2237
  return createFsClientBase({
2234
2238
  db,
2235
2239
  httpsCallable,