@khanacademy/perseus-score 8.0.10 → 8.1.1

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/score.d.ts CHANGED
@@ -1,15 +1,10 @@
1
1
  import type { PerseusRenderer, PerseusScore, PerseusWidgetsMap, UserInputMap } from "@khanacademy/perseus-core";
2
- /**
3
- * If a widget says that it is empty once it is graded.
4
- * Trying to encapsulate references to the score format.
5
- */
6
- export declare function scoreIsEmpty(score: PerseusScore): boolean;
7
- export declare function flattenScores(widgetScoreMap: {
8
- [widgetId: string]: PerseusScore;
9
- }): PerseusScore;
10
2
  /**
11
3
  * score a Perseus item
12
4
  *
5
+ * TODO: this should be named differently -
6
+ * it's scoring UserInput, not a PerseusItem; also it doesn't take a PerseusItem
7
+ *
13
8
  * @param perseusRenderData - the full answer data, includes the correct answer
14
9
  * @param userInputMap - the user's input for each widget, mapped by ID
15
10
  * @param locale - string locale for math parsing ("de" 1.000,00 vs "en" 1,000.00)
@@ -0,0 +1,4 @@
1
+ import type { PerseusScore } from "@khanacademy/perseus-core";
2
+ export default function flattenScores(widgetScoreMap: {
3
+ [widgetId: string]: PerseusScore;
4
+ }): PerseusScore;
@@ -0,0 +1,9 @@
1
+ import type { PerseusRenderer, PerseusWidgetsMap } from "@khanacademy/perseus-core";
2
+ /**
3
+ * Returns the upgraded widgets and the IDs of widgets that should be scored.
4
+ * Filters out widgets not referenced in content and widgets that are static or ungraded.
5
+ */
6
+ export default function getScoreableWidgets(perseusRenderData: PerseusRenderer): {
7
+ upgradedWidgets: PerseusWidgetsMap;
8
+ scoreableWidgetIds: ReadonlyArray<string>;
9
+ };
@@ -0,0 +1,6 @@
1
+ import type { PerseusWidget } from "@khanacademy/perseus-core";
2
+ /**
3
+ * Determines if a widget should be scored/validated.
4
+ * Widgets that are ungraded or static should not be scored.
5
+ */
6
+ export default function isWidgetScoreable(widget: PerseusWidget | undefined): boolean;
@@ -0,0 +1,6 @@
1
+ import type { PerseusScore } from "@khanacademy/perseus-core";
2
+ /**
3
+ * If a widget says that it is empty once it is graded.
4
+ * Trying to encapsulate references to the score format.
5
+ */
6
+ export default function scoreIsEmpty(score: PerseusScore): boolean;
@@ -1,7 +1,17 @@
1
- import type { UserInputMap, ValidationDataMap } from "@khanacademy/perseus-core";
1
+ import type { PerseusRenderer, PerseusScore, PerseusWidgetsMap, UserInputMap } from "@khanacademy/perseus-core";
2
+ /**
3
+ * validate, meant for client-side validation using answerless Perseus data
4
+ *
5
+ * @param perseusRenderData - the answerless Perseus data
6
+ * @param userInputMap - the user's input for each widget, mapped by ID
7
+ * @param locale - string locale for math parsing ("de" 1.000,00 vs "en" 1,000.00)
8
+ *
9
+ * @returns an invalid "score" if there's invalid input, otherwise null
10
+ */
11
+ export declare function validateUserInput(perseusRenderData: PerseusRenderer, userInputMap: UserInputMap, locale: string): PerseusScore | null;
2
12
  /**
3
13
  * Checks the given user input to see if any answerable widgets have not been
4
14
  * "filled in" (ie. if they're empty). Another way to think about this
5
15
  * function is that its a check to see if we can score the provided input.
6
16
  */
7
- export declare function emptyWidgetsFunctional(widgets: ValidationDataMap, widgetIds: ReadonlyArray<string>, userInputMap: UserInputMap, locale: string): ReadonlyArray<string>;
17
+ export declare function emptyWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: ReadonlyArray<string>, userInputMap: UserInputMap, locale: string): ReadonlyArray<string>;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Perseus score",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "8.0.10",
6
+ "version": "8.1.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,8 +23,8 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@khanacademy/kas": "2.1.6",
26
- "@khanacademy/kmath": "2.2.21",
27
- "@khanacademy/perseus-core": "20.4.1",
26
+ "@khanacademy/kmath": "2.2.23",
27
+ "@khanacademy/perseus-core": "21.0.1",
28
28
  "@khanacademy/perseus-utils": "2.1.4"
29
29
  },
30
30
  "devDependencies": {