@khanacademy/perseus-score 0.0.0-PR3119-20251211231658 → 0.0.0-PR3119-20251217222259
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/es/index.js +16 -8
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/dist/score.d.ts +3 -8
- package/dist/util/flatten-scores.d.ts +4 -0
- package/dist/util/get-scoreable-widgets.d.ts +9 -0
- package/dist/util/is-widget-scoreable.d.ts +6 -0
- package/dist/util/score-is-empty.d.ts +6 -0
- package/dist/validate.d.ts +12 -2
- package/dist/widgets/deprecated-standin/score-deprecated-standin.d.ts +10 -0
- package/package.json +4 -4
- package/dist/util/score-noop.d.ts +0 -11
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,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;
|
package/dist/validate.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import type {
|
|
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:
|
|
17
|
+
export declare function emptyWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: ReadonlyArray<string>, userInputMap: UserInputMap, locale: string): ReadonlyArray<string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PerseusScore } from "@khanacademy/perseus-core";
|
|
2
|
+
/**
|
|
3
|
+
* Scoring function for deprecated-standin widget.
|
|
4
|
+
*
|
|
5
|
+
* The deprecated-standin widget is used as a placeholder for deprecated widgets
|
|
6
|
+
* to prevent old content from breaking. It always scores as correct (full credit)
|
|
7
|
+
* so that content using deprecated widgets doesn't experience any regressions.
|
|
8
|
+
*/
|
|
9
|
+
declare function scoreDeprecatedStandin(userInput: any, rubric: any, locale: string): PerseusScore;
|
|
10
|
+
export default scoreDeprecatedStandin;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Perseus score",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.0.0-PR3119-
|
|
6
|
+
"version": "0.0.0-PR3119-20251217222259",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@khanacademy/kas": "2.1.6",
|
|
26
|
-
"@khanacademy/kmath": "0.0.0-PR3119-
|
|
27
|
-
"@khanacademy/perseus-
|
|
28
|
-
"@khanacademy/perseus-
|
|
26
|
+
"@khanacademy/kmath": "0.0.0-PR3119-20251217222259",
|
|
27
|
+
"@khanacademy/perseus-core": "0.0.0-PR3119-20251217222259",
|
|
28
|
+
"@khanacademy/perseus-utils": "2.1.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"underscore": "1.4.4",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PerseusScore } from "@khanacademy/perseus-core";
|
|
2
|
-
/**
|
|
3
|
-
* Several widgets don't have "right"/"wrong" scoring logic,
|
|
4
|
-
* so this just says to move on past those widgets
|
|
5
|
-
*
|
|
6
|
-
* TODO(LEMS-2543) widgets that use this probably shouldn't have any
|
|
7
|
-
* scoring logic and the thing scoring an exercise
|
|
8
|
-
* should just know to skip these
|
|
9
|
-
*/
|
|
10
|
-
declare function scoreNoop(points?: number): PerseusScore;
|
|
11
|
-
export default scoreNoop;
|