@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/es/index.js
CHANGED
|
@@ -18800,11 +18800,11 @@ const getInputNumberRenameMap = json => {
|
|
|
18800
18800
|
};
|
|
18801
18801
|
|
|
18802
18802
|
// Convert the user input data keys from input-number to numeric-input
|
|
18803
|
-
const convertUserInputNumberData = userInputMap => {
|
|
18803
|
+
const convertUserInputNumberData = (userInputMap, renameMap) => {
|
|
18804
18804
|
const updatedUserInputMap = _extends({}, userInputMap);
|
|
18805
18805
|
for (const key of Object.keys(userInputMap)) {
|
|
18806
18806
|
if (key.includes("input-number")) {
|
|
18807
|
-
const updatedKey = key
|
|
18807
|
+
const updatedKey = renameMap[key];
|
|
18808
18808
|
updatedUserInputMap[updatedKey] = userInputMap[key];
|
|
18809
18809
|
delete updatedUserInputMap[key];
|
|
18810
18810
|
}
|
|
@@ -18812,6 +18812,19 @@ const convertUserInputNumberData = userInputMap => {
|
|
|
18812
18812
|
return updatedUserInputMap;
|
|
18813
18813
|
};
|
|
18814
18814
|
|
|
18815
|
+
// Used to convert InputNumber widgets to NumericInput widgets for scoring
|
|
18816
|
+
const convertInputNumberForScoring = (rubric, userInputMap) => {
|
|
18817
|
+
// First we need to create a map of the old input-number keys to the new numeric-input keys
|
|
18818
|
+
// so that we can ensure we update the content, widgets, AND userInput accordingly
|
|
18819
|
+
const renameMap = getInputNumberRenameMap(rubric);
|
|
18820
|
+
const convertedRubric = convertInputNumberJson(rubric, renameMap);
|
|
18821
|
+
const convertedUserData = convertUserInputNumberData(userInputMap, renameMap);
|
|
18822
|
+
return {
|
|
18823
|
+
convertedRubric,
|
|
18824
|
+
convertedUserData
|
|
18825
|
+
};
|
|
18826
|
+
};
|
|
18827
|
+
|
|
18815
18828
|
const widgetRegExes = [/input-number \d+/]; // We can add more regexes here in the future
|
|
18816
18829
|
|
|
18817
18830
|
// This utils in this file are used to modernize our Perseus JSON structure,
|
|
@@ -18819,6 +18832,7 @@ const widgetRegExes = [/input-number \d+/]; // We can add more regexes here in t
|
|
|
18819
18832
|
// content creators use the Editor Page to update content containing these widgets.
|
|
18820
18833
|
// Currently, we're only converting input-number to numeric-input,
|
|
18821
18834
|
// but we can add more conversions here in the future.
|
|
18835
|
+
|
|
18822
18836
|
// Modernize the json content of a PerseusRenderer object
|
|
18823
18837
|
// by converting deprecated widgets to their modern equivalents
|
|
18824
18838
|
const convertDeprecatedWidgets = json => {
|
|
@@ -18848,11 +18862,13 @@ const conversionRequired = json => {
|
|
|
18848
18862
|
return false;
|
|
18849
18863
|
};
|
|
18850
18864
|
|
|
18851
|
-
|
|
18852
|
-
|
|
18853
|
-
|
|
18854
|
-
|
|
18855
|
-
|
|
18865
|
+
/**
|
|
18866
|
+
* Convert the deprecated widgets in the rubric and user data to their
|
|
18867
|
+
* modern equivalents for scoring. These need to be updated together
|
|
18868
|
+
* in order to ensure that the widgetKeys match between the rubric and user data.
|
|
18869
|
+
*/
|
|
18870
|
+
const convertDeprecatedWidgetsForScoring = (rubric, userInputMap) => {
|
|
18871
|
+
return convertInputNumberForScoring(rubric, userInputMap);
|
|
18856
18872
|
};
|
|
18857
18873
|
|
|
18858
18874
|
// These are all the current widgets that require user-input and are supported for automatic scoring
|
|
@@ -19457,12 +19473,19 @@ function scorePerseusItem(perseusRenderData, userInputMap,
|
|
|
19457
19473
|
// TODO(LEMS-2461,LEMS-2391): these probably
|
|
19458
19474
|
// need to be removed before we move this to the server
|
|
19459
19475
|
strings, locale) {
|
|
19476
|
+
let convertedRenderData = perseusRenderData;
|
|
19477
|
+
let convertedUserInputMap = userInputMap;
|
|
19478
|
+
|
|
19460
19479
|
// Check if the PerseusRenderer object contains any deprecated widgets that need to be converted
|
|
19461
19480
|
const mustConvertData = conversionRequired(perseusRenderData);
|
|
19462
|
-
|
|
19463
|
-
|
|
19464
|
-
|
|
19465
|
-
|
|
19481
|
+
if (mustConvertData) {
|
|
19482
|
+
const {
|
|
19483
|
+
convertedRubric,
|
|
19484
|
+
convertedUserData
|
|
19485
|
+
} = convertDeprecatedWidgetsForScoring(perseusRenderData, userInputMap);
|
|
19486
|
+
convertedRenderData = convertedRubric;
|
|
19487
|
+
convertedUserInputMap = convertedUserData;
|
|
19488
|
+
}
|
|
19466
19489
|
|
|
19467
19490
|
// There seems to be a chance that PerseusRenderer.widgets might include
|
|
19468
19491
|
// widget data for widgets that are not in PerseusRenderer.content,
|
|
@@ -22576,10 +22599,10 @@ const propsTransform = function propsTransform(widgetOptions) {
|
|
|
22576
22599
|
const propUpgrades$2 = {
|
|
22577
22600
|
/* c8 ignore next */
|
|
22578
22601
|
"1": initialProps => {
|
|
22579
|
-
// If the initialProps has
|
|
22602
|
+
// If the initialProps has simplify, it means we're upgrading from
|
|
22580
22603
|
// input-number to numeric-input. In this case, we need to upgrade
|
|
22581
22604
|
// the widget options accordingly.
|
|
22582
|
-
if (initialProps.
|
|
22605
|
+
if (initialProps.simplify !== undefined) {
|
|
22583
22606
|
// If the answerType is not number or percent, we need to provide
|
|
22584
22607
|
// the answer form for the numeric-input widget
|
|
22585
22608
|
const provideAnswerForm = initialProps.answerType !== "number" && initialProps.answerType !== "percent";
|
|
@@ -45030,7 +45053,7 @@ const init = function init() {
|
|
|
45030
45053
|
|
|
45031
45054
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
45032
45055
|
const libName = "@khanacademy/perseus";
|
|
45033
|
-
const libVersion = "42.0.
|
|
45056
|
+
const libVersion = "42.0.3";
|
|
45034
45057
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
45035
45058
|
|
|
45036
45059
|
const apiVersion = {
|
|
@@ -49212,7 +49235,7 @@ const parseRadioWidget = parseWidget(constant("radio"), object({
|
|
|
49212
49235
|
displayCount: optional(any),
|
|
49213
49236
|
// v0 props
|
|
49214
49237
|
// `noneOfTheAbove` is still in use (but only set to `false`).
|
|
49215
|
-
noneOfTheAbove: constant(false)
|
|
49238
|
+
noneOfTheAbove: optional(constant(false))
|
|
49216
49239
|
}));
|
|
49217
49240
|
|
|
49218
49241
|
const parseSorterWidget = parseWidget(constant("sorter"), object({
|