@pie-element/categorize 11.3.4-next.3 → 12.0.0-beta.1
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 +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/__tests__/main.test.js +100 -0
- package/configure/lib/__tests__/utils.js +39 -0
- package/configure/lib/defaults.js +3 -6
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/__tests__/builder.test.js +34 -0
- package/configure/lib/design/__tests__/buttons.test.js +36 -0
- package/configure/lib/design/__tests__/header.test.js +37 -0
- package/configure/lib/design/__tests__/index.test.js +125 -0
- package/configure/lib/design/__tests__/input-header.test.js +41 -0
- package/configure/lib/design/builder.js +16 -34
- package/configure/lib/design/builder.js.map +1 -1
- package/configure/lib/design/buttons.js +42 -96
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/RowLabel.js +34 -47
- package/configure/lib/design/categories/RowLabel.js.map +1 -1
- package/configure/lib/design/categories/__tests__/alternateResponses.test.js +93 -0
- package/configure/lib/design/categories/__tests__/category.test.js +65 -0
- package/configure/lib/design/categories/__tests__/choice-preview.test.js +52 -0
- package/configure/lib/design/categories/__tests__/droppable-placeholder.test.js +63 -0
- package/configure/lib/design/categories/__tests__/index.test.js +91 -0
- package/configure/lib/design/categories/alternateResponses.js +97 -252
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +136 -209
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +62 -127
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +74 -166
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +196 -385
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/__tests__/choice.test.js +62 -0
- package/configure/lib/design/choices/__tests__/config.test.js +66 -0
- package/configure/lib/design/choices/__tests__/index.test.js +70 -0
- package/configure/lib/design/choices/choice.js +156 -265
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +43 -99
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +149 -237
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +58 -112
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +633 -478
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +95 -151
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/design/utils.js +5 -16
- package/configure/lib/design/utils.js.map +1 -1
- package/configure/lib/index.js +121 -184
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +31 -75
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +23 -33
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +15 -15
- package/controller/CHANGELOG.md +0 -11
- package/controller/lib/__tests__/index.test.js +526 -0
- package/controller/lib/defaults.js +3 -6
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +238 -319
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +29 -66
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +5 -5
- package/docs/demo/.pie/.configure/package.json +10 -0
- package/docs/demo/.pie/.configure/yarn.lock +2181 -0
- package/docs/demo/.pie/.controllers/package.json +10 -0
- package/docs/demo/.pie/.controllers/yarn.lock +110 -0
- package/docs/demo/.pie/info.entry.js +89 -0
- package/docs/demo/.pie/info.webpack.config.js +119 -0
- package/docs/demo/.pie/package.json +10 -0
- package/docs/demo/.pie/yarn.lock +2190 -0
- package/docs/demo/pie.manifest.json +11 -0
- package/lib/__tests__/index.test.js +197 -0
- package/lib/categorize/__tests__/categories.test.js +138 -0
- package/lib/categorize/__tests__/category.test.js +137 -0
- package/lib/categorize/__tests__/choice.test.js +88 -0
- package/lib/categorize/__tests__/choices.test.js +118 -0
- package/lib/categorize/__tests__/droppable-placeholder.test.js +96 -0
- package/lib/categorize/__tests__/grid-content.test.js +48 -0
- package/lib/categorize/__tests__/index.test.js +152 -0
- package/lib/categorize/categories.js +107 -165
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +74 -124
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +119 -246
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +67 -132
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +47 -104
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +40 -88
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +342 -318
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +286 -307
- package/lib/index.js.map +1 -1
- package/package.json +16 -14
- package/esm/configure.js +0 -34401
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -1468
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -13134
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
package/esm/controller.js
DELETED
|
@@ -1,1468 +0,0 @@
|
|
|
1
|
-
import { buildState } from '@pie-lib/categorize';
|
|
2
|
-
export { score } from '@pie-lib/categorize';
|
|
3
|
-
import { getFeedbackForCorrectness } from '@pie-lib/feedback';
|
|
4
|
-
import { partialScoring, lockChoices, getShuffledChoices } from '@pie-lib/controller-utils';
|
|
5
|
-
import Translator from '@pie-lib/translator';
|
|
6
|
-
|
|
7
|
-
function _extends() {
|
|
8
|
-
_extends = Object.assign || function (target) {
|
|
9
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
10
|
-
var source = arguments[i];
|
|
11
|
-
|
|
12
|
-
for (var key in source) {
|
|
13
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14
|
-
target[key] = source[key];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return target;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return _extends.apply(this, arguments);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
26
|
-
|
|
27
|
-
/** Used for built-in method references. */
|
|
28
|
-
|
|
29
|
-
var objectProto$6 = Object.prototype;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Checks if `value` is likely a prototype object.
|
|
33
|
-
*
|
|
34
|
-
* @private
|
|
35
|
-
* @param {*} value The value to check.
|
|
36
|
-
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
|
|
37
|
-
*/
|
|
38
|
-
function isPrototype$2(value) {
|
|
39
|
-
var Ctor = value && value.constructor,
|
|
40
|
-
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
|
|
41
|
-
|
|
42
|
-
return value === proto;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var _isPrototype = isPrototype$2;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Creates a unary function that invokes `func` with its argument transformed.
|
|
49
|
-
*
|
|
50
|
-
* @private
|
|
51
|
-
* @param {Function} func The function to wrap.
|
|
52
|
-
* @param {Function} transform The argument transform.
|
|
53
|
-
* @returns {Function} Returns the new function.
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
function overArg$1(func, transform) {
|
|
57
|
-
return function(arg) {
|
|
58
|
-
return func(transform(arg));
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var _overArg = overArg$1;
|
|
63
|
-
|
|
64
|
-
var overArg = _overArg;
|
|
65
|
-
|
|
66
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
67
|
-
var nativeKeys$1 = overArg(Object.keys, Object);
|
|
68
|
-
|
|
69
|
-
var _nativeKeys = nativeKeys$1;
|
|
70
|
-
|
|
71
|
-
var isPrototype$1 = _isPrototype,
|
|
72
|
-
nativeKeys = _nativeKeys;
|
|
73
|
-
|
|
74
|
-
/** Used for built-in method references. */
|
|
75
|
-
var objectProto$5 = Object.prototype;
|
|
76
|
-
|
|
77
|
-
/** Used to check objects for own properties. */
|
|
78
|
-
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
|
|
82
|
-
*
|
|
83
|
-
* @private
|
|
84
|
-
* @param {Object} object The object to query.
|
|
85
|
-
* @returns {Array} Returns the array of property names.
|
|
86
|
-
*/
|
|
87
|
-
function baseKeys$1(object) {
|
|
88
|
-
if (!isPrototype$1(object)) {
|
|
89
|
-
return nativeKeys(object);
|
|
90
|
-
}
|
|
91
|
-
var result = [];
|
|
92
|
-
for (var key in Object(object)) {
|
|
93
|
-
if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
|
|
94
|
-
result.push(key);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var _baseKeys = baseKeys$1;
|
|
101
|
-
|
|
102
|
-
/** Detect free variable `global` from Node.js. */
|
|
103
|
-
|
|
104
|
-
var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
105
|
-
|
|
106
|
-
var _freeGlobal = freeGlobal$1;
|
|
107
|
-
|
|
108
|
-
var freeGlobal = _freeGlobal;
|
|
109
|
-
|
|
110
|
-
/** Detect free variable `self`. */
|
|
111
|
-
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
112
|
-
|
|
113
|
-
/** Used as a reference to the global object. */
|
|
114
|
-
var root$7 = freeGlobal || freeSelf || Function('return this')();
|
|
115
|
-
|
|
116
|
-
var _root = root$7;
|
|
117
|
-
|
|
118
|
-
var root$6 = _root;
|
|
119
|
-
|
|
120
|
-
/** Built-in value references. */
|
|
121
|
-
var Symbol$2 = root$6.Symbol;
|
|
122
|
-
|
|
123
|
-
var _Symbol = Symbol$2;
|
|
124
|
-
|
|
125
|
-
var Symbol$1 = _Symbol;
|
|
126
|
-
|
|
127
|
-
/** Used for built-in method references. */
|
|
128
|
-
var objectProto$4 = Object.prototype;
|
|
129
|
-
|
|
130
|
-
/** Used to check objects for own properties. */
|
|
131
|
-
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Used to resolve the
|
|
135
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
136
|
-
* of values.
|
|
137
|
-
*/
|
|
138
|
-
var nativeObjectToString$1 = objectProto$4.toString;
|
|
139
|
-
|
|
140
|
-
/** Built-in value references. */
|
|
141
|
-
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
145
|
-
*
|
|
146
|
-
* @private
|
|
147
|
-
* @param {*} value The value to query.
|
|
148
|
-
* @returns {string} Returns the raw `toStringTag`.
|
|
149
|
-
*/
|
|
150
|
-
function getRawTag$1(value) {
|
|
151
|
-
var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
|
|
152
|
-
tag = value[symToStringTag$1];
|
|
153
|
-
|
|
154
|
-
try {
|
|
155
|
-
value[symToStringTag$1] = undefined;
|
|
156
|
-
var unmasked = true;
|
|
157
|
-
} catch (e) {}
|
|
158
|
-
|
|
159
|
-
var result = nativeObjectToString$1.call(value);
|
|
160
|
-
if (unmasked) {
|
|
161
|
-
if (isOwn) {
|
|
162
|
-
value[symToStringTag$1] = tag;
|
|
163
|
-
} else {
|
|
164
|
-
delete value[symToStringTag$1];
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
var _getRawTag = getRawTag$1;
|
|
171
|
-
|
|
172
|
-
/** Used for built-in method references. */
|
|
173
|
-
|
|
174
|
-
var objectProto$3 = Object.prototype;
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Used to resolve the
|
|
178
|
-
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
179
|
-
* of values.
|
|
180
|
-
*/
|
|
181
|
-
var nativeObjectToString = objectProto$3.toString;
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Converts `value` to a string using `Object.prototype.toString`.
|
|
185
|
-
*
|
|
186
|
-
* @private
|
|
187
|
-
* @param {*} value The value to convert.
|
|
188
|
-
* @returns {string} Returns the converted string.
|
|
189
|
-
*/
|
|
190
|
-
function objectToString$1(value) {
|
|
191
|
-
return nativeObjectToString.call(value);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
var _objectToString = objectToString$1;
|
|
195
|
-
|
|
196
|
-
var Symbol = _Symbol,
|
|
197
|
-
getRawTag = _getRawTag,
|
|
198
|
-
objectToString = _objectToString;
|
|
199
|
-
|
|
200
|
-
/** `Object#toString` result references. */
|
|
201
|
-
var nullTag = '[object Null]',
|
|
202
|
-
undefinedTag = '[object Undefined]';
|
|
203
|
-
|
|
204
|
-
/** Built-in value references. */
|
|
205
|
-
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
209
|
-
*
|
|
210
|
-
* @private
|
|
211
|
-
* @param {*} value The value to query.
|
|
212
|
-
* @returns {string} Returns the `toStringTag`.
|
|
213
|
-
*/
|
|
214
|
-
function baseGetTag$4(value) {
|
|
215
|
-
if (value == null) {
|
|
216
|
-
return value === undefined ? undefinedTag : nullTag;
|
|
217
|
-
}
|
|
218
|
-
return (symToStringTag && symToStringTag in Object(value))
|
|
219
|
-
? getRawTag(value)
|
|
220
|
-
: objectToString(value);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
var _baseGetTag = baseGetTag$4;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Checks if `value` is the
|
|
227
|
-
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
228
|
-
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
229
|
-
*
|
|
230
|
-
* @static
|
|
231
|
-
* @memberOf _
|
|
232
|
-
* @since 0.1.0
|
|
233
|
-
* @category Lang
|
|
234
|
-
* @param {*} value The value to check.
|
|
235
|
-
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
236
|
-
* @example
|
|
237
|
-
*
|
|
238
|
-
* _.isObject({});
|
|
239
|
-
* // => true
|
|
240
|
-
*
|
|
241
|
-
* _.isObject([1, 2, 3]);
|
|
242
|
-
* // => true
|
|
243
|
-
*
|
|
244
|
-
* _.isObject(_.noop);
|
|
245
|
-
* // => true
|
|
246
|
-
*
|
|
247
|
-
* _.isObject(null);
|
|
248
|
-
* // => false
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
function isObject$2(value) {
|
|
252
|
-
var type = typeof value;
|
|
253
|
-
return value != null && (type == 'object' || type == 'function');
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
var isObject_1 = isObject$2;
|
|
257
|
-
|
|
258
|
-
var baseGetTag$3 = _baseGetTag,
|
|
259
|
-
isObject$1 = isObject_1;
|
|
260
|
-
|
|
261
|
-
/** `Object#toString` result references. */
|
|
262
|
-
var asyncTag = '[object AsyncFunction]',
|
|
263
|
-
funcTag$1 = '[object Function]',
|
|
264
|
-
genTag = '[object GeneratorFunction]',
|
|
265
|
-
proxyTag = '[object Proxy]';
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Checks if `value` is classified as a `Function` object.
|
|
269
|
-
*
|
|
270
|
-
* @static
|
|
271
|
-
* @memberOf _
|
|
272
|
-
* @since 0.1.0
|
|
273
|
-
* @category Lang
|
|
274
|
-
* @param {*} value The value to check.
|
|
275
|
-
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
276
|
-
* @example
|
|
277
|
-
*
|
|
278
|
-
* _.isFunction(_);
|
|
279
|
-
* // => true
|
|
280
|
-
*
|
|
281
|
-
* _.isFunction(/abc/);
|
|
282
|
-
* // => false
|
|
283
|
-
*/
|
|
284
|
-
function isFunction$2(value) {
|
|
285
|
-
if (!isObject$1(value)) {
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
289
|
-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
290
|
-
var tag = baseGetTag$3(value);
|
|
291
|
-
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
var isFunction_1 = isFunction$2;
|
|
295
|
-
|
|
296
|
-
var root$5 = _root;
|
|
297
|
-
|
|
298
|
-
/** Used to detect overreaching core-js shims. */
|
|
299
|
-
var coreJsData$1 = root$5['__core-js_shared__'];
|
|
300
|
-
|
|
301
|
-
var _coreJsData = coreJsData$1;
|
|
302
|
-
|
|
303
|
-
var coreJsData = _coreJsData;
|
|
304
|
-
|
|
305
|
-
/** Used to detect methods masquerading as native. */
|
|
306
|
-
var maskSrcKey = (function() {
|
|
307
|
-
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
308
|
-
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
309
|
-
}());
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Checks if `func` has its source masked.
|
|
313
|
-
*
|
|
314
|
-
* @private
|
|
315
|
-
* @param {Function} func The function to check.
|
|
316
|
-
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
317
|
-
*/
|
|
318
|
-
function isMasked$1(func) {
|
|
319
|
-
return !!maskSrcKey && (maskSrcKey in func);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
var _isMasked = isMasked$1;
|
|
323
|
-
|
|
324
|
-
/** Used for built-in method references. */
|
|
325
|
-
|
|
326
|
-
var funcProto$1 = Function.prototype;
|
|
327
|
-
|
|
328
|
-
/** Used to resolve the decompiled source of functions. */
|
|
329
|
-
var funcToString$1 = funcProto$1.toString;
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Converts `func` to its source code.
|
|
333
|
-
*
|
|
334
|
-
* @private
|
|
335
|
-
* @param {Function} func The function to convert.
|
|
336
|
-
* @returns {string} Returns the source code.
|
|
337
|
-
*/
|
|
338
|
-
function toSource$2(func) {
|
|
339
|
-
if (func != null) {
|
|
340
|
-
try {
|
|
341
|
-
return funcToString$1.call(func);
|
|
342
|
-
} catch (e) {}
|
|
343
|
-
try {
|
|
344
|
-
return (func + '');
|
|
345
|
-
} catch (e) {}
|
|
346
|
-
}
|
|
347
|
-
return '';
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
var _toSource = toSource$2;
|
|
351
|
-
|
|
352
|
-
var isFunction$1 = isFunction_1,
|
|
353
|
-
isMasked = _isMasked,
|
|
354
|
-
isObject = isObject_1,
|
|
355
|
-
toSource$1 = _toSource;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Used to match `RegExp`
|
|
359
|
-
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
360
|
-
*/
|
|
361
|
-
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
362
|
-
|
|
363
|
-
/** Used to detect host constructors (Safari). */
|
|
364
|
-
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
365
|
-
|
|
366
|
-
/** Used for built-in method references. */
|
|
367
|
-
var funcProto = Function.prototype,
|
|
368
|
-
objectProto$2 = Object.prototype;
|
|
369
|
-
|
|
370
|
-
/** Used to resolve the decompiled source of functions. */
|
|
371
|
-
var funcToString = funcProto.toString;
|
|
372
|
-
|
|
373
|
-
/** Used to check objects for own properties. */
|
|
374
|
-
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
|
375
|
-
|
|
376
|
-
/** Used to detect if a method is native. */
|
|
377
|
-
var reIsNative = RegExp('^' +
|
|
378
|
-
funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
|
|
379
|
-
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* The base implementation of `_.isNative` without bad shim checks.
|
|
384
|
-
*
|
|
385
|
-
* @private
|
|
386
|
-
* @param {*} value The value to check.
|
|
387
|
-
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
388
|
-
* else `false`.
|
|
389
|
-
*/
|
|
390
|
-
function baseIsNative$1(value) {
|
|
391
|
-
if (!isObject(value) || isMasked(value)) {
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
395
|
-
return pattern.test(toSource$1(value));
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
var _baseIsNative = baseIsNative$1;
|
|
399
|
-
|
|
400
|
-
/**
|
|
401
|
-
* Gets the value at `key` of `object`.
|
|
402
|
-
*
|
|
403
|
-
* @private
|
|
404
|
-
* @param {Object} [object] The object to query.
|
|
405
|
-
* @param {string} key The key of the property to get.
|
|
406
|
-
* @returns {*} Returns the property value.
|
|
407
|
-
*/
|
|
408
|
-
|
|
409
|
-
function getValue$1(object, key) {
|
|
410
|
-
return object == null ? undefined : object[key];
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
var _getValue = getValue$1;
|
|
414
|
-
|
|
415
|
-
var baseIsNative = _baseIsNative,
|
|
416
|
-
getValue = _getValue;
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Gets the native function at `key` of `object`.
|
|
420
|
-
*
|
|
421
|
-
* @private
|
|
422
|
-
* @param {Object} object The object to query.
|
|
423
|
-
* @param {string} key The key of the method to get.
|
|
424
|
-
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
425
|
-
*/
|
|
426
|
-
function getNative$5(object, key) {
|
|
427
|
-
var value = getValue(object, key);
|
|
428
|
-
return baseIsNative(value) ? value : undefined;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
var _getNative = getNative$5;
|
|
432
|
-
|
|
433
|
-
var getNative$4 = _getNative,
|
|
434
|
-
root$4 = _root;
|
|
435
|
-
|
|
436
|
-
/* Built-in method references that are verified to be native. */
|
|
437
|
-
var DataView$1 = getNative$4(root$4, 'DataView');
|
|
438
|
-
|
|
439
|
-
var _DataView = DataView$1;
|
|
440
|
-
|
|
441
|
-
var getNative$3 = _getNative,
|
|
442
|
-
root$3 = _root;
|
|
443
|
-
|
|
444
|
-
/* Built-in method references that are verified to be native. */
|
|
445
|
-
var Map$1 = getNative$3(root$3, 'Map');
|
|
446
|
-
|
|
447
|
-
var _Map = Map$1;
|
|
448
|
-
|
|
449
|
-
var getNative$2 = _getNative,
|
|
450
|
-
root$2 = _root;
|
|
451
|
-
|
|
452
|
-
/* Built-in method references that are verified to be native. */
|
|
453
|
-
var Promise$2 = getNative$2(root$2, 'Promise');
|
|
454
|
-
|
|
455
|
-
var _Promise = Promise$2;
|
|
456
|
-
|
|
457
|
-
var getNative$1 = _getNative,
|
|
458
|
-
root$1 = _root;
|
|
459
|
-
|
|
460
|
-
/* Built-in method references that are verified to be native. */
|
|
461
|
-
var Set$2 = getNative$1(root$1, 'Set');
|
|
462
|
-
|
|
463
|
-
var _Set = Set$2;
|
|
464
|
-
|
|
465
|
-
var getNative = _getNative,
|
|
466
|
-
root = _root;
|
|
467
|
-
|
|
468
|
-
/* Built-in method references that are verified to be native. */
|
|
469
|
-
var WeakMap$1 = getNative(root, 'WeakMap');
|
|
470
|
-
|
|
471
|
-
var _WeakMap = WeakMap$1;
|
|
472
|
-
|
|
473
|
-
var DataView = _DataView,
|
|
474
|
-
Map = _Map,
|
|
475
|
-
Promise$1 = _Promise,
|
|
476
|
-
Set$1 = _Set,
|
|
477
|
-
WeakMap = _WeakMap,
|
|
478
|
-
baseGetTag$2 = _baseGetTag,
|
|
479
|
-
toSource = _toSource;
|
|
480
|
-
|
|
481
|
-
/** `Object#toString` result references. */
|
|
482
|
-
var mapTag$2 = '[object Map]',
|
|
483
|
-
objectTag$1 = '[object Object]',
|
|
484
|
-
promiseTag = '[object Promise]',
|
|
485
|
-
setTag$2 = '[object Set]',
|
|
486
|
-
weakMapTag$1 = '[object WeakMap]';
|
|
487
|
-
|
|
488
|
-
var dataViewTag$1 = '[object DataView]';
|
|
489
|
-
|
|
490
|
-
/** Used to detect maps, sets, and weakmaps. */
|
|
491
|
-
var dataViewCtorString = toSource(DataView),
|
|
492
|
-
mapCtorString = toSource(Map),
|
|
493
|
-
promiseCtorString = toSource(Promise$1),
|
|
494
|
-
setCtorString = toSource(Set$1),
|
|
495
|
-
weakMapCtorString = toSource(WeakMap);
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Gets the `toStringTag` of `value`.
|
|
499
|
-
*
|
|
500
|
-
* @private
|
|
501
|
-
* @param {*} value The value to query.
|
|
502
|
-
* @returns {string} Returns the `toStringTag`.
|
|
503
|
-
*/
|
|
504
|
-
var getTag$1 = baseGetTag$2;
|
|
505
|
-
|
|
506
|
-
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
|
|
507
|
-
if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
|
|
508
|
-
(Map && getTag$1(new Map) != mapTag$2) ||
|
|
509
|
-
(Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
|
|
510
|
-
(Set$1 && getTag$1(new Set$1) != setTag$2) ||
|
|
511
|
-
(WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
|
|
512
|
-
getTag$1 = function(value) {
|
|
513
|
-
var result = baseGetTag$2(value),
|
|
514
|
-
Ctor = result == objectTag$1 ? value.constructor : undefined,
|
|
515
|
-
ctorString = Ctor ? toSource(Ctor) : '';
|
|
516
|
-
|
|
517
|
-
if (ctorString) {
|
|
518
|
-
switch (ctorString) {
|
|
519
|
-
case dataViewCtorString: return dataViewTag$1;
|
|
520
|
-
case mapCtorString: return mapTag$2;
|
|
521
|
-
case promiseCtorString: return promiseTag;
|
|
522
|
-
case setCtorString: return setTag$2;
|
|
523
|
-
case weakMapCtorString: return weakMapTag$1;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return result;
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
var _getTag = getTag$1;
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
534
|
-
* and has a `typeof` result of "object".
|
|
535
|
-
*
|
|
536
|
-
* @static
|
|
537
|
-
* @memberOf _
|
|
538
|
-
* @since 4.0.0
|
|
539
|
-
* @category Lang
|
|
540
|
-
* @param {*} value The value to check.
|
|
541
|
-
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
542
|
-
* @example
|
|
543
|
-
*
|
|
544
|
-
* _.isObjectLike({});
|
|
545
|
-
* // => true
|
|
546
|
-
*
|
|
547
|
-
* _.isObjectLike([1, 2, 3]);
|
|
548
|
-
* // => true
|
|
549
|
-
*
|
|
550
|
-
* _.isObjectLike(_.noop);
|
|
551
|
-
* // => false
|
|
552
|
-
*
|
|
553
|
-
* _.isObjectLike(null);
|
|
554
|
-
* // => false
|
|
555
|
-
*/
|
|
556
|
-
|
|
557
|
-
function isObjectLike$3(value) {
|
|
558
|
-
return value != null && typeof value == 'object';
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
var isObjectLike_1 = isObjectLike$3;
|
|
562
|
-
|
|
563
|
-
var baseGetTag$1 = _baseGetTag,
|
|
564
|
-
isObjectLike$2 = isObjectLike_1;
|
|
565
|
-
|
|
566
|
-
/** `Object#toString` result references. */
|
|
567
|
-
var argsTag$1 = '[object Arguments]';
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* The base implementation of `_.isArguments`.
|
|
571
|
-
*
|
|
572
|
-
* @private
|
|
573
|
-
* @param {*} value The value to check.
|
|
574
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
575
|
-
*/
|
|
576
|
-
function baseIsArguments$1(value) {
|
|
577
|
-
return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
var _baseIsArguments = baseIsArguments$1;
|
|
581
|
-
|
|
582
|
-
var baseIsArguments = _baseIsArguments,
|
|
583
|
-
isObjectLike$1 = isObjectLike_1;
|
|
584
|
-
|
|
585
|
-
/** Used for built-in method references. */
|
|
586
|
-
var objectProto$1 = Object.prototype;
|
|
587
|
-
|
|
588
|
-
/** Used to check objects for own properties. */
|
|
589
|
-
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
590
|
-
|
|
591
|
-
/** Built-in value references. */
|
|
592
|
-
var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* Checks if `value` is likely an `arguments` object.
|
|
596
|
-
*
|
|
597
|
-
* @static
|
|
598
|
-
* @memberOf _
|
|
599
|
-
* @since 0.1.0
|
|
600
|
-
* @category Lang
|
|
601
|
-
* @param {*} value The value to check.
|
|
602
|
-
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
|
|
603
|
-
* else `false`.
|
|
604
|
-
* @example
|
|
605
|
-
*
|
|
606
|
-
* _.isArguments(function() { return arguments; }());
|
|
607
|
-
* // => true
|
|
608
|
-
*
|
|
609
|
-
* _.isArguments([1, 2, 3]);
|
|
610
|
-
* // => false
|
|
611
|
-
*/
|
|
612
|
-
var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
|
|
613
|
-
return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') &&
|
|
614
|
-
!propertyIsEnumerable.call(value, 'callee');
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
var isArguments_1 = isArguments$1;
|
|
618
|
-
|
|
619
|
-
/**
|
|
620
|
-
* Checks if `value` is classified as an `Array` object.
|
|
621
|
-
*
|
|
622
|
-
* @static
|
|
623
|
-
* @memberOf _
|
|
624
|
-
* @since 0.1.0
|
|
625
|
-
* @category Lang
|
|
626
|
-
* @param {*} value The value to check.
|
|
627
|
-
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
|
|
628
|
-
* @example
|
|
629
|
-
*
|
|
630
|
-
* _.isArray([1, 2, 3]);
|
|
631
|
-
* // => true
|
|
632
|
-
*
|
|
633
|
-
* _.isArray(document.body.children);
|
|
634
|
-
* // => false
|
|
635
|
-
*
|
|
636
|
-
* _.isArray('abc');
|
|
637
|
-
* // => false
|
|
638
|
-
*
|
|
639
|
-
* _.isArray(_.noop);
|
|
640
|
-
* // => false
|
|
641
|
-
*/
|
|
642
|
-
|
|
643
|
-
var isArray$1 = Array.isArray;
|
|
644
|
-
|
|
645
|
-
var isArray_1 = isArray$1;
|
|
646
|
-
|
|
647
|
-
/** Used as references for various `Number` constants. */
|
|
648
|
-
|
|
649
|
-
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Checks if `value` is a valid array-like length.
|
|
653
|
-
*
|
|
654
|
-
* **Note:** This method is loosely based on
|
|
655
|
-
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
656
|
-
*
|
|
657
|
-
* @static
|
|
658
|
-
* @memberOf _
|
|
659
|
-
* @since 4.0.0
|
|
660
|
-
* @category Lang
|
|
661
|
-
* @param {*} value The value to check.
|
|
662
|
-
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
663
|
-
* @example
|
|
664
|
-
*
|
|
665
|
-
* _.isLength(3);
|
|
666
|
-
* // => true
|
|
667
|
-
*
|
|
668
|
-
* _.isLength(Number.MIN_VALUE);
|
|
669
|
-
* // => false
|
|
670
|
-
*
|
|
671
|
-
* _.isLength(Infinity);
|
|
672
|
-
* // => false
|
|
673
|
-
*
|
|
674
|
-
* _.isLength('3');
|
|
675
|
-
* // => false
|
|
676
|
-
*/
|
|
677
|
-
function isLength$2(value) {
|
|
678
|
-
return typeof value == 'number' &&
|
|
679
|
-
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
var isLength_1 = isLength$2;
|
|
683
|
-
|
|
684
|
-
var isFunction = isFunction_1,
|
|
685
|
-
isLength$1 = isLength_1;
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
689
|
-
* not a function and has a `value.length` that's an integer greater than or
|
|
690
|
-
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
691
|
-
*
|
|
692
|
-
* @static
|
|
693
|
-
* @memberOf _
|
|
694
|
-
* @since 4.0.0
|
|
695
|
-
* @category Lang
|
|
696
|
-
* @param {*} value The value to check.
|
|
697
|
-
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
698
|
-
* @example
|
|
699
|
-
*
|
|
700
|
-
* _.isArrayLike([1, 2, 3]);
|
|
701
|
-
* // => true
|
|
702
|
-
*
|
|
703
|
-
* _.isArrayLike(document.body.children);
|
|
704
|
-
* // => true
|
|
705
|
-
*
|
|
706
|
-
* _.isArrayLike('abc');
|
|
707
|
-
* // => true
|
|
708
|
-
*
|
|
709
|
-
* _.isArrayLike(_.noop);
|
|
710
|
-
* // => false
|
|
711
|
-
*/
|
|
712
|
-
function isArrayLike$1(value) {
|
|
713
|
-
return value != null && isLength$1(value.length) && !isFunction(value);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
var isArrayLike_1 = isArrayLike$1;
|
|
717
|
-
|
|
718
|
-
var isBuffer$1 = {exports: {}};
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* This method returns `false`.
|
|
722
|
-
*
|
|
723
|
-
* @static
|
|
724
|
-
* @memberOf _
|
|
725
|
-
* @since 4.13.0
|
|
726
|
-
* @category Util
|
|
727
|
-
* @returns {boolean} Returns `false`.
|
|
728
|
-
* @example
|
|
729
|
-
*
|
|
730
|
-
* _.times(2, _.stubFalse);
|
|
731
|
-
* // => [false, false]
|
|
732
|
-
*/
|
|
733
|
-
|
|
734
|
-
function stubFalse() {
|
|
735
|
-
return false;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
var stubFalse_1 = stubFalse;
|
|
739
|
-
|
|
740
|
-
(function (module, exports) {
|
|
741
|
-
var root = _root,
|
|
742
|
-
stubFalse = stubFalse_1;
|
|
743
|
-
|
|
744
|
-
/** Detect free variable `exports`. */
|
|
745
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
746
|
-
|
|
747
|
-
/** Detect free variable `module`. */
|
|
748
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
749
|
-
|
|
750
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
751
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
752
|
-
|
|
753
|
-
/** Built-in value references. */
|
|
754
|
-
var Buffer = moduleExports ? root.Buffer : undefined;
|
|
755
|
-
|
|
756
|
-
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
757
|
-
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* Checks if `value` is a buffer.
|
|
761
|
-
*
|
|
762
|
-
* @static
|
|
763
|
-
* @memberOf _
|
|
764
|
-
* @since 4.3.0
|
|
765
|
-
* @category Lang
|
|
766
|
-
* @param {*} value The value to check.
|
|
767
|
-
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
|
|
768
|
-
* @example
|
|
769
|
-
*
|
|
770
|
-
* _.isBuffer(new Buffer(2));
|
|
771
|
-
* // => true
|
|
772
|
-
*
|
|
773
|
-
* _.isBuffer(new Uint8Array(2));
|
|
774
|
-
* // => false
|
|
775
|
-
*/
|
|
776
|
-
var isBuffer = nativeIsBuffer || stubFalse;
|
|
777
|
-
|
|
778
|
-
module.exports = isBuffer;
|
|
779
|
-
}(isBuffer$1, isBuffer$1.exports));
|
|
780
|
-
|
|
781
|
-
var baseGetTag = _baseGetTag,
|
|
782
|
-
isLength = isLength_1,
|
|
783
|
-
isObjectLike = isObjectLike_1;
|
|
784
|
-
|
|
785
|
-
/** `Object#toString` result references. */
|
|
786
|
-
var argsTag = '[object Arguments]',
|
|
787
|
-
arrayTag = '[object Array]',
|
|
788
|
-
boolTag = '[object Boolean]',
|
|
789
|
-
dateTag = '[object Date]',
|
|
790
|
-
errorTag = '[object Error]',
|
|
791
|
-
funcTag = '[object Function]',
|
|
792
|
-
mapTag$1 = '[object Map]',
|
|
793
|
-
numberTag = '[object Number]',
|
|
794
|
-
objectTag = '[object Object]',
|
|
795
|
-
regexpTag = '[object RegExp]',
|
|
796
|
-
setTag$1 = '[object Set]',
|
|
797
|
-
stringTag = '[object String]',
|
|
798
|
-
weakMapTag = '[object WeakMap]';
|
|
799
|
-
|
|
800
|
-
var arrayBufferTag = '[object ArrayBuffer]',
|
|
801
|
-
dataViewTag = '[object DataView]',
|
|
802
|
-
float32Tag = '[object Float32Array]',
|
|
803
|
-
float64Tag = '[object Float64Array]',
|
|
804
|
-
int8Tag = '[object Int8Array]',
|
|
805
|
-
int16Tag = '[object Int16Array]',
|
|
806
|
-
int32Tag = '[object Int32Array]',
|
|
807
|
-
uint8Tag = '[object Uint8Array]',
|
|
808
|
-
uint8ClampedTag = '[object Uint8ClampedArray]',
|
|
809
|
-
uint16Tag = '[object Uint16Array]',
|
|
810
|
-
uint32Tag = '[object Uint32Array]';
|
|
811
|
-
|
|
812
|
-
/** Used to identify `toStringTag` values of typed arrays. */
|
|
813
|
-
var typedArrayTags = {};
|
|
814
|
-
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
|
815
|
-
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
|
816
|
-
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
|
817
|
-
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
|
818
|
-
typedArrayTags[uint32Tag] = true;
|
|
819
|
-
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
|
|
820
|
-
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
|
821
|
-
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
|
822
|
-
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
|
|
823
|
-
typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
|
|
824
|
-
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
|
|
825
|
-
typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
|
|
826
|
-
typedArrayTags[weakMapTag] = false;
|
|
827
|
-
|
|
828
|
-
/**
|
|
829
|
-
* The base implementation of `_.isTypedArray` without Node.js optimizations.
|
|
830
|
-
*
|
|
831
|
-
* @private
|
|
832
|
-
* @param {*} value The value to check.
|
|
833
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
834
|
-
*/
|
|
835
|
-
function baseIsTypedArray$1(value) {
|
|
836
|
-
return isObjectLike(value) &&
|
|
837
|
-
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
var _baseIsTypedArray = baseIsTypedArray$1;
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* The base implementation of `_.unary` without support for storing metadata.
|
|
844
|
-
*
|
|
845
|
-
* @private
|
|
846
|
-
* @param {Function} func The function to cap arguments for.
|
|
847
|
-
* @returns {Function} Returns the new capped function.
|
|
848
|
-
*/
|
|
849
|
-
|
|
850
|
-
function baseUnary$1(func) {
|
|
851
|
-
return function(value) {
|
|
852
|
-
return func(value);
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
var _baseUnary = baseUnary$1;
|
|
857
|
-
|
|
858
|
-
var _nodeUtil = {exports: {}};
|
|
859
|
-
|
|
860
|
-
(function (module, exports) {
|
|
861
|
-
var freeGlobal = _freeGlobal;
|
|
862
|
-
|
|
863
|
-
/** Detect free variable `exports`. */
|
|
864
|
-
var freeExports = exports && !exports.nodeType && exports;
|
|
865
|
-
|
|
866
|
-
/** Detect free variable `module`. */
|
|
867
|
-
var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
|
868
|
-
|
|
869
|
-
/** Detect the popular CommonJS extension `module.exports`. */
|
|
870
|
-
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
871
|
-
|
|
872
|
-
/** Detect free variable `process` from Node.js. */
|
|
873
|
-
var freeProcess = moduleExports && freeGlobal.process;
|
|
874
|
-
|
|
875
|
-
/** Used to access faster Node.js helpers. */
|
|
876
|
-
var nodeUtil = (function() {
|
|
877
|
-
try {
|
|
878
|
-
// Use `util.types` for Node.js 10+.
|
|
879
|
-
var types = freeModule && freeModule.require && freeModule.require('util').types;
|
|
880
|
-
|
|
881
|
-
if (types) {
|
|
882
|
-
return types;
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
// Legacy `process.binding('util')` for Node.js < 10.
|
|
886
|
-
return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
|
887
|
-
} catch (e) {}
|
|
888
|
-
}());
|
|
889
|
-
|
|
890
|
-
module.exports = nodeUtil;
|
|
891
|
-
}(_nodeUtil, _nodeUtil.exports));
|
|
892
|
-
|
|
893
|
-
var baseIsTypedArray = _baseIsTypedArray,
|
|
894
|
-
baseUnary = _baseUnary,
|
|
895
|
-
nodeUtil = _nodeUtil.exports;
|
|
896
|
-
|
|
897
|
-
/* Node.js helper references. */
|
|
898
|
-
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Checks if `value` is classified as a typed array.
|
|
902
|
-
*
|
|
903
|
-
* @static
|
|
904
|
-
* @memberOf _
|
|
905
|
-
* @since 3.0.0
|
|
906
|
-
* @category Lang
|
|
907
|
-
* @param {*} value The value to check.
|
|
908
|
-
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
|
|
909
|
-
* @example
|
|
910
|
-
*
|
|
911
|
-
* _.isTypedArray(new Uint8Array);
|
|
912
|
-
* // => true
|
|
913
|
-
*
|
|
914
|
-
* _.isTypedArray([]);
|
|
915
|
-
* // => false
|
|
916
|
-
*/
|
|
917
|
-
var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
918
|
-
|
|
919
|
-
var isTypedArray_1 = isTypedArray$1;
|
|
920
|
-
|
|
921
|
-
var baseKeys = _baseKeys,
|
|
922
|
-
getTag = _getTag,
|
|
923
|
-
isArguments = isArguments_1,
|
|
924
|
-
isArray = isArray_1,
|
|
925
|
-
isArrayLike = isArrayLike_1,
|
|
926
|
-
isBuffer = isBuffer$1.exports,
|
|
927
|
-
isPrototype = _isPrototype,
|
|
928
|
-
isTypedArray = isTypedArray_1;
|
|
929
|
-
|
|
930
|
-
/** `Object#toString` result references. */
|
|
931
|
-
var mapTag = '[object Map]',
|
|
932
|
-
setTag = '[object Set]';
|
|
933
|
-
|
|
934
|
-
/** Used for built-in method references. */
|
|
935
|
-
var objectProto = Object.prototype;
|
|
936
|
-
|
|
937
|
-
/** Used to check objects for own properties. */
|
|
938
|
-
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
939
|
-
|
|
940
|
-
/**
|
|
941
|
-
* Checks if `value` is an empty object, collection, map, or set.
|
|
942
|
-
*
|
|
943
|
-
* Objects are considered empty if they have no own enumerable string keyed
|
|
944
|
-
* properties.
|
|
945
|
-
*
|
|
946
|
-
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
|
947
|
-
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
|
948
|
-
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
|
949
|
-
*
|
|
950
|
-
* @static
|
|
951
|
-
* @memberOf _
|
|
952
|
-
* @since 0.1.0
|
|
953
|
-
* @category Lang
|
|
954
|
-
* @param {*} value The value to check.
|
|
955
|
-
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
|
956
|
-
* @example
|
|
957
|
-
*
|
|
958
|
-
* _.isEmpty(null);
|
|
959
|
-
* // => true
|
|
960
|
-
*
|
|
961
|
-
* _.isEmpty(true);
|
|
962
|
-
* // => true
|
|
963
|
-
*
|
|
964
|
-
* _.isEmpty(1);
|
|
965
|
-
* // => true
|
|
966
|
-
*
|
|
967
|
-
* _.isEmpty([1, 2, 3]);
|
|
968
|
-
* // => false
|
|
969
|
-
*
|
|
970
|
-
* _.isEmpty({ 'a': 1 });
|
|
971
|
-
* // => false
|
|
972
|
-
*/
|
|
973
|
-
function isEmpty(value) {
|
|
974
|
-
if (value == null) {
|
|
975
|
-
return true;
|
|
976
|
-
}
|
|
977
|
-
if (isArrayLike(value) &&
|
|
978
|
-
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
|
979
|
-
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
|
980
|
-
return !value.length;
|
|
981
|
-
}
|
|
982
|
-
var tag = getTag(value);
|
|
983
|
-
if (tag == mapTag || tag == setTag) {
|
|
984
|
-
return !value.size;
|
|
985
|
-
}
|
|
986
|
-
if (isPrototype(value)) {
|
|
987
|
-
return !baseKeys(value).length;
|
|
988
|
-
}
|
|
989
|
-
for (var key in value) {
|
|
990
|
-
if (hasOwnProperty.call(value, key)) {
|
|
991
|
-
return false;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
return true;
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
var isEmpty_1 = isEmpty;
|
|
998
|
-
|
|
999
|
-
// used in configure too, for consistency modify it there too
|
|
1000
|
-
const multiplePlacements = {
|
|
1001
|
-
enabled: 'Yes',
|
|
1002
|
-
disabled: 'No',
|
|
1003
|
-
perChoice: 'Set Per Choice'
|
|
1004
|
-
}; // used to validate the config
|
|
1005
|
-
|
|
1006
|
-
const isCorrectResponseDuplicated = (choices, alternate) => {
|
|
1007
|
-
if (choices.length < 1 || alternate.length < 1) {
|
|
1008
|
-
return -1;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
const stringChoices = JSON.stringify(choices.sort());
|
|
1012
|
-
const stringAlternate = alternate.reduce((total, current) => current.length > 0 ? [...total, JSON.stringify(current.sort())] : total, []);
|
|
1013
|
-
const foundIndexDuplicate = stringAlternate.findIndex(alternate => alternate.length && alternate === stringChoices);
|
|
1014
|
-
return foundIndexDuplicate;
|
|
1015
|
-
};
|
|
1016
|
-
const isAlternateDuplicated = alternate => {
|
|
1017
|
-
if (alternate.length <= 1) {
|
|
1018
|
-
return -1;
|
|
1019
|
-
}
|
|
1020
|
-
|
|
1021
|
-
const elementSet = new Set();
|
|
1022
|
-
const stringAlternate = alternate.reduce((total, current) => current.length > 0 ? [...total, JSON.stringify(current.sort())] : total, []);
|
|
1023
|
-
|
|
1024
|
-
for (let i = 0; i < stringAlternate.length; i++) {
|
|
1025
|
-
if (elementSet.has(stringAlternate[i]) && stringAlternate[i]) {
|
|
1026
|
-
return i;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
elementSet.add(stringAlternate[i]);
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
return -1;
|
|
1033
|
-
}; // calculate the minimum number of populated response areas (categories) in the correct answer or alternates
|
|
1034
|
-
// and create an array with the possible responses ids
|
|
1035
|
-
|
|
1036
|
-
const getCompleteResponseDetails = (correctResponse, alternates, allChoices) => {
|
|
1037
|
-
const choicesPerCategory = correctResponse.map(category => category.choices);
|
|
1038
|
-
const possibleResponses = [choicesPerCategory.flat()];
|
|
1039
|
-
let responseAreasToBeFilled = choicesPerCategory.filter(choices => choices.length).length;
|
|
1040
|
-
|
|
1041
|
-
if (alternates.length) {
|
|
1042
|
-
var _alternates$;
|
|
1043
|
-
|
|
1044
|
-
const alternatesPerChoice = ((_alternates$ = alternates[0]) == null ? void 0 : _alternates$.length) || 0; // number of alternates
|
|
1045
|
-
|
|
1046
|
-
[...Array(alternatesPerChoice).keys()].forEach(index => {
|
|
1047
|
-
const alternatesPerResponse = alternates.map(alternate => alternate[index]);
|
|
1048
|
-
const filledCategories = alternatesPerResponse.filter(category => category == null ? void 0 : category.length).length;
|
|
1049
|
-
possibleResponses.push(alternatesPerResponse.flat());
|
|
1050
|
-
|
|
1051
|
-
if (filledCategories < responseAreasToBeFilled) {
|
|
1052
|
-
responseAreasToBeFilled = filledCategories;
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
} // check if any correct answer have any unplaced answer choices
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const hasUnplacedChoices = possibleResponses.some(response => !allChoices.every(val => response.includes(val == null ? void 0 : val.id)));
|
|
1059
|
-
return {
|
|
1060
|
-
responseAreasToBeFilled,
|
|
1061
|
-
possibleResponses,
|
|
1062
|
-
hasUnplacedChoices
|
|
1063
|
-
};
|
|
1064
|
-
};
|
|
1065
|
-
|
|
1066
|
-
var defaults = {
|
|
1067
|
-
allowMultiplePlacementsEnabled: multiplePlacements.enabled,
|
|
1068
|
-
alternates: [],
|
|
1069
|
-
categories: [],
|
|
1070
|
-
categoriesPerRow: 2,
|
|
1071
|
-
choices: [],
|
|
1072
|
-
choicesLabel: '',
|
|
1073
|
-
choicesPosition: 'below',
|
|
1074
|
-
correctResponse: [],
|
|
1075
|
-
feedbackEnabled: false,
|
|
1076
|
-
lockChoiceOrder: true,
|
|
1077
|
-
maxAnswerChoices: 6,
|
|
1078
|
-
maxChoicesPerCategory: 0,
|
|
1079
|
-
partialScoring: true,
|
|
1080
|
-
prompt: '',
|
|
1081
|
-
promptEnabled: true,
|
|
1082
|
-
rationale: '',
|
|
1083
|
-
rationaleEnabled: true,
|
|
1084
|
-
rowLabels: [''],
|
|
1085
|
-
studentInstructionsEnabled: true,
|
|
1086
|
-
teacherInstructions: '',
|
|
1087
|
-
teacherInstructionsEnabled: true,
|
|
1088
|
-
toolbarEditorPosition: 'bottom',
|
|
1089
|
-
minRowHeight: '80px'
|
|
1090
|
-
};
|
|
1091
|
-
|
|
1092
|
-
const {
|
|
1093
|
-
translator
|
|
1094
|
-
} = Translator;
|
|
1095
|
-
const getPartialScore = (correctResponse, builtCategories) => {
|
|
1096
|
-
// in the resulted best scenario we make a sum with all the correct responses
|
|
1097
|
-
// and all the placements
|
|
1098
|
-
const {
|
|
1099
|
-
placements,
|
|
1100
|
-
score
|
|
1101
|
-
} = builtCategories.reduce((acc, {
|
|
1102
|
-
choices: _choices = []
|
|
1103
|
-
}) => ({
|
|
1104
|
-
placements: acc.placements + _choices.length,
|
|
1105
|
-
score: acc.score + _choices.filter(ch => ch.correct).length
|
|
1106
|
-
}), {
|
|
1107
|
-
placements: 0,
|
|
1108
|
-
score: 0
|
|
1109
|
-
}); // in the correct response, we make a sum of the max possible score
|
|
1110
|
-
|
|
1111
|
-
const {
|
|
1112
|
-
maxScore
|
|
1113
|
-
} = correctResponse.reduce((acc, {
|
|
1114
|
-
choices
|
|
1115
|
-
}) => ({
|
|
1116
|
-
maxScore: acc.maxScore + choices.length
|
|
1117
|
-
}), {
|
|
1118
|
-
maxScore: 0
|
|
1119
|
-
}); // if there are any extra placements, we subtract from the obtained score
|
|
1120
|
-
|
|
1121
|
-
const extraPlacements = placements > maxScore ? placements - maxScore : 0;
|
|
1122
|
-
const totalScore = (score - extraPlacements) / maxScore;
|
|
1123
|
-
return totalScore < 0 ? 0 : parseFloat(totalScore.toFixed(2));
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
|
-
const getAlternates = correctResponse => correctResponse.map(c => c.alternateResponses).filter(alternate => alternate);
|
|
1127
|
-
|
|
1128
|
-
const getTotalScore = (question, session, env) => {
|
|
1129
|
-
if (!session) {
|
|
1130
|
-
return 0;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
if (Object.keys(session).length === 0) {
|
|
1134
|
-
return 0;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
const {
|
|
1138
|
-
categories,
|
|
1139
|
-
choices
|
|
1140
|
-
} = question || {};
|
|
1141
|
-
let {
|
|
1142
|
-
correctResponse
|
|
1143
|
-
} = question || {};
|
|
1144
|
-
let {
|
|
1145
|
-
answers
|
|
1146
|
-
} = session || {};
|
|
1147
|
-
answers = answers || [];
|
|
1148
|
-
correctResponse = correctResponse || []; // this function is used in pie-ui/categorize as well, in order to get the best scenario
|
|
1149
|
-
// so we get the best scenario and calculate the score
|
|
1150
|
-
|
|
1151
|
-
const {
|
|
1152
|
-
categories: builtCategories,
|
|
1153
|
-
correct
|
|
1154
|
-
} = buildState(categories, choices, answers, correctResponse);
|
|
1155
|
-
const alternates = getAlternates(correctResponse);
|
|
1156
|
-
const enabled = partialScoring.enabled(question, env); // if there are any alternates, there will be no partial scoring!
|
|
1157
|
-
|
|
1158
|
-
if (enabled && !alternates.length) {
|
|
1159
|
-
// we apply partial scoring
|
|
1160
|
-
return getPartialScore(correctResponse, builtCategories);
|
|
1161
|
-
} // else we apply dichotomous
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
return correct ? 1 : 0;
|
|
1165
|
-
};
|
|
1166
|
-
const getCorrectness = (question, session, env) => {
|
|
1167
|
-
return new Promise(resolve => {
|
|
1168
|
-
if (env.mode === 'evaluate') {
|
|
1169
|
-
const score = getTotalScore(question, session, env);
|
|
1170
|
-
|
|
1171
|
-
if (score === 1) {
|
|
1172
|
-
resolve('correct');
|
|
1173
|
-
} else if (score === 0) {
|
|
1174
|
-
resolve('incorrect');
|
|
1175
|
-
} else {
|
|
1176
|
-
resolve('partially-correct');
|
|
1177
|
-
}
|
|
1178
|
-
} else {
|
|
1179
|
-
resolve(undefined);
|
|
1180
|
-
}
|
|
1181
|
-
});
|
|
1182
|
-
};
|
|
1183
|
-
const createDefaultModel = (model = {}) => new Promise(resolve => {
|
|
1184
|
-
resolve(_extends({}, defaults, model));
|
|
1185
|
-
});
|
|
1186
|
-
const normalize = question => _extends({}, defaults, question);
|
|
1187
|
-
/**
|
|
1188
|
-
*
|
|
1189
|
-
* @param {*} question
|
|
1190
|
-
* @param {*} session
|
|
1191
|
-
* @param {*} env
|
|
1192
|
-
* @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
|
|
1193
|
-
*/
|
|
1194
|
-
|
|
1195
|
-
const model = (question, session, env, updateSession) => new Promise(async resolve => {
|
|
1196
|
-
const normalizedQuestion = normalize(question);
|
|
1197
|
-
const answerCorrectness = await getCorrectness(normalizedQuestion, session, env);
|
|
1198
|
-
const {
|
|
1199
|
-
mode,
|
|
1200
|
-
role
|
|
1201
|
-
} = env || {};
|
|
1202
|
-
const {
|
|
1203
|
-
categories,
|
|
1204
|
-
categoriesPerRow,
|
|
1205
|
-
choicesLabel,
|
|
1206
|
-
choicesPosition,
|
|
1207
|
-
correctResponse,
|
|
1208
|
-
feedback,
|
|
1209
|
-
feedbackEnabled,
|
|
1210
|
-
promptEnabled,
|
|
1211
|
-
prompt,
|
|
1212
|
-
rowLabels,
|
|
1213
|
-
rationaleEnabled,
|
|
1214
|
-
rationale,
|
|
1215
|
-
teacherInstructionsEnabled,
|
|
1216
|
-
teacherInstructions,
|
|
1217
|
-
language,
|
|
1218
|
-
maxChoicesPerCategory,
|
|
1219
|
-
extraCSSRules,
|
|
1220
|
-
minRowHeight,
|
|
1221
|
-
fontSizeFactor,
|
|
1222
|
-
autoplayAudioEnabled,
|
|
1223
|
-
completeAudioEnabled,
|
|
1224
|
-
customAudioButton
|
|
1225
|
-
} = normalizedQuestion;
|
|
1226
|
-
let {
|
|
1227
|
-
choices,
|
|
1228
|
-
note
|
|
1229
|
-
} = normalizedQuestion;
|
|
1230
|
-
let fb;
|
|
1231
|
-
const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);
|
|
1232
|
-
const filteredCorrectResponse = correctResponse.map(response => {
|
|
1233
|
-
const filteredChoices = (response.choices || []).filter(choice => choice !== 'null');
|
|
1234
|
-
return _extends({}, response, {
|
|
1235
|
-
choices: filteredChoices
|
|
1236
|
-
});
|
|
1237
|
-
});
|
|
1238
|
-
|
|
1239
|
-
if (mode === 'evaluate' && feedbackEnabled) {
|
|
1240
|
-
fb = await getFeedbackForCorrectness(answerCorrectness, feedback);
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
if (!lockChoiceOrder) {
|
|
1244
|
-
choices = await getShuffledChoices(choices, session, updateSession, 'id');
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
if (!note) {
|
|
1248
|
-
note = translator.t('common:commonCorrectAnswerWithAlternates', {
|
|
1249
|
-
lng: language
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
const alternates = getAlternates(filteredCorrectResponse);
|
|
1254
|
-
const {
|
|
1255
|
-
responseAreasToBeFilled,
|
|
1256
|
-
possibleResponses,
|
|
1257
|
-
hasUnplacedChoices
|
|
1258
|
-
} = getCompleteResponseDetails(filteredCorrectResponse, normalizedQuestion.allowAlternateEnabled ? alternates : [], normalizedQuestion.choices);
|
|
1259
|
-
const out = {
|
|
1260
|
-
categories: categories || [],
|
|
1261
|
-
categoriesPerRow: categoriesPerRow || 2,
|
|
1262
|
-
maxChoicesPerCategory,
|
|
1263
|
-
correctness: answerCorrectness,
|
|
1264
|
-
choices: choices || [],
|
|
1265
|
-
choicesLabel: choicesLabel || '',
|
|
1266
|
-
choicesPosition,
|
|
1267
|
-
disabled: mode !== 'gather',
|
|
1268
|
-
feedback: fb,
|
|
1269
|
-
lockChoiceOrder,
|
|
1270
|
-
prompt: promptEnabled ? prompt : null,
|
|
1271
|
-
rowLabels,
|
|
1272
|
-
note,
|
|
1273
|
-
env,
|
|
1274
|
-
showNote: alternates && alternates.length > 0,
|
|
1275
|
-
correctResponse: mode === 'evaluate' ? filteredCorrectResponse : undefined,
|
|
1276
|
-
language,
|
|
1277
|
-
extraCSSRules,
|
|
1278
|
-
fontSizeFactor,
|
|
1279
|
-
minRowHeight: minRowHeight,
|
|
1280
|
-
autoplayAudioEnabled,
|
|
1281
|
-
completeAudioEnabled,
|
|
1282
|
-
customAudioButton,
|
|
1283
|
-
possibleResponses,
|
|
1284
|
-
responseAreasToBeFilled,
|
|
1285
|
-
hasUnplacedChoices
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
1289
|
-
out.rationale = rationaleEnabled ? rationale : null;
|
|
1290
|
-
out.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;
|
|
1291
|
-
} else {
|
|
1292
|
-
out.rationale = null;
|
|
1293
|
-
out.teacherInstructions = null;
|
|
1294
|
-
}
|
|
1295
|
-
|
|
1296
|
-
resolve(out);
|
|
1297
|
-
});
|
|
1298
|
-
const outcome = (question, session, env) => {
|
|
1299
|
-
if (env.mode !== 'evaluate') {
|
|
1300
|
-
return Promise.reject(new Error('Can not call outcome when mode is not evaluate'));
|
|
1301
|
-
} else {
|
|
1302
|
-
return new Promise(resolve => {
|
|
1303
|
-
resolve({
|
|
1304
|
-
score: getTotalScore(question, session, env),
|
|
1305
|
-
empty: !session || isEmpty_1(session)
|
|
1306
|
-
});
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
const createCorrectResponseSession = (question, env) => {
|
|
1311
|
-
return new Promise(resolve => {
|
|
1312
|
-
const {
|
|
1313
|
-
mode,
|
|
1314
|
-
role
|
|
1315
|
-
} = env || {};
|
|
1316
|
-
|
|
1317
|
-
if (mode !== 'evaluate' && role === 'instructor') {
|
|
1318
|
-
const {
|
|
1319
|
-
correctResponse
|
|
1320
|
-
} = question;
|
|
1321
|
-
resolve({
|
|
1322
|
-
answers: correctResponse,
|
|
1323
|
-
id: 1
|
|
1324
|
-
});
|
|
1325
|
-
} else {
|
|
1326
|
-
return resolve(null);
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1329
|
-
}; // remove all html tags
|
|
1330
|
-
|
|
1331
|
-
const getInnerText = html => (html || '').replaceAll(/<[^>]*>/g, ''); // remove all html tags except img, iframe and source tag for audio
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
1335
|
-
|
|
1336
|
-
const validate = (model = {}, config = {}) => {
|
|
1337
|
-
const {
|
|
1338
|
-
categories,
|
|
1339
|
-
choices,
|
|
1340
|
-
correctResponse,
|
|
1341
|
-
maxAnswerChoices
|
|
1342
|
-
} = model;
|
|
1343
|
-
const {
|
|
1344
|
-
minChoices = 1,
|
|
1345
|
-
minCategories = 1,
|
|
1346
|
-
maxCategories = 12,
|
|
1347
|
-
maxLengthPerChoice = 300,
|
|
1348
|
-
maxLengthPerCategory = 150
|
|
1349
|
-
} = config;
|
|
1350
|
-
const reversedChoices = [...(choices || [])].reverse();
|
|
1351
|
-
const errors = {};
|
|
1352
|
-
const choicesErrors = {};
|
|
1353
|
-
const categoriesErrors = {};
|
|
1354
|
-
['teacherInstructions', 'prompt', 'rationale'].forEach(field => {
|
|
1355
|
-
var _config$field;
|
|
1356
|
-
|
|
1357
|
-
if ((_config$field = config[field]) != null && _config$field.required && !getContent(model[field])) {
|
|
1358
|
-
errors[field] = 'This field is required.';
|
|
1359
|
-
}
|
|
1360
|
-
});
|
|
1361
|
-
(categories || []).forEach(category => {
|
|
1362
|
-
const {
|
|
1363
|
-
id,
|
|
1364
|
-
label
|
|
1365
|
-
} = category;
|
|
1366
|
-
|
|
1367
|
-
if (getInnerText(label).length > maxLengthPerCategory) {
|
|
1368
|
-
categoriesErrors[id] = `Category labels should be no more than ${maxLengthPerCategory} characters long.`;
|
|
1369
|
-
}
|
|
1370
|
-
});
|
|
1371
|
-
(reversedChoices || []).forEach((choice, index) => {
|
|
1372
|
-
const {
|
|
1373
|
-
id,
|
|
1374
|
-
content
|
|
1375
|
-
} = choice;
|
|
1376
|
-
|
|
1377
|
-
if (getInnerText(content).length > maxLengthPerChoice) {
|
|
1378
|
-
choicesErrors[id] = `Tokens should be no more than ${maxLengthPerChoice} characters long.`;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
if (!getContent(content)) {
|
|
1382
|
-
choicesErrors[id] = 'Tokens should not be empty.';
|
|
1383
|
-
} else {
|
|
1384
|
-
const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.content === content);
|
|
1385
|
-
|
|
1386
|
-
if (identicalAnswer) {
|
|
1387
|
-
choicesErrors[id] = 'Tokens content should be unique.';
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
});
|
|
1391
|
-
const nbOfCategories = (categories || []).length;
|
|
1392
|
-
const nbOfChoices = (choices || []).length;
|
|
1393
|
-
|
|
1394
|
-
if (nbOfCategories > maxCategories) {
|
|
1395
|
-
errors.categoriesError = `No more than ${maxCategories} categories should be defined.`;
|
|
1396
|
-
} else if (nbOfCategories < minCategories) {
|
|
1397
|
-
errors.categoriesError = `There should be at least ${minCategories} category defined.`;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
if (nbOfChoices < minChoices) {
|
|
1401
|
-
errors.choicesError = `There should be at least ${minChoices} choices defined.`;
|
|
1402
|
-
} else if (nbOfChoices > maxAnswerChoices) {
|
|
1403
|
-
errors.choicesError = `No more than ${maxAnswerChoices} choices should be defined.`;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
if (nbOfChoices && nbOfCategories) {
|
|
1407
|
-
let hasAssociations = false;
|
|
1408
|
-
(correctResponse || []).forEach(response => {
|
|
1409
|
-
const {
|
|
1410
|
-
choices = [],
|
|
1411
|
-
alternateResponses = []
|
|
1412
|
-
} = response;
|
|
1413
|
-
|
|
1414
|
-
if (choices.length) {
|
|
1415
|
-
hasAssociations = true;
|
|
1416
|
-
} else {
|
|
1417
|
-
alternateResponses.forEach(alternate => {
|
|
1418
|
-
if ((alternate || []).length) {
|
|
1419
|
-
hasAssociations = true;
|
|
1420
|
-
}
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
});
|
|
1424
|
-
let duplicateAlternateIndex = -1;
|
|
1425
|
-
let duplicateCategory = '';
|
|
1426
|
-
(correctResponse || []).forEach(response => {
|
|
1427
|
-
const {
|
|
1428
|
-
choices = [],
|
|
1429
|
-
alternateResponses = [],
|
|
1430
|
-
category
|
|
1431
|
-
} = response;
|
|
1432
|
-
|
|
1433
|
-
if (duplicateAlternateIndex === -1) {
|
|
1434
|
-
duplicateAlternateIndex = isCorrectResponseDuplicated(choices, alternateResponses);
|
|
1435
|
-
|
|
1436
|
-
if (duplicateAlternateIndex === -1) {
|
|
1437
|
-
duplicateAlternateIndex = isAlternateDuplicated(alternateResponses);
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
duplicateCategory = category;
|
|
1441
|
-
}
|
|
1442
|
-
});
|
|
1443
|
-
|
|
1444
|
-
if (duplicateAlternateIndex > -1) {
|
|
1445
|
-
errors.duplicateAlternate = {
|
|
1446
|
-
index: duplicateAlternateIndex,
|
|
1447
|
-
category: duplicateCategory
|
|
1448
|
-
};
|
|
1449
|
-
}
|
|
1450
|
-
|
|
1451
|
-
if (!hasAssociations) {
|
|
1452
|
-
errors.associationError = 'At least one token should be assigned to at least one category.';
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
if (!isEmpty_1(choicesErrors)) {
|
|
1457
|
-
errors.choicesErrors = choicesErrors;
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
if (!isEmpty_1(categoriesErrors)) {
|
|
1461
|
-
errors.categoriesErrors = categoriesErrors;
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
return errors;
|
|
1465
|
-
};
|
|
1466
|
-
|
|
1467
|
-
export { createCorrectResponseSession, createDefaultModel, getCorrectness, getPartialScore, getTotalScore, model, normalize, outcome, validate };
|
|
1468
|
-
//# sourceMappingURL=controller.js.map
|