@speakableio/core 1.0.16 → 1.0.18
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.native.js +24 -7
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +24 -7
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +24 -7
- package/dist/index.web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.js
CHANGED
|
@@ -1141,15 +1141,26 @@ var getScore = withErrorHandler(_getScore, "getScore");
|
|
|
1141
1141
|
|
|
1142
1142
|
// src/domains/assignment/utils/calculateScoreAndProgress.ts
|
|
1143
1143
|
var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
1144
|
+
const filteredScoreCards = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce(
|
|
1145
|
+
(acc, cardId) => {
|
|
1146
|
+
var _a;
|
|
1147
|
+
const cardScores = (_a = scores == null ? void 0 : scores.cards) == null ? void 0 : _a[cardId];
|
|
1148
|
+
if (cardScores && !cardScores.media_area_opened) {
|
|
1149
|
+
acc[cardId] = cardScores;
|
|
1150
|
+
}
|
|
1151
|
+
return acc;
|
|
1152
|
+
},
|
|
1153
|
+
{}
|
|
1154
|
+
);
|
|
1144
1155
|
const totalSetPoints = cardsList.reduce((acc, cardId) => {
|
|
1145
1156
|
acc += (weights == null ? void 0 : weights[cardId]) || 1;
|
|
1146
1157
|
return acc;
|
|
1147
1158
|
}, 0);
|
|
1148
|
-
const totalPointsAwarded = Object.keys(
|
|
1149
|
-
var _a
|
|
1150
|
-
const cardScores =
|
|
1159
|
+
const totalPointsAwarded = Object.keys(filteredScoreCards).reduce((acc, cardId) => {
|
|
1160
|
+
var _a;
|
|
1161
|
+
const cardScores = filteredScoreCards[cardId];
|
|
1151
1162
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1152
|
-
const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((
|
|
1163
|
+
const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((_a = cardScores == null ? void 0 : cardScores.score) != null ? _a : 0) : null;
|
|
1153
1164
|
const weight = (weights == null ? void 0 : weights[cardId]) || 1;
|
|
1154
1165
|
const fraction = (score2 != null ? score2 : 0) / 100;
|
|
1155
1166
|
if (score2 || score2 === 0) {
|
|
@@ -1160,9 +1171,8 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1160
1171
|
}
|
|
1161
1172
|
return acc;
|
|
1162
1173
|
}, 0);
|
|
1163
|
-
const totalCompletedCards = Object.keys(
|
|
1164
|
-
|
|
1165
|
-
const cardScores = (_a = scores == null ? void 0 : scores.cards) == null ? void 0 : _a[cardId];
|
|
1174
|
+
const totalCompletedCards = Object.keys(filteredScoreCards).reduce((acc, cardId) => {
|
|
1175
|
+
const cardScores = filteredScoreCards[cardId];
|
|
1166
1176
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1167
1177
|
acc += 1;
|
|
1168
1178
|
}
|
|
@@ -1441,6 +1451,11 @@ function useUpdateCardScore({
|
|
|
1441
1451
|
cardIds,
|
|
1442
1452
|
weights
|
|
1443
1453
|
});
|
|
1454
|
+
console.log("updates", {
|
|
1455
|
+
cardScore: updatedCardScore,
|
|
1456
|
+
progress,
|
|
1457
|
+
score
|
|
1458
|
+
});
|
|
1444
1459
|
await updateCardScore({
|
|
1445
1460
|
userId,
|
|
1446
1461
|
cardId,
|
|
@@ -1507,7 +1522,9 @@ var getScoreUpdated = ({
|
|
|
1507
1522
|
[cardId]: newCardScore
|
|
1508
1523
|
}
|
|
1509
1524
|
};
|
|
1525
|
+
console.log("newScores", newScores, cardIds, weights);
|
|
1510
1526
|
const { score, progress } = calculateScoreAndProgress_default(newScores, cardIds, weights);
|
|
1527
|
+
console.log("score and progress", score, progress);
|
|
1511
1528
|
return {
|
|
1512
1529
|
newScoreUpdated: newScores,
|
|
1513
1530
|
updatedCardScore: cardScore,
|