@khanacademy/perseus-core 18.3.0 → 18.5.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 +5 -0
- package/dist/es/index.item-splitting.js +192 -0
- package/dist/es/index.item-splitting.js.map +1 -0
- package/dist/es/index.js +7 -7
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.item-splitting.d.ts +2 -0
- package/dist/index.item-splitting.js +220 -0
- package/dist/index.item-splitting.js.map +1 -0
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/general-purpose-parsers/array.d.ts +5 -0
- package/dist/parse-perseus-json/perseus-parsers/categorizer-user-input.d.ts +1 -1
- package/dist/parse-perseus-json/perseus-parsers/radio-widget.d.ts +2 -0
- package/dist/parse-perseus-json/perseus-parsers/radio-widget.mockData.d.ts +10 -0
- package/dist/utils/random-util.d.ts +7 -0
- package/dist/validation.types.d.ts +3 -3
- package/dist/widgets/radio/derive-num-correct.d.ts +5 -2
- package/dist/widgets/radio/radio-util.d.ts +2 -2
- package/package.json +15 -1
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { Parser } from "../parser-types";
|
|
2
2
|
export declare function array<T>(elementParser: Parser<T>): Parser<T[]>;
|
|
3
|
+
/**
|
|
4
|
+
* Like the standard `array` parser, but passes the array index to a parser factory function.
|
|
5
|
+
* This allows element parsers to generate index-based default values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function arrayWithIndex<T>(elementParserFactory: (index: number) => Parser<T>): Parser<T[]>;
|
|
@@ -6,6 +6,7 @@ declare const parseRadioWidgetV3: import("../parser-types").Parser<import("../..
|
|
|
6
6
|
rationale: string | undefined;
|
|
7
7
|
correct: boolean | undefined;
|
|
8
8
|
isNoneOfTheAbove: boolean | undefined;
|
|
9
|
+
id: string;
|
|
9
10
|
}>[];
|
|
10
11
|
hasNoneOfTheAbove: boolean | undefined;
|
|
11
12
|
countChoices: boolean | undefined;
|
|
@@ -75,6 +76,7 @@ export declare const parseRadioWidget: import("../parser-types").Parser<import("
|
|
|
75
76
|
rationale: string | undefined;
|
|
76
77
|
correct: boolean | undefined;
|
|
77
78
|
isNoneOfTheAbove: boolean | undefined;
|
|
79
|
+
id: string;
|
|
78
80
|
}>[];
|
|
79
81
|
hasNoneOfTheAbove: boolean | undefined;
|
|
80
82
|
countChoices: boolean | undefined;
|
|
@@ -150,30 +150,40 @@ export declare const v3Widget: {
|
|
|
150
150
|
graded: boolean;
|
|
151
151
|
options: {
|
|
152
152
|
choices: ({
|
|
153
|
+
id: string;
|
|
153
154
|
content: string;
|
|
154
155
|
correct: boolean;
|
|
155
156
|
rationale: string;
|
|
156
157
|
isNoneOfTheAbove: boolean;
|
|
158
|
+
widgets?: undefined;
|
|
157
159
|
} | {
|
|
160
|
+
id: string;
|
|
158
161
|
content: string;
|
|
159
162
|
correct: boolean;
|
|
160
163
|
rationale: string;
|
|
164
|
+
widgets: undefined;
|
|
161
165
|
isNoneOfTheAbove?: undefined;
|
|
162
166
|
} | {
|
|
167
|
+
id: string;
|
|
163
168
|
content: string;
|
|
164
169
|
correct: boolean;
|
|
165
170
|
isNoneOfTheAbove: boolean;
|
|
166
171
|
rationale?: undefined;
|
|
172
|
+
widgets?: undefined;
|
|
167
173
|
} | {
|
|
174
|
+
id: string;
|
|
168
175
|
content: string;
|
|
169
176
|
rationale: string;
|
|
170
177
|
isNoneOfTheAbove: boolean;
|
|
171
178
|
correct?: undefined;
|
|
179
|
+
widgets?: undefined;
|
|
172
180
|
} | {
|
|
181
|
+
id: string;
|
|
173
182
|
content: string;
|
|
174
183
|
correct?: undefined;
|
|
175
184
|
rationale?: undefined;
|
|
176
185
|
isNoneOfTheAbove?: undefined;
|
|
186
|
+
widgets?: undefined;
|
|
177
187
|
})[];
|
|
178
188
|
numCorrect: number;
|
|
179
189
|
hasNoneOfTheAbove: boolean;
|
|
@@ -13,3 +13,10 @@ export declare function shuffle<T>(array: ReadonlyArray<T>, randomSeed: number |
|
|
|
13
13
|
export declare function constrainedShuffle<T>(array: readonly T[], random: RNG, isValidShuffle: (shuffled: readonly T[]) => boolean): T[];
|
|
14
14
|
export declare function randomIntInRange(min: number, max: number, random: RNG): number;
|
|
15
15
|
export declare const random: RNG;
|
|
16
|
+
/**
|
|
17
|
+
* Randomizes an array using the sort-by-random-key method
|
|
18
|
+
*
|
|
19
|
+
* @param inputArray - The array of elements to randomize
|
|
20
|
+
* @returns A new array containing the same elements in randomized order
|
|
21
|
+
*/
|
|
22
|
+
export declare function randomizeArrayElements<T>(inputArray: ReadonlyArray<T>): T[];
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
*/
|
|
31
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
|
-
export type WidgetValidatorFunction = (userInput: UserInput, validationData: ValidationData, locale: string) => ValidationResult;
|
|
34
|
-
export type WidgetScorerFunction = (userInput: UserInput, rubric: Rubric, locale?: string) => PerseusScore;
|
|
33
|
+
export type WidgetValidatorFunction = (userInput: UserInput | undefined, validationData: ValidationData, locale: string) => ValidationResult;
|
|
34
|
+
export type WidgetScorerFunction = (userInput: UserInput | undefined, rubric: Rubric, locale?: string) => PerseusScore;
|
|
35
35
|
export type PerseusScore = {
|
|
36
36
|
type: "invalid";
|
|
37
37
|
message?: string | null | undefined;
|
|
@@ -50,7 +50,7 @@ export type PerseusCategorizerRubric = {
|
|
|
50
50
|
values: number[];
|
|
51
51
|
} & PerseusCategorizerValidationData;
|
|
52
52
|
export type PerseusCategorizerUserInput = {
|
|
53
|
-
values:
|
|
53
|
+
values: Array<number | null | undefined>;
|
|
54
54
|
};
|
|
55
55
|
export type PerseusCategorizerValidationData = {
|
|
56
56
|
items: string[];
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface Choice {
|
|
2
|
+
correct?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function deriveNumCorrect(choices: Choice[]): number;
|
|
5
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PerseusRadioChoice, PerseusRadioWidgetOptions } from "../../data-schema";
|
|
2
2
|
/**
|
|
3
3
|
* For details on the individual options, see the
|
|
4
|
-
* PerseusRadioWidgetOptions type
|
|
4
|
+
* PerseusRadioWidgetOptions type.
|
|
5
5
|
*/
|
|
6
6
|
export type RadioPublicWidgetOptions = {
|
|
7
7
|
choices: ReadonlyArray<RadioChoicePublicData>;
|
|
@@ -15,7 +15,7 @@ export type RadioPublicWidgetOptions = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Only the options from each Radio choice that should be exposed to the client.
|
|
17
17
|
*/
|
|
18
|
-
type RadioChoicePublicData = Pick<PerseusRadioChoice, "content" | "isNoneOfTheAbove">;
|
|
18
|
+
type RadioChoicePublicData = Pick<PerseusRadioChoice, "id" | "content" | "isNoneOfTheAbove">;
|
|
19
19
|
/**
|
|
20
20
|
* Shared functionality to determine if numCorrect is used, because:
|
|
21
21
|
*
|
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": "18.
|
|
6
|
+
"version": "18.5.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -18,6 +18,20 @@
|
|
|
18
18
|
"module": "dist/es/index.js",
|
|
19
19
|
"main": "dist/index.js",
|
|
20
20
|
"source": "src/index.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/es/index.js",
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"source": "./src/index.ts"
|
|
27
|
+
},
|
|
28
|
+
"./item-splitting": {
|
|
29
|
+
"import": "./dist/es/index.item-splitting.js",
|
|
30
|
+
"require": "./dist/index.item-splitting.js",
|
|
31
|
+
"types": "./dist/index.item-splitting.d.ts",
|
|
32
|
+
"source": "./src/index.item-splitting.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
21
35
|
"files": [
|
|
22
36
|
"dist"
|
|
23
37
|
],
|