@speakableio/core 0.1.45 → 0.1.47
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 +115 -113
- package/dist/index.native.mjs.map +1 -1
- package/dist/index.web.js +115 -113
- 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,28 +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
|
-
updateAssignmentGradebookStatus: api.httpsCallable("updateAssignmentGradebookStatus"),
|
|
786
|
-
onSetOpened: api.httpsCallable("onSetOpened"),
|
|
787
|
-
updateAlgoliaIndex: api.httpsCallable("updateAlgoliaIndex"),
|
|
788
|
-
submitAssignmentToGoogleClassroomV2: api.httpsCallable("submitAssignmentToGoogleClassroomV2"),
|
|
789
|
-
submitLTIAssignmentScore: api.httpsCallable("submitLTIAssignmentScore"),
|
|
790
|
-
submitAssignmentV2: api.httpsCallable("submitLTIAssignmentScoreV2"),
|
|
791
|
-
submitAssessment: api.httpsCallable("submitAssessment"),
|
|
792
|
-
sendAssessmentScoredEmail: api.httpsCallable("sendAssessmentScoredEmail"),
|
|
793
|
-
createNotification: api.httpsCallable("createNotificationV2"),
|
|
794
|
-
updateCourseAnalytics: api.httpsCallable("handleCouresAnalyticsEvent"),
|
|
795
|
-
checkStudentTeacherPlan: api.httpsCallable("checkStudentTeacherPlan"),
|
|
796
|
-
getGeminiFeedback: api.httpsCallable("callGetFeedback"),
|
|
797
|
-
getProficiencyEstimate: api.httpsCallable("getProficiencyEstimate"),
|
|
798
|
-
getAssemblyAITranscript: api.httpsCallable("transcribeAssemblyAIAudio"),
|
|
799
|
-
createChatCompletion: api.httpsCallable("createChatCompletion")
|
|
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")
|
|
800
801
|
};
|
|
801
802
|
|
|
802
803
|
// src/domains/notification/services/send-notification.service.ts
|
|
803
804
|
var _sendNotification = async (sendTo, notification) => {
|
|
804
|
-
var
|
|
805
|
-
const results = await ((
|
|
805
|
+
var _a2, _b2;
|
|
806
|
+
const results = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).createNotification) == null ? void 0 : _b2.call(_a2, {
|
|
806
807
|
sendTo,
|
|
807
808
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
808
809
|
notification
|
|
@@ -872,7 +873,7 @@ var createNewAssignmentNotification = async ({
|
|
|
872
873
|
data,
|
|
873
874
|
profile
|
|
874
875
|
}) => {
|
|
875
|
-
var
|
|
876
|
+
var _a2;
|
|
876
877
|
const { assignment, sendTo } = data;
|
|
877
878
|
const teacherName = profile.displayName || "Your teacher";
|
|
878
879
|
const dueDate = assignment.dueDateTimestamp ? dayjs2(assignment.dueDateTimestamp.toDate()).format("MMM Do") : null;
|
|
@@ -883,7 +884,7 @@ var createNewAssignmentNotification = async ({
|
|
|
883
884
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
884
885
|
messagePreview: `A new assignment "${assignment.name}" is now available. ${dueDate ? `Due ${dueDate}` : ""}`,
|
|
885
886
|
title: "New Assignment Available!",
|
|
886
|
-
imageUrl: (
|
|
887
|
+
imageUrl: (_a2 = profile.image) == null ? void 0 : _a2.url
|
|
887
888
|
});
|
|
888
889
|
return results;
|
|
889
890
|
};
|
|
@@ -892,7 +893,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
892
893
|
profile,
|
|
893
894
|
userId
|
|
894
895
|
}) => {
|
|
895
|
-
var
|
|
896
|
+
var _a2;
|
|
896
897
|
const studentName = profile.displayName || "Your student";
|
|
897
898
|
const results = await sendNotification(assignment.owners, {
|
|
898
899
|
courseId: assignment.courseId,
|
|
@@ -901,7 +902,7 @@ var createAssessmentSubmissionNotification = async ({
|
|
|
901
902
|
title: `Assessment Submitted!`,
|
|
902
903
|
senderName: studentName,
|
|
903
904
|
messagePreview: `${studentName} has submitted the assessment "${assignment.name}"`,
|
|
904
|
-
imageUrl: (
|
|
905
|
+
imageUrl: (_a2 = profile.image) == null ? void 0 : _a2.url
|
|
905
906
|
});
|
|
906
907
|
return results;
|
|
907
908
|
};
|
|
@@ -909,7 +910,7 @@ var createAssessmentScoredNotification = async ({
|
|
|
909
910
|
data,
|
|
910
911
|
profile
|
|
911
912
|
}) => {
|
|
912
|
-
var
|
|
913
|
+
var _a2, _b2, _c2, _d2;
|
|
913
914
|
const { assignment, sendTo } = data;
|
|
914
915
|
const teacherName = profile.displayName || "Your teacher";
|
|
915
916
|
const title = `${assignment.isAssessment ? "Assessment" : "Assignment"} Reviewed!`;
|
|
@@ -920,13 +921,13 @@ var createAssessmentScoredNotification = async ({
|
|
|
920
921
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
921
922
|
title,
|
|
922
923
|
messagePreview,
|
|
923
|
-
imageUrl: (
|
|
924
|
+
imageUrl: (_a2 = profile.image) == null ? void 0 : _a2.url,
|
|
924
925
|
senderName: teacherName
|
|
925
926
|
});
|
|
926
|
-
await ((
|
|
927
|
+
await ((_d2 = (_c2 = SpeakableFirebaseFunctions).sendAssessmentScoredEmail) == null ? void 0 : _d2.call(_c2, {
|
|
927
928
|
assessmentTitle: assignment.name,
|
|
928
929
|
link: `${WEB_BASE_URL}/assignment/${assignment.id}`,
|
|
929
|
-
senderImage: ((
|
|
930
|
+
senderImage: ((_b2 = profile.image) == null ? void 0 : _b2.url) || "",
|
|
930
931
|
studentId: sendTo[0],
|
|
931
932
|
teacherName: profile.displayName
|
|
932
933
|
}));
|
|
@@ -941,15 +942,15 @@ var notificationQueryKeys = {
|
|
|
941
942
|
var useCreateNotification = () => {
|
|
942
943
|
const { user, queryClient } = useSpeakableApi();
|
|
943
944
|
const handleCreateNotifications = async (type, data) => {
|
|
944
|
-
var
|
|
945
|
+
var _a2, _b2;
|
|
945
946
|
const result = await createNotification({
|
|
946
947
|
type,
|
|
947
948
|
userId: user.auth.uid,
|
|
948
|
-
profile: (
|
|
949
|
+
profile: (_a2 = user == null ? void 0 : user.profile) != null ? _a2 : {},
|
|
949
950
|
data
|
|
950
951
|
});
|
|
951
952
|
queryClient.invalidateQueries({
|
|
952
|
-
queryKey: notificationQueryKeys.byId((
|
|
953
|
+
queryKey: notificationQueryKeys.byId((_b2 = user == null ? void 0 : user.auth.uid) != null ? _b2 : "")
|
|
953
954
|
});
|
|
954
955
|
return result;
|
|
955
956
|
};
|
|
@@ -1408,8 +1409,8 @@ var SpeakablePlanHierarchy = [
|
|
|
1408
1409
|
var usePermissions = () => {
|
|
1409
1410
|
const { permissions } = useSpeakableApi();
|
|
1410
1411
|
const has = (permission) => {
|
|
1411
|
-
var
|
|
1412
|
-
return (
|
|
1412
|
+
var _a2;
|
|
1413
|
+
return (_a2 = permissions.permissions) == null ? void 0 : _a2.includes(permission);
|
|
1413
1414
|
};
|
|
1414
1415
|
return {
|
|
1415
1416
|
plan: permissions.plan,
|
|
@@ -1440,7 +1441,7 @@ var useGoogleClassroom = () => {
|
|
|
1440
1441
|
googleUserId = null
|
|
1441
1442
|
// optional to override the user's googleUserId
|
|
1442
1443
|
}) => {
|
|
1443
|
-
var
|
|
1444
|
+
var _a2, _b2;
|
|
1444
1445
|
try {
|
|
1445
1446
|
const { googleClassroomUserId = null } = scores;
|
|
1446
1447
|
const googleId = googleUserId || googleClassroomUserId;
|
|
@@ -1451,7 +1452,7 @@ var useGoogleClassroom = () => {
|
|
|
1451
1452
|
};
|
|
1452
1453
|
const { courseWorkId, maxPoints, owners, courseId } = assignment;
|
|
1453
1454
|
const draftGrade = (scores == null ? void 0 : scores.score) ? (scores == null ? void 0 : scores.score) / 100 * maxPoints : 0;
|
|
1454
|
-
const result = await ((
|
|
1455
|
+
const result = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).submitAssignmentToGoogleClassroomV2) == null ? void 0 : _b2.call(_a2, {
|
|
1455
1456
|
teacherId: owners[0],
|
|
1456
1457
|
courseId,
|
|
1457
1458
|
courseWorkId,
|
|
@@ -1470,9 +1471,9 @@ var useGoogleClassroom = () => {
|
|
|
1470
1471
|
|
|
1471
1472
|
// src/lib/firebase/firebase-analytics/grading-standard.ts
|
|
1472
1473
|
var logGradingStandardLog = (data) => {
|
|
1473
|
-
var
|
|
1474
|
+
var _a2, _b2;
|
|
1474
1475
|
if (data.courseId && data.type && data.level) {
|
|
1475
|
-
(
|
|
1476
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).updateCourseAnalytics) == null ? void 0 : _b2.call(_a2, {
|
|
1476
1477
|
eventType: data.type || "custom",
|
|
1477
1478
|
level: data.level,
|
|
1478
1479
|
courseId: data.courseId
|
|
@@ -1508,17 +1509,17 @@ var logOpenActivityPreview = (data = {}) => {
|
|
|
1508
1509
|
api.logEvent("open_activity_preview", data);
|
|
1509
1510
|
};
|
|
1510
1511
|
var logSubmitAssignment = (data = {}) => {
|
|
1511
|
-
var
|
|
1512
|
-
(
|
|
1512
|
+
var _a2, _b2;
|
|
1513
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).updateCourseAnalytics) == null ? void 0 : _b2.call(_a2, {
|
|
1513
1514
|
eventType: ANALYTICS_EVENT_TYPES.SUBMISSION,
|
|
1514
1515
|
...data
|
|
1515
1516
|
});
|
|
1516
1517
|
api.logEvent(ANALYTICS_EVENT_TYPES.SUBMISSION, data);
|
|
1517
1518
|
};
|
|
1518
1519
|
var logStartAssignment = (data = {}) => {
|
|
1519
|
-
var
|
|
1520
|
+
var _a2, _b2;
|
|
1520
1521
|
if (data.courseId) {
|
|
1521
|
-
(
|
|
1522
|
+
(_b2 = (_a2 = SpeakableFirebaseFunctions).updateCourseAnalytics) == null ? void 0 : _b2.call(_a2, {
|
|
1522
1523
|
eventType: ANALYTICS_EVENT_TYPES.ASSIGNMENT_STARTED,
|
|
1523
1524
|
...data
|
|
1524
1525
|
});
|
|
@@ -1559,13 +1560,13 @@ var refsScoresPractice = {
|
|
|
1559
1560
|
|
|
1560
1561
|
// src/domains/assignment/services/create-score.service.ts
|
|
1561
1562
|
async function _createScore(params) {
|
|
1562
|
-
var
|
|
1563
|
+
var _a2, _b2;
|
|
1563
1564
|
if (params.isAssignment) {
|
|
1564
1565
|
const ref = refsAssignmentFiresotre.assignmentScores({
|
|
1565
1566
|
id: params.activityId,
|
|
1566
1567
|
userId: params.userId
|
|
1567
1568
|
});
|
|
1568
|
-
await ((
|
|
1569
|
+
await ((_b2 = (_a2 = SpeakableFirebaseFunctions).updateAssignmentGradebookStatus) == null ? void 0 : _b2.call(_a2, {
|
|
1569
1570
|
assignmentId: params.activityId,
|
|
1570
1571
|
userId: params.userId,
|
|
1571
1572
|
status: "IN_PROGRESS",
|
|
@@ -1675,10 +1676,10 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1675
1676
|
return acc;
|
|
1676
1677
|
}, 0);
|
|
1677
1678
|
const totalPointsAwarded = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
|
|
1678
|
-
var
|
|
1679
|
-
const cardScores = (
|
|
1679
|
+
var _a2, _b2;
|
|
1680
|
+
const cardScores = (_a2 = scores == null ? void 0 : scores.cards) == null ? void 0 : _a2[cardId];
|
|
1680
1681
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1681
|
-
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;
|
|
1682
1683
|
const weight = (weights == null ? void 0 : weights[cardId]) || 1;
|
|
1683
1684
|
const fraction = (score2 != null ? score2 : 0) / 100;
|
|
1684
1685
|
if (score2 || score2 === 0) {
|
|
@@ -1690,8 +1691,8 @@ var calculateScoreAndProgress = (scores, cardsList, weights) => {
|
|
|
1690
1691
|
return acc;
|
|
1691
1692
|
}, 0);
|
|
1692
1693
|
const totalCompletedCards = Object.keys((scores == null ? void 0 : scores.cards) || {}).reduce((acc, cardId) => {
|
|
1693
|
-
var
|
|
1694
|
-
const cardScores = (
|
|
1694
|
+
var _a2;
|
|
1695
|
+
const cardScores = (_a2 = scores == null ? void 0 : scores.cards) == null ? void 0 : _a2[cardId];
|
|
1695
1696
|
if ((cardScores == null ? void 0 : cardScores.completed) || (cardScores == null ? void 0 : cardScores.score) || (cardScores == null ? void 0 : cardScores.score) === 0) {
|
|
1696
1697
|
acc += 1;
|
|
1697
1698
|
}
|
|
@@ -1748,22 +1749,22 @@ var updateCardScore = withErrorHandler(_updateCardScore, "updateCardScore");
|
|
|
1748
1749
|
// src/domains/assignment/services/clear-score.service.ts
|
|
1749
1750
|
import dayjs3 from "dayjs";
|
|
1750
1751
|
async function clearScore(params) {
|
|
1751
|
-
var
|
|
1752
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
1752
1753
|
const update = {
|
|
1753
1754
|
[`cards.${params.cardId}`]: {
|
|
1754
|
-
attempts: (
|
|
1755
|
-
correct: (
|
|
1755
|
+
attempts: (_a2 = params.cardScores.attempts) != null ? _a2 : 1,
|
|
1756
|
+
correct: (_b2 = params.cardScores.correct) != null ? _b2 : 0,
|
|
1756
1757
|
// save old score history
|
|
1757
1758
|
history: [
|
|
1758
1759
|
{
|
|
1759
1760
|
...params.cardScores,
|
|
1760
|
-
attempts: (
|
|
1761
|
-
correct: (
|
|
1761
|
+
attempts: (_c2 = params.cardScores.attempts) != null ? _c2 : 1,
|
|
1762
|
+
correct: (_d2 = params.cardScores.correct) != null ? _d2 : 0,
|
|
1762
1763
|
retryTime: dayjs3().format("YYYY-MM-DD HH:mm:ss"),
|
|
1763
1764
|
history: null
|
|
1764
1765
|
},
|
|
1765
1766
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1766
|
-
...(
|
|
1767
|
+
...(_e2 = params.cardScores.history) != null ? _e2 : []
|
|
1767
1768
|
]
|
|
1768
1769
|
}
|
|
1769
1770
|
};
|
|
@@ -1820,7 +1821,7 @@ var submitAssignmentScore = withErrorHandler(
|
|
|
1820
1821
|
"submitAssignmentScore"
|
|
1821
1822
|
);
|
|
1822
1823
|
async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpdated, studentName) {
|
|
1823
|
-
var
|
|
1824
|
+
var _a2, _b2;
|
|
1824
1825
|
const path = refsAssignmentFiresotre.assignmentScores({ id: assignment.id, userId });
|
|
1825
1826
|
const response = await api.getDoc(path);
|
|
1826
1827
|
if (!response.data) {
|
|
@@ -1828,7 +1829,7 @@ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpda
|
|
|
1828
1829
|
}
|
|
1829
1830
|
const { score: scoreCalculated } = calculateScoreAndProgress_default(response.data, cardIds, weights);
|
|
1830
1831
|
await api.updateDoc(path, { score: scoreCalculated, status: "PENDING_REVIEW" });
|
|
1831
|
-
await ((
|
|
1832
|
+
await ((_b2 = (_a2 = SpeakableFirebaseFunctions).submitAssessment) == null ? void 0 : _b2.call(_a2, {
|
|
1832
1833
|
assignmentId: assignment.id,
|
|
1833
1834
|
assignmentTitle: assignment.name,
|
|
1834
1835
|
userId,
|
|
@@ -1839,8 +1840,8 @@ async function handleAssessment(assignment, userId, cardIds, weights, fieldsUpda
|
|
|
1839
1840
|
return { success: true, fieldsUpdated };
|
|
1840
1841
|
}
|
|
1841
1842
|
async function handleCourseAssignment(assignment, userId) {
|
|
1842
|
-
var
|
|
1843
|
-
await ((
|
|
1843
|
+
var _a2, _b2;
|
|
1844
|
+
await ((_b2 = (_a2 = SpeakableFirebaseFunctions) == null ? void 0 : _a2.submitAssignmentV2) == null ? void 0 : _b2.call(_a2, {
|
|
1844
1845
|
assignmentId: assignment.id,
|
|
1845
1846
|
userId
|
|
1846
1847
|
}));
|
|
@@ -1985,8 +1986,8 @@ var getScoreUpdated = ({
|
|
|
1985
1986
|
cardIds,
|
|
1986
1987
|
weights
|
|
1987
1988
|
}) => {
|
|
1988
|
-
var
|
|
1989
|
-
const previousCard = (
|
|
1989
|
+
var _a2, _b2;
|
|
1990
|
+
const previousCard = (_a2 = previousScores.cards) == null ? void 0 : _a2[cardId];
|
|
1990
1991
|
const newCardScore = {
|
|
1991
1992
|
...previousCard != null ? previousCard : {},
|
|
1992
1993
|
...cardScore
|
|
@@ -1994,7 +1995,7 @@ var getScoreUpdated = ({
|
|
|
1994
1995
|
const newScores = {
|
|
1995
1996
|
...previousScores,
|
|
1996
1997
|
cards: {
|
|
1997
|
-
...(
|
|
1998
|
+
...(_b2 = previousScores.cards) != null ? _b2 : {},
|
|
1998
1999
|
[cardId]: newCardScore
|
|
1999
2000
|
}
|
|
2000
2001
|
};
|
|
@@ -2013,8 +2014,8 @@ var handleOptimisticScore = ({
|
|
|
2013
2014
|
cardIds,
|
|
2014
2015
|
weights
|
|
2015
2016
|
}) => {
|
|
2016
|
-
var
|
|
2017
|
-
let cards = { ...(
|
|
2017
|
+
var _a2;
|
|
2018
|
+
let cards = { ...(_a2 = score == null ? void 0 : score.cards) != null ? _a2 : {} };
|
|
2018
2019
|
cards = {
|
|
2019
2020
|
...cards,
|
|
2020
2021
|
[cardId]: {
|
|
@@ -2038,9 +2039,9 @@ function useClearScore() {
|
|
|
2038
2039
|
const mutation = useMutation2({
|
|
2039
2040
|
mutationFn: clearScore,
|
|
2040
2041
|
onSettled: (result) => {
|
|
2041
|
-
var
|
|
2042
|
+
var _a2;
|
|
2042
2043
|
queryClient.invalidateQueries({
|
|
2043
|
-
queryKey: scoreQueryKeys.byId((
|
|
2044
|
+
queryKey: scoreQueryKeys.byId((_a2 = result == null ? void 0 : result.activityId) != null ? _a2 : "")
|
|
2044
2045
|
});
|
|
2045
2046
|
}
|
|
2046
2047
|
});
|
|
@@ -2189,7 +2190,7 @@ function useActivity({
|
|
|
2189
2190
|
onAssignmentSubmitted,
|
|
2190
2191
|
ltiData
|
|
2191
2192
|
}) {
|
|
2192
|
-
var
|
|
2193
|
+
var _a2, _b2;
|
|
2193
2194
|
const { queryClient, user } = useSpeakableApi();
|
|
2194
2195
|
const userId = user.auth.uid;
|
|
2195
2196
|
const assignmentQuery = useAssignment({
|
|
@@ -2198,7 +2199,7 @@ function useActivity({
|
|
|
2198
2199
|
enabled: isAssignment
|
|
2199
2200
|
});
|
|
2200
2201
|
const activeAssignment = assignmentQuery.data;
|
|
2201
|
-
const setId = isAssignment ? (
|
|
2202
|
+
const setId = isAssignment ? (_a2 = activeAssignment == null ? void 0 : activeAssignment.setId) != null ? _a2 : "" : id;
|
|
2202
2203
|
const querySet = useSet({ setId });
|
|
2203
2204
|
const setData = querySet.data;
|
|
2204
2205
|
const assignmentContent = activeAssignment == null ? void 0 : activeAssignment.content;
|
|
@@ -2207,7 +2208,7 @@ function useActivity({
|
|
|
2207
2208
|
const setWeights = setData == null ? void 0 : setData.weights;
|
|
2208
2209
|
const contentCardsToUse = isAssignment ? assignmentContent != null ? assignmentContent : setContent : setContent;
|
|
2209
2210
|
const weightsToUse = isAssignment ? assignmentWeights != null ? assignmentWeights : setWeights : setWeights;
|
|
2210
|
-
const activityId = isAssignment ? (
|
|
2211
|
+
const activityId = isAssignment ? (_b2 = activeAssignment == null ? void 0 : activeAssignment.id) != null ? _b2 : "" : setId;
|
|
2211
2212
|
const { cardsObject, cardsQueries, cards } = useCards({
|
|
2212
2213
|
cardIds: contentCardsToUse != null ? contentCardsToUse : [],
|
|
2213
2214
|
enabled: querySet.isSuccess,
|
|
@@ -2250,13 +2251,13 @@ function useActivity({
|
|
|
2250
2251
|
cardId,
|
|
2251
2252
|
wasCompleted = true
|
|
2252
2253
|
}) => {
|
|
2253
|
-
var
|
|
2254
|
+
var _a3, _b3;
|
|
2254
2255
|
const currentCard = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2255
2256
|
if ((currentCard == null ? void 0 : currentCard.type) === "MULTIPLE_CHOICE" /* MULTIPLE_CHOICE */ || (currentCard == null ? void 0 : currentCard.type) === "READ_REPEAT" /* READ_REPEAT */) {
|
|
2256
2257
|
return;
|
|
2257
2258
|
}
|
|
2258
2259
|
const queryKeys = scoreQueryKeys.byId(activityId);
|
|
2259
|
-
const activeCardScores = (
|
|
2260
|
+
const activeCardScores = (_b3 = (_a3 = queryClient.getQueryData(queryKeys)) == null ? void 0 : _a3.cards) == null ? void 0 : _b3[cardId];
|
|
2260
2261
|
if (activeCardScores === void 0) return;
|
|
2261
2262
|
mutationClearScore.mutate({
|
|
2262
2263
|
isAssignment,
|
|
@@ -2267,11 +2268,11 @@ function useActivity({
|
|
|
2267
2268
|
});
|
|
2268
2269
|
};
|
|
2269
2270
|
const onSubmitScore = async () => {
|
|
2270
|
-
var
|
|
2271
|
+
var _a3, _b3, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2;
|
|
2271
2272
|
try {
|
|
2272
2273
|
let results;
|
|
2273
2274
|
if (isAssignment) {
|
|
2274
|
-
const cardScores = ((
|
|
2275
|
+
const cardScores = ((_a3 = scoreQuery.data) == null ? void 0 : _a3.cards) || {};
|
|
2275
2276
|
const hasPendingReview = Object.values(cardScores).some(
|
|
2276
2277
|
(cardScore) => cardScore.status === "pending_review"
|
|
2277
2278
|
);
|
|
@@ -2283,18 +2284,18 @@ function useActivity({
|
|
|
2283
2284
|
weights: weightsToUse != null ? weightsToUse : {},
|
|
2284
2285
|
status: hasPendingReview ? "PENDING_REVIEW" : "FINALIZED"
|
|
2285
2286
|
});
|
|
2286
|
-
if ((
|
|
2287
|
+
if ((_b3 = assignmentQuery.data) == null ? void 0 : _b3.ltiDeeplink) {
|
|
2287
2288
|
submitLTIScore({
|
|
2288
|
-
maxPoints: (
|
|
2289
|
-
score: (
|
|
2290
|
-
SERVICE_KEY: (
|
|
2291
|
-
lineItemId: (
|
|
2292
|
-
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 : ""
|
|
2293
2294
|
});
|
|
2294
2295
|
}
|
|
2295
2296
|
} else {
|
|
2296
2297
|
results = await submitPracticeScore2({
|
|
2297
|
-
setId: (
|
|
2298
|
+
setId: (_j2 = (_i2 = querySet.data) == null ? void 0 : _i2.id) != null ? _j2 : "",
|
|
2298
2299
|
userId,
|
|
2299
2300
|
scores: scoreQuery.data
|
|
2300
2301
|
});
|
|
@@ -2312,23 +2313,23 @@ function useActivity({
|
|
|
2312
2313
|
gradingStandard,
|
|
2313
2314
|
type
|
|
2314
2315
|
}) => {
|
|
2315
|
-
var
|
|
2316
|
+
var _a3, _b3, _c2, _d2, _e2, _f2, _g2, _h2;
|
|
2316
2317
|
const card = cardsObject == null ? void 0 : cardsObject[cardId];
|
|
2317
2318
|
const scoresObject = queryClient.getQueryData(scoreQueryKeys.byId(activityId));
|
|
2318
|
-
const cardScore = (
|
|
2319
|
+
const cardScore = (_a3 = scoresObject == null ? void 0 : scoresObject.cards) == null ? void 0 : _a3[cardId];
|
|
2319
2320
|
const serverTimestamp2 = api.helpers.serverTimestamp;
|
|
2320
2321
|
addGradingStandardLog(
|
|
2321
2322
|
{
|
|
2322
|
-
assignmentId: (
|
|
2323
|
-
courseId: (
|
|
2324
|
-
teacherId: (
|
|
2325
|
-
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 : "",
|
|
2326
2327
|
cardId,
|
|
2327
2328
|
level: gradingStandard.level,
|
|
2328
2329
|
justification: gradingStandard.justification,
|
|
2329
|
-
transcript: (
|
|
2330
|
-
audioUrl: (
|
|
2331
|
-
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 : "",
|
|
2332
2333
|
responseType: (card == null ? void 0 : card.type) === "RESPOND_WRITE" /* RESPOND_WRITE */ ? "written" : "spoken",
|
|
2333
2334
|
type,
|
|
2334
2335
|
dateMade: serverTimestamp2()
|
|
@@ -2384,11 +2385,11 @@ var useInitActivity = ({
|
|
|
2384
2385
|
}) => {
|
|
2385
2386
|
const { trackActivity } = useActivityTracker({ userId });
|
|
2386
2387
|
const init = () => {
|
|
2387
|
-
var
|
|
2388
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
2388
2389
|
if (!enabled) return;
|
|
2389
2390
|
if (!assignment) {
|
|
2390
2391
|
trackActivity({
|
|
2391
|
-
activityName: (
|
|
2392
|
+
activityName: (_a2 = set == null ? void 0 : set.name) != null ? _a2 : "",
|
|
2392
2393
|
activityType: "set",
|
|
2393
2394
|
id: set == null ? void 0 : set.id,
|
|
2394
2395
|
language: set == null ? void 0 : set.language
|
|
@@ -2402,12 +2403,12 @@ var useInitActivity = ({
|
|
|
2402
2403
|
});
|
|
2403
2404
|
}
|
|
2404
2405
|
if (set == null ? void 0 : set.public) {
|
|
2405
|
-
(
|
|
2406
|
+
(_c2 = (_b2 = SpeakableFirebaseFunctions) == null ? void 0 : _b2.onSetOpened) == null ? void 0 : _c2.call(_b2, {
|
|
2406
2407
|
setId: set.id,
|
|
2407
2408
|
language: set.language
|
|
2408
2409
|
});
|
|
2409
2410
|
}
|
|
2410
|
-
(
|
|
2411
|
+
(_e2 = (_d2 = SpeakableFirebaseFunctions) == null ? void 0 : _d2.updateAlgoliaIndex) == null ? void 0 : _e2.call(_d2, {
|
|
2411
2412
|
updatePlays: true,
|
|
2412
2413
|
objectID: set == null ? void 0 : set.id
|
|
2413
2414
|
});
|
|
@@ -2423,13 +2424,13 @@ var submitLTIScore = async ({
|
|
|
2423
2424
|
lineItemId,
|
|
2424
2425
|
lti_id
|
|
2425
2426
|
}) => {
|
|
2426
|
-
var
|
|
2427
|
+
var _a2, _b2;
|
|
2427
2428
|
try {
|
|
2428
2429
|
if (!SERVICE_KEY || !lineItemId || !lti_id) {
|
|
2429
2430
|
throw new Error("Missing required LTI credentials");
|
|
2430
2431
|
}
|
|
2431
2432
|
const earnedPoints = score ? score / 100 * maxPoints : 0;
|
|
2432
|
-
const { data } = await ((
|
|
2433
|
+
const { data } = await ((_b2 = (_a2 = SpeakableFirebaseFunctions) == null ? void 0 : _a2.submitLTIAssignmentScore) == null ? void 0 : _b2.call(_a2, {
|
|
2433
2434
|
SERVICE_KEY,
|
|
2434
2435
|
scoreData: {
|
|
2435
2436
|
lineItemId,
|
|
@@ -2607,19 +2608,19 @@ var useActivityFeedbackAccess = ({
|
|
|
2607
2608
|
aiEnabled = false,
|
|
2608
2609
|
isActivityRoute = false
|
|
2609
2610
|
}) => {
|
|
2610
|
-
var
|
|
2611
|
+
var _a2, _b2, _c2;
|
|
2611
2612
|
const { user } = useSpeakableApi();
|
|
2612
2613
|
const uid = user.auth.uid;
|
|
2613
|
-
const isTeacher = (
|
|
2614
|
-
const isStudent = (
|
|
2615
|
-
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) || [];
|
|
2616
2617
|
const query2 = useQuery6({
|
|
2617
2618
|
queryKey: activityFeedbackAccessQueryKeys.activityFeedbackAccess({
|
|
2618
2619
|
aiEnabled,
|
|
2619
2620
|
isActivityRoute
|
|
2620
2621
|
}),
|
|
2621
2622
|
queryFn: async () => {
|
|
2622
|
-
var
|
|
2623
|
+
var _a3, _b3;
|
|
2623
2624
|
if (!uid) {
|
|
2624
2625
|
return {
|
|
2625
2626
|
canAccessFeedback: false,
|
|
@@ -2647,7 +2648,7 @@ var useActivityFeedbackAccess = ({
|
|
|
2647
2648
|
}
|
|
2648
2649
|
if (isStudent && isActivityRoute) {
|
|
2649
2650
|
try {
|
|
2650
|
-
const result = await ((
|
|
2651
|
+
const result = await ((_b3 = (_a3 = SpeakableFirebaseFunctions) == null ? void 0 : _a3.checkStudentTeacherPlan) == null ? void 0 : _b3.call(_a3, {
|
|
2651
2652
|
studentId: uid
|
|
2652
2653
|
}));
|
|
2653
2654
|
const planCheckResult = result.data;
|
|
@@ -2723,14 +2724,15 @@ var useBaseOpenAI = ({
|
|
|
2723
2724
|
});
|
|
2724
2725
|
const getTranscript = async (audioUrl, language) => {
|
|
2725
2726
|
try {
|
|
2726
|
-
const response = await getAssemblyAITranscript({
|
|
2727
|
+
const response = await (getAssemblyAITranscript == null ? void 0 : getAssemblyAITranscript({
|
|
2727
2728
|
audioUrl,
|
|
2728
2729
|
language
|
|
2729
|
-
});
|
|
2730
|
+
}));
|
|
2730
2731
|
console.log("response (getTranscript) from getAssemblyAITranscript", {
|
|
2731
2732
|
response,
|
|
2732
2733
|
audioUrl,
|
|
2733
|
-
language
|
|
2734
|
+
language,
|
|
2735
|
+
getAssemblyAITranscript
|
|
2734
2736
|
});
|
|
2735
2737
|
const transcript = response == null ? void 0 : response.data;
|
|
2736
2738
|
onTranscriptSuccess(transcript);
|
|
@@ -2745,7 +2747,7 @@ var useBaseOpenAI = ({
|
|
|
2745
2747
|
}
|
|
2746
2748
|
};
|
|
2747
2749
|
const getFreeResponseCompletion = async (messages, isFreeResponse, feedbackLanguage, gradingStandard = "actfl") => {
|
|
2748
|
-
var
|
|
2750
|
+
var _a2, _b2, _c2, _d2, _e2;
|
|
2749
2751
|
const responseTool = getRespondCardTool({
|
|
2750
2752
|
language: feedbackLanguage,
|
|
2751
2753
|
standard: gradingStandard
|
|
@@ -2759,7 +2761,7 @@ var useBaseOpenAI = ({
|
|
|
2759
2761
|
success: aiSuccess = false
|
|
2760
2762
|
// the AI was able to generate a response
|
|
2761
2763
|
}
|
|
2762
|
-
} = await ((
|
|
2764
|
+
} = await ((_b2 = (_a2 = SpeakableFirebaseFunctions).createChatCompletion) == null ? void 0 : _b2.call(_a2, {
|
|
2763
2765
|
chat: {
|
|
2764
2766
|
model: isFreeResponse ? "gpt-4-1106-preview" : "gpt-3.5-turbo-1106",
|
|
2765
2767
|
messages,
|
|
@@ -2768,7 +2770,7 @@ var useBaseOpenAI = ({
|
|
|
2768
2770
|
},
|
|
2769
2771
|
type: isFreeResponse ? "LONG_RESPONSE" : "SHORT_RESPONSE"
|
|
2770
2772
|
}));
|
|
2771
|
-
const functionArguments = JSON.parse(((
|
|
2773
|
+
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) || "{}");
|
|
2772
2774
|
const result = {
|
|
2773
2775
|
...functionArguments,
|
|
2774
2776
|
prompt_tokens,
|
|
@@ -2853,7 +2855,7 @@ var useBaseOpenAI = ({
|
|
|
2853
2855
|
}
|
|
2854
2856
|
};
|
|
2855
2857
|
const getAIResponse = async ({ cardId, transcript }) => {
|
|
2856
|
-
var
|
|
2858
|
+
var _a2;
|
|
2857
2859
|
try {
|
|
2858
2860
|
const card = getCardFromCache({
|
|
2859
2861
|
cardId,
|
|
@@ -2877,7 +2879,7 @@ var useBaseOpenAI = ({
|
|
|
2877
2879
|
]);
|
|
2878
2880
|
proficiencyData = (proficiencyResult == null ? void 0 : proficiencyResult.data) || {};
|
|
2879
2881
|
feedbackData = {
|
|
2880
|
-
...(
|
|
2882
|
+
...(_a2 = geminiResult == null ? void 0 : geminiResult.data) != null ? _a2 : {},
|
|
2881
2883
|
// @ts-ignore
|
|
2882
2884
|
proficiency_level: (proficiencyData == null ? void 0 : proficiencyData.proficiency_level) || null
|
|
2883
2885
|
};
|