@speakableio/core 0.1.17 → 0.1.19

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.
package/dist/index.js CHANGED
@@ -1371,6 +1371,7 @@ var getScore = withErrorHandler(_getScore, "getScore");
1371
1371
 
1372
1372
  // src/domains/assignment/utils/calculateScoreAndProgress.ts
1373
1373
  var calculateScoreAndProgress = (scores, cardsList, weights) => {
1374
+ console.log("calculateScoreAndProgress", scores, cardsList, weights);
1374
1375
  const totalSetPoints = cardsList.reduce((acc, cardId) => {
1375
1376
  acc += _optionalChain([weights, 'optionalAccess', _32 => _32[cardId]]) || 1;
1376
1377
  return acc;
@@ -1481,7 +1482,7 @@ async function clearScore(params) {
1481
1482
 
1482
1483
  // src/domains/assignment/services/submit-assignment-score.service.ts
1483
1484
 
1484
- async function submitAssignmentScore({
1485
+ async function _submitAssignmentScore({
1485
1486
  cardIds,
1486
1487
  assignment,
1487
1488
  setWeights,
@@ -1513,6 +1514,10 @@ async function submitAssignmentScore({
1513
1514
  await api.updateDoc(path, { ...fieldsUpdated });
1514
1515
  return { success: true, fieldsUpdated };
1515
1516
  }
1517
+ var submitAssignmentScore = withErrorHandler(
1518
+ _submitAssignmentScore,
1519
+ "submitAssignmentScore"
1520
+ );
1516
1521
  async function handleAssessment(assignment, userId, cardIds, setWeights, fieldsUpdated, studentName) {
1517
1522
  const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
1518
1523
  const response = await api.getDoc(path);
@@ -1532,7 +1537,7 @@ async function handleAssessment(assignment, userId, cardIds, setWeights, fieldsU
1532
1537
  return { success: true, fieldsUpdated };
1533
1538
  }
1534
1539
  async function handleCourseAssignment(assignment, userId) {
1535
- const { data } = await _optionalChain([SpeakableFirebaseFunctions, 'optionalAccess', _51 => _51.submitAssignmentV2, 'optionalCall', _52 => _52({
1540
+ await _optionalChain([SpeakableFirebaseFunctions, 'optionalAccess', _51 => _51.submitAssignmentV2, 'optionalCall', _52 => _52({
1536
1541
  assignmentId: assignment.id,
1537
1542
  userId
1538
1543
  })]);
@@ -1622,11 +1627,11 @@ function useUpdateCardScore({
1622
1627
  const mutation = _reactquery.useMutation.call(void 0, {
1623
1628
  mutationFn: async ({ cardId, cardScore }) => {
1624
1629
  const previousScores = queryClient.getQueryData(queryKey);
1625
- console.log({
1626
- previousScores,
1630
+ console.log("useUpdateCardScore", {
1631
+ previousScores: _nullishCoalesce(previousScores, () => ( {})),
1627
1632
  cardId,
1628
1633
  cardScore,
1629
- dataCurrentSet
1634
+ activityId
1630
1635
  });
1631
1636
  const { progress, score, newScoreUpdated, updatedCardScore } = getScoreUpdated({
1632
1637
  previousScores: _nullishCoalesce(previousScores, () => ( {})),
@@ -1879,11 +1884,12 @@ function useActivity({
1879
1884
  enabled: isAssignment
1880
1885
  });
1881
1886
  const activeAssignment = assignmentQuery.data;
1882
- const activityId = isAssignment ? _nullishCoalesce(_optionalChain([activeAssignment, 'optionalAccess', _62 => _62.id]), () => ( "")) : id;
1883
- const querySet = useSet({ setId: _nullishCoalesce(id, () => ( "")), enabled: isAssignment });
1887
+ const setId = isAssignment ? _nullishCoalesce(_optionalChain([activeAssignment, 'optionalAccess', _62 => _62.setId]), () => ( "")) : id;
1888
+ const querySet = useSet({ setId });
1884
1889
  const setData = querySet.data;
1890
+ const activityId = isAssignment ? _nullishCoalesce(_optionalChain([activeAssignment, 'optionalAccess', _63 => _63.id]), () => ( "")) : setId;
1885
1891
  const { cardsObject, cardsQueries, cards } = useCards({
1886
- cardIds: _nullishCoalesce(_optionalChain([setData, 'optionalAccess', _63 => _63.content]), () => ( [])),
1892
+ cardIds: _nullishCoalesce(_optionalChain([setData, 'optionalAccess', _64 => _64.content]), () => ( [])),
1887
1893
  enabled: querySet.isSuccess,
1888
1894
  asObject: true
1889
1895
  });
@@ -1891,7 +1897,7 @@ function useActivity({
1891
1897
  isAssignment,
1892
1898
  activityId: id,
1893
1899
  userId,
1894
- courseId: _optionalChain([activeAssignment, 'optionalAccess', _64 => _64.courseId]),
1900
+ courseId: _optionalChain([activeAssignment, 'optionalAccess', _65 => _65.courseId]),
1895
1901
  googleClassroomUserId: user.profile.googleClassroomUserId,
1896
1902
  enabled: isAssignment ? assignmentQuery.isSuccess : querySet.isSuccess
1897
1903
  });
@@ -1922,12 +1928,12 @@ function useActivity({
1922
1928
  cardId,
1923
1929
  wasCompleted = true
1924
1930
  }) => {
1925
- const currentCard = _optionalChain([cardsObject, 'optionalAccess', _65 => _65[cardId]]);
1926
- if (_optionalChain([currentCard, 'optionalAccess', _66 => _66.type]) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || _optionalChain([currentCard, 'optionalAccess', _67 => _67.type]) === "READ_REPEAT" /* READ_REPEAT */) {
1931
+ const currentCard = _optionalChain([cardsObject, 'optionalAccess', _66 => _66[cardId]]);
1932
+ if (_optionalChain([currentCard, 'optionalAccess', _67 => _67.type]) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || _optionalChain([currentCard, 'optionalAccess', _68 => _68.type]) === "READ_REPEAT" /* READ_REPEAT */) {
1927
1933
  return;
1928
1934
  }
1929
1935
  const queryKeys = scoreQueryKeys.byId(activityId);
1930
- const activeCardScores = _optionalChain([queryClient, 'access', _68 => _68.getQueryData, 'call', _69 => _69(queryKeys), 'optionalAccess', _70 => _70.cards, 'optionalAccess', _71 => _71[cardId]]);
1936
+ const activeCardScores = _optionalChain([queryClient, 'access', _69 => _69.getQueryData, 'call', _70 => _70(queryKeys), 'optionalAccess', _71 => _71.cards, 'optionalAccess', _72 => _72[cardId]]);
1931
1937
  if (activeCardScores === void 0) return;
1932
1938
  mutationClearScore.mutate({
1933
1939
  isAssignment,
@@ -1941,21 +1947,21 @@ function useActivity({
1941
1947
  try {
1942
1948
  let results;
1943
1949
  if (isAssignment) {
1944
- const cardScores = _optionalChain([scoreQuery, 'access', _72 => _72.data, 'optionalAccess', _73 => _73.cards]) || {};
1950
+ const cardScores = _optionalChain([scoreQuery, 'access', _73 => _73.data, 'optionalAccess', _74 => _74.cards]) || {};
1945
1951
  const hasPendingReview = Object.values(cardScores).some(
1946
1952
  (cardScore) => cardScore.status === "pending_review"
1947
1953
  );
1948
1954
  results = await submitAssignmentScore2({
1949
1955
  assignment: assignmentQuery.data,
1950
1956
  userId,
1951
- cardIds: _nullishCoalesce(_optionalChain([setData, 'optionalAccess', _74 => _74.content]), () => ( [])),
1957
+ cardIds: _nullishCoalesce(_optionalChain([setData, 'optionalAccess', _75 => _75.content]), () => ( [])),
1952
1958
  scores: scoreQuery.data,
1953
- setWeights: _nullishCoalesce(_optionalChain([setData, 'optionalAccess', _75 => _75.weights]), () => ( {})),
1959
+ setWeights: _nullishCoalesce(_optionalChain([setData, 'optionalAccess', _76 => _76.weights]), () => ( {})),
1954
1960
  status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
1955
1961
  });
1956
1962
  } else {
1957
1963
  results = await submitPracticeScore2({
1958
- setId: _nullishCoalesce(_optionalChain([querySet, 'access', _76 => _76.data, 'optionalAccess', _77 => _77.id]), () => ( "")),
1964
+ setId: _nullishCoalesce(_optionalChain([querySet, 'access', _77 => _77.data, 'optionalAccess', _78 => _78.id]), () => ( "")),
1959
1965
  userId,
1960
1966
  scores: scoreQuery.data
1961
1967
  });
@@ -2013,28 +2019,28 @@ var useInitActivity = ({
2013
2019
  if (!enabled) return;
2014
2020
  if (!assignment) {
2015
2021
  trackActivity({
2016
- activityName: _nullishCoalesce(_optionalChain([set, 'optionalAccess', _78 => _78.name]), () => ( "")),
2022
+ activityName: _nullishCoalesce(_optionalChain([set, 'optionalAccess', _79 => _79.name]), () => ( "")),
2017
2023
  activityType: "set",
2018
- id: _optionalChain([set, 'optionalAccess', _79 => _79.id]),
2019
- language: _optionalChain([set, 'optionalAccess', _80 => _80.language])
2024
+ id: _optionalChain([set, 'optionalAccess', _80 => _80.id]),
2025
+ language: _optionalChain([set, 'optionalAccess', _81 => _81.language])
2020
2026
  });
2021
2027
  } else if (assignment.name) {
2022
2028
  trackActivity({
2023
2029
  activityName: assignment.name,
2024
2030
  activityType: assignment.isAssessment ? "assessment" : "assignment",
2025
2031
  id: assignment.id,
2026
- language: _optionalChain([set, 'optionalAccess', _81 => _81.language])
2032
+ language: _optionalChain([set, 'optionalAccess', _82 => _82.language])
2027
2033
  });
2028
2034
  }
2029
- if (_optionalChain([set, 'optionalAccess', _82 => _82.public])) {
2030
- _optionalChain([SpeakableFirebaseFunctions, 'optionalAccess', _83 => _83.onSetOpened, 'optionalCall', _84 => _84({
2035
+ if (_optionalChain([set, 'optionalAccess', _83 => _83.public])) {
2036
+ _optionalChain([SpeakableFirebaseFunctions, 'optionalAccess', _84 => _84.onSetOpened, 'optionalCall', _85 => _85({
2031
2037
  setId: set.id,
2032
2038
  language: set.language
2033
2039
  })]);
2034
2040
  }
2035
- _optionalChain([SpeakableFirebaseFunctions, 'optionalAccess', _85 => _85.updateAlgoliaIndex, 'optionalCall', _86 => _86({
2041
+ _optionalChain([SpeakableFirebaseFunctions, 'optionalAccess', _86 => _86.updateAlgoliaIndex, 'optionalCall', _87 => _87({
2036
2042
  updatePlays: true,
2037
- objectID: _optionalChain([set, 'optionalAccess', _87 => _87.id])
2043
+ objectID: _optionalChain([set, 'optionalAccess', _88 => _88.id])
2038
2044
  })]);
2039
2045
  };
2040
2046
  _react.useEffect.call(void 0, () => {
package/dist/index.mjs CHANGED
@@ -1371,6 +1371,7 @@ var getScore = withErrorHandler(_getScore, "getScore");
1371
1371
 
1372
1372
  // src/domains/assignment/utils/calculateScoreAndProgress.ts
1373
1373
  var calculateScoreAndProgress = (scores, cardsList, weights) => {
1374
+ console.log("calculateScoreAndProgress", scores, cardsList, weights);
1374
1375
  const totalSetPoints = cardsList.reduce((acc, cardId) => {
1375
1376
  acc += weights?.[cardId] || 1;
1376
1377
  return acc;
@@ -1481,7 +1482,7 @@ async function clearScore(params) {
1481
1482
 
1482
1483
  // src/domains/assignment/services/submit-assignment-score.service.ts
1483
1484
  import dayjs4 from "dayjs";
1484
- async function submitAssignmentScore({
1485
+ async function _submitAssignmentScore({
1485
1486
  cardIds,
1486
1487
  assignment,
1487
1488
  setWeights,
@@ -1513,6 +1514,10 @@ async function submitAssignmentScore({
1513
1514
  await api.updateDoc(path, { ...fieldsUpdated });
1514
1515
  return { success: true, fieldsUpdated };
1515
1516
  }
1517
+ var submitAssignmentScore = withErrorHandler(
1518
+ _submitAssignmentScore,
1519
+ "submitAssignmentScore"
1520
+ );
1516
1521
  async function handleAssessment(assignment, userId, cardIds, setWeights, fieldsUpdated, studentName) {
1517
1522
  const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
1518
1523
  const response = await api.getDoc(path);
@@ -1532,7 +1537,7 @@ async function handleAssessment(assignment, userId, cardIds, setWeights, fieldsU
1532
1537
  return { success: true, fieldsUpdated };
1533
1538
  }
1534
1539
  async function handleCourseAssignment(assignment, userId) {
1535
- const { data } = await SpeakableFirebaseFunctions?.submitAssignmentV2?.({
1540
+ await SpeakableFirebaseFunctions?.submitAssignmentV2?.({
1536
1541
  assignmentId: assignment.id,
1537
1542
  userId
1538
1543
  });
@@ -1622,11 +1627,11 @@ function useUpdateCardScore({
1622
1627
  const mutation = useMutation2({
1623
1628
  mutationFn: async ({ cardId, cardScore }) => {
1624
1629
  const previousScores = queryClient.getQueryData(queryKey);
1625
- console.log({
1626
- previousScores,
1630
+ console.log("useUpdateCardScore", {
1631
+ previousScores: previousScores ?? {},
1627
1632
  cardId,
1628
1633
  cardScore,
1629
- dataCurrentSet
1634
+ activityId
1630
1635
  });
1631
1636
  const { progress, score, newScoreUpdated, updatedCardScore } = getScoreUpdated({
1632
1637
  previousScores: previousScores ?? {},
@@ -1879,9 +1884,10 @@ function useActivity({
1879
1884
  enabled: isAssignment
1880
1885
  });
1881
1886
  const activeAssignment = assignmentQuery.data;
1882
- const activityId = isAssignment ? activeAssignment?.id ?? "" : id;
1883
- const querySet = useSet({ setId: id ?? "", enabled: isAssignment });
1887
+ const setId = isAssignment ? activeAssignment?.setId ?? "" : id;
1888
+ const querySet = useSet({ setId });
1884
1889
  const setData = querySet.data;
1890
+ const activityId = isAssignment ? activeAssignment?.id ?? "" : setId;
1885
1891
  const { cardsObject, cardsQueries, cards } = useCards({
1886
1892
  cardIds: setData?.content ?? [],
1887
1893
  enabled: querySet.isSuccess,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speakableio/core",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Speakable-io/speakable-core.git"