@speakableio/core 0.1.18 → 0.1.20

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
  })]);
@@ -1613,25 +1618,24 @@ function useUpdateScore() {
1613
1618
  function useUpdateCardScore({
1614
1619
  isAssignment,
1615
1620
  activityId,
1616
- userId
1621
+ userId,
1622
+ set
1617
1623
  }) {
1618
1624
  const { queryClient } = useSpeakableApi();
1619
- const querySet = useSet({ setId: activityId });
1620
- const dataCurrentSet = querySet.data;
1621
1625
  const queryKey = scoreQueryKeys.byId(activityId);
1622
1626
  const mutation = _reactquery.useMutation.call(void 0, {
1623
1627
  mutationFn: async ({ cardId, cardScore }) => {
1624
1628
  const previousScores = queryClient.getQueryData(queryKey);
1625
- console.log({
1626
- previousScores,
1629
+ console.log("useUpdateCardScore", {
1630
+ previousScores: _nullishCoalesce(previousScores, () => ( {})),
1627
1631
  cardId,
1628
1632
  cardScore,
1629
- dataCurrentSet
1633
+ activityId
1630
1634
  });
1631
1635
  const { progress, score, newScoreUpdated, updatedCardScore } = getScoreUpdated({
1632
1636
  previousScores: _nullishCoalesce(previousScores, () => ( {})),
1633
1637
  cardId,
1634
- set: _nullishCoalesce(dataCurrentSet, () => ( void 0)),
1638
+ set,
1635
1639
  cardScore
1636
1640
  });
1637
1641
  await updateCardScore({
@@ -1653,7 +1657,7 @@ function useUpdateCardScore({
1653
1657
  score: previousScore,
1654
1658
  cardId,
1655
1659
  cardScore,
1656
- set: _nullishCoalesce(dataCurrentSet, () => ( void 0))
1660
+ set
1657
1661
  });
1658
1662
  return {
1659
1663
  ...previousScore,
@@ -1900,7 +1904,8 @@ function useActivity({
1900
1904
  const { mutationUpdateCardScore } = useUpdateCardScore({
1901
1905
  activityId,
1902
1906
  isAssignment,
1903
- userId
1907
+ userId,
1908
+ set: _nullishCoalesce(querySet.data, () => ( void 0))
1904
1909
  });
1905
1910
  const { mutationClearScore } = useClearScore();
1906
1911
  const { submitAssignmentScore: submitAssignmentScore2 } = useSubmitAssignmentScore({
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
  });
@@ -1613,25 +1618,24 @@ function useUpdateScore() {
1613
1618
  function useUpdateCardScore({
1614
1619
  isAssignment,
1615
1620
  activityId,
1616
- userId
1621
+ userId,
1622
+ set
1617
1623
  }) {
1618
1624
  const { queryClient } = useSpeakableApi();
1619
- const querySet = useSet({ setId: activityId });
1620
- const dataCurrentSet = querySet.data;
1621
1625
  const queryKey = scoreQueryKeys.byId(activityId);
1622
1626
  const mutation = useMutation2({
1623
1627
  mutationFn: async ({ cardId, cardScore }) => {
1624
1628
  const previousScores = queryClient.getQueryData(queryKey);
1625
- console.log({
1626
- previousScores,
1629
+ console.log("useUpdateCardScore", {
1630
+ previousScores: previousScores ?? {},
1627
1631
  cardId,
1628
1632
  cardScore,
1629
- dataCurrentSet
1633
+ activityId
1630
1634
  });
1631
1635
  const { progress, score, newScoreUpdated, updatedCardScore } = getScoreUpdated({
1632
1636
  previousScores: previousScores ?? {},
1633
1637
  cardId,
1634
- set: dataCurrentSet ?? void 0,
1638
+ set,
1635
1639
  cardScore
1636
1640
  });
1637
1641
  await updateCardScore({
@@ -1653,7 +1657,7 @@ function useUpdateCardScore({
1653
1657
  score: previousScore,
1654
1658
  cardId,
1655
1659
  cardScore,
1656
- set: dataCurrentSet ?? void 0
1660
+ set
1657
1661
  });
1658
1662
  return {
1659
1663
  ...previousScore,
@@ -1900,7 +1904,8 @@ function useActivity({
1900
1904
  const { mutationUpdateCardScore } = useUpdateCardScore({
1901
1905
  activityId,
1902
1906
  isAssignment,
1903
- userId
1907
+ userId,
1908
+ set: querySet.data ?? void 0
1904
1909
  });
1905
1910
  const { mutationClearScore } = useClearScore();
1906
1911
  const { submitAssignmentScore: submitAssignmentScore2 } = useSubmitAssignmentScore({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@speakableio/core",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Speakable-io/speakable-core.git"