@khanacademy/perseus 77.1.0 → 77.2.1
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/gif-image.d.ts +38 -0
- package/dist/components/svg-image.d.ts +12 -0
- package/dist/es/index.css +2 -2
- package/dist/es/index.css.map +1 -1
- package/dist/es/index.js +24 -19
- package/dist/es/index.js.map +1 -1
- package/dist/es/strings.js +1 -1
- package/dist/es/strings.js.map +1 -1
- package/dist/hint-renderer.d.ts +15 -2
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +100 -7
- package/dist/index.js +24 -18
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +3 -3
- package/dist/strings.d.ts +50 -0
- package/dist/strings.js +1 -1
- package/dist/strings.js.map +1 -1
- package/dist/testing/test-dependencies.d.ts +0 -1
- package/dist/types.d.ts +2 -1
- package/dist/widget-ai-utils/categorizer/categorizer-ai-utils.d.ts +29 -0
- package/dist/widget-ai-utils/definition/definition-ai-utils.d.ts +8 -0
- package/dist/widget-ai-utils/dropdown/dropdown-ai-utils.d.ts +12 -0
- package/dist/widget-ai-utils/explanation/explanation-ai-utils.d.ts +12 -0
- package/dist/widget-ai-utils/expression/expression-ai-utils.d.ts +11 -0
- package/dist/widget-ai-utils/graded-group/graded-group-ai-utils.d.ts +15 -3
- package/dist/widget-ai-utils/graded-group-set/graded-group-set-ai-utils.d.ts +10 -0
- package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +35 -0
- package/dist/widget-ai-utils/group/group-ai-utils.d.ts +6 -0
- package/dist/widget-ai-utils/image/image-ai-utils.d.ts +16 -0
- package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +22 -0
- package/dist/widget-ai-utils/interactive-graph/interactive-graph-ai-utils.d.ts +61 -22
- package/dist/widget-ai-utils/label-image/label-image-ai-utils.d.ts +63 -0
- package/dist/widget-ai-utils/matcher/matcher-ai-utils.d.ts +40 -0
- package/dist/widget-ai-utils/matrix/matrix-ai-utils.d.ts +23 -0
- package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +52 -0
- package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +17 -0
- package/dist/widget-ai-utils/orderer/orderer-ai-utils.d.ts +23 -0
- package/dist/widget-ai-utils/prompt-types.d.ts +16 -2
- package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +38 -0
- package/dist/widget-ai-utils/sorter/sorter-ai-utils.d.ts +19 -0
- package/dist/widget-ai-utils/unsupported-widget.d.ts +6 -5
- package/dist/widgets/dropdown/dropdown.d.ts +1 -1
- package/dist/widgets/expression/expression.d.ts +2 -2
- package/dist/widgets/image/components/explore-image-modal-content.d.ts +1 -1
- package/dist/widgets/image/utils.d.ts +6 -0
- package/dist/widgets/interactive-graphs/graphs/exponential.d.ts +2 -2
- package/dist/widgets/interactive-graphs/graphs/logarithm.d.ts +12 -0
- package/dist/widgets/interactive-graphs/graphs/utils.d.ts +25 -0
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +6 -0
- package/dist/widgets/interactive-graphs/interactive-graph.d.ts +5 -3
- package/dist/widgets/interactive-graphs/reducer/initialize-graph-state.d.ts +5 -1
- package/dist/widgets/interactive-graphs/reducer/interactive-graph-action.d.ts +4 -0
- package/dist/widgets/interactive-graphs/types.d.ts +7 -1
- package/dist/widgets/label-image/label-image.d.ts +1 -1
- package/dist/widgets/mock-widgets/mock-widget.d.ts +1 -1
- package/dist/widgets/numeric-input/numeric-input.class.d.ts +1 -1
- package/dist/widgets/numeric-input/numeric-input.d.ts +1 -1
- package/dist/widgets/table/table.d.ts +1 -1
- package/package.json +10 -9
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type definition from "../../widgets/definition/definition";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a definition widget. Intended for consumption by AI tools.
|
|
5
|
+
* The definition widget usually appears inline in a paragraph of text. It
|
|
6
|
+
* renders a term and displays its definition in a popover when clicked.
|
|
7
|
+
* Learners' interactions with this widget are not graded.
|
|
8
|
+
*/
|
|
3
9
|
export type DefinitionPromptJSON = {
|
|
4
10
|
type: "definition";
|
|
11
|
+
/** The definition of the term. */
|
|
5
12
|
definition: string;
|
|
13
|
+
/** The term being defined. */
|
|
6
14
|
togglePrompt: string;
|
|
7
15
|
};
|
|
8
16
|
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof definition.widget>) => DefinitionPromptJSON;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import type dropdown from "../../widgets/dropdown/dropdown";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a dropdown widget. Intended for consumption by AI tools.
|
|
5
|
+
* The dropdown widget displays a menu of options.
|
|
6
|
+
*/
|
|
3
7
|
export type DropdownPromptJSON = {
|
|
4
8
|
type: "dropdown";
|
|
9
|
+
/**
|
|
10
|
+
* The configuration of the widget, set by the content creator.
|
|
11
|
+
*/
|
|
5
12
|
options: {
|
|
13
|
+
/** The choices present in the dropdown */
|
|
6
14
|
items: ReadonlyArray<string>;
|
|
7
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* The current state of the widget user interface. Usually represents a
|
|
18
|
+
* learner's attempt to answer a question.
|
|
19
|
+
*/
|
|
8
20
|
userInput: {
|
|
9
21
|
selectedIndex: number;
|
|
10
22
|
};
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import type explanation from "../../widgets/explanation/explanation";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing an explanation widget. Intended for consumption by AI tools.
|
|
5
|
+
* The explanation widget displays a disclosure element that the user can
|
|
6
|
+
* click to see more details about a topic. Learners' interactions with this
|
|
7
|
+
* widget are not graded.
|
|
8
|
+
*/
|
|
3
9
|
export type ExplanationPromptJSON = {
|
|
4
10
|
type: "explanation";
|
|
11
|
+
/**
|
|
12
|
+
* The clickable text shown when the disclosure is closed.
|
|
13
|
+
*/
|
|
5
14
|
showPrompt: string;
|
|
15
|
+
/**
|
|
16
|
+
* The text shown when the disclosure is open.
|
|
17
|
+
*/
|
|
6
18
|
explanation: string;
|
|
7
19
|
};
|
|
8
20
|
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof explanation.widget>) => ExplanationPromptJSON;
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { PerseusExpressionUserInput } from "@khanacademy/perseus-core";
|
|
2
|
+
/**
|
|
3
|
+
* JSON describing an expression widget. Intended for consumption by AI tools.
|
|
4
|
+
* The expression widget shows an input field that allows a user to input a
|
|
5
|
+
* math expression or equation.
|
|
6
|
+
*/
|
|
2
7
|
export type ExpressionPromptJSON = {
|
|
3
8
|
type: "expression";
|
|
9
|
+
/** The label shown on the input field */
|
|
4
10
|
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The current state of the widget user interface. Usually represents a
|
|
13
|
+
* learner's attempt to answer a question.
|
|
14
|
+
*/
|
|
5
15
|
userInput: {
|
|
16
|
+
/** The expression or equation input by the user. Uses TeX syntax. */
|
|
6
17
|
value: string;
|
|
7
18
|
};
|
|
8
19
|
};
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import type { RendererPromptJSON } from "../prompt-types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* JSON describing a graded group widget. Intended for consumption by AI tools.
|
|
4
|
+
* The graded group widget displays a self-contained question with its own
|
|
5
|
+
* "check answer" button. The learner's score on this question is not recorded.
|
|
6
|
+
* Graded groups are provided for learners to check their own understanding of
|
|
7
|
+
* a concept.
|
|
8
|
+
*/
|
|
9
|
+
export interface GradedGroupPromptJSON extends RendererPromptJSON {
|
|
3
10
|
type: "graded-group";
|
|
11
|
+
/** Displayed above the graded group. */
|
|
4
12
|
title: string;
|
|
5
|
-
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Explanation of the question, which the learner can show or hide by
|
|
15
|
+
* clicking a button. There is no penalty for looking at this hint.
|
|
16
|
+
*/
|
|
17
|
+
hint: RendererPromptJSON;
|
|
18
|
+
}
|
|
7
19
|
export declare const getPromptJSON: (title: string, rendererJSON: RendererPromptJSON | undefined, hintRendererJSON: RendererPromptJSON) => GradedGroupPromptJSON;
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type gradedGroupSet from "../../widgets/graded-group-set";
|
|
2
2
|
import type { GradedGroupPromptJSON } from "../graded-group/graded-group-ai-utils";
|
|
3
3
|
import type React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* JSON describing a graded group set widget. Intended for consumption by AI tools.
|
|
6
|
+
* A graded group set displays several review questions (GradedGroups) in a
|
|
7
|
+
* carousel-like UI. The learner's score on a graded group set is not recorded.
|
|
8
|
+
* Graded group sets are provided for learners to check their own understanding
|
|
9
|
+
* of a concept.
|
|
10
|
+
*/
|
|
4
11
|
export type GradedGroupSetPromptJSON = {
|
|
5
12
|
type: "graded-group-set";
|
|
13
|
+
/** The configuration of the widget, set by the content creator. */
|
|
6
14
|
options: {
|
|
15
|
+
/** The number of questions (`GradedGroup`s) in this widget */
|
|
7
16
|
groupCount: number;
|
|
17
|
+
/** The currently-displayed question */
|
|
8
18
|
currentGroup: GradedGroupPromptJSON;
|
|
9
19
|
};
|
|
10
20
|
};
|
|
@@ -1,17 +1,52 @@
|
|
|
1
1
|
import type grapher from "../../widgets/grapher/grapher";
|
|
2
2
|
import type { GrapherAnswerTypes } from "@khanacademy/perseus-core";
|
|
3
3
|
import type React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* JSON describing a grapher widget. Intended for consumption by AI tools.
|
|
6
|
+
* The grapher widget displays a Cartesian plane where the learner can plot an
|
|
7
|
+
* equation by clicking and dragging control points.
|
|
8
|
+
*/
|
|
4
9
|
export type GrapherPromptJSON = {
|
|
5
10
|
type: "grapher";
|
|
11
|
+
/** The configuration of the widget, set by the content creator. */
|
|
6
12
|
options: {
|
|
13
|
+
/**
|
|
14
|
+
* The types of equations the learner can plot. If there is more than
|
|
15
|
+
* one entry in this array, the widget displays a set of buttons for
|
|
16
|
+
* selecting the graph type.
|
|
17
|
+
*/
|
|
7
18
|
availableTypes: ReadonlyArray<string>;
|
|
19
|
+
/**
|
|
20
|
+
* The bounds of the graph, in the format
|
|
21
|
+
* `[[xMin, xMax], [yMin, yMax]]`.
|
|
22
|
+
*/
|
|
8
23
|
range: [x: [min: number, max: number], y: [min: number, max: number]];
|
|
24
|
+
/**
|
|
25
|
+
* Labels for the x and y axes of the graph, in the format `[x, y]`.
|
|
26
|
+
*/
|
|
9
27
|
labels: ReadonlyArray<string>;
|
|
28
|
+
/**
|
|
29
|
+
* The spacing between tick markings on the graph axes, measured in
|
|
30
|
+
* units on the Cartesian plane. Format: `[xTickStep, yTickStep]`.
|
|
31
|
+
*/
|
|
10
32
|
tickStep: [number, number];
|
|
33
|
+
/**
|
|
34
|
+
* The spacing between grid lines, measured in units on the Cartesian
|
|
35
|
+
* plane. Format: `[xGridStep, yGridStep]`.
|
|
36
|
+
*/
|
|
11
37
|
gridStep?: [number, number];
|
|
38
|
+
/**
|
|
39
|
+
* Control points snap to coordinates that are multiples of the snap
|
|
40
|
+
* step. Format: `[xSnapStep, ySnapStep]`.
|
|
41
|
+
*/
|
|
12
42
|
snapStep?: [number, number];
|
|
43
|
+
/** An image displayed behind the graph */
|
|
13
44
|
backgroundImageUrl?: string | null;
|
|
14
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* The current state of the widget user interface. Usually represents a
|
|
48
|
+
* learner's attempt to answer a question.
|
|
49
|
+
*/
|
|
15
50
|
userInput: GrapherAnswerTypes;
|
|
16
51
|
};
|
|
17
52
|
export declare const getPromptJSON: (widgetData: React.ComponentProps<typeof grapher.widget>) => GrapherPromptJSON;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { RendererPromptJSON } from "../prompt-types";
|
|
2
|
+
/**
|
|
3
|
+
* JSON describing a group widget. Intended for consumption by AI tools.
|
|
4
|
+
* A group widget is simply an embedded Markdown document that can contain
|
|
5
|
+
* other widgets. To the user, the group widget looks like part of the
|
|
6
|
+
* surrounding document.
|
|
7
|
+
*/
|
|
2
8
|
export type GroupPromptJSON = RendererPromptJSON & {
|
|
3
9
|
type: "group";
|
|
4
10
|
};
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type image from "../../widgets/image/image.class";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing an image widget. Intended for consumption by AI tools.
|
|
5
|
+
*/
|
|
3
6
|
export type ImagePromptJSON = {
|
|
4
7
|
type: "image";
|
|
8
|
+
/** Configuration set by the content creator. */
|
|
5
9
|
options: {
|
|
10
|
+
/**
|
|
11
|
+
* Text displayed to screenreaders and browsers without graphical
|
|
12
|
+
* capabilities
|
|
13
|
+
*/
|
|
6
14
|
altText: string;
|
|
15
|
+
/**
|
|
16
|
+
* Displayed above the image. May contain Markdown formatting, and TeX
|
|
17
|
+
* delimited by dollar signs, e.g. `$\dfrac{1}{2}$`.
|
|
18
|
+
*/
|
|
7
19
|
title: string;
|
|
20
|
+
/**
|
|
21
|
+
* Displayed below the image. May contain Markdown formatting, and TeX
|
|
22
|
+
* delimited by dollar signs, e.g. `$\dfrac{1}{2}$`.
|
|
23
|
+
*/
|
|
8
24
|
caption: string;
|
|
9
25
|
imageUrl: string | null | undefined;
|
|
10
26
|
};
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import type inputNumber from "../../widgets/input-number/input-number";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing an InputNumber widget. Intended for consumption by AI tools.
|
|
5
|
+
* An InputNumber displays a text field where users can enter numbers in a
|
|
6
|
+
* variety of formats: decimals, integers, fractions, mixed numbers,
|
|
7
|
+
* percentages, and multiples of pi. The allowed formats are configurable by
|
|
8
|
+
* the content creator.
|
|
9
|
+
*/
|
|
3
10
|
export type InputNumberPromptJSON = {
|
|
4
11
|
type: "input-number";
|
|
12
|
+
/** The configuration of the widget, set by the content creator. */
|
|
5
13
|
options: {
|
|
14
|
+
/**
|
|
15
|
+
* Indicates how answers in unsimplified form are scored.
|
|
16
|
+
*
|
|
17
|
+
* - "optional" means the answer can be unsimplified.
|
|
18
|
+
* - "required" means an unsimplified answer is considered invalid,
|
|
19
|
+
* and the learner can try again without penalty.
|
|
20
|
+
* - "enforced" means unsimplified answers are counted as incorrect.
|
|
21
|
+
*/
|
|
6
22
|
simplify: string;
|
|
23
|
+
/** The expected numeric form, e.g. "rational", "decimal" */
|
|
7
24
|
answerType: string;
|
|
8
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* The current state of the widget user interface. Usually represents a
|
|
28
|
+
* learner's attempt to answer a question.
|
|
29
|
+
*/
|
|
9
30
|
userInput: {
|
|
31
|
+
/** The text input by the user */
|
|
10
32
|
value: string;
|
|
11
33
|
};
|
|
12
34
|
};
|
|
@@ -4,61 +4,78 @@ import type { PerseusGraphType } from "@khanacademy/perseus-core";
|
|
|
4
4
|
import type React from "react";
|
|
5
5
|
type Coord = [x: number, y: number];
|
|
6
6
|
type CollinearTuple = readonly [Coord, Coord];
|
|
7
|
-
type
|
|
8
|
-
type:
|
|
9
|
-
|
|
10
|
-
type AngleGraphOptions = BaseGraphOptions & {
|
|
11
|
-
angleOffsetDegrees: number;
|
|
7
|
+
type AngleGraphOptions = {
|
|
8
|
+
type: "angle";
|
|
9
|
+
angleOffsetDegrees: number | undefined;
|
|
12
10
|
startCoords?: readonly [Coord, Coord, Coord];
|
|
13
11
|
};
|
|
14
|
-
type CircleGraphOptions =
|
|
12
|
+
type CircleGraphOptions = {
|
|
13
|
+
type: "circle";
|
|
15
14
|
startParams: {
|
|
16
15
|
center?: Coord;
|
|
17
16
|
radius?: number;
|
|
18
17
|
};
|
|
19
18
|
};
|
|
20
|
-
type LinearGraphOptions =
|
|
19
|
+
type LinearGraphOptions = {
|
|
20
|
+
type: "linear";
|
|
21
21
|
startCoords?: CollinearTuple;
|
|
22
22
|
};
|
|
23
|
-
type LinearSystemGraphOptions =
|
|
23
|
+
type LinearSystemGraphOptions = {
|
|
24
|
+
type: "linear-system";
|
|
24
25
|
startCoords?: readonly CollinearTuple[];
|
|
25
26
|
};
|
|
26
|
-
type PointGraphOptions =
|
|
27
|
+
type PointGraphOptions = {
|
|
28
|
+
type: "point";
|
|
27
29
|
numPoints?: number | "unlimited";
|
|
28
30
|
startCoords?: readonly Coord[];
|
|
29
31
|
};
|
|
30
|
-
type PolygonGraphOptions =
|
|
32
|
+
type PolygonGraphOptions = {
|
|
33
|
+
type: "polygon";
|
|
31
34
|
match?: string;
|
|
32
35
|
numSides?: number | "unlimited";
|
|
33
36
|
startCoords?: readonly Coord[];
|
|
34
37
|
};
|
|
35
|
-
type QuadraticGraphOptions =
|
|
38
|
+
type QuadraticGraphOptions = {
|
|
39
|
+
type: "quadratic";
|
|
36
40
|
startCoords?: readonly [Coord, Coord, Coord];
|
|
37
41
|
};
|
|
38
|
-
type RayGraphOptions =
|
|
42
|
+
type RayGraphOptions = {
|
|
43
|
+
type: "ray";
|
|
39
44
|
startCoords?: CollinearTuple;
|
|
40
45
|
};
|
|
41
|
-
type SegmentGraphOptions =
|
|
46
|
+
type SegmentGraphOptions = {
|
|
47
|
+
type: "segment";
|
|
42
48
|
numSegments?: number;
|
|
43
|
-
startCoords?: CollinearTuple;
|
|
49
|
+
startCoords?: CollinearTuple[];
|
|
44
50
|
};
|
|
45
|
-
type SinusoidGraphOptions =
|
|
51
|
+
type SinusoidGraphOptions = {
|
|
52
|
+
type: "sinusoid";
|
|
46
53
|
startCoords?: readonly Coord[];
|
|
47
54
|
};
|
|
48
|
-
type AbsoluteValueGraphOptions =
|
|
55
|
+
type AbsoluteValueGraphOptions = {
|
|
56
|
+
type: "absolute-value";
|
|
49
57
|
startCoords?: readonly [Coord, Coord];
|
|
50
58
|
};
|
|
51
|
-
type TangentGraphOptions =
|
|
59
|
+
type TangentGraphOptions = {
|
|
60
|
+
type: "tangent";
|
|
52
61
|
startCoords?: readonly Coord[];
|
|
53
62
|
};
|
|
54
|
-
type ExponentialGraphOptions =
|
|
63
|
+
type ExponentialGraphOptions = {
|
|
64
|
+
type: "exponential";
|
|
65
|
+
startCoords?: {
|
|
66
|
+
coords: readonly [Coord, Coord];
|
|
67
|
+
asymptote: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
type LogarithmGraphOptions = {
|
|
71
|
+
type: "logarithm";
|
|
55
72
|
startCoords?: {
|
|
56
73
|
coords: readonly [Coord, Coord];
|
|
57
74
|
asymptote: number;
|
|
58
75
|
};
|
|
59
76
|
};
|
|
60
77
|
type NoneGraphOptions = Record<string, never>;
|
|
61
|
-
type GraphOptions = AbsoluteValueGraphOptions | AngleGraphOptions | CircleGraphOptions | ExponentialGraphOptions | LinearGraphOptions | LinearSystemGraphOptions | NoneGraphOptions | PointGraphOptions | PolygonGraphOptions | QuadraticGraphOptions | RayGraphOptions | SegmentGraphOptions | SinusoidGraphOptions | TangentGraphOptions;
|
|
78
|
+
type GraphOptions = AbsoluteValueGraphOptions | AngleGraphOptions | CircleGraphOptions | ExponentialGraphOptions | LinearGraphOptions | LinearSystemGraphOptions | NoneGraphOptions | PointGraphOptions | PolygonGraphOptions | QuadraticGraphOptions | RayGraphOptions | SegmentGraphOptions | SinusoidGraphOptions | TangentGraphOptions | LogarithmGraphOptions;
|
|
62
79
|
type AngleUserInput = {
|
|
63
80
|
coords?: readonly [Coord, Coord, Coord];
|
|
64
81
|
angleOffsetDegrees?: number;
|
|
@@ -98,17 +115,39 @@ type ExponentialUserInput = {
|
|
|
98
115
|
coords?: readonly Coord[] | null;
|
|
99
116
|
asymptote?: number | null;
|
|
100
117
|
};
|
|
118
|
+
type LogarithmUserInput = {
|
|
119
|
+
coords?: readonly Coord[] | null;
|
|
120
|
+
asymptote?: number | null;
|
|
121
|
+
};
|
|
101
122
|
type TangentUserInput = {
|
|
102
123
|
coords?: readonly Coord[] | null;
|
|
103
124
|
};
|
|
104
|
-
type UserInput = AbsoluteValueUserInput | AngleUserInput | CircleUserInput | ExponentialUserInput | LinearUserInput | LinearSystemInput | PointUserInput | PolygonUserInput | QuadraticUserInput | RayUserInput | SegmentUserInput | SinusoidUserInput | TangentUserInput;
|
|
125
|
+
type UserInput = AbsoluteValueUserInput | AngleUserInput | CircleUserInput | ExponentialUserInput | LinearUserInput | LinearSystemInput | PointUserInput | PolygonUserInput | QuadraticUserInput | RayUserInput | SegmentUserInput | SinusoidUserInput | TangentUserInput | LogarithmUserInput;
|
|
126
|
+
/**
|
|
127
|
+
* JSON describing an interactive graph widget. Intended for consumption by AI tools.
|
|
128
|
+
* An interactive graph plots equations and draws geometric figures on a
|
|
129
|
+
* Cartesian plane. The user can move and reshape these elements by dragging
|
|
130
|
+
* control points.
|
|
131
|
+
*/
|
|
105
132
|
export type InteractiveGraphPromptJSON = {
|
|
106
133
|
type: "interactive-graph";
|
|
134
|
+
/**
|
|
135
|
+
* The configuration of the widget, set by the content creator.
|
|
136
|
+
*/
|
|
107
137
|
options: {
|
|
138
|
+
/**
|
|
139
|
+
* Configuration of the plotted equation or geometric figure.
|
|
140
|
+
*/
|
|
108
141
|
graph: GraphOptions;
|
|
142
|
+
/**
|
|
143
|
+
* The bounds of the graph. Format: `[[xMin, xMax], [yMin, yMax]]`
|
|
144
|
+
*/
|
|
145
|
+
range: [x: [min: number, max: number], y: [min: number, max: number]];
|
|
146
|
+
/**
|
|
147
|
+
* Labels on the graph axes. Format: `[xLabel, yLabel]`.
|
|
148
|
+
*/
|
|
149
|
+
labels: string[];
|
|
109
150
|
backgroundImageUrl: string | null | undefined;
|
|
110
|
-
range: [min: number, max: number][];
|
|
111
|
-
labels: ReadonlyArray<string>;
|
|
112
151
|
};
|
|
113
152
|
userInput: UserInput;
|
|
114
153
|
};
|
|
@@ -1,22 +1,85 @@
|
|
|
1
1
|
import type labelImage from "../../widgets/label-image/label-image";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* A marker placed on the image, representing a location the learner must
|
|
5
|
+
* label. Used in the `options` section to describe the marker's identity and
|
|
6
|
+
* correct answers.
|
|
7
|
+
*/
|
|
3
8
|
type BaseMarker = {
|
|
9
|
+
/**
|
|
10
|
+
* The text label identifying this marker's position on the image. Not
|
|
11
|
+
* shown directly to the learner; used to correlate options markers with
|
|
12
|
+
* user input markers.
|
|
13
|
+
*/
|
|
4
14
|
label: string;
|
|
5
15
|
};
|
|
16
|
+
/**
|
|
17
|
+
* A marker as it appears in the user input section. Extends the base marker
|
|
18
|
+
* with optional correct answers (when present) and the learner's current
|
|
19
|
+
* selections.
|
|
20
|
+
*/
|
|
6
21
|
type UserInputMarker = {
|
|
22
|
+
/**
|
|
23
|
+
* The text label identifying this marker's position on the image.
|
|
24
|
+
* Corresponds to the matching marker in `options.markers`.
|
|
25
|
+
*/
|
|
7
26
|
label: string;
|
|
27
|
+
/**
|
|
28
|
+
* The set of correct answer labels for this marker, as defined by the
|
|
29
|
+
* content creator. Only present when the marker has designated correct
|
|
30
|
+
* answers. A marker without answers is used purely for labeling purposes
|
|
31
|
+
* and is not scored.
|
|
32
|
+
*/
|
|
8
33
|
answers?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* The answer labels the learner has selected for this marker. Each entry
|
|
36
|
+
* is one of the strings from `options.choices`. May be absent or empty if
|
|
37
|
+
* the learner has not yet made a selection for this marker.
|
|
38
|
+
*/
|
|
9
39
|
selected?: ReadonlyArray<string>;
|
|
10
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* JSON describing a label-image widget. Intended for consumption by AI tools.
|
|
43
|
+
* A label-image widget displays an image with interactive markers placed at
|
|
44
|
+
* specific locations. The learner selects one or more answer labels from a
|
|
45
|
+
* shared list of choices for each marker.
|
|
46
|
+
*/
|
|
11
47
|
export type LabelImagePromptJSON = {
|
|
12
48
|
type: "label-image";
|
|
49
|
+
/**
|
|
50
|
+
* The configuration of the widget, set by the content creator.
|
|
51
|
+
*/
|
|
13
52
|
options: {
|
|
53
|
+
/**
|
|
54
|
+
* The list of answer choices available to the learner. Each marker's
|
|
55
|
+
* selection must come from this list.
|
|
56
|
+
*/
|
|
14
57
|
choices: ReadonlyArray<string>;
|
|
58
|
+
/**
|
|
59
|
+
* The URL of the image on which markers are placed.
|
|
60
|
+
*/
|
|
15
61
|
imageUrl: string;
|
|
62
|
+
/**
|
|
63
|
+
* Accessible alternative text for the image, used in the `alt`
|
|
64
|
+
* attribute.
|
|
65
|
+
*/
|
|
16
66
|
imageAlt: string;
|
|
67
|
+
/**
|
|
68
|
+
* The markers placed on the image by the content creator, each
|
|
69
|
+
* identifying a location the learner must label.
|
|
70
|
+
*/
|
|
17
71
|
markers: BaseMarker[];
|
|
18
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* The current state of the widget user interface. Usually represents a
|
|
75
|
+
* learner's attempt to answer a question.
|
|
76
|
+
*/
|
|
19
77
|
userInput: {
|
|
78
|
+
/**
|
|
79
|
+
* The learner's selections for each marker, parallel to
|
|
80
|
+
* `options.markers`. Each element corresponds to the marker at the
|
|
81
|
+
* same index.
|
|
82
|
+
*/
|
|
20
83
|
markers: UserInputMarker[];
|
|
21
84
|
};
|
|
22
85
|
};
|
|
@@ -1,15 +1,55 @@
|
|
|
1
1
|
import type matcher from "../../widgets/matcher/matcher";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a matcher widget. Intended for consumption by AI tools.
|
|
5
|
+
* A matcher displays two columns of items that the learner must match by
|
|
6
|
+
* dragging cards in the right column to align with their corresponding items
|
|
7
|
+
* in the left column.
|
|
8
|
+
*/
|
|
3
9
|
export type MatcherPromptJSON = {
|
|
4
10
|
type: "matcher";
|
|
11
|
+
/**
|
|
12
|
+
* The configuration of the widget, set by the content creator.
|
|
13
|
+
*/
|
|
5
14
|
options: {
|
|
15
|
+
/**
|
|
16
|
+
* Labels for the column headings. Contains exactly 2 values:
|
|
17
|
+
* the left column label and the right column label.
|
|
18
|
+
* e.g. `["Concepts", "Things"]`
|
|
19
|
+
*/
|
|
6
20
|
labels: ReadonlyArray<string>;
|
|
21
|
+
/**
|
|
22
|
+
* The items shown in the left column that the learner must match
|
|
23
|
+
* against. e.g. `["Fruit", "Color", "Clothes"]`
|
|
24
|
+
*/
|
|
7
25
|
left: ReadonlyArray<string>;
|
|
26
|
+
/**
|
|
27
|
+
* The draggable cards in the right column that the learner arranges
|
|
28
|
+
* to match the left column items. e.g. `["Red", "Shirt", "Banana"]`
|
|
29
|
+
*/
|
|
8
30
|
right: ReadonlyArray<string>;
|
|
31
|
+
/**
|
|
32
|
+
* When true, the items in the left column are draggable and the
|
|
33
|
+
* learner must put them into the correct order. When false, the left
|
|
34
|
+
* column is static.
|
|
35
|
+
*/
|
|
9
36
|
orderMatters: boolean;
|
|
10
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* The current state of the widget user interface. Usually represents a
|
|
40
|
+
* learner's attempt to answer a question.
|
|
41
|
+
*/
|
|
11
42
|
userInput: {
|
|
43
|
+
/**
|
|
44
|
+
* The current order of items in the left column. When `orderMatters`
|
|
45
|
+
* is false, the left column is fixed and only right can be reordered.
|
|
46
|
+
*/
|
|
12
47
|
left: ReadonlyArray<string>;
|
|
48
|
+
/**
|
|
49
|
+
* The current order of cards in the right column, as arranged by the
|
|
50
|
+
* learner. Each element corresponds to the left column item at the
|
|
51
|
+
* same index.
|
|
52
|
+
*/
|
|
13
53
|
right: ReadonlyArray<string>;
|
|
14
54
|
};
|
|
15
55
|
};
|
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import type matrix from "../../widgets/matrix/matrix";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a matrix widget. Intended for consumption by AI tools.
|
|
5
|
+
* A matrix widget displays a grid of numeric cells that the learner fills in.
|
|
6
|
+
*/
|
|
3
7
|
export type MatrixPromptJSON = {
|
|
4
8
|
type: "matrix";
|
|
9
|
+
/**
|
|
10
|
+
* The configuration of the widget, set by the content creator.
|
|
11
|
+
*/
|
|
5
12
|
options: {
|
|
13
|
+
/**
|
|
14
|
+
* The number of rows in the matrix grid.
|
|
15
|
+
*/
|
|
6
16
|
height: number;
|
|
17
|
+
/**
|
|
18
|
+
* The number of columns in the matrix grid.
|
|
19
|
+
*/
|
|
7
20
|
width: number;
|
|
8
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* The current state of the widget user interface. Usually represents a
|
|
24
|
+
* learner's attempt to answer a question.
|
|
25
|
+
*/
|
|
9
26
|
userInput: {
|
|
27
|
+
/**
|
|
28
|
+
* The current values entered by the learner. Each element of the outer
|
|
29
|
+
* array represents a row; each element of the inner arrays represents a
|
|
30
|
+
* cell value within that row. Cells that have not been filled in are
|
|
31
|
+
* represented as empty strings.
|
|
32
|
+
*/
|
|
10
33
|
answerRows: ReadonlyArray<ReadonlyArray<string>>;
|
|
11
34
|
};
|
|
12
35
|
};
|
|
@@ -1,14 +1,66 @@
|
|
|
1
1
|
import type numberLine from "../../widgets/number-line/number-line";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a number-line widget. Intended for consumption by AI tools.
|
|
5
|
+
* A number-line widget displays a horizontal number line with a draggable
|
|
6
|
+
* point. The learner positions the point to answer a question, optionally
|
|
7
|
+
* selecting an inequality relationship (e.g. ≤, ≥) when the widget is in
|
|
8
|
+
* inequality mode.
|
|
9
|
+
*/
|
|
3
10
|
export type NumberLinePromptJSON = {
|
|
4
11
|
type: "number-line";
|
|
12
|
+
/**
|
|
13
|
+
* The configuration of the widget, set by the content creator.
|
|
14
|
+
*/
|
|
5
15
|
options: {
|
|
16
|
+
/**
|
|
17
|
+
* The numeric values of the left and right endpoints of the number
|
|
18
|
+
* line, e.g. `[-5, 5]`. These bounds also constrain where the learner
|
|
19
|
+
* can place the point.
|
|
20
|
+
*/
|
|
6
21
|
range: ReadonlyArray<number>;
|
|
22
|
+
/**
|
|
23
|
+
* The number of sub-intervals between adjacent tick marks into which
|
|
24
|
+
* the point can snap. Higher values allow finer-grained placement.
|
|
25
|
+
* For example, a value of `4` means the point snaps to quarter-tick
|
|
26
|
+
* increments.
|
|
27
|
+
*/
|
|
7
28
|
snapDivisions: number;
|
|
8
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* The current state of the widget user interface. Usually represents a
|
|
32
|
+
* learner's attempt to answer a question.
|
|
33
|
+
*/
|
|
9
34
|
userInput: {
|
|
35
|
+
/**
|
|
36
|
+
* The numeric axis value where the learner has placed the point,
|
|
37
|
+
* e.g. `3.5` on a `[-5, 5]` number line. Clamped to `options.range`
|
|
38
|
+
* and snapped to the nearest tick increment.
|
|
39
|
+
*/
|
|
10
40
|
numLinePosition: number;
|
|
41
|
+
/**
|
|
42
|
+
* The number of tick-mark divisions currently shown on the number
|
|
43
|
+
* line. When the widget's `isTickCtrl` option is enabled, the learner
|
|
44
|
+
* can adjust this value; otherwise it is set by the content author.
|
|
45
|
+
*/
|
|
11
46
|
numDivisions: number;
|
|
47
|
+
/**
|
|
48
|
+
* The number line widget can represent a set of real numbers that is
|
|
49
|
+
* greater than, greater than or equal to, less than, or less than or
|
|
50
|
+
* equal to some number. Visually, the portion of the number line
|
|
51
|
+
* included in this set is shaded. The `rel` property describes the
|
|
52
|
+
* inequality relation the learner has selected.
|
|
53
|
+
*
|
|
54
|
+
* Possible values:
|
|
55
|
+
* - `"eq"` – equals (standard point, no inequality shading)
|
|
56
|
+
* - `"lt"` – less than
|
|
57
|
+
* - `"gt"` – greater than
|
|
58
|
+
* - `"le"` – less than or equal to
|
|
59
|
+
* - `"ge"` – greater than or equal to
|
|
60
|
+
*
|
|
61
|
+
* Only meaningful when the widget is configured for inequality mode;
|
|
62
|
+
* otherwise always `"eq"`.
|
|
63
|
+
*/
|
|
12
64
|
rel: string;
|
|
13
65
|
};
|
|
14
66
|
};
|
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
import type numericInput from "../../widgets/numeric-input/numeric-input.class";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a numeric-input widget. Intended for consumption by AI tools.
|
|
5
|
+
* A numeric-input widget displays a single text field where the learner types
|
|
6
|
+
* a numeric answer (integer, decimal, fraction, etc.).
|
|
7
|
+
*/
|
|
3
8
|
export type NumericInputPromptJSON = {
|
|
4
9
|
type: "numeric-input";
|
|
10
|
+
/**
|
|
11
|
+
* Accessible label for the input field, set by the content creator.
|
|
12
|
+
* Shown to learners using screen readers to describe what value should
|
|
13
|
+
* be entered.
|
|
14
|
+
*/
|
|
5
15
|
label: string;
|
|
16
|
+
/**
|
|
17
|
+
* The current state of the widget user interface. Usually represents a
|
|
18
|
+
* learner's attempt to answer a question.
|
|
19
|
+
*/
|
|
6
20
|
userInput: {
|
|
21
|
+
/**
|
|
22
|
+
* The text currently entered in the input field by the learner.
|
|
23
|
+
*/
|
|
7
24
|
value: string;
|
|
8
25
|
};
|
|
9
26
|
};
|