@pie-element/math-inline 5.6.4-next.135 → 5.6.4-next.1357
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 +310 -0
- package/configure/CHANGELOG.md +281 -0
- package/configure/lib/configure.js +42 -10
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +34 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +117 -21
- package/configure/lib/general-config-block.js.map +1 -1
- package/configure/lib/index.js +31 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/response.js +89 -36
- 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 +7 -8
- package/controller/CHANGELOG.md +128 -0
- package/controller/lib/defaults.js +1 -1
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +137 -131
- package/controller/lib/index.js.map +1 -1
- package/controller/package.json +2 -2
- package/docs/config-schema.json +163 -0
- package/docs/config-schema.json.md +128 -1
- package/docs/demo/generate.js +3 -2
- package/docs/pie-schema.json +114 -4
- package/docs/pie-schema.json.md +93 -4
- package/lib/index.js +7 -4
- package/lib/index.js.map +1 -1
- package/lib/main.js +203 -66
- package/lib/main.js.map +1 -1
- package/lib/print.js +133 -0
- package/lib/print.js.map +1 -0
- package/lib/simple-question-block.js +50 -38
- package/lib/simple-question-block.js.map +1 -1
- package/package.json +12 -8
package/configure/lib/utils.js
CHANGED
|
@@ -3,10 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ResponseTypes = void 0;
|
|
6
|
+
exports.generateValidationMessage = exports.ResponseTypes = void 0;
|
|
7
7
|
var ResponseTypes = {
|
|
8
8
|
advanced: 'Advanced Multi',
|
|
9
9
|
simple: 'Simple'
|
|
10
10
|
};
|
|
11
11
|
exports.ResponseTypes = ResponseTypes;
|
|
12
|
+
|
|
13
|
+
var generateValidationMessage = function generateValidationMessage() {
|
|
14
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
16
|
+
var maxResponseAreas = config.maxResponseAreas;
|
|
17
|
+
var responseType = model.responseType;
|
|
18
|
+
var responseAreasMessage = '';
|
|
19
|
+
var answersMessage = '\nAll correct answers (the primary and any alternates) should not be empty and should be unique.';
|
|
20
|
+
|
|
21
|
+
if (responseType === 'Advanced Multi') {
|
|
22
|
+
responseAreasMessage = '\nThere should be at least 1 ' + (maxResponseAreas ? "and at most ".concat(maxResponseAreas, " ") : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return 'Validation requirements:' + answersMessage + responseAreasMessage;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.generateValidationMessage = generateValidationMessage;
|
|
12
29
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["ResponseTypes","advanced","simple"],"mappings":";;;;;;AAAO,IAAMA,aAAa,GAAG;AAC3BC,EAAAA,QAAQ,EAAE,gBADiB;AAE3BC,EAAAA,MAAM,EAAE;AAFmB,CAAtB","sourcesContent":["export const ResponseTypes = {\n advanced: 'Advanced Multi',\n simple: 'Simple'\n}
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["ResponseTypes","advanced","simple","generateValidationMessage","model","config","maxResponseAreas","responseType","responseAreasMessage","answersMessage"],"mappings":";;;;;;AAAO,IAAMA,aAAa,GAAG;AAC3BC,EAAAA,QAAQ,EAAE,gBADiB;AAE3BC,EAAAA,MAAM,EAAE;AAFmB,CAAtB;;;AAKA,IAAMC,yBAAyB,GAAG,SAA5BA,yBAA4B,GAA6B;AAAA,MAA5BC,KAA4B,uEAApB,EAAoB;AAAA,MAAhBC,MAAgB,uEAAP,EAAO;AACpE,MAAQC,gBAAR,GAA6BD,MAA7B,CAAQC,gBAAR;AACA,MAAQC,YAAR,GAAyBH,KAAzB,CAAQG,YAAR;AACA,MAAIC,oBAAoB,GAAG,EAA3B;AAEA,MAAMC,cAAc,GAAG,kGAAvB;;AAEA,MAAIF,YAAY,KAAK,gBAArB,EAAuC;AACrCC,IAAAA,oBAAoB,GAAG,mCACpBF,gBAAgB,yBAAkBA,gBAAlB,SAAwC,EADpC,IAErB,eAFqB,IAEFA,gBAAgB,GAAG,GAAH,GAAS,EAFvB,IAE6B,WAFpD;AAGD;;AAED,SAAO,6BAA6BG,cAA7B,GAA8CD,oBAArD;AACD,CAdM","sourcesContent":["export const ResponseTypes = {\n advanced: 'Advanced Multi',\n simple: 'Simple'\n};\n\nexport const generateValidationMessage = (model = {}, config = {}) => {\n const { maxResponseAreas } = config;\n const { responseType } = model;\n let responseAreasMessage = '';\n\n const answersMessage = '\\nAll correct answers (the primary and any alternates) should not be empty and should be unique.';\n\n if (responseType === 'Advanced Multi') {\n responseAreasMessage = '\\nThere should be at least 1 ' +\n (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') +\n 'response area' + (maxResponseAreas ? 's' : '') + ' defined.';\n }\n\n return 'Validation requirements:' + answersMessage + responseAreasMessage;\n};\n"],"file":"utils.js"}
|
package/configure/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/math-inline-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.1.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
11
|
"@material-ui/icons": "^3.0.1",
|
|
12
|
-
"@pie-framework/mathquill": "^1.1.
|
|
13
|
-
"@pie-framework/pie-configure-events": "^1.
|
|
14
|
-
"@pie-lib/config-ui": "^
|
|
15
|
-
"@pie-lib/editable-html": "^
|
|
16
|
-
"@pie-lib/math-
|
|
17
|
-
"@pie-lib/math-
|
|
18
|
-
"@pie-lib/math-toolbar": "^1.7.14",
|
|
12
|
+
"@pie-framework/mathquill": "^1.1.3",
|
|
13
|
+
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
14
|
+
"@pie-lib/config-ui": "^11.0.19",
|
|
15
|
+
"@pie-lib/editable-html": "^9.2.2",
|
|
16
|
+
"@pie-lib/math-input": "^6.8.1",
|
|
17
|
+
"@pie-lib/math-toolbar": "^1.11.1",
|
|
19
18
|
"classnames": "^2.2.5",
|
|
20
19
|
"debug": "^3.1.0",
|
|
21
20
|
"prop-types": "^15.6.2",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,134 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.6.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.6.8...@pie-element/math-inline-controller@5.6.9) (2022-05-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [5.6.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.6.7...@pie-element/math-inline-controller@5.6.8) (2022-03-28)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [5.6.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.6.6...@pie-element/math-inline-controller@5.6.7) (2022-03-22)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [5.6.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.6.5...@pie-element/math-inline-controller@5.6.6) (2022-03-08)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## [5.6.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.6.1...@pie-element/math-inline-controller@5.6.2) (2021-11-29)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [5.6.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.5.4...@pie-element/math-inline-controller@5.6.1) (2021-11-11)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# [5.6.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.4.3...@pie-element/math-inline-controller@5.6.0) (2021-11-11)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
### Bug Fixes
|
|
58
|
+
|
|
59
|
+
* **math-inline:** Evaluate should not highlight answers when no correct response is defined + refactoring PD-994 ([58bfe7c](https://github.com/pie-framework/pie-elements/commit/58bfe7c209da39a31b20d2d905d14b5697aa5375))
|
|
60
|
+
* **math-inline:** Initialized correctResponse in evaluate mode ([27161c1](https://github.com/pie-framework/pie-elements/commit/27161c154c2dcc7bfd2a3cb3d7f8ec158f23beb8))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
|
|
65
|
+
* **math-inline:** Displayed a message when the item has additional correct responses PD-198 - BREAKING CHANGE: Added note property to the model ([7fce264](https://github.com/pie-framework/pie-elements/commit/7fce2649a9c8ddae2eb6643e5d5e9d307233a23b))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
## [5.5.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.5.3...@pie-element/math-inline-controller@5.5.4) (2021-11-01)
|
|
73
|
+
|
|
74
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## [5.5.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.5.2...@pie-element/math-inline-controller@5.5.3) (2021-10-18)
|
|
81
|
+
|
|
82
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
## [5.5.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.5.1...@pie-element/math-inline-controller@5.5.2) (2021-10-04)
|
|
89
|
+
|
|
90
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## [5.5.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.5.0...@pie-element/math-inline-controller@5.5.1) (2021-09-01)
|
|
97
|
+
|
|
98
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# [5.5.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.4.3...@pie-element/math-inline-controller@5.5.0) (2021-08-05)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
### Features
|
|
108
|
+
|
|
109
|
+
* **math-inline:** Displayed a message when the item has additional correct responses PD-198 - BREAKING CHANGE: Added note property to the model ([7fce264](https://github.com/pie-framework/pie-elements/commit/7fce2649a9c8ddae2eb6643e5d5e9d307233a23b))
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
## [5.4.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.4.1...@pie-element/math-inline-controller@5.4.3) (2021-08-05)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### Bug Fixes
|
|
119
|
+
|
|
120
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## [5.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.4.0...@pie-element/math-inline-controller@5.4.1) (2021-06-29)
|
|
127
|
+
|
|
128
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
6
134
|
# [5.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.3.16...@pie-element/math-inline-controller@5.4.0) (2021-04-07)
|
|
7
135
|
|
|
8
136
|
|
|
@@ -25,7 +25,7 @@ var _default = {
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
note: 'The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.',
|
|
28
|
-
equationEditor: '
|
|
28
|
+
equationEditor: '8',
|
|
29
29
|
expression: '',
|
|
30
30
|
question: '',
|
|
31
31
|
responses: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["responseType","ResponseTypes","advanced","element","feedback","correct","type","incorrect","partial","note","equationEditor","expression","question","responses","customKeys"],"mappings":";;;;;;;AAAA;;eAEe;AACbA,EAAAA,YAAY,EAAEC,qBAAcC,QADf;AAEbC,EAAAA,OAAO,EAAE,aAFI;AAGbC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,OAAO,EAAE;AACP,iBAAS,SADF;AAEPC,MAAAA,IAAI,EAAE;AAFC,KADD;AAKRC,IAAAA,SAAS,EAAE;AACT,iBAAS,WADA;AAETD,MAAAA,IAAI,EAAE;AAFG,KALH;AASRE,IAAAA,OAAO,EAAE;AACP,iBAAS,QADF;AAEPF,MAAAA,IAAI,EAAE;AAFC;AATD,GAHG;AAiBbG,EAAAA,IAAI,EAAE,kJAjBO;AAkBbC,EAAAA,cAAc,EAAE,GAlBH;AAmBbC,EAAAA,UAAU,EAAE,EAnBC;AAoBbC,EAAAA,QAAQ,EAAE,EApBG;AAqBbC,EAAAA,SAAS,EAAE,EArBE;AAsBbC,EAAAA,UAAU,EAAE;AAtBC,C","sourcesContent":["import { ResponseTypes } from './utils';\n\nexport default {\n responseType: ResponseTypes.advanced,\n element: 'math-inline',\n feedback: {\n correct: {\n default: 'Correct',\n type: 'none'\n },\n incorrect: {\n default: 'Incorrect',\n type: 'none'\n },\n partial: {\n default: 'Nearly',\n type: 'none'\n }\n },\n note: 'The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.',\n equationEditor: '
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["responseType","ResponseTypes","advanced","element","feedback","correct","type","incorrect","partial","note","equationEditor","expression","question","responses","customKeys"],"mappings":";;;;;;;AAAA;;eAEe;AACbA,EAAAA,YAAY,EAAEC,qBAAcC,QADf;AAEbC,EAAAA,OAAO,EAAE,aAFI;AAGbC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,OAAO,EAAE;AACP,iBAAS,SADF;AAEPC,MAAAA,IAAI,EAAE;AAFC,KADD;AAKRC,IAAAA,SAAS,EAAE;AACT,iBAAS,WADA;AAETD,MAAAA,IAAI,EAAE;AAFG,KALH;AASRE,IAAAA,OAAO,EAAE;AACP,iBAAS,QADF;AAEPF,MAAAA,IAAI,EAAE;AAFC;AATD,GAHG;AAiBbG,EAAAA,IAAI,EAAE,kJAjBO;AAkBbC,EAAAA,cAAc,EAAE,GAlBH;AAmBbC,EAAAA,UAAU,EAAE,EAnBC;AAoBbC,EAAAA,QAAQ,EAAE,EApBG;AAqBbC,EAAAA,SAAS,EAAE,EArBE;AAsBbC,EAAAA,UAAU,EAAE;AAtBC,C","sourcesContent":["import { ResponseTypes } from './utils';\n\nexport default {\n responseType: ResponseTypes.advanced,\n element: 'math-inline',\n feedback: {\n correct: {\n default: 'Correct',\n type: 'none'\n },\n incorrect: {\n default: 'Incorrect',\n type: 'none'\n },\n partial: {\n default: 'Nearly',\n type: 'none'\n }\n },\n note: 'The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.',\n equationEditor: '8',\n expression: '',\n question: '',\n responses: [],\n customKeys: []\n};\n"],"file":"defaults.js"}
|
package/controller/lib/index.js
CHANGED
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
10
|
+
exports.createCorrectResponseSession = void 0;
|
|
8
11
|
exports.createDefaultModel = createDefaultModel;
|
|
9
12
|
exports.model = model;
|
|
10
|
-
exports.
|
|
13
|
+
exports.validate = exports.outcome = exports.normalize = void 0;
|
|
14
|
+
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
|
|
17
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
18
|
|
|
12
19
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
20
|
|
|
@@ -19,59 +26,23 @@ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
|
19
26
|
|
|
20
27
|
var _feedback = require("@pie-lib/feedback");
|
|
21
28
|
|
|
22
|
-
var _mathEvaluator = _interopRequireDefault(require("@pie-lib/math-evaluator"));
|
|
23
|
-
|
|
24
29
|
var _utils = require("./utils");
|
|
25
30
|
|
|
26
31
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
var mv = _interopRequireWildcard(require("@pie-framework/math-validation"));
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
var _excluded = ["responses"];
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
var decimalRegex = /\.|,/g;
|
|
34
|
-
var decimalCommaRegex = /,/g;
|
|
35
|
-
var textRegex = /\\text\{([^{}]+)\}/g;
|
|
36
|
-
var decimalWithThousandSeparatorNumberRegex = /^(?!0+\.00)(?=.{1,9}(\.|$))(?!0(?!\.))\d{1,3}(,\d{3})*(\.\d+)?$/;
|
|
37
|
-
var noNumbers = /[^0-9.,]+/g;
|
|
38
|
-
/**
|
|
39
|
-
* TODO:
|
|
40
|
-
*
|
|
41
|
-
* We have `stringCheck` which if true disabled 'literal' and 'symbolic' so really it should be a validation method. And if it is what's the difference between it and 'literal'?
|
|
42
|
-
*
|
|
43
|
-
* We should support a equivalence option per correct response like:
|
|
44
|
-
* responses: [ { answer: '..', validation: 'symbolic', alternates: [{ value: '..', validation: 'stringCompare'}, 'abc'] } ]
|
|
45
|
-
*
|
|
46
|
-
* if option is a string it is turned into an object w/ inherited opts.
|
|
47
|
-
*
|
|
48
|
-
* This would override any shared setting at the root.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
function processAnswerItem() {
|
|
52
|
-
var answerItem = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
53
|
-
var isLiteral = arguments.length > 1 ? arguments[1] : undefined;
|
|
54
|
-
// looks confusing, but we're replacing U+002D and U+2212 (minus and hyphen) so we have the same symbol everywhere consistently
|
|
55
|
-
// further processing is to be added here if needed
|
|
56
|
-
var newAnswerItem = answerItem.replace('−', '-');
|
|
57
|
-
newAnswerItem = newAnswerItem.replace(/\\cdot/g, '\\times'); // also ignore text nodes, just swap out with empty string
|
|
58
|
-
|
|
59
|
-
newAnswerItem = newAnswerItem.replace(textRegex, '');
|
|
60
|
-
|
|
61
|
-
if (containsDecimal(newAnswerItem) && validExpressionWithThousandSeparator(newAnswerItem)) {
|
|
62
|
-
newAnswerItem = newAnswerItem.replace(decimalCommaRegex, '');
|
|
63
|
-
}
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
64
38
|
|
|
65
|
-
|
|
39
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
66
40
|
|
|
67
|
-
|
|
68
|
-
return isLiteral ? stripForStringCompare(newAnswerItem) : newAnswerItem;
|
|
69
|
-
}
|
|
41
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
70
42
|
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
43
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
44
|
+
|
|
45
|
+
var log = (0, _debug["default"])('@pie-element:math-inline:controller');
|
|
75
46
|
|
|
76
47
|
var getResponseCorrectness = function getResponseCorrectness(model, answerItem, isOutcome) {
|
|
77
48
|
var correctResponses = model.responses;
|
|
@@ -101,84 +72,36 @@ var getResponseCorrectness = function getResponseCorrectness(model, answerItem,
|
|
|
101
72
|
return correctnessObject;
|
|
102
73
|
};
|
|
103
74
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var validExpressionWithThousandSeparator = function validExpressionWithThousandSeparator(answer) {
|
|
107
|
-
var numericValues = answer.split(noNumbers);
|
|
108
|
-
|
|
109
|
-
for (var i = 0; i < numericValues.length; i++) {
|
|
110
|
-
if (numericValues[i] != '' && containsDecimal(numericValues[i]) && !decimalWithThousandSeparatorNumberRegex.test(numericValues[i])) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return true;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
function stripForStringCompare() {
|
|
119
|
-
var answer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
120
|
-
var stripped = answer;
|
|
121
|
-
stripTargets.forEach(function (stripTarget) {
|
|
122
|
-
return stripped = stripped.replace(stripTarget, '');
|
|
123
|
-
});
|
|
124
|
-
return stripped;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function handleStringBasedCheck(acceptedValues, answerItem) {
|
|
128
|
-
var answerValueToUse = processAnswerItem(answerItem, true);
|
|
75
|
+
function getIsAnswerCorrect(correctResponseItem, answerItem) {
|
|
129
76
|
var answerCorrect = false;
|
|
77
|
+
(correctResponseItem || []).forEach(function (correctResponse) {
|
|
78
|
+
var opts = {
|
|
79
|
+
mode: correctResponse.validation || _defaults["default"].validationDefault
|
|
80
|
+
};
|
|
130
81
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
break;
|
|
82
|
+
if (opts.mode == 'literal') {
|
|
83
|
+
opts.literal = {
|
|
84
|
+
allowTrailingZeros: correctResponse.allowTrailingZeros || false,
|
|
85
|
+
ignoreOrder: correctResponse.ignoreOrder || false
|
|
86
|
+
};
|
|
137
87
|
}
|
|
138
|
-
}
|
|
139
88
|
|
|
140
|
-
return answerCorrect;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function getIsAnswerCorrect(correctResponseItem, answerItem) {
|
|
144
|
-
var answerCorrect = false;
|
|
145
|
-
correctResponseItem.forEach(function (correctResponse) {
|
|
146
|
-
// if not already deemed correct for one of the correct responses
|
|
147
89
|
if (!answerCorrect) {
|
|
148
90
|
var acceptedValues = [correctResponse.answer].concat(Object.keys(correctResponse.alternates || {}).map(function (alternateId) {
|
|
149
91
|
return correctResponse.alternates[alternateId];
|
|
150
|
-
}));
|
|
92
|
+
})) || [];
|
|
151
93
|
|
|
152
|
-
|
|
94
|
+
try {
|
|
153
95
|
for (var i = 0; i < acceptedValues.length; i++) {
|
|
154
|
-
|
|
155
|
-
var acceptedValueToUse = processAnswerItem(acceptedValues[i], true);
|
|
96
|
+
answerCorrect = mv.latexEqual(answerItem, acceptedValues[i], opts);
|
|
156
97
|
|
|
157
|
-
if (
|
|
158
|
-
answerCorrect = true;
|
|
98
|
+
if (answerCorrect) {
|
|
159
99
|
break;
|
|
160
100
|
}
|
|
161
101
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// let answerValueToUse = processAnswerItem(answerItem);
|
|
166
|
-
// let acceptedValueToUse = processAnswerItem(acceptedValues[i]);
|
|
167
|
-
answerCorrect = (0, _mathEvaluator["default"])(processAnswerItem(acceptedValues[_i]), processAnswerItem(answerItem), {
|
|
168
|
-
isLatex: true,
|
|
169
|
-
allowThousandsSeparator: correctResponse.allowThousandsSeparator
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (answerCorrect) {
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
} catch (e) {
|
|
177
|
-
log('Parse failure when evaluating math', e, correctResponse, answerItem); // try to string check compare, last resort?
|
|
178
|
-
// once invalid models have been weeded out, this'll get removed.
|
|
179
|
-
|
|
180
|
-
answerCorrect = handleStringBasedCheck(acceptedValues, answerItem);
|
|
181
|
-
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
log('Parse failure when evaluating math', e, correctResponse, answerItem);
|
|
104
|
+
answerCorrect = false;
|
|
182
105
|
}
|
|
183
106
|
}
|
|
184
107
|
});
|
|
@@ -226,6 +149,17 @@ var outcome = function outcome(question, session, env) {
|
|
|
226
149
|
exports.outcome = outcome;
|
|
227
150
|
|
|
228
151
|
var normalize = function normalize(question) {
|
|
152
|
+
// making sure that defaults are set
|
|
153
|
+
if (!(0, _isEmpty["default"])(question.responses)) {
|
|
154
|
+
question.responses = question.responses.map(function (correctResponse) {
|
|
155
|
+
return _objectSpread(_objectSpread({}, correctResponse), {}, {
|
|
156
|
+
validation: correctResponse.validation || question.validationDefault,
|
|
157
|
+
allowTrailingZeros: correctResponse.allowTrailingZeros || question.allowTrailingZerosDefault,
|
|
158
|
+
ignoreOrder: correctResponse.ignoreOrder || question.ignoreOrderDefault
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
229
163
|
return _objectSpread(_objectSpread({}, _defaults["default"]), {}, {
|
|
230
164
|
feedbackEnabled: true,
|
|
231
165
|
promptEnabled: true,
|
|
@@ -241,14 +175,14 @@ function model(question, session, env) {
|
|
|
241
175
|
return new Promise(function (resolve) {
|
|
242
176
|
var normalizedQuestion = normalize(question);
|
|
243
177
|
var correctness = getCorrectness(normalizedQuestion, env, session);
|
|
244
|
-
var correctResponse = {};
|
|
245
178
|
var responses = normalizedQuestion.responses,
|
|
246
|
-
config = (0, _objectWithoutProperties2["default"])(normalizedQuestion,
|
|
179
|
+
config = (0, _objectWithoutProperties2["default"])(normalizedQuestion, _excluded);
|
|
247
180
|
|
|
248
181
|
if (config.responseType === _utils.ResponseTypes.simple) {
|
|
249
182
|
config.responses = responses.slice(0, 1);
|
|
250
183
|
} else {
|
|
251
184
|
config.responses = responses;
|
|
185
|
+
config.customKeys = [];
|
|
252
186
|
}
|
|
253
187
|
|
|
254
188
|
var fb = env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled ? (0, _feedback.getFeedbackForCorrectness)(correctness, normalizedQuestion.feedback) : Promise.resolve(undefined);
|
|
@@ -260,7 +194,7 @@ function model(question, session, env) {
|
|
|
260
194
|
disabled: env.mode !== 'gather',
|
|
261
195
|
view: env.mode === 'view'
|
|
262
196
|
};
|
|
263
|
-
var out;
|
|
197
|
+
var out = base;
|
|
264
198
|
var showNote = false;
|
|
265
199
|
(config && config.responses || []).forEach(function (response) {
|
|
266
200
|
if (response.validation === 'symbolic' || Object.keys(response.alternates || {}).length > 0) {
|
|
@@ -270,12 +204,9 @@ function model(question, session, env) {
|
|
|
270
204
|
});
|
|
271
205
|
|
|
272
206
|
if (env.mode === 'evaluate') {
|
|
273
|
-
out =
|
|
274
|
-
correctResponse: correctResponse
|
|
275
|
-
});
|
|
207
|
+
out.correctResponse = {};
|
|
276
208
|
out.config.showNote = showNote;
|
|
277
209
|
} else {
|
|
278
|
-
out = base;
|
|
279
210
|
out.config.responses = [];
|
|
280
211
|
out.config.showNote = false;
|
|
281
212
|
}
|
|
@@ -283,7 +214,6 @@ function model(question, session, env) {
|
|
|
283
214
|
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
284
215
|
out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
|
|
285
216
|
out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
286
|
-
out.config.showNote = showNote;
|
|
287
217
|
} else {
|
|
288
218
|
out.rationale = null;
|
|
289
219
|
out.teacherInstructions = null;
|
|
@@ -306,26 +236,37 @@ var escape = function escape(string) {
|
|
|
306
236
|
|
|
307
237
|
var simpleSessionResponse = function simpleSessionResponse(question) {
|
|
308
238
|
return new Promise(function (resolve) {
|
|
309
|
-
var responses = question.responses
|
|
239
|
+
var responses = question.responses,
|
|
240
|
+
id = question.id;
|
|
310
241
|
|
|
311
|
-
var _ref = responses ? responses[0] : {},
|
|
242
|
+
var _ref = responses && responses.length ? responses[0] : {},
|
|
312
243
|
answer = _ref.answer;
|
|
313
244
|
|
|
314
245
|
resolve({
|
|
315
|
-
id:
|
|
316
|
-
response: answer,
|
|
317
|
-
completeAnswer: answer
|
|
246
|
+
id: id,
|
|
247
|
+
response: answer || '',
|
|
248
|
+
completeAnswer: answer || ''
|
|
318
249
|
});
|
|
319
250
|
});
|
|
320
251
|
};
|
|
321
252
|
|
|
322
253
|
var advancedSessionResponse = function advancedSessionResponse(question) {
|
|
323
254
|
return new Promise(function (resolve, reject) {
|
|
324
|
-
var responses = question.responses
|
|
255
|
+
var responses = question.responses,
|
|
256
|
+
id = question.id;
|
|
325
257
|
|
|
326
|
-
var _ref2 = responses ? responses[0] : {},
|
|
258
|
+
var _ref2 = responses && responses.length ? responses[0] : {},
|
|
327
259
|
answer = _ref2.answer;
|
|
328
260
|
|
|
261
|
+
if (!answer) {
|
|
262
|
+
resolve({
|
|
263
|
+
id: id,
|
|
264
|
+
answers: {},
|
|
265
|
+
completeAnswer: ''
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
329
270
|
try {
|
|
330
271
|
var e = question.expression;
|
|
331
272
|
var RESPONSE_TOKEN = /\\{\\{\s*response\s*\\}\\}/g;
|
|
@@ -341,9 +282,9 @@ var advancedSessionResponse = function advancedSessionResponse(question) {
|
|
|
341
282
|
|
|
342
283
|
if (!m) {
|
|
343
284
|
resolve({
|
|
285
|
+
id: id,
|
|
344
286
|
answers: {},
|
|
345
|
-
completeAnswer: answer
|
|
346
|
-
id: question.id
|
|
287
|
+
completeAnswer: answer
|
|
347
288
|
});
|
|
348
289
|
console.log("can not find match: ".concat(o, " in ").concat(answer));
|
|
349
290
|
return;
|
|
@@ -359,15 +300,15 @@ var advancedSessionResponse = function advancedSessionResponse(question) {
|
|
|
359
300
|
}
|
|
360
301
|
|
|
361
302
|
resolve({
|
|
303
|
+
id: id,
|
|
362
304
|
answers: answers,
|
|
363
|
-
completeAnswer: answer
|
|
364
|
-
id: question.id
|
|
305
|
+
completeAnswer: answer
|
|
365
306
|
});
|
|
366
307
|
} catch (e) {
|
|
367
308
|
resolve({
|
|
309
|
+
id: id,
|
|
368
310
|
answers: {},
|
|
369
|
-
completeAnswer: answer
|
|
370
|
-
id: question.id
|
|
311
|
+
completeAnswer: answer
|
|
371
312
|
});
|
|
372
313
|
console.error(e.toString());
|
|
373
314
|
}
|
|
@@ -389,4 +330,69 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
389
330
|
};
|
|
390
331
|
|
|
391
332
|
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
333
|
+
|
|
334
|
+
var validate = function validate() {
|
|
335
|
+
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
336
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
337
|
+
var _model$expression = model.expression,
|
|
338
|
+
expression = _model$expression === void 0 ? '' : _model$expression,
|
|
339
|
+
responses = model.responses,
|
|
340
|
+
responseType = model.responseType;
|
|
341
|
+
var maxResponseAreas = config.maxResponseAreas;
|
|
342
|
+
var responsesErrors = {};
|
|
343
|
+
(responses || []).forEach(function (response, index) {
|
|
344
|
+
var answer = response.answer;
|
|
345
|
+
var reversedAlternates = (0, _toConsumableArray2["default"])(Object.entries(response.alternates || {})).reverse();
|
|
346
|
+
var alternatesErrors = {};
|
|
347
|
+
var responseError = {};
|
|
348
|
+
|
|
349
|
+
if (answer === '') {
|
|
350
|
+
responseError.answer = 'Content should not be empty.';
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
reversedAlternates.forEach(function (_ref3, index) {
|
|
354
|
+
var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
|
|
355
|
+
key = _ref4[0],
|
|
356
|
+
value = _ref4[1];
|
|
357
|
+
|
|
358
|
+
if (value === '') {
|
|
359
|
+
alternatesErrors[key] = 'Content should not be empty.';
|
|
360
|
+
} else {
|
|
361
|
+
var identicalAnswer = answer === value || reversedAlternates.slice(index + 1).some(function (_ref5) {
|
|
362
|
+
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
363
|
+
val = _ref6[1];
|
|
364
|
+
|
|
365
|
+
return val === value;
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
if (identicalAnswer) {
|
|
369
|
+
alternatesErrors[key] = 'Content should be unique.';
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
if (!(0, _isEmpty["default"])(responseError) || !(0, _isEmpty["default"])(alternatesErrors)) {
|
|
375
|
+
responsesErrors[index] = _objectSpread(_objectSpread({}, responseError), alternatesErrors);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
var errors = {};
|
|
379
|
+
|
|
380
|
+
if (responseType === 'Advanced Multi') {
|
|
381
|
+
var nbOfResponseAreas = (expression.match(/\{\{response\}\}/g) || []).length;
|
|
382
|
+
|
|
383
|
+
if (nbOfResponseAreas > maxResponseAreas) {
|
|
384
|
+
errors.responseAreasError = "No more than ".concat(maxResponseAreas, " response areas should be defined.");
|
|
385
|
+
} else if (nbOfResponseAreas < 1) {
|
|
386
|
+
errors.responseAreasError = 'There should be at least 1 response area defined.';
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (!(0, _isEmpty["default"])(responsesErrors)) {
|
|
391
|
+
errors.responsesErrors = responsesErrors;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return errors;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
exports.validate = validate;
|
|
392
398
|
//# sourceMappingURL=index.js.map
|