bloom-player 2.11.6 → 2.12.0

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A library for displaying Bloom books in iframes or WebViews",
4
4
  "author": "SIL Global",
5
5
  "license": "MIT",
6
- "version": "2.11.6",
6
+ "version": "2.12.0",
7
7
  "private": false,
8
8
  "// sideeffects might need to be ['*.css'] to avoid 'shaking' our CSS, if we ever get tree shaking working": "",
9
9
  "sideEffects": false,
@@ -12,6 +12,7 @@
12
12
  // For now, though, it's much easier to just edit them and have them built automatically
13
13
  // than to have this code in another repo.
14
14
 
15
+ import { ActivityManager } from "../activities/activityManager";
15
16
  import {
16
17
  kAudioSentence,
17
18
  playAllAudio,
@@ -458,6 +459,20 @@ export function playInitialElements(page: HTMLElement, playVideos: boolean) {
458
459
  }
459
460
  }
460
461
 
462
+ // Allows a client (currently BloomPlayer) to insert a function that will be called
463
+ // when the user checks the correctness of a page. It should be called every time
464
+ // they check, though currently only the first time on each page counts.
465
+ let reportScore: (possible: number, actual: number) => void = (
466
+ possible,
467
+ actual,
468
+ ) => {};
469
+
470
+ export function setReportScore(
471
+ reportScoreFunction: (possible: number, actual: number) => void,
472
+ ) {
473
+ reportScore = reportScoreFunction;
474
+ }
475
+
461
476
  function getAudioSentences(editables: HTMLElement[]) {
462
477
  // Could be done more cleanly with flatMap or flat() but not ready to switch to es2019 yet.
463
478
  const result: HTMLElement[] = [];
@@ -748,6 +763,10 @@ export const performCheck = (e: MouseEvent) => {
748
763
  const allCorrect = checkDraggables(page) && checkRandomSentences(page);
749
764
 
750
765
  showCorrectOrWrongItems(page, allCorrect);
766
+ // Enhance: plausibly we could count the targets and report the total
767
+ // number and the number that contain the right draggable, but it's more
768
+ // consistent with older games to just report success or failure.
769
+ reportScore(1, allCorrect ? 1 : 0);
751
770
 
752
771
  return allCorrect;
753
772
  };