@khanacademy/perseus 42.0.1 → 42.0.3
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/index.js
CHANGED
|
@@ -19006,13 +19006,13 @@ const getInputNumberRenameMap = json => {
|
|
|
19006
19006
|
};
|
|
19007
19007
|
|
|
19008
19008
|
// Convert the user input data keys from input-number to numeric-input
|
|
19009
|
-
const convertUserInputNumberData = userInputMap => {
|
|
19009
|
+
const convertUserInputNumberData = (userInputMap, renameMap) => {
|
|
19010
19010
|
const updatedUserInputMap = {
|
|
19011
19011
|
...userInputMap
|
|
19012
19012
|
};
|
|
19013
19013
|
for (const key of Object.keys(userInputMap)) {
|
|
19014
19014
|
if (key.includes("input-number")) {
|
|
19015
|
-
const updatedKey = key
|
|
19015
|
+
const updatedKey = renameMap[key];
|
|
19016
19016
|
updatedUserInputMap[updatedKey] = userInputMap[key];
|
|
19017
19017
|
delete updatedUserInputMap[key];
|
|
19018
19018
|
}
|
|
@@ -19020,6 +19020,19 @@ const convertUserInputNumberData = userInputMap => {
|
|
|
19020
19020
|
return updatedUserInputMap;
|
|
19021
19021
|
};
|
|
19022
19022
|
|
|
19023
|
+
// Used to convert InputNumber widgets to NumericInput widgets for scoring
|
|
19024
|
+
const convertInputNumberForScoring = (rubric, userInputMap) => {
|
|
19025
|
+
// First we need to create a map of the old input-number keys to the new numeric-input keys
|
|
19026
|
+
// so that we can ensure we update the content, widgets, AND userInput accordingly
|
|
19027
|
+
const renameMap = getInputNumberRenameMap(rubric);
|
|
19028
|
+
const convertedRubric = convertInputNumberJson(rubric, renameMap);
|
|
19029
|
+
const convertedUserData = convertUserInputNumberData(userInputMap, renameMap);
|
|
19030
|
+
return {
|
|
19031
|
+
convertedRubric,
|
|
19032
|
+
convertedUserData
|
|
19033
|
+
};
|
|
19034
|
+
};
|
|
19035
|
+
|
|
19023
19036
|
const widgetRegExes = [/input-number \d+/]; // We can add more regexes here in the future
|
|
19024
19037
|
|
|
19025
19038
|
// This utils in this file are used to modernize our Perseus JSON structure,
|
|
@@ -19027,6 +19040,7 @@ const widgetRegExes = [/input-number \d+/]; // We can add more regexes here in t
|
|
|
19027
19040
|
// content creators use the Editor Page to update content containing these widgets.
|
|
19028
19041
|
// Currently, we're only converting input-number to numeric-input,
|
|
19029
19042
|
// but we can add more conversions here in the future.
|
|
19043
|
+
|
|
19030
19044
|
// Modernize the json content of a PerseusRenderer object
|
|
19031
19045
|
// by converting deprecated widgets to their modern equivalents
|
|
19032
19046
|
const convertDeprecatedWidgets = json => {
|
|
@@ -19056,11 +19070,13 @@ const conversionRequired = json => {
|
|
|
19056
19070
|
return false;
|
|
19057
19071
|
};
|
|
19058
19072
|
|
|
19059
|
-
|
|
19060
|
-
|
|
19061
|
-
|
|
19062
|
-
|
|
19063
|
-
|
|
19073
|
+
/**
|
|
19074
|
+
* Convert the deprecated widgets in the rubric and user data to their
|
|
19075
|
+
* modern equivalents for scoring. These need to be updated together
|
|
19076
|
+
* in order to ensure that the widgetKeys match between the rubric and user data.
|
|
19077
|
+
*/
|
|
19078
|
+
const convertDeprecatedWidgetsForScoring = (rubric, userInputMap) => {
|
|
19079
|
+
return convertInputNumberForScoring(rubric, userInputMap);
|
|
19064
19080
|
};
|
|
19065
19081
|
|
|
19066
19082
|
// These are all the current widgets that require user-input and are supported for automatic scoring
|
|
@@ -19662,12 +19678,19 @@ function scorePerseusItem(perseusRenderData, userInputMap,
|
|
|
19662
19678
|
// TODO(LEMS-2461,LEMS-2391): these probably
|
|
19663
19679
|
// need to be removed before we move this to the server
|
|
19664
19680
|
strings, locale) {
|
|
19681
|
+
let convertedRenderData = perseusRenderData;
|
|
19682
|
+
let convertedUserInputMap = userInputMap;
|
|
19683
|
+
|
|
19665
19684
|
// Check if the PerseusRenderer object contains any deprecated widgets that need to be converted
|
|
19666
19685
|
const mustConvertData = conversionRequired(perseusRenderData);
|
|
19667
|
-
|
|
19668
|
-
|
|
19669
|
-
|
|
19670
|
-
|
|
19686
|
+
if (mustConvertData) {
|
|
19687
|
+
const {
|
|
19688
|
+
convertedRubric,
|
|
19689
|
+
convertedUserData
|
|
19690
|
+
} = convertDeprecatedWidgetsForScoring(perseusRenderData, userInputMap);
|
|
19691
|
+
convertedRenderData = convertedRubric;
|
|
19692
|
+
convertedUserInputMap = convertedUserData;
|
|
19693
|
+
}
|
|
19671
19694
|
|
|
19672
19695
|
// There seems to be a chance that PerseusRenderer.widgets might include
|
|
19673
19696
|
// widget data for widgets that are not in PerseusRenderer.content,
|
|
@@ -22798,10 +22821,10 @@ const propsTransform = function (widgetOptions) {
|
|
|
22798
22821
|
const propUpgrades$2 = {
|
|
22799
22822
|
/* c8 ignore next */
|
|
22800
22823
|
"1": initialProps => {
|
|
22801
|
-
// If the initialProps has
|
|
22824
|
+
// If the initialProps has simplify, it means we're upgrading from
|
|
22802
22825
|
// input-number to numeric-input. In this case, we need to upgrade
|
|
22803
22826
|
// the widget options accordingly.
|
|
22804
|
-
if (initialProps.
|
|
22827
|
+
if (initialProps.simplify !== undefined) {
|
|
22805
22828
|
// If the answerType is not number or percent, we need to provide
|
|
22806
22829
|
// the answer form for the numeric-input widget
|
|
22807
22830
|
const provideAnswerForm = initialProps.answerType !== "number" && initialProps.answerType !== "percent";
|
|
@@ -45398,7 +45421,7 @@ const init = function () {
|
|
|
45398
45421
|
|
|
45399
45422
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
45400
45423
|
const libName = "@khanacademy/perseus";
|
|
45401
|
-
const libVersion = "42.0.
|
|
45424
|
+
const libVersion = "42.0.3";
|
|
45402
45425
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
45403
45426
|
|
|
45404
45427
|
const apiVersion = {
|
|
@@ -49600,7 +49623,7 @@ const parseRadioWidget = parseWidget(constant("radio"), object({
|
|
|
49600
49623
|
displayCount: optional(any),
|
|
49601
49624
|
// v0 props
|
|
49602
49625
|
// `noneOfTheAbove` is still in use (but only set to `false`).
|
|
49603
|
-
noneOfTheAbove: constant(false)
|
|
49626
|
+
noneOfTheAbove: optional(constant(false))
|
|
49604
49627
|
}));
|
|
49605
49628
|
|
|
49606
49629
|
const parseSorterWidget = parseWidget(constant("sorter"), object({
|