@speakableio/core 1.0.31 → 1.0.33

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.
@@ -95,7 +95,7 @@ interface PageActivity {
95
95
  media_area_layout?: 'left' | 'right' | null;
96
96
  media_mode?: 'single' | 'media_area' | 'none' | null;
97
97
  media?: {
98
- type: 'image' | 'video';
98
+ type: 'image' | 'video' | 'link';
99
99
  url: string;
100
100
  } | null;
101
101
  score?: number;
@@ -198,7 +198,7 @@ declare function useCards({ cardIds, enabled, asObject, }: {
198
198
  media_area_layout?: "left" | "right" | null;
199
199
  media_mode?: "single" | "media_area" | "none" | null;
200
200
  media?: {
201
- type: "image" | "video";
201
+ type: "image" | "video" | "link";
202
202
  url: string;
203
203
  } | null;
204
204
  score?: number;
@@ -278,7 +278,7 @@ declare function useCreateCards(): {
278
278
  media_area_layout?: "left" | "right" | null;
279
279
  media_mode?: "single" | "media_area" | "none" | null;
280
280
  media?: {
281
- type: "image" | "video";
281
+ type: "image" | "video" | "link";
282
282
  url: string;
283
283
  } | null;
284
284
  score?: number;
@@ -366,7 +366,7 @@ declare function useGetCard({ cardId, enabled }: {
366
366
  media_area_layout?: "left" | "right" | null;
367
367
  media_mode?: "single" | "media_area" | "none" | null;
368
368
  media?: {
369
- type: "image" | "video";
369
+ type: "image" | "video" | "link";
370
370
  url: string;
371
371
  } | null;
372
372
  score?: number;
@@ -446,7 +446,7 @@ declare const createCardRepo: () => {
446
446
  media_area_layout?: "left" | "right" | null;
447
447
  media_mode?: "single" | "media_area" | "none" | null;
448
448
  media?: {
449
- type: "image" | "video";
449
+ type: "image" | "video" | "link";
450
450
  url: string;
451
451
  } | null;
452
452
  score?: number;
@@ -521,7 +521,7 @@ declare const createCardRepo: () => {
521
521
  media_area_layout?: "left" | "right" | null;
522
522
  media_mode?: "single" | "media_area" | "none" | null;
523
523
  media?: {
524
- type: "image" | "video";
524
+ type: "image" | "video" | "link";
525
525
  url: string;
526
526
  } | null;
527
527
  score?: number;
@@ -622,21 +622,21 @@ declare function getPageMediaData(page: PageActivityWithId): {
622
622
  mode: "single" | "media_area" | "none" | null;
623
623
  singleMedia: {
624
624
  rawObject: {
625
- type: "image" | "video";
625
+ type: "image" | "video" | "link";
626
626
  url: string;
627
627
  };
628
- type: "image" | "video";
628
+ type: "image" | "video" | "link";
629
629
  content: string;
630
630
  } | undefined;
631
631
  isMediaPage: boolean;
632
- hasMediaData: boolean;
632
+ hasMediaData: string | boolean;
633
633
  };
634
634
  declare function getSingleMediaPageData(page: PageActivityWithId): {
635
635
  rawObject: {
636
- type: "image" | "video";
636
+ type: "image" | "video" | "link";
637
637
  url: string;
638
638
  };
639
- type: "image" | "video";
639
+ type: "image" | "video" | "link";
640
640
  content: string;
641
641
  } | undefined;
642
642
 
@@ -1373,7 +1373,7 @@ declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
1373
1373
  media_area_layout?: "left" | "right" | null;
1374
1374
  media_mode?: "single" | "media_area" | "none" | null;
1375
1375
  media?: {
1376
- type: "image" | "video";
1376
+ type: "image" | "video" | "link";
1377
1377
  url: string;
1378
1378
  } | null;
1379
1379
  score?: number;
@@ -1448,7 +1448,7 @@ declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
1448
1448
  media_area_layout?: "left" | "right" | null;
1449
1449
  media_mode?: "single" | "media_area" | "none" | null;
1450
1450
  media?: {
1451
- type: "image" | "video";
1451
+ type: "image" | "video" | "link";
1452
1452
  url: string;
1453
1453
  } | null;
1454
1454
  score?: number;
@@ -1706,7 +1706,7 @@ declare function useActivity({ id, isAssignment, onAssignmentSubmitted, ltiData,
1706
1706
  media_area_layout?: "left" | "right" | null;
1707
1707
  media_mode?: "single" | "media_area" | "none" | null;
1708
1708
  media?: {
1709
- type: "image" | "video";
1709
+ type: "image" | "video" | "link";
1710
1710
  url: string;
1711
1711
  } | null;
1712
1712
  score?: number;
@@ -3252,7 +3252,7 @@ declare const createFsClientWeb: ({ db, httpsCallable, logEvent }: FsClientParam
3252
3252
  media_area_layout?: "left" | "right" | null;
3253
3253
  media_mode?: "single" | "media_area" | "none" | null;
3254
3254
  media?: {
3255
- type: "image" | "video";
3255
+ type: "image" | "video" | "link";
3256
3256
  url: string;
3257
3257
  } | null;
3258
3258
  score?: number;
@@ -3327,7 +3327,7 @@ declare const createFsClientWeb: ({ db, httpsCallable, logEvent }: FsClientParam
3327
3327
  media_area_layout?: "left" | "right" | null;
3328
3328
  media_mode?: "single" | "media_area" | "none" | null;
3329
3329
  media?: {
3330
- type: "image" | "video";
3330
+ type: "image" | "video" | "link";
3331
3331
  url: string;
3332
3332
  } | null;
3333
3333
  score?: number;
package/dist/index.web.js CHANGED
@@ -2090,7 +2090,7 @@ function getPageMediaData(page) {
2090
2090
  const { isMediaPage } = checkTypePageActivity(page.type);
2091
2091
  const mode = (_b = page.media_mode) != null ? _b : page.media_area_id ? "media_area" : null;
2092
2092
  const singleMedia = getSingleMediaPageData(page);
2093
- const hasMediaData = isMediaPage || singleMedia !== void 0;
2093
+ const hasMediaData = !!page.media_area_id || page.media_area_context_ref || singleMedia !== void 0;
2094
2094
  return {
2095
2095
  direction,
2096
2096
  mode,
@@ -3568,11 +3568,45 @@ var useBaseOpenAI = ({
3568
3568
  throw new Error(error);
3569
3569
  }
3570
3570
  };
3571
- const getAIResponse = async ({ cardId, transcript }) => {
3572
- var _a, _b, _c, _d, _e;
3571
+ const onGetGeminiFeedback = async ({
3572
+ cardId,
3573
+ studentId,
3574
+ studentResponse
3575
+ }) => {
3576
+ var _a, _b;
3573
3577
  try {
3574
3578
  const getGeminiFeedback = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "callGetFeedback");
3575
- const getProficiencyEstimate = (_d = (_c = api).httpsCallable) == null ? void 0 : _d.call(_c, "getProficiencyEstimate");
3579
+ return await (getGeminiFeedback == null ? void 0 : getGeminiFeedback({
3580
+ cardId,
3581
+ studentId,
3582
+ studentResponse
3583
+ }));
3584
+ } catch (error) {
3585
+ console.error("Error getting Gemini feedback:", error);
3586
+ return {};
3587
+ }
3588
+ };
3589
+ const onGetProficiencyEstimate = async ({
3590
+ cardId,
3591
+ studentId,
3592
+ studentResponse
3593
+ }) => {
3594
+ var _a, _b;
3595
+ try {
3596
+ const getProficiencyEstimate = (_b = (_a = api).httpsCallable) == null ? void 0 : _b.call(_a, "getProficiencyEstimate");
3597
+ return await (getProficiencyEstimate == null ? void 0 : getProficiencyEstimate({
3598
+ cardId,
3599
+ studentId,
3600
+ studentResponse
3601
+ }));
3602
+ } catch (error) {
3603
+ console.error("Error getting proficiency estimate:", error);
3604
+ return {};
3605
+ }
3606
+ };
3607
+ const getAIResponse = async ({ cardId, transcript }) => {
3608
+ var _a;
3609
+ try {
3576
3610
  const card = getCardFromCache({
3577
3611
  cardId,
3578
3612
  queryClient
@@ -3582,12 +3616,12 @@ var useBaseOpenAI = ({
3582
3616
  if (card && card.grading_method === "manual") {
3583
3617
  } else if (card && card.grading_method !== "standards_based") {
3584
3618
  const [geminiResult, proficiencyResult] = await Promise.all([
3585
- getGeminiFeedback == null ? void 0 : getGeminiFeedback({
3619
+ onGetGeminiFeedback == null ? void 0 : onGetGeminiFeedback({
3586
3620
  cardId,
3587
3621
  studentId: currentUserId,
3588
3622
  studentResponse: transcript
3589
3623
  }),
3590
- getProficiencyEstimate == null ? void 0 : getProficiencyEstimate({
3624
+ onGetProficiencyEstimate == null ? void 0 : onGetProficiencyEstimate({
3591
3625
  cardId,
3592
3626
  studentId: currentUserId,
3593
3627
  studentResponse: transcript
@@ -3595,12 +3629,12 @@ var useBaseOpenAI = ({
3595
3629
  ]);
3596
3630
  proficiencyData = (proficiencyResult == null ? void 0 : proficiencyResult.data) || {};
3597
3631
  feedbackData = {
3598
- ...(_e = geminiResult == null ? void 0 : geminiResult.data) != null ? _e : {},
3632
+ ...(_a = geminiResult == null ? void 0 : geminiResult.data) != null ? _a : {},
3599
3633
  // @ts-ignore
3600
3634
  proficiency_level: (proficiencyData == null ? void 0 : proficiencyData.proficiency_level) || null
3601
3635
  };
3602
3636
  } else {
3603
- const geminiResult = await (getGeminiFeedback == null ? void 0 : getGeminiFeedback({
3637
+ const geminiResult = await (onGetGeminiFeedback == null ? void 0 : onGetGeminiFeedback({
3604
3638
  cardId,
3605
3639
  studentId: currentUserId,
3606
3640
  studentResponse: transcript