@pie-element/multiple-choice 8.9.1-next.2 → 8.9.1-next.39
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/configure/lib/defaults.js +6 -3
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/main.js +18 -6
- package/configure/lib/main.js.map +1 -1
- package/configure/package.json +1 -1
- package/controller/lib/index.js +37 -8
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +89 -3
- package/docs/config-schema.json.md +64 -0
- package/docs/pie-schema.json +71 -0
- package/docs/pie-schema.json.md +52 -0
- package/module/configure.js +61 -34
- package/module/controller.js +26 -7
- package/module/element.js +1 -1
- package/module/manifest.json +1 -1
- package/module/print.js +1 -1
- package/package.json +3 -3
package/module/controller.js
CHANGED
|
@@ -20776,21 +20776,33 @@ const createCorrectResponseSession = (question, env) => {
|
|
|
20776
20776
|
});
|
|
20777
20777
|
};
|
|
20778
20778
|
|
|
20779
|
+
// remove all html tags except img and iframe
|
|
20780
|
+
const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
|
|
20781
|
+
|
|
20779
20782
|
const validate = (model = {}, config = {}) => {
|
|
20780
20783
|
const { choices } = model;
|
|
20781
20784
|
const { minAnswerChoices = 2, maxAnswerChoices } = config;
|
|
20782
20785
|
const reversedChoices = [...(choices || [])].reverse();
|
|
20783
20786
|
const choicesErrors = {};
|
|
20787
|
+
const rationaleErrors = {};
|
|
20788
|
+
const errors = {};
|
|
20789
|
+
|
|
20790
|
+
['teacherInstructions', 'prompt'].forEach((field) => {
|
|
20791
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
20792
|
+
errors[field] = 'This field is required.';
|
|
20793
|
+
}
|
|
20794
|
+
});
|
|
20795
|
+
|
|
20784
20796
|
let hasCorrectResponse = false;
|
|
20785
20797
|
|
|
20786
20798
|
reversedChoices.forEach((choice, index) => {
|
|
20787
|
-
const { correct, value, label } = choice;
|
|
20799
|
+
const { correct, value, label, rationale } = choice;
|
|
20788
20800
|
|
|
20789
20801
|
if (correct) {
|
|
20790
20802
|
hasCorrectResponse = true;
|
|
20791
20803
|
}
|
|
20792
20804
|
|
|
20793
|
-
if (label
|
|
20805
|
+
if (!getContent(label)) {
|
|
20794
20806
|
choicesErrors[value] = 'Content should not be empty.';
|
|
20795
20807
|
} else {
|
|
20796
20808
|
const identicalAnswer = reversedChoices.slice(index + 1).some((c) => c.label === label);
|
|
@@ -20799,23 +20811,30 @@ const validate = (model = {}, config = {}) => {
|
|
|
20799
20811
|
choicesErrors[value] = 'Content should be unique.';
|
|
20800
20812
|
}
|
|
20801
20813
|
}
|
|
20814
|
+
|
|
20815
|
+
if (config.rationale?.required && !getContent(rationale)) {
|
|
20816
|
+
rationaleErrors[value] = 'This field is required.';
|
|
20817
|
+
}
|
|
20802
20818
|
});
|
|
20803
20819
|
|
|
20804
|
-
const errors = {};
|
|
20805
20820
|
const nbOfChoices = (choices || []).length;
|
|
20806
20821
|
|
|
20807
20822
|
if (nbOfChoices < minAnswerChoices) {
|
|
20808
|
-
errors.
|
|
20823
|
+
errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
|
|
20809
20824
|
} else if (nbOfChoices > maxAnswerChoices) {
|
|
20810
|
-
errors.
|
|
20825
|
+
errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
|
|
20811
20826
|
}
|
|
20812
20827
|
|
|
20813
20828
|
if (!hasCorrectResponse) {
|
|
20814
|
-
errors.
|
|
20829
|
+
errors.correctResponse = 'No correct response defined.';
|
|
20815
20830
|
}
|
|
20816
20831
|
|
|
20817
20832
|
if (!isEmpty_1(choicesErrors)) {
|
|
20818
|
-
errors.
|
|
20833
|
+
errors.choices = choicesErrors;
|
|
20834
|
+
}
|
|
20835
|
+
|
|
20836
|
+
if (!isEmpty_1(rationaleErrors)) {
|
|
20837
|
+
errors.rationale = rationaleErrors;
|
|
20819
20838
|
}
|
|
20820
20839
|
|
|
20821
20840
|
return errors;
|
package/module/element.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering_accessible} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.1/module/index.js";
|
|
2
2
|
import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@4.0.0/module/index.js";
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
function getDefaultExportFromCjs(x) {
|
package/module/manifest.json
CHANGED
package/module/print.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering_accessible, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.
|
|
1
|
+
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_pie_lib__pie_toolbox_math_rendering_accessible, _dll_debug} from "../../../@pie-lib/pie-toolbox-math-rendering-module@1.5.1/module/index.js";
|
|
2
2
|
import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@4.0.0/module/index.js";
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
function getDefaultExportFromCjs(x) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/multiple-choice",
|
|
3
3
|
"repository": "pie-framework/pie-elements",
|
|
4
|
-
"version": "8.9.1-next.
|
|
4
|
+
"version": "8.9.1-next.39+072ef11f3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@material-ui/core": "^3.9.2",
|
|
10
|
-
"@pie-lib/pie-toolbox": "1.12.
|
|
10
|
+
"@pie-lib/pie-toolbox": "1.12.2",
|
|
11
11
|
"classnames": "^2.2.5",
|
|
12
12
|
"debug": "^4.1.1",
|
|
13
13
|
"enzyme-to-json": "^3.3.3",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"react-test-renderer": "^16.3.2",
|
|
19
19
|
"react-transition-group": "^2.3.1"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "072ef11f320de229433e4373b83fe2828ea7cf06",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"postpublish": "../../scripts/postpublish"
|
|
24
24
|
},
|