@khanacademy/perseus-core 23.6.1 → 23.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-schema.d.ts +773 -18
- package/dist/es/index.item-splitting.js +1 -1
- package/dist/es/index.item-splitting.js.map +1 -1
- package/dist/es/index.js +6 -4
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.item-splitting.js +1 -1
- package/dist/index.item-splitting.js.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/interactive-graph-user-input.d.ts +16 -0
- package/dist/parse-perseus-json/perseus-parsers/interactive-graph-widget.d.ts +48 -0
- package/dist/utils/generators/interactive-graph-widget-generator.d.ts +2 -1
- package/dist/utils/remove-orphaned-widgets.d.ts +13 -0
- package/dist/validation.types.d.ts +358 -2
- package/package.json +1 -1
package/dist/data-schema.d.ts
CHANGED
|
@@ -87,11 +87,14 @@ export type MakeWidgetMap<TRegistry> = {
|
|
|
87
87
|
* Our core set of Perseus widgets.
|
|
88
88
|
*
|
|
89
89
|
* This interface is the basis for "registering" all Perseus widget types.
|
|
90
|
+
*
|
|
90
91
|
* There should be one key/value pair for each supported widget. If you create
|
|
91
92
|
* a new widget, an entry should be added to this interface. Note that this
|
|
92
93
|
* only registers the widget options type, you'll also need to register the
|
|
93
|
-
* widget so that it's available at runtime
|
|
94
|
-
*
|
|
94
|
+
* widget so that it's available at runtime using `registerWidget` in this
|
|
95
|
+
* library (as well as equivalent `registerWidget` functions in
|
|
96
|
+
* `@khanacademy/perseus` (for UI support) and `@khanacademy/perseus-score`
|
|
97
|
+
* (for scoring support)).
|
|
95
98
|
*
|
|
96
99
|
* Importantly, the key should be the name that is used in widget IDs. For most
|
|
97
100
|
* widgets that is the same as the widget option's `type` field. In cases where
|
|
@@ -193,13 +196,20 @@ export type PerseusWidget = PerseusWidgetTypes[keyof PerseusWidgetTypes];
|
|
|
193
196
|
/**
|
|
194
197
|
* A "PerseusItem" is a classic Perseus item. It is rendered by the
|
|
195
198
|
* `ServerItemRenderer` and the layout is pre-set.
|
|
196
|
-
*
|
|
197
|
-
* To render more complex Perseus items, see the `Item` type in the multi item
|
|
198
|
-
* area.
|
|
199
199
|
*/
|
|
200
200
|
export type PerseusItem = {
|
|
201
|
+
/** The details of the question being asked to the user. */
|
|
201
202
|
question: PerseusRenderer;
|
|
203
|
+
/**
|
|
204
|
+
* A collection of hints to be offered to the user that support answering
|
|
205
|
+
* the question.
|
|
206
|
+
*/
|
|
202
207
|
hints: Hint[];
|
|
208
|
+
/**
|
|
209
|
+
* Question helpers that should be made available to the user. Perseus
|
|
210
|
+
* itself does not ship with any of these tools, they are strictly hints to
|
|
211
|
+
* the host application.
|
|
212
|
+
*/
|
|
203
213
|
answerArea: PerseusAnswerArea | null | undefined;
|
|
204
214
|
};
|
|
205
215
|
/**
|
|
@@ -208,16 +218,25 @@ export type PerseusItem = {
|
|
|
208
218
|
*/
|
|
209
219
|
export type PerseusArticle = PerseusRenderer | PerseusRenderer[];
|
|
210
220
|
export type Version = {
|
|
221
|
+
/** The major part of the version */
|
|
211
222
|
major: number;
|
|
223
|
+
/** The minor part of the version */
|
|
212
224
|
minor: number;
|
|
213
225
|
};
|
|
214
226
|
export type PerseusRenderer = {
|
|
215
227
|
/**
|
|
216
228
|
* Translatable Markdown content to be rendered. May include references to
|
|
217
|
-
* widgets (as [[☃
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
229
|
+
* widgets (as `[[☃ widget-id]]`) or [deprecated] images (as ``). This markdown can also include Math in the form of
|
|
231
|
+
* TeX surrounded by `$` characters (eg. `Solve the following: $1 + 1 =
|
|
232
|
+
* ?$.`).
|
|
233
|
+
*
|
|
234
|
+
* For each widget found in the Markdown, there _must_ be an entry in the
|
|
235
|
+
* {@link PerseusRenderer.widgets} object using the widget-id as the key.
|
|
236
|
+
*
|
|
237
|
+
* For each image found in the Markdown, there can be an entry in the
|
|
238
|
+
* {@link PerseusRenderer.images} object with the key being the image's url
|
|
239
|
+
* which defines additional attributes for the image.
|
|
221
240
|
*/
|
|
222
241
|
content: string;
|
|
223
242
|
/**
|
|
@@ -233,7 +252,12 @@ export type PerseusRenderer = {
|
|
|
233
252
|
*/
|
|
234
253
|
metadata?: any;
|
|
235
254
|
/**
|
|
236
|
-
* A dictionary of {[imageUrl]: PerseusImageDetail}.
|
|
255
|
+
* A dictionary of {[imageUrl]: {@link PerseusImageDetail}}.
|
|
256
|
+
*
|
|
257
|
+
* @deprecated Use of inline images is deprecated in top-level Perseus
|
|
258
|
+
* content but may be used when widgets embed a PerseusRenderer (such as
|
|
259
|
+
* the `radio` widget). In top-level content, please use an `image` widget
|
|
260
|
+
* instead.
|
|
237
261
|
*/
|
|
238
262
|
images: {
|
|
239
263
|
[imageUrl: string]: PerseusImageDetail;
|
|
@@ -242,8 +266,10 @@ export type PerseusRenderer = {
|
|
|
242
266
|
export type Hint = PerseusRenderer & {
|
|
243
267
|
/**
|
|
244
268
|
* When `true`, causes the previous hint to be replaced with this hint when
|
|
245
|
-
* displayed.
|
|
246
|
-
*
|
|
269
|
+
* it is displayed.
|
|
270
|
+
*
|
|
271
|
+
* When `false`, the previous hint remains visible when this one is
|
|
272
|
+
* displayed. This allows for hints that build upon each other.
|
|
247
273
|
*/
|
|
248
274
|
replace?: boolean;
|
|
249
275
|
/**
|
|
@@ -257,9 +283,16 @@ export type Hint = PerseusRenderer & {
|
|
|
257
283
|
placeholder?: boolean;
|
|
258
284
|
};
|
|
259
285
|
export type PerseusImageDetail = {
|
|
286
|
+
/** The width of the image */
|
|
260
287
|
width: number;
|
|
288
|
+
/** the height of the image */
|
|
261
289
|
height: number;
|
|
262
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* ItemExtras represent extra UI elements that help the learner in answering
|
|
293
|
+
* the question (such as a calculator for questions where solving by hand is
|
|
294
|
+
* not material to testing understanding of the skill).
|
|
295
|
+
*/
|
|
263
296
|
export declare const ItemExtras: readonly ["calculator", "financialCalculatorMonthlyPayment", "financialCalculatorTotalAmount", "financialCalculatorTimeToPayOff", "periodicTable", "periodicTableWithKey"];
|
|
264
297
|
export type PerseusAnswerArea = Record<(typeof ItemExtras)[number], boolean>;
|
|
265
298
|
/**
|
|
@@ -267,12 +300,45 @@ export type PerseusAnswerArea = Record<(typeof ItemExtras)[number], boolean>;
|
|
|
267
300
|
* `Options` generic type represents the widget-specific option data.
|
|
268
301
|
*/
|
|
269
302
|
export type WidgetOptions<Type extends string, Options extends Record<string, any>> = {
|
|
303
|
+
/**
|
|
304
|
+
* The "type" of widget which will define what the Options field looks
|
|
305
|
+
* like.
|
|
306
|
+
*/
|
|
270
307
|
type: Type;
|
|
308
|
+
/**
|
|
309
|
+
* Whether this widget is displayed with the values and is immutable. For
|
|
310
|
+
* display only.
|
|
311
|
+
*/
|
|
271
312
|
static?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Whether a widget is scored. Usually true except for IFrame widgets (deprecated).
|
|
315
|
+
* Default: true
|
|
316
|
+
*/
|
|
272
317
|
graded?: boolean;
|
|
318
|
+
/**
|
|
319
|
+
* The HTML alignment of the widget. "default" or "block".
|
|
320
|
+
*
|
|
321
|
+
* If the alignment is "default", it gets the default alignment from the
|
|
322
|
+
* widget logic, which can be various other alignments (e.g.
|
|
323
|
+
* "inline-block", "inline", etc).
|
|
324
|
+
*/
|
|
273
325
|
alignment?: string;
|
|
326
|
+
/**
|
|
327
|
+
* Options specific to the type field of the widget. See Perseus*WidgetOptions for
|
|
328
|
+
* more details
|
|
329
|
+
*/
|
|
274
330
|
options: Options;
|
|
331
|
+
/**
|
|
332
|
+
* Only used by interactive child widgets (line, point, etc) to identify the
|
|
333
|
+
* components
|
|
334
|
+
*/
|
|
275
335
|
key?: number | null;
|
|
336
|
+
/**
|
|
337
|
+
* The version of the widget data spec. Used to differentiate between newer
|
|
338
|
+
* and older content data. The parsers (`parseAndMigratePerseusItem`,
|
|
339
|
+
* `parseAndMigratePerseusArticle`, or `parseAndMigratePerseusRenderer`)
|
|
340
|
+
* will upgrade non-current versions of widget options to the latest.
|
|
341
|
+
*/
|
|
276
342
|
version?: Version;
|
|
277
343
|
};
|
|
278
344
|
export type CategorizerWidget = WidgetOptions<'categorizer', PerseusCategorizerWidgetOptions>;
|
|
@@ -311,153 +377,346 @@ export type DeprecatedStandinWidget = WidgetOptions<'deprecated-standin', object
|
|
|
311
377
|
* A background image applied to various widgets.
|
|
312
378
|
*/
|
|
313
379
|
export type PerseusImageBackground = {
|
|
380
|
+
/** The URL of the image */
|
|
314
381
|
url?: string | null;
|
|
382
|
+
/** The width of the image */
|
|
315
383
|
width?: number;
|
|
384
|
+
/** The height of the image */
|
|
316
385
|
height?: number;
|
|
386
|
+
/** The top offset of the image */
|
|
317
387
|
top?: number;
|
|
388
|
+
/** The left offset of the image */
|
|
318
389
|
left?: number;
|
|
390
|
+
/** The scale of the image */
|
|
319
391
|
scale?: number;
|
|
392
|
+
/** The bottom offset of the image */
|
|
320
393
|
bottom?: number;
|
|
321
394
|
};
|
|
322
395
|
/**
|
|
323
396
|
* The type of markings to display on the graph.
|
|
324
|
-
* - axes: shows the axes without the
|
|
397
|
+
* - axes: shows the axes without the grid lines
|
|
325
398
|
* - graph: shows the axes and the grid lines
|
|
326
399
|
* - grid: shows only the grid lines
|
|
327
400
|
* - none: shows no markings
|
|
328
401
|
*/
|
|
329
402
|
export type MarkingsType = "axes" | "graph" | "grid" | "none";
|
|
330
403
|
export type AxisLabelLocation = "onAxis" | "alongEdge";
|
|
404
|
+
/** Options for the categorizer widget. Presents items to sort into groups. */
|
|
331
405
|
export type PerseusCategorizerWidgetOptions = {
|
|
406
|
+
/**
|
|
407
|
+
* Translatable text; a list of items to categorize. e.g. ["banana",
|
|
408
|
+
* "yellow", "apple", "purple", "shirt"]
|
|
409
|
+
*/
|
|
332
410
|
items: string[];
|
|
411
|
+
/** Translatable text; a list of categories. e.g. ["fruits", "colors", "clothing"] */
|
|
333
412
|
categories: string[];
|
|
413
|
+
/** Whether the items should be randomized */
|
|
334
414
|
randomizeItems: boolean;
|
|
415
|
+
/** Whether this widget is displayed with the results and immutable */
|
|
335
416
|
static: boolean;
|
|
417
|
+
/**
|
|
418
|
+
* The correct answers where index relates to the items and value relates to
|
|
419
|
+
* the category. e.g. [0, 1, 0, 1, 2]
|
|
420
|
+
*/
|
|
336
421
|
values: number[];
|
|
422
|
+
/** Whether we should highlight i18n linter errors found on this widget */
|
|
337
423
|
highlightLint?: boolean;
|
|
338
424
|
};
|
|
425
|
+
/** Options for the definition widget. Reveals a definition on click. */
|
|
339
426
|
export type PerseusDefinitionWidgetOptions = {
|
|
427
|
+
/** Translatable text; the word to define. e.g. "vertex" */
|
|
340
428
|
togglePrompt: string;
|
|
429
|
+
/** Translatable text; the definition of the word. e.g. "where 2 rays connect" */
|
|
341
430
|
definition: string;
|
|
431
|
+
/** Always false. Not used for this widget */
|
|
342
432
|
static: boolean;
|
|
343
433
|
};
|
|
434
|
+
/** Options for the dropdown widget. A list of choices in a dropdown. */
|
|
344
435
|
export type PerseusDropdownWidgetOptions = {
|
|
436
|
+
/** A list of choices for the dropdown */
|
|
345
437
|
choices: PerseusDropdownChoice[];
|
|
438
|
+
/** Translatable Text; placeholder text for a dropdown. e.g. "Please select a fruit" */
|
|
346
439
|
placeholder: string;
|
|
440
|
+
/** Always false. Not used for this widget */
|
|
347
441
|
static: boolean;
|
|
442
|
+
/** Translatable Text; visible label for the dropdown */
|
|
348
443
|
visibleLabel?: string;
|
|
444
|
+
/** Translatable Text; aria label that screen readers will read */
|
|
349
445
|
ariaLabel?: string;
|
|
350
446
|
};
|
|
351
447
|
export type PerseusDropdownChoice = {
|
|
448
|
+
/** Translatable text; The text for the option. e.g. "Banana" or "Orange" */
|
|
352
449
|
content: string;
|
|
450
|
+
/** Whether this is the correct option or not */
|
|
353
451
|
correct: boolean;
|
|
354
452
|
};
|
|
453
|
+
/** Options for the explanation widget. Reveals an explanation on click. */
|
|
355
454
|
export type PerseusExplanationWidgetOptions = {
|
|
455
|
+
/**
|
|
456
|
+
* Translatable Text; The clickable text to expand an explanation.
|
|
457
|
+
* e.g. "What is an apple?"
|
|
458
|
+
*/
|
|
356
459
|
showPrompt: string;
|
|
460
|
+
/**
|
|
461
|
+
* Translatable Text; The clickable text to hide an explanation.
|
|
462
|
+
* e.g. "Thanks. I got it!"
|
|
463
|
+
*/
|
|
357
464
|
hidePrompt: string;
|
|
465
|
+
/**
|
|
466
|
+
* Translatable Markdown; The explanation that is shown when showPrompt is
|
|
467
|
+
* clicked. e.g. "An apple is a tasty fruit."
|
|
468
|
+
*/
|
|
358
469
|
explanation: string;
|
|
470
|
+
/**
|
|
471
|
+
* explanation fields can embed widgets. When they do, the details of the
|
|
472
|
+
* widgets are here.
|
|
473
|
+
*/
|
|
359
474
|
widgets: PerseusWidgetsMap;
|
|
475
|
+
/** Always false. Not used for this widget */
|
|
360
476
|
static: boolean;
|
|
361
477
|
};
|
|
362
478
|
export type LegacyButtonSets = Array<"basic" | "basic+div" | "trig" | "prealgebra" | "logarithms" | "basic relations" | "advanced relations" | "scientific">;
|
|
479
|
+
/** Options for the expression widget. Accepts a math expression answer. */
|
|
363
480
|
export type PerseusExpressionWidgetOptions = {
|
|
481
|
+
/** The expression forms the answer may come in */
|
|
364
482
|
answerForms: PerseusExpressionAnswerForm[];
|
|
365
483
|
buttonSets: LegacyButtonSets;
|
|
484
|
+
/** Variables that can be used as functions. Default: ["f", "g", "h"] */
|
|
366
485
|
functions: string[];
|
|
486
|
+
/** Use x for rendering multiplication instead of a center dot. */
|
|
367
487
|
times: boolean;
|
|
488
|
+
/**
|
|
489
|
+
* What extra keys need to be displayed on the keypad so that the question
|
|
490
|
+
* can be answerable without a keyboard (ie mobile)
|
|
491
|
+
*/
|
|
368
492
|
extraKeys?: KeypadKey[];
|
|
493
|
+
/** Visible label associated with the MathQuill field */
|
|
369
494
|
visibleLabel?: string;
|
|
495
|
+
/** Aria label for screen readers attached to MathQuill field */
|
|
370
496
|
ariaLabel?: string;
|
|
497
|
+
/**
|
|
498
|
+
* Controls when buttons for special characters are visible when using a
|
|
499
|
+
* desktop browser. Defaults to "focused".
|
|
500
|
+
* NOTE: This isn't listed in perseus-format.js or perseus_data.go, but
|
|
501
|
+
* appears in item data in the datastore.
|
|
502
|
+
*/
|
|
371
503
|
buttonsVisible?: "always" | "never" | "focused";
|
|
372
504
|
};
|
|
373
505
|
export declare const PerseusExpressionAnswerFormConsidered: readonly ["correct", "wrong", "ungraded"];
|
|
374
506
|
export type PerseusExpressionAnswerForm = {
|
|
507
|
+
/** The TeX form of the expression. e.g. "x\\cdot3=y" */
|
|
375
508
|
value: string;
|
|
509
|
+
/** The Answer expression must have the same form */
|
|
376
510
|
form: boolean;
|
|
511
|
+
/** The answer expression must be fully expanded and simplified */
|
|
377
512
|
simplify: boolean;
|
|
513
|
+
/** Whether the form is considered "correct", "wrong", or "ungraded" */
|
|
378
514
|
considered: (typeof PerseusExpressionAnswerFormConsidered)[number];
|
|
515
|
+
/**
|
|
516
|
+
* A key to identify the answer form in a list. Used only by the Perseus
|
|
517
|
+
* editor!
|
|
518
|
+
*/
|
|
379
519
|
key?: string;
|
|
380
520
|
};
|
|
521
|
+
/** Options for the graded-group widget. A self-contained scoreable group. */
|
|
381
522
|
export type PerseusGradedGroupWidgetOptions = {
|
|
523
|
+
/** Translatable Text; A title to be displayed for the group. */
|
|
382
524
|
title: string;
|
|
525
|
+
/** Not used in Perseus (but is set in (en, pt) production data) */
|
|
383
526
|
hasHint?: boolean | null | undefined;
|
|
527
|
+
/** A section to define hints for the group. */
|
|
384
528
|
hint?: PerseusRenderer | null | undefined;
|
|
529
|
+
/** Translatable Markdown. May include widgets and images embedded. */
|
|
385
530
|
content: string;
|
|
531
|
+
/** See {@link PerseusRenderer.widgets} */
|
|
386
532
|
widgets: PerseusWidgetsMap;
|
|
533
|
+
/** Not used in Perseus */
|
|
387
534
|
widgetEnabled?: boolean | null | undefined;
|
|
535
|
+
/** Not used in Perseus */
|
|
388
536
|
immutableWidgets?: boolean | null | undefined;
|
|
537
|
+
/** See {@link PerseusRenderer.images} */
|
|
389
538
|
images: {
|
|
390
539
|
[key: string]: PerseusImageDetail;
|
|
391
540
|
};
|
|
392
541
|
};
|
|
542
|
+
/** Options for the graded-group-set widget. A set of graded groups. */
|
|
393
543
|
export type PerseusGradedGroupSetWidgetOptions = {
|
|
544
|
+
/** A list of Widget Groups */
|
|
394
545
|
gradedGroups: PerseusGradedGroupWidgetOptions[];
|
|
395
546
|
};
|
|
547
|
+
/** A 2D coordinate range: x-axis [min, max] and y-axis [min, max]. */
|
|
396
548
|
export type GraphRange = [
|
|
397
549
|
x: [min: number, max: number],
|
|
398
550
|
y: [min: number, max: number]
|
|
399
551
|
];
|
|
552
|
+
/**
|
|
553
|
+
* The state of the grapher widget's plotted function, discriminated by
|
|
554
|
+
* the `type` field. Used as both the learner's
|
|
555
|
+
* user input and the rubric's correct answer.
|
|
556
|
+
*/
|
|
400
557
|
export type GrapherAnswerTypes = {
|
|
558
|
+
/**
|
|
559
|
+
* A V-shaped graph defined by its vertex.
|
|
560
|
+
*/
|
|
401
561
|
type: "absolute_value";
|
|
562
|
+
/**
|
|
563
|
+
* The vertex and a second point defining the V-shape. If null,
|
|
564
|
+
* the graph is not gradable and all answers score as invalid.
|
|
565
|
+
*/
|
|
402
566
|
coords: null | [vertex: Coord, secondPoint: Coord];
|
|
403
567
|
} | {
|
|
568
|
+
/**
|
|
569
|
+
* A curve of the form y = a·bˣ + c approaching a horizontal.
|
|
570
|
+
*/
|
|
404
571
|
type: "exponential";
|
|
572
|
+
/**
|
|
573
|
+
* Two points along the horizontal asymptote line. Only the
|
|
574
|
+
* y-coordinate of the first point is used during scoring;
|
|
575
|
+
* x-coordinates are completely ignored.
|
|
576
|
+
*/
|
|
405
577
|
asymptote: [Coord, Coord];
|
|
578
|
+
/**
|
|
579
|
+
* Two points along the exponential curve. One end of the curve
|
|
580
|
+
* trends towards the asymptote. If null, the graph is not
|
|
581
|
+
* gradable and all answers score as invalid.
|
|
582
|
+
*/
|
|
406
583
|
coords: null | [Coord, Coord];
|
|
407
584
|
} | {
|
|
585
|
+
/**
|
|
586
|
+
* A straight line of the form y = mx + b.
|
|
587
|
+
*/
|
|
408
588
|
type: "linear";
|
|
589
|
+
/**
|
|
590
|
+
* Two points along the straight line. If null, the graph is not
|
|
591
|
+
* gradable and all answers score as invalid.
|
|
592
|
+
*/
|
|
409
593
|
coords: null | [Coord, Coord];
|
|
410
594
|
} | {
|
|
595
|
+
/**
|
|
596
|
+
* A curve of the form y = a·log_b(x - c) approaching a vertical
|
|
597
|
+
* asymptote.
|
|
598
|
+
*/
|
|
411
599
|
type: "logarithm";
|
|
600
|
+
/** Two points along the asymptote line. */
|
|
412
601
|
asymptote: [Coord, Coord];
|
|
602
|
+
/**
|
|
603
|
+
* Two points along the logarithmic curve. One end of the curve
|
|
604
|
+
* trends towards the asymptote. If null, the graph is not
|
|
605
|
+
* gradable and all answers score as invalid.
|
|
606
|
+
*/
|
|
413
607
|
coords: null | [Coord, Coord];
|
|
414
608
|
} | {
|
|
609
|
+
/**
|
|
610
|
+
* A parabola of the form y = ax² + bx + c.
|
|
611
|
+
*/
|
|
415
612
|
type: "quadratic";
|
|
613
|
+
/**
|
|
614
|
+
* The vertex and a second point defining the parabola. If null,
|
|
615
|
+
* the graph is not gradable and all answers score as invalid.
|
|
616
|
+
*/
|
|
416
617
|
coords: null | [vertex: Coord, secondPoint: Coord];
|
|
417
618
|
} | {
|
|
619
|
+
/**
|
|
620
|
+
* A periodic wave of the form y = a·sin(bx - c) + d.
|
|
621
|
+
*/
|
|
418
622
|
type: "sinusoid";
|
|
623
|
+
/**
|
|
624
|
+
* Two points on the same slope of the sinusoid. If null, the
|
|
625
|
+
* graph is not gradable and all answers score as invalid.
|
|
626
|
+
*/
|
|
419
627
|
coords: null | [Coord, Coord];
|
|
420
628
|
} | {
|
|
629
|
+
/**
|
|
630
|
+
* A periodic curve of the form y = a·tan(bx - c) + d.
|
|
631
|
+
*/
|
|
421
632
|
type: "tangent";
|
|
633
|
+
/**
|
|
634
|
+
* Two points on the same slope of the tangent curve. If null,
|
|
635
|
+
* the graph is not gradable and all answers score as invalid.
|
|
636
|
+
*/
|
|
422
637
|
coords: null | [Coord, Coord];
|
|
423
638
|
};
|
|
639
|
+
/**
|
|
640
|
+
* Options for the Grapher widget. Defines the available function
|
|
641
|
+
* types, the correct answer, and the visual graph configuration.
|
|
642
|
+
*/
|
|
424
643
|
export type PerseusGrapherWidgetOptions = {
|
|
644
|
+
/** The set of function types the learner can choose from when plotting. */
|
|
425
645
|
availableTypes: Array<"absolute_value" | "exponential" | "linear" | "logarithm" | "quadratic" | "sinusoid" | "tangent">;
|
|
646
|
+
/** The correct answer; used to score the learner's plotted function. */
|
|
426
647
|
correct: GrapherAnswerTypes;
|
|
648
|
+
/** Visual configuration for the coordinate plane. */
|
|
427
649
|
graph: {
|
|
650
|
+
/** An optional background image displayed behind the graph. */
|
|
428
651
|
backgroundImage: {
|
|
652
|
+
/** Vertical offset from the bottom of the graph in pixels. */
|
|
429
653
|
bottom?: number;
|
|
654
|
+
/** Height of the image in pixels. */
|
|
430
655
|
height?: number;
|
|
656
|
+
/** Horizontal offset from the left edge of the graph in pixels. */
|
|
431
657
|
left?: number;
|
|
658
|
+
/** Scale factor applied to the image. */
|
|
432
659
|
scale?: number;
|
|
660
|
+
/** URL of the background image, or null/undefined if none. */
|
|
433
661
|
url?: string | null | undefined;
|
|
662
|
+
/** Width of the image in pixels. */
|
|
434
663
|
width?: number;
|
|
435
664
|
};
|
|
665
|
+
/** The [width, height] of the graph canvas in pixels. */
|
|
436
666
|
box?: [number, number];
|
|
667
|
+
/** Which graph settings are editable in the editor UI. */
|
|
437
668
|
editableSettings?: Array<"graph" | "snap" | "image" | "measure">;
|
|
669
|
+
/** The [x, y] spacing between grid lines. */
|
|
438
670
|
gridStep?: [number, number];
|
|
671
|
+
/** The [x-axis, y-axis] labels. */
|
|
439
672
|
labels: [string, string];
|
|
673
|
+
/** Which markings to show on the graph (axes, grid, graph, or none). */
|
|
440
674
|
markings: MarkingsType;
|
|
675
|
+
/** The visible [x-range, y-range] of the coordinate plane. */
|
|
441
676
|
range: GraphRange;
|
|
677
|
+
/** The label for the ruler overlay (currently always empty string). */
|
|
442
678
|
rulerLabel: "";
|
|
679
|
+
/** The number of tick marks on the ruler overlay. */
|
|
443
680
|
rulerTicks: number;
|
|
681
|
+
/** When true, a protractor overlay is shown on the graph. */
|
|
444
682
|
showProtractor?: boolean;
|
|
683
|
+
/** When true, a ruler overlay is shown on the graph. */
|
|
445
684
|
showRuler?: boolean;
|
|
685
|
+
/** When true, coordinate tooltips are shown on hover. */
|
|
446
686
|
showTooltips?: boolean;
|
|
687
|
+
/** The [x, y] snap increment for interactive elements. */
|
|
447
688
|
snapStep?: [number, number];
|
|
689
|
+
/** The [x, y] distance between labeled tick marks. */
|
|
448
690
|
step: [number, number];
|
|
691
|
+
/**
|
|
692
|
+
* Whether the graph configuration is valid. Can be false or an
|
|
693
|
+
* error message string.
|
|
694
|
+
*/
|
|
449
695
|
valid?: boolean | string;
|
|
450
696
|
};
|
|
451
697
|
};
|
|
698
|
+
/** Options for the group widget. An alias for PerseusRenderer. */
|
|
452
699
|
export type PerseusGroupWidgetOptions = PerseusRenderer;
|
|
700
|
+
/** Options for the image widget. Shows an image with a caption and alt text. */
|
|
453
701
|
export type PerseusImageWidgetOptions = {
|
|
702
|
+
/** Translatable Markdown; Text to be shown for the title of the image */
|
|
454
703
|
title?: string;
|
|
704
|
+
/** Translatable Markdown; Text to be shown in the caption section of an image */
|
|
455
705
|
caption?: string;
|
|
706
|
+
/** Translatable Text; The alt text to be shown in the img.alt attribute */
|
|
456
707
|
alt?: string;
|
|
708
|
+
/** Translatable Markdown; Text to be shown as the long description of an image */
|
|
457
709
|
longDescription?: string;
|
|
710
|
+
/**
|
|
711
|
+
* When true, standalone image will be rendered with alt="" and without any alt
|
|
712
|
+
* text, caption, title, or long description.
|
|
713
|
+
*/
|
|
458
714
|
decorative?: boolean;
|
|
715
|
+
/** The image details for the image to be displayed */
|
|
459
716
|
backgroundImage: PerseusImageBackground;
|
|
717
|
+
/** The size scale of the image */
|
|
460
718
|
scale?: number;
|
|
719
|
+
/** Always false. Not used for this widget */
|
|
461
720
|
static?: boolean;
|
|
462
721
|
/** @deprecated - labels were removed from the image widget in 2017 */
|
|
463
722
|
labels?: Array<PerseusImageLabel>;
|
|
@@ -467,28 +726,47 @@ export type PerseusImageWidgetOptions = {
|
|
|
467
726
|
box?: Size;
|
|
468
727
|
};
|
|
469
728
|
export type PerseusImageLabel = {
|
|
729
|
+
/** Translatable Text; The content of the label to display */
|
|
470
730
|
content: string;
|
|
731
|
+
/** The visual alignment of the label. default: "center" */
|
|
471
732
|
alignment: string;
|
|
733
|
+
/** The point on the image to display the label */
|
|
472
734
|
coordinates: number[];
|
|
473
735
|
};
|
|
736
|
+
/** Options for the interactive-graph widget. An interactive geometry graph. */
|
|
474
737
|
export type PerseusInteractiveGraphWidgetOptions = {
|
|
738
|
+
/**
|
|
739
|
+
* Where the little black axis lines & labels (ticks) should render. Also
|
|
740
|
+
* known as the tick step. default [1, 1]
|
|
741
|
+
*/
|
|
475
742
|
step: [number, number];
|
|
743
|
+
/** Where the grid lines on the graph will render. default [1, 1] */
|
|
476
744
|
gridStep?: [x: number, y: number];
|
|
745
|
+
/**
|
|
746
|
+
* Where the graph points will lock to when they are moved.
|
|
747
|
+
* default [0.5, 0.5]
|
|
748
|
+
*/
|
|
477
749
|
snapStep?: [x: number, y: number];
|
|
750
|
+
/** An optional image to use in the background */
|
|
478
751
|
backgroundImage?: PerseusImageBackground;
|
|
479
752
|
/**
|
|
480
753
|
* The type of markings to display on the graph.
|
|
481
754
|
*/
|
|
482
755
|
markings: MarkingsType;
|
|
756
|
+
/** How to label the X and Y axis. default: ["x", "y"] */
|
|
483
757
|
labels?: string[];
|
|
484
758
|
/**
|
|
485
759
|
* Specifies the location of the labels on the graph. default: "onAxis".
|
|
486
|
-
* - "onAxis": Labels are positioned on the axis at the right (x) and top
|
|
487
|
-
*
|
|
488
|
-
*
|
|
760
|
+
* - "onAxis": Labels are positioned on the axis at the right (x) and top
|
|
761
|
+
* (y) of the graph.
|
|
762
|
+
* - "alongEdge": Labels are centered along the bottom (x) and left (y)
|
|
763
|
+
* edges of the graph. The y label is rotated. Typically used when the
|
|
764
|
+
* range min is near 0 with longer labels.
|
|
489
765
|
*/
|
|
490
766
|
labelLocation?: AxisLabelLocation;
|
|
767
|
+
/** Which sides of the graph are bounded (removed axis arrows). */
|
|
491
768
|
showAxisArrows: ShowAxisArrows;
|
|
769
|
+
/** Whether to show the Protractor tool overlayed on top of the graph */
|
|
492
770
|
showProtractor: boolean;
|
|
493
771
|
/**
|
|
494
772
|
* Whether to show the Ruler tool overlayed on top of the graph.
|
|
@@ -497,6 +775,7 @@ export type PerseusInteractiveGraphWidgetOptions = {
|
|
|
497
775
|
* features, since it may appear in production data.
|
|
498
776
|
*/
|
|
499
777
|
showRuler?: boolean;
|
|
778
|
+
/** Whether to show tooltips on the graph */
|
|
500
779
|
showTooltips?: boolean;
|
|
501
780
|
/**
|
|
502
781
|
* The unit to show on the ruler. e.g. "mm", "cm", "m", "km", "in", "ft",
|
|
@@ -514,11 +793,23 @@ export type PerseusInteractiveGraphWidgetOptions = {
|
|
|
514
793
|
* features, since it may appear in production data.
|
|
515
794
|
*/
|
|
516
795
|
rulerTicks?: number;
|
|
796
|
+
/**
|
|
797
|
+
* The X and Y coordinate ranges for the view of the graph.
|
|
798
|
+
* default: [[-10, 10], [-10, 10]]
|
|
799
|
+
*/
|
|
517
800
|
range: GraphRange;
|
|
801
|
+
/** The type of graph */
|
|
518
802
|
graph: PerseusGraphType;
|
|
803
|
+
/** The correct kind of graph, if being used to select function type */
|
|
519
804
|
correct: PerseusGraphType;
|
|
805
|
+
/**
|
|
806
|
+
* Shapes (points, chords, etc) displayed on the graph that cannot be moved
|
|
807
|
+
* by the user.
|
|
808
|
+
*/
|
|
520
809
|
lockedFigures: LockedFigure[];
|
|
810
|
+
/** Aria label that applies to the entire graph. */
|
|
521
811
|
fullGraphAriaLabel?: string;
|
|
812
|
+
/** Aria description that applies to the entire graph. */
|
|
522
813
|
fullGraphAriaDescription?: string;
|
|
523
814
|
};
|
|
524
815
|
export declare const lockedFigureColorNames: readonly ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
|
|
@@ -606,25 +897,40 @@ export type LockedFunctionType = {
|
|
|
606
897
|
export type LockedLabelType = {
|
|
607
898
|
type: "label";
|
|
608
899
|
coord: Coord;
|
|
900
|
+
/** TeX-supported string */
|
|
609
901
|
text: string;
|
|
610
902
|
color: LockedFigureColor;
|
|
611
903
|
size: "small" | "medium" | "large";
|
|
612
904
|
};
|
|
613
|
-
export type PerseusGraphType = PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypeNone | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid;
|
|
905
|
+
export type PerseusGraphType = PerseusGraphTypeAbsoluteValue | PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypeNone | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid | PerseusGraphTypeExponential | PerseusGraphTypeTangent;
|
|
614
906
|
export type PerseusGraphTypeAngle = {
|
|
615
907
|
type: "angle";
|
|
908
|
+
/** Whether to show the angle measurements. default: false */
|
|
616
909
|
showAngles?: boolean;
|
|
910
|
+
/** Allow Reflex Angles if an "angle" type. default: true */
|
|
617
911
|
allowReflexAngles?: boolean;
|
|
912
|
+
/** The angle offset in degrees if an "angle" type. default: 0 */
|
|
618
913
|
angleOffsetDeg?: number;
|
|
914
|
+
/** Snap to degree increments if an "angle" type. default: 1 */
|
|
619
915
|
snapDegrees?: number;
|
|
916
|
+
/** How to match the answer. If missing, defaults to exact matching. */
|
|
620
917
|
match?: "congruent";
|
|
918
|
+
/**
|
|
919
|
+
* The angle represented as ∠ABC; point B is the vertex, while rays
|
|
920
|
+
* BA and BC are the sides of the angle.
|
|
921
|
+
*/
|
|
621
922
|
coords?: [Coord, Coord, Coord];
|
|
923
|
+
/**
|
|
924
|
+
* The initial state for this graph, represented as ∠ABC, where point B is
|
|
925
|
+
* the vertex, while rays BA and BC form the angle.
|
|
926
|
+
*/
|
|
622
927
|
startCoords?: [Coord, Coord, Coord];
|
|
623
928
|
};
|
|
624
929
|
export type PerseusGraphTypeCircle = {
|
|
625
930
|
type: "circle";
|
|
626
931
|
center?: Coord;
|
|
627
932
|
radius?: number;
|
|
933
|
+
/** The initial coordinates the graph renders with. */
|
|
628
934
|
startCoords?: {
|
|
629
935
|
center: Coord;
|
|
630
936
|
radius: number;
|
|
@@ -632,12 +938,16 @@ export type PerseusGraphTypeCircle = {
|
|
|
632
938
|
};
|
|
633
939
|
export type PerseusGraphTypeLinear = {
|
|
634
940
|
type: "linear";
|
|
941
|
+
/** expects 2 coords */
|
|
635
942
|
coords?: CollinearTuple | null;
|
|
943
|
+
/** The initial coordinates the graph renders with. */
|
|
636
944
|
startCoords?: CollinearTuple;
|
|
637
945
|
};
|
|
638
946
|
export type PerseusGraphTypeLinearSystem = {
|
|
639
947
|
type: "linear-system";
|
|
948
|
+
/** expects 2 sets of 2 coords */
|
|
640
949
|
coords?: CollinearTuple[] | null;
|
|
950
|
+
/** The initial coordinates the graph renders with. */
|
|
641
951
|
startCoords?: CollinearTuple[];
|
|
642
952
|
};
|
|
643
953
|
export type PerseusGraphTypeNone = {
|
|
@@ -645,42 +955,95 @@ export type PerseusGraphTypeNone = {
|
|
|
645
955
|
};
|
|
646
956
|
export type PerseusGraphTypePoint = {
|
|
647
957
|
type: "point";
|
|
958
|
+
/**
|
|
959
|
+
* The number of points if a "point" type. default: 1. "unlimited" if no
|
|
960
|
+
* limit
|
|
961
|
+
*/
|
|
648
962
|
numPoints?: number | "unlimited";
|
|
649
963
|
coords?: Coord[] | null;
|
|
964
|
+
/** The initial coordinates the graph renders with. */
|
|
650
965
|
startCoords?: Coord[];
|
|
966
|
+
/** Used instead of `coords` in some old graphs that have only one point. */
|
|
651
967
|
coord?: Coord;
|
|
652
968
|
};
|
|
653
969
|
export type PerseusGraphTypePolygon = {
|
|
654
970
|
type: "polygon";
|
|
971
|
+
/** The number of sides. default: 3. "unlimited" if no limit */
|
|
655
972
|
numSides?: number | "unlimited";
|
|
973
|
+
/** Whether to show the angle measurements. default: false */
|
|
656
974
|
showAngles?: boolean;
|
|
975
|
+
/** Whether to show side measurements. default: false */
|
|
657
976
|
showSides?: boolean;
|
|
977
|
+
/** How to snap points. e.g. "grid", "angles", or "sides". default: grid */
|
|
658
978
|
snapTo?: "grid" | "angles" | "sides";
|
|
979
|
+
/** How to match the answer. If missing, defaults to exact matching. */
|
|
659
980
|
match?: "similar" | "congruent" | "approx" | "exact";
|
|
660
981
|
coords?: Coord[] | null;
|
|
982
|
+
/** The initial coordinates the graph renders with. */
|
|
661
983
|
startCoords?: Coord[];
|
|
662
984
|
};
|
|
663
985
|
export type PerseusGraphTypeQuadratic = {
|
|
664
986
|
type: "quadratic";
|
|
987
|
+
/** expects a list of 3 coords */
|
|
665
988
|
coords?: [Coord, Coord, Coord] | null;
|
|
989
|
+
/** The initial coordinates the graph renders with. */
|
|
666
990
|
startCoords?: [Coord, Coord, Coord];
|
|
667
991
|
};
|
|
668
992
|
export type PerseusGraphTypeSegment = {
|
|
669
993
|
type: "segment";
|
|
994
|
+
/** The number of segments if a "segment" type. default: 1. Max: 6 */
|
|
670
995
|
numSegments?: number;
|
|
996
|
+
/**
|
|
997
|
+
* Expects a list of Coord tuples. Length should match the `numSegments`
|
|
998
|
+
* value.
|
|
999
|
+
*/
|
|
671
1000
|
coords?: CollinearTuple[] | null;
|
|
1001
|
+
/** The initial coordinates the graph renders with. */
|
|
672
1002
|
startCoords?: CollinearTuple[];
|
|
673
1003
|
};
|
|
674
1004
|
export type PerseusGraphTypeSinusoid = {
|
|
675
1005
|
type: "sinusoid";
|
|
1006
|
+
/** Expects a list of 2 Coords */
|
|
676
1007
|
coords?: Coord[] | null;
|
|
1008
|
+
/** The initial coordinates the graph renders with. */
|
|
677
1009
|
startCoords?: Coord[];
|
|
678
1010
|
};
|
|
1011
|
+
export type PerseusGraphTypeTangent = {
|
|
1012
|
+
type: "tangent";
|
|
1013
|
+
coords?: Coord[] | null;
|
|
1014
|
+
startCoords?: Coord[];
|
|
1015
|
+
};
|
|
1016
|
+
export type PerseusGraphTypeExponential = {
|
|
1017
|
+
type: "exponential";
|
|
1018
|
+
/** Two points along the exponential curve. */
|
|
1019
|
+
coords?: Coord[] | null;
|
|
1020
|
+
/**
|
|
1021
|
+
* The y-value of the horizontal asymptote (the line y = asymptote).
|
|
1022
|
+
* Corresponds to the coefficient c in f(x) = a·eᵇˣ + c.
|
|
1023
|
+
*/
|
|
1024
|
+
asymptote?: number | null;
|
|
1025
|
+
/** The initial coordinates the graph renders with. */
|
|
1026
|
+
startCoords?: {
|
|
1027
|
+
coords: [Coord, Coord];
|
|
1028
|
+
asymptote: number;
|
|
1029
|
+
};
|
|
1030
|
+
};
|
|
1031
|
+
export type PerseusGraphTypeAbsoluteValue = {
|
|
1032
|
+
type: "absolute-value";
|
|
1033
|
+
coords?: [Coord, Coord] | null;
|
|
1034
|
+
startCoords?: [Coord, Coord];
|
|
1035
|
+
};
|
|
679
1036
|
export type PerseusGraphTypeRay = {
|
|
680
1037
|
type: "ray";
|
|
1038
|
+
/** Expects a list of 2 Coords */
|
|
681
1039
|
coords?: CollinearTuple | null;
|
|
1040
|
+
/** The initial coordinates the graph renders with. */
|
|
682
1041
|
startCoords?: CollinearTuple;
|
|
683
1042
|
};
|
|
1043
|
+
type AbsoluteValueGraphCorrect = {
|
|
1044
|
+
type: "absolute-value";
|
|
1045
|
+
coords: [Coord, Coord];
|
|
1046
|
+
};
|
|
684
1047
|
type AngleGraphCorrect = {
|
|
685
1048
|
type: "angle";
|
|
686
1049
|
allowReflexAngles: boolean;
|
|
@@ -724,52 +1087,131 @@ type SinusoidGraphCorrect = {
|
|
|
724
1087
|
type: "sinusoid";
|
|
725
1088
|
coords: CollinearTuple;
|
|
726
1089
|
};
|
|
1090
|
+
type ExponentialGraphCorrect = {
|
|
1091
|
+
type: "exponential";
|
|
1092
|
+
coords: CollinearTuple;
|
|
1093
|
+
asymptote: number;
|
|
1094
|
+
};
|
|
1095
|
+
type TangentGraphCorrect = {
|
|
1096
|
+
type: "tangent";
|
|
1097
|
+
coords: CollinearTuple;
|
|
1098
|
+
};
|
|
727
1099
|
type RayGraphCorrect = {
|
|
728
1100
|
type: "ray";
|
|
729
1101
|
coords: CollinearTuple;
|
|
730
1102
|
};
|
|
731
|
-
export type PerseusGraphCorrectType = AngleGraphCorrect | CircleGraphCorrect | LinearGraphCorrect | LinearSystemGraphCorrect | NoneGraphCorrect | PointGraphCorrect | PolygonGraphCorrect | QuadraticGraphCorrect | RayGraphCorrect | SegmentGraphCorrect | SinusoidGraphCorrect;
|
|
1103
|
+
export type PerseusGraphCorrectType = AbsoluteValueGraphCorrect | AngleGraphCorrect | CircleGraphCorrect | LinearGraphCorrect | LinearSystemGraphCorrect | NoneGraphCorrect | PointGraphCorrect | PolygonGraphCorrect | QuadraticGraphCorrect | RayGraphCorrect | SegmentGraphCorrect | SinusoidGraphCorrect | ExponentialGraphCorrect | TangentGraphCorrect;
|
|
1104
|
+
/** Options for the label-image widget. Asks learners to label image parts. */
|
|
732
1105
|
export type PerseusLabelImageWidgetOptions = {
|
|
1106
|
+
/** Translatable Text; TeX representation of choices */
|
|
733
1107
|
choices: string[];
|
|
1108
|
+
/** The URL of the image */
|
|
734
1109
|
imageUrl: string;
|
|
1110
|
+
/** Translatable Text; To show up in the img.alt attribute */
|
|
735
1111
|
imageAlt: string;
|
|
1112
|
+
/** The height of the image */
|
|
736
1113
|
imageHeight: number;
|
|
1114
|
+
/** The width of the image */
|
|
737
1115
|
imageWidth: number;
|
|
1116
|
+
/** A list of markers to display on the image */
|
|
738
1117
|
markers: PerseusLabelImageMarker[];
|
|
1118
|
+
/** Do not display answer choices in instructions */
|
|
739
1119
|
hideChoicesFromInstructions: boolean;
|
|
1120
|
+
/** Allow multiple answers per marker */
|
|
740
1121
|
multipleAnswers: boolean;
|
|
1122
|
+
/** Always false. Not used for this widget */
|
|
741
1123
|
static: boolean;
|
|
742
1124
|
};
|
|
743
1125
|
export type PerseusLabelImageMarker = {
|
|
1126
|
+
/**
|
|
1127
|
+
* A list of correct answers for this marker. Often only one but can have
|
|
1128
|
+
* multiple
|
|
1129
|
+
*/
|
|
744
1130
|
answers: string[];
|
|
1131
|
+
/**
|
|
1132
|
+
* Translatable Text; The text to show for the marker. Not displayed
|
|
1133
|
+
* directly to the user
|
|
1134
|
+
*/
|
|
745
1135
|
label: string;
|
|
1136
|
+
/** X Coordinate location of the marker on the image */
|
|
746
1137
|
x: number;
|
|
1138
|
+
/** Y Coordinate location of the marker on the image */
|
|
747
1139
|
y: number;
|
|
748
1140
|
};
|
|
1141
|
+
/** Options for the matcher widget. Two-column drag-and-drop matching. */
|
|
749
1142
|
export type PerseusMatcherWidgetOptions = {
|
|
1143
|
+
/**
|
|
1144
|
+
* Translatable Text; Labels to adorn the headings for the columns. Only 2
|
|
1145
|
+
* values [left, right]. e.g. ["Concepts", "Things"]
|
|
1146
|
+
*/
|
|
750
1147
|
labels: string[];
|
|
1148
|
+
/**
|
|
1149
|
+
* Translatable Text; Static concepts to show in the left column.
|
|
1150
|
+
* e.g. ["Fruit", "Color", "Clothes"]
|
|
1151
|
+
*/
|
|
751
1152
|
left: string[];
|
|
1153
|
+
/**
|
|
1154
|
+
* Translatable Markup; Values that represent the concepts to be correlated
|
|
1155
|
+
* with the concepts. e.g. ["Red", "Shirt", "Banana"]
|
|
1156
|
+
*/
|
|
752
1157
|
right: string[];
|
|
1158
|
+
/**
|
|
1159
|
+
* Order of the matched pairs matters. With this option enabled, only the
|
|
1160
|
+
* order provided above will be treated as correct. This is useful when
|
|
1161
|
+
* ordering is significant, such as in the context of a proof. If disabled,
|
|
1162
|
+
* pairwise matching is sufficient. To make this clear, the left column
|
|
1163
|
+
* becomes fixed in the provided order and only the cards in the right
|
|
1164
|
+
* column can be moved.
|
|
1165
|
+
*/
|
|
753
1166
|
orderMatters: boolean;
|
|
1167
|
+
/** Adds padding to the rows. Padding is good for text, but not needed for images. */
|
|
754
1168
|
padding: boolean;
|
|
755
1169
|
};
|
|
756
1170
|
export type PerseusMatrixWidgetAnswers = number[][];
|
|
1171
|
+
/** Options for the matrix widget. A grid of numeric cells to fill in. */
|
|
757
1172
|
export type PerseusMatrixWidgetOptions = {
|
|
1173
|
+
/** Translatable Text; Shown before the matrix */
|
|
758
1174
|
prefix?: string | undefined;
|
|
1175
|
+
/** Translatable Text; Shown after the matrix */
|
|
759
1176
|
suffix?: string | undefined;
|
|
1177
|
+
/**
|
|
1178
|
+
* A data matrix representing the "correct" answers to be entered into the
|
|
1179
|
+
* matrix
|
|
1180
|
+
*/
|
|
760
1181
|
answers: PerseusMatrixWidgetAnswers;
|
|
1182
|
+
/**
|
|
1183
|
+
* The coordinate location of the cursor position at start.
|
|
1184
|
+
* default: [0, 0]
|
|
1185
|
+
*/
|
|
761
1186
|
cursorPosition?: number[] | undefined;
|
|
1187
|
+
/**
|
|
1188
|
+
* The coordinate size of the matrix. Only supports 2-dimensional matrix.
|
|
1189
|
+
* default: [3, 3]
|
|
1190
|
+
*/
|
|
762
1191
|
matrixBoardSize: number[];
|
|
1192
|
+
/**
|
|
1193
|
+
* Whether this is meant to statically display the answers (true) or be
|
|
1194
|
+
* used as an input field, graded against the answers
|
|
1195
|
+
*/
|
|
763
1196
|
static?: boolean | undefined;
|
|
764
1197
|
};
|
|
1198
|
+
/** Options for the measurer widget. A virtual ruler and/or protractor. */
|
|
765
1199
|
export type PerseusMeasurerWidgetOptions = {
|
|
1200
|
+
/** The image that the user is meant to measure */
|
|
766
1201
|
image: PerseusImageBackground;
|
|
1202
|
+
/** Whether to show the Protractor tool overlayed on top of the image */
|
|
767
1203
|
showProtractor: boolean;
|
|
1204
|
+
/** Whether to show the Ruler tool overlayed on top of the image */
|
|
768
1205
|
showRuler: boolean;
|
|
1206
|
+
/** The unit to show on the ruler. e.g. "mm", "cm", "m", "km", "in", "ft", "yd", "mi" */
|
|
769
1207
|
rulerLabel: string;
|
|
1208
|
+
/** How many ticks to show on the ruler. e.g. 1, 2, 4, 8, 10, 16 */
|
|
770
1209
|
rulerTicks: number;
|
|
1210
|
+
/** The number of image pixels per unit (label) */
|
|
771
1211
|
rulerPixels: number;
|
|
1212
|
+
/** The number of units to display on the ruler */
|
|
772
1213
|
rulerLength: number;
|
|
1214
|
+
/** Containing area [width, height] */
|
|
773
1215
|
box: [number, number];
|
|
774
1216
|
};
|
|
775
1217
|
export type MathFormat = "integer" | "mixed" | "improper" | "proper" | "decimal" | "percent" | "pi";
|
|
@@ -786,269 +1228,581 @@ export type PerseusNumericInputAnswerForm = {
|
|
|
786
1228
|
* - "optional" means unsimplified fractions are accepted.
|
|
787
1229
|
*/
|
|
788
1230
|
export type PerseusNumericInputSimplify = "required" | "enforced" | "optional";
|
|
1231
|
+
/** Options for the numeric-input widget. Accepts a single numeric answer. */
|
|
789
1232
|
export type PerseusNumericInputWidgetOptions = {
|
|
1233
|
+
/**
|
|
1234
|
+
* A list of correct and incorrect answers. Each answer can have a
|
|
1235
|
+
* message explaining why it is correct/incorrect. There may be
|
|
1236
|
+
* multiple correct answers if multiple formats are accepted. For
|
|
1237
|
+
* example, some questions might accept either a fraction or a
|
|
1238
|
+
* decimal as correct.
|
|
1239
|
+
*
|
|
1240
|
+
* The first answer that matches (correct or incorrect) is the scoring
|
|
1241
|
+
* result (so order of answers is very important).
|
|
1242
|
+
*/
|
|
790
1243
|
answers: PerseusNumericInputAnswer[];
|
|
1244
|
+
/**
|
|
1245
|
+
* Translatable Text; Text to describe this input. This will be shown to
|
|
1246
|
+
* users using screenreaders.
|
|
1247
|
+
*/
|
|
791
1248
|
labelText?: string | undefined;
|
|
1249
|
+
/**
|
|
1250
|
+
* Use size "Normal" for all text boxes, unless there are multiple text
|
|
1251
|
+
* boxes in one line and the answer area is too narrow to fit them.
|
|
1252
|
+
* Options: "normal" or "small"
|
|
1253
|
+
*/
|
|
792
1254
|
size: string;
|
|
1255
|
+
/**
|
|
1256
|
+
* A coefficient style number allows the student to use - for -1 and an
|
|
1257
|
+
* empty string to mean 1.
|
|
1258
|
+
*/
|
|
793
1259
|
coefficient: boolean;
|
|
1260
|
+
/** Whether to right-align the text or not */
|
|
794
1261
|
rightAlign?: boolean;
|
|
1262
|
+
/** Always false. Not used for this widget */
|
|
795
1263
|
static: boolean;
|
|
796
1264
|
};
|
|
797
1265
|
export type PerseusNumericInputAnswer = {
|
|
1266
|
+
/**
|
|
1267
|
+
* Translatable Display; A description for why this answer is correct,
|
|
1268
|
+
* wrong, or ungraded
|
|
1269
|
+
*/
|
|
798
1270
|
message: string;
|
|
1271
|
+
/** The expected answer */
|
|
799
1272
|
value?: number | null;
|
|
1273
|
+
/** Whether this answer is "correct", "wrong", or "ungraded" */
|
|
800
1274
|
status: string;
|
|
1275
|
+
/**
|
|
1276
|
+
* The forms available for this answer.
|
|
1277
|
+
*/
|
|
801
1278
|
answerForms?: MathFormat[];
|
|
1279
|
+
/**
|
|
1280
|
+
* Whether we should check the answer strictly against the configured
|
|
1281
|
+
* answerForms (strict = true) or include the set of default answerForms
|
|
1282
|
+
* (strict = false).
|
|
1283
|
+
*/
|
|
802
1284
|
strict: boolean;
|
|
1285
|
+
/** A range of error +/- the value */
|
|
803
1286
|
maxError?: number | null;
|
|
1287
|
+
/** Unsimplified answers are Ungraded, Accepted, or Wrong. */
|
|
804
1288
|
simplify: PerseusNumericInputSimplify;
|
|
805
1289
|
};
|
|
1290
|
+
/** Options for the number-line widget. A draggable point on a number line. */
|
|
806
1291
|
export type PerseusNumberLineWidgetOptions = {
|
|
1292
|
+
/**
|
|
1293
|
+
* The position of the endpoints of the number line. Setting the range
|
|
1294
|
+
* constrains the position of the answer and the labels.
|
|
1295
|
+
*/
|
|
807
1296
|
range: number[];
|
|
1297
|
+
/**
|
|
1298
|
+
* This controls the position of the left / right labels. By default, the
|
|
1299
|
+
* labels are set by the range. Note: Ensure that the labels line up with
|
|
1300
|
+
* the tick marks, or it may be confusing for users.
|
|
1301
|
+
*/
|
|
808
1302
|
labelRange: Array<number | null>;
|
|
1303
|
+
/**
|
|
1304
|
+
* This controls the styling of the labels for the two main labels as well
|
|
1305
|
+
* as all the tick mark labels, if applicable. Options: "decimal",
|
|
1306
|
+
* "improper", "mixed", "non-reduced"
|
|
1307
|
+
*/
|
|
809
1308
|
labelStyle: string;
|
|
1309
|
+
/** Show label ticks */
|
|
810
1310
|
labelTicks: boolean;
|
|
1311
|
+
/** Show tick controller */
|
|
811
1312
|
isTickCtrl: boolean;
|
|
812
1313
|
isInequality: boolean;
|
|
1314
|
+
/** The range of divisions within the line */
|
|
813
1315
|
divisionRange: number[];
|
|
1316
|
+
/**
|
|
1317
|
+
* This controls the number (and position) of the tick marks. The number of
|
|
1318
|
+
* divisions is constrained to the division range. Note: The user will be
|
|
1319
|
+
* able to specify the number of divisions in a number input.
|
|
1320
|
+
*/
|
|
814
1321
|
numDivisions?: number | null;
|
|
1322
|
+
/**
|
|
1323
|
+
* This determines the number of different places the point will snap
|
|
1324
|
+
* between two adjacent tick marks. Note: Ensure the required number of
|
|
1325
|
+
* snap increments is provided to answer the question.
|
|
1326
|
+
*/
|
|
815
1327
|
snapDivisions: number;
|
|
1328
|
+
/**
|
|
1329
|
+
* This controls the number (and position) of the tick marks; you can
|
|
1330
|
+
* either set the number of divisions (2 divisions would split the entire
|
|
1331
|
+
* range in two halves), or the tick step (the distance between ticks) and
|
|
1332
|
+
* the other value will be updated accordingly. Note: There is no check to
|
|
1333
|
+
* see if labels coordinate with the tick marks, which may be confusing for
|
|
1334
|
+
* users if the blue labels and black ticks are off-step.
|
|
1335
|
+
*/
|
|
816
1336
|
tickStep?: number | null;
|
|
1337
|
+
/**
|
|
1338
|
+
* The answer to a NumberLine widget is a set of real numbers. `correctRel`
|
|
1339
|
+
* expresses the relationship between the numbers in that set and the value
|
|
1340
|
+
* of `correctX`.
|
|
1341
|
+
*/
|
|
817
1342
|
correctRel?: "eq" | "lt" | "gt" | "le" | "ge";
|
|
1343
|
+
/**
|
|
1344
|
+
* This is the correct answer. The answer is validated (as right or wrong)
|
|
1345
|
+
* by using only the end position of the point and the relation
|
|
1346
|
+
* (=, <, >, ≤, ≥).
|
|
1347
|
+
*/
|
|
818
1348
|
correctX: number | null;
|
|
1349
|
+
/** This controls the initial position of the point along the number line */
|
|
819
1350
|
initialX?: number | null;
|
|
1351
|
+
/** Show tooltips */
|
|
820
1352
|
showTooltips?: boolean;
|
|
1353
|
+
/** When true, the answer is displayed and is immutable */
|
|
821
1354
|
static: boolean;
|
|
822
1355
|
};
|
|
1356
|
+
/** Options for the orderer widget. Cards to place in the correct order. */
|
|
823
1357
|
export type PerseusOrdererWidgetOptions = {
|
|
1358
|
+
/**
|
|
1359
|
+
* All of the options available to the user. Place the cards in the correct
|
|
1360
|
+
* order. The same card can be used more than once in the answer but will
|
|
1361
|
+
* only be displayed once at the top of a stack of identical cards.
|
|
1362
|
+
*/
|
|
824
1363
|
options: PerseusRenderer[];
|
|
1364
|
+
/** The correct order of the options */
|
|
825
1365
|
correctOptions: PerseusRenderer[];
|
|
1366
|
+
/** Cards that are not part of the answer */
|
|
826
1367
|
otherOptions: PerseusRenderer[];
|
|
1368
|
+
/** "normal" for text options. "auto" for image options. */
|
|
827
1369
|
height: "normal" | "auto";
|
|
1370
|
+
/**
|
|
1371
|
+
* Use the "horizontal" layout for short text and small images. The
|
|
1372
|
+
* "vertical" layout is best for longer text (e.g. proofs).
|
|
1373
|
+
*/
|
|
828
1374
|
layout: "horizontal" | "vertical";
|
|
829
1375
|
};
|
|
830
1376
|
export declare const plotterPlotTypes: readonly ["bar", "line", "pic", "histogram", "dotplot"];
|
|
831
1377
|
export type PlotType = (typeof plotterPlotTypes)[number];
|
|
1378
|
+
/** Options for the plotter widget. A bar, line, histogram, or dot plot. */
|
|
832
1379
|
export type PerseusPlotterWidgetOptions = {
|
|
1380
|
+
/** Translatable Text; The Axis labels. e.g. ["X Label", "Y Label"] */
|
|
833
1381
|
labels: string[];
|
|
1382
|
+
/**
|
|
1383
|
+
* Translatable Text; Categories to display along the X axis.
|
|
1384
|
+
* e.g. [">0", ">6", ">12", ">18"]
|
|
1385
|
+
*/
|
|
834
1386
|
categories: string[];
|
|
1387
|
+
/** The type of the graph. options "bar", "line", "pic", "histogram", "dotplot" */
|
|
835
1388
|
type: PlotType;
|
|
1389
|
+
/** The maximum Y tick to display in the graph */
|
|
836
1390
|
maxY: number;
|
|
1391
|
+
/** The scale of the Y Axis */
|
|
837
1392
|
scaleY: number;
|
|
1393
|
+
/**
|
|
1394
|
+
* Which ticks to display the labels for. For instance, setting this to "4"
|
|
1395
|
+
* will only show every 4th label (plus the last one)
|
|
1396
|
+
*/
|
|
838
1397
|
labelInterval?: number | null;
|
|
1398
|
+
/**
|
|
1399
|
+
* Creates the specified number of divisions between the horizontal lines.
|
|
1400
|
+
* Fewer snaps between lines makes the graph easier for the student to
|
|
1401
|
+
* create correctly.
|
|
1402
|
+
*/
|
|
839
1403
|
snapsPerLine: number;
|
|
1404
|
+
/** The Y values the graph should start with */
|
|
840
1405
|
starting: number[];
|
|
1406
|
+
/** The Y values that represent the correct answer expected */
|
|
841
1407
|
correct: number[];
|
|
1408
|
+
/** A picture to represent items in a graph. */
|
|
842
1409
|
picUrl?: string | null;
|
|
1410
|
+
/** @deprecated */
|
|
843
1411
|
picSize?: number | null;
|
|
1412
|
+
/** @deprecated */
|
|
844
1413
|
picBoxHeight?: number | null;
|
|
1414
|
+
/** @deprecated */
|
|
845
1415
|
plotDimensions: number[];
|
|
846
1416
|
};
|
|
1417
|
+
/** Options for the radio widget. Presents a multiple-choice question. */
|
|
847
1418
|
export type PerseusRadioWidgetOptions = {
|
|
1419
|
+
/** The choices provided to the user. */
|
|
848
1420
|
choices: PerseusRadioChoice[];
|
|
1421
|
+
/** Does this have a "none of the above" option? */
|
|
849
1422
|
hasNoneOfTheAbove?: boolean;
|
|
1423
|
+
/**
|
|
1424
|
+
* When true, the learner must select exactly as many choices as there
|
|
1425
|
+
* are correct answers before the answer is graded. Only has an effect
|
|
1426
|
+
* when there are multiple correct answers.
|
|
1427
|
+
*/
|
|
850
1428
|
countChoices?: boolean;
|
|
1429
|
+
/**
|
|
1430
|
+
* How many of the choices are correct, which is conditionally used to tell
|
|
1431
|
+
* learners ahead of time how many options they'll need.
|
|
1432
|
+
*/
|
|
851
1433
|
numCorrect?: number;
|
|
1434
|
+
/** Randomize the order of the options or keep them as defined */
|
|
852
1435
|
randomize?: boolean;
|
|
1436
|
+
/** Does this set allow for multiple selections to be correct? */
|
|
853
1437
|
multipleSelect?: boolean;
|
|
1438
|
+
/** @deprecated */
|
|
854
1439
|
deselectEnabled?: boolean;
|
|
855
1440
|
};
|
|
856
1441
|
export type PerseusRadioChoice = {
|
|
1442
|
+
/** Translatable Markdown; The label for this choice */
|
|
857
1443
|
content: string;
|
|
858
1444
|
/**
|
|
859
1445
|
* An opaque string that uniquely identifies this choice within
|
|
860
1446
|
* the radio widget. The format of this ID is subject to change.
|
|
861
1447
|
*/
|
|
862
1448
|
id: string;
|
|
1449
|
+
/** Translatable Markdown; Rationale to give the user when they get it wrong */
|
|
863
1450
|
rationale?: string;
|
|
1451
|
+
/** Whether this option is a correct answer or not */
|
|
864
1452
|
correct?: boolean;
|
|
1453
|
+
/** If this is none of the above, override the content with "None of the above" */
|
|
865
1454
|
isNoneOfTheAbove?: boolean;
|
|
866
1455
|
};
|
|
1456
|
+
/** Options for the sorter widget. Cards to arrange into the correct order. */
|
|
867
1457
|
export type PerseusSorterWidgetOptions = {
|
|
1458
|
+
/**
|
|
1459
|
+
* Translatable Text; The correct answer (in the correct order). The user
|
|
1460
|
+
* will see the cards in a randomized order.
|
|
1461
|
+
*/
|
|
868
1462
|
correct: string[];
|
|
1463
|
+
/**
|
|
1464
|
+
* Adds padding to the options. Padding is good for text but not needed
|
|
1465
|
+
* for images
|
|
1466
|
+
*/
|
|
869
1467
|
padding: boolean;
|
|
1468
|
+
/**
|
|
1469
|
+
* Use the "horizontal" layout for short text and small images. The
|
|
1470
|
+
* "vertical" layout is best for longer text and larger images.
|
|
1471
|
+
*/
|
|
870
1472
|
layout: "horizontal" | "vertical";
|
|
871
1473
|
};
|
|
1474
|
+
/** Options for the table widget. A grid of input cells with column headers. */
|
|
872
1475
|
export type PerseusTableWidgetOptions = {
|
|
1476
|
+
/** Translatable Text; A list of column headers */
|
|
873
1477
|
headers: string[];
|
|
1478
|
+
/** The number of rows to display */
|
|
874
1479
|
rows: number;
|
|
1480
|
+
/** The number of columns to display */
|
|
875
1481
|
columns: number;
|
|
1482
|
+
/** Translatable Text; A 2-dimensional array of text to populate the table with */
|
|
876
1483
|
answers: string[][];
|
|
877
1484
|
};
|
|
1485
|
+
/** Options for the interaction widget. A customizable interactive graph. */
|
|
878
1486
|
export type PerseusInteractionWidgetOptions = {
|
|
1487
|
+
/** The definition of the graph */
|
|
879
1488
|
graph: PerseusInteractionGraph;
|
|
1489
|
+
/** The elements of the graph */
|
|
880
1490
|
elements: PerseusInteractionElement[];
|
|
1491
|
+
/** Always false. Not used for this widget */
|
|
881
1492
|
static: boolean;
|
|
882
1493
|
};
|
|
883
1494
|
export type PerseusInteractionGraph = {
|
|
1495
|
+
/** "canvas", "graph" */
|
|
884
1496
|
editableSettings?: Array<"canvas" | "graph">;
|
|
1497
|
+
/** The Grid Canvas size. e.g. [400, 140] */
|
|
885
1498
|
box: Size;
|
|
1499
|
+
/** The Axis labels. e.g. ["x", "y"] */
|
|
886
1500
|
labels: string[];
|
|
1501
|
+
/** The Axis ranges. e.g. [[-10, 10], [-10, 10]] */
|
|
887
1502
|
range: [Interval, Interval];
|
|
1503
|
+
/** The steps in the grid. default [1, 1] */
|
|
888
1504
|
gridStep: [number, number];
|
|
889
1505
|
/**
|
|
890
1506
|
* The type of markings to display on the graph.
|
|
891
1507
|
*/
|
|
892
1508
|
markings: MarkingsType;
|
|
1509
|
+
/** The snap steps. default [0.5, 0.5] */
|
|
893
1510
|
snapStep?: [number, number];
|
|
1511
|
+
/**
|
|
1512
|
+
* Whether the grid is valid or not. Do the numbers all make sense?
|
|
1513
|
+
* NOTE(jeremy) The editor for this widget sometimes stores the graph
|
|
1514
|
+
* editor validation error message into this field. It seems innocuous
|
|
1515
|
+
* because it looks like many of these usages don't actually use the graph
|
|
1516
|
+
* at all.
|
|
1517
|
+
*/
|
|
894
1518
|
valid?: boolean | string;
|
|
1519
|
+
/** An optional background image to use */
|
|
895
1520
|
backgroundImage?: PerseusImageBackground;
|
|
1521
|
+
/** Whether to show the Protractor tool overlayed on top of the graph */
|
|
896
1522
|
showProtractor?: boolean;
|
|
1523
|
+
/** Whether to show the Ruler tool overlayed on top of the graph */
|
|
897
1524
|
showRuler?: boolean;
|
|
1525
|
+
/** The unit to show on the ruler. e.g. "mm", "cm", "m", "km", "in", "ft", "yd", "mi" */
|
|
898
1526
|
rulerLabel?: string;
|
|
1527
|
+
/** How many ticks to show on the ruler. e.g. 1, 2, 4, 8, 10, 16 */
|
|
899
1528
|
rulerTicks?: number;
|
|
1529
|
+
/**
|
|
1530
|
+
* This controls the number (and position) of the tick marks for the X and
|
|
1531
|
+
* Y axis. e.g. [1, 1]
|
|
1532
|
+
*/
|
|
900
1533
|
tickStep: [number, number];
|
|
901
1534
|
};
|
|
902
1535
|
export type PerseusInteractionElement = {
|
|
903
1536
|
type: "function";
|
|
1537
|
+
/** An identifier for the element */
|
|
904
1538
|
key: string;
|
|
905
1539
|
options: PerseusInteractionFunctionElementOptions;
|
|
906
1540
|
} | {
|
|
907
1541
|
type: "label";
|
|
1542
|
+
/** An identifier for the element */
|
|
908
1543
|
key: string;
|
|
909
1544
|
options: PerseusInteractionLabelElementOptions;
|
|
910
1545
|
} | {
|
|
911
1546
|
type: "line";
|
|
1547
|
+
/** An identifier for the element */
|
|
912
1548
|
key: string;
|
|
913
1549
|
options: PerseusInteractionLineElementOptions;
|
|
914
1550
|
} | {
|
|
915
1551
|
type: "movable-line";
|
|
1552
|
+
/** An identifier for the element */
|
|
916
1553
|
key: string;
|
|
917
1554
|
options: PerseusInteractionMovableLineElementOptions;
|
|
918
1555
|
} | {
|
|
919
1556
|
type: "movable-point";
|
|
1557
|
+
/** An identifier for the element */
|
|
920
1558
|
key: string;
|
|
921
1559
|
options: PerseusInteractionMovablePointElementOptions;
|
|
922
1560
|
} | {
|
|
923
1561
|
type: "parametric";
|
|
1562
|
+
/** An identifier for the element */
|
|
924
1563
|
key: string;
|
|
925
1564
|
options: PerseusInteractionParametricElementOptions;
|
|
926
1565
|
} | {
|
|
927
1566
|
type: "point";
|
|
1567
|
+
/** An identifier for the element */
|
|
928
1568
|
key: string;
|
|
929
1569
|
options: PerseusInteractionPointElementOptions;
|
|
930
1570
|
} | {
|
|
931
1571
|
type: "rectangle";
|
|
1572
|
+
/** An identifier for the element */
|
|
932
1573
|
key: string;
|
|
933
1574
|
options: PerseusInteractionRectangleElementOptions;
|
|
934
1575
|
};
|
|
935
1576
|
export type PerseusInteractionFunctionElementOptions = {
|
|
1577
|
+
/** The definition of the function to draw on the graph. e.g "x^2 + 1" */
|
|
936
1578
|
value: string;
|
|
1579
|
+
/** The name of the function like f(n). default: "f" */
|
|
937
1580
|
funcName: string;
|
|
1581
|
+
/** The range of points to start plotting */
|
|
938
1582
|
rangeMin: string;
|
|
1583
|
+
/** The range of points to end plotting */
|
|
939
1584
|
rangeMax: string;
|
|
1585
|
+
/** The color of the stroke. e.g. #6495ED */
|
|
940
1586
|
color: string;
|
|
1587
|
+
/** If the function stroke has a dash, what is it? options: "", "-", "- ", ".", ". " */
|
|
941
1588
|
strokeDasharray: string;
|
|
1589
|
+
/** The thickness of the stroke */
|
|
942
1590
|
strokeWidth: number;
|
|
943
1591
|
};
|
|
944
1592
|
export type PerseusInteractionLabelElementOptions = {
|
|
1593
|
+
/** Translatable Text; the content of the label */
|
|
945
1594
|
label: string;
|
|
1595
|
+
/** The color of the label. e.g. "red" */
|
|
946
1596
|
color: string;
|
|
1597
|
+
/** The X location of the label */
|
|
947
1598
|
coordX: string;
|
|
1599
|
+
/** The Y location of the label */
|
|
948
1600
|
coordY: string;
|
|
949
1601
|
};
|
|
950
1602
|
export type PerseusInteractionLineElementOptions = {
|
|
1603
|
+
/** A color code for the line segment. e.g. "#FFOOAF" */
|
|
951
1604
|
color: string;
|
|
1605
|
+
/** The start of the line segment (X) */
|
|
952
1606
|
startX: string;
|
|
1607
|
+
/** The start of the line segment (Y) */
|
|
953
1608
|
startY: string;
|
|
1609
|
+
/** The end of the line segment (X) */
|
|
954
1610
|
endX: string;
|
|
1611
|
+
/** The end of the line segment (Y) */
|
|
955
1612
|
endY: string;
|
|
1613
|
+
/** If the line stroke has a dash, what is it? options: "", "-", "- ", ".", ". " */
|
|
956
1614
|
strokeDasharray: string;
|
|
1615
|
+
/** The thickness of the line */
|
|
957
1616
|
strokeWidth: number;
|
|
1617
|
+
/** Does the line have an arrow point to it? options: "", "->" */
|
|
958
1618
|
arrows: string;
|
|
959
1619
|
};
|
|
960
1620
|
export type PerseusInteractionMovableLineElementOptions = {
|
|
1621
|
+
/** The start of the line segment (X) */
|
|
961
1622
|
startX: string;
|
|
1623
|
+
/** The start of the line segment (Y) */
|
|
962
1624
|
startY: string;
|
|
1625
|
+
/** Start updates (Xn, Yn) for n */
|
|
963
1626
|
startSubscript: number;
|
|
1627
|
+
/** The end of the line segment (X) */
|
|
964
1628
|
endX: string;
|
|
1629
|
+
/** The end of the line segment (Y) */
|
|
965
1630
|
endY: string;
|
|
1631
|
+
/** End updates (Xm, Ym) for m */
|
|
966
1632
|
endSubscript: number;
|
|
1633
|
+
/** How to constrain this line? options "none", "snap", "x", "y" */
|
|
967
1634
|
constraint: string;
|
|
1635
|
+
/** The snap resolution when constraint is set to "snap" */
|
|
968
1636
|
snap: number;
|
|
1637
|
+
/** The constraint function for when constraint is set to "x" or "y" */
|
|
969
1638
|
constraintFn: string;
|
|
1639
|
+
/** The lowest possible X value */
|
|
970
1640
|
constraintXMin: string;
|
|
1641
|
+
/** The highest possible X value */
|
|
971
1642
|
constraintXMax: string;
|
|
1643
|
+
/** The lowest possible Y value */
|
|
972
1644
|
constraintYMin: string;
|
|
1645
|
+
/** The highest possible Y value */
|
|
973
1646
|
constraintYMax: string;
|
|
974
1647
|
};
|
|
975
1648
|
export type PerseusInteractionMovablePointElementOptions = {
|
|
1649
|
+
/** The X position of the point */
|
|
976
1650
|
startX: string;
|
|
1651
|
+
/** The Y position of the point */
|
|
977
1652
|
startY: string;
|
|
1653
|
+
/** Update (Xn, Yn) for n */
|
|
978
1654
|
varSubscript: number;
|
|
1655
|
+
/** How to constrain this line? options "none", "snap", "x", "y" */
|
|
979
1656
|
constraint: string;
|
|
1657
|
+
/** The snap resolution when constraint is set to "snap" */
|
|
980
1658
|
snap: number;
|
|
1659
|
+
/** The constraint function for when constraint is set to "x" or "y" */
|
|
981
1660
|
constraintFn: string;
|
|
1661
|
+
/** The lowest possible X value */
|
|
982
1662
|
constraintXMin: string;
|
|
1663
|
+
/** The highest possible X value */
|
|
983
1664
|
constraintXMax: string;
|
|
1665
|
+
/** The lowest possible Y value */
|
|
984
1666
|
constraintYMin: string;
|
|
1667
|
+
/** The highest possible Y value */
|
|
985
1668
|
constraintYMax: string;
|
|
986
1669
|
};
|
|
987
1670
|
export type PerseusInteractionParametricElementOptions = {
|
|
1671
|
+
/** The function for the X coordinate. e.g. "\\cos(t)" */
|
|
988
1672
|
x: string;
|
|
1673
|
+
/** The function for the Y coordinate. e.g. "\\sin(t)" */
|
|
989
1674
|
y: string;
|
|
1675
|
+
/** The range of points to start plotting */
|
|
990
1676
|
rangeMin: string;
|
|
1677
|
+
/** The range of points to end plotting */
|
|
991
1678
|
rangeMax: string;
|
|
1679
|
+
/** The color of the stroke. e.g. #6495ED */
|
|
992
1680
|
color: string;
|
|
1681
|
+
/** If the function stroke has a dash, what is it? options: "", "-", "- ", ".", ". " */
|
|
993
1682
|
strokeDasharray: string;
|
|
1683
|
+
/** The thickness of the stroke */
|
|
994
1684
|
strokeWidth: number;
|
|
995
1685
|
};
|
|
996
1686
|
export type PerseusInteractionPointElementOptions = {
|
|
1687
|
+
/** The color of the point. e.g. "black" */
|
|
997
1688
|
color: string;
|
|
1689
|
+
/** The X coordinate of the point */
|
|
998
1690
|
coordX: string;
|
|
1691
|
+
/** The Y coordinate of the point */
|
|
999
1692
|
coordY: string;
|
|
1000
1693
|
};
|
|
1001
1694
|
export type PerseusInteractionRectangleElementOptions = {
|
|
1695
|
+
/** The fill color. e.g. "#EDD19B" */
|
|
1002
1696
|
color: string;
|
|
1697
|
+
/** The lower left point X */
|
|
1003
1698
|
coordX: string;
|
|
1699
|
+
/** The lower left point Y */
|
|
1004
1700
|
coordY: string;
|
|
1701
|
+
/** The width of the rectangle */
|
|
1005
1702
|
width: string;
|
|
1703
|
+
/** The height of the rectangle */
|
|
1006
1704
|
height: string;
|
|
1007
1705
|
};
|
|
1706
|
+
/** Options for the cs-program widget. Embeds a Khan Academy JS program. */
|
|
1008
1707
|
export type PerseusCSProgramWidgetOptions = {
|
|
1708
|
+
/** The ID of the CS program to embed */
|
|
1009
1709
|
programID: string;
|
|
1710
|
+
/** Deprecated. Always null and sometimes omitted entirely. */
|
|
1010
1711
|
programType?: any;
|
|
1712
|
+
/**
|
|
1713
|
+
* Settings that you add here are available to the program as an object
|
|
1714
|
+
* returned by Program.settings()
|
|
1715
|
+
*/
|
|
1011
1716
|
settings: PerseusCSProgramSetting[];
|
|
1717
|
+
/**
|
|
1718
|
+
* If you show the editor, you should use the "full-width" alignment to
|
|
1719
|
+
* make room for the width of the editor.
|
|
1720
|
+
*/
|
|
1012
1721
|
showEditor: boolean;
|
|
1722
|
+
/** Whether to show the execute buttons */
|
|
1013
1723
|
showButtons: boolean;
|
|
1724
|
+
/** The height of the widget */
|
|
1014
1725
|
height: number;
|
|
1015
1726
|
static: boolean;
|
|
1016
1727
|
};
|
|
1017
1728
|
export type PerseusCSProgramSetting = {
|
|
1729
|
+
/** The name/key of the setting */
|
|
1018
1730
|
name: string;
|
|
1731
|
+
/** The value of the setting */
|
|
1019
1732
|
value: string;
|
|
1020
1733
|
};
|
|
1734
|
+
/** Options for the python-program widget. Embeds a KA Python program. */
|
|
1021
1735
|
export type PerseusPythonProgramWidgetOptions = {
|
|
1736
|
+
/** The ID of the Python program to embed */
|
|
1022
1737
|
programID: string;
|
|
1738
|
+
/** The height of the widget in pixels */
|
|
1023
1739
|
height: number;
|
|
1024
1740
|
};
|
|
1741
|
+
/**
|
|
1742
|
+
* This is an object instead of just a string because we think we'll want to
|
|
1743
|
+
* add more fields in the future, like a weight, which would allow us to give
|
|
1744
|
+
* partial credit and weight each criterion separately.
|
|
1745
|
+
*/
|
|
1025
1746
|
export type PerseusFreeResponseWidgetScoringCriterion = {
|
|
1747
|
+
/**
|
|
1748
|
+
* An English-language description of how to score the response for this
|
|
1749
|
+
* criterion.
|
|
1750
|
+
*/
|
|
1026
1751
|
text: string;
|
|
1027
1752
|
};
|
|
1753
|
+
/** Options for the free-response widget. An open-ended text answer. */
|
|
1028
1754
|
export type PerseusFreeResponseWidgetOptions = {
|
|
1755
|
+
/** Whether to allow the user to enter an unlimited number of characters. */
|
|
1029
1756
|
allowUnlimitedCharacters: boolean;
|
|
1757
|
+
/** The maximum number of characters that the user can enter. */
|
|
1030
1758
|
characterLimit: number;
|
|
1759
|
+
/**
|
|
1760
|
+
* The placeholder text that will be displayed to the user in the text
|
|
1761
|
+
* input field.
|
|
1762
|
+
*/
|
|
1031
1763
|
placeholder: string;
|
|
1764
|
+
/** The question text that will be displayed to the user. */
|
|
1032
1765
|
question: string;
|
|
1766
|
+
/**
|
|
1767
|
+
* A list of scoring criteria for the free response question. This is a
|
|
1768
|
+
* list of things the answer should contain to be considered correct.
|
|
1769
|
+
*/
|
|
1033
1770
|
scoringCriteria: ReadonlyArray<PerseusFreeResponseWidgetScoringCriterion>;
|
|
1034
1771
|
};
|
|
1772
|
+
/** Options for the iframe widget. Embeds external content in an iframe. */
|
|
1035
1773
|
export type PerseusIFrameWidgetOptions = {
|
|
1774
|
+
/** A URL to display OR a CS Program ID */
|
|
1036
1775
|
url: string;
|
|
1776
|
+
/**
|
|
1777
|
+
* Settings that you add here are available to the program as an object
|
|
1778
|
+
* returned by Program.settings()
|
|
1779
|
+
*/
|
|
1037
1780
|
settings?: PerseusCSProgramSetting[];
|
|
1781
|
+
/** The width of the widget */
|
|
1038
1782
|
width: number | string;
|
|
1783
|
+
/** The height of the widget */
|
|
1039
1784
|
height: number | string;
|
|
1785
|
+
/** Whether to allow the IFrame to become full-screen (like a video) */
|
|
1040
1786
|
allowFullScreen: boolean;
|
|
1787
|
+
/** Whether to allow the iframe content to redirect the page */
|
|
1041
1788
|
allowTopNavigation?: boolean;
|
|
1789
|
+
/** Always false */
|
|
1042
1790
|
static: boolean;
|
|
1043
1791
|
};
|
|
1792
|
+
/** Options for the phet-simulation widget. Embeds a PhET simulation. */
|
|
1044
1793
|
export type PerseusPhetSimulationWidgetOptions = {
|
|
1794
|
+
/** A URL to display, must start with https://phet.colorado.edu/ */
|
|
1045
1795
|
url: string;
|
|
1796
|
+
/** Translatable Text; Description of the sim for Khanmigo and alt text */
|
|
1046
1797
|
description: string;
|
|
1047
1798
|
};
|
|
1799
|
+
/** Options for the video widget. Embeds a video by its location ID. */
|
|
1048
1800
|
export type PerseusVideoWidgetOptions = {
|
|
1049
1801
|
location: string;
|
|
1802
|
+
/** `static` is not used for the video widget. */
|
|
1050
1803
|
static?: boolean;
|
|
1051
1804
|
};
|
|
1805
|
+
/** Options for the input-number widget (deprecated; prefer numeric-input). */
|
|
1052
1806
|
export type PerseusInputNumberWidgetOptions = {
|
|
1053
1807
|
answerType?: "number" | "decimal" | "integer" | "rational" | "improper" | "mixed" | "percent" | "pi";
|
|
1054
1808
|
inexact?: boolean;
|
|
@@ -1059,6 +1813,7 @@ export type PerseusInputNumberWidgetOptions = {
|
|
|
1059
1813
|
value: string | number;
|
|
1060
1814
|
customKeypad?: boolean;
|
|
1061
1815
|
};
|
|
1816
|
+
/** Options for the molecule-renderer widget. Renders a molecule via SMILES. */
|
|
1062
1817
|
export type PerseusMoleculeRendererWidgetOptions = {
|
|
1063
1818
|
widgetId: string;
|
|
1064
1819
|
rotationAngle?: number;
|