@pie-element/select-text 8.5.1-next.14 → 8.5.1-next.48
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/defaultConfiguration.js +6 -3
- package/configure/lib/defaultConfiguration.js.map +1 -1
- package/configure/lib/design.js +21 -8
- package/configure/lib/design.js.map +1 -1
- package/configure/package.json +1 -1
- package/controller/lib/index.js +18 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +91 -5
- package/docs/config-schema.json.md +66 -2
- package/docs/pie-schema.json +29 -2
- package/docs/pie-schema.json.md +22 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/print.js +2 -2
- package/lib/print.js.map +1 -1
- package/module/configure.js +47357 -3874
- package/module/controller.js +17 -5
- package/module/element.js +47045 -3588
- package/module/manifest.json +1 -1
- package/module/print.js +47045 -3588
- package/package.json +3 -3
package/module/controller.js
CHANGED
|
@@ -19899,11 +19899,14 @@ var defaults = {
|
|
|
19899
19899
|
tokens: tokens(),
|
|
19900
19900
|
};
|
|
19901
19901
|
|
|
19902
|
-
const isAnswerSelected = (token, selectedToken) =>
|
|
19903
|
-
|
|
19904
|
-
|
|
19905
|
-
|
|
19906
|
-
|
|
19902
|
+
const isAnswerSelected = (token, selectedToken) =>
|
|
19903
|
+
token &&
|
|
19904
|
+
selectedToken &&
|
|
19905
|
+
token.correct === true &&
|
|
19906
|
+
!(
|
|
19907
|
+
(token.start === selectedToken.start && token.end === selectedToken.end) ||
|
|
19908
|
+
(token.start === selectedToken.oldStart && token.end === selectedToken.oldEnd)
|
|
19909
|
+
);
|
|
19907
19910
|
|
|
19908
19911
|
const buildTokens = (tokens, selectedTokens, evaluateMode) => {
|
|
19909
19912
|
tokens = tokens || [];
|
|
@@ -20079,12 +20082,21 @@ const createCorrectResponseSession = (question, env) => {
|
|
|
20079
20082
|
});
|
|
20080
20083
|
};
|
|
20081
20084
|
|
|
20085
|
+
// remove all html tags except img and iframe
|
|
20086
|
+
const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
|
|
20087
|
+
|
|
20082
20088
|
const validate = (model = {}, config = {}) => {
|
|
20083
20089
|
const { tokens } = model;
|
|
20084
20090
|
const { minTokens = 2, maxTokens, maxSelections } = config;
|
|
20085
20091
|
const errors = {};
|
|
20086
20092
|
const nbOfTokens = (tokens || []).length;
|
|
20087
20093
|
|
|
20094
|
+
['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {
|
|
20095
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
20096
|
+
errors[field] = 'This field is required.';
|
|
20097
|
+
}
|
|
20098
|
+
});
|
|
20099
|
+
|
|
20088
20100
|
const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);
|
|
20089
20101
|
|
|
20090
20102
|
if (nbOfTokens < minTokens) {
|