@khanacademy/perseus-core 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data-schema.d.ts +11 -3
- package/dist/es/index.js +30 -11
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +30 -11
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/numeric-input-widget.d.ts +2 -1
- package/dist/utils/split-perseus-item.d.ts +3 -2
- package/package.json +1 -1
package/dist/data-schema.d.ts
CHANGED
|
@@ -766,10 +766,18 @@ export type PerseusMeasurerWidgetOptions = {
|
|
|
766
766
|
};
|
|
767
767
|
export type MathFormat = "integer" | "mixed" | "improper" | "proper" | "decimal" | "percent" | "pi";
|
|
768
768
|
export type PerseusNumericInputAnswerForm = {
|
|
769
|
-
simplify: PerseusNumericInputSimplify
|
|
769
|
+
simplify: PerseusNumericInputSimplify;
|
|
770
770
|
name: MathFormat;
|
|
771
771
|
};
|
|
772
|
-
|
|
772
|
+
/**
|
|
773
|
+
* Determines how unsimplified fractions are scored.
|
|
774
|
+
*
|
|
775
|
+
* - "required" means unsimplified fractions are considered invalid input, and
|
|
776
|
+
* the learner can try again.
|
|
777
|
+
* - "enforced" means unsimplified fractions are marked incorrect.
|
|
778
|
+
* - "optional" means unsimplified fractions are accepted.
|
|
779
|
+
*/
|
|
780
|
+
export type PerseusNumericInputSimplify = "required" | "enforced" | "optional";
|
|
773
781
|
export type PerseusNumericInputWidgetOptions = {
|
|
774
782
|
answers: ReadonlyArray<PerseusNumericInputAnswer>;
|
|
775
783
|
labelText?: string | undefined;
|
|
@@ -785,7 +793,7 @@ export type PerseusNumericInputAnswer = {
|
|
|
785
793
|
answerForms?: ReadonlyArray<MathFormat>;
|
|
786
794
|
strict: boolean;
|
|
787
795
|
maxError: number | null | undefined;
|
|
788
|
-
simplify: PerseusNumericInputSimplify
|
|
796
|
+
simplify: PerseusNumericInputSimplify;
|
|
789
797
|
};
|
|
790
798
|
export type PerseusNumberLineWidgetOptions = {
|
|
791
799
|
range: ReadonlyArray<number>;
|
package/dist/es/index.js
CHANGED
|
@@ -1959,6 +1959,15 @@ const lockedFigureFillStyles = {
|
|
|
1959
1959
|
|
|
1960
1960
|
// Not associated with a specific figure
|
|
1961
1961
|
|
|
1962
|
+
/**
|
|
1963
|
+
* Determines how unsimplified fractions are scored.
|
|
1964
|
+
*
|
|
1965
|
+
* - "required" means unsimplified fractions are considered invalid input, and
|
|
1966
|
+
* the learner can try again.
|
|
1967
|
+
* - "enforced" means unsimplified fractions are marked incorrect.
|
|
1968
|
+
* - "optional" means unsimplified fractions are accepted.
|
|
1969
|
+
*/
|
|
1970
|
+
|
|
1962
1971
|
const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
|
|
1963
1972
|
|
|
1964
1973
|
// Used to represent 2-D points and ranges
|
|
@@ -2243,7 +2252,21 @@ const parseNumberLineWidget = parseWidget(constant("number-line"), object({
|
|
|
2243
2252
|
}));
|
|
2244
2253
|
|
|
2245
2254
|
const parseMathFormat = enumeration("integer", "mixed", "improper", "proper", "decimal", "percent", "pi");
|
|
2246
|
-
const parseSimplify =
|
|
2255
|
+
const parseSimplify = pipeParsers(union(constant(null)).or(constant(undefined)).or(boolean).or(constant("required")).or(constant("correct")).or(constant("enforced")).or(constant("optional")).or(constant("accepted")).parser).then(convert(deprecatedSimplifyValuesToRequired)).parser;
|
|
2256
|
+
function deprecatedSimplifyValuesToRequired(simplify) {
|
|
2257
|
+
switch (simplify) {
|
|
2258
|
+
case "enforced":
|
|
2259
|
+
case "required":
|
|
2260
|
+
case "optional":
|
|
2261
|
+
return simplify;
|
|
2262
|
+
// NOTE(benchristel): "accepted", "correct", true, false, undefined, and
|
|
2263
|
+
// null are all treated the same as "required" during scoring, so we
|
|
2264
|
+
// convert them to "required" here to preserve behavior. See the tests
|
|
2265
|
+
// in score-numeric-input.test.ts
|
|
2266
|
+
default:
|
|
2267
|
+
return "required";
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2247
2270
|
const parseNumericInputWidget = parseWidget(constant("numeric-input"), object({
|
|
2248
2271
|
answers: array(object({
|
|
2249
2272
|
message: string,
|
|
@@ -2258,12 +2281,7 @@ const parseNumericInputWidget = parseWidget(constant("numeric-input"), object({
|
|
|
2258
2281
|
// TODO(benchristel): simplify should never be a boolean, but we
|
|
2259
2282
|
// have some content where it is anyway. If we ever backfill
|
|
2260
2283
|
// the data, we should simplify `simplify`.
|
|
2261
|
-
simplify:
|
|
2262
|
-
if (typeof value === "boolean") {
|
|
2263
|
-
return value ? "required" : "optional";
|
|
2264
|
-
}
|
|
2265
|
-
return value;
|
|
2266
|
-
})).parser).parser))
|
|
2284
|
+
simplify: parseSimplify
|
|
2267
2285
|
})),
|
|
2268
2286
|
labelText: optional(string),
|
|
2269
2287
|
size: string,
|
|
@@ -2272,7 +2290,7 @@ const parseNumericInputWidget = parseWidget(constant("numeric-input"), object({
|
|
|
2272
2290
|
static: defaulted(boolean, () => false),
|
|
2273
2291
|
answerForms: optional(array(object({
|
|
2274
2292
|
name: parseMathFormat,
|
|
2275
|
-
simplify:
|
|
2293
|
+
simplify: parseSimplify
|
|
2276
2294
|
})))
|
|
2277
2295
|
}));
|
|
2278
2296
|
|
|
@@ -2844,7 +2862,7 @@ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
|
|
|
2844
2862
|
|
|
2845
2863
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
2846
2864
|
const libName = "@khanacademy/perseus-core";
|
|
2847
|
-
const libVersion = "5.4.
|
|
2865
|
+
const libVersion = "5.4.1";
|
|
2848
2866
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
2849
2867
|
|
|
2850
2868
|
/**
|
|
@@ -4025,8 +4043,9 @@ function getUpgradedWidgetOptions(oldWidgetOptions) {
|
|
|
4025
4043
|
}
|
|
4026
4044
|
|
|
4027
4045
|
/**
|
|
4028
|
-
*
|
|
4029
|
-
*
|
|
4046
|
+
* Return a copy of a Perseus item with rubric data removed (ie answers)
|
|
4047
|
+
*
|
|
4048
|
+
* @param originalItem - the original, full Perseus item (which includes the rubric - aka answer data)
|
|
4030
4049
|
*/
|
|
4031
4050
|
function splitPerseusItem(originalItem) {
|
|
4032
4051
|
var _item$widgets;
|