@speakableio/core 0.1.50 → 0.1.51
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 +99 -119
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +99 -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,
|
|
@@ -2251,13 +2231,13 @@ function useActivity({
|
|
|
2251
2231
|
cardId,
|
|
2252
2232
|
wasCompleted = true
|
|
2253
2233
|
}) => {
|
|
2254
|
-
var
|
|
2234
|
+
var _a2, _b2;
|
|
2255
2235
|
const currentCard = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2256
2236
|
if ((currentCard == null ? void 0 : currentCard.type) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || (currentCard == null ? void 0 : currentCard.type) === "READ_REPEAT" /* READ_REPEAT */) {
|
|
2257
2237
|
return;
|
|
2258
2238
|
}
|
|
2259
2239
|
const queryKeys = scoreQueryKeys.byId(activityId);
|
|
2260
|
-
const activeCardScores = (
|
|
2240
|
+
const activeCardScores = (_b2 = (_a2 = queryClient.getQueryData(queryKeys)) == null ? void 0 : _a2.cards) == null ? void 0 : _b2[cardId];
|
|
2261
2241
|
if (activeCardScores === void 0) return;
|
|
2262
2242
|
mutationClearScore.mutate({
|
|
2263
2243
|
isAssignment,
|
|
@@ -2268,11 +2248,11 @@ function useActivity({
|
|
|
2268
2248
|
});
|
|
2269
2249
|
};
|
|
2270
2250
|
const onSubmitScore = async () => {
|
|
2271
|
-
var
|
|
2251
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2272
2252
|
try {
|
|
2273
2253
|
let results;
|
|
2274
2254
|
if (isAssignment) {
|
|
2275
|
-
const cardScores = ((
|
|
2255
|
+
const cardScores = ((_a2 = scoreQuery.data) == null ? void 0 : _a2.cards) || {};
|
|
2276
2256
|
const hasPendingReview = Object.values(cardScores).some(
|
|
2277
2257
|
(cardScore) => cardScore.status === "pending_review"
|
|
2278
2258
|
);
|
|
@@ -2284,18 +2264,18 @@ function useActivity({
|
|
|
2284
2264
|
weights: weightsToUse != null ? weightsToUse : {},
|
|
2285
2265
|
status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
|
|
2286
2266
|
});
|
|
2287
|
-
if ((
|
|
2267
|
+
if ((_b2 = assignmentQuery.data) == null ? void 0 : _b2.ltiDeeplink) {
|
|
2288
2268
|
submitLTIScore({
|
|
2289
|
-
maxPoints: (
|
|
2290
|
-
score: (
|
|
2291
|
-
SERVICE_KEY: (
|
|
2292
|
-
lineItemId: (
|
|
2293
|
-
lti_id: (
|
|
2269
|
+
maxPoints: (_c = assignmentQuery.data) == null ? void 0 : _c.maxPoints,
|
|
2270
|
+
score: (_e = (_d = scoreQuery.data) == null ? void 0 : _d.score) != null ? _e : 0,
|
|
2271
|
+
SERVICE_KEY: (_f = ltiData == null ? void 0 : ltiData.serviceKey) != null ? _f : "",
|
|
2272
|
+
lineItemId: (_g = ltiData == null ? void 0 : ltiData.lineItemId) != null ? _g : "",
|
|
2273
|
+
lti_id: (_h = ltiData == null ? void 0 : ltiData.lti_id) != null ? _h : ""
|
|
2294
2274
|
});
|
|
2295
2275
|
}
|
|
2296
2276
|
} else {
|
|
2297
2277
|
results = await submitPracticeScore2({
|
|
2298
|
-
setId: (
|
|
2278
|
+
setId: (_j = (_i = querySet.data) == null ? void 0 : _i.id) != null ? _j : "",
|
|
2299
2279
|
userId,
|
|
2300
2280
|
scores: scoreQuery.data
|
|
2301
2281
|
});
|
|
@@ -2313,23 +2293,23 @@ function useActivity({
|
|
|
2313
2293
|
gradingStandard,
|
|
2314
2294
|
type
|
|
2315
2295
|
}) => {
|
|
2316
|
-
var
|
|
2296
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
2317
2297
|
const card = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2318
2298
|
const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
|
|
2319
|
-
const cardScore = (
|
|
2299
|
+
const cardScore = (_a2 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a2[cardId];
|
|
2320
2300
|
const serverTimestamp2 = api.helpers.serverTimestamp;
|
|
2321
2301
|
addGradingStandardLog(
|
|
2322
2302
|
{
|
|
2323
|
-
assignmentId: (
|
|
2324
|
-
courseId: (
|
|
2325
|
-
teacherId: (
|
|
2326
|
-
setId: (
|
|
2303
|
+
assignmentId: (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "",
|
|
2304
|
+
courseId: (_c = activeAssignment == null ? void 0 : activeAssignment.courseId) != null ? _c : "",
|
|
2305
|
+
teacherId: (_d = activeAssignment == null ? void 0 : activeAssignment.owners[0]) != null ? _d : "",
|
|
2306
|
+
setId: (_e = setData == null ? void 0 : setData.id) != null ? _e : "",
|
|
2327
2307
|
cardId,
|
|
2328
2308
|
level: gradingStandard.level,
|
|
2329
2309
|
justification: gradingStandard.justification,
|
|
2330
|
-
transcript: (
|
|
2331
|
-
audioUrl: (
|
|
2332
|
-
prompt: (
|
|
2310
|
+
transcript: (_f = cardScore == null ? void 0 : cardScore.transcript) != null ? _f : "",
|
|
2311
|
+
audioUrl: (_g = cardScore == null ? void 0 : cardScore.audio) != null ? _g : "",
|
|
2312
|
+
prompt: (_h = card == null ? void 0 : card.prompt) != null ? _h : "",
|
|
2333
2313
|
responseType: (card == null ? void 0 : card.type) === "RESPOND_WRITE" /* RESPOND_WRITE */ ? "written" : "spoken",
|
|
2334
2314
|
type,
|
|
2335
2315
|
dateMade: serverTimestamp2()
|
|
@@ -2385,11 +2365,11 @@ var useInitActivity = ({
|
|
|
2385
2365
|
}) => {
|
|
2386
2366
|
const { trackActivity } = useActivityTracker({ userId });
|
|
2387
2367
|
const init = () => {
|
|
2388
|
-
var
|
|
2368
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
2389
2369
|
if (!enabled) return;
|
|
2390
2370
|
if (!assignment) {
|
|
2391
2371
|
trackActivity({
|
|
2392
|
-
activityName: (
|
|
2372
|
+
activityName: (_a = set == null ? void 0 : set.name) != null ? _a : "",
|
|
2393
2373
|
activityType: "set",
|
|
2394
2374
|
id: set == null ? void 0 : set.id,
|
|
2395
2375
|
language: set == null ? void 0 : set.language
|
|
@@ -2403,12 +2383,12 @@ var useInitActivity = ({
|
|
|
2403
2383
|
});
|
|
2404
2384
|
}
|
|
2405
2385
|
if (set == null ? void 0 : set.public) {
|
|
2406
|
-
(
|
|
2386
|
+
(_d = (_c = (_b = api).httpsCallable) == null ? void 0 : _c.call(_b, "onSetOpened")) == null ? void 0 : _d({
|
|
2407
2387
|
setId: set.id,
|
|
2408
2388
|
language: set.language
|
|
2409
2389
|
});
|
|
2410
2390
|
}
|
|
2411
|
-
(
|
|
2391
|
+
(_g = (_f = (_e = api).httpsCallable) == null ? void 0 : _f.call(_e, "updateAlgoliaIndex")) == null ? void 0 : _g({
|
|
2412
2392
|
updatePlays: true,
|
|
2413
2393
|
objectID: set == null ? void 0 : set.id
|
|
2414
2394
|
});
|
|
@@ -2424,13 +2404,13 @@ var submitLTIScore = async ({
|
|
|
2424
2404
|
lineItemId,
|
|
2425
2405
|
lti_id
|
|
2426
2406
|
}) => {
|
|
2427
|
-
var
|
|
2407
|
+
var _a, _b, _c;
|
|
2428
2408
|
try {
|
|
2429
2409
|
if (!SERVICE_KEY || !lineItemId || !lti_id) {
|
|
2430
2410
|
throw new Error("Missing required LTI credentials");
|
|
2431
2411
|
}
|
|
2432
2412
|
const earnedPoints = score ? score / 100 * maxPoints : 0;
|
|
2433
|
-
const { data } = await ((
|
|
2413
|
+
const { data } = await ((_c = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "submitLTIAssignmentScore")) == null ? void 0 : _c({
|
|
2434
2414
|
SERVICE_KEY,
|
|
2435
2415
|
scoreData: {
|
|
2436
2416
|
lineItemId,
|
|
@@ -2608,19 +2588,19 @@ var useActivityFeedbackAccess = ({
|
|
|
2608
2588
|
aiEnabled = false,
|
|
2609
2589
|
isActivityRoute = false
|
|
2610
2590
|
}) => {
|
|
2611
|
-
var
|
|
2591
|
+
var _a, _b, _c;
|
|
2612
2592
|
const { user } = useSpeakableApi();
|
|
2613
2593
|
const uid = user.auth.uid;
|
|
2614
|
-
const isTeacher = (
|
|
2615
|
-
const isStudent = (
|
|
2616
|
-
const userRoles = ((
|
|
2594
|
+
const isTeacher = (_a = user.profile) == null ? void 0 : _a.isTeacher;
|
|
2595
|
+
const isStudent = (_b = user.profile) == null ? void 0 : _b.isStudent;
|
|
2596
|
+
const userRoles = ((_c = user.profile) == null ? void 0 : _c.roles) || [];
|
|
2617
2597
|
const query2 = useQuery6({
|
|
2618
2598
|
queryKey: activityFeedbackAccessQueryKeys.activityFeedbackAccess({
|
|
2619
2599
|
aiEnabled,
|
|
2620
2600
|
isActivityRoute
|
|
2621
2601
|
}),
|
|
2622
2602
|
queryFn: async () => {
|
|
2623
|
-
var
|
|
2603
|
+
var _a2, _b2, _c2;
|
|
2624
2604
|
if (!uid) {
|
|
2625
2605
|
return {
|
|
2626
2606
|
canAccessFeedback: false,
|
|
@@ -2648,7 +2628,7 @@ var useActivityFeedbackAccess = ({
|
|
|
2648
2628
|
}
|
|
2649
2629
|
if (isStudent && isActivityRoute) {
|
|
2650
2630
|
try {
|
|
2651
|
-
const result = await ((
|
|
2631
|
+
const result = await ((_c2 = (_b2 = (_a2 = api).httpsCallable) == null ? void 0 : _b2.call(_a2, "checkStudentTeacherPlan")) == null ? void 0 : _c2({
|
|
2652
2632
|
studentId: uid
|
|
2653
2633
|
}));
|
|
2654
2634
|
const planCheckResult = result.data;
|
|
@@ -2720,9 +2700,9 @@ var useBaseOpenAI = ({
|
|
|
2720
2700
|
aiEnabled
|
|
2721
2701
|
});
|
|
2722
2702
|
const getTranscript = async (audioUrl, language) => {
|
|
2723
|
-
var
|
|
2703
|
+
var _a, _b;
|
|
2724
2704
|
try {
|
|
2725
|
-
const getAssemblyAITranscript = (
|
|
2705
|
+
const getAssemblyAITranscript = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "transcribeAssemblyAIAudio");
|
|
2726
2706
|
const response = await (getAssemblyAITranscript == null ? void 0 : getAssemblyAITranscript({
|
|
2727
2707
|
audioUrl,
|
|
2728
2708
|
language
|
|
@@ -2746,13 +2726,13 @@ var useBaseOpenAI = ({
|
|
|
2746
2726
|
}
|
|
2747
2727
|
};
|
|
2748
2728
|
const getFreeResponseCompletion = async (messages, isFreeResponse, feedbackLanguage, gradingStandard = "actfl") => {
|
|
2749
|
-
var
|
|
2729
|
+
var _a, _b, _c, _d, _e;
|
|
2750
2730
|
const responseTool = getRespondCardTool({
|
|
2751
2731
|
language: feedbackLanguage,
|
|
2752
2732
|
standard: gradingStandard
|
|
2753
2733
|
});
|
|
2754
2734
|
try {
|
|
2755
|
-
const createChatCompletion = (
|
|
2735
|
+
const createChatCompletion = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "createChatCompletion");
|
|
2756
2736
|
const {
|
|
2757
2737
|
data: {
|
|
2758
2738
|
response,
|
|
@@ -2770,7 +2750,7 @@ var useBaseOpenAI = ({
|
|
|
2770
2750
|
},
|
|
2771
2751
|
type: isFreeResponse ? "LONG_RESPONSE" : "SHORT_RESPONSE"
|
|
2772
2752
|
}));
|
|
2773
|
-
const functionArguments = JSON.parse(((
|
|
2753
|
+
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
2754
|
const result = {
|
|
2775
2755
|
...functionArguments,
|
|
2776
2756
|
prompt_tokens,
|
|
@@ -2855,10 +2835,10 @@ var useBaseOpenAI = ({
|
|
|
2855
2835
|
}
|
|
2856
2836
|
};
|
|
2857
2837
|
const getAIResponse = async ({ cardId, transcript }) => {
|
|
2858
|
-
var
|
|
2838
|
+
var _a, _b, _c, _d, _e;
|
|
2859
2839
|
try {
|
|
2860
|
-
const getGeminiFeedback = (
|
|
2861
|
-
const getProficiencyEstimate = (
|
|
2840
|
+
const getGeminiFeedback = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "callGetFeedback");
|
|
2841
|
+
const getProficiencyEstimate = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "getProficiencyEstimate");
|
|
2862
2842
|
const card = getCardFromCache({
|
|
2863
2843
|
cardId,
|
|
2864
2844
|
queryClient
|
|
@@ -2881,7 +2861,7 @@ var useBaseOpenAI = ({
|
|
|
2881
2861
|
]);
|
|
2882
2862
|
proficiencyData = (proficiencyResult == null ? void 0 : proficiencyResult.data) || {};
|
|
2883
2863
|
feedbackData = {
|
|
2884
|
-
...(
|
|
2864
|
+
...(_e = geminiResult == null ? void 0 : geminiResult.data) != null ? _e : {},
|
|
2885
2865
|
// @ts-ignore
|
|
2886
2866
|
proficiency_level: (proficiencyData == null ? void 0 : proficiencyData.proficiency_level) || null
|
|
2887
2867
|
};
|