@khanacademy/perseus-core 11.0.0 → 12.0.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 +19 -13
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/free-response-widget.d.ts +3 -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/logic-export.types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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;
|