@khanacademy/perseus-core 11.0.0 → 12.1.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/dist/data-schema.d.ts +13 -1
- package/dist/es/index.js +26 -20
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +28 -19
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/categorizer-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/categorizer-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/free-response-widget.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/grapher-widget.d.ts +2 -1
- package/dist/parse-perseus-json/perseus-parsers/input-number-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/input-number-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/label-image-user-input.d.ts +6 -0
- package/dist/parse-perseus-json/perseus-parsers/label-image-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/matcher-user-input.d.ts +4 -0
- package/dist/parse-perseus-json/perseus-parsers/matcher-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/matrix-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/matrix-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/number-line-user-input.d.ts +7 -0
- package/dist/parse-perseus-json/perseus-parsers/number-line-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/orderer-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/orderer-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/plotter-user-input.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/plotter-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/sorter-user-input.d.ts +4 -0
- package/dist/parse-perseus-json/perseus-parsers/sorter-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/table-user-input.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/table-user-input.typetest.d.ts +1 -0
- package/dist/utils/split-perseus-item.d.ts +10 -0
- package/dist/validation.types.d.ts +9 -1
- package/dist/widgets/free-response/free-response-util.d.ts +17 -0
- package/dist/widgets/free-response/index.d.ts +5 -0
- package/dist/widgets/interactive-graph/index.d.ts +1 -1
- package/dist/widgets/label-image/label-image-util.d.ts +2 -3
- package/dist/widgets/logic-export.types.d.ts +2 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Parser } from "../parser-types";
|
|
2
|
+
export declare const parseGrapherWidget: Parser<import("../..").WidgetOptions<"grapher", import("../general-purpose-parsers/object-types").OptionalizeProperties<{
|
|
2
3
|
availableTypes: ("absolute_value" | "exponential" | "linear" | "logarithm" | "quadratic" | "sinusoid" | "tangent")[];
|
|
3
4
|
correct: import("../general-purpose-parsers/object-types").OptionalizeProperties<{
|
|
4
5
|
type: "absolute_value";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const parseLabelImageUserInput: import("../parser-types").Parser<import("../general-purpose-parsers/object-types").OptionalizeProperties<{
|
|
2
|
+
markers: import("../general-purpose-parsers/object-types").OptionalizeProperties<{
|
|
3
|
+
selected: string[] | undefined;
|
|
4
|
+
label: string;
|
|
5
|
+
}>[];
|
|
6
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const parseNumberLineUserInput: import("../parser-types").Parser<import("../general-purpose-parsers/object-types").OptionalizeProperties<{
|
|
2
|
+
isTickCrtl: boolean | undefined;
|
|
3
|
+
numLinePosition: number;
|
|
4
|
+
rel: "eq" | "lt" | "gt" | "le" | "ge";
|
|
5
|
+
numDivisions: number;
|
|
6
|
+
divisionRange: number[];
|
|
7
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parsePlotterUserInput: import("../parser-types").Parser<number[]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseTableUserInput: import("../parser-types").Parser<string[][]>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,3 +5,13 @@ import type { PerseusItem } from "../data-schema";
|
|
|
5
5
|
* @param original - the original, full PerseusItem (which includes the rubric - aka answer data)
|
|
6
6
|
*/
|
|
7
7
|
export default function splitPerseusItem(original: PerseusItem): PerseusItem;
|
|
8
|
+
/**
|
|
9
|
+
* Returns a JSON copy of a PerseusItem with rubric data (i.e. answers and
|
|
10
|
+
* hints) removed. Idempotent and deterministic.
|
|
11
|
+
*
|
|
12
|
+
* @param data a {@linkcode PerseusItem}, either as JSON or as an object.
|
|
13
|
+
* @returns {string} the answerless data formatted as JSON
|
|
14
|
+
* @throws {SyntaxError} given malformed JSON or data that can't be parsed as
|
|
15
|
+
* a Perseus item.
|
|
16
|
+
*/
|
|
17
|
+
export declare function splitPerseusItemJSON(data: unknown): string;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* } & Perseus<Widget>ValidationData;
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType, MakeWidgetMap } from "./data-schema";
|
|
31
|
+
import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType, MakeWidgetMap, PerseusFreeResponseWidgetScoringCriterion } from "./data-schema";
|
|
32
32
|
import type { Relationship } from "./types";
|
|
33
33
|
export type WidgetValidatorFunction = (userInput: UserInput, validationData: ValidationData, locale: string) => ValidationResult;
|
|
34
34
|
export type WidgetScorerFunction = (userInput: UserInput, rubric: Rubric, locale?: string) => PerseusScore;
|
|
@@ -148,6 +148,13 @@ export type PerseusNumericInputRubric = {
|
|
|
148
148
|
export type PerseusNumericInputUserInput = {
|
|
149
149
|
currentValue: string;
|
|
150
150
|
};
|
|
151
|
+
export type PerseusFreeResponseUserInput = {
|
|
152
|
+
currentValue: string;
|
|
153
|
+
};
|
|
154
|
+
export type PerseusFreeResponseRubric = {
|
|
155
|
+
question: string;
|
|
156
|
+
scoringCriteria: ReadonlyArray<PerseusFreeResponseWidgetScoringCriterion>;
|
|
157
|
+
};
|
|
151
158
|
export type PerseusOrdererRubric = PerseusOrdererWidgetOptions;
|
|
152
159
|
export type PerseusOrdererUserInput = {
|
|
153
160
|
current: string[];
|
|
@@ -225,6 +232,7 @@ interface UserInputRegistry {
|
|
|
225
232
|
"cs-program": PerseusCSProgramUserInput;
|
|
226
233
|
dropdown: PerseusDropdownUserInput;
|
|
227
234
|
expression: PerseusExpressionUserInput;
|
|
235
|
+
"free-response": PerseusFreeResponseUserInput;
|
|
228
236
|
grapher: PerseusGrapherUserInput;
|
|
229
237
|
group: PerseusGroupUserInput;
|
|
230
238
|
iframe: PerseusIFrameUserInput;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PerseusFreeResponseWidgetOptions } from "../../data-schema";
|
|
2
|
+
/**
|
|
3
|
+
* For details on the individual options, see the
|
|
4
|
+
* {@link PerseusFreeResponseWidgetOptions} type
|
|
5
|
+
*/
|
|
6
|
+
export type FreeResponsePublicWidgetOptions = {
|
|
7
|
+
allowUnlimitedCharacters: PerseusFreeResponseWidgetOptions["allowUnlimitedCharacters"];
|
|
8
|
+
characterLimit: PerseusFreeResponseWidgetOptions["characterLimit"];
|
|
9
|
+
placeholder: PerseusFreeResponseWidgetOptions["placeholder"];
|
|
10
|
+
question: PerseusFreeResponseWidgetOptions["question"];
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Given a FreeResponsePublicWidgetOptions object, return a new object with only
|
|
14
|
+
* the public options that should be exposed to the client.
|
|
15
|
+
*/
|
|
16
|
+
declare function getFreeResponsePublicWidgetOptions(options: PerseusFreeResponseWidgetOptions): FreeResponsePublicWidgetOptions;
|
|
17
|
+
export default getFreeResponsePublicWidgetOptions;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PerseusFreeResponseWidgetOptions } from "../../data-schema";
|
|
2
|
+
import type { WidgetLogic } from "../logic-export.types";
|
|
3
|
+
export type FreeResponseDefaultWidgetOptions = Pick<PerseusFreeResponseWidgetOptions, "allowUnlimitedCharacters" | "characterLimit" | "placeholder" | "question" | "scoringCriteria">;
|
|
4
|
+
declare const freeResponseWidgetLogic: WidgetLogic;
|
|
5
|
+
export default freeResponseWidgetLogic;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusInteractiveGraphWidgetOptions } from "../../data-schema";
|
|
2
2
|
import type { WidgetLogic } from "../logic-export.types";
|
|
3
|
-
export type InteractiveGraphDefaultWidgetOptions = Pick<PerseusInteractiveGraphWidgetOptions, "labels" | "range" | "step" | "backgroundImage" | "markings" | "showTooltips" | "showProtractor" | "graph" | "correct">;
|
|
3
|
+
export type InteractiveGraphDefaultWidgetOptions = Pick<PerseusInteractiveGraphWidgetOptions, "labels" | "labelLocation" | "range" | "step" | "backgroundImage" | "markings" | "showTooltips" | "showProtractor" | "graph" | "correct">;
|
|
4
4
|
declare const interactiveGraphWidgetLogic: WidgetLogic;
|
|
5
5
|
export default interactiveGraphWidgetLogic;
|
|
@@ -3,7 +3,7 @@ import type { PerseusLabelImageMarker, PerseusLabelImageWidgetOptions } from "..
|
|
|
3
3
|
* For details on the individual options, see the
|
|
4
4
|
* PerseusLabelImageWidgetOptions type
|
|
5
5
|
*/
|
|
6
|
-
type LabelImagePublicWidgetOptions = {
|
|
6
|
+
export type LabelImagePublicWidgetOptions = {
|
|
7
7
|
choices: PerseusLabelImageWidgetOptions["choices"];
|
|
8
8
|
imageUrl: PerseusLabelImageWidgetOptions["imageUrl"];
|
|
9
9
|
imageAlt: PerseusLabelImageWidgetOptions["imageAlt"];
|
|
@@ -14,6 +14,5 @@ type LabelImagePublicWidgetOptions = {
|
|
|
14
14
|
multipleAnswers: PerseusLabelImageWidgetOptions["multipleAnswers"];
|
|
15
15
|
static: PerseusLabelImageWidgetOptions["static"];
|
|
16
16
|
};
|
|
17
|
-
type LabelImageMarkerPublicData = Pick<PerseusLabelImageMarker, "x" | "y" | "label">;
|
|
17
|
+
export type LabelImageMarkerPublicData = Pick<PerseusLabelImageMarker, "x" | "y" | "label">;
|
|
18
18
|
export default function getLabelImagePublicWidgetOptions(options: PerseusLabelImageWidgetOptions): LabelImagePublicWidgetOptions;
|
|
19
|
-
export {};
|
|
@@ -2,6 +2,7 @@ import type getCategorizerPublicWidgetOptions from "./categorizer/categorizer-ut
|
|
|
2
2
|
import type getCSProgramPublicWidgetOptions from "./cs-program/cs-program-util";
|
|
3
3
|
import type getDropdownPublicWidgetOptions from "./dropdown/dropdown-util";
|
|
4
4
|
import type getExpressionPublicWidgetOptions from "./expression/expression-util";
|
|
5
|
+
import type getFreeResponsePublicWidgetOptions from "./free-response/free-response-util";
|
|
5
6
|
import type getGrapherPublicWidgetOptions from "./grapher/grapher-util";
|
|
6
7
|
import type getGroupPublicWidgetOptions from "./group/group-util";
|
|
7
8
|
import type getIFramePublicWidgetOptions from "./iframe/iframe-util";
|
|
@@ -28,7 +29,7 @@ export type WidgetOptionsUpgradeMap = {
|
|
|
28
29
|
* TODO(LEMS-2870): figure out how to make this generic so we don't need to be
|
|
29
30
|
* so reliant on a set group of widgets
|
|
30
31
|
*/
|
|
31
|
-
export type PublicWidgetOptionsFunction = typeof getCategorizerPublicWidgetOptions | typeof getCSProgramPublicWidgetOptions | typeof getDropdownPublicWidgetOptions | typeof getExpressionPublicWidgetOptions | typeof getGrapherPublicWidgetOptions | typeof getGroupPublicWidgetOptions | typeof getIFramePublicWidgetOptions | typeof getInputNumberPublicWidgetOptions | typeof getInteractiveGraphPublicWidgetOptions | typeof getLabelImagePublicWidgetOptions | typeof getMatcherPublicWidgetOptions | typeof getMatrixPublicWidgetOptions | typeof getNumberLinePublicWidgetOptions | typeof getNumericInputPublicWidgetOptions | typeof getOrdererPublicWidgetOptions | typeof getPlotterPublicWidgetOptions | typeof getRadioPublicWidgetOptions | typeof getSorterPublicWidgetOptions | typeof getTablePublicWidgetOptions;
|
|
32
|
+
export type PublicWidgetOptionsFunction = typeof getCategorizerPublicWidgetOptions | typeof getCSProgramPublicWidgetOptions | typeof getDropdownPublicWidgetOptions | typeof getExpressionPublicWidgetOptions | typeof getFreeResponsePublicWidgetOptions | typeof getGrapherPublicWidgetOptions | typeof getGroupPublicWidgetOptions | typeof getIFramePublicWidgetOptions | typeof getInputNumberPublicWidgetOptions | typeof getInteractiveGraphPublicWidgetOptions | typeof getLabelImagePublicWidgetOptions | typeof getMatcherPublicWidgetOptions | typeof getMatrixPublicWidgetOptions | typeof getNumberLinePublicWidgetOptions | typeof getNumericInputPublicWidgetOptions | typeof getOrdererPublicWidgetOptions | typeof getPlotterPublicWidgetOptions | typeof getRadioPublicWidgetOptions | typeof getSorterPublicWidgetOptions | typeof getTablePublicWidgetOptions;
|
|
32
33
|
export type WidgetLogic = {
|
|
33
34
|
name: string;
|
|
34
35
|
version?: Version;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Shared Perseus infrastructure",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "12.1.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"tiny-invariant": "^1.3.1",
|
|
26
|
-
"@khanacademy/kas": "2.0.
|
|
27
|
-
"@khanacademy/perseus-utils": "2.0.
|
|
26
|
+
"@khanacademy/kas": "2.0.5",
|
|
27
|
+
"@khanacademy/perseus-utils": "2.0.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@khanacademy/wonder-stuff-core": "1.5.4",
|
|
31
31
|
"underscore": "^1.4.4",
|
|
32
|
-
"perseus-build-settings": "0.6.
|
|
32
|
+
"perseus-build-settings": "0.6.2"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@khanacademy/wonder-stuff-core": "1.5.4",
|