@speakableio/core 0.1.50 → 0.1.52
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.mjs +112 -119
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +112 -119
- package/dist/index.web.js.map +1 -1
- package/package.json +1 -1
package/dist/index.native.mjs
CHANGED
|
@@ -87,12 +87,12 @@ var FirebaseAPI = class _FirebaseAPI {
|
|
|
87
87
|
return this.config.helpers;
|
|
88
88
|
}
|
|
89
89
|
get httpsCallable() {
|
|
90
|
-
var
|
|
91
|
-
return (
|
|
90
|
+
var _a;
|
|
91
|
+
return (_a = this.config) == null ? void 0 : _a.httpsCallable;
|
|
92
92
|
}
|
|
93
93
|
logEvent(name, data) {
|
|
94
|
-
var
|
|
95
|
-
(
|
|
94
|
+
var _a;
|
|
95
|
+
(_a = this.config) == null ? void 0 : _a.logEvent(name, data);
|
|
96
96
|
}
|
|
97
97
|
accessQueryConstraints() {
|
|
98
98
|
const { query: query2, orderBy: orderBy2, limit: limit2, startAt: startAt2, startAfter: startAfter2, endAt: endAt2, endBefore: endBefore2, where: where2 } = this.helpers;
|
|
@@ -269,13 +269,13 @@ var _attachScoresAssignment = async ({
|
|
|
269
269
|
return acc;
|
|
270
270
|
}, {});
|
|
271
271
|
const assignmentsWithScores = assignments.map((a) => {
|
|
272
|
-
var
|
|
272
|
+
var _a;
|
|
273
273
|
return {
|
|
274
274
|
...a,
|
|
275
275
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/ban-ts-comment
|
|
276
276
|
// @ts-ignore
|
|
277
277
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
278
|
-
scores: (
|
|
278
|
+
scores: (_a = scoresObject[a.id]) != null ? _a : null
|
|
279
279
|
};
|
|
280
280
|
});
|
|
281
281
|
return assignmentsWithScores;
|
|
@@ -304,7 +304,7 @@ var checkAssignmentAvailability = (scheduledTime) => {
|
|
|
304
304
|
|
|
305
305
|
// src/domains/assignment/services/get-assignment.service.ts
|
|
306
306
|
async function _getAssignment(params) {
|
|
307
|
-
var
|
|
307
|
+
var _a;
|
|
308
308
|
const path = refsAssignmentFiresotre.assignment({ id: params.assignmentId });
|
|
309
309
|
const response = await api.getDoc(path);
|
|
310
310
|
if (!response.data) return null;
|
|
@@ -314,7 +314,7 @@ async function _getAssignment(params) {
|
|
|
314
314
|
...assignment,
|
|
315
315
|
isAvailable,
|
|
316
316
|
id: params.assignmentId,
|
|
317
|
-
scheduledTime: (
|
|
317
|
+
scheduledTime: (_a = assignment.scheduledTime) != null ? _a : null
|
|
318
318
|
};
|
|
319
319
|
if (params.analyticType) {
|
|
320
320
|
const assignmentsWithScores = await attachScoresAssignment({
|
|
@@ -780,30 +780,10 @@ import dayjs2 from "dayjs";
|
|
|
780
780
|
// src/constants/web.constants.ts
|
|
781
781
|
var WEB_BASE_URL = "https://app.speakable.io";
|
|
782
782
|
|
|
783
|
-
// src/lib/firebase/firebase-functions.ts
|
|
784
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
|
|
785
|
-
var SpeakableFirebaseFunctions = {
|
|
786
|
-
updateAssignmentGradebookStatus: (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "updateAssignmentGradebookStatus"),
|
|
787
|
-
onSetOpened: (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "onSetOpened"),
|
|
788
|
-
updateAlgoliaIndex: (_f = (_e = api).httpsCallable) == null ? void 0 : _f.call(_e, "updateAlgoliaIndex"),
|
|
789
|
-
submitAssignmentToGoogleClassroomV2: (_h = (_g = api).httpsCallable) == null ? void 0 : _h.call(_g, "submitAssignmentToGoogleClassroomV2"),
|
|
790
|
-
submitLTIAssignmentScore: (_j = (_i = api).httpsCallable) == null ? void 0 : _j.call(_i, "submitLTIAssignmentScore"),
|
|
791
|
-
submitAssignmentV2: (_l = (_k = api).httpsCallable) == null ? void 0 : _l.call(_k, "submitLTIAssignmentScoreV2"),
|
|
792
|
-
submitAssessment: (_n = (_m = api).httpsCallable) == null ? void 0 : _n.call(_m, "submitAssessment"),
|
|
793
|
-
sendAssessmentScoredEmail: (_p = (_o = api).httpsCallable) == null ? void 0 : _p.call(_o, "sendAssessmentScoredEmail"),
|
|
794
|
-
createNotification: (_r = (_q = api).httpsCallable) == null ? void 0 : _r.call(_q, "createNotificationV2"),
|
|
795
|
-
updateCourseAnalytics: (_t = (_s = api).httpsCallable) == null ? void 0 : _t.call(_s, "handleCouresAnalyticsEvent"),
|
|
796
|
-
checkStudentTeacherPlan: (_v = (_u = api).httpsCallable) == null ? void 0 : _v.call(_u, "checkStudentTeacherPlan"),
|
|
797
|
-
getGeminiFeedback: (_x = (_w = api).httpsCallable) == null ? void 0 : _x.call(_w, "callGetFeedback"),
|
|
798
|
-
getProficiencyEstimate: (_z = (_y = api).httpsCallable) == null ? void 0 : _z.call(_y, "getProficiencyEstimate"),
|
|
799
|
-
getAssemblyAITranscript: (_B = (_A = api).httpsCallable) == null ? void 0 : _B.call(_A, "transcribeAssemblyAIAudio"),
|
|
800
|
-
createChatCompletion: (_D = (_C = api).httpsCallable) == null ? void 0 : _D.call(_C, "createChatCompletion")
|
|
801
|
-
};
|
|
802
|
-
|
|
803
783
|
// src/domains/notification/services/send-notification.service.ts
|
|
804
784
|
var _sendNotification = async (sendTo, notification) => {
|
|
805
|
-
var
|
|
806
|
-
const results = await ((
|
|
785
|
+
var _a, _b, _c;
|
|
786
|
+
const results = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "createNotificationV2")) == null ? void 0 : _c({
|
|
807
787
|
sendTo,
|
|
808
788
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
809
789
|
notification
|
|
@@ -873,7 +853,7 @@ var createNewAssignmentNotification = async ({
|
|
|
873
853
|
data,
|
|
874
854
|
profile
|
|
875
855
|
}) => {
|
|
876
|
-
var
|
|
856
|
+
var _a;
|
|
877
857
|
const { assignment, sendTo } = data;
|
|
878
858
|
const teacherName = profile.displayName || "Your teacher";
|
|
879
859
|
const dueDate = assignment.dueDateTimestamp ? dayjs2(assignment.dueDateTimestamp.toDate()).format("MMM Do") : null;
|
|
@@ -884,7 +864,7 @@ var createNewAssignmentNotification = async ({
|
|
|
884
864
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
885
865
|
messagePreview: `A new assignment "${assignment.name}" is now available. ${dueDate ? `Due ${dueDate}` : ""}`,
|
|
886
866
|
title: "New Assignment Available!",
|
|
887
|
-
imageUrl: (
|
|
867
|
+
imageUrl: (_a = profile.image) == null ? void 0 : _a.url
|
|
888
868
|
});
|
|
889
869
|
return results;
|
|
890
870
|
};
|
|
@@ -893,7 +873,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
893
873
|
profile,
|
|
894
874
|
userId
|
|
895
875
|
}) => {
|
|
896
|
-
var
|
|
876
|
+
var _a;
|
|
897
877
|
const studentName = profile.displayName || "Your student";
|
|
898
878
|
const results = await sendNotification(assignment.owners, {
|
|
899
879
|
courseId: assignment.courseId,
|
|
@@ -902,7 +882,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
902
882
|
title: `Assessment Submitted!`,
|
|
903
883
|
senderName: studentName,
|
|
904
884
|
messagePreview: `${studentName} has submitted the assessment "${assignment.name}"`,
|
|
905
|
-
imageUrl: (
|
|
885
|
+
imageUrl: (_a = profile.image) == null ? void 0 : _a.url
|
|
906
886
|
});
|
|
907
887
|
return results;
|
|
908
888
|
};
|
|
@@ -910,7 +890,7 @@ var createAssessmentScoredNotification = async ({
|
|
|
910
890
|
data,
|
|
911
891
|
profile
|
|
912
892
|
}) => {
|
|
913
|
-
var
|
|
893
|
+
var _a, _b, _c, _d, _e;
|
|
914
894
|
const { assignment, sendTo } = data;
|
|
915
895
|
const teacherName = profile.displayName || "Your teacher";
|
|
916
896
|
const title = `${assignment.isAssessment ? "Assessment" : "Assignment"} Reviewed!`;
|
|
@@ -921,13 +901,13 @@ var createAssessmentScoredNotification = async ({
|
|
|
921
901
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
922
902
|
title,
|
|
923
903
|
messagePreview,
|
|
924
|
-
imageUrl: (
|
|
904
|
+
imageUrl: (_a = profile.image) == null ? void 0 : _a.url,
|
|
925
905
|
senderName: teacherName
|
|
926
906
|
});
|
|
927
|
-
await ((
|
|
907
|
+
await ((_e = (_c = (_b = api).httpsCallable) == null ? void 0 : _c.call(_b, "sendAssessmentScoredEmail")) == null ? void 0 : _e({
|
|
928
908
|
assessmentTitle: assignment.name,
|
|
929
909
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
930
|
-
senderImage: ((
|
|
910
|
+
senderImage: ((_d = profile.image) == null ? void 0 : _d.url) || "",
|
|
931
911
|
studentId: sendTo[0],
|
|
932
912
|
teacherName: profile.displayName
|
|
933
913
|
}));
|
|
@@ -942,15 +922,15 @@ var notificationQueryKeys = {
|
|
|
942
922
|
var useCreateNotification = () => {
|
|
943
923
|
const { user, queryClient } = useSpeakableApi();
|
|
944
924
|
const handleCreateNotifications = async (type, data) => {
|
|
945
|
-
var
|
|
925
|
+
var _a, _b;
|
|
946
926
|
const result = await createNotification({
|
|
947
927
|
type,
|
|
948
928
|
userId: user.auth.uid,
|
|
949
|
-
profile: (
|
|
929
|
+
profile: (_a = user == null ? void 0 : user.profile) != null ? _a : {},
|
|
950
930
|
data
|
|
951
931
|
});
|
|
952
932
|
queryClient.invalidateQueries({
|
|
953
|
-
queryKey: notificationQueryKeys.byId((
|
|
933
|
+
queryKey: notificationQueryKeys.byId((_b = user == null ? void 0 : user.auth.uid) != null ? _b : "")
|
|
954
934
|
});
|
|
955
935
|
return result;
|
|
956
936
|
};
|
|
@@ -1409,8 +1389,8 @@ var SpeakablePlanHierarchy = [
|
|
|
1409
1389
|
var usePermissions = () => {
|
|
1410
1390
|
const { permissions } = useSpeakableApi();
|
|
1411
1391
|
const has = (permission) => {
|
|
1412
|
-
var
|
|
1413
|
-
return (
|
|
1392
|
+
var _a;
|
|
1393
|
+
return (_a = permissions.permissions) == null ? void 0 : _a.includes(permission);
|
|
1414
1394
|
};
|
|
1415
1395
|
return {
|
|
1416
1396
|
plan: permissions.plan,
|
|
@@ -1441,7 +1421,7 @@ var useGoogleClassroom = () => {
|
|
|
1441
1421
|
googleUserId = null
|
|
1442
1422
|
// optional to override the user's googleUserId
|
|
1443
1423
|
}) => {
|
|
1444
|
-
var
|
|
1424
|
+
var _a, _b, _c;
|
|
1445
1425
|
try {
|
|
1446
1426
|
const { googleClassroomUserId = null } = scores;
|
|
1447
1427
|
const googleId = googleUserId || googleClassroomUserId;
|
|
@@ -1452,7 +1432,7 @@ var useGoogleClassroom = () => {
|
|
|
1452
1432
|
};
|
|
1453
1433
|
const { courseWorkId, maxPoints, owners, courseId } = assignment;
|
|
1454
1434
|
const draftGrade = (scores == null ? void 0 : scores.score) ? (scores == null ? void 0 : scores.score) / 100 * maxPoints : 0;
|
|
1455
|
-
const result = await ((
|
|
1435
|
+
const result = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitAssignmentToGoogleClassroomV2")) == null ? void 0 : _c({
|
|
1456
1436
|
teacherId: owners[0],
|
|
1457
1437
|
courseId,
|
|
1458
1438
|
courseWorkId,
|
|
@@ -1471,9 +1451,9 @@ var useGoogleClassroom = () => {
|
|
|
1471
1451
|
|
|
1472
1452
|
// src/lib/firebase/firebase-analytics/grading-standard.ts
|
|
1473
1453
|
var logGradingStandardLog = (data) => {
|
|
1474
|
-
var
|
|
1454
|
+
var _a, _b, _c;
|
|
1475
1455
|
if (data.courseId && data.type && data.level) {
|
|
1476
|
-
(
|
|
1456
|
+
(_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "handleCouresAnalyticsEvent")) == null ? void 0 : _c({
|
|
1477
1457
|
eventType: data.type || "custom",
|
|
1478
1458
|
level: data.level,
|
|
1479
1459
|
courseId: data.courseId
|
|
@@ -1509,17 +1489,17 @@ var logOpenActivityPreview = (data = {}) => {
|
|
|
1509
1489
|
api.logEvent("open_activity_preview", data);
|
|
1510
1490
|
};
|
|
1511
1491
|
var logSubmitAssignment = (data = {}) => {
|
|
1512
|
-
var
|
|
1513
|
-
(
|
|
1492
|
+
var _a, _b, _c;
|
|
1493
|
+
(_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "handleCouresAnalyticsEvent")) == null ? void 0 : _c({
|
|
1514
1494
|
eventType: ANALYTICS_EVENT_TYPES.SUBMISSION,
|
|
1515
1495
|
...data
|
|
1516
1496
|
});
|
|
1517
1497
|
api.logEvent(ANALYTICS_EVENT_TYPES.SUBMISSION, data);
|
|
1518
1498
|
};
|
|
1519
1499
|
var logStartAssignment = (data = {}) => {
|
|
1520
|
-
var
|
|
1500
|
+
var _a, _b, _c;
|
|
1521
1501
|
if (data.courseId) {
|
|
1522
|
-
(
|
|
1502
|
+
(_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "handleCouresAnalyticsEvent")) == null ? void 0 : _c({
|
|
1523
1503
|
eventType: ANALYTICS_EVENT_TYPES.ASSIGNMENT_STARTED,
|
|
1524
1504
|
...data
|
|
1525
1505
|
});
|
|
@@ -1560,13 +1540,13 @@ var refsScoresPractice = {
|
|
|
1560
1540
|
|
|
1561
1541
|
// src/domains/assignment/services/create-score.service.ts
|
|
1562
1542
|
async function _createScore(params) {
|
|
1563
|
-
var
|
|
1543
|
+
var _a, _b, _c;
|
|
1564
1544
|
if (params.isAssignment) {
|
|
1565
1545
|
const ref = refsAssignmentFiresotre.assignmentScores({
|
|
1566
1546
|
id: params.activityId,
|
|
1567
1547
|
userId: params.userId
|
|
1568
1548
|
});
|
|
1569
|
-
await ((
|
|
1549
|
+
await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "updateAssignmentGradebookStatus")) == null ? void 0 : _c({
|
|
1570
1550
|
assignmentId: params.activityId,
|
|
1571
1551
|
userId: params.userId,
|
|
1572
1552
|
status: "IN_PROGRESS",
|
|
@@ -1676,10 +1656,10 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1676
1656
|
return acc;
|
|
1677
1657
|
}, 0);
|
|
1678
1658
|
const totalPointsAwarded = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
|
|
1679
|
-
var
|
|
1680
|
-
const cardScores = (
|
|
1659
|
+
var _a, _b;
|
|
1660
|
+
const cardScores = (_a = scores == null ? void 0 : scores.cards) == null ? void 0 : _a[cardId];
|
|
1681
1661
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1682
|
-
const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((
|
|
1662
|
+
const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((_b = cardScores == null ? void 0 : cardScores.score) != null ? _b : 0) : null;
|
|
1683
1663
|
const weight = (weights == null ? void 0 : weights[cardId]) || 1;
|
|
1684
1664
|
const fraction = (score2 != null ? score2 : 0) / 100;
|
|
1685
1665
|
if (score2 || score2 === 0) {
|
|
@@ -1691,8 +1671,8 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1691
1671
|
return acc;
|
|
1692
1672
|
}, 0);
|
|
1693
1673
|
const totalCompletedCards = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
|
|
1694
|
-
var
|
|
1695
|
-
const cardScores = (
|
|
1674
|
+
var _a;
|
|
1675
|
+
const cardScores = (_a = scores == null ? void 0 : scores.cards) == null ? void 0 : _a[cardId];
|
|
1696
1676
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1697
1677
|
acc += 1;
|
|
1698
1678
|
}
|
|
@@ -1749,22 +1729,22 @@ var updateCardScore = withErrorHandler(_updateCardScore, "updateCardScore");
|
|
|
1749
1729
|
// src/domains/assignment/services/clear-score.service.ts
|
|
1750
1730
|
import dayjs3 from "dayjs";
|
|
1751
1731
|
async function clearScore(params) {
|
|
1752
|
-
var
|
|
1732
|
+
var _a, _b, _c, _d, _e;
|
|
1753
1733
|
const update = {
|
|
1754
1734
|
[`cards.${params.cardId}`]: {
|
|
1755
|
-
attempts: (
|
|
1756
|
-
correct: (
|
|
1735
|
+
attempts: (_a = params.cardScores.attempts) != null ? _a : 1,
|
|
1736
|
+
correct: (_b = params.cardScores.correct) != null ? _b : 0,
|
|
1757
1737
|
// save old score history
|
|
1758
1738
|
history: [
|
|
1759
1739
|
{
|
|
1760
1740
|
...params.cardScores,
|
|
1761
|
-
attempts: (
|
|
1762
|
-
correct: (
|
|
1741
|
+
attempts: (_c = params.cardScores.attempts) != null ? _c : 1,
|
|
1742
|
+
correct: (_d = params.cardScores.correct) != null ? _d : 0,
|
|
1763
1743
|
retryTime: dayjs3().format("YYYY-MM-DD HH:mm:ss"),
|
|
1764
1744
|
history: null
|
|
1765
1745
|
},
|
|
1766
1746
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1767
|
-
...(
|
|
1747
|
+
...(_e = params.cardScores.history) != null ? _e : []
|
|
1768
1748
|
]
|
|
1769
1749
|
}
|
|
1770
1750
|
};
|
|
@@ -1821,7 +1801,7 @@ var submitAssignmentScore = withErrorHandler(
|
|
|
1821
1801
|
"submitAssignmentScore"
|
|
1822
1802
|
);
|
|
1823
1803
|
async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpdated, studentName) {
|
|
1824
|
-
var
|
|
1804
|
+
var _a, _b, _c;
|
|
1825
1805
|
const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
|
|
1826
1806
|
const response = await api.getDoc(path);
|
|
1827
1807
|
if (!response.data) {
|
|
@@ -1829,7 +1809,7 @@ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpda
|
|
|
1829
1809
|
}
|
|
1830
1810
|
const { score: scoreCalculated } = calculateScoreAndProgress_default(response.data, cardIds, weights);
|
|
1831
1811
|
await api.updateDoc(path, { score: scoreCalculated, status: "PENDING_REVIEW" });
|
|
1832
|
-
await ((
|
|
1812
|
+
await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitAssessment")) == null ? void 0 : _c({
|
|
1833
1813
|
assignmentId: assignment.id,
|
|
1834
1814
|
assignmentTitle: assignment.name,
|
|
1835
1815
|
userId,
|
|
@@ -1840,8 +1820,8 @@ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpda
|
|
|
1840
1820
|
return { success: true, fieldsUpdated };
|
|
1841
1821
|
}
|
|
1842
1822
|
async function handleCourseAssignment(assignment, userId) {
|
|
1843
|
-
var
|
|
1844
|
-
await ((
|
|
1823
|
+
var _a, _b, _c;
|
|
1824
|
+
await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitLTIAssignmentScoreV2")) == null ? void 0 : _c({
|
|
1845
1825
|
assignmentId: assignment.id,
|
|
1846
1826
|
userId
|
|
1847
1827
|
}));
|
|
@@ -1986,8 +1966,8 @@ var getScoreUpdated = ({
|
|
|
1986
1966
|
cardIds,
|
|
1987
1967
|
weights
|
|
1988
1968
|
}) => {
|
|
1989
|
-
var
|
|
1990
|
-
const previousCard = (
|
|
1969
|
+
var _a, _b;
|
|
1970
|
+
const previousCard = (_a = previousScores.cards) == null ? void 0 : _a[cardId];
|
|
1991
1971
|
const newCardScore = {
|
|
1992
1972
|
...previousCard != null ? previousCard : {},
|
|
1993
1973
|
...cardScore
|
|
@@ -1995,7 +1975,7 @@ var getScoreUpdated = ({
|
|
|
1995
1975
|
const newScores = {
|
|
1996
1976
|
...previousScores,
|
|
1997
1977
|
cards: {
|
|
1998
|
-
...(
|
|
1978
|
+
...(_b = previousScores.cards) != null ? _b : {},
|
|
1999
1979
|
[cardId]: newCardScore
|
|
2000
1980
|
}
|
|
2001
1981
|
};
|
|
@@ -2014,8 +1994,8 @@ var handleOptimisticScore = ({
|
|
|
2014
1994
|
cardIds,
|
|
2015
1995
|
weights
|
|
2016
1996
|
}) => {
|
|
2017
|
-
var
|
|
2018
|
-
let cards = { ...(
|
|
1997
|
+
var _a;
|
|
1998
|
+
let cards = { ...(_a = score == null ? void 0 : score.cards) != null ? _a : {} };
|
|
2019
1999
|
cards = {
|
|
2020
2000
|
...cards,
|
|
2021
2001
|
[cardId]: {
|
|
@@ -2039,9 +2019,9 @@ function useClearScore() {
|
|
|
2039
2019
|
const mutation = useMutation2({
|
|
2040
2020
|
mutationFn: clearScore,
|
|
2041
2021
|
onSettled: (result) => {
|
|
2042
|
-
var
|
|
2022
|
+
var _a;
|
|
2043
2023
|
queryClient.invalidateQueries({
|
|
2044
|
-
queryKey: scoreQueryKeys.byId((
|
|
2024
|
+
queryKey: scoreQueryKeys.byId((_a = result == null ? void 0 : result.activityId) != null ? _a : "")
|
|
2045
2025
|
});
|
|
2046
2026
|
}
|
|
2047
2027
|
});
|
|
@@ -2190,7 +2170,7 @@ function useActivity({
|
|
|
2190
2170
|
onAssignmentSubmitted,
|
|
2191
2171
|
ltiData
|
|
2192
2172
|
}) {
|
|
2193
|
-
var
|
|
2173
|
+
var _a, _b;
|
|
2194
2174
|
const { queryClient, user } = useSpeakableApi();
|
|
2195
2175
|
const userId = user.auth.uid;
|
|
2196
2176
|
const assignmentQuery = useAssignment({
|
|
@@ -2199,7 +2179,7 @@ function useActivity({
|
|
|
2199
2179
|
enabled: isAssignment
|
|
2200
2180
|
});
|
|
2201
2181
|
const activeAssignment = assignmentQuery.data;
|
|
2202
|
-
const setId = isAssignment ? (
|
|
2182
|
+
const setId = isAssignment ? (_a = activeAssignment == null ? void 0 : activeAssignment.setId) != null ? _a : "" : id;
|
|
2203
2183
|
const querySet = useSet({ setId });
|
|
2204
2184
|
const setData = querySet.data;
|
|
2205
2185
|
const assignmentContent = activeAssignment == null ? void 0 : activeAssignment.content;
|
|
@@ -2208,7 +2188,7 @@ function useActivity({
|
|
|
2208
2188
|
const setWeights = setData == null ? void 0 : setData.weights;
|
|
2209
2189
|
const contentCardsToUse = isAssignment ? assignmentContent != null ? assignmentContent : setContent : setContent;
|
|
2210
2190
|
const weightsToUse = isAssignment ? assignmentWeights != null ? assignmentWeights : setWeights : setWeights;
|
|
2211
|
-
const activityId = isAssignment ? (
|
|
2191
|
+
const activityId = isAssignment ? (_b = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b : "" : setId;
|
|
2212
2192
|
const { cardsObject, cardsQueries, cards } = useCards({
|
|
2213
2193
|
cardIds: contentCardsToUse != null ? contentCardsToUse : [],
|
|
2214
2194
|
enabled: querySet.isSuccess,
|
|
@@ -2246,18 +2226,31 @@ function useActivity({
|
|
|
2246
2226
|
};
|
|
2247
2227
|
const handleUpdateCardScore = (cardId, cardScore) => {
|
|
2248
2228
|
mutationUpdateCardScore.mutate({ cardId, cardScore });
|
|
2229
|
+
if (cardScore.proficiency_level) {
|
|
2230
|
+
logGradingStandardEntry({
|
|
2231
|
+
type: cardScore.proficiency_level.standardId,
|
|
2232
|
+
cardId,
|
|
2233
|
+
gradingStandard: cardScore.proficiency_level
|
|
2234
|
+
});
|
|
2235
|
+
} else if (cardScore.wida || cardScore.actfl) {
|
|
2236
|
+
logGradingStandardEntry({
|
|
2237
|
+
type: cardScore.wida ? "wida" : "actfl",
|
|
2238
|
+
cardId,
|
|
2239
|
+
gradingStandard: cardScore.wida || cardScore.actfl || { level: "", justification: "" }
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2249
2242
|
};
|
|
2250
2243
|
const onClearScore = ({
|
|
2251
2244
|
cardId,
|
|
2252
2245
|
wasCompleted = true
|
|
2253
2246
|
}) => {
|
|
2254
|
-
var
|
|
2247
|
+
var _a2, _b2;
|
|
2255
2248
|
const currentCard = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2256
2249
|
if ((currentCard == null ? void 0 : currentCard.type) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || (currentCard == null ? void 0 : currentCard.type) === "READ_REPEAT" /* READ_REPEAT */) {
|
|
2257
2250
|
return;
|
|
2258
2251
|
}
|
|
2259
2252
|
const queryKeys = scoreQueryKeys.byId(activityId);
|
|
2260
|
-
const activeCardScores = (
|
|
2253
|
+
const activeCardScores = (_b2 = (_a2 = queryClient.getQueryData(queryKeys)) == null ? void 0 : _a2.cards) == null ? void 0 : _b2[cardId];
|
|
2261
2254
|
if (activeCardScores === void 0) return;
|
|
2262
2255
|
mutationClearScore.mutate({
|
|
2263
2256
|
isAssignment,
|
|
@@ -2268,11 +2261,11 @@ function useActivity({
|
|
|
2268
2261
|
});
|
|
2269
2262
|
};
|
|
2270
2263
|
const onSubmitScore = async () => {
|
|
2271
|
-
var
|
|
2264
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2272
2265
|
try {
|
|
2273
2266
|
let results;
|
|
2274
2267
|
if (isAssignment) {
|
|
2275
|
-
const cardScores = ((
|
|
2268
|
+
const cardScores = ((_a2 = scoreQuery.data) == null ? void 0 : _a2.cards) || {};
|
|
2276
2269
|
const hasPendingReview = Object.values(cardScores).some(
|
|
2277
2270
|
(cardScore) => cardScore.status === "pending_review"
|
|
2278
2271
|
);
|
|
@@ -2284,18 +2277,18 @@ function useActivity({
|
|
|
2284
2277
|
weights: weightsToUse != null ? weightsToUse : {},
|
|
2285
2278
|
status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
|
|
2286
2279
|
});
|
|
2287
|
-
if ((
|
|
2280
|
+
if ((_b2 = assignmentQuery.data) == null ? void 0 : _b2.ltiDeeplink) {
|
|
2288
2281
|
submitLTIScore({
|
|
2289
|
-
maxPoints: (
|
|
2290
|
-
score: (
|
|
2291
|
-
SERVICE_KEY: (
|
|
2292
|
-
lineItemId: (
|
|
2293
|
-
lti_id: (
|
|
2282
|
+
maxPoints: (_c = assignmentQuery.data) == null ? void 0 : _c.maxPoints,
|
|
2283
|
+
score: (_e = (_d = scoreQuery.data) == null ? void 0 : _d.score) != null ? _e : 0,
|
|
2284
|
+
SERVICE_KEY: (_f = ltiData == null ? void 0 : ltiData.serviceKey) != null ? _f : "",
|
|
2285
|
+
lineItemId: (_g = ltiData == null ? void 0 : ltiData.lineItemId) != null ? _g : "",
|
|
2286
|
+
lti_id: (_h = ltiData == null ? void 0 : ltiData.lti_id) != null ? _h : ""
|
|
2294
2287
|
});
|
|
2295
2288
|
}
|
|
2296
2289
|
} else {
|
|
2297
2290
|
results = await submitPracticeScore2({
|
|
2298
|
-
setId: (
|
|
2291
|
+
setId: (_j = (_i = querySet.data) == null ? void 0 : _i.id) != null ? _j : "",
|
|
2299
2292
|
userId,
|
|
2300
2293
|
scores: scoreQuery.data
|
|
2301
2294
|
});
|
|
@@ -2313,23 +2306,23 @@ function useActivity({
|
|
|
2313
2306
|
gradingStandard,
|
|
2314
2307
|
type
|
|
2315
2308
|
}) => {
|
|
2316
|
-
var
|
|
2309
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
2317
2310
|
const card = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2318
2311
|
const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
|
|
2319
|
-
const cardScore = (
|
|
2312
|
+
const cardScore = (_a2 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a2[cardId];
|
|
2320
2313
|
const serverTimestamp2 = api.helpers.serverTimestamp;
|
|
2321
2314
|
addGradingStandardLog(
|
|
2322
2315
|
{
|
|
2323
|
-
assignmentId: (
|
|
2324
|
-
courseId: (
|
|
2325
|
-
teacherId: (
|
|
2326
|
-
setId: (
|
|
2316
|
+
assignmentId: (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "",
|
|
2317
|
+
courseId: (_c = activeAssignment == null ? void 0 : activeAssignment.courseId) != null ? _c : "",
|
|
2318
|
+
teacherId: (_d = activeAssignment == null ? void 0 : activeAssignment.owners[0]) != null ? _d : "",
|
|
2319
|
+
setId: (_e = setData == null ? void 0 : setData.id) != null ? _e : "",
|
|
2327
2320
|
cardId,
|
|
2328
2321
|
level: gradingStandard.level,
|
|
2329
2322
|
justification: gradingStandard.justification,
|
|
2330
|
-
transcript: (
|
|
2331
|
-
audioUrl: (
|
|
2332
|
-
prompt: (
|
|
2323
|
+
transcript: (_f = cardScore == null ? void 0 : cardScore.transcript) != null ? _f : "",
|
|
2324
|
+
audioUrl: (_g = cardScore == null ? void 0 : cardScore.audio) != null ? _g : "",
|
|
2325
|
+
prompt: (_h = card == null ? void 0 : card.prompt) != null ? _h : "",
|
|
2333
2326
|
responseType: (card == null ? void 0 : card.type) === "RESPOND_WRITE" /* RESPOND_WRITE */ ? "written" : "spoken",
|
|
2334
2327
|
type,
|
|
2335
2328
|
dateMade: serverTimestamp2()
|
|
@@ -2385,11 +2378,11 @@ var useInitActivity = ({
|
|
|
2385
2378
|
}) => {
|
|
2386
2379
|
const { trackActivity } = useActivityTracker({ userId });
|
|
2387
2380
|
const init = () => {
|
|
2388
|
-
var
|
|
2381
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2389
2382
|
if (!enabled) return;
|
|
2390
2383
|
if (!assignment) {
|
|
2391
2384
|
trackActivity({
|
|
2392
|
-
activityName: (
|
|
2385
|
+
activityName: (_a = set == null ? void 0 : set.name) != null ? _a : "",
|
|
2393
2386
|
activityType: "set",
|
|
2394
2387
|
id: set == null ? void 0 : set.id,
|
|
2395
2388
|
language: set == null ? void 0 : set.language
|
|
@@ -2403,12 +2396,12 @@ var useInitActivity = ({
|
|
|
2403
2396
|
});
|
|
2404
2397
|
}
|
|
2405
2398
|
if (set == null ? void 0 : set.public) {
|
|
2406
|
-
(
|
|
2399
|
+
(_d = (_c = (_b = api).httpsCallable) == null ? void 0 : _c.call(_b, "onSetOpened")) == null ? void 0 : _d({
|
|
2407
2400
|
setId: set.id,
|
|
2408
2401
|
language: set.language
|
|
2409
2402
|
});
|
|
2410
2403
|
}
|
|
2411
|
-
(
|
|
2404
|
+
(_g = (_f = (_e = api).httpsCallable) == null ? void 0 : _f.call(_e, "updateAlgoliaIndex")) == null ? void 0 : _g({
|
|
2412
2405
|
updatePlays: true,
|
|
2413
2406
|
objectID: set == null ? void 0 : set.id
|
|
2414
2407
|
});
|
|
@@ -2424,13 +2417,13 @@ var submitLTIScore = async ({
|
|
|
2424
2417
|
lineItemId,
|
|
2425
2418
|
lti_id
|
|
2426
2419
|
}) => {
|
|
2427
|
-
var
|
|
2420
|
+
var _a, _b, _c;
|
|
2428
2421
|
try {
|
|
2429
2422
|
if (!SERVICE_KEY || !lineItemId || !lti_id) {
|
|
2430
2423
|
throw new Error("Missing required LTI credentials");
|
|
2431
2424
|
}
|
|
2432
2425
|
const earnedPoints = score ? score / 100 * maxPoints : 0;
|
|
2433
|
-
const { data } = await ((
|
|
2426
|
+
const { data } = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitLTIAssignmentScore")) == null ? void 0 : _c({
|
|
2434
2427
|
SERVICE_KEY,
|
|
2435
2428
|
scoreData: {
|
|
2436
2429
|
lineItemId,
|
|
@@ -2608,19 +2601,19 @@ var useActivityFeedbackAccess = ({
|
|
|
2608
2601
|
aiEnabled = false,
|
|
2609
2602
|
isActivityRoute = false
|
|
2610
2603
|
}) => {
|
|
2611
|
-
var
|
|
2604
|
+
var _a, _b, _c;
|
|
2612
2605
|
const { user } = useSpeakableApi();
|
|
2613
2606
|
const uid = user.auth.uid;
|
|
2614
|
-
const isTeacher = (
|
|
2615
|
-
const isStudent = (
|
|
2616
|
-
const userRoles = ((
|
|
2607
|
+
const isTeacher = (_a = user.profile) == null ? void 0 : _a.isTeacher;
|
|
2608
|
+
const isStudent = (_b = user.profile) == null ? void 0 : _b.isStudent;
|
|
2609
|
+
const userRoles = ((_c = user.profile) == null ? void 0 : _c.roles) || [];
|
|
2617
2610
|
const query2 = useQuery6({
|
|
2618
2611
|
queryKey: activityFeedbackAccessQueryKeys.activityFeedbackAccess({
|
|
2619
2612
|
aiEnabled,
|
|
2620
2613
|
isActivityRoute
|
|
2621
2614
|
}),
|
|
2622
2615
|
queryFn: async () => {
|
|
2623
|
-
var
|
|
2616
|
+
var _a2, _b2, _c2;
|
|
2624
2617
|
if (!uid) {
|
|
2625
2618
|
return {
|
|
2626
2619
|
canAccessFeedback: false,
|
|
@@ -2648,7 +2641,7 @@ var useActivityFeedbackAccess = ({
|
|
|
2648
2641
|
}
|
|
2649
2642
|
if (isStudent && isActivityRoute) {
|
|
2650
2643
|
try {
|
|
2651
|
-
const result = await ((
|
|
2644
|
+
const result = await ((_c2 = (_b2 = (_a2 = api).httpsCallable) == null ? void 0 : _b2.call(_a2, "checkStudentTeacherPlan")) == null ? void 0 : _c2({
|
|
2652
2645
|
studentId: uid
|
|
2653
2646
|
}));
|
|
2654
2647
|
const planCheckResult = result.data;
|
|
@@ -2720,9 +2713,9 @@ var useBaseOpenAI = ({
|
|
|
2720
2713
|
aiEnabled
|
|
2721
2714
|
});
|
|
2722
2715
|
const getTranscript = async (audioUrl, language) => {
|
|
2723
|
-
var
|
|
2716
|
+
var _a, _b;
|
|
2724
2717
|
try {
|
|
2725
|
-
const getAssemblyAITranscript = (
|
|
2718
|
+
const getAssemblyAITranscript = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "transcribeAssemblyAIAudio");
|
|
2726
2719
|
const response = await (getAssemblyAITranscript == null ? void 0 : getAssemblyAITranscript({
|
|
2727
2720
|
audioUrl,
|
|
2728
2721
|
language
|
|
@@ -2746,13 +2739,13 @@ var useBaseOpenAI = ({
|
|
|
2746
2739
|
}
|
|
2747
2740
|
};
|
|
2748
2741
|
const getFreeResponseCompletion = async (messages, isFreeResponse, feedbackLanguage, gradingStandard = "actfl") => {
|
|
2749
|
-
var
|
|
2742
|
+
var _a, _b, _c, _d, _e;
|
|
2750
2743
|
const responseTool = getRespondCardTool({
|
|
2751
2744
|
language: feedbackLanguage,
|
|
2752
2745
|
standard: gradingStandard
|
|
2753
2746
|
});
|
|
2754
2747
|
try {
|
|
2755
|
-
const createChatCompletion = (
|
|
2748
|
+
const createChatCompletion = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "createChatCompletion");
|
|
2756
2749
|
const {
|
|
2757
2750
|
data: {
|
|
2758
2751
|
response,
|
|
@@ -2770,7 +2763,7 @@ var useBaseOpenAI = ({
|
|
|
2770
2763
|
},
|
|
2771
2764
|
type: isFreeResponse ? "LONG_RESPONSE" : "SHORT_RESPONSE"
|
|
2772
2765
|
}));
|
|
2773
|
-
const functionArguments = JSON.parse(((
|
|
2766
|
+
const functionArguments = JSON.parse(((_e = (_d = (_c = response == null ? void 0 : response.tool_calls) == null ? void 0 : _c[0]) == null ? void 0 : _d.function) == null ? void 0 : _e.arguments) || "{}");
|
|
2774
2767
|
const result = {
|
|
2775
2768
|
...functionArguments,
|
|
2776
2769
|
prompt_tokens,
|
|
@@ -2855,10 +2848,10 @@ var useBaseOpenAI = ({
|
|
|
2855
2848
|
}
|
|
2856
2849
|
};
|
|
2857
2850
|
const getAIResponse = async ({ cardId, transcript }) => {
|
|
2858
|
-
var
|
|
2851
|
+
var _a, _b, _c, _d, _e;
|
|
2859
2852
|
try {
|
|
2860
|
-
const getGeminiFeedback = (
|
|
2861
|
-
const getProficiencyEstimate = (
|
|
2853
|
+
const getGeminiFeedback = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "callGetFeedback");
|
|
2854
|
+
const getProficiencyEstimate = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "getProficiencyEstimate");
|
|
2862
2855
|
const card = getCardFromCache({
|
|
2863
2856
|
cardId,
|
|
2864
2857
|
queryClient
|
|
@@ -2881,7 +2874,7 @@ var useBaseOpenAI = ({
|
|
|
2881
2874
|
]);
|
|
2882
2875
|
proficiencyData = (proficiencyResult == null ? void 0 : proficiencyResult.data) || {};
|
|
2883
2876
|
feedbackData = {
|
|
2884
|
-
...(
|
|
2877
|
+
...(_e = geminiResult == null ? void 0 : geminiResult.data) != null ? _e : {},
|
|
2885
2878
|
// @ts-ignore
|
|
2886
2879
|
proficiency_level: (proficiencyData == null ? void 0 : proficiencyData.proficiency_level) || null
|
|
2887
2880
|
};
|