@khanacademy/perseus-core 42.3.0 → 42.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-schema.d.ts +40 -8
- package/dist/index.d.ts +3 -2
- package/dist/index.js +448 -415
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/general-purpose-parsers/object.d.ts +1 -16
- package/dist/parse-perseus-json/perseus-parsers/answer-tile.d.ts +10 -8
- package/dist/parse-perseus-json/perseus-parsers/blank-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/fill-in-the-blank-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/fill-in-the-blank-widget.d.ts +1 -1
- package/dist/parse-perseus-json/perseus-parsers/number-line-widget.d.ts +3 -3
- package/dist/parse-perseus-json/perseus-parsers/sorter-widget.d.ts +9 -0
- package/dist/parse-perseus-json/regression-tests/item-data/sorter-with-legend-and-variant.d.ts +42 -0
- package/dist/parse-perseus-json/regression-tests/item-data/sorter-without-legend-and-variant.d.ts +33 -0
- package/dist/utils/generators/fill-in-the-blank-widget-generator.d.ts +2 -1
- package/dist/utils/generators/sorter-widget-generator.d.ts +2 -1
- package/dist/utils/is-correct.d.ts +5 -0
- package/dist/validation.types.d.ts +7 -0
- package/dist/widgets/sorter/sorter-util.d.ts +2 -0
- package/package.json +1 -1
- package/dist/parse-perseus-json/general-purpose-parsers/parser.testutils.d.ts +0 -14
- package/dist/utils/range.testutils.d.ts +0 -1
package/dist/data-schema.d.ts
CHANGED
|
@@ -438,6 +438,17 @@ export type PerseusAnswerTile = {
|
|
|
438
438
|
/** Display height in px for an image tile. */
|
|
439
439
|
imageHeight?: number;
|
|
440
440
|
};
|
|
441
|
+
/**
|
|
442
|
+
* An answer tile in a fill-in-the-blank widget's choice bank.
|
|
443
|
+
*/
|
|
444
|
+
export type PerseusFillInTheBlankTile = PerseusAnswerTile & {
|
|
445
|
+
/**
|
|
446
|
+
* How many blanks this tile may fill: a positive number, or "unlimited".
|
|
447
|
+
* 1 makes the tile single-use: placing it again moves it rather than
|
|
448
|
+
* copying it. Authors set this per tile, e.g. 10 pennies and 5 dimes.
|
|
449
|
+
*/
|
|
450
|
+
maxUses: number | "unlimited";
|
|
451
|
+
};
|
|
441
452
|
/**
|
|
442
453
|
* Options for the fill-in-the-blank widget. Presents content with inline
|
|
443
454
|
* blanks above a choice bank of answer tiles.
|
|
@@ -449,11 +460,7 @@ export type PerseusFillInTheBlankWidgetOptions = {
|
|
|
449
460
|
/** The widgets embedded in `content`, keyed by widget id. */
|
|
450
461
|
widgets: PerseusWidgetsMap;
|
|
451
462
|
/** The choice bank the learner draws answer tiles from */
|
|
452
|
-
tiles:
|
|
453
|
-
/**
|
|
454
|
-
* How many times each tile may be placed, for the whole choice bank.
|
|
455
|
-
*/
|
|
456
|
-
maxUsesPerTile: number | "unlimited";
|
|
463
|
+
tiles: PerseusFillInTheBlankTile[];
|
|
457
464
|
/**
|
|
458
465
|
* Randomize the order of the answer tiles or keep them as defined.
|
|
459
466
|
*/
|
|
@@ -1446,13 +1453,13 @@ export type PerseusNumberLineWidgetOptions = {
|
|
|
1446
1453
|
* The position of the endpoints of the number line. Setting the range
|
|
1447
1454
|
* constrains the position of the answer and the labels.
|
|
1448
1455
|
*/
|
|
1449
|
-
range: number
|
|
1456
|
+
range: [min: number, max: number];
|
|
1450
1457
|
/**
|
|
1451
1458
|
* This controls the position of the left / right labels. By default, the
|
|
1452
1459
|
* labels are set by the range. Note: Ensure that the labels line up with
|
|
1453
1460
|
* the tick marks, or it may be confusing for users.
|
|
1454
1461
|
*/
|
|
1455
|
-
labelRange:
|
|
1462
|
+
labelRange: [left: number | null, right: number | null];
|
|
1456
1463
|
/**
|
|
1457
1464
|
* This controls the styling of the labels for the two main labels as well
|
|
1458
1465
|
* as all the tick mark labels, if applicable.
|
|
@@ -1468,7 +1475,7 @@ export type PerseusNumberLineWidgetOptions = {
|
|
|
1468
1475
|
/**
|
|
1469
1476
|
* The range of possible values for numDivisions, in the format [min, max].
|
|
1470
1477
|
*/
|
|
1471
|
-
divisionRange: number
|
|
1478
|
+
divisionRange: [min: number, max: number];
|
|
1472
1479
|
/**
|
|
1473
1480
|
* The number of divisions of the number line. Divisions are the spaces
|
|
1474
1481
|
* between tick marks.
|
|
@@ -1608,6 +1615,19 @@ export type PerseusRadioChoice = {
|
|
|
1608
1615
|
/** If this is none of the above, override the content with "None of the above" */
|
|
1609
1616
|
isNoneOfTheAbove?: boolean;
|
|
1610
1617
|
};
|
|
1618
|
+
export type SorterVariant = "scale" | "timeline";
|
|
1619
|
+
export type SorterLegendCap = "arrow" | "bar" | "none";
|
|
1620
|
+
export type SorterLegend = {
|
|
1621
|
+
startCap: SorterLegendCap;
|
|
1622
|
+
endCap: SorterLegendCap;
|
|
1623
|
+
/** Translatable text - accepts plain text and TeX but not markdown */
|
|
1624
|
+
startLabel: string;
|
|
1625
|
+
/** Translatable text - accepts plain text and TeX but not markdown */
|
|
1626
|
+
endLabel: string;
|
|
1627
|
+
/** Translatable text */
|
|
1628
|
+
ariaLabel: string;
|
|
1629
|
+
position: "above" | "below";
|
|
1630
|
+
};
|
|
1611
1631
|
/** Options for the sorter widget. Cards to arrange into the correct order. */
|
|
1612
1632
|
export type PerseusSorterWidgetOptions = {
|
|
1613
1633
|
/**
|
|
@@ -1620,6 +1640,18 @@ export type PerseusSorterWidgetOptions = {
|
|
|
1620
1640
|
* "vertical" layout is best for longer text and larger images.
|
|
1621
1641
|
*/
|
|
1622
1642
|
layout: "horizontal" | "vertical";
|
|
1643
|
+
/**
|
|
1644
|
+
* Which kind of Sorter this is. Content saved without one is parsed as
|
|
1645
|
+
* "scale".
|
|
1646
|
+
* Sets the allowed number of blanks, the layout ("timeline" adds connector
|
|
1647
|
+
* lines and staggers blanks around the legend), and the default legend caps.
|
|
1648
|
+
*/
|
|
1649
|
+
variant: SorterVariant;
|
|
1650
|
+
/**
|
|
1651
|
+
* The labeled line along the blanks that shows learners which order
|
|
1652
|
+
* to place the tiles in, with optional end caps.
|
|
1653
|
+
*/
|
|
1654
|
+
legend?: SorterLegend;
|
|
1623
1655
|
/**
|
|
1624
1656
|
* Adds padding to the options. Padding is good for text but not needed
|
|
1625
1657
|
* for images
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type { KeypadConfiguration, KeypadContextRendererInterface, } from "./key
|
|
|
7
7
|
export type { ErrorKind } from "./error/errors";
|
|
8
8
|
/** @hidden */
|
|
9
9
|
export { default as ErrorCodes, type ErrorCode } from "./error-codes";
|
|
10
|
+
export { isCorrect } from "./utils/is-correct";
|
|
10
11
|
/** @hidden */
|
|
11
12
|
export type { FunctionTypeMappingKeys } from "./utils/grapher-util";
|
|
12
13
|
/** @hidden */
|
|
@@ -223,7 +224,7 @@ export { generateExplanationOptions, generateExplanationWidget, } from "./utils/
|
|
|
223
224
|
/** @hidden */
|
|
224
225
|
export { generateExpressionOptions, generateExpressionAnswerForm, generateExpressionWidget, } from "./utils/generators/expression-widget-generator";
|
|
225
226
|
/** @hidden */
|
|
226
|
-
export { generateAnswerTile, generateFillInTheBlankOptions, generateFillInTheBlankWidget, } from "./utils/generators/fill-in-the-blank-widget-generator";
|
|
227
|
+
export { generateAnswerTile, generateFillInTheBlankTile, generateFillInTheBlankOptions, generateFillInTheBlankWidget, } from "./utils/generators/fill-in-the-blank-widget-generator";
|
|
227
228
|
/** @hidden */
|
|
228
229
|
export { generateFreeResponseOptions, generateFreeResponseWidget, } from "./utils/generators/free-response-widget-generator";
|
|
229
230
|
/** @hidden */
|
|
@@ -263,7 +264,7 @@ export { generateRadioOptions, generateRadioChoice, generateSimpleRadioQuestion,
|
|
|
263
264
|
/** @hidden */
|
|
264
265
|
export { generateVideoWidget } from "./utils/generators/video-widget-generator";
|
|
265
266
|
/** @hidden */
|
|
266
|
-
export { generateSorterWidget, generateSorterOptions, } from "./utils/generators/sorter-widget-generator";
|
|
267
|
+
export { generateSorterWidget, generateSorterOptions, generateSorterLegend, } from "./utils/generators/sorter-widget-generator";
|
|
267
268
|
/** @hidden */
|
|
268
269
|
export { generateTableOptions } from "./utils/generators/table-widget-generator";
|
|
269
270
|
/** @hidden */
|