@pie-element/math-inline 5.5.6-next.85 → 5.6.1-beta.587
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 +533 -0
- package/configure/CHANGELOG.md +488 -0
- package/configure/lib/configure.js +73 -31
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/defaults.js +37 -2
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/general-config-block.js +123 -29
- 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 +90 -37
- 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 +164 -0
- package/controller/lib/defaults.js +2 -1
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +148 -131
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +4 -4
- package/docs/config-schema.json +168 -0
- package/docs/config-schema.json.md +132 -1
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +20 -16
- package/docs/demo/session.js +1 -1
- package/docs/pie-schema.json +128 -3
- package/docs/pie-schema.json.md +107 -3
- package/lib/index.js +7 -4
- package/lib/index.js.map +1 -1
- package/lib/main.js +230 -55
- 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/lib/utils.js.map +1 -1
- package/package.json +13 -8
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,170 @@
|
|
|
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.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.6.9...@pie-element/math-inline-controller@5.7.0) (2022-12-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update libs ([441f403](https://github.com/pie-framework/pie-elements/commit/441f403870b7bec0d61fab58b8d93dbe0ead4c32))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **math-inline:** added configurable validation PD-1704 ([9275fb0](https://github.com/pie-framework/pie-elements/commit/9275fb0a13df7872706b17d61945854d9c6b93a2))
|
|
17
|
+
* **math-inline:** implement ui/ux for validation PD-1705 ([74b9682](https://github.com/pie-framework/pie-elements/commit/74b968278cbe07fffd6979889bae91d137d334c3))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [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)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [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)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [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)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## [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)
|
|
48
|
+
|
|
49
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## [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)
|
|
56
|
+
|
|
57
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## [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)
|
|
64
|
+
|
|
65
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# [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)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
|
|
76
|
+
* **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))
|
|
77
|
+
* **math-inline:** Initialized correctResponse in evaluate mode ([27161c1](https://github.com/pie-framework/pie-elements/commit/27161c154c2dcc7bfd2a3cb3d7f8ec158f23beb8))
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### Features
|
|
81
|
+
|
|
82
|
+
* **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))
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
## [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)
|
|
90
|
+
|
|
91
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
## [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)
|
|
98
|
+
|
|
99
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## [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)
|
|
106
|
+
|
|
107
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
## [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)
|
|
114
|
+
|
|
115
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# [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)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Features
|
|
125
|
+
|
|
126
|
+
* **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))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## [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)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
## [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)
|
|
144
|
+
|
|
145
|
+
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# [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)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
### Bug Fixes
|
|
155
|
+
|
|
156
|
+
* **math-inline:** remove allow thousand separators from model, remove checkbox, validate answers indifferent to the presence of commas used as thousands separators PD-1031 ([#554](https://github.com/pie-framework/pie-elements/issues/554)) ([188555b](https://github.com/pie-framework/pie-elements/commit/188555ba3dd7fa6802a1d00eead0f8a86f4615b4))
|
|
157
|
+
* createCorrectResponseSession was throwing an error if model was incorrectly set and this was causing issues in ibx; instead, if the model is not correctly set, just return an empty answer. PD-173 ([863425a](https://github.com/pie-framework/pie-elements/commit/863425ad48816dea1304de7e4fbae8e5f75e7f54))
|
|
158
|
+
* rename the 'Everything' math editor as the 'Miscellaneous' math editor PD-870 ([cebc7da](https://github.com/pie-framework/pie-elements/commit/cebc7dad9cd8b8ad498134e116b705079c1e13c9))
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Features
|
|
162
|
+
|
|
163
|
+
* **math-inline:** remove allowSpaces. BREAKING CHANGE: removed allowSpaces from model PD-285 ([#549](https://github.com/pie-framework/pie-elements/issues/549)) ([9fdd6bd](https://github.com/pie-framework/pie-elements/commit/9fdd6bde196124f138bdd93a1afc1ac7bfaa2508))
|
|
164
|
+
* merge pie-ui into pie-elements PD-977 ([01ebfd7](https://github.com/pie-framework/pie-elements/commit/01ebfd7ce98b041dd0573575efd8b6da03f22162))
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
6
170
|
## [5.3.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/math-inline-controller@5.3.13...@pie-element/math-inline-controller@5.3.16) (2021-03-03)
|
|
7
171
|
|
|
8
172
|
**Note:** Version bump only for package @pie-element/math-inline-controller
|
|
@@ -24,7 +24,8 @@ var _default = {
|
|
|
24
24
|
type: 'none'
|
|
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: '8',
|
|
28
29
|
expression: '',
|
|
29
30
|
question: '',
|
|
30
31
|
responses: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["responseType","ResponseTypes","advanced","element","feedback","correct","type","incorrect","partial","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,
|
|
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,7 +149,18 @@ var outcome = function outcome(question, session, env) {
|
|
|
226
149
|
exports.outcome = outcome;
|
|
227
150
|
|
|
228
151
|
var normalize = function normalize(question) {
|
|
229
|
-
|
|
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
|
+
|
|
163
|
+
return _objectSpread(_objectSpread({}, _defaults["default"]), {}, {
|
|
230
164
|
feedbackEnabled: true,
|
|
231
165
|
promptEnabled: true,
|
|
232
166
|
rationaleEnabled: 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,15 +194,21 @@ 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;
|
|
198
|
+
var showNote = false;
|
|
199
|
+
(config && config.responses || []).forEach(function (response) {
|
|
200
|
+
if (response.validation === 'symbolic' || Object.keys(response.alternates || {}).length > 0) {
|
|
201
|
+
showNote = true;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
264
205
|
|
|
265
206
|
if (env.mode === 'evaluate') {
|
|
266
|
-
out =
|
|
267
|
-
|
|
268
|
-
});
|
|
207
|
+
out.correctResponse = {};
|
|
208
|
+
out.config.showNote = showNote;
|
|
269
209
|
} else {
|
|
270
|
-
out = base;
|
|
271
210
|
out.config.responses = [];
|
|
211
|
+
out.config.showNote = false;
|
|
272
212
|
}
|
|
273
213
|
|
|
274
214
|
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
@@ -281,6 +221,7 @@ function model(question, session, env) {
|
|
|
281
221
|
out.config.teacherInstructions = null;
|
|
282
222
|
}
|
|
283
223
|
|
|
224
|
+
out.config.env = env;
|
|
284
225
|
out.config.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null;
|
|
285
226
|
log('out: ', out);
|
|
286
227
|
resolve(out);
|
|
@@ -295,26 +236,37 @@ var escape = function escape(string) {
|
|
|
295
236
|
|
|
296
237
|
var simpleSessionResponse = function simpleSessionResponse(question) {
|
|
297
238
|
return new Promise(function (resolve) {
|
|
298
|
-
var responses = question.responses
|
|
239
|
+
var responses = question.responses,
|
|
240
|
+
id = question.id;
|
|
299
241
|
|
|
300
|
-
var _ref = responses ? responses[0] : {},
|
|
242
|
+
var _ref = responses && responses.length ? responses[0] : {},
|
|
301
243
|
answer = _ref.answer;
|
|
302
244
|
|
|
303
245
|
resolve({
|
|
304
|
-
id:
|
|
305
|
-
response: answer,
|
|
306
|
-
completeAnswer: answer
|
|
246
|
+
id: id,
|
|
247
|
+
response: answer || '',
|
|
248
|
+
completeAnswer: answer || ''
|
|
307
249
|
});
|
|
308
250
|
});
|
|
309
251
|
};
|
|
310
252
|
|
|
311
253
|
var advancedSessionResponse = function advancedSessionResponse(question) {
|
|
312
254
|
return new Promise(function (resolve, reject) {
|
|
313
|
-
var responses = question.responses
|
|
255
|
+
var responses = question.responses,
|
|
256
|
+
id = question.id;
|
|
314
257
|
|
|
315
|
-
var _ref2 = responses ? responses[0] : {},
|
|
258
|
+
var _ref2 = responses && responses.length ? responses[0] : {},
|
|
316
259
|
answer = _ref2.answer;
|
|
317
260
|
|
|
261
|
+
if (!answer) {
|
|
262
|
+
resolve({
|
|
263
|
+
id: id,
|
|
264
|
+
answers: {},
|
|
265
|
+
completeAnswer: ''
|
|
266
|
+
});
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
318
270
|
try {
|
|
319
271
|
var e = question.expression;
|
|
320
272
|
var RESPONSE_TOKEN = /\\{\\{\s*response\s*\\}\\}/g;
|
|
@@ -330,9 +282,9 @@ var advancedSessionResponse = function advancedSessionResponse(question) {
|
|
|
330
282
|
|
|
331
283
|
if (!m) {
|
|
332
284
|
resolve({
|
|
285
|
+
id: id,
|
|
333
286
|
answers: {},
|
|
334
|
-
completeAnswer: answer
|
|
335
|
-
id: question.id
|
|
287
|
+
completeAnswer: answer
|
|
336
288
|
});
|
|
337
289
|
console.log("can not find match: ".concat(o, " in ").concat(answer));
|
|
338
290
|
return;
|
|
@@ -348,15 +300,15 @@ var advancedSessionResponse = function advancedSessionResponse(question) {
|
|
|
348
300
|
}
|
|
349
301
|
|
|
350
302
|
resolve({
|
|
303
|
+
id: id,
|
|
351
304
|
answers: answers,
|
|
352
|
-
completeAnswer: answer
|
|
353
|
-
id: question.id
|
|
305
|
+
completeAnswer: answer
|
|
354
306
|
});
|
|
355
307
|
} catch (e) {
|
|
356
308
|
resolve({
|
|
309
|
+
id: id,
|
|
357
310
|
answers: {},
|
|
358
|
-
completeAnswer: answer
|
|
359
|
-
id: question.id
|
|
311
|
+
completeAnswer: answer
|
|
360
312
|
});
|
|
361
313
|
console.error(e.toString());
|
|
362
314
|
}
|
|
@@ -378,4 +330,69 @@ var createCorrectResponseSession = function createCorrectResponseSession(questio
|
|
|
378
330
|
};
|
|
379
331
|
|
|
380
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;
|
|
381
398
|
//# sourceMappingURL=index.js.map
|