@pie-element/charting 5.6.1-beta.0 → 5.6.1-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/configure/package.json +2 -2
- package/package.json +2 -2
- package/configure/lib/charting-config.js +0 -236
- package/configure/lib/charting-config.js.map +0 -1
- package/configure/lib/configure.js +0 -340
- package/configure/lib/configure.js.map +0 -1
- package/configure/lib/correct-response.js +0 -324
- package/configure/lib/correct-response.js.map +0 -1
- package/configure/lib/defaults.js +0 -118
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -149
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/utils.js +0 -95
- package/configure/lib/utils.js.map +0 -1
- package/controller/lib/defaults.js +0 -15
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -357
- package/controller/lib/index.js.map +0 -1
- package/lib/index.js +0 -115
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -197
- package/lib/main.js.map +0 -1
package/configure/lib/index.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
|
|
20
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
27
|
-
|
|
28
|
-
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
29
|
-
|
|
30
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
31
|
-
|
|
32
|
-
var _configure = _interopRequireDefault(require("./configure"));
|
|
33
|
-
|
|
34
|
-
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
35
|
-
|
|
36
|
-
var _mathRendering = require("@pie-lib/math-rendering");
|
|
37
|
-
|
|
38
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
-
|
|
40
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
|
-
|
|
42
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
43
|
-
|
|
44
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
|
-
|
|
46
|
-
var log = (0, _debug["default"])('pie-elements:graphing:configure');
|
|
47
|
-
|
|
48
|
-
var GraphLinesConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
49
|
-
(0, _inherits2["default"])(GraphLinesConfigure, _HTMLElement);
|
|
50
|
-
|
|
51
|
-
var _super = _createSuper(GraphLinesConfigure);
|
|
52
|
-
|
|
53
|
-
function GraphLinesConfigure() {
|
|
54
|
-
var _this;
|
|
55
|
-
|
|
56
|
-
(0, _classCallCheck2["default"])(this, GraphLinesConfigure);
|
|
57
|
-
_this = _super.call(this);
|
|
58
|
-
_this._model = GraphLinesConfigure.createDefaultModel();
|
|
59
|
-
_this._configuration = _defaults["default"].configuration;
|
|
60
|
-
return _this;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
(0, _createClass2["default"])(GraphLinesConfigure, [{
|
|
64
|
-
key: "model",
|
|
65
|
-
set: function set(m) {
|
|
66
|
-
this._model = GraphLinesConfigure.createDefaultModel(m);
|
|
67
|
-
|
|
68
|
-
this._render();
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "configuration",
|
|
72
|
-
set: function set(c) {
|
|
73
|
-
this._configuration = c;
|
|
74
|
-
|
|
75
|
-
this._render();
|
|
76
|
-
}
|
|
77
|
-
}, {
|
|
78
|
-
key: "onModelChanged",
|
|
79
|
-
value: function onModelChanged(model) {
|
|
80
|
-
this._model = model;
|
|
81
|
-
|
|
82
|
-
this._render();
|
|
83
|
-
|
|
84
|
-
log('[onModelChanged]: ', this._model);
|
|
85
|
-
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model));
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "onConfigurationChanged",
|
|
89
|
-
value: function onConfigurationChanged(config) {
|
|
90
|
-
this._configuration = config;
|
|
91
|
-
|
|
92
|
-
this._render();
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
key: "insertImage",
|
|
96
|
-
value: function insertImage(handler) {
|
|
97
|
-
this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "onDeleteImage",
|
|
101
|
-
value: function onDeleteImage(src, done) {
|
|
102
|
-
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "insertSound",
|
|
106
|
-
value: function insertSound(handler) {
|
|
107
|
-
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "onDeleteSound",
|
|
111
|
-
value: function onDeleteSound(src, done) {
|
|
112
|
-
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "_render",
|
|
116
|
-
value: function _render() {
|
|
117
|
-
var _this2 = this;
|
|
118
|
-
|
|
119
|
-
if (this._model) {
|
|
120
|
-
var el = /*#__PURE__*/_react["default"].createElement(_configure["default"], {
|
|
121
|
-
onModelChanged: this.onModelChanged.bind(this),
|
|
122
|
-
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
123
|
-
model: this._model,
|
|
124
|
-
configuration: this._configuration,
|
|
125
|
-
imageSupport: {
|
|
126
|
-
add: this.insertImage.bind(this),
|
|
127
|
-
"delete": this.onDeleteImage.bind(this)
|
|
128
|
-
},
|
|
129
|
-
uploadSoundSupport: {
|
|
130
|
-
add: this.insertSound.bind(this),
|
|
131
|
-
"delete": this.onDeleteSound.bind(this)
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
_reactDom["default"].render(el, this, function () {
|
|
136
|
-
(0, _mathRendering.renderMath)(_this2);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}]);
|
|
141
|
-
return GraphLinesConfigure;
|
|
142
|
-
}( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
|
|
143
|
-
|
|
144
|
-
exports["default"] = GraphLinesConfigure;
|
|
145
|
-
(0, _defineProperty2["default"])(GraphLinesConfigure, "createDefaultModel", function () {
|
|
146
|
-
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
147
|
-
return _objectSpread(_objectSpread({}, _defaults["default"].model), model);
|
|
148
|
-
});
|
|
149
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","GraphLinesConfigure","_model","createDefaultModel","_configuration","defaultValues","configuration","m","_render","c","model","dispatchEvent","ModelUpdatedEvent","config","handler","InsertImageEvent","src","done","DeleteImageEvent","InsertSoundEvent","DeleteSoundEvent","el","React","createElement","Configure","onModelChanged","bind","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;;IAEqBC,mB;;;;;AAGnB,iCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAcD,mBAAmB,CAACE,kBAApB,EAAd;AACA,UAAKC,cAAL,GAAsBC,qBAAcC,aAApC;AAHY;AAIb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKL,MAAL,GAAcD,mBAAmB,CAACE,kBAApB,CAA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Aa,EAAE,KAAKF,cAJoB;AAKxCwB,UAAAA,YAAY,EAAE;AACZC,YAAAA,GAAG,EAAE,KAAKC,WAAL,CAAiBJ,IAAjB,CAAsB,IAAtB,CADO;AAEZ,sBAAQ,KAAKK,aAAL,CAAmBL,IAAnB,CAAwB,IAAxB;AAFI,WAL0B;AASxCM,UAAAA,kBAAkB,EAAE;AAClBH,YAAAA,GAAG,EAAE,KAAKI,WAAL,CAAiBP,IAAjB,CAAsB,IAAtB,CADa;AAElB,sBAAQ,KAAKQ,aAAL,CAAmBR,IAAnB,CAAwB,IAAxB;AAFU;AAToB,SAA/B,CAAX;;AAeAS,6BAASC,MAAT,CAAgBf,EAAhB,EAAoB,IAApB,EAA0B,YAAM;AAC9B,yCAAW,MAAX;AACD,SAFD;AAGD;AACF;;;kDAtE8CgB,W;;;iCAA5BpC,mB,wBACS;AAAA,MAACS,KAAD,uEAAS,EAAT;AAAA,yCAAsBL,qBAAcK,KAApC,GAA8CA,KAA9C;AAAA,C","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport debug from 'debug';\nimport Configure from './configure';\nimport defaultValues from './defaults';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst log = debug('pie-elements:graphing:configure');\n\nexport default class GraphLinesConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({ ...defaultValues.model, ...model });\n\n constructor() {\n super();\n this._model = GraphLinesConfigure.createDefaultModel();\n this._configuration = defaultValues.configuration;\n }\n\n set model(m) {\n this._model = GraphLinesConfigure.createDefaultModel(m);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = c;\n this._render();\n }\n\n onModelChanged(model) {\n this._model = model;\n this._render();\n\n log('[onModelChanged]: ', this._model);\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model));\n }\n\n onConfigurationChanged(config) {\n this._configuration = config;\n this._render();\n }\n\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _render() {\n if (this._model) {\n const el = React.createElement(Configure, {\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n model: this._model,\n configuration: this._configuration,\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n ReactDOM.render(el, this, () => {\n renderMath(this);\n });\n }\n }\n}\n"],"file":"index.js"}
|
package/configure/lib/utils.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getLabelValues = exports.getGridValues = exports.applyConstraints = exports.VALID_LABEL_VALUES = void 0;
|
|
9
|
-
|
|
10
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
|
-
|
|
12
|
-
// this file is almost duplicated from graphing/configure/src/utils.js; the same logic must be used in charting
|
|
13
|
-
var VALID_GRID_VALUES = [0.01, 0.02, 0.04, 0.05, 0.0625, 0.1, 0.125, 0.2, 0.25, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500, 1000]; // same as VALID_GRID_VALUES but next values are excluded: 0.04, 0.0625, 0.125, 3, 4, 8, 12, 15, 40, 64
|
|
14
|
-
|
|
15
|
-
var PREFERRED_VALID_GRID_VALUES = [0.01, 0.02, 0.05, 0.1, 0.2, 0.25, 0.5, 1, 2, 5, 10, 20, 50, 100, 500, 1000];
|
|
16
|
-
var VALID_LABEL_VALUES = {
|
|
17
|
-
0.01: [0, 0.01, 0.02, 0.04, 0.05, 0.1],
|
|
18
|
-
0.02: [0, 0.02, 0.04, 0.1],
|
|
19
|
-
0.04: [0, 0.04, 0.08, 0.16, 0.2],
|
|
20
|
-
0.05: [0, 0.05, 0.1, 0.2, 0.25],
|
|
21
|
-
0.0625: [0, 0.0625, 0.125, 0.25, 0.5],
|
|
22
|
-
0.1: [0, 0.1, 0.2, 0.4, 0.5, 1],
|
|
23
|
-
0.125: [0, 0.125, 0.25, 0.5, 1],
|
|
24
|
-
0.2: [0, 0.2, 0.5, 0.1],
|
|
25
|
-
0.25: [0, 0.25, 0.5, 1, 2],
|
|
26
|
-
0.5: [0, 0.5, 1, 2],
|
|
27
|
-
1: [0, 1, 2, 4, 5, 10],
|
|
28
|
-
2: [0, 2, 4, 8, 10],
|
|
29
|
-
3: [0, 3, 6, 12, 15],
|
|
30
|
-
4: [0, 4, 8, 16, 20],
|
|
31
|
-
5: [0, 5, 10, 20, 25],
|
|
32
|
-
8: [0, 8, 16, 32, 40, 64],
|
|
33
|
-
10: [0, 10, 20, 40, 50, 100],
|
|
34
|
-
12: [0, 12, 24],
|
|
35
|
-
15: [0, 15, 30, 60],
|
|
36
|
-
20: [0, 20, 40, 80, 100],
|
|
37
|
-
40: [0, 40, 80, 160, 200],
|
|
38
|
-
50: [0, 50, 100, 200, 250],
|
|
39
|
-
64: [0, 64, 128],
|
|
40
|
-
100: [0, 100, 200, 400, 500],
|
|
41
|
-
500: [0, 500, 1000, 2500],
|
|
42
|
-
1000: [0, 1000, 2000, 4000, 5000]
|
|
43
|
-
};
|
|
44
|
-
exports.VALID_LABEL_VALUES = VALID_LABEL_VALUES;
|
|
45
|
-
|
|
46
|
-
var getGridValues = function getGridValues(axis, size) {
|
|
47
|
-
var prefferedValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
48
|
-
var minValue = 10 * (axis.max - axis.min) / size;
|
|
49
|
-
var maxValue = minValue * 10;
|
|
50
|
-
var values = prefferedValues ? PREFERRED_VALID_GRID_VALUES : VALID_GRID_VALUES;
|
|
51
|
-
return values.filter(function (value) {
|
|
52
|
-
return value >= minValue && value <= maxValue;
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
exports.getGridValues = getGridValues;
|
|
57
|
-
|
|
58
|
-
var getLabelValues = function getLabelValues(value) {
|
|
59
|
-
return VALID_LABEL_VALUES[value] || [];
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
exports.getLabelValues = getLabelValues;
|
|
63
|
-
|
|
64
|
-
var applyConstraints = function applyConstraints(axis, size, oldGridValues, oldLabelValues) {
|
|
65
|
-
var gridValues = getGridValues(axis, size);
|
|
66
|
-
var labelValues = getLabelValues(axis.step || 1);
|
|
67
|
-
|
|
68
|
-
if (!(0, _isEqual["default"])(oldGridValues, gridValues) && !gridValues.includes(axis.step)) {
|
|
69
|
-
var preferredValues = getGridValues(axis, size, true);
|
|
70
|
-
var lowestValue = preferredValues[0] || 1;
|
|
71
|
-
axis.step = lowestValue;
|
|
72
|
-
labelValues = getLabelValues(lowestValue);
|
|
73
|
-
|
|
74
|
-
if (!labelValues.includes(axis.labelStep)) {
|
|
75
|
-
axis.labelStep = lowestValue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
gridValues: gridValues,
|
|
80
|
-
labelValues: labelValues
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (!(0, _isEqual["default"])(oldLabelValues, labelValues) && !labelValues.includes(axis.labelStep)) {
|
|
85
|
-
axis.labelStep = axis.step;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
gridValues: gridValues,
|
|
90
|
-
labelValues: labelValues
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
exports.applyConstraints = applyConstraints;
|
|
95
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["VALID_GRID_VALUES","PREFERRED_VALID_GRID_VALUES","VALID_LABEL_VALUES","getGridValues","axis","size","prefferedValues","minValue","max","min","maxValue","values","filter","value","getLabelValues","applyConstraints","oldGridValues","oldLabelValues","gridValues","labelValues","step","includes","preferredValues","lowestValue","labelStep"],"mappings":";;;;;;;;;AACA;;AADA;AAGA,IAAMA,iBAAiB,GAAG,CACxB,IADwB,EAClB,IADkB,EACZ,IADY,EACN,IADM,EACA,MADA,EACQ,GADR,EACa,KADb,EACoB,GADpB,EACyB,IADzB,EAC+B,GAD/B,EACoC,CADpC,EACuC,CADvC,EAC0C,CAD1C,EAC6C,CAD7C,EACgD,CADhD,EACmD,CADnD,EACsD,EADtD,EAC0D,EAD1D,EAC8D,EAD9D,EACkE,EADlE,EACsE,EADtE,EAC0E,EAD1E,EAC8E,EAD9E,EACkF,GADlF,EACuF,GADvF,EAExB,IAFwB,CAA1B,C,CAKA;;AACA,IAAMC,2BAA2B,GAAG,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,GAAnB,EAAwB,GAAxB,EAA6B,IAA7B,EAAmC,GAAnC,EAAwC,CAAxC,EAA2C,CAA3C,EAA8C,CAA9C,EAAiD,EAAjD,EAAqD,EAArD,EAAyD,EAAzD,EAA6D,GAA7D,EAAkE,GAAlE,EAAuE,IAAvE,CAApC;AAEO,IAAMC,kBAAkB,GAAG;AAChC,QAAM,CAAC,CAAD,EAAI,IAAJ,EAAU,IAAV,EAAgB,IAAhB,EAAsB,IAAtB,EAA4B,GAA5B,CAD0B;AAEhC,QAAM,CAAC,CAAD,EAAI,IAAJ,EAAU,IAAV,EAAgB,GAAhB,CAF0B;AAGhC,QAAM,CAAC,CAAD,EAAI,IAAJ,EAAU,IAAV,EAAgB,IA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// this file is almost duplicated from graphing/configure/src/utils.js; the same logic must be used in charting\nimport isEqual from 'lodash/isEqual';\n\nconst VALID_GRID_VALUES = [\n 0.01, 0.02, 0.04, 0.05, 0.0625, 0.1, 0.125, 0.2, 0.25, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500,\n 1000,\n];\n\n// same as VALID_GRID_VALUES but next values are excluded: 0.04, 0.0625, 0.125, 3, 4, 8, 12, 15, 40, 64\nconst PREFERRED_VALID_GRID_VALUES = [0.01, 0.02, 0.05, 0.1, 0.2, 0.25, 0.5, 1, 2, 5, 10, 20, 50, 100, 500, 1000];\n\nexport const VALID_LABEL_VALUES = {\n 0.01: [0, 0.01, 0.02, 0.04, 0.05, 0.1],\n 0.02: [0, 0.02, 0.04, 0.1],\n 0.04: [0, 0.04, 0.08, 0.16, 0.2],\n 0.05: [0, 0.05, 0.1, 0.2, 0.25],\n 0.0625: [0, 0.0625, 0.125, 0.25, 0.5],\n 0.1: [0, 0.1, 0.2, 0.4, 0.5, 1],\n 0.125: [0, 0.125, 0.25, 0.5, 1],\n 0.2: [0, 0.2, 0.5, 0.1],\n 0.25: [0, 0.25, 0.5, 1, 2],\n 0.5: [0, 0.5, 1, 2],\n 1: [0, 1, 2, 4, 5, 10],\n 2: [0, 2, 4, 8, 10],\n 3: [0, 3, 6, 12, 15],\n 4: [0, 4, 8, 16, 20],\n 5: [0, 5, 10, 20, 25],\n 8: [0, 8, 16, 32, 40, 64],\n 10: [0, 10, 20, 40, 50, 100],\n 12: [0, 12, 24],\n 15: [0, 15, 30, 60],\n 20: [0, 20, 40, 80, 100],\n 40: [0, 40, 80, 160, 200],\n 50: [0, 50, 100, 200, 250],\n 64: [0, 64, 128],\n 100: [0, 100, 200, 400, 500],\n 500: [0, 500, 1000, 2500],\n 1000: [0, 1000, 2000, 4000, 5000],\n};\n\nexport const getGridValues = (axis, size, prefferedValues = false) => {\n const minValue = (10 * (axis.max - axis.min)) / size;\n const maxValue = minValue * 10;\n const values = prefferedValues ? PREFERRED_VALID_GRID_VALUES : VALID_GRID_VALUES;\n\n return values.filter((value) => value >= minValue && value <= maxValue);\n};\n\nexport const getLabelValues = (value) => VALID_LABEL_VALUES[value] || [];\n\nexport const applyConstraints = (axis, size, oldGridValues, oldLabelValues) => {\n const gridValues = getGridValues(axis, size);\n let labelValues = getLabelValues(axis.step || 1);\n\n if (!isEqual(oldGridValues, gridValues) && !gridValues.includes(axis.step)) {\n const preferredValues = getGridValues(axis, size, true);\n const lowestValue = preferredValues[0] || 1;\n\n axis.step = lowestValue;\n labelValues = getLabelValues(lowestValue);\n\n if (!labelValues.includes(axis.labelStep)) {\n axis.labelStep = lowestValue;\n }\n\n return { gridValues, labelValues };\n }\n\n if (!isEqual(oldLabelValues, labelValues) && !labelValues.includes(axis.labelStep)) {\n axis.labelStep = axis.step;\n }\n\n return { gridValues, labelValues };\n};\n"],"file":"utils.js"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* NOTE: There's no functionality described for graphTitle,
|
|
10
|
-
* rationale, scoringType, studentInstructions, teacherInstructions
|
|
11
|
-
* so there's no implementation (they are only added in model)
|
|
12
|
-
*/
|
|
13
|
-
var _default = {};
|
|
14
|
-
exports["default"] = _default;
|
|
15
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;eAEe,E","sourcesContent":["/**\n * NOTE: There's no functionality described for graphTitle,\n * rationale, scoringType, studentInstructions, teacherInstructions\n * so there's no implementation (they are only added in model)\n */\n\nexport default {};\n"],"file":"defaults.js"}
|
package/controller/lib/index.js
DELETED
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getScore = exports.filterCategories = exports.createCorrectResponseSession = exports.checkLabelsEquality = void 0;
|
|
9
|
-
exports.model = model;
|
|
10
|
-
exports.normalize = void 0;
|
|
11
|
-
exports.outcome = outcome;
|
|
12
|
-
exports.validate = exports.setCorrectness = void 0;
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
17
|
-
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
21
|
-
|
|
22
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
23
|
-
|
|
24
|
-
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
25
|
-
|
|
26
|
-
var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
27
|
-
|
|
28
|
-
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
29
|
-
|
|
30
|
-
var _excluded = ["deletable"],
|
|
31
|
-
_excluded2 = ["correctness"];
|
|
32
|
-
|
|
33
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
|
-
|
|
35
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
36
|
-
|
|
37
|
-
var log = (0, _debug["default"])('@pie-element:graphing:controller');
|
|
38
|
-
|
|
39
|
-
var lowerCase = function lowerCase(string) {
|
|
40
|
-
return (string || '').toLowerCase();
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
var checkLabelsEquality = function checkLabelsEquality(givenAnswerLabel, correctAnswerLabel) {
|
|
44
|
-
return lowerCase(givenAnswerLabel) === lowerCase(correctAnswerLabel);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
exports.checkLabelsEquality = checkLabelsEquality;
|
|
48
|
-
|
|
49
|
-
var setCorrectness = function setCorrectness(answers, partialScoring) {
|
|
50
|
-
return answers ? answers.map(function (answer) {
|
|
51
|
-
return _objectSpread(_objectSpread({}, answer), {}, {
|
|
52
|
-
correctness: {
|
|
53
|
-
value: partialScoring ? 'incorrect' : 'correct',
|
|
54
|
-
label: partialScoring ? 'incorrect' : 'correct'
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}) : [];
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.setCorrectness = setCorrectness;
|
|
61
|
-
|
|
62
|
-
var normalize = function normalize(question) {
|
|
63
|
-
return _objectSpread({
|
|
64
|
-
addCategoryEnabled: true,
|
|
65
|
-
promptEnabled: true,
|
|
66
|
-
rationaleEnabled: true,
|
|
67
|
-
teacherInstructionsEnabled: true,
|
|
68
|
-
studentInstructionsEnabled: true
|
|
69
|
-
}, question);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
exports.normalize = normalize;
|
|
73
|
-
|
|
74
|
-
var getScore = function getScore(question, session) {
|
|
75
|
-
var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
76
|
-
var correctAnswer = question.correctAnswer,
|
|
77
|
-
_question$data = question.data,
|
|
78
|
-
initialData = _question$data === void 0 ? [] : _question$data,
|
|
79
|
-
scoringType = question.scoringType;
|
|
80
|
-
|
|
81
|
-
var isPartialScoring = _controllerUtils.partialScoring.enabled({
|
|
82
|
-
partialScoring: scoringType !== undefined ? scoringType === 'partial scoring' : scoringType
|
|
83
|
-
}, env);
|
|
84
|
-
|
|
85
|
-
var _ref = correctAnswer || {},
|
|
86
|
-
_ref$data = _ref.data,
|
|
87
|
-
correctAnswers = _ref$data === void 0 ? [] : _ref$data;
|
|
88
|
-
|
|
89
|
-
var defaultAnswers = filterCategories(initialData);
|
|
90
|
-
var answers = setCorrectness(session && session.answer || defaultAnswers, isPartialScoring);
|
|
91
|
-
var result = 0;
|
|
92
|
-
|
|
93
|
-
if (isPartialScoring) {
|
|
94
|
-
// if score type is "partial scoring"
|
|
95
|
-
// maxScore is calculated based on the correct response
|
|
96
|
-
// score is calculated based on the given response
|
|
97
|
-
var maxScore = 0;
|
|
98
|
-
var score = 0;
|
|
99
|
-
|
|
100
|
-
var scoreForLabelAndValueEditable = function scoreForLabelAndValueEditable(answer, corrAnswer) {
|
|
101
|
-
var value = answer.value,
|
|
102
|
-
label = answer.label;
|
|
103
|
-
maxScore += 2;
|
|
104
|
-
|
|
105
|
-
if (value === corrAnswer.value) {
|
|
106
|
-
score += 1;
|
|
107
|
-
answer.correctness.value = 'correct';
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (checkLabelsEquality(label, corrAnswer.label)) {
|
|
111
|
-
score += 1;
|
|
112
|
-
answer.correctness.label = 'correct';
|
|
113
|
-
}
|
|
114
|
-
}; // if given answer has more categories than the correct answers, the "extra" will be ignored
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
correctAnswers.forEach(function (corrAnswer, index) {
|
|
118
|
-
var defaultAnswer = defaultAnswers[index];
|
|
119
|
-
var answer = answers[index]; // if there is a corresponding category at the same position in the given answer
|
|
120
|
-
|
|
121
|
-
if (answer) {
|
|
122
|
-
// if there is a corresponding category at the same position in the default answer
|
|
123
|
-
if (defaultAnswer) {
|
|
124
|
-
// if category's label (in default answer) was not editable
|
|
125
|
-
// it means that this category values only one point (only the value can be changed)
|
|
126
|
-
if (!defaultAnswer.editable && answer.interactive) {
|
|
127
|
-
maxScore += 1;
|
|
128
|
-
|
|
129
|
-
if (answer.value === corrAnswer.value) {
|
|
130
|
-
score += 1;
|
|
131
|
-
answer.correctness.value = 'correct';
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
answer.correctness.label = 'correct'; // if category's label (in default answer) was editable
|
|
135
|
-
// it means that this category values 2 points (both label and value can be changed)
|
|
136
|
-
} else if (defaultAnswer.editable && answer.interactive) {
|
|
137
|
-
scoreForLabelAndValueEditable(answer, corrAnswer);
|
|
138
|
-
} else if (!answer.interactive) {
|
|
139
|
-
answer.correctness.value = 'correct';
|
|
140
|
-
answer.correctness.label = 'correct';
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
// if there is not a corresponding category at the same position in the default answer
|
|
144
|
-
scoreForLabelAndValueEditable(answer, corrAnswer);
|
|
145
|
-
}
|
|
146
|
-
} else {
|
|
147
|
-
// if there is not a corresponding category at the same position in the given answer
|
|
148
|
-
// it means that the given answer has less categories than the correct answer
|
|
149
|
-
maxScore += 2;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
result = maxScore ? score / maxScore : 0;
|
|
153
|
-
} else {
|
|
154
|
-
// if scoring type is "all or nothing"
|
|
155
|
-
// the length on correct answers and length of given answer have to match
|
|
156
|
-
result = correctAnswers.length === answers.length ? 1 : 0;
|
|
157
|
-
|
|
158
|
-
if (result) {
|
|
159
|
-
// if there is at least one difference between the correct answer and the given answer
|
|
160
|
-
// the result will be incorrect
|
|
161
|
-
correctAnswers.forEach(function (corrAnswer, index) {
|
|
162
|
-
var _answers$index = answers[index],
|
|
163
|
-
value = _answers$index.value,
|
|
164
|
-
label = _answers$index.label;
|
|
165
|
-
|
|
166
|
-
if (value !== corrAnswer.value) {
|
|
167
|
-
result = 0;
|
|
168
|
-
answers[index].correctness.value = 'incorrect';
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (lowerCase(label) !== lowerCase(corrAnswer.label)) {
|
|
172
|
-
result = 0;
|
|
173
|
-
answers[index].correctness.label = 'incorrect';
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
} else {
|
|
177
|
-
answers = [].concat((0, _toConsumableArray2["default"])(answers.slice(0, correctAnswers.length)), (0, _toConsumableArray2["default"])(setCorrectness(answers.slice(correctAnswers.length), true)));
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
score: parseFloat(result.toFixed(2)),
|
|
183
|
-
answers: answers
|
|
184
|
-
};
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
exports.getScore = getScore;
|
|
188
|
-
|
|
189
|
-
var filterCategories = function filterCategories(categories) {
|
|
190
|
-
return categories ? categories.map(function (_ref2) {
|
|
191
|
-
var deletable = _ref2.deletable,
|
|
192
|
-
rest = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
193
|
-
return rest;
|
|
194
|
-
}) : [];
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
exports.filterCategories = filterCategories;
|
|
198
|
-
|
|
199
|
-
function model(question, session, env) {
|
|
200
|
-
return new Promise(function (resolve) {
|
|
201
|
-
var normalizedQuestion = normalize(question);
|
|
202
|
-
var addCategoryEnabled = normalizedQuestion.addCategoryEnabled,
|
|
203
|
-
categoryDefaultLabel = normalizedQuestion.categoryDefaultLabel,
|
|
204
|
-
chartType = normalizedQuestion.chartType,
|
|
205
|
-
data = normalizedQuestion.data,
|
|
206
|
-
domain = normalizedQuestion.domain,
|
|
207
|
-
graph = normalizedQuestion.graph,
|
|
208
|
-
prompt = normalizedQuestion.prompt,
|
|
209
|
-
promptEnabled = normalizedQuestion.promptEnabled,
|
|
210
|
-
range = normalizedQuestion.range,
|
|
211
|
-
rationale = normalizedQuestion.rationale,
|
|
212
|
-
title = normalizedQuestion.title,
|
|
213
|
-
rationaleEnabled = normalizedQuestion.rationaleEnabled,
|
|
214
|
-
teacherInstructions = normalizedQuestion.teacherInstructions,
|
|
215
|
-
teacherInstructionsEnabled = normalizedQuestion.teacherInstructionsEnabled,
|
|
216
|
-
correctAnswer = normalizedQuestion.correctAnswer,
|
|
217
|
-
scoringType = normalizedQuestion.scoringType;
|
|
218
|
-
var correctInfo = {
|
|
219
|
-
correctness: 'incorrect',
|
|
220
|
-
score: '0%'
|
|
221
|
-
};
|
|
222
|
-
var base = {
|
|
223
|
-
addCategoryEnabled: addCategoryEnabled,
|
|
224
|
-
categoryDefaultLabel: categoryDefaultLabel,
|
|
225
|
-
chartType: chartType,
|
|
226
|
-
data: filterCategories(data),
|
|
227
|
-
domain: domain,
|
|
228
|
-
graph: graph,
|
|
229
|
-
prompt: promptEnabled ? prompt : null,
|
|
230
|
-
range: range,
|
|
231
|
-
rationale: rationale,
|
|
232
|
-
title: title,
|
|
233
|
-
size: graph,
|
|
234
|
-
correctness: correctInfo,
|
|
235
|
-
disabled: env.mode !== 'gather',
|
|
236
|
-
scoringType: scoringType
|
|
237
|
-
};
|
|
238
|
-
var answers = filterCategories(getScore(normalizedQuestion, session, env).answers);
|
|
239
|
-
|
|
240
|
-
if (env.mode === 'view') {
|
|
241
|
-
base.correctedAnswer = answers.map(function (_ref3) {
|
|
242
|
-
var correctness = _ref3.correctness,
|
|
243
|
-
rest = (0, _objectWithoutProperties2["default"])(_ref3, _excluded2);
|
|
244
|
-
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
245
|
-
interactive: false
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
base.addCategoryEnabled = false;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if (env.mode === 'evaluate') {
|
|
252
|
-
base.correctedAnswer = answers;
|
|
253
|
-
base.correctAnswer = correctAnswer;
|
|
254
|
-
base.addCategoryEnabled = false;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
258
|
-
base.rationale = rationaleEnabled ? rationale : null;
|
|
259
|
-
base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;
|
|
260
|
-
} else {
|
|
261
|
-
base.rationale = null;
|
|
262
|
-
base.teacherInstructions = null;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
log('base: ', base);
|
|
266
|
-
resolve(base);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function outcome(model, session, env) {
|
|
271
|
-
return new Promise(function (resolve) {
|
|
272
|
-
resolve({
|
|
273
|
-
score: getScore(model, session, env).score,
|
|
274
|
-
empty: !session || (0, _isEmpty["default"])(session)
|
|
275
|
-
});
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
|
|
280
|
-
return new Promise(function (resolve) {
|
|
281
|
-
if (env.mode !== 'evaluate' && env.role === 'instructor') {
|
|
282
|
-
var correctAnswer = question.correctAnswer;
|
|
283
|
-
var answers = correctAnswer && correctAnswer.data; // for IBX preview mode
|
|
284
|
-
|
|
285
|
-
if (env.mode === 'gather') {
|
|
286
|
-
var data = question.data;
|
|
287
|
-
answers = (correctAnswer && correctAnswer.data || []).map(function (answer, index) {
|
|
288
|
-
return _objectSpread(_objectSpread({}, data[index]), answer);
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
resolve({
|
|
293
|
-
answer: answers,
|
|
294
|
-
id: '1'
|
|
295
|
-
});
|
|
296
|
-
} else {
|
|
297
|
-
return resolve(null);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
exports.createCorrectResponseSession = createCorrectResponseSession;
|
|
303
|
-
|
|
304
|
-
var validate = function validate() {
|
|
305
|
-
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
306
|
-
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
307
|
-
|
|
308
|
-
var _ref4 = model || {},
|
|
309
|
-
correctAnswer = _ref4.correctAnswer,
|
|
310
|
-
data = _ref4.data;
|
|
311
|
-
|
|
312
|
-
var _ref5 = correctAnswer || {},
|
|
313
|
-
correctData = _ref5.data;
|
|
314
|
-
|
|
315
|
-
var categories = correctData || [];
|
|
316
|
-
var errors = {};
|
|
317
|
-
var correctAnswerErrors = {};
|
|
318
|
-
var categoryErrors = {};
|
|
319
|
-
categories.forEach(function (category, index) {
|
|
320
|
-
var label = category.label;
|
|
321
|
-
|
|
322
|
-
if (label === '' || label === '<div></div>') {
|
|
323
|
-
categoryErrors[index] = 'Content should not be empty.';
|
|
324
|
-
} else {
|
|
325
|
-
var identicalAnswer = categories.slice(index + 1).some(function (c) {
|
|
326
|
-
return c.label === label;
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
if (identicalAnswer) {
|
|
330
|
-
categoryErrors[index + 1] = 'Content should be unique.';
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
if (categories.length < 1 || categories.length > 20) {
|
|
336
|
-
correctAnswerErrors.categoriesError = 'The correct answer should include between 1 and 20 categories.';
|
|
337
|
-
} else if ((0, _isEqual["default"])(data.map(function (category) {
|
|
338
|
-
return (0, _pick["default"])(category, 'value', 'label');
|
|
339
|
-
}), correctData.map(function (category) {
|
|
340
|
-
return (0, _pick["default"])(category, 'value', 'label');
|
|
341
|
-
}))) {
|
|
342
|
-
correctAnswerErrors.identicalError = 'Correct answer should not be identical to the chart’s initial state';
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (!(0, _isEmpty["default"])(categoryErrors)) {
|
|
346
|
-
errors.categoryErrors = categoryErrors;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
if (!(0, _isEmpty["default"])(correctAnswerErrors)) {
|
|
350
|
-
errors.correctAnswerErrors = correctAnswerErrors;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
return errors;
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
exports.validate = validate;
|
|
357
|
-
//# sourceMappingURL=index.js.map
|