@speakableio/core 0.1.46 → 0.1.48
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 +119 -149
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +119 -149
- 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
|
-
|
|
91
|
-
return this.config.httpsCallable;
|
|
90
|
+
var _a2;
|
|
91
|
+
return (_a2 = this.config) == null ? void 0 : _a2.httpsCallable;
|
|
92
92
|
}
|
|
93
93
|
logEvent(name, data) {
|
|
94
|
-
var
|
|
95
|
-
(
|
|
94
|
+
var _a2;
|
|
95
|
+
(_a2 = this.config) == null ? void 0 : _a2.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 _a2;
|
|
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: (_a2 = scoresObject[a.id]) != null ? _a2 : 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 _a2;
|
|
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: (_a2 = assignment.scheduledTime) != null ? _a2 : null
|
|
318
318
|
};
|
|
319
319
|
if (params.analyticType) {
|
|
320
320
|
const assignmentsWithScores = await attachScoresAssignment({
|
|
@@ -781,58 +781,29 @@ import dayjs2 from "dayjs";
|
|
|
781
781
|
var WEB_BASE_URL = "https://app.speakable.io";
|
|
782
782
|
|
|
783
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;
|
|
784
785
|
var SpeakableFirebaseFunctions = {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
get submitAssignmentV2() {
|
|
801
|
-
return api.httpsCallable("submitLTIAssignmentScoreV2");
|
|
802
|
-
},
|
|
803
|
-
get submitAssessment() {
|
|
804
|
-
return api.httpsCallable("submitAssessment");
|
|
805
|
-
},
|
|
806
|
-
get sendAssessmentScoredEmail() {
|
|
807
|
-
return api.httpsCallable("sendAssessmentScoredEmail");
|
|
808
|
-
},
|
|
809
|
-
get createNotification() {
|
|
810
|
-
return api.httpsCallable("createNotificationV2");
|
|
811
|
-
},
|
|
812
|
-
get updateCourseAnalytics() {
|
|
813
|
-
return api.httpsCallable("handleCouresAnalyticsEvent");
|
|
814
|
-
},
|
|
815
|
-
get checkStudentTeacherPlan() {
|
|
816
|
-
return api.httpsCallable("checkStudentTeacherPlan");
|
|
817
|
-
},
|
|
818
|
-
get getGeminiFeedback() {
|
|
819
|
-
return api.httpsCallable("callGetFeedback");
|
|
820
|
-
},
|
|
821
|
-
get getProficiencyEstimate() {
|
|
822
|
-
return api.httpsCallable("getProficiencyEstimate");
|
|
823
|
-
},
|
|
824
|
-
get getAssemblyAITranscript() {
|
|
825
|
-
return api.httpsCallable("transcribeAssemblyAIAudio");
|
|
826
|
-
},
|
|
827
|
-
get createChatCompletion() {
|
|
828
|
-
return api.httpsCallable("createChatCompletion");
|
|
829
|
-
}
|
|
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")
|
|
830
801
|
};
|
|
831
802
|
|
|
832
803
|
// src/domains/notification/services/send-notification.service.ts
|
|
833
804
|
var _sendNotification = async (sendTo, notification) => {
|
|
834
|
-
var
|
|
835
|
-
const results = await ((
|
|
805
|
+
var _a2, _b2;
|
|
806
|
+
const results = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).createNotification) == null ? void 0 : _b2.call(_a2, {
|
|
836
807
|
sendTo,
|
|
837
808
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
838
809
|
notification
|
|
@@ -902,7 +873,7 @@ var createNewAssignmentNotification = async ({
|
|
|
902
873
|
data,
|
|
903
874
|
profile
|
|
904
875
|
}) => {
|
|
905
|
-
var
|
|
876
|
+
var _a2;
|
|
906
877
|
const { assignment, sendTo } = data;
|
|
907
878
|
const teacherName = profile.displayName || "Your teacher";
|
|
908
879
|
const dueDate = assignment.dueDateTimestamp ? dayjs2(assignment.dueDateTimestamp.toDate()).format("MMM Do") : null;
|
|
@@ -913,7 +884,7 @@ var createNewAssignmentNotification = async ({
|
|
|
913
884
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
914
885
|
messagePreview: `A new assignment "${assignment.name}" is now available. ${dueDate ? `Due ${dueDate}` : ""}`,
|
|
915
886
|
title: "New Assignment Available!",
|
|
916
|
-
imageUrl: (
|
|
887
|
+
imageUrl: (_a2 = profile.image) == null ? void 0 : _a2.url
|
|
917
888
|
});
|
|
918
889
|
return results;
|
|
919
890
|
};
|
|
@@ -922,7 +893,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
922
893
|
profile,
|
|
923
894
|
userId
|
|
924
895
|
}) => {
|
|
925
|
-
var
|
|
896
|
+
var _a2;
|
|
926
897
|
const studentName = profile.displayName || "Your student";
|
|
927
898
|
const results = await sendNotification(assignment.owners, {
|
|
928
899
|
courseId: assignment.courseId,
|
|
@@ -931,7 +902,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
931
902
|
title: `Assessment Submitted!`,
|
|
932
903
|
senderName: studentName,
|
|
933
904
|
messagePreview: `${studentName} has submitted the assessment "${assignment.name}"`,
|
|
934
|
-
imageUrl: (
|
|
905
|
+
imageUrl: (_a2 = profile.image) == null ? void 0 : _a2.url
|
|
935
906
|
});
|
|
936
907
|
return results;
|
|
937
908
|
};
|
|
@@ -939,7 +910,7 @@ var createAssessmentScoredNotification = async ({
|
|
|
939
910
|
data,
|
|
940
911
|
profile
|
|
941
912
|
}) => {
|
|
942
|
-
var
|
|
913
|
+
var _a2, _b2, _c2, _d2;
|
|
943
914
|
const { assignment, sendTo } = data;
|
|
944
915
|
const teacherName = profile.displayName || "Your teacher";
|
|
945
916
|
const title = `${assignment.isAssessment ? "Assessment" : "Assignment"} Reviewed!`;
|
|
@@ -950,13 +921,13 @@ var createAssessmentScoredNotification = async ({
|
|
|
950
921
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
951
922
|
title,
|
|
952
923
|
messagePreview,
|
|
953
|
-
imageUrl: (
|
|
924
|
+
imageUrl: (_a2 = profile.image) == null ? void 0 : _a2.url,
|
|
954
925
|
senderName: teacherName
|
|
955
926
|
});
|
|
956
|
-
await ((
|
|
927
|
+
await ((_d2 = (_c2 = SpeakableFirebaseFunctions).sendAssessmentScoredEmail) == null ? void 0 : _d2.call(_c2, {
|
|
957
928
|
assessmentTitle: assignment.name,
|
|
958
929
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
959
|
-
senderImage: ((
|
|
930
|
+
senderImage: ((_b2 = profile.image) == null ? void 0 : _b2.url) || "",
|
|
960
931
|
studentId: sendTo[0],
|
|
961
932
|
teacherName: profile.displayName
|
|
962
933
|
}));
|
|
@@ -971,15 +942,15 @@ var notificationQueryKeys = {
|
|
|
971
942
|
var useCreateNotification = () => {
|
|
972
943
|
const { user, queryClient } = useSpeakableApi();
|
|
973
944
|
const handleCreateNotifications = async (type, data) => {
|
|
974
|
-
var
|
|
945
|
+
var _a2, _b2;
|
|
975
946
|
const result = await createNotification({
|
|
976
947
|
type,
|
|
977
948
|
userId: user.auth.uid,
|
|
978
|
-
profile: (
|
|
949
|
+
profile: (_a2 = user == null ? void 0 : user.profile) != null ? _a2 : {},
|
|
979
950
|
data
|
|
980
951
|
});
|
|
981
952
|
queryClient.invalidateQueries({
|
|
982
|
-
queryKey: notificationQueryKeys.byId((
|
|
953
|
+
queryKey: notificationQueryKeys.byId((_b2 = user == null ? void 0 : user.auth.uid) != null ? _b2 : "")
|
|
983
954
|
});
|
|
984
955
|
return result;
|
|
985
956
|
};
|
|
@@ -1438,8 +1409,8 @@ var SpeakablePlanHierarchy = [
|
|
|
1438
1409
|
var usePermissions = () => {
|
|
1439
1410
|
const { permissions } = useSpeakableApi();
|
|
1440
1411
|
const has = (permission) => {
|
|
1441
|
-
var
|
|
1442
|
-
return (
|
|
1412
|
+
var _a2;
|
|
1413
|
+
return (_a2 = permissions.permissions) == null ? void 0 : _a2.includes(permission);
|
|
1443
1414
|
};
|
|
1444
1415
|
return {
|
|
1445
1416
|
plan: permissions.plan,
|
|
@@ -1470,7 +1441,7 @@ var useGoogleClassroom = () => {
|
|
|
1470
1441
|
googleUserId = null
|
|
1471
1442
|
// optional to override the user's googleUserId
|
|
1472
1443
|
}) => {
|
|
1473
|
-
var
|
|
1444
|
+
var _a2, _b2;
|
|
1474
1445
|
try {
|
|
1475
1446
|
const { googleClassroomUserId = null } = scores;
|
|
1476
1447
|
const googleId = googleUserId || googleClassroomUserId;
|
|
@@ -1481,7 +1452,7 @@ var useGoogleClassroom = () => {
|
|
|
1481
1452
|
};
|
|
1482
1453
|
const { courseWorkId, maxPoints, owners, courseId } = assignment;
|
|
1483
1454
|
const draftGrade = (scores == null ? void 0 : scores.score) ? (scores == null ? void 0 : scores.score) / 100 * maxPoints : 0;
|
|
1484
|
-
const result = await ((
|
|
1455
|
+
const result = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).submitAssignmentToGoogleClassroomV2) == null ? void 0 : _b2.call(_a2, {
|
|
1485
1456
|
teacherId: owners[0],
|
|
1486
1457
|
courseId,
|
|
1487
1458
|
courseWorkId,
|
|
@@ -1500,9 +1471,9 @@ var useGoogleClassroom = () => {
|
|
|
1500
1471
|
|
|
1501
1472
|
// src/lib/firebase/firebase-analytics/grading-standard.ts
|
|
1502
1473
|
var logGradingStandardLog = (data) => {
|
|
1503
|
-
var
|
|
1474
|
+
var _a2, _b2;
|
|
1504
1475
|
if (data.courseId && data.type && data.level) {
|
|
1505
|
-
(
|
|
1476
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).updateCourseAnalytics) == null ? void 0 : _b2.call(_a2, {
|
|
1506
1477
|
eventType: data.type || "custom",
|
|
1507
1478
|
level: data.level,
|
|
1508
1479
|
courseId: data.courseId
|
|
@@ -1538,17 +1509,17 @@ var logOpenActivityPreview = (data = {}) => {
|
|
|
1538
1509
|
api.logEvent("open_activity_preview", data);
|
|
1539
1510
|
};
|
|
1540
1511
|
var logSubmitAssignment = (data = {}) => {
|
|
1541
|
-
var
|
|
1542
|
-
(
|
|
1512
|
+
var _a2, _b2;
|
|
1513
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).updateCourseAnalytics) == null ? void 0 : _b2.call(_a2, {
|
|
1543
1514
|
eventType: ANALYTICS_EVENT_TYPES.SUBMISSION,
|
|
1544
1515
|
...data
|
|
1545
1516
|
});
|
|
1546
1517
|
api.logEvent(ANALYTICS_EVENT_TYPES.SUBMISSION, data);
|
|
1547
1518
|
};
|
|
1548
1519
|
var logStartAssignment = (data = {}) => {
|
|
1549
|
-
var
|
|
1520
|
+
var _a2, _b2;
|
|
1550
1521
|
if (data.courseId) {
|
|
1551
|
-
(
|
|
1522
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).updateCourseAnalytics) == null ? void 0 : _b2.call(_a2, {
|
|
1552
1523
|
eventType: ANALYTICS_EVENT_TYPES.ASSIGNMENT_STARTED,
|
|
1553
1524
|
...data
|
|
1554
1525
|
});
|
|
@@ -1589,13 +1560,13 @@ var refsScoresPractice = {
|
|
|
1589
1560
|
|
|
1590
1561
|
// src/domains/assignment/services/create-score.service.ts
|
|
1591
1562
|
async function _createScore(params) {
|
|
1592
|
-
var
|
|
1563
|
+
var _a2, _b2;
|
|
1593
1564
|
if (params.isAssignment) {
|
|
1594
1565
|
const ref = refsAssignmentFiresotre.assignmentScores({
|
|
1595
1566
|
id: params.activityId,
|
|
1596
1567
|
userId: params.userId
|
|
1597
1568
|
});
|
|
1598
|
-
await ((
|
|
1569
|
+
await ((_b2 = (_a2 = SpeakableFirebaseFunctions).updateAssignmentGradebookStatus) == null ? void 0 : _b2.call(_a2, {
|
|
1599
1570
|
assignmentId: params.activityId,
|
|
1600
1571
|
userId: params.userId,
|
|
1601
1572
|
status: "IN_PROGRESS",
|
|
@@ -1705,10 +1676,10 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1705
1676
|
return acc;
|
|
1706
1677
|
}, 0);
|
|
1707
1678
|
const totalPointsAwarded = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
|
|
1708
|
-
var
|
|
1709
|
-
const cardScores = (
|
|
1679
|
+
var _a2, _b2;
|
|
1680
|
+
const cardScores = (_a2 = scores == null ? void 0 : scores.cards) == null ? void 0 : _a2[cardId];
|
|
1710
1681
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1711
|
-
const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((
|
|
1682
|
+
const score2 = (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0 ? Number((_b2 = cardScores == null ? void 0 : cardScores.score) != null ? _b2 : 0) : null;
|
|
1712
1683
|
const weight = (weights == null ? void 0 : weights[cardId]) || 1;
|
|
1713
1684
|
const fraction = (score2 != null ? score2 : 0) / 100;
|
|
1714
1685
|
if (score2 || score2 === 0) {
|
|
@@ -1720,8 +1691,8 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1720
1691
|
return acc;
|
|
1721
1692
|
}, 0);
|
|
1722
1693
|
const totalCompletedCards = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
|
|
1723
|
-
var
|
|
1724
|
-
const cardScores = (
|
|
1694
|
+
var _a2;
|
|
1695
|
+
const cardScores = (_a2 = scores == null ? void 0 : scores.cards) == null ? void 0 : _a2[cardId];
|
|
1725
1696
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1726
1697
|
acc += 1;
|
|
1727
1698
|
}
|
|
@@ -1778,22 +1749,22 @@ var updateCardScore = withErrorHandler(_updateCardScore, "updateCardScore");
|
|
|
1778
1749
|
// src/domains/assignment/services/clear-score.service.ts
|
|
1779
1750
|
import dayjs3 from "dayjs";
|
|
1780
1751
|
async function clearScore(params) {
|
|
1781
|
-
var
|
|
1752
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
1782
1753
|
const update = {
|
|
1783
1754
|
[`cards.${params.cardId}`]: {
|
|
1784
|
-
attempts: (
|
|
1785
|
-
correct: (
|
|
1755
|
+
attempts: (_a2 = params.cardScores.attempts) != null ? _a2 : 1,
|
|
1756
|
+
correct: (_b2 = params.cardScores.correct) != null ? _b2 : 0,
|
|
1786
1757
|
// save old score history
|
|
1787
1758
|
history: [
|
|
1788
1759
|
{
|
|
1789
1760
|
...params.cardScores,
|
|
1790
|
-
attempts: (
|
|
1791
|
-
correct: (
|
|
1761
|
+
attempts: (_c2 = params.cardScores.attempts) != null ? _c2 : 1,
|
|
1762
|
+
correct: (_d2 = params.cardScores.correct) != null ? _d2 : 0,
|
|
1792
1763
|
retryTime: dayjs3().format("YYYY-MM-DD HH:mm:ss"),
|
|
1793
1764
|
history: null
|
|
1794
1765
|
},
|
|
1795
1766
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1796
|
-
...(
|
|
1767
|
+
...(_e2 = params.cardScores.history) != null ? _e2 : []
|
|
1797
1768
|
]
|
|
1798
1769
|
}
|
|
1799
1770
|
};
|
|
@@ -1850,7 +1821,7 @@ var submitAssignmentScore = withErrorHandler(
|
|
|
1850
1821
|
"submitAssignmentScore"
|
|
1851
1822
|
);
|
|
1852
1823
|
async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpdated, studentName) {
|
|
1853
|
-
var
|
|
1824
|
+
var _a2, _b2;
|
|
1854
1825
|
const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
|
|
1855
1826
|
const response = await api.getDoc(path);
|
|
1856
1827
|
if (!response.data) {
|
|
@@ -1858,7 +1829,7 @@ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpda
|
|
|
1858
1829
|
}
|
|
1859
1830
|
const { score: scoreCalculated } = calculateScoreAndProgress_default(response.data, cardIds, weights);
|
|
1860
1831
|
await api.updateDoc(path, { score: scoreCalculated, status: "PENDING_REVIEW" });
|
|
1861
|
-
await ((
|
|
1832
|
+
await ((_b2 = (_a2 = SpeakableFirebaseFunctions).submitAssessment) == null ? void 0 : _b2.call(_a2, {
|
|
1862
1833
|
assignmentId: assignment.id,
|
|
1863
1834
|
assignmentTitle: assignment.name,
|
|
1864
1835
|
userId,
|
|
@@ -1869,8 +1840,8 @@ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpda
|
|
|
1869
1840
|
return { success: true, fieldsUpdated };
|
|
1870
1841
|
}
|
|
1871
1842
|
async function handleCourseAssignment(assignment, userId) {
|
|
1872
|
-
var
|
|
1873
|
-
await ((
|
|
1843
|
+
var _a2, _b2;
|
|
1844
|
+
await ((_b2 = (_a2 = SpeakableFirebaseFunctions) == null ? void 0 : _a2.submitAssignmentV2) == null ? void 0 : _b2.call(_a2, {
|
|
1874
1845
|
assignmentId: assignment.id,
|
|
1875
1846
|
userId
|
|
1876
1847
|
}));
|
|
@@ -2015,8 +1986,8 @@ var getScoreUpdated = ({
|
|
|
2015
1986
|
cardIds,
|
|
2016
1987
|
weights
|
|
2017
1988
|
}) => {
|
|
2018
|
-
var
|
|
2019
|
-
const previousCard = (
|
|
1989
|
+
var _a2, _b2;
|
|
1990
|
+
const previousCard = (_a2 = previousScores.cards) == null ? void 0 : _a2[cardId];
|
|
2020
1991
|
const newCardScore = {
|
|
2021
1992
|
...previousCard != null ? previousCard : {},
|
|
2022
1993
|
...cardScore
|
|
@@ -2024,7 +1995,7 @@ var getScoreUpdated = ({
|
|
|
2024
1995
|
const newScores = {
|
|
2025
1996
|
...previousScores,
|
|
2026
1997
|
cards: {
|
|
2027
|
-
...(
|
|
1998
|
+
...(_b2 = previousScores.cards) != null ? _b2 : {},
|
|
2028
1999
|
[cardId]: newCardScore
|
|
2029
2000
|
}
|
|
2030
2001
|
};
|
|
@@ -2043,8 +2014,8 @@ var handleOptimisticScore = ({
|
|
|
2043
2014
|
cardIds,
|
|
2044
2015
|
weights
|
|
2045
2016
|
}) => {
|
|
2046
|
-
var
|
|
2047
|
-
let cards = { ...(
|
|
2017
|
+
var _a2;
|
|
2018
|
+
let cards = { ...(_a2 = score == null ? void 0 : score.cards) != null ? _a2 : {} };
|
|
2048
2019
|
cards = {
|
|
2049
2020
|
...cards,
|
|
2050
2021
|
[cardId]: {
|
|
@@ -2068,9 +2039,9 @@ function useClearScore() {
|
|
|
2068
2039
|
const mutation = useMutation2({
|
|
2069
2040
|
mutationFn: clearScore,
|
|
2070
2041
|
onSettled: (result) => {
|
|
2071
|
-
var
|
|
2042
|
+
var _a2;
|
|
2072
2043
|
queryClient.invalidateQueries({
|
|
2073
|
-
queryKey: scoreQueryKeys.byId((
|
|
2044
|
+
queryKey: scoreQueryKeys.byId((_a2 = result == null ? void 0 : result.activityId) != null ? _a2 : "")
|
|
2074
2045
|
});
|
|
2075
2046
|
}
|
|
2076
2047
|
});
|
|
@@ -2219,7 +2190,7 @@ function useActivity({
|
|
|
2219
2190
|
onAssignmentSubmitted,
|
|
2220
2191
|
ltiData
|
|
2221
2192
|
}) {
|
|
2222
|
-
var
|
|
2193
|
+
var _a2, _b2;
|
|
2223
2194
|
const { queryClient, user } = useSpeakableApi();
|
|
2224
2195
|
const userId = user.auth.uid;
|
|
2225
2196
|
const assignmentQuery = useAssignment({
|
|
@@ -2228,7 +2199,7 @@ function useActivity({
|
|
|
2228
2199
|
enabled: isAssignment
|
|
2229
2200
|
});
|
|
2230
2201
|
const activeAssignment = assignmentQuery.data;
|
|
2231
|
-
const setId = isAssignment ? (
|
|
2202
|
+
const setId = isAssignment ? (_a2 = activeAssignment == null ? void 0 : activeAssignment.setId) != null ? _a2 : "" : id;
|
|
2232
2203
|
const querySet = useSet({ setId });
|
|
2233
2204
|
const setData = querySet.data;
|
|
2234
2205
|
const assignmentContent = activeAssignment == null ? void 0 : activeAssignment.content;
|
|
@@ -2237,7 +2208,7 @@ function useActivity({
|
|
|
2237
2208
|
const setWeights = setData == null ? void 0 : setData.weights;
|
|
2238
2209
|
const contentCardsToUse = isAssignment ? assignmentContent != null ? assignmentContent : setContent : setContent;
|
|
2239
2210
|
const weightsToUse = isAssignment ? assignmentWeights != null ? assignmentWeights : setWeights : setWeights;
|
|
2240
|
-
const activityId = isAssignment ? (
|
|
2211
|
+
const activityId = isAssignment ? (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "" : setId;
|
|
2241
2212
|
const { cardsObject, cardsQueries, cards } = useCards({
|
|
2242
2213
|
cardIds: contentCardsToUse != null ? contentCardsToUse : [],
|
|
2243
2214
|
enabled: querySet.isSuccess,
|
|
@@ -2280,13 +2251,13 @@ function useActivity({
|
|
|
2280
2251
|
cardId,
|
|
2281
2252
|
wasCompleted = true
|
|
2282
2253
|
}) => {
|
|
2283
|
-
var
|
|
2254
|
+
var _a3, _b3;
|
|
2284
2255
|
const currentCard = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2285
2256
|
if ((currentCard == null ? void 0 : currentCard.type) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || (currentCard == null ? void 0 : currentCard.type) === "READ_REPEAT" /* READ_REPEAT */) {
|
|
2286
2257
|
return;
|
|
2287
2258
|
}
|
|
2288
2259
|
const queryKeys = scoreQueryKeys.byId(activityId);
|
|
2289
|
-
const activeCardScores = (
|
|
2260
|
+
const activeCardScores = (_b3 = (_a3 = queryClient.getQueryData(queryKeys)) == null ? void 0 : _a3.cards) == null ? void 0 : _b3[cardId];
|
|
2290
2261
|
if (activeCardScores === void 0) return;
|
|
2291
2262
|
mutationClearScore.mutate({
|
|
2292
2263
|
isAssignment,
|
|
@@ -2297,11 +2268,11 @@ function useActivity({
|
|
|
2297
2268
|
});
|
|
2298
2269
|
};
|
|
2299
2270
|
const onSubmitScore = async () => {
|
|
2300
|
-
var
|
|
2271
|
+
var _a3, _b3, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
|
|
2301
2272
|
try {
|
|
2302
2273
|
let results;
|
|
2303
2274
|
if (isAssignment) {
|
|
2304
|
-
const cardScores = ((
|
|
2275
|
+
const cardScores = ((_a3 = scoreQuery.data) == null ? void 0 : _a3.cards) || {};
|
|
2305
2276
|
const hasPendingReview = Object.values(cardScores).some(
|
|
2306
2277
|
(cardScore) => cardScore.status === "pending_review"
|
|
2307
2278
|
);
|
|
@@ -2313,18 +2284,18 @@ function useActivity({
|
|
|
2313
2284
|
weights: weightsToUse != null ? weightsToUse : {},
|
|
2314
2285
|
status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
|
|
2315
2286
|
});
|
|
2316
|
-
if ((
|
|
2287
|
+
if ((_b3 = assignmentQuery.data) == null ? void 0 : _b3.ltiDeeplink) {
|
|
2317
2288
|
submitLTIScore({
|
|
2318
|
-
maxPoints: (
|
|
2319
|
-
score: (
|
|
2320
|
-
SERVICE_KEY: (
|
|
2321
|
-
lineItemId: (
|
|
2322
|
-
lti_id: (
|
|
2289
|
+
maxPoints: (_c2 = assignmentQuery.data) == null ? void 0 : _c2.maxPoints,
|
|
2290
|
+
score: (_e2 = (_d2 = scoreQuery.data) == null ? void 0 : _d2.score) != null ? _e2 : 0,
|
|
2291
|
+
SERVICE_KEY: (_f2 = ltiData == null ? void 0 : ltiData.serviceKey) != null ? _f2 : "",
|
|
2292
|
+
lineItemId: (_g2 = ltiData == null ? void 0 : ltiData.lineItemId) != null ? _g2 : "",
|
|
2293
|
+
lti_id: (_h2 = ltiData == null ? void 0 : ltiData.lti_id) != null ? _h2 : ""
|
|
2323
2294
|
});
|
|
2324
2295
|
}
|
|
2325
2296
|
} else {
|
|
2326
2297
|
results = await submitPracticeScore2({
|
|
2327
|
-
setId: (
|
|
2298
|
+
setId: (_j2 = (_i2 = querySet.data) == null ? void 0 : _i2.id) != null ? _j2 : "",
|
|
2328
2299
|
userId,
|
|
2329
2300
|
scores: scoreQuery.data
|
|
2330
2301
|
});
|
|
@@ -2342,23 +2313,23 @@ function useActivity({
|
|
|
2342
2313
|
gradingStandard,
|
|
2343
2314
|
type
|
|
2344
2315
|
}) => {
|
|
2345
|
-
var
|
|
2316
|
+
var _a3, _b3, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
2346
2317
|
const card = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2347
2318
|
const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
|
|
2348
|
-
const cardScore = (
|
|
2319
|
+
const cardScore = (_a3 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a3[cardId];
|
|
2349
2320
|
const serverTimestamp2 = api.helpers.serverTimestamp;
|
|
2350
2321
|
addGradingStandardLog(
|
|
2351
2322
|
{
|
|
2352
|
-
assignmentId: (
|
|
2353
|
-
courseId: (
|
|
2354
|
-
teacherId: (
|
|
2355
|
-
setId: (
|
|
2323
|
+
assignmentId: (_b3 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b3 : "",
|
|
2324
|
+
courseId: (_c2 = activeAssignment == null ? void 0 : activeAssignment.courseId) != null ? _c2 : "",
|
|
2325
|
+
teacherId: (_d2 = activeAssignment == null ? void 0 : activeAssignment.owners[0]) != null ? _d2 : "",
|
|
2326
|
+
setId: (_e2 = setData == null ? void 0 : setData.id) != null ? _e2 : "",
|
|
2356
2327
|
cardId,
|
|
2357
2328
|
level: gradingStandard.level,
|
|
2358
2329
|
justification: gradingStandard.justification,
|
|
2359
|
-
transcript: (
|
|
2360
|
-
audioUrl: (
|
|
2361
|
-
prompt: (
|
|
2330
|
+
transcript: (_f2 = cardScore == null ? void 0 : cardScore.transcript) != null ? _f2 : "",
|
|
2331
|
+
audioUrl: (_g2 = cardScore == null ? void 0 : cardScore.audio) != null ? _g2 : "",
|
|
2332
|
+
prompt: (_h2 = card == null ? void 0 : card.prompt) != null ? _h2 : "",
|
|
2362
2333
|
responseType: (card == null ? void 0 : card.type) === "RESPOND_WRITE" /* RESPOND_WRITE */ ? "written" : "spoken",
|
|
2363
2334
|
type,
|
|
2364
2335
|
dateMade: serverTimestamp2()
|
|
@@ -2414,11 +2385,11 @@ var useInitActivity = ({
|
|
|
2414
2385
|
}) => {
|
|
2415
2386
|
const { trackActivity } = useActivityTracker({ userId });
|
|
2416
2387
|
const init = () => {
|
|
2417
|
-
var
|
|
2388
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
2418
2389
|
if (!enabled) return;
|
|
2419
2390
|
if (!assignment) {
|
|
2420
2391
|
trackActivity({
|
|
2421
|
-
activityName: (
|
|
2392
|
+
activityName: (_a2 = set == null ? void 0 : set.name) != null ? _a2 : "",
|
|
2422
2393
|
activityType: "set",
|
|
2423
2394
|
id: set == null ? void 0 : set.id,
|
|
2424
2395
|
language: set == null ? void 0 : set.language
|
|
@@ -2432,12 +2403,12 @@ var useInitActivity = ({
|
|
|
2432
2403
|
});
|
|
2433
2404
|
}
|
|
2434
2405
|
if (set == null ? void 0 : set.public) {
|
|
2435
|
-
(
|
|
2406
|
+
(_c2 = (_b2 = SpeakableFirebaseFunctions) == null ? void 0 : _b2.onSetOpened) == null ? void 0 : _c2.call(_b2, {
|
|
2436
2407
|
setId: set.id,
|
|
2437
2408
|
language: set.language
|
|
2438
2409
|
});
|
|
2439
2410
|
}
|
|
2440
|
-
(
|
|
2411
|
+
(_e2 = (_d2 = SpeakableFirebaseFunctions) == null ? void 0 : _d2.updateAlgoliaIndex) == null ? void 0 : _e2.call(_d2, {
|
|
2441
2412
|
updatePlays: true,
|
|
2442
2413
|
objectID: set == null ? void 0 : set.id
|
|
2443
2414
|
});
|
|
@@ -2453,13 +2424,13 @@ var submitLTIScore = async ({
|
|
|
2453
2424
|
lineItemId,
|
|
2454
2425
|
lti_id
|
|
2455
2426
|
}) => {
|
|
2456
|
-
var
|
|
2427
|
+
var _a2, _b2;
|
|
2457
2428
|
try {
|
|
2458
2429
|
if (!SERVICE_KEY || !lineItemId || !lti_id) {
|
|
2459
2430
|
throw new Error("Missing required LTI credentials");
|
|
2460
2431
|
}
|
|
2461
2432
|
const earnedPoints = score ? score / 100 * maxPoints : 0;
|
|
2462
|
-
const { data } = await ((
|
|
2433
|
+
const { data } = await ((_b2 = (_a2 = SpeakableFirebaseFunctions) == null ? void 0 : _a2.submitLTIAssignmentScore) == null ? void 0 : _b2.call(_a2, {
|
|
2463
2434
|
SERVICE_KEY,
|
|
2464
2435
|
scoreData: {
|
|
2465
2436
|
lineItemId,
|
|
@@ -2637,19 +2608,19 @@ var useActivityFeedbackAccess = ({
|
|
|
2637
2608
|
aiEnabled = false,
|
|
2638
2609
|
isActivityRoute = false
|
|
2639
2610
|
}) => {
|
|
2640
|
-
var
|
|
2611
|
+
var _a2, _b2, _c2;
|
|
2641
2612
|
const { user } = useSpeakableApi();
|
|
2642
2613
|
const uid = user.auth.uid;
|
|
2643
|
-
const isTeacher = (
|
|
2644
|
-
const isStudent = (
|
|
2645
|
-
const userRoles = ((
|
|
2614
|
+
const isTeacher = (_a2 = user.profile) == null ? void 0 : _a2.isTeacher;
|
|
2615
|
+
const isStudent = (_b2 = user.profile) == null ? void 0 : _b2.isStudent;
|
|
2616
|
+
const userRoles = ((_c2 = user.profile) == null ? void 0 : _c2.roles) || [];
|
|
2646
2617
|
const query2 = useQuery6({
|
|
2647
2618
|
queryKey: activityFeedbackAccessQueryKeys.activityFeedbackAccess({
|
|
2648
2619
|
aiEnabled,
|
|
2649
2620
|
isActivityRoute
|
|
2650
2621
|
}),
|
|
2651
2622
|
queryFn: async () => {
|
|
2652
|
-
var
|
|
2623
|
+
var _a3, _b3;
|
|
2653
2624
|
if (!uid) {
|
|
2654
2625
|
return {
|
|
2655
2626
|
canAccessFeedback: false,
|
|
@@ -2677,7 +2648,7 @@ var useActivityFeedbackAccess = ({
|
|
|
2677
2648
|
}
|
|
2678
2649
|
if (isStudent && isActivityRoute) {
|
|
2679
2650
|
try {
|
|
2680
|
-
const result = await ((
|
|
2651
|
+
const result = await ((_b3 = (_a3 = SpeakableFirebaseFunctions) == null ? void 0 : _a3.checkStudentTeacherPlan) == null ? void 0 : _b3.call(_a3, {
|
|
2681
2652
|
studentId: uid
|
|
2682
2653
|
}));
|
|
2683
2654
|
const planCheckResult = result.data;
|
|
@@ -2734,9 +2705,6 @@ var useActivityFeedbackAccess = ({
|
|
|
2734
2705
|
};
|
|
2735
2706
|
|
|
2736
2707
|
// src/hooks/useOpenAI.ts
|
|
2737
|
-
var getGeminiFeedback = SpeakableFirebaseFunctions.getGeminiFeedback;
|
|
2738
|
-
var getProficiencyEstimate = SpeakableFirebaseFunctions.getProficiencyEstimate;
|
|
2739
|
-
var getAssemblyAITranscript = SpeakableFirebaseFunctions.getAssemblyAITranscript;
|
|
2740
2708
|
var useBaseOpenAI = ({
|
|
2741
2709
|
onTranscriptSuccess,
|
|
2742
2710
|
onTranscriptError,
|
|
@@ -2752,15 +2720,17 @@ var useBaseOpenAI = ({
|
|
|
2752
2720
|
aiEnabled
|
|
2753
2721
|
});
|
|
2754
2722
|
const getTranscript = async (audioUrl, language) => {
|
|
2723
|
+
var _a2, _b2;
|
|
2755
2724
|
try {
|
|
2756
|
-
const response = await getAssemblyAITranscript({
|
|
2725
|
+
const response = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).getAssemblyAITranscript) == null ? void 0 : _b2.call(_a2, {
|
|
2757
2726
|
audioUrl,
|
|
2758
2727
|
language
|
|
2759
|
-
});
|
|
2728
|
+
}));
|
|
2760
2729
|
console.log("response (getTranscript) from getAssemblyAITranscript", {
|
|
2761
2730
|
response,
|
|
2762
2731
|
audioUrl,
|
|
2763
|
-
language
|
|
2732
|
+
language,
|
|
2733
|
+
getAssemblyAITranscript: SpeakableFirebaseFunctions.getAssemblyAITranscript
|
|
2764
2734
|
});
|
|
2765
2735
|
const transcript = response == null ? void 0 : response.data;
|
|
2766
2736
|
onTranscriptSuccess(transcript);
|
|
@@ -2775,7 +2745,7 @@ var useBaseOpenAI = ({
|
|
|
2775
2745
|
}
|
|
2776
2746
|
};
|
|
2777
2747
|
const getFreeResponseCompletion = async (messages, isFreeResponse, feedbackLanguage, gradingStandard = "actfl") => {
|
|
2778
|
-
var
|
|
2748
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
2779
2749
|
const responseTool = getRespondCardTool({
|
|
2780
2750
|
language: feedbackLanguage,
|
|
2781
2751
|
standard: gradingStandard
|
|
@@ -2789,7 +2759,7 @@ var useBaseOpenAI = ({
|
|
|
2789
2759
|
success: aiSuccess = false
|
|
2790
2760
|
// the AI was able to generate a response
|
|
2791
2761
|
}
|
|
2792
|
-
} = await ((
|
|
2762
|
+
} = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).createChatCompletion) == null ? void 0 : _b2.call(_a2, {
|
|
2793
2763
|
chat: {
|
|
2794
2764
|
model: isFreeResponse ? "gpt-4-1106-preview" : "gpt-3.5-turbo-1106",
|
|
2795
2765
|
messages,
|
|
@@ -2798,7 +2768,7 @@ var useBaseOpenAI = ({
|
|
|
2798
2768
|
},
|
|
2799
2769
|
type: isFreeResponse ? "LONG_RESPONSE" : "SHORT_RESPONSE"
|
|
2800
2770
|
}));
|
|
2801
|
-
const functionArguments = JSON.parse(((
|
|
2771
|
+
const functionArguments = JSON.parse(((_e2 = (_d2 = (_c2 = response == null ? void 0 : response.tool_calls) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.function) == null ? void 0 : _e2.arguments) || "{}");
|
|
2802
2772
|
const result = {
|
|
2803
2773
|
...functionArguments,
|
|
2804
2774
|
prompt_tokens,
|
|
@@ -2883,7 +2853,7 @@ var useBaseOpenAI = ({
|
|
|
2883
2853
|
}
|
|
2884
2854
|
};
|
|
2885
2855
|
const getAIResponse = async ({ cardId, transcript }) => {
|
|
2886
|
-
var
|
|
2856
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
2887
2857
|
try {
|
|
2888
2858
|
const card = getCardFromCache({
|
|
2889
2859
|
cardId,
|
|
@@ -2894,12 +2864,12 @@ var useBaseOpenAI = ({
|
|
|
2894
2864
|
if (card && card.grading_method === "manual") {
|
|
2895
2865
|
} else if (card && card.grading_method !== "standards_based") {
|
|
2896
2866
|
const [geminiResult, proficiencyResult] = await Promise.all([
|
|
2897
|
-
getGeminiFeedback == null ? void 0 :
|
|
2867
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).getGeminiFeedback) == null ? void 0 : _b2.call(_a2, {
|
|
2898
2868
|
cardId,
|
|
2899
2869
|
studentId: currentUserId,
|
|
2900
2870
|
studentResponse: transcript
|
|
2901
2871
|
}),
|
|
2902
|
-
getProficiencyEstimate == null ? void 0 :
|
|
2872
|
+
(_d2 = (_c2 = SpeakableFirebaseFunctions).getProficiencyEstimate) == null ? void 0 : _d2.call(_c2, {
|
|
2903
2873
|
cardId,
|
|
2904
2874
|
studentId: currentUserId,
|
|
2905
2875
|
studentResponse: transcript
|
|
@@ -2907,12 +2877,12 @@ var useBaseOpenAI = ({
|
|
|
2907
2877
|
]);
|
|
2908
2878
|
proficiencyData = (proficiencyResult == null ? void 0 : proficiencyResult.data) || {};
|
|
2909
2879
|
feedbackData = {
|
|
2910
|
-
...(
|
|
2880
|
+
...(_e2 = geminiResult == null ? void 0 : geminiResult.data) != null ? _e2 : {},
|
|
2911
2881
|
// @ts-ignore
|
|
2912
2882
|
proficiency_level: (proficiencyData == null ? void 0 : proficiencyData.proficiency_level) || null
|
|
2913
2883
|
};
|
|
2914
2884
|
} else {
|
|
2915
|
-
const geminiResult = await (getGeminiFeedback == null ? void 0 :
|
|
2885
|
+
const geminiResult = await ((_g2 = (_f2 = SpeakableFirebaseFunctions).getGeminiFeedback) == null ? void 0 : _g2.call(_f2, {
|
|
2916
2886
|
cardId,
|
|
2917
2887
|
studentId: currentUserId,
|
|
2918
2888
|
studentResponse: transcript
|