@khanacademy/perseus 41.3.0 → 41.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/es/index.css +3 -0
- package/dist/es/index.js +591 -97
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +3 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +591 -97
- package/dist/index.js.map +1 -1
- package/dist/server-item-renderer.d.ts +1 -1
- package/dist/util/answer-types.d.ts +45 -2
- package/dist/util/parse-perseus-json/perseus-parsers/graded-group-set-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/graded-group-widget.d.ts +16 -0
- package/dist/util/parse-perseus-json/perseus-parsers/grapher-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/group-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/iframe-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/image-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/input-number-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/interaction-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/label-image-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/matcher-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/matrix-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/measurer-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/molecule-renderer-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/number-line-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/numeric-input-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/orderer-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/passage-ref-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/passage-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/phet-simulation-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/plotter-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/python-program-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/radio-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/sorter-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/table-widget.d.ts +3 -0
- package/dist/util/parse-perseus-json/perseus-parsers/video-widget.d.ts +3 -0
- package/dist/validation.types.d.ts +4 -2
- package/dist/widgets/numeric-input/numeric-input.d.ts +7 -0
- package/dist/widgets/table/score-table.d.ts +1 -1
- package/dist/widgets/table/utils.d.ts +7 -0
- package/dist/widgets/table/validate-table.d.ts +6 -0
- package/package.json +2 -2
|
@@ -62,7 +62,7 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
|
|
|
62
62
|
_onRendererBlur(blurPath: FocusPath): void;
|
|
63
63
|
/**
|
|
64
64
|
* Accepts a question area widgetId, or an answer area widgetId of
|
|
65
|
-
* the form "answer-input
|
|
65
|
+
* the form "answer-numeric-input 1", or the string "answer-area"
|
|
66
66
|
* for the whole answer area (if the answer area is a single widget).
|
|
67
67
|
*/
|
|
68
68
|
_setWidgetProps(widgetId: string, newProps: Props, callback: any): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PerseusStrings } from "../strings";
|
|
2
2
|
type Guess = any;
|
|
3
|
-
type Predicate =
|
|
3
|
+
type Predicate = (guess: number, maxError: number) => boolean;
|
|
4
4
|
export type Score = {
|
|
5
5
|
empty: boolean;
|
|
6
6
|
correct: boolean;
|
|
@@ -9,13 +9,56 @@ export type Score = {
|
|
|
9
9
|
guess: Guess;
|
|
10
10
|
ungraded?: boolean;
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Answer types
|
|
14
|
+
*
|
|
15
|
+
* Utility for creating answerable questions displayed in exercises
|
|
16
|
+
*
|
|
17
|
+
* Different answer types produce different kinds of input displays, and do
|
|
18
|
+
* different kinds of checking on the solutions.
|
|
19
|
+
*
|
|
20
|
+
* Each of the objects contain two functions, setup and createValidator.
|
|
21
|
+
*
|
|
22
|
+
* The setup function takes a solutionarea and solution, and performs setup
|
|
23
|
+
* within the solutionarea, and then returns an object which contains:
|
|
24
|
+
*
|
|
25
|
+
* answer: a function which, when called, will retrieve the current answer from
|
|
26
|
+
* the solutionarea, which can then be validated using the validator
|
|
27
|
+
* function
|
|
28
|
+
* validator: a function returned from the createValidator function (defined
|
|
29
|
+
* below)
|
|
30
|
+
* solution: the correct answer to the problem
|
|
31
|
+
* showGuess: a function which, when given a guess, shows the guess within the
|
|
32
|
+
* provided solutionarea
|
|
33
|
+
* showGuessCustom: a function which displays parts of a guess that are not
|
|
34
|
+
* within the solutionarea; currently only used for custom
|
|
35
|
+
* answers
|
|
36
|
+
*
|
|
37
|
+
* The createValidator function only takes a solution, and it returns a
|
|
38
|
+
* function which can be used to validate an answer.
|
|
39
|
+
*
|
|
40
|
+
* The resulting validator function returns:
|
|
41
|
+
* - true: if the answer is fully correct
|
|
42
|
+
* - false: if the answer is incorrect
|
|
43
|
+
* - "" (the empty string): if no answer has been provided (e.g. the answer box
|
|
44
|
+
* is left unfilled)
|
|
45
|
+
* - a string: if there is some slight error
|
|
46
|
+
*
|
|
47
|
+
* In most cases, setup and createValidator don't really need the solution DOM
|
|
48
|
+
* element so we have setupFunctional and createValidatorFunctional for them
|
|
49
|
+
* which take only $solution.text() and $solution.data(). This makes it easier
|
|
50
|
+
* to reuse specific answer types.
|
|
51
|
+
*
|
|
52
|
+
* TODO(alpert): Think of a less-absurd name for createValidatorFunctional.
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
12
55
|
declare const KhanAnswerTypes: {
|
|
13
56
|
readonly predicate: {
|
|
14
57
|
readonly defaultForms: "integer, proper, improper, mixed, decimal";
|
|
15
58
|
readonly createValidatorFunctional: (predicate: Predicate, options: any, strings: PerseusStrings) => (arg1: Guess) => Score;
|
|
16
59
|
};
|
|
17
60
|
readonly number: {
|
|
18
|
-
readonly convertToPredicate: (correctAnswer: string, options: any) => Predicate;
|
|
61
|
+
readonly convertToPredicate: (correctAnswer: string, options: any) => [predicate: Predicate, options: any];
|
|
19
62
|
readonly createValidatorFunctional: (correctAnswer: string, options: any, strings: PerseusStrings) => (arg1: Guess) => Score;
|
|
20
63
|
};
|
|
21
64
|
readonly expression: {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GradedGroupWidget } from "../../../perseus-types";
|
|
2
|
+
import type { Parser } from "../parser-types";
|
|
3
|
+
export declare const parseGradedGroupWidgetOptions: Parser<{
|
|
4
|
+
title: string;
|
|
5
|
+
hasHint: boolean | null | undefined;
|
|
6
|
+
hint: import("../../../perseus-types").PerseusRenderer | null | undefined;
|
|
7
|
+
content: string;
|
|
8
|
+
widgets: import("../../../perseus-types").PerseusWidgetsMap;
|
|
9
|
+
widgetEnabled: boolean | null | undefined;
|
|
10
|
+
immutableWidgets: boolean | null | undefined;
|
|
11
|
+
images: Record<string, {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const parseGradedGroupWidget: Parser<GradedGroupWidget>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioChoice,
|
|
1
|
+
import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType } from "./perseus-types";
|
|
2
2
|
import type { InteractiveMarkerType } from "./widgets/label-image/types";
|
|
3
3
|
import type { Relationship } from "./widgets/number-line/number-line";
|
|
4
4
|
export type UserInputStatus = "correct" | "incorrect" | "incomplete";
|
|
@@ -102,7 +102,9 @@ export type PerseusSorterUserInput = {
|
|
|
102
102
|
options: ReadonlyArray<string>;
|
|
103
103
|
changed: boolean;
|
|
104
104
|
};
|
|
105
|
-
export type PerseusTableRubric =
|
|
105
|
+
export type PerseusTableRubric = {
|
|
106
|
+
answers: ReadonlyArray<ReadonlyArray<string>>;
|
|
107
|
+
};
|
|
106
108
|
export type PerseusTableUserInput = ReadonlyArray<ReadonlyArray<string>>;
|
|
107
109
|
export type Rubric = PerseusCategorizerRubric | PerseusCSProgramRubric | PerseusDropdownRubric | PerseusExpressionRubric | PerseusGroupRubric | PerseusGradedGroupRubric | PerseusGradedGroupSetRubric | PerseusGrapherRubric | PerseusIFrameRubric | PerseusInputNumberRubric | PerseusInteractiveGraphRubric | PerseusLabelImageRubric | PerseusMatcherRubric | PerseusMatrixRubric | PerseusNumberLineRubric | PerseusNumericInputRubric | PerseusOrdererRubric | PerseusPlotterRubric | PerseusRadioRubric | PerseusSorterRubric | PerseusTableRubric;
|
|
108
110
|
export type UserInput = PerseusCategorizerUserInput | PerseusCSProgramUserInput | PerseusDropdownUserInput | PerseusExpressionUserInput | PerseusGrapherUserInput | PerseusIFrameUserInput | PerseusInputNumberUserInput | PerseusInteractiveGraphUserInput | PerseusLabelImageUserInput | PerseusMatcherUserInput | PerseusMatrixUserInput | PerseusNumberLineUserInput | PerseusNumericInputUserInput | PerseusOrdererUserInput | PerseusPlotterUserInput | PerseusRadioUserInput | PerseusSorterUserInput | PerseusTableUserInput;
|
|
@@ -74,7 +74,14 @@ declare const _default: {
|
|
|
74
74
|
defaultAlignment: "inline-block";
|
|
75
75
|
accessible: true;
|
|
76
76
|
widget: typeof NumericInput;
|
|
77
|
+
version: {
|
|
78
|
+
major: number;
|
|
79
|
+
minor: number;
|
|
80
|
+
};
|
|
77
81
|
transform: (widgetOptions: PerseusNumericInputWidgetOptions) => RenderProps;
|
|
82
|
+
propUpgrades: {
|
|
83
|
+
readonly "1": (initialProps: any) => PerseusNumericInputWidgetOptions;
|
|
84
|
+
};
|
|
78
85
|
isLintable: true;
|
|
79
86
|
scorer: typeof scoreNumericInput;
|
|
80
87
|
getOneCorrectAnswerFromRubric(rubric: PerseusNumericInputRubric): string | null | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusStrings } from "../../strings";
|
|
2
2
|
import type { PerseusScore } from "../../types";
|
|
3
3
|
import type { PerseusTableRubric, PerseusTableUserInput } from "../../validation.types";
|
|
4
|
-
declare function scoreTable(
|
|
4
|
+
declare function scoreTable(userInput: PerseusTableUserInput, rubric: PerseusTableRubric, strings: PerseusStrings): PerseusScore;
|
|
5
5
|
export default scoreTable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters the given table (modelled as a 2D array) to remove any rows that are
|
|
3
|
+
* completely empty.
|
|
4
|
+
*
|
|
5
|
+
* @returns A new table with only non-empty rows.
|
|
6
|
+
*/
|
|
7
|
+
export declare const filterNonEmpty: (table: ReadonlyArray<ReadonlyArray<string>>) => (readonly string[])[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PerseusScore } from "../../types";
|
|
2
|
+
import type { PerseusTableUserInput } from "../../validation.types";
|
|
3
|
+
declare function validateTable(userInput: PerseusTableUserInput): Extract<PerseusScore, {
|
|
4
|
+
type: "invalid";
|
|
5
|
+
}> | null;
|
|
6
|
+
export default validateTable;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core Perseus API (includes renderers and widgets)",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "41.
|
|
6
|
+
"version": "41.5.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@khanacademy/kas": "^0.
|
|
43
|
+
"@khanacademy/kas": "^0.4.0",
|
|
44
44
|
"@khanacademy/keypad-context": "^1.0.4",
|
|
45
45
|
"@khanacademy/kmath": "^0.1.16",
|
|
46
46
|
"@khanacademy/math-input": "^21.1.4",
|