@pie-element/number-line 11.0.1 → 11.0.2-esm.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/package.json +4 -4
- package/esm/configure.css +847 -0
- package/esm/configure.js +578 -17598
- package/esm/configure.js.map +1 -1
- package/esm/controller.css +847 -0
- package/esm/controller.js +226 -286
- package/esm/controller.js.map +1 -1
- package/esm/element.css +847 -0
- package/esm/element.js +6381 -11753
- package/esm/element.js.map +1 -1
- package/package.json +4 -4
package/esm/controller.js
CHANGED
|
@@ -10,55 +10,22 @@ import uniqWith from 'lodash/uniqWith';
|
|
|
10
10
|
import isObject$1 from 'lodash/isObject';
|
|
11
11
|
import isNumber$1 from 'lodash/isNumber';
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
} catch (error) {
|
|
18
|
-
reject(error);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (info.done) {
|
|
23
|
-
resolve(value);
|
|
24
|
-
} else {
|
|
25
|
-
Promise.resolve(value).then(_next, _throw);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
13
|
+
function _extends$7() {
|
|
14
|
+
_extends$7 = Object.assign || function (target) {
|
|
15
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
16
|
+
var source = arguments[i];
|
|
28
17
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return new Promise(function (resolve, reject) {
|
|
34
|
-
var gen = fn.apply(self, args);
|
|
35
|
-
|
|
36
|
-
function _next(value) {
|
|
37
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function _throw(err) {
|
|
41
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
18
|
+
for (var key in source) {
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
20
|
+
target[key] = source[key];
|
|
21
|
+
}
|
|
42
22
|
}
|
|
23
|
+
}
|
|
43
24
|
|
|
44
|
-
|
|
45
|
-
});
|
|
25
|
+
return target;
|
|
46
26
|
};
|
|
47
|
-
}
|
|
48
27
|
|
|
49
|
-
|
|
50
|
-
if (key in obj) {
|
|
51
|
-
Object.defineProperty(obj, key, {
|
|
52
|
-
value: value,
|
|
53
|
-
enumerable: true,
|
|
54
|
-
configurable: true,
|
|
55
|
-
writable: true
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
obj[key] = value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return obj;
|
|
28
|
+
return _extends$7.apply(this, arguments);
|
|
62
29
|
}
|
|
63
30
|
|
|
64
31
|
var DEFAULT_CONFIG = {
|
|
@@ -26439,9 +26406,9 @@ var createPow = /* #__PURE__ */factory(name$2E, dependencies$2E, function (_ref)
|
|
|
26439
26406
|
}
|
|
26440
26407
|
});
|
|
26441
26408
|
|
|
26442
|
-
function ownKeys$
|
|
26409
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
26443
26410
|
|
|
26444
|
-
function _objectSpread$
|
|
26411
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty$1(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26445
26412
|
|
|
26446
26413
|
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
26447
26414
|
var NO_INT = 'Number of decimals in function round must be an integer';
|
|
@@ -26501,7 +26468,7 @@ var createRound = /* #__PURE__ */factory(name$2D, dependencies$2D, function (_re
|
|
|
26501
26468
|
* @return {number | BigNumber | Fraction | Complex | Array | Matrix} Rounded value
|
|
26502
26469
|
*/
|
|
26503
26470
|
|
|
26504
|
-
return typed(name$2D, _objectSpread$
|
|
26471
|
+
return typed(name$2D, _objectSpread$1(_objectSpread$1({}, roundNumberSignatures), {}, {
|
|
26505
26472
|
Complex: function Complex(x) {
|
|
26506
26473
|
return x.round();
|
|
26507
26474
|
},
|
|
@@ -31712,9 +31679,9 @@ function _typeof$6(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "func
|
|
|
31712
31679
|
|
|
31713
31680
|
function _extends$5() { _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
|
|
31714
31681
|
|
|
31715
|
-
function ownKeys
|
|
31682
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
31716
31683
|
|
|
31717
|
-
function _objectSpread
|
|
31684
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31718
31685
|
|
|
31719
31686
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31720
31687
|
var name$25 = 'Unit';
|
|
@@ -32395,7 +32362,7 @@ var createUnitClass = /* #__PURE__ */factory(name$25, dependencies$25, function
|
|
|
32395
32362
|
|
|
32396
32363
|
for (var _i = 0; _i < other.units.length; _i++) {
|
|
32397
32364
|
// Make a shallow copy of every unit
|
|
32398
|
-
var inverted = _objectSpread
|
|
32365
|
+
var inverted = _objectSpread({}, other.units[_i]);
|
|
32399
32366
|
|
|
32400
32367
|
res.units.push(inverted);
|
|
32401
32368
|
} // If at least one operand has a value, then the result should also have a value
|
|
@@ -32431,7 +32398,7 @@ var createUnitClass = /* #__PURE__ */factory(name$25, dependencies$25, function
|
|
|
32431
32398
|
|
|
32432
32399
|
for (var _i2 = 0; _i2 < other.units.length; _i2++) {
|
|
32433
32400
|
// Make a shallow copy of every unit
|
|
32434
|
-
var inverted = _objectSpread
|
|
32401
|
+
var inverted = _objectSpread(_objectSpread({}, other.units[_i2]), {}, {
|
|
32435
32402
|
power: -other.units[_i2].power
|
|
32436
32403
|
});
|
|
32437
32404
|
|
|
@@ -61620,20 +61587,16 @@ var defaults = {
|
|
|
61620
61587
|
widthEnabled: true
|
|
61621
61588
|
};
|
|
61622
61589
|
|
|
61623
|
-
function ownKeys$2(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; }
|
|
61624
|
-
|
|
61625
|
-
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
61626
|
-
|
|
61627
61590
|
/*This will store the possible decimal tick values*/
|
|
61628
61591
|
|
|
61629
|
-
|
|
61592
|
+
const decimalTickValues = [0.001, 0.01, 0.02, 0.04, 0.05, 0.1, 0.125, 0.2, 0.25, 0.5];
|
|
61630
61593
|
/*This will store the possible fraction tick values*/
|
|
61631
61594
|
|
|
61632
|
-
|
|
61595
|
+
const fractionTickValues = ['1/1000', '1/100', '1/64', '1/50', '1/32', '1/25', '1/20', '1/16', '1/15', '1/12', '1/10', '1/9', '1/8', '1/7', '1/6', '1/5', '1/4', '1/3', '1/2'];
|
|
61633
61596
|
/*This const will store possible multiplier for label interval that needs to be multiplied
|
|
61634
61597
|
with tick interval with denominator represented with object key.*/
|
|
61635
61598
|
|
|
61636
|
-
|
|
61599
|
+
const labelMultiplier = {
|
|
61637
61600
|
1: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
61638
61601
|
2: [1, 2, 4, 6, 8, 10],
|
|
61639
61602
|
3: [1, 3, 6, 9],
|
|
@@ -61656,8 +61619,8 @@ var labelMultiplier = {
|
|
|
61656
61619
|
1000: [1, 2, 4, 5, 8, 10]
|
|
61657
61620
|
};
|
|
61658
61621
|
|
|
61659
|
-
|
|
61660
|
-
|
|
61622
|
+
const fractionRange = (start, end, interval) => {
|
|
61623
|
+
const m = mod(abs(start), abs(interval));
|
|
61661
61624
|
|
|
61662
61625
|
if (!equal(m, 0)) {
|
|
61663
61626
|
throw new Error('start point must be divisible by interval');
|
|
@@ -61667,8 +61630,8 @@ var fractionRange = (start, end, interval) => {
|
|
|
61667
61630
|
return [];
|
|
61668
61631
|
}
|
|
61669
61632
|
|
|
61670
|
-
|
|
61671
|
-
|
|
61633
|
+
const e = subtract(end, mod(end, abs(interval)));
|
|
61634
|
+
const direction = larger(interval, 0) ? 'positive' : 'negative';
|
|
61672
61635
|
|
|
61673
61636
|
if (direction === 'negative' && largerEq(end, start)) {
|
|
61674
61637
|
throw new Error('start must be > than end when doing a negative decrement');
|
|
@@ -61678,9 +61641,9 @@ var fractionRange = (start, end, interval) => {
|
|
|
61678
61641
|
throw new Error('start must be < end when doing increments');
|
|
61679
61642
|
}
|
|
61680
61643
|
|
|
61681
|
-
|
|
61682
|
-
|
|
61683
|
-
|
|
61644
|
+
const compareFn = direction === 'positive' ? smallerEq : equal(e, end) ? largerEq : larger;
|
|
61645
|
+
const out = [];
|
|
61646
|
+
let next = start;
|
|
61684
61647
|
|
|
61685
61648
|
while (compareFn(next, e)) {
|
|
61686
61649
|
out.push(next);
|
|
@@ -61690,28 +61653,28 @@ var fractionRange = (start, end, interval) => {
|
|
|
61690
61653
|
return out;
|
|
61691
61654
|
};
|
|
61692
61655
|
|
|
61693
|
-
|
|
61656
|
+
const zbrErrorMessage = (start, end) => `Can only do a positive or negative range, but got: start: ${start} and end:${end}`;
|
|
61694
61657
|
|
|
61695
|
-
|
|
61658
|
+
const zeroBasedRange = (start, end, interval) => {
|
|
61696
61659
|
start = fraction$1(start);
|
|
61697
61660
|
end = fraction$1(end);
|
|
61698
61661
|
interval = fraction$1(interval);
|
|
61699
|
-
|
|
61662
|
+
const length = abs(subtract(end, start));
|
|
61700
61663
|
|
|
61701
61664
|
if (larger(length, abs(end))) {
|
|
61702
61665
|
throw new Error(zbrErrorMessage(start, end));
|
|
61703
61666
|
}
|
|
61704
61667
|
|
|
61705
|
-
|
|
61668
|
+
const a = {
|
|
61706
61669
|
start: abs(start),
|
|
61707
61670
|
end: abs(end),
|
|
61708
61671
|
interval: abs(interval),
|
|
61709
61672
|
multiplier: smaller(interval, 0) ? -1 : 1
|
|
61710
61673
|
};
|
|
61711
|
-
|
|
61712
|
-
|
|
61713
|
-
|
|
61714
|
-
|
|
61674
|
+
const m = mod(a.start, a.interval);
|
|
61675
|
+
const s = larger(m, 0) ? add(subtract(a.start, m), a.interval) : a.start;
|
|
61676
|
+
const r = fractionRange(s, a.end, a.interval);
|
|
61677
|
+
const out = a.multiplier === -1 ? r.map(v => multiply(v, -1)) : r;
|
|
61715
61678
|
|
|
61716
61679
|
if (smaller(interval, 0)) {
|
|
61717
61680
|
out.reverse();
|
|
@@ -61720,13 +61683,13 @@ var zeroBasedRange = (start, end, interval) => {
|
|
|
61720
61683
|
return out;
|
|
61721
61684
|
};
|
|
61722
61685
|
|
|
61723
|
-
|
|
61686
|
+
const fmin = (a, b) => {
|
|
61724
61687
|
a = fraction$1(a);
|
|
61725
61688
|
b = fraction$1(b);
|
|
61726
61689
|
return smaller(a, b) ? a : b;
|
|
61727
61690
|
};
|
|
61728
61691
|
|
|
61729
|
-
|
|
61692
|
+
const fmax = (a, b) => {
|
|
61730
61693
|
a = fraction$1(a);
|
|
61731
61694
|
b = fraction$1(b);
|
|
61732
61695
|
return larger(a, b) ? a : b;
|
|
@@ -61738,25 +61701,25 @@ var fmax = (a, b) => {
|
|
|
61738
61701
|
*/
|
|
61739
61702
|
|
|
61740
61703
|
|
|
61741
|
-
|
|
61704
|
+
const simpleRange = (start, end, interval) => {
|
|
61742
61705
|
start = fraction$1(start);
|
|
61743
61706
|
end = fraction$1(end);
|
|
61744
61707
|
interval = fraction$1(interval);
|
|
61745
|
-
|
|
61746
|
-
|
|
61747
|
-
|
|
61748
|
-
|
|
61708
|
+
const positiveRange = larger(end, 0) ? zeroBasedRange(fmax(0, start), end, interval) : [];
|
|
61709
|
+
const negativeRange = smaller(start, 0) ? zeroBasedRange(fmin(0, end), start, multiply(interval, -1)) : [];
|
|
61710
|
+
let together = negativeRange.concat(positiveRange);
|
|
61711
|
+
const out = uniqWith(together, equal);
|
|
61749
61712
|
return out;
|
|
61750
61713
|
};
|
|
61751
61714
|
|
|
61752
|
-
|
|
61715
|
+
const closeTo$1 = (a, b, precision) => {
|
|
61753
61716
|
precision = precision || 2;
|
|
61754
|
-
|
|
61755
|
-
|
|
61717
|
+
const expectedDiff = Math.pow(10, -precision) / 2;
|
|
61718
|
+
const receivedDiff = Math.abs(a - b);
|
|
61756
61719
|
return receivedDiff < expectedDiff;
|
|
61757
61720
|
};
|
|
61758
61721
|
|
|
61759
|
-
|
|
61722
|
+
const limit = (v, min, max) => {
|
|
61760
61723
|
if (smaller(fraction(v), fraction(min))) {
|
|
61761
61724
|
return min;
|
|
61762
61725
|
}
|
|
@@ -61774,18 +61737,18 @@ var limit = (v, min, max) => {
|
|
|
61774
61737
|
* */
|
|
61775
61738
|
|
|
61776
61739
|
|
|
61777
|
-
|
|
61778
|
-
|
|
61779
|
-
|
|
61780
|
-
|
|
61740
|
+
const getMinorLimits = (domain, width) => {
|
|
61741
|
+
const end = domain.max - domain.min;
|
|
61742
|
+
const min = number(multiply(10, divide(fraction$1(end), width)));
|
|
61743
|
+
const max = number(multiply(20, min));
|
|
61781
61744
|
return {
|
|
61782
61745
|
min: min,
|
|
61783
61746
|
max: max
|
|
61784
61747
|
};
|
|
61785
61748
|
};
|
|
61786
61749
|
|
|
61787
|
-
|
|
61788
|
-
|
|
61750
|
+
const isMultiple = (multiple, src) => {
|
|
61751
|
+
const mod$1 = mod(multiple, src);
|
|
61789
61752
|
return equal(mod$1, 0);
|
|
61790
61753
|
};
|
|
61791
61754
|
/**
|
|
@@ -61795,7 +61758,7 @@ var isMultiple = (multiple, src) => {
|
|
|
61795
61758
|
*/
|
|
61796
61759
|
|
|
61797
61760
|
|
|
61798
|
-
|
|
61761
|
+
const fraction = v => {
|
|
61799
61762
|
if (isObject$1(v)) {
|
|
61800
61763
|
return fraction$1(v.n * v.s, v.d);
|
|
61801
61764
|
} else if (isNumber$1(v)) {
|
|
@@ -61803,16 +61766,16 @@ var fraction = v => {
|
|
|
61803
61766
|
}
|
|
61804
61767
|
};
|
|
61805
61768
|
|
|
61806
|
-
|
|
61807
|
-
|
|
61808
|
-
|
|
61809
|
-
|
|
61810
|
-
|
|
61811
|
-
|
|
61769
|
+
const normalizeTicks = (domain, width, ticks, opts) => {
|
|
61770
|
+
const useLimit = opts ? opts.limit !== false : true;
|
|
61771
|
+
const minorLimits = getMinorLimits(domain, width);
|
|
61772
|
+
const minor = useLimit ? limit(fraction(ticks.minor), minorLimits.min, minorLimits.max) : fraction(ticks.minor);
|
|
61773
|
+
const major = useLimit ? limit(fraction(ticks.major), minor, multiply(minor, 20)) : fraction(ticks.major);
|
|
61774
|
+
const isMajorMultiple = isMultiple(major, minor);
|
|
61812
61775
|
|
|
61813
61776
|
if (!isMajorMultiple) {
|
|
61814
|
-
|
|
61815
|
-
|
|
61777
|
+
const multiplier = divide(major, minor);
|
|
61778
|
+
const multiplyBy = multiplier <= 2 ? 2 : Math.round(multiplier); // major must be a multiple of minor
|
|
61816
61779
|
|
|
61817
61780
|
return {
|
|
61818
61781
|
minor,
|
|
@@ -61830,12 +61793,12 @@ var normalizeTicks = (domain, width, ticks, opts) => {
|
|
|
61830
61793
|
*/
|
|
61831
61794
|
|
|
61832
61795
|
|
|
61833
|
-
|
|
61796
|
+
const buildTickDataAsFractions = (domain, width, ticks, opts) => {
|
|
61834
61797
|
ticks = normalizeTicks(domain, width, ticks, opts);
|
|
61835
|
-
|
|
61836
|
-
|
|
61837
|
-
|
|
61838
|
-
|
|
61798
|
+
const rng = simpleRange(domain.min, domain.max, ticks.minor);
|
|
61799
|
+
const o = rng.filter(x => smallerEq(x, fraction$1(domain.max))).map(x => {
|
|
61800
|
+
let type = 'minor';
|
|
61801
|
+
const modulo = mod(x, ticks.major);
|
|
61839
61802
|
|
|
61840
61803
|
if (closeTo$1(number(modulo), 0)) {
|
|
61841
61804
|
type = 'major';
|
|
@@ -61855,8 +61818,8 @@ var buildTickDataAsFractions = (domain, width, ticks, opts) => {
|
|
|
61855
61818
|
* */
|
|
61856
61819
|
|
|
61857
61820
|
|
|
61858
|
-
|
|
61859
|
-
|
|
61821
|
+
const generateMinorValues = minorLimits => {
|
|
61822
|
+
let out = {
|
|
61860
61823
|
fraction: [],
|
|
61861
61824
|
decimal: []
|
|
61862
61825
|
};
|
|
@@ -61866,7 +61829,7 @@ var generateMinorValues = minorLimits => {
|
|
|
61866
61829
|
}
|
|
61867
61830
|
});
|
|
61868
61831
|
fractionTickValues.forEach(value => {
|
|
61869
|
-
|
|
61832
|
+
let decimalValue = number(fraction$1(value));
|
|
61870
61833
|
|
|
61871
61834
|
if (decimalValue >= minorLimits.min && decimalValue <= minorLimits.max) {
|
|
61872
61835
|
out.fraction.push(value);
|
|
@@ -61882,24 +61845,24 @@ var generateMinorValues = minorLimits => {
|
|
|
61882
61845
|
* @return out object containing three arrays 1. fraction values, 2. decimal values,
|
|
61883
61846
|
* */
|
|
61884
61847
|
|
|
61885
|
-
|
|
61886
|
-
|
|
61848
|
+
const generateMajorValuesForMinor = (minor, domain, width) => {
|
|
61849
|
+
let out = {
|
|
61887
61850
|
decimal: [],
|
|
61888
61851
|
fraction: []
|
|
61889
61852
|
};
|
|
61890
|
-
|
|
61891
|
-
|
|
61892
|
-
|
|
61853
|
+
let fraction = fraction$1(number(number(minor)));
|
|
61854
|
+
let n = fraction.n;
|
|
61855
|
+
let d = fraction.d;
|
|
61893
61856
|
|
|
61894
61857
|
if (n >= 1 && d === 1) {
|
|
61895
|
-
for (
|
|
61896
|
-
|
|
61858
|
+
for (let i = 1; i <= 10; i++) {
|
|
61859
|
+
let num = number(multiply(n, i)); //Here we check if this major value can plot at least 2 points on number line.
|
|
61897
61860
|
|
|
61898
|
-
|
|
61861
|
+
let ticksData = {
|
|
61899
61862
|
minor: minor,
|
|
61900
61863
|
major: num
|
|
61901
61864
|
};
|
|
61902
|
-
|
|
61865
|
+
let output = buildTickData(domain, width, ticksData, {
|
|
61903
61866
|
fraction: undefined
|
|
61904
61867
|
});
|
|
61905
61868
|
|
|
@@ -61909,27 +61872,25 @@ var generateMajorValuesForMinor = (minor, domain, width) => {
|
|
|
61909
61872
|
}
|
|
61910
61873
|
}
|
|
61911
61874
|
} else {
|
|
61912
|
-
for (
|
|
61913
|
-
|
|
61875
|
+
for (const multiplierKey in labelMultiplier[d]) {
|
|
61876
|
+
let num = multiply(fraction$1(n, d), labelMultiplier[d][multiplierKey]); //Here we check if this major value can plot at least 2 points on number line.
|
|
61914
61877
|
|
|
61915
|
-
|
|
61916
|
-
var _ticksData = {
|
|
61878
|
+
let ticksData = {
|
|
61917
61879
|
minor: minor,
|
|
61918
|
-
major: number(
|
|
61880
|
+
major: number(num)
|
|
61919
61881
|
};
|
|
61920
|
-
|
|
61921
|
-
var _output = buildTickData(domain, width, _ticksData, {
|
|
61882
|
+
let output = buildTickData(domain, width, ticksData, {
|
|
61922
61883
|
fraction: undefined
|
|
61923
61884
|
});
|
|
61924
61885
|
|
|
61925
|
-
if (
|
|
61926
|
-
if (
|
|
61927
|
-
out.fraction.push(
|
|
61886
|
+
if (output.filter(x => x.type === 'major').length > 1) {
|
|
61887
|
+
if (num.d !== 1) {
|
|
61888
|
+
out.fraction.push(num.n + '/' + num.d);
|
|
61928
61889
|
} else {
|
|
61929
|
-
out.fraction.push(
|
|
61890
|
+
out.fraction.push(num.n.toString());
|
|
61930
61891
|
}
|
|
61931
61892
|
|
|
61932
|
-
out.decimal.push(number(
|
|
61893
|
+
out.decimal.push(number(num));
|
|
61933
61894
|
}
|
|
61934
61895
|
}
|
|
61935
61896
|
}
|
|
@@ -61937,17 +61898,14 @@ var generateMajorValuesForMinor = (minor, domain, width) => {
|
|
|
61937
61898
|
return out;
|
|
61938
61899
|
};
|
|
61939
61900
|
|
|
61940
|
-
|
|
61941
|
-
|
|
61942
|
-
|
|
61901
|
+
const buildTickData = (domain, width, ticks, opts) => {
|
|
61902
|
+
const result = buildTickDataAsFractions(domain, width, ticks, opts);
|
|
61903
|
+
const out = result.map(o => opts.fraction ? o : _extends$7({}, o, {
|
|
61943
61904
|
x: number(o.x) || 0
|
|
61944
61905
|
}));
|
|
61945
61906
|
return out;
|
|
61946
61907
|
};
|
|
61947
61908
|
|
|
61948
|
-
function ownKeys$1(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; }
|
|
61949
|
-
|
|
61950
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
61951
61909
|
/*
|
|
61952
61910
|
* This function is duplicated in configure/main.js
|
|
61953
61911
|
* This function will update major value whenever minor value is changed or tick type is changed
|
|
@@ -61955,16 +61913,16 @@ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) {
|
|
|
61955
61913
|
* @return graph object with updated ticks values
|
|
61956
61914
|
* */
|
|
61957
61915
|
|
|
61958
|
-
|
|
61959
|
-
|
|
61916
|
+
const updateMajorValue = graph => {
|
|
61917
|
+
const {
|
|
61960
61918
|
domain,
|
|
61961
61919
|
ticks,
|
|
61962
61920
|
width
|
|
61963
61921
|
} = graph;
|
|
61964
|
-
|
|
61922
|
+
const majorValues = generateMajorValuesForMinor(ticks.minor, domain, width);
|
|
61965
61923
|
|
|
61966
61924
|
if (majorValues.decimal.indexOf(ticks.major) === -1) {
|
|
61967
|
-
|
|
61925
|
+
let currIndex = 0;
|
|
61968
61926
|
|
|
61969
61927
|
if (ticks.tickIntervalType === 'Integer') {
|
|
61970
61928
|
currIndex = majorValues.decimal.length > 4 ? 4 : majorValues.decimal.length - 1;
|
|
@@ -61976,7 +61934,7 @@ var updateMajorValue = graph => {
|
|
|
61976
61934
|
}
|
|
61977
61935
|
|
|
61978
61936
|
graph.fraction = ticks.tickIntervalType === 'Fraction' && ticks.major < 1;
|
|
61979
|
-
return
|
|
61937
|
+
return _extends$7({}, graph, {
|
|
61980
61938
|
ticks
|
|
61981
61939
|
});
|
|
61982
61940
|
};
|
|
@@ -61989,8 +61947,8 @@ var updateMajorValue = graph => {
|
|
|
61989
61947
|
* */
|
|
61990
61948
|
|
|
61991
61949
|
|
|
61992
|
-
|
|
61993
|
-
|
|
61950
|
+
const reloadTicksData = graph => {
|
|
61951
|
+
const {
|
|
61994
61952
|
domain,
|
|
61995
61953
|
ticks = {},
|
|
61996
61954
|
width
|
|
@@ -62006,7 +61964,7 @@ var reloadTicksData = graph => {
|
|
|
62006
61964
|
// to different tick types object
|
|
62007
61965
|
|
|
62008
61966
|
|
|
62009
|
-
|
|
61967
|
+
const minorLimits = getMinorLimits(domain, width);
|
|
62010
61968
|
|
|
62011
61969
|
if (minorLimits.min >= 1) {
|
|
62012
61970
|
/*
|
|
@@ -62025,37 +61983,36 @@ var reloadTicksData = graph => {
|
|
|
62025
61983
|
ticks.tickIntervalType = 'Fraction';
|
|
62026
61984
|
}
|
|
62027
61985
|
|
|
62028
|
-
|
|
62029
|
-
|
|
62030
|
-
|
|
62031
|
-
var maxValue = number(fraction$1(_minorValues.fraction[_minorValues.fraction.length - 1]));
|
|
61986
|
+
const minorValues = generateMinorValues(minorLimits);
|
|
61987
|
+
let minValue = number(fraction$1(minorValues.fraction[0]));
|
|
61988
|
+
let maxValue = number(fraction$1(minorValues.fraction[minorValues.fraction.length - 1]));
|
|
62032
61989
|
|
|
62033
61990
|
if (ticks.minor < minValue || ticks.minor > maxValue) {
|
|
62034
61991
|
switch (ticks.tickIntervalType) {
|
|
62035
61992
|
case 'Fraction':
|
|
62036
|
-
ticks.minor = number(fraction$1(
|
|
62037
|
-
ticks.fractionTick =
|
|
62038
|
-
ticks.decimalTick =
|
|
61993
|
+
ticks.minor = number(fraction$1(minorValues.fraction[minorValues.fraction.length - 1]));
|
|
61994
|
+
ticks.fractionTick = minorValues.fraction[minorValues.fraction.length - 1];
|
|
61995
|
+
ticks.decimalTick = minorValues.decimal[0];
|
|
62039
61996
|
break;
|
|
62040
61997
|
|
|
62041
61998
|
case 'Decimal':
|
|
62042
61999
|
case 'Integer':
|
|
62043
|
-
ticks.minor =
|
|
62044
|
-
ticks.decimalTick =
|
|
62045
|
-
ticks.fractionTick =
|
|
62000
|
+
ticks.minor = minorValues.decimal[minorValues.decimal.length - 1];
|
|
62001
|
+
ticks.decimalTick = minorValues.decimal[minorValues.decimal.length - 1];
|
|
62002
|
+
ticks.fractionTick = minorValues.fraction[0];
|
|
62046
62003
|
}
|
|
62047
62004
|
} else {
|
|
62048
62005
|
switch (ticks.tickIntervalType) {
|
|
62049
62006
|
case 'Fraction':
|
|
62050
|
-
|
|
62007
|
+
let fraction = fraction$1(number(ticks.minor));
|
|
62051
62008
|
ticks.fractionTick = fraction.n + '/' + fraction.d;
|
|
62052
|
-
ticks.decimalTick = ticks.decimalTick ? ticks.decimalTick :
|
|
62009
|
+
ticks.decimalTick = ticks.decimalTick ? ticks.decimalTick : minorValues.decimal[0];
|
|
62053
62010
|
break;
|
|
62054
62011
|
|
|
62055
62012
|
case 'Decimal':
|
|
62056
62013
|
case 'Integer':
|
|
62057
62014
|
ticks.decimalTick = ticks.minor;
|
|
62058
|
-
ticks.fractionTick = ticks.fractionTick ? ticks.fractionTick :
|
|
62015
|
+
ticks.fractionTick = ticks.fractionTick ? ticks.fractionTick : minorValues.fraction[0];
|
|
62059
62016
|
}
|
|
62060
62017
|
}
|
|
62061
62018
|
|
|
@@ -62064,7 +62021,7 @@ var reloadTicksData = graph => {
|
|
|
62064
62021
|
/*
|
|
62065
62022
|
* In this scenario all integer, decimal or fraction tick will be enabled
|
|
62066
62023
|
* */
|
|
62067
|
-
|
|
62024
|
+
const minorValues = generateMinorValues(minorLimits);
|
|
62068
62025
|
|
|
62069
62026
|
if (!(ticks.minor >= minorLimits.min && ticks.minor <= minorLimits.max)) {
|
|
62070
62027
|
if (minorLimits.min > 0.5) {
|
|
@@ -62075,58 +62032,52 @@ var reloadTicksData = graph => {
|
|
|
62075
62032
|
case 'Integer':
|
|
62076
62033
|
ticks.minor = number(ceil(minorLimits.min));
|
|
62077
62034
|
ticks.integerTick = ticks.minor;
|
|
62078
|
-
ticks.decimalTick = minorLimits.min > 0.5 ? 0 :
|
|
62079
|
-
ticks.fractionTick = minorLimits.min > 0.5 ? '0' :
|
|
62035
|
+
ticks.decimalTick = minorLimits.min > 0.5 ? 0 : minorValues.decimal[0];
|
|
62036
|
+
ticks.fractionTick = minorLimits.min > 0.5 ? '0' : minorValues.fraction[0];
|
|
62080
62037
|
break;
|
|
62081
62038
|
|
|
62082
62039
|
case 'Decimal':
|
|
62083
|
-
ticks.minor =
|
|
62040
|
+
ticks.minor = minorValues.decimal[0];
|
|
62084
62041
|
ticks.integerTick = 1;
|
|
62085
62042
|
ticks.decimalTick = ticks.minor;
|
|
62086
|
-
ticks.fractionTick =
|
|
62043
|
+
ticks.fractionTick = minorValues.fraction[0];
|
|
62087
62044
|
break;
|
|
62088
62045
|
|
|
62089
62046
|
case 'Fraction':
|
|
62090
|
-
ticks.minor = number(fraction$1(
|
|
62047
|
+
ticks.minor = number(fraction$1(minorValues.fraction[0]));
|
|
62091
62048
|
ticks.integerTick = 1;
|
|
62092
|
-
ticks.decimalTick =
|
|
62093
|
-
ticks.fractionTick =
|
|
62049
|
+
ticks.decimalTick = minorValues.decimal[0];
|
|
62050
|
+
ticks.fractionTick = minorValues.fraction[0];
|
|
62094
62051
|
}
|
|
62095
62052
|
} else {
|
|
62096
62053
|
switch (ticks.tickIntervalType) {
|
|
62097
62054
|
case 'Integer':
|
|
62098
62055
|
ticks.integerTick = ticks.minor;
|
|
62099
|
-
ticks.decimalTick = minorLimits.min > 0.5 ? 0 :
|
|
62100
|
-
ticks.fractionTick = minorLimits.min > 0.5 ? '0' :
|
|
62056
|
+
ticks.decimalTick = minorLimits.min > 0.5 ? 0 : minorValues.decimal[0];
|
|
62057
|
+
ticks.fractionTick = minorLimits.min > 0.5 ? '0' : minorValues.fraction[0];
|
|
62101
62058
|
break;
|
|
62102
62059
|
|
|
62103
62060
|
case 'Decimal':
|
|
62104
62061
|
ticks.integerTick = 1;
|
|
62105
62062
|
ticks.decimalTick = ticks.minor;
|
|
62106
|
-
ticks.fractionTick =
|
|
62063
|
+
ticks.fractionTick = minorValues.fraction[0];
|
|
62107
62064
|
break;
|
|
62108
62065
|
|
|
62109
62066
|
case 'Fraction':
|
|
62110
62067
|
ticks.integerTick = 1;
|
|
62111
|
-
ticks.decimalTick =
|
|
62112
|
-
|
|
62113
|
-
|
|
62114
|
-
|
|
62115
|
-
ticks.fractionTick = _fraction.n + '/' + _fraction.d;
|
|
62068
|
+
ticks.decimalTick = minorValues.decimal[0];
|
|
62069
|
+
let fraction = fraction$1(number(ticks.minor));
|
|
62070
|
+
ticks.fractionTick = fraction.n + '/' + fraction.d;
|
|
62116
62071
|
}
|
|
62117
62072
|
}
|
|
62118
62073
|
}
|
|
62119
62074
|
|
|
62120
|
-
return updateMajorValue(
|
|
62075
|
+
return updateMajorValue(_extends$7({}, graph, {
|
|
62121
62076
|
ticks
|
|
62122
62077
|
}));
|
|
62123
62078
|
};
|
|
62124
62079
|
|
|
62125
|
-
|
|
62126
|
-
|
|
62127
|
-
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) { _defineProperty$2(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; }
|
|
62128
|
-
|
|
62129
|
-
var score = number => {
|
|
62080
|
+
const score = number => {
|
|
62130
62081
|
return {
|
|
62131
62082
|
score: {
|
|
62132
62083
|
scaled: number
|
|
@@ -62134,11 +62085,11 @@ var score = number => {
|
|
|
62134
62085
|
};
|
|
62135
62086
|
};
|
|
62136
62087
|
|
|
62137
|
-
|
|
62138
|
-
|
|
62088
|
+
const getPartialScore = (corrected, ps) => {
|
|
62089
|
+
const {
|
|
62139
62090
|
correct
|
|
62140
62091
|
} = corrected;
|
|
62141
|
-
|
|
62092
|
+
const rule = ps.find(r => r.numberOfCorrect === correct.length);
|
|
62142
62093
|
|
|
62143
62094
|
if (rule) {
|
|
62144
62095
|
return 1.0 * (rule.scorePercentage / 100);
|
|
@@ -62147,8 +62098,8 @@ var getPartialScore = (corrected, ps) => {
|
|
|
62147
62098
|
}
|
|
62148
62099
|
};
|
|
62149
62100
|
|
|
62150
|
-
|
|
62151
|
-
|
|
62101
|
+
const accumulateAnswer = correctResponse => (total, answer) => {
|
|
62102
|
+
const isCorrectResponse = correctResponse.some(cr => matches(cr)(answer));
|
|
62152
62103
|
return total + (isCorrectResponse ? 1 : 0);
|
|
62153
62104
|
};
|
|
62154
62105
|
/**
|
|
@@ -62163,10 +62114,10 @@ function outcome(model, session, env) {
|
|
|
62163
62114
|
empty: true
|
|
62164
62115
|
});
|
|
62165
62116
|
} else {
|
|
62166
|
-
|
|
62167
|
-
|
|
62168
|
-
|
|
62169
|
-
|
|
62117
|
+
const partialScoringEnabled = partialScoring.enabled(model, env);
|
|
62118
|
+
const numCorrect = (session.answer || []).reduce(accumulateAnswer(model.correctResponse), 0);
|
|
62119
|
+
let total = model.correctResponse.length;
|
|
62120
|
+
let numIncorrect = 0;
|
|
62170
62121
|
|
|
62171
62122
|
if ((session.answer || []).length > total) {
|
|
62172
62123
|
numIncorrect = (session.answer || []).length - total;
|
|
@@ -62176,14 +62127,14 @@ function outcome(model, session, env) {
|
|
|
62176
62127
|
total = 1;
|
|
62177
62128
|
}
|
|
62178
62129
|
|
|
62179
|
-
|
|
62130
|
+
let score = numCorrect < 0 ? 0 : (numCorrect - numIncorrect) / total;
|
|
62180
62131
|
|
|
62181
|
-
if (
|
|
62182
|
-
|
|
62132
|
+
if (score < 0) {
|
|
62133
|
+
score = 0;
|
|
62183
62134
|
}
|
|
62184
62135
|
|
|
62185
62136
|
resolve({
|
|
62186
|
-
score: partialScoringEnabled ?
|
|
62137
|
+
score: partialScoringEnabled ? score : score === 1 ? 1 : 0
|
|
62187
62138
|
});
|
|
62188
62139
|
}
|
|
62189
62140
|
});
|
|
@@ -62198,22 +62149,20 @@ function getScore(question, session) {
|
|
|
62198
62149
|
});
|
|
62199
62150
|
} else {
|
|
62200
62151
|
session.answer = session.answer || [];
|
|
62201
|
-
|
|
62202
|
-
|
|
62152
|
+
const corrected = getCorrected(session.answer, cloneDeep(question.correctResponse));
|
|
62153
|
+
const correctness = getCorrectness(corrected);
|
|
62203
62154
|
|
|
62204
62155
|
if (correctness === 'correct') {
|
|
62205
62156
|
resolve(score(1.0));
|
|
62206
62157
|
} else if (correctness === 'incorrect') {
|
|
62207
62158
|
resolve(score(0.0));
|
|
62208
62159
|
} else if (correctness === 'partial') {
|
|
62209
|
-
|
|
62160
|
+
const {
|
|
62210
62161
|
allowPartialScoring,
|
|
62211
|
-
partialScoring
|
|
62162
|
+
partialScoring
|
|
62212
62163
|
} = question;
|
|
62213
|
-
|
|
62214
|
-
|
|
62215
|
-
|
|
62216
|
-
var canDoPartialScoring = allowPartialScoring && ps.length > 0;
|
|
62164
|
+
const ps = (partialScoring || []).filter(o => !isEmpty(o));
|
|
62165
|
+
const canDoPartialScoring = allowPartialScoring && ps.length > 0;
|
|
62217
62166
|
|
|
62218
62167
|
if (canDoPartialScoring) {
|
|
62219
62168
|
resolve(score(getPartialScore(corrected, ps)));
|
|
@@ -62230,16 +62179,16 @@ function getScore(question, session) {
|
|
|
62230
62179
|
}
|
|
62231
62180
|
});
|
|
62232
62181
|
}
|
|
62233
|
-
|
|
62234
|
-
|
|
62182
|
+
const CLOSE_TO_PRECISION = 3;
|
|
62183
|
+
const closeTo = (a, b, precision) => {
|
|
62235
62184
|
precision = precision || 5;
|
|
62236
|
-
|
|
62237
|
-
|
|
62238
|
-
|
|
62185
|
+
const expectedDiff = Math.pow(10, -precision) / 2;
|
|
62186
|
+
const receivedDiff = Math.abs(a - b);
|
|
62187
|
+
const close = receivedDiff <= expectedDiff;
|
|
62239
62188
|
return close;
|
|
62240
62189
|
};
|
|
62241
62190
|
|
|
62242
|
-
|
|
62191
|
+
const matches = a => v => {
|
|
62243
62192
|
return isEqualWith(a, v, (v, ov) => {
|
|
62244
62193
|
if (typeof v === 'number' && typeof ov === 'number') {
|
|
62245
62194
|
return closeTo(v, ov, CLOSE_TO_PRECISION);
|
|
@@ -62247,7 +62196,7 @@ var matches = a => v => {
|
|
|
62247
62196
|
});
|
|
62248
62197
|
};
|
|
62249
62198
|
|
|
62250
|
-
|
|
62199
|
+
const getCorrected = (answer, correctResponse) => {
|
|
62251
62200
|
if (isEmpty(correctResponse) && answer.length > 0) {
|
|
62252
62201
|
return {
|
|
62253
62202
|
correct: [],
|
|
@@ -62258,12 +62207,12 @@ var getCorrected = (answer, correctResponse) => {
|
|
|
62258
62207
|
}
|
|
62259
62208
|
|
|
62260
62209
|
return answer.reduce((acc, a, index) => {
|
|
62261
|
-
|
|
62210
|
+
const {
|
|
62262
62211
|
correct,
|
|
62263
62212
|
incorrect,
|
|
62264
62213
|
notInAnswer
|
|
62265
62214
|
} = acc;
|
|
62266
|
-
|
|
62215
|
+
const match = find(notInAnswer, matches(a));
|
|
62267
62216
|
|
|
62268
62217
|
if (match) {
|
|
62269
62218
|
correct.push(index);
|
|
@@ -62283,8 +62232,8 @@ var getCorrected = (answer, correctResponse) => {
|
|
|
62283
62232
|
notInAnswer: correctResponse
|
|
62284
62233
|
});
|
|
62285
62234
|
};
|
|
62286
|
-
|
|
62287
|
-
|
|
62235
|
+
const getCorrectness = corrected => {
|
|
62236
|
+
const {
|
|
62288
62237
|
incorrect,
|
|
62289
62238
|
correct,
|
|
62290
62239
|
notInAnswer,
|
|
@@ -62319,16 +62268,15 @@ var getCorrectness = corrected => {
|
|
|
62319
62268
|
*/
|
|
62320
62269
|
|
|
62321
62270
|
function normalize(question) {
|
|
62322
|
-
|
|
62323
|
-
return
|
|
62271
|
+
const feedback = merge(defaults.feedback, question.feedback);
|
|
62272
|
+
return _extends$7({}, defaults, question, {
|
|
62324
62273
|
feedback
|
|
62325
62274
|
});
|
|
62326
62275
|
}
|
|
62327
|
-
function createDefaultModel() {
|
|
62328
|
-
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
62276
|
+
function createDefaultModel(model = {}) {
|
|
62329
62277
|
return new Promise(resolve => {
|
|
62330
|
-
|
|
62331
|
-
graph:
|
|
62278
|
+
const out = _extends$7({}, model, {
|
|
62279
|
+
graph: _extends$7({}, defaults.graph, model.graph),
|
|
62332
62280
|
colorContrast: 'black_on_white'
|
|
62333
62281
|
});
|
|
62334
62282
|
|
|
@@ -62336,15 +62284,15 @@ function createDefaultModel() {
|
|
|
62336
62284
|
});
|
|
62337
62285
|
} // this function is duplicated in configure; at some point, use the same shared function
|
|
62338
62286
|
|
|
62339
|
-
|
|
62340
|
-
|
|
62287
|
+
const updateTicks = model => {
|
|
62288
|
+
const {
|
|
62341
62289
|
graph: {
|
|
62342
62290
|
domain,
|
|
62343
62291
|
labelStep,
|
|
62344
62292
|
ticks = {}
|
|
62345
62293
|
} = {}
|
|
62346
62294
|
} = model;
|
|
62347
|
-
|
|
62295
|
+
const {
|
|
62348
62296
|
minor,
|
|
62349
62297
|
major
|
|
62350
62298
|
} = ticks;
|
|
@@ -62358,7 +62306,7 @@ var updateTicks = model => {
|
|
|
62358
62306
|
model.graph.fraction = true;
|
|
62359
62307
|
ticks.tickIntervalType = 'Fraction'; // update the ticks frequency and label value to match the label step if needed
|
|
62360
62308
|
|
|
62361
|
-
|
|
62309
|
+
const step = evaluate(labelStep);
|
|
62362
62310
|
|
|
62363
62311
|
if (step !== major) {
|
|
62364
62312
|
ticks.major = step;
|
|
@@ -62374,61 +62322,55 @@ function model(question, session, env) {
|
|
|
62374
62322
|
return Promise.reject(new Error('question is null'));
|
|
62375
62323
|
}
|
|
62376
62324
|
|
|
62377
|
-
return new Promise(
|
|
62378
|
-
|
|
62379
|
-
|
|
62380
|
-
|
|
62381
|
-
|
|
62382
|
-
|
|
62383
|
-
|
|
62384
|
-
|
|
62385
|
-
|
|
62386
|
-
|
|
62387
|
-
|
|
62388
|
-
|
|
62389
|
-
|
|
62390
|
-
|
|
62391
|
-
|
|
62392
|
-
|
|
62393
|
-
|
|
62394
|
-
|
|
62395
|
-
|
|
62396
|
-
|
|
62397
|
-
|
|
62398
|
-
|
|
62399
|
-
|
|
62400
|
-
|
|
62401
|
-
|
|
62402
|
-
|
|
62403
|
-
|
|
62404
|
-
|
|
62405
|
-
|
|
62406
|
-
|
|
62407
|
-
|
|
62408
|
-
|
|
62409
|
-
|
|
62410
|
-
|
|
62411
|
-
|
|
62412
|
-
|
|
62413
|
-
|
|
62414
|
-
|
|
62415
|
-
|
|
62416
|
-
|
|
62417
|
-
|
|
62418
|
-
|
|
62419
|
-
|
|
62420
|
-
|
|
62421
|
-
});
|
|
62422
|
-
|
|
62423
|
-
return function (_x, _x2) {
|
|
62424
|
-
return _ref.apply(this, arguments);
|
|
62425
|
-
};
|
|
62426
|
-
}());
|
|
62325
|
+
return new Promise(async (resolve, reject) => {
|
|
62326
|
+
const normalizedQuestion = await normalize(question);
|
|
62327
|
+
const normalizedModel = updateTicks(normalizedQuestion); // this function is also called in configure, it is a duplicate to maintain consistency and correctness
|
|
62328
|
+
|
|
62329
|
+
const graph = reloadTicksData(normalizedModel.graph);
|
|
62330
|
+
|
|
62331
|
+
if (graph) {
|
|
62332
|
+
const evaluateMode = env.mode === 'evaluate';
|
|
62333
|
+
const correctResponse = cloneDeep(normalizedQuestion.correctResponse);
|
|
62334
|
+
const corrected = evaluateMode && getCorrected(session ? session.answer || [] : [], correctResponse);
|
|
62335
|
+
const correctness = evaluateMode && getCorrectness(corrected);
|
|
62336
|
+
const {
|
|
62337
|
+
exhibitOnly
|
|
62338
|
+
} = graph;
|
|
62339
|
+
const disabled = env.mode !== 'gather' || exhibitOnly === true;
|
|
62340
|
+
let teacherInstructions = null;
|
|
62341
|
+
|
|
62342
|
+
if (env.role === 'instructor' && (env.mode === 'view' || evaluateMode)) {
|
|
62343
|
+
teacherInstructions = normalizedQuestion.teacherInstructions;
|
|
62344
|
+
}
|
|
62345
|
+
|
|
62346
|
+
const fb = evaluateMode ? getFeedbackForCorrectness(correctness, normalizedQuestion.feedback) : Promise.resolve(undefined);
|
|
62347
|
+
fb.then(feedbackMessage => {
|
|
62348
|
+
const out = {
|
|
62349
|
+
prompt: normalizedQuestion.prompt,
|
|
62350
|
+
teacherInstructions,
|
|
62351
|
+
graph,
|
|
62352
|
+
disabled,
|
|
62353
|
+
corrected,
|
|
62354
|
+
correctResponse: evaluateMode && ['unanswered', 'correct'].indexOf(correctness) === -1 && normalizedQuestion.correctResponse,
|
|
62355
|
+
feedback: feedbackMessage && {
|
|
62356
|
+
type: correctness,
|
|
62357
|
+
message: feedbackMessage
|
|
62358
|
+
},
|
|
62359
|
+
colorContrast: env.accessibility && env.accessibility.colorContrast || 'black_on_white',
|
|
62360
|
+
language: normalizedQuestion.language,
|
|
62361
|
+
extraCSSRules: normalizedQuestion.extraCSSRules
|
|
62362
|
+
};
|
|
62363
|
+
resolve(omitBy(out, v => !v));
|
|
62364
|
+
});
|
|
62365
|
+
} else {
|
|
62366
|
+
reject(new Error('graph is undefined'));
|
|
62367
|
+
}
|
|
62368
|
+
});
|
|
62427
62369
|
}
|
|
62428
|
-
|
|
62370
|
+
const createCorrectResponseSession = (question, env) => {
|
|
62429
62371
|
return new Promise(resolve => {
|
|
62430
62372
|
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
62431
|
-
|
|
62373
|
+
const {
|
|
62432
62374
|
correctResponse: answer
|
|
62433
62375
|
} = question;
|
|
62434
62376
|
resolve({
|
|
@@ -62442,49 +62384,47 @@ var createCorrectResponseSession = (question, env) => {
|
|
|
62442
62384
|
}; // remove all html tags
|
|
62443
62385
|
|
|
62444
62386
|
|
|
62445
|
-
|
|
62387
|
+
const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
62446
62388
|
|
|
62447
|
-
|
|
62448
|
-
|
|
62449
|
-
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
62450
|
-
var {
|
|
62389
|
+
const validate = (model = {}, config = {}) => {
|
|
62390
|
+
const {
|
|
62451
62391
|
graph,
|
|
62452
62392
|
correctResponse
|
|
62453
62393
|
} = model || {};
|
|
62454
|
-
|
|
62394
|
+
const {
|
|
62455
62395
|
maxMaxElements = 20,
|
|
62456
62396
|
numberLineDimensions: {
|
|
62457
62397
|
min: minWidth = 200,
|
|
62458
62398
|
max: maxWidth = 800
|
|
62459
62399
|
} = {}
|
|
62460
62400
|
} = config || {};
|
|
62461
|
-
|
|
62401
|
+
const {
|
|
62462
62402
|
width,
|
|
62463
62403
|
domain,
|
|
62464
62404
|
maxNumberOfPoints
|
|
62465
62405
|
} = graph || {};
|
|
62466
|
-
|
|
62406
|
+
const {
|
|
62467
62407
|
min,
|
|
62468
62408
|
max
|
|
62469
62409
|
} = domain || {};
|
|
62470
|
-
|
|
62410
|
+
const errors = {};
|
|
62471
62411
|
['teacherInstructions', 'prompt'].forEach(field => {
|
|
62472
62412
|
var _config$field;
|
|
62473
62413
|
|
|
62474
|
-
if ((_config$field = config[field])
|
|
62414
|
+
if ((_config$field = config[field]) != null && _config$field.required && !getContent(model[field])) {
|
|
62475
62415
|
errors[field] = 'This field is required.';
|
|
62476
62416
|
}
|
|
62477
62417
|
});
|
|
62478
62418
|
|
|
62479
62419
|
if (width < minWidth || width > maxWidth) {
|
|
62480
|
-
errors.widthError =
|
|
62420
|
+
errors.widthError = `Width should be a value between ${minWidth} and ${maxWidth}.`;
|
|
62481
62421
|
}
|
|
62482
62422
|
|
|
62483
|
-
|
|
62484
|
-
|
|
62423
|
+
const MIN_DOMAIN = -100000;
|
|
62424
|
+
const MAX_DOMAIN = 100000;
|
|
62485
62425
|
|
|
62486
62426
|
if (min < MIN_DOMAIN || min > MAX_DOMAIN || max < MIN_DOMAIN || max > MAX_DOMAIN) {
|
|
62487
|
-
errors.domainError =
|
|
62427
|
+
errors.domainError = `Min and max values must both be in the range [${MIN_DOMAIN}, ${MAX_DOMAIN}].`;
|
|
62488
62428
|
}
|
|
62489
62429
|
|
|
62490
62430
|
if (min >= max) {
|
|
@@ -62492,7 +62432,7 @@ var validate = function validate() {
|
|
|
62492
62432
|
}
|
|
62493
62433
|
|
|
62494
62434
|
if (maxNumberOfPoints < 1 || maxNumberOfPoints > maxMaxElements) {
|
|
62495
|
-
errors.pointsError =
|
|
62435
|
+
errors.pointsError = `Max number of elements should be between 1 and ${maxMaxElements}.`;
|
|
62496
62436
|
}
|
|
62497
62437
|
|
|
62498
62438
|
if (correctResponse && correctResponse.length === 0) {
|