@khanacademy/perseus 43.0.1 → 43.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/components/number-input.d.ts +5 -3
- package/dist/components/text-input.d.ts +4 -2
- package/dist/es/index.js +433 -238
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +424 -229
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +14 -7
- package/dist/util/parse-perseus-json/general-purpose-parsers/defaulted.d.ts +1 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/index.d.ts +2 -0
- package/dist/util/parse-perseus-json/general-purpose-parsers/pipe-parsers.d.ts +7 -0
- package/dist/util/parse-perseus-json/general-purpose-parsers/pipe-parsers.typetest.d.ts +1 -0
- package/dist/util/parse-perseus-json/general-purpose-parsers/unknown.d.ts +2 -0
- package/dist/util/parse-perseus-json/perseus-parsers/images-map.d.ts +5 -0
- package/dist/util/parse-perseus-json/perseus-parsers/widget.d.ts +4 -0
- package/dist/validation.types.d.ts +14 -6
- package/dist/widgets/categorizer/categorizer.d.ts +2 -2
- package/dist/widgets/categorizer/score-categorizer.d.ts +2 -2
- package/dist/widgets/categorizer/validate-categorizer.d.ts +15 -0
- package/dist/widgets/dropdown/validate-dropdown.d.ts +10 -0
- package/dist/widgets/interactive-graphs/graphs/components/movable-point.d.ts +11 -7
- package/dist/widgets/interactive-graphs/graphs/components/use-control-point.d.ts +7 -3
- package/dist/widgets/interactive-graphs/types.d.ts +1 -0
- package/dist/widgets/matrix/matrix.d.ts +12 -5
- package/dist/widgets/measurer/measurer.d.ts +1 -1
- package/dist/widgets/orderer/validate-orderer.d.ts +12 -0
- package/dist/widgets/plotter/plotter.d.ts +2 -2
- package/dist/widgets/plotter/score-plotter.d.ts +2 -2
- package/dist/widgets/plotter/validate-plotter.d.ts +12 -0
- package/dist/widgets/radio/radio.d.ts +1 -1
- package/dist/widgets/radio/validate-radio.d.ts +14 -0
- package/dist/widgets/sorter/validate-sorter.d.ts +13 -0
- package/package.json +4 -4
- package/dist/util/parse-perseus-json/general-purpose-parsers/compose-parsers.d.ts +0 -2
package/dist/perseus-types.d.ts
CHANGED
|
@@ -82,7 +82,14 @@ export type PerseusItem = {
|
|
|
82
82
|
question: PerseusRenderer;
|
|
83
83
|
hints: ReadonlyArray<Hint>;
|
|
84
84
|
answerArea: PerseusAnswerArea | null | undefined;
|
|
85
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The version of the item.
|
|
87
|
+
* @deprecated Not used.
|
|
88
|
+
*/
|
|
89
|
+
itemDataVersion: any;
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Superseded by per-widget answers.
|
|
92
|
+
*/
|
|
86
93
|
answer: any;
|
|
87
94
|
};
|
|
88
95
|
/**
|
|
@@ -590,12 +597,12 @@ export type PerseusMatcherWidgetOptions = {
|
|
|
590
597
|
};
|
|
591
598
|
export type PerseusMatrixWidgetAnswers = ReadonlyArray<ReadonlyArray<number>>;
|
|
592
599
|
export type PerseusMatrixWidgetOptions = {
|
|
593
|
-
prefix
|
|
594
|
-
suffix
|
|
600
|
+
prefix?: string | undefined;
|
|
601
|
+
suffix?: string | undefined;
|
|
595
602
|
answers: PerseusMatrixWidgetAnswers;
|
|
596
|
-
cursorPosition
|
|
603
|
+
cursorPosition?: ReadonlyArray<number> | undefined;
|
|
597
604
|
matrixBoardSize: ReadonlyArray<number>;
|
|
598
|
-
static
|
|
605
|
+
static?: boolean | undefined;
|
|
599
606
|
};
|
|
600
607
|
export type PerseusMeasurerWidgetOptions = {
|
|
601
608
|
image: PerseusImageBackground;
|
|
@@ -651,8 +658,8 @@ export type PerseusOrdererWidgetOptions = {
|
|
|
651
658
|
options: ReadonlyArray<PerseusRenderer>;
|
|
652
659
|
correctOptions: ReadonlyArray<PerseusRenderer>;
|
|
653
660
|
otherOptions: ReadonlyArray<PerseusRenderer>;
|
|
654
|
-
height:
|
|
655
|
-
layout:
|
|
661
|
+
height: "normal" | "auto";
|
|
662
|
+
layout: "horizontal" | "vertical";
|
|
656
663
|
};
|
|
657
664
|
export type PerseusPassageWidgetOptions = {
|
|
658
665
|
footnotes: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Parser } from "../parser-types";
|
|
2
|
-
export declare function defaulted<T, Default
|
|
2
|
+
export declare function defaulted<T, Default>(parser: Parser<T>, fallback: (missingValue: null | undefined) => Default): Parser<T | Default>;
|
|
@@ -9,7 +9,9 @@ export * from "./number";
|
|
|
9
9
|
export * from "./object";
|
|
10
10
|
export * from "./optional";
|
|
11
11
|
export * from "./pair";
|
|
12
|
+
export * from "./pipe-parsers";
|
|
12
13
|
export * from "./record";
|
|
13
14
|
export * from "./string";
|
|
14
15
|
export * from "./trio";
|
|
15
16
|
export * from "./union";
|
|
17
|
+
export * from "./unknown";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Parser, PartialParser } from "../parser-types";
|
|
2
|
+
export declare function pipeParsers<T>(p: Parser<T>): ParserPipeline<T>;
|
|
3
|
+
export declare class ParserPipeline<T> {
|
|
4
|
+
readonly parser: Parser<T>;
|
|
5
|
+
constructor(parser: Parser<T>);
|
|
6
|
+
then<U>(nextParser: PartialParser<T, U>): ParserPipeline<U>;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { WidgetOptions } from "../../../perseus-types";
|
|
2
2
|
import type { Parser } from "../parser-types";
|
|
3
3
|
export declare function parseWidget<Type extends string, Options>(parseType: Parser<Type>, parseOptions: Parser<Options>): Parser<WidgetOptions<Type, Options>>;
|
|
4
|
+
export declare function parseWidgetWithVersion<Version extends {
|
|
5
|
+
major: number;
|
|
6
|
+
minor: number;
|
|
7
|
+
} | undefined, Type extends string, Options>(parseVersion: Parser<Version>, parseType: Parser<Type>, parseOptions: Parser<Options>): Parser<WidgetOptions<Type, Options>>;
|
|
@@ -27,15 +27,18 @@
|
|
|
27
27
|
* } & Perseus<Widget>ValidationData;
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions,
|
|
30
|
+
import type { GrapherAnswerTypes, PerseusDropdownChoice, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetAnswers, PerseusNumberLineWidgetOptions, PerseusNumericInputAnswer, PerseusOrdererWidgetOptions, PerseusRadioChoice, PerseusGraphCorrectType } from "./perseus-types";
|
|
31
31
|
import type { InteractiveMarkerType } from "./widgets/label-image/types";
|
|
32
32
|
import type { Relationship } from "./widgets/number-line/number-line";
|
|
33
33
|
export type UserInputStatus = "correct" | "incorrect" | "incomplete";
|
|
34
|
-
export type
|
|
34
|
+
export type PerseusCategorizerScoringData = {
|
|
35
35
|
values: ReadonlyArray<number>;
|
|
36
|
-
};
|
|
36
|
+
} & PerseusCategorizerValidationData;
|
|
37
37
|
export type PerseusCategorizerUserInput = {
|
|
38
|
-
values:
|
|
38
|
+
values: PerseusCategorizerScoringData["values"];
|
|
39
|
+
};
|
|
40
|
+
export type PerseusCategorizerValidationData = {
|
|
41
|
+
items: ReadonlyArray<string>;
|
|
39
42
|
};
|
|
40
43
|
export type PerseusCSProgramRubric = Empty;
|
|
41
44
|
export type PerseusCSProgramUserInput = {
|
|
@@ -117,7 +120,12 @@ export type PerseusOrdererRubric = PerseusOrdererWidgetOptions;
|
|
|
117
120
|
export type PerseusOrdererUserInput = {
|
|
118
121
|
current: ReadonlyArray<string>;
|
|
119
122
|
};
|
|
120
|
-
export type
|
|
123
|
+
export type PerseusPlotterScoringData = {
|
|
124
|
+
correct: ReadonlyArray<number>;
|
|
125
|
+
} & PerseusPlotterValidationData;
|
|
126
|
+
export type PerseusPlotterValidationData = {
|
|
127
|
+
starting: ReadonlyArray<number>;
|
|
128
|
+
};
|
|
121
129
|
export type PerseusPlotterUserInput = ReadonlyArray<number>;
|
|
122
130
|
export type PerseusRadioRubric = {
|
|
123
131
|
choices: ReadonlyArray<PerseusRadioChoice>;
|
|
@@ -136,7 +144,7 @@ export type PerseusTableRubric = {
|
|
|
136
144
|
answers: ReadonlyArray<ReadonlyArray<string>>;
|
|
137
145
|
};
|
|
138
146
|
export type PerseusTableUserInput = ReadonlyArray<ReadonlyArray<string>>;
|
|
139
|
-
export type Rubric =
|
|
147
|
+
export type Rubric = PerseusCategorizerScoringData | PerseusCSProgramRubric | PerseusDropdownRubric | PerseusExpressionRubric | PerseusGroupRubric | PerseusGradedGroupRubric | PerseusGradedGroupSetRubric | PerseusGrapherRubric | PerseusIFrameRubric | PerseusInputNumberRubric | PerseusInteractiveGraphRubric | PerseusLabelImageRubric | PerseusMatcherRubric | PerseusMatrixRubric | PerseusNumberLineRubric | PerseusNumericInputRubric | PerseusOrdererRubric | PerseusPlotterScoringData | PerseusRadioRubric | PerseusSorterRubric | PerseusTableRubric;
|
|
140
148
|
export type UserInput = PerseusCategorizerUserInput | PerseusCSProgramUserInput | PerseusDropdownUserInput | PerseusExpressionUserInput | PerseusGrapherUserInput | PerseusIFrameUserInput | PerseusInputNumberUserInput | PerseusInteractiveGraphUserInput | PerseusLabelImageUserInput | PerseusMatcherUserInput | PerseusMatrixUserInput | PerseusNumberLineUserInput | PerseusNumericInputUserInput | PerseusOrdererUserInput | PerseusPlotterUserInput | PerseusRadioUserInput | PerseusSorterUserInput | PerseusTableUserInput;
|
|
141
149
|
export type UserInputMap = {
|
|
142
150
|
[widgetId: string]: UserInput | UserInputMap;
|
|
@@ -3,9 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import scoreCategorizer from "./score-categorizer";
|
|
4
4
|
import type { PerseusCategorizerWidgetOptions } from "../../perseus-types";
|
|
5
5
|
import type { Widget, WidgetProps } from "../../types";
|
|
6
|
-
import type {
|
|
6
|
+
import type { PerseusCategorizerScoringData, PerseusCategorizerUserInput } from "../../validation.types";
|
|
7
7
|
import type { CategorizerPromptJSON } from "../../widget-ai-utils/categorizer/categorizer-ai-utils";
|
|
8
|
-
type Props = WidgetProps<RenderProps,
|
|
8
|
+
type Props = WidgetProps<RenderProps, PerseusCategorizerScoringData> & {
|
|
9
9
|
values: ReadonlyArray<string>;
|
|
10
10
|
};
|
|
11
11
|
type DefaultProps = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusStrings } from "../../strings";
|
|
2
2
|
import type { PerseusScore } from "../../types";
|
|
3
|
-
import type {
|
|
4
|
-
declare function scoreCategorizer(userInput: PerseusCategorizerUserInput,
|
|
3
|
+
import type { PerseusCategorizerScoringData, PerseusCategorizerUserInput } from "../../validation.types";
|
|
4
|
+
declare function scoreCategorizer(userInput: PerseusCategorizerUserInput, scoringData: PerseusCategorizerScoringData, strings: PerseusStrings): PerseusScore;
|
|
5
5
|
export default scoreCategorizer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PerseusStrings } from "../../strings";
|
|
2
|
+
import type { PerseusScore } from "../../types";
|
|
3
|
+
import type { PerseusCategorizerUserInput, PerseusCategorizerValidationData } from "../../validation.types";
|
|
4
|
+
/**
|
|
5
|
+
* Checks userInput from the categorizer widget to see if the user has selected
|
|
6
|
+
* a category for each item.
|
|
7
|
+
* @param userInput - The user's input corresponding to an array of indices that
|
|
8
|
+
* represent the selected category for each row/item.
|
|
9
|
+
* @param validationData - An array of strings corresponding to each row/item
|
|
10
|
+
* @param strings - Used to provide a validation message
|
|
11
|
+
*/
|
|
12
|
+
declare function validateCategorizer(userInput: PerseusCategorizerUserInput, validationData: PerseusCategorizerValidationData, strings: PerseusStrings): Extract<PerseusScore, {
|
|
13
|
+
type: "invalid";
|
|
14
|
+
}> | null;
|
|
15
|
+
export default validateCategorizer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PerseusScore } from "../../types";
|
|
2
|
+
import type { PerseusDropdownUserInput } from "../../validation.types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the user has selected an item from the dropdown before scoring.
|
|
5
|
+
* This is shown with a userInput value / index other than 0.
|
|
6
|
+
*/
|
|
7
|
+
declare function validateDropdown(userInput: PerseusDropdownUserInput): Extract<PerseusScore, {
|
|
8
|
+
type: "invalid";
|
|
9
|
+
}> | null;
|
|
10
|
+
export default validateDropdown;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { CSSCursor } from "./css-cursor";
|
|
3
|
+
import type { AriaLive } from "../../types";
|
|
3
4
|
import type { KeyboardMovementConstraint } from "../use-draggable";
|
|
4
5
|
import type { vec } from "mafs";
|
|
5
6
|
type Props = {
|
|
6
7
|
point: vec.Vector2;
|
|
8
|
+
ariaDescribedBy?: string;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
ariaLive?: AriaLive;
|
|
11
|
+
color?: string;
|
|
12
|
+
constrain?: KeyboardMovementConstraint;
|
|
13
|
+
cursor?: CSSCursor | undefined;
|
|
7
14
|
/**
|
|
8
15
|
* Represents where this point stands in the overall point sequence.
|
|
9
16
|
* This is used to provide screen readers with context about the point.
|
|
@@ -12,14 +19,11 @@ type Props = {
|
|
|
12
19
|
* Note: This number is 1-indexed, and should restart from 1 for each
|
|
13
20
|
* interactive figure on the graph.
|
|
14
21
|
*/
|
|
15
|
-
sequenceNumber
|
|
16
|
-
|
|
22
|
+
sequenceNumber?: number;
|
|
23
|
+
onBlur?: (event: React.FocusEvent) => unknown;
|
|
17
24
|
onClick?: () => unknown;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
constrain?: KeyboardMovementConstraint;
|
|
21
|
-
onFocus?: ((event: React.FocusEvent) => unknown) | undefined;
|
|
22
|
-
onBlur?: ((event: React.FocusEvent) => unknown) | undefined;
|
|
25
|
+
onFocus?: (event: React.FocusEvent) => unknown;
|
|
26
|
+
onMove?: (newPoint: vec.Vector2) => unknown;
|
|
23
27
|
};
|
|
24
28
|
export declare const MovablePoint: React.ForwardRefExoticComponent<Props & React.RefAttributes<SVGGElement | null>>;
|
|
25
29
|
export {};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { CSSCursor } from "./css-cursor";
|
|
3
|
+
import type { AriaLive } from "../../types";
|
|
3
4
|
import type { KeyboardMovementConstraint } from "../use-draggable";
|
|
4
5
|
import type { vec } from "mafs";
|
|
5
6
|
type Params = {
|
|
6
7
|
point: vec.Vector2;
|
|
8
|
+
ariaDescribedBy?: string;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
ariaLive?: AriaLive;
|
|
7
11
|
color?: string | undefined;
|
|
12
|
+
constrain?: KeyboardMovementConstraint;
|
|
8
13
|
cursor?: CSSCursor | undefined;
|
|
14
|
+
forwardedRef?: React.ForwardedRef<SVGGElement | null> | undefined;
|
|
9
15
|
/**
|
|
10
16
|
* Represents where this point stands in the overall point sequence.
|
|
11
17
|
* This is used to provide screen readers with context about the point.
|
|
@@ -14,13 +20,11 @@ type Params = {
|
|
|
14
20
|
* Note: This number is 1-indexed, and should restart from 1 for each
|
|
15
21
|
* interactive figure on the graph.
|
|
16
22
|
*/
|
|
17
|
-
sequenceNumber
|
|
18
|
-
constrain?: KeyboardMovementConstraint;
|
|
23
|
+
sequenceNumber?: number;
|
|
19
24
|
onMove?: ((newPoint: vec.Vector2) => unknown) | undefined;
|
|
20
25
|
onClick?: (() => unknown) | undefined;
|
|
21
26
|
onFocus?: ((event: React.FocusEvent) => unknown) | undefined;
|
|
22
27
|
onBlur?: ((event: React.FocusEvent) => unknown) | undefined;
|
|
23
|
-
forwardedRef?: React.ForwardedRef<SVGGElement | null> | undefined;
|
|
24
28
|
};
|
|
25
29
|
type Return = {
|
|
26
30
|
focusableHandle: React.ReactNode;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
3
|
import scoreMatrix from "./score-matrix";
|
|
4
|
-
import type {
|
|
4
|
+
import type { PerseusMatrixWidgetAnswers } from "../../perseus-types";
|
|
5
5
|
import type { WidgetProps, Widget, FocusPath } from "../../types";
|
|
6
6
|
import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
|
|
7
7
|
import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
|
|
8
8
|
export declare function getMatrixSize(matrix: ReadonlyArray<ReadonlyArray<number>>): number[];
|
|
9
|
-
type ExternalProps = WidgetProps<
|
|
9
|
+
type ExternalProps = WidgetProps<{
|
|
10
|
+
prefix: string;
|
|
11
|
+
suffix: string;
|
|
12
|
+
answers: PerseusMatrixWidgetAnswers;
|
|
13
|
+
cursorPosition: ReadonlyArray<number>;
|
|
14
|
+
matrixBoardSize: ReadonlyArray<number>;
|
|
15
|
+
static?: boolean | undefined;
|
|
16
|
+
}, PerseusMatrixRubric>;
|
|
10
17
|
type Props = ExternalProps & {
|
|
11
18
|
onChange: (arg1: {
|
|
12
19
|
cursorPosition?: ReadonlyArray<number>;
|
|
@@ -17,9 +24,9 @@ type Props = ExternalProps & {
|
|
|
17
24
|
type DefaultProps = {
|
|
18
25
|
matrixBoardSize: Props["matrixBoardSize"];
|
|
19
26
|
answers: Props["answers"];
|
|
20
|
-
prefix:
|
|
21
|
-
suffix:
|
|
22
|
-
cursorPosition:
|
|
27
|
+
prefix: string;
|
|
28
|
+
suffix: string;
|
|
29
|
+
cursorPosition: ReadonlyArray<number>;
|
|
23
30
|
apiOptions: Props["apiOptions"];
|
|
24
31
|
linterContext: Props["linterContext"];
|
|
25
32
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PerseusScore } from "../../types";
|
|
2
|
+
import type { PerseusOrdererUserInput } from "../../validation.types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks user input from the orderer widget to see if the user has started
|
|
5
|
+
* ordering the options, making the widget scorable.
|
|
6
|
+
* @param userInput
|
|
7
|
+
* @see `scoreOrderer` for more details.
|
|
8
|
+
*/
|
|
9
|
+
declare function validateOrderer(userInput: PerseusOrdererUserInput): Extract<PerseusScore, {
|
|
10
|
+
type: "invalid";
|
|
11
|
+
}> | null;
|
|
12
|
+
export default validateOrderer;
|
|
@@ -3,10 +3,10 @@ import { PerseusI18nContext } from "../../components/i18n-context";
|
|
|
3
3
|
import scorePlotter from "./score-plotter";
|
|
4
4
|
import type { PerseusPlotterWidgetOptions } from "../../perseus-types";
|
|
5
5
|
import type { Widget, WidgetProps } from "../../types";
|
|
6
|
-
import type {
|
|
6
|
+
import type { PerseusPlotterScoringData, PerseusPlotterUserInput } from "../../validation.types";
|
|
7
7
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
8
8
|
type RenderProps = PerseusPlotterWidgetOptions;
|
|
9
|
-
type Props = WidgetProps<RenderProps,
|
|
9
|
+
type Props = WidgetProps<RenderProps, PerseusPlotterScoringData> & {
|
|
10
10
|
labelInterval: NonNullable<PerseusPlotterWidgetOptions["labelInterval"]>;
|
|
11
11
|
picSize: NonNullable<PerseusPlotterWidgetOptions["picSize"]>;
|
|
12
12
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PerseusScore } from "../../types";
|
|
2
|
-
import type {
|
|
3
|
-
declare function scorePlotter(userInput: PerseusPlotterUserInput,
|
|
2
|
+
import type { PerseusPlotterScoringData, PerseusPlotterUserInput } from "../../validation.types";
|
|
3
|
+
declare function scorePlotter(userInput: PerseusPlotterUserInput, scoringData: PerseusPlotterScoringData): PerseusScore;
|
|
4
4
|
export default scorePlotter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PerseusScore } from "../../types";
|
|
2
|
+
import type { PerseusPlotterUserInput, PerseusPlotterValidationData } from "../../validation.types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks user input to confirm it is not the same as the starting values for the graph.
|
|
5
|
+
* This means the user has modified the graph, and the question can be scored.
|
|
6
|
+
*
|
|
7
|
+
* @see 'scorePlotter' for more details on scoring.
|
|
8
|
+
*/
|
|
9
|
+
declare function validatePlotter(userInput: PerseusPlotterUserInput, validationData: PerseusPlotterValidationData): Extract<PerseusScore, {
|
|
10
|
+
type: "invalid";
|
|
11
|
+
}> | null;
|
|
12
|
+
export default validatePlotter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PerseusScore } from "../../types";
|
|
2
|
+
import type { PerseusRadioUserInput } from "../../validation.types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the user has selected at least one option. Additional validation
|
|
5
|
+
* is done in scoreRadio to check if the number of selected options is correct
|
|
6
|
+
* and if the user has selected both a correct option and the "none of the above"
|
|
7
|
+
* option.
|
|
8
|
+
* @param userInput
|
|
9
|
+
* @see `scoreRadio` for the additional validation logic and the scoring logic.
|
|
10
|
+
*/
|
|
11
|
+
declare function validateRadio(userInput: PerseusRadioUserInput): Extract<PerseusScore, {
|
|
12
|
+
type: "invalid";
|
|
13
|
+
}> | null;
|
|
14
|
+
export default validateRadio;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PerseusScore } from "../../types";
|
|
2
|
+
import type { PerseusSorterUserInput } from "../../validation.types";
|
|
3
|
+
/**
|
|
4
|
+
* Checks user input for the sorter widget to ensure that the user has made
|
|
5
|
+
* changes before attempting to score the widget.
|
|
6
|
+
* @param userInput
|
|
7
|
+
* @see 'scoreSorter' in 'packages/perseus/src/widgets/sorter/score-sorter.ts'
|
|
8
|
+
* for more details on how the sorter widget is scored.
|
|
9
|
+
*/
|
|
10
|
+
declare function validateSorter(userInput: PerseusSorterUserInput): Extract<PerseusScore, {
|
|
11
|
+
type: "invalid";
|
|
12
|
+
}> | null;
|
|
13
|
+
export default validateSorter;
|
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": "43.0
|
|
6
|
+
"version": "43.1.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@khanacademy/kas": "^0.4.
|
|
43
|
+
"@khanacademy/kas": "^0.4.2",
|
|
44
44
|
"@khanacademy/keypad-context": "^1.0.4",
|
|
45
45
|
"@khanacademy/kmath": "^0.1.16",
|
|
46
46
|
"@khanacademy/math-input": "^21.1.5",
|
|
47
47
|
"@khanacademy/perseus-core": "1.5.3",
|
|
48
48
|
"@khanacademy/perseus-linter": "^1.2.4",
|
|
49
|
-
"@khanacademy/pure-markdown": "^0.3.
|
|
50
|
-
"@khanacademy/simple-markdown": "^0.13.
|
|
49
|
+
"@khanacademy/pure-markdown": "^0.3.13",
|
|
50
|
+
"@khanacademy/simple-markdown": "^0.13.6",
|
|
51
51
|
"@types/classnames": "2.2.0",
|
|
52
52
|
"@use-gesture/react": "^10.2.27",
|
|
53
53
|
"mafs": "0.19.0",
|