@khanacademy/perseus 77.2.0 → 77.2.2
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 +1 -1
- package/dist/es/index.css.map +1 -1
- package/dist/es/index.js +11 -8
- package/dist/es/index.js.map +1 -1
- package/dist/hint-renderer.d.ts +15 -2
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +99 -6
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/renderer.d.ts +3 -3
- 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 +50 -21
- 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/interactive-graphs/interactive-graph.d.ts +1 -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 +9 -8
package/dist/renderer.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import TranslationLinter from "./translation-linter";
|
|
|
5
5
|
import WidgetContainer from "./widget-container";
|
|
6
6
|
import type { DependenciesContext } from "./dependencies";
|
|
7
7
|
import type { PerseusStrings } from "./strings";
|
|
8
|
-
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FocusPath, Widget, WidgetProps } from "./types";
|
|
8
|
+
import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FindWidgetsFunction, FocusPath, Widget, WidgetProps } from "./types";
|
|
9
9
|
import type { HandleUserInputCallback, InitializeUserInputCallback } from "./user-input-manager";
|
|
10
10
|
import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
|
|
11
11
|
import type { KeypadAPI } from "@khanacademy/math-input";
|
|
@@ -29,7 +29,7 @@ type Props = Partial<React.ContextType<typeof DependenciesContext>> & {
|
|
|
29
29
|
handleUserInput?: HandleUserInputCallback;
|
|
30
30
|
initializeUserInput?: InitializeUserInputCallback;
|
|
31
31
|
alwaysUpdate?: boolean;
|
|
32
|
-
findExternalWidgets:
|
|
32
|
+
findExternalWidgets: FindWidgetsFunction;
|
|
33
33
|
keypadElement?: KeypadAPI | null;
|
|
34
34
|
onRender: (node?: any) => void;
|
|
35
35
|
problemNum?: number;
|
|
@@ -147,7 +147,7 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
|
|
|
147
147
|
* Includes both widgets internal to this Renderer, and external widgets
|
|
148
148
|
* exposed by the `findExternalWidgets` prop.
|
|
149
149
|
*
|
|
150
|
-
* See `
|
|
150
|
+
* See `findInternalWidgets` for more information.
|
|
151
151
|
*/
|
|
152
152
|
findWidgets: (filterCriterion: FilterCriterion) => any;
|
|
153
153
|
getWidgetInstance: (id: string) => Widget | null | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { PerseusDependencies, PerseusDependenciesV2 } from "../types";
|
|
2
2
|
export declare const testDependencies: PerseusDependencies;
|
|
3
3
|
export declare const testDependenciesV2: PerseusDependenciesV2;
|
|
4
|
-
export declare const storybookTestDependencies: PerseusDependencies;
|
|
5
4
|
export declare const storybookDependenciesV2: PerseusDependenciesV2;
|
|
6
5
|
export declare const cypressTestDependencies: PerseusDependencies;
|
|
7
6
|
export declare const cypressDependenciesV2: PerseusDependenciesV2;
|
package/dist/types.d.ts
CHANGED
|
@@ -368,6 +368,7 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
|
|
|
368
368
|
getCorrectUserInput?: (widgetOptions: WidgetOptions) => TUserInput;
|
|
369
369
|
getStartUserInput?: (widgetOptions: WidgetOptions, problemNum: number) => TUserInput;
|
|
370
370
|
}>;
|
|
371
|
+
export type FindWidgetsFunction = (filterFunc: FilterCriterion) => ReadonlyArray<Widget | null | undefined>;
|
|
371
372
|
export type FilterCriterion = string | ((id: string, widgetInfo: PerseusWidget, widget?: Widget | null | undefined) => boolean);
|
|
372
373
|
/**
|
|
373
374
|
* The full set of props provided to all widgets when they are rendered. The
|
|
@@ -389,7 +390,7 @@ type UniversalWidgetProps<TUserInput = Empty, TrackingExtraArgs = Empty> = {
|
|
|
389
390
|
keypadElement?: any;
|
|
390
391
|
onFocus: (blurPath: FocusPath) => void;
|
|
391
392
|
onBlur: (blurPath: FocusPath) => void;
|
|
392
|
-
findWidgets:
|
|
393
|
+
findWidgets: FindWidgetsFunction;
|
|
393
394
|
reviewMode: boolean;
|
|
394
395
|
showSolutions?: ShowSolutions;
|
|
395
396
|
handleUserInput: (newUserInput: TUserInput, cb?: () => void, silent?: boolean) => void;
|
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import type categorizer from "../../widgets/categorizer/categorizer";
|
|
2
2
|
import type React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* JSON describing a categorizer widget. Intended for consumption by AI tools.
|
|
5
|
+
* A categorizer displays a table where each row represents an item to be
|
|
6
|
+
* categorized, and each column represents a category. Each table cell contains
|
|
7
|
+
* a bubble that the learner can fill to indicate that that item belongs in
|
|
8
|
+
* that category. Only one bubble in each row can be filled. Learners fill
|
|
9
|
+
* bubbles by clicking on them.
|
|
10
|
+
*/
|
|
3
11
|
export type CategorizerPromptJSON = {
|
|
4
12
|
type: "categorizer";
|
|
13
|
+
/**
|
|
14
|
+
* The configuration of the widget, set by the content creator.
|
|
15
|
+
*/
|
|
5
16
|
options: {
|
|
17
|
+
/**
|
|
18
|
+
* The items for the learner to categorize.
|
|
19
|
+
*/
|
|
6
20
|
items: ReadonlyArray<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Categories to which items can be assigned.
|
|
23
|
+
*/
|
|
7
24
|
categories: ReadonlyArray<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
|
+
/**
|
|
32
|
+
* The category indices for each item. Elements in this array
|
|
33
|
+
* correspond to elements of `options.items`, and refer to indices of
|
|
34
|
+
* the `categories` array. For example, a value of `[2, null, 0]` means
|
|
35
|
+
* that the first item is in the category at index 2, the second item
|
|
36
|
+
* has not been assigned to a category, and the third item is in the
|
|
37
|
+
* category at index 0.
|
|
38
|
+
*/
|
|
10
39
|
itemToCategoryMapping: ReadonlyArray<number | null | undefined>;
|
|
11
40
|
};
|
|
12
41
|
};
|
|
@@ -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,60 +4,71 @@ 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";
|
|
55
65
|
startCoords?: {
|
|
56
66
|
coords: readonly [Coord, Coord];
|
|
57
67
|
asymptote: number;
|
|
58
68
|
};
|
|
59
69
|
};
|
|
60
|
-
type LogarithmGraphOptions =
|
|
70
|
+
type LogarithmGraphOptions = {
|
|
71
|
+
type: "logarithm";
|
|
61
72
|
startCoords?: {
|
|
62
73
|
coords: readonly [Coord, Coord];
|
|
63
74
|
asymptote: number;
|
|
@@ -112,13 +123,31 @@ type TangentUserInput = {
|
|
|
112
123
|
coords?: readonly Coord[] | null;
|
|
113
124
|
};
|
|
114
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
|
+
*/
|
|
115
132
|
export type InteractiveGraphPromptJSON = {
|
|
116
133
|
type: "interactive-graph";
|
|
134
|
+
/**
|
|
135
|
+
* The configuration of the widget, set by the content creator.
|
|
136
|
+
*/
|
|
117
137
|
options: {
|
|
138
|
+
/**
|
|
139
|
+
* Configuration of the plotted equation or geometric figure.
|
|
140
|
+
*/
|
|
118
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[];
|
|
119
150
|
backgroundImageUrl: string | null | undefined;
|
|
120
|
-
range: [min: number, max: number][];
|
|
121
|
-
labels: ReadonlyArray<string>;
|
|
122
151
|
};
|
|
123
152
|
userInput: UserInput;
|
|
124
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
|
};
|