@khanacademy/perseus 37.0.0 → 37.0.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/all-widgets.d.ts +1 -0
- package/dist/basic-widgets.d.ts +1 -0
- package/dist/es/index.js +58 -61
- package/dist/es/index.js.map +1 -1
- package/dist/extra-widgets.d.ts +1 -0
- package/dist/index.js +55 -59
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -0
- package/dist/server-item-renderer.d.ts +2 -3
- package/dist/types.d.ts +2 -1
- package/dist/util/extract-perseus-data.d.ts +1 -1
- package/dist/widgets/categorizer/categorizer.d.ts +1 -0
- package/dist/widgets/cs-program/cs-program.d.ts +1 -0
- package/dist/widgets/definition/definition.d.ts +1 -0
- package/dist/widgets/deprecated-standin/deprecated-standin.d.ts +1 -0
- package/dist/widgets/dropdown/dropdown.d.ts +1 -0
- package/dist/widgets/explanation/explanation.d.ts +1 -0
- package/dist/widgets/expression/expression.d.ts +7 -1
- package/dist/widgets/graded-group/graded-group.d.ts +1 -0
- package/dist/widgets/graded-group-set/graded-group-set.d.ts +1 -0
- package/dist/widgets/grapher/grapher.d.ts +1 -0
- package/dist/widgets/group/group.d.ts +1 -0
- package/dist/widgets/iframe/iframe.d.ts +1 -0
- package/dist/widgets/image/image.d.ts +1 -0
- package/dist/widgets/input-number/input-number.d.ts +1 -1
- package/dist/widgets/interaction/interaction.d.ts +1 -0
- package/dist/widgets/interactive-graph.d.ts +1 -0
- package/dist/widgets/interactive-graphs/mafs-supported-graph-types.d.ts +1 -1
- package/dist/widgets/label-image/label-image.d.ts +3 -0
- package/dist/widgets/matcher/matcher.d.ts +1 -0
- package/dist/widgets/matrix/matrix.d.ts +1 -0
- package/dist/widgets/measurer/measurer.d.ts +1 -0
- package/dist/widgets/molecule/molecule.d.ts +1 -0
- package/dist/widgets/number-line/number-line.d.ts +1 -0
- package/dist/widgets/numeric-input/numeric-input.d.ts +1 -1
- package/dist/widgets/orderer/orderer.d.ts +1 -0
- package/dist/widgets/passage/passage.d.ts +1 -0
- package/dist/widgets/passage-ref/passage-ref.d.ts +1 -0
- package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +1 -0
- package/dist/widgets/phet-simulation/phet-simulation.d.ts +1 -0
- package/dist/widgets/plotter/plotter.d.ts +1 -0
- package/dist/widgets/python-program/python-program.d.ts +1 -0
- package/dist/widgets/radio/radio.d.ts +1 -0
- package/dist/widgets/sorter/sorter.d.ts +1 -0
- package/dist/widgets/table/table.d.ts +1 -0
- package/dist/widgets/video/video.d.ts +1 -0
- package/dist/widgets.d.ts +1 -0
- package/package.json +1 -1
package/dist/all-widgets.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ declare const _default: readonly Readonly<{
|
|
|
16
16
|
transform?: import("./types").WidgetTransform | undefined;
|
|
17
17
|
staticTransform?: import("./types").WidgetTransform | undefined;
|
|
18
18
|
validator?: import("./types").WidgetValidatorFunction | undefined;
|
|
19
|
+
getOneCorrectAnswerFromRubric?: ((rubric: import("./validation.types").Rubric) => string | null | undefined) | undefined;
|
|
19
20
|
propUpgrades?: {
|
|
20
21
|
[key: string]: (arg1: any) => any;
|
|
21
22
|
} | undefined;
|
package/dist/basic-widgets.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ declare const _default: readonly Readonly<{
|
|
|
16
16
|
transform?: import("./types").WidgetTransform | undefined;
|
|
17
17
|
staticTransform?: import("./types").WidgetTransform | undefined;
|
|
18
18
|
validator?: import("./types").WidgetValidatorFunction | undefined;
|
|
19
|
+
getOneCorrectAnswerFromRubric?: ((rubric: import("./validation.types").Rubric) => string | null | undefined) | undefined;
|
|
19
20
|
propUpgrades?: {
|
|
20
21
|
[key: string]: (arg1: any) => any;
|
|
21
22
|
} | undefined;
|
package/dist/es/index.js
CHANGED
|
@@ -2376,15 +2376,6 @@ class Expression extends React.Component {
|
|
|
2376
2376
|
static getUserInputFromProps(props) {
|
|
2377
2377
|
return normalizeTex(props.value);
|
|
2378
2378
|
}
|
|
2379
|
-
static getOneCorrectAnswerFromRubric(rubric) {
|
|
2380
|
-
const correctAnswers = (rubric.answerForms || []).filter(answerForm => answerForm.considered === "correct");
|
|
2381
|
-
if (correctAnswers.length === 0) {
|
|
2382
|
-
return;
|
|
2383
|
-
}
|
|
2384
|
-
return correctAnswers[0].value;
|
|
2385
|
-
}
|
|
2386
|
-
//#endregion
|
|
2387
|
-
|
|
2388
2379
|
getUserInput() {
|
|
2389
2380
|
return Expression.getUserInputFromProps(this.props);
|
|
2390
2381
|
}
|
|
@@ -2612,11 +2603,7 @@ const ExpressionWithDependencies = /*#__PURE__*/React.forwardRef((props, ref) =>
|
|
|
2612
2603
|
// methods and instead adjust Perseus to provide these facilities through
|
|
2613
2604
|
// instance methods on our Renderers.
|
|
2614
2605
|
// @ts-expect-error - TS2339 - Property 'validate' does not exist on type
|
|
2615
|
-
ExpressionWithDependencies.validate = expressionValidator;
|
|
2616
|
-
// @ts-expect-error - TS2339 - Property 'validate' does not exist on type
|
|
2617
2606
|
ExpressionWithDependencies.getUserInputFromProps = Expression.getUserInputFromProps;
|
|
2618
|
-
// @ts-expect-error - TS2339 - Property 'validate' does not exist on type
|
|
2619
|
-
ExpressionWithDependencies.getOneCorrectAnswerFromRubric = Expression.getOneCorrectAnswerFromRubric;
|
|
2620
2607
|
var Expression$1 = {
|
|
2621
2608
|
name: "expression",
|
|
2622
2609
|
displayName: "Expression / Equation",
|
|
@@ -2649,7 +2636,14 @@ var Expression$1 = {
|
|
|
2649
2636
|
propUpgrades: propUpgrades$2,
|
|
2650
2637
|
// For use by the editor
|
|
2651
2638
|
isLintable: true,
|
|
2652
|
-
validator: expressionValidator
|
|
2639
|
+
validator: expressionValidator,
|
|
2640
|
+
getOneCorrectAnswerFromRubric(rubric) {
|
|
2641
|
+
const correctAnswers = (rubric.answerForms || []).filter(answerForm => answerForm.considered === "correct");
|
|
2642
|
+
if (correctAnswers.length === 0) {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
return correctAnswers[0].value;
|
|
2646
|
+
}
|
|
2653
2647
|
};
|
|
2654
2648
|
|
|
2655
2649
|
/**
|
|
@@ -18893,9 +18887,13 @@ const getWidget = name => {
|
|
|
18893
18887
|
}
|
|
18894
18888
|
return widgets[name].widget;
|
|
18895
18889
|
};
|
|
18890
|
+
const getWidgetExport = name => {
|
|
18891
|
+
var _widgets$name3;
|
|
18892
|
+
return (_widgets$name3 = widgets[name]) != null ? _widgets$name3 : null;
|
|
18893
|
+
};
|
|
18896
18894
|
const getWidgetValidator = name => {
|
|
18897
|
-
var _widgets$name$validat, _widgets$
|
|
18898
|
-
return (_widgets$name$validat = (_widgets$
|
|
18895
|
+
var _widgets$name$validat, _widgets$name4;
|
|
18896
|
+
return (_widgets$name$validat = (_widgets$name4 = widgets[name]) == null ? void 0 : _widgets$name4.validator) != null ? _widgets$name$validat : null;
|
|
18899
18897
|
};
|
|
18900
18898
|
const getEditor = name => {
|
|
18901
18899
|
return _.has(editors, name) ? editors[name] : null;
|
|
@@ -19199,6 +19197,7 @@ var widgets$1 = /*#__PURE__*/Object.freeze({
|
|
|
19199
19197
|
replaceEditor: replaceEditor,
|
|
19200
19198
|
replaceDeprecatedEditors: replaceDeprecatedEditors,
|
|
19201
19199
|
getWidget: getWidget,
|
|
19200
|
+
getWidgetExport: getWidgetExport,
|
|
19202
19201
|
getWidgetValidator: getWidgetValidator,
|
|
19203
19202
|
getEditor: getEditor,
|
|
19204
19203
|
getTransform: getTransform,
|
|
@@ -21817,16 +21816,6 @@ class InputNumber extends React.Component {
|
|
|
21817
21816
|
currentValue: props.currentValue
|
|
21818
21817
|
};
|
|
21819
21818
|
}
|
|
21820
|
-
static getOneCorrectAnswerFromRubric(rubric) {
|
|
21821
|
-
if (rubric.value == null) {
|
|
21822
|
-
return;
|
|
21823
|
-
}
|
|
21824
|
-
let answerString = String(rubric.value);
|
|
21825
|
-
if (rubric.inexact && rubric.maxError) {
|
|
21826
|
-
answerString += " \u00B1 " + rubric.maxError;
|
|
21827
|
-
}
|
|
21828
|
-
return answerString;
|
|
21829
|
-
}
|
|
21830
21819
|
getUserInput() {
|
|
21831
21820
|
return InputNumber.getUserInputFromProps(this.props);
|
|
21832
21821
|
}
|
|
@@ -21935,7 +21924,17 @@ var InputNumber$1 = {
|
|
|
21935
21924
|
widget: InputNumber,
|
|
21936
21925
|
transform: propTransform$3,
|
|
21937
21926
|
isLintable: true,
|
|
21938
|
-
validator: inputNumberValidator
|
|
21927
|
+
validator: inputNumberValidator,
|
|
21928
|
+
getOneCorrectAnswerFromRubric(rubric) {
|
|
21929
|
+
if (rubric.value == null) {
|
|
21930
|
+
return;
|
|
21931
|
+
}
|
|
21932
|
+
let answerString = String(rubric.value);
|
|
21933
|
+
if (rubric.inexact && rubric.maxError) {
|
|
21934
|
+
answerString += " \u00B1 " + rubric.maxError;
|
|
21935
|
+
}
|
|
21936
|
+
return answerString;
|
|
21937
|
+
}
|
|
21939
21938
|
};
|
|
21940
21939
|
|
|
21941
21940
|
const ParseTex = TexWrangler.parseTex;
|
|
@@ -22181,34 +22180,6 @@ class NumericInput extends React.Component {
|
|
|
22181
22180
|
currentValue: props.currentValue
|
|
22182
22181
|
};
|
|
22183
22182
|
}
|
|
22184
|
-
static getOneCorrectAnswerFromRubric(rubric) {
|
|
22185
|
-
const correctAnswers = rubric.answers.filter(answer => answer.status === "correct");
|
|
22186
|
-
const answerStrings = correctAnswers.map(answer => {
|
|
22187
|
-
// Figure out how this answer is supposed to be
|
|
22188
|
-
// displayed
|
|
22189
|
-
let format = "decimal";
|
|
22190
|
-
if (answer.answerForms && answer.answerForms[0]) {
|
|
22191
|
-
// NOTE(johnsullivan): This isn't exactly ideal, but
|
|
22192
|
-
// it does behave well for all the currently known
|
|
22193
|
-
// problems. See D14742 for some discussion on
|
|
22194
|
-
// alternate strategies.
|
|
22195
|
-
format = answer.answerForms[0];
|
|
22196
|
-
}
|
|
22197
|
-
|
|
22198
|
-
// @ts-expect-error - TS2345 - Argument of type 'string' is not assignable to parameter of type 'MathFormat | undefined'.
|
|
22199
|
-
let answerString = KhanMath.toNumericString(answer.value, format);
|
|
22200
|
-
if (answer.maxError) {
|
|
22201
|
-
answerString += " \u00B1 " +
|
|
22202
|
-
// @ts-expect-error - TS2345 - Argument of type 'string' is not assignable to parameter of type 'MathFormat | undefined'.
|
|
22203
|
-
KhanMath.toNumericString(answer.maxError, format);
|
|
22204
|
-
}
|
|
22205
|
-
return answerString;
|
|
22206
|
-
});
|
|
22207
|
-
if (answerStrings.length === 0) {
|
|
22208
|
-
return;
|
|
22209
|
-
}
|
|
22210
|
-
return answerStrings[0];
|
|
22211
|
-
}
|
|
22212
22183
|
getUserInput() {
|
|
22213
22184
|
return NumericInput.getUserInputFromProps(this.props);
|
|
22214
22185
|
}
|
|
@@ -22336,7 +22307,35 @@ var NumericInput$1 = {
|
|
|
22336
22307
|
widget: NumericInput,
|
|
22337
22308
|
transform: propsTransform,
|
|
22338
22309
|
isLintable: true,
|
|
22339
|
-
validator: numericInputValidator
|
|
22310
|
+
validator: numericInputValidator,
|
|
22311
|
+
getOneCorrectAnswerFromRubric(rubric) {
|
|
22312
|
+
const correctAnswers = rubric.answers.filter(answer => answer.status === "correct");
|
|
22313
|
+
const answerStrings = correctAnswers.map(answer => {
|
|
22314
|
+
// Figure out how this answer is supposed to be
|
|
22315
|
+
// displayed
|
|
22316
|
+
let format = "decimal";
|
|
22317
|
+
if (answer.answerForms && answer.answerForms[0]) {
|
|
22318
|
+
// NOTE(johnsullivan): This isn't exactly ideal, but
|
|
22319
|
+
// it does behave well for all the currently known
|
|
22320
|
+
// problems. See D14742 for some discussion on
|
|
22321
|
+
// alternate strategies.
|
|
22322
|
+
format = answer.answerForms[0];
|
|
22323
|
+
}
|
|
22324
|
+
|
|
22325
|
+
// @ts-expect-error - TS2345 - Argument of type 'string' is not assignable to parameter of type 'MathFormat | undefined'.
|
|
22326
|
+
let answerString = KhanMath.toNumericString(answer.value, format);
|
|
22327
|
+
if (answer.maxError) {
|
|
22328
|
+
answerString += " \u00B1 " +
|
|
22329
|
+
// @ts-expect-error - TS2345 - Argument of type 'string' is not assignable to parameter of type 'MathFormat | undefined'.
|
|
22330
|
+
KhanMath.toNumericString(answer.maxError, format);
|
|
22331
|
+
}
|
|
22332
|
+
return answerString;
|
|
22333
|
+
});
|
|
22334
|
+
if (answerStrings.length === 0) {
|
|
22335
|
+
return;
|
|
22336
|
+
}
|
|
22337
|
+
return answerStrings[0];
|
|
22338
|
+
}
|
|
22340
22339
|
};
|
|
22341
22340
|
|
|
22342
22341
|
/**
|
|
@@ -37599,7 +37598,7 @@ function shouldUseMafs(mafsFlags, graph) {
|
|
|
37599
37598
|
// TODO(benchristel): add a feature flag for the "unlimited"
|
|
37600
37599
|
// case once we've implemented polygon graphs with unlimited
|
|
37601
37600
|
// sides
|
|
37602
|
-
return
|
|
37601
|
+
return Boolean(mafsFlags["unlimited-polygon"]);
|
|
37603
37602
|
}
|
|
37604
37603
|
return Boolean(mafsFlags["polygon"]);
|
|
37605
37604
|
default:
|
|
@@ -44805,7 +44804,7 @@ const init = function init(options) {
|
|
|
44805
44804
|
|
|
44806
44805
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44807
44806
|
const libName = "@khanacademy/perseus";
|
|
44808
|
-
const libVersion = "37.0.
|
|
44807
|
+
const libVersion = "37.0.1";
|
|
44809
44808
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44810
44809
|
|
|
44811
44810
|
const apiVersion = {
|
|
@@ -48053,9 +48052,7 @@ const getCorrectAnswerForWidgetId = (widgetId, itemData) => {
|
|
|
48053
48052
|
const rubric = itemData.question.widgets[widgetId].options;
|
|
48054
48053
|
const widgetMap = getWidgetsMapFromItemData(itemData);
|
|
48055
48054
|
const widgetType = getWidgetTypeByWidgetId(widgetId, widgetMap);
|
|
48056
|
-
const widget =
|
|
48057
|
-
|
|
48058
|
-
// @ts-expect-error - TS2339 - Property 'getOneCorrectAnswerFromRubric' does not exist on type 'ComponentType<any>'.
|
|
48055
|
+
const widget = getWidgetExport(widgetType);
|
|
48059
48056
|
return widget == null || widget.getOneCorrectAnswerFromRubric == null ? void 0 : widget.getOneCorrectAnswerFromRubric(rubric);
|
|
48060
48057
|
};
|
|
48061
48058
|
|