@pie-element/math-inline 5.9.8 → 5.9.11
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/CHANGELOG.md +24 -0
- package/configure/CHANGELOG.md +24 -0
- package/configure/lib/general-config-block.js +50 -6
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/response.js +19 -5
- package/configure/lib/response.js.map +1 -1
- package/configure/lib/utils.js +18 -1
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +8 -0
- package/controller/lib/index.js +70 -1
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +5 -0
- package/docs/config-schema.json.md +4 -0
- package/module/configure.js +169 -74
- package/module/controller.js +53 -1
- package/module/element.js +3869 -723
- package/module/index.html +1 -1
- package/module/manifest.json +4 -4
- package/module/print.html +1 -1
- package/module/print.js +3865 -729
- package/package.json +5 -5
package/module/controller.js
CHANGED
|
@@ -1369,4 +1369,56 @@ const createCorrectResponseSession = (question, env) => {
|
|
|
1369
1369
|
}
|
|
1370
1370
|
};
|
|
1371
1371
|
|
|
1372
|
-
|
|
1372
|
+
const validate = (model = {}, config = {}) => {
|
|
1373
|
+
const { expression = '', responses, responseType } = model;
|
|
1374
|
+
const { maxResponseAreas } = config;
|
|
1375
|
+
const responsesErrors = {};
|
|
1376
|
+
|
|
1377
|
+
(responses || []).forEach((response, index) => {
|
|
1378
|
+
const { answer } = response;
|
|
1379
|
+
const reversedAlternates = [ ...Object.entries(response.alternates || {}) ].reverse();
|
|
1380
|
+
const alternatesErrors = {};
|
|
1381
|
+
const responseError = {};
|
|
1382
|
+
|
|
1383
|
+
if (answer === '') {
|
|
1384
|
+
responseError.answer = 'Content should not be empty.';
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
reversedAlternates.forEach(([key, value], index) => {
|
|
1388
|
+
if (value === '') {
|
|
1389
|
+
alternatesErrors[key] = 'Content should not be empty.';
|
|
1390
|
+
} else {
|
|
1391
|
+
const identicalAnswer = answer === value ||
|
|
1392
|
+
reversedAlternates.slice(index + 1).some(([ , val]) => val === value);
|
|
1393
|
+
|
|
1394
|
+
if (identicalAnswer) {
|
|
1395
|
+
alternatesErrors[key] = 'Content should be unique.';
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1399
|
+
|
|
1400
|
+
if (!isEmpty_1(responseError) || !isEmpty_1(alternatesErrors)) {
|
|
1401
|
+
responsesErrors[index] = { ...responseError, ...alternatesErrors };
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
const errors = {};
|
|
1406
|
+
|
|
1407
|
+
if (responseType === 'Advanced Multi') {
|
|
1408
|
+
const nbOfResponseAreas = (expression.match(/\{\{response\}\}/g) || []).length;
|
|
1409
|
+
|
|
1410
|
+
if (nbOfResponseAreas > maxResponseAreas) {
|
|
1411
|
+
errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;
|
|
1412
|
+
} else if (nbOfResponseAreas < 1) {
|
|
1413
|
+
errors.responseAreasError = 'There should be at least 1 response area defined.';
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
if (!isEmpty_1(responsesErrors)) {
|
|
1418
|
+
errors.responsesErrors = responsesErrors;
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
return errors;
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
export { createCorrectResponseSession, createDefaultModel, model, normalize, outcome, validate };
|