@pie-element/graphing 3.5.4-next.137 → 3.5.4-next.1372
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 +292 -0
- package/configure/CHANGELOG.md +278 -0
- package/configure/lib/configure.js +120 -52
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/correct-response.js +312 -61
- package/configure/lib/correct-response.js.map +1 -1
- package/configure/lib/defaults.js +256 -11
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/graphing-config.js +266 -178
- package/configure/lib/graphing-config.js.map +1 -1
- package/configure/lib/index.js +63 -18
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/utils.js +94 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +6 -5
- package/controller/CHANGELOG.md +84 -0
- package/controller/lib/defaults.js +4 -0
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +25 -23
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +8 -6
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +1 -1
- package/docs/config-schema.json +1031 -11
- package/docs/config-schema.json.md +717 -10
- package/docs/demo/generate.js +2 -0
- package/docs/pie-schema.json +702 -215
- package/docs/pie-schema.json.md +435 -86
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/main.js +18 -19
- package/lib/main.js.map +1 -1
- package/lib/utils.js +3 -1
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
package/configure/lib/index.js
CHANGED
|
@@ -35,23 +35,24 @@ var _debug = _interopRequireDefault(require("debug"));
|
|
|
35
35
|
|
|
36
36
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
37
37
|
|
|
38
|
-
var
|
|
38
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
39
39
|
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
+
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; }
|
|
41
41
|
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
42
|
+
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; }
|
|
43
43
|
|
|
44
44
|
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); }; }
|
|
45
45
|
|
|
46
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
46
|
+
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; } }
|
|
47
47
|
|
|
48
|
-
var log = (0, _debug["default"])('pie-elements:graphing:configure');
|
|
48
|
+
var log = (0, _debug["default"])('pie-elements:graphing:configure'); // this function is implemented in controller as well
|
|
49
49
|
|
|
50
|
-
// this function is implemented in controller as well
|
|
51
50
|
var sortedAnswers = function sortedAnswers(answers) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
return Object.keys(answers || {}).sort().reduce(function (result, key) {
|
|
52
|
+
if (key !== 'correctAnswer') {
|
|
53
|
+
result[key] = answers[key];
|
|
54
|
+
}
|
|
55
|
+
|
|
55
56
|
return result;
|
|
56
57
|
}, {});
|
|
57
58
|
};
|
|
@@ -73,7 +74,7 @@ var GraphLinesConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
|
73
74
|
|
|
74
75
|
log('[onModelChanged]: ', _this._model);
|
|
75
76
|
|
|
76
|
-
_this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(_this._model
|
|
77
|
+
_this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(_this._model));
|
|
77
78
|
});
|
|
78
79
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onConfigurationChanged", function (config) {
|
|
79
80
|
_this._configuration = config;
|
|
@@ -105,9 +106,21 @@ var GraphLinesConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
|
105
106
|
|
|
106
107
|
this._render();
|
|
107
108
|
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "insertSound",
|
|
111
|
+
value: function insertSound(handler) {
|
|
112
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "onDeleteSound",
|
|
116
|
+
value: function onDeleteSound(src, done) {
|
|
117
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
118
|
+
}
|
|
108
119
|
}, {
|
|
109
120
|
key: "_render",
|
|
110
121
|
value: function _render() {
|
|
122
|
+
var _this2 = this;
|
|
123
|
+
|
|
111
124
|
if (this._model) {
|
|
112
125
|
var el = /*#__PURE__*/_react["default"].createElement(_configure["default"], {
|
|
113
126
|
onModelChanged: this.onModelChanged,
|
|
@@ -117,10 +130,16 @@ var GraphLinesConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
|
117
130
|
imageSupport: {
|
|
118
131
|
add: this.insertImage,
|
|
119
132
|
"delete": this.onDeleteImage
|
|
133
|
+
},
|
|
134
|
+
uploadSoundSupport: {
|
|
135
|
+
add: this.insertSound.bind(this),
|
|
136
|
+
"delete": this.onDeleteSound.bind(this)
|
|
120
137
|
}
|
|
121
138
|
});
|
|
122
139
|
|
|
123
|
-
_reactDom["default"].render(el, this)
|
|
140
|
+
_reactDom["default"].render(el, this, function () {
|
|
141
|
+
(0, _mathRendering.renderMath)(_this2);
|
|
142
|
+
});
|
|
124
143
|
}
|
|
125
144
|
}
|
|
126
145
|
}]);
|
|
@@ -131,12 +150,38 @@ exports["default"] = GraphLinesConfigure;
|
|
|
131
150
|
(0, _defineProperty2["default"])(GraphLinesConfigure, "createDefaultModel", function () {
|
|
132
151
|
var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
133
152
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
153
|
+
var normalizedModel = _objectSpread(_objectSpread({}, _defaults["default"].model), model);
|
|
154
|
+
|
|
155
|
+
var _normalizedModel$answ = normalizedModel.answers,
|
|
156
|
+
answers = _normalizedModel$answ === void 0 ? {} : _normalizedModel$answ,
|
|
157
|
+
_normalizedModel$doma = normalizedModel.domain,
|
|
158
|
+
domain = _normalizedModel$doma === void 0 ? {} : _normalizedModel$doma,
|
|
159
|
+
defaultTool = normalizedModel.defaultTool,
|
|
160
|
+
_normalizedModel$grap = normalizedModel.graph,
|
|
161
|
+
graph = _normalizedModel$grap === void 0 ? {} : _normalizedModel$grap,
|
|
162
|
+
_normalizedModel$rang = normalizedModel.range,
|
|
163
|
+
range = _normalizedModel$rang === void 0 ? {} : _normalizedModel$rang,
|
|
164
|
+
standardGrid = normalizedModel.standardGrid,
|
|
165
|
+
toolbarTools = normalizedModel.toolbarTools; // added support for models without defaultTool defined; also used in packages/graphing/controller/src/index.js
|
|
166
|
+
|
|
167
|
+
var toolbarToolsNoLabel = (toolbarTools || []).filter(function (tool) {
|
|
168
|
+
return tool !== 'label';
|
|
169
|
+
});
|
|
170
|
+
var normalizedDefaultTool = defaultTool || toolbarToolsNoLabel.length && toolbarToolsNoLabel[0] || '';
|
|
171
|
+
return _objectSpread(_objectSpread({}, normalizedModel), {}, {
|
|
172
|
+
answers: answers && answers.correctAnswer && _objectSpread({
|
|
173
|
+
correctAnswer: answers.correctAnswer
|
|
174
|
+
}, sortedAnswers(answers)) || answers,
|
|
175
|
+
defaultTool: normalizedDefaultTool,
|
|
176
|
+
range: standardGrid && _objectSpread(_objectSpread({}, range), {}, {
|
|
177
|
+
min: domain.min,
|
|
178
|
+
max: domain.max,
|
|
179
|
+
step: domain.step,
|
|
180
|
+
labelStep: domain.labelStep
|
|
181
|
+
}) || range,
|
|
182
|
+
graph: standardGrid && _objectSpread(_objectSpread({}, graph), {}, {
|
|
183
|
+
height: graph.width
|
|
184
|
+
}) || graph
|
|
185
|
+
});
|
|
141
186
|
});
|
|
142
187
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","sortedAnswers","answers","Object","keys","sort","reduce","result","key","GraphLinesConfigure","model","_model","_render","dispatchEvent","ModelUpdatedEvent","config","_configuration","handler","InsertImageEvent","src","done","DeleteImageEvent","createDefaultModel","defaultValues","configuration","m","c","el","React","createElement","Configure","onModelChanged","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","ReactDOM","render","HTMLElement","
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","sortedAnswers","answers","Object","keys","sort","reduce","result","key","GraphLinesConfigure","model","_model","_render","dispatchEvent","ModelUpdatedEvent","config","_configuration","handler","InsertImageEvent","src","done","DeleteImageEvent","createDefaultModel","defaultValues","configuration","m","c","InsertSoundEvent","DeleteSoundEvent","el","React","createElement","Configure","onModelChanged","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","bind","onDeleteSound","ReactDOM","render","HTMLElement","normalizedModel","domain","defaultTool","graph","range","standardGrid","toolbarTools","toolbarToolsNoLabel","filter","tool","normalizedDefaultTool","length","correctAnswer","min","max","step","labelStep","height","width"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ,C,CAEA;;AACA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,OAAO;AAAA,SAAIC,MAAM,CAACC,IAAP,CAAYF,OAAO,IAAI,EAAvB,EAA2BG,IAA3B,GAAkCC,MAAlC,CAAyC,UAACC,MAAD,EAASC,GAAT,EAAiB;AACzF,QAAIA,GAAG,KAAK,eAAZ,EAA6B;AAC3BD,MAAAA,MAAM,CAACC,GAAD,CAAN,GAAcN,OAAO,CAACM,GAAD,CAArB;AACD;;AAED,WAAOD,MAAP;AACD,GANgC,EAM9B,EAN8B,CAAJ;AAAA,CAA7B;;IAQqBE,mB;;;;;AAmCnB,iCAAc;AAAA;;AAAA;AACZ;AADY,uGAgBG,UAACC,KAAD,EAAW;AAC1B,YAAKC,MAAL,GAAcD,KAAd;;AACA,YAAKE,OAAL;;AAEAZ,MAAAA,GAAG,CAAC,oBAAD,EAAuB,MAAKW,MAA5B,CAAH;;AAEA,YAAKE,aAAL,CAAmB,IAAIC,qCAAJ,CAAsB,MAAKH,MAA3B,CAAnB;AACD,KAvBa;AAAA,+GAyBW,UAACI,MAAD,EAAY;AACnC,YAAKC,cAAL,GAAsBD,MAAtB;;AACA,YAAKH,OAAL;AACD,KA5Ba;AAAA,oGA8BA,UAACK,OAAD,EAAa;AACzB,YAAKJ,aAAL,CAAmB,IAAIK,oCAAJ,CAAqBD,OAArB,CAAnB;AACD,K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MAAM,CAACY,GAFK;AAGjBC,MAAAA,GAAG,EAAEb,MAAM,CAACa,GAHK;AAIjBC,MAAAA,IAAI,EAAEd,MAAM,CAACc,IAJI;AAKjBC,MAAAA,SAAS,EAAEf,MAAM,CAACe;AALD,MAAZ,IAMFZ,KAbP;AAcED,IAAAA,KAAK,EAAEE,YAAY,oCAASF,KAAT;AAAgBc,MAAAA,MAAM,EAAEd,KAAK,CAACe;AAA9B,MAAZ,IAAqDf;AAd9D;AAgBD,C","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport Configure from './configure';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent\n} from '@pie-framework/pie-configure-events';\nimport debug from 'debug';\nimport defaultValues from './defaults';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst log = debug('pie-elements:graphing:configure');\n\n// this function is implemented in controller as well\nconst sortedAnswers = answers => Object.keys(answers || {}).sort().reduce((result, key) => {\n if (key !== 'correctAnswer') {\n result[key] = answers[key];\n }\n\n return result;\n}, {});\n\nexport default class GraphLinesConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n const normalizedModel = { ...defaultValues.model, ...model };\n const {\n answers = {},\n domain = {},\n defaultTool,\n graph = {},\n range = {},\n standardGrid,\n toolbarTools\n } = normalizedModel;\n\n // added support for models without defaultTool defined; also used in packages/graphing/controller/src/index.js\n const toolbarToolsNoLabel = (toolbarTools || []).filter(tool => tool !== 'label');\n const normalizedDefaultTool = defaultTool || toolbarToolsNoLabel.length && toolbarToolsNoLabel[0] || '';\n\n return {\n ...normalizedModel,\n answers: answers && answers.correctAnswer && {\n correctAnswer: answers.correctAnswer,\n ...sortedAnswers(answers)\n } || answers,\n defaultTool: normalizedDefaultTool,\n range: standardGrid && {\n ...range,\n min: domain.min,\n max: domain.max,\n step: domain.step,\n labelStep: domain.labelStep\n } || range,\n graph: standardGrid && { ...graph, height: graph.width } || graph\n };\n };\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,\n onConfigurationChanged: this.onConfigurationChanged,\n model: this._model,\n configuration: this._configuration,\n imageSupport: {\n add: this.insertImage,\n delete: this.onDeleteImage,\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"}
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
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
|
|
13
|
+
|
|
14
|
+
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];
|
|
15
|
+
var VALID_LABEL_VALUES = {
|
|
16
|
+
'0.01': [0, 0.01, 0.02, 0.04, 0.05, 0.1],
|
|
17
|
+
'0.02': [0, 0.02, 0.04, 0.1],
|
|
18
|
+
'0.04': [0, 0.04, 0.08, 0.16, 0.2],
|
|
19
|
+
'0.05': [0, 0.05, 0.1, 0.2, 0.25],
|
|
20
|
+
'0.0625': [0, 0.0625, 0.125, 0.25, 0.5],
|
|
21
|
+
'0.1': [0, 0.1, 0.2, 0.4, 0.5, 1],
|
|
22
|
+
'0.125': [0, 0.125, 0.25, 0.5, 1],
|
|
23
|
+
'0.2': [0, 0.2, 0.5, 0.1],
|
|
24
|
+
'0.25': [0, 0.25, 0.5, 1, 2],
|
|
25
|
+
'0.5': [0, 0.5, 1, 2],
|
|
26
|
+
'1': [0, 1, 2, 4, 5, 10],
|
|
27
|
+
'2': [0, 2, 4, 8, 10],
|
|
28
|
+
'3': [0, 3, 6, 12, 15],
|
|
29
|
+
'4': [0, 4, 8, 16, 20],
|
|
30
|
+
'5': [0, 5, 10, 20, 25],
|
|
31
|
+
'8': [0, 8, 16, 32, 40, 64],
|
|
32
|
+
'10': [0, 10, 20, 40, 50, 100],
|
|
33
|
+
'12': [0, 12, 24],
|
|
34
|
+
'15': [0, 15, 30, 60],
|
|
35
|
+
'20': [0, 20, 40, 80, 100],
|
|
36
|
+
'40': [0, 40, 80, 160, 200],
|
|
37
|
+
'50': [0, 50, 100, 200, 250],
|
|
38
|
+
'64': [0, 64, 128],
|
|
39
|
+
'100': [0, 100, 200, 400, 500],
|
|
40
|
+
'500': [0, 500, 1000, 2500],
|
|
41
|
+
'1000': [0, 1000, 2000, 4000, 5000]
|
|
42
|
+
};
|
|
43
|
+
exports.VALID_LABEL_VALUES = VALID_LABEL_VALUES;
|
|
44
|
+
|
|
45
|
+
var getGridValues = function getGridValues(axis, size) {
|
|
46
|
+
var prefferedValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
47
|
+
var minValue = 10 * (axis.max - axis.min) / size;
|
|
48
|
+
var maxValue = minValue * 10;
|
|
49
|
+
var values = prefferedValues ? PREFERRED_VALID_GRID_VALUES : VALID_GRID_VALUES;
|
|
50
|
+
return values.filter(function (value) {
|
|
51
|
+
return value >= minValue && value <= maxValue;
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.getGridValues = getGridValues;
|
|
56
|
+
|
|
57
|
+
var getLabelValues = function getLabelValues(value) {
|
|
58
|
+
return VALID_LABEL_VALUES[value] || [];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
exports.getLabelValues = getLabelValues;
|
|
62
|
+
|
|
63
|
+
var applyConstraints = function applyConstraints(axis, size, oldGridValues, oldLabelValues) {
|
|
64
|
+
var gridValues = getGridValues(axis, size);
|
|
65
|
+
var labelValues = getLabelValues(axis.step);
|
|
66
|
+
|
|
67
|
+
if (!(0, _isEqual["default"])(oldGridValues, gridValues) && !gridValues.includes(axis.step)) {
|
|
68
|
+
var preferredValues = getGridValues(axis, size, true);
|
|
69
|
+
var lowestValue = preferredValues[0] || 1;
|
|
70
|
+
axis.step = lowestValue;
|
|
71
|
+
labelValues = getLabelValues(lowestValue);
|
|
72
|
+
|
|
73
|
+
if (!labelValues.includes(axis.labelStep)) {
|
|
74
|
+
axis.labelStep = lowestValue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
gridValues: gridValues,
|
|
79
|
+
labelValues: labelValues
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!(0, _isEqual["default"])(oldLabelValues, labelValues) && !labelValues.includes(axis.labelStep)) {
|
|
84
|
+
axis.labelStep = axis.step;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
gridValues: gridValues,
|
|
89
|
+
labelValues: labelValues
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
exports.applyConstraints = applyConstraints;
|
|
94
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;;;;;;AAAA;;AAEA,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,EAExB,CAFwB,EAErB,CAFqB,EAElB,CAFkB,EAEf,CAFe,EAEZ,CAFY,EAET,CAFS,EAEN,EAFM,EAEF,EAFE,EAEE,EAFF,EAEM,EAFN,EAEU,EAFV,EAEc,EAFd,EAEkB,EAFlB,EAEsB,GAFtB,EAE2B,GAF3B,EAEgC,IAFhC,CAA1B,C,CAKA;;AACA,IAAMC,2BAA2B,GAAG,CAAE,IAAF,EAAQ,IAAR,EAAc,IAAd,EAAoB,GAApB,EAAyB,GAAzB,EAA8B,IAA9B,EAAoC,GAApC,EAAyC,CAAzC,EAA4C,CAA5C,EAA+C,CAA/C,EAAkD,EAAlD,EAAsD,EAAtD,EAA0D,EAA1D,EAA8D,GAA9D,EAAmE,GAAnE,EAAwE,IAAxE,CAApC;AAEO,IAAMC,kBAAkB,GAAG;AAChC,UAAQ,CAA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SAA1B,CAA9C,EAAoF;AAClFpB,IAAAA,IAAI,CAACoB,SAAL,GAAiBpB,IAAI,CAACgB,IAAtB;AACD;;AAED,SAAO;AAAEF,IAAAA,UAAU,EAAVA,UAAF;AAAcC,IAAAA,WAAW,EAAXA;AAAd,GAAP;AACD,CAvBM","sourcesContent":["import 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,\n 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500, 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);\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"}
|
package/configure/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/graphing-configure",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
|
-
"@pie-framework/pie-configure-events": "^1.
|
|
12
|
-
"@pie-lib/config-ui": "^
|
|
13
|
-
"@pie-lib/editable-html": "^
|
|
14
|
-
"@pie-lib/graphing": "^2.
|
|
11
|
+
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
12
|
+
"@pie-lib/config-ui": "^11.0.20",
|
|
13
|
+
"@pie-lib/editable-html": "^9.2.2",
|
|
14
|
+
"@pie-lib/graphing": "^2.11.2",
|
|
15
|
+
"@pie-lib/math-rendering": "^2.5.0",
|
|
15
16
|
"classnames": "^2.2.5",
|
|
16
17
|
"debug": "^4.1.1",
|
|
17
18
|
"prop-types": "^15.6.2",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,90 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [4.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.4.6...@pie-element/graphing-controller@4.0.0) (2022-06-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### chore
|
|
10
|
+
|
|
11
|
+
* Merge master with develop. ([cdca48a](https://github.com/pie-framework/pie-elements/commit/cdca48abaa1d4179e4a961e13d171e14b7ed2444))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### BREAKING CHANGES
|
|
15
|
+
|
|
16
|
+
* Image percent buttons were removed from toolbar.
|
|
17
|
+
New properties maxImageWidth and maxImageHeight were added.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [3.4.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.4.5...@pie-element/graphing-controller@3.4.6) (2022-06-13)
|
|
24
|
+
|
|
25
|
+
**Note:** Version bump only for package @pie-element/graphing-controller
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## [3.4.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.4.4...@pie-element/graphing-controller@3.4.5) (2022-02-21)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package @pie-element/graphing-controller
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## [3.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.3.0...@pie-element/graphing-controller@3.4.1) (2021-11-11)
|
|
40
|
+
|
|
41
|
+
**Note:** Version bump only for package @pie-element/graphing-controller
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# [3.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.2.16...@pie-element/graphing-controller@3.4.0) (2021-11-11)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **graphing:** control over displaying graph arrows PD-483 ([6f98639](https://github.com/pie-framework/pie-elements/commit/6f98639b4bcce0e7ce75f28435c6fe1c8db8a4d4))
|
|
53
|
+
* **graphing:** Displayed point coordinates on hover PD-188 \n BREAKING CHANGE: Added coordinatesOnHover property to the model ([124cc2d](https://github.com/pie-framework/pie-elements/commit/124cc2de418fbdd1825c6c39eee550875a3e24af))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# [3.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.2.16...@pie-element/graphing-controller@3.3.0) (2021-08-05)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Features
|
|
63
|
+
|
|
64
|
+
* **graphing:** control over displaying graph arrows PD-483 ([6f98639](https://github.com/pie-framework/pie-elements/commit/6f98639b4bcce0e7ce75f28435c6fe1c8db8a4d4))
|
|
65
|
+
* **graphing:** Displayed point coordinates on hover PD-188 \n BREAKING CHANGE: Added coordinatesOnHover property to the model ([124cc2d](https://github.com/pie-framework/pie-elements/commit/124cc2de418fbdd1825c6c39eee550875a3e24af))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## [3.2.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.2.14...@pie-element/graphing-controller@3.2.16) (2021-08-05)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
|
|
76
|
+
* force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## [3.2.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.2.13...@pie-element/graphing-controller@3.2.14) (2021-06-29)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @pie-element/graphing-controller
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
6
90
|
## [3.2.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/graphing-controller@3.2.10...@pie-element/graphing-controller@3.2.13) (2021-03-03)
|
|
7
91
|
|
|
8
92
|
**Note:** Version bump only for package @pie-element/graphing-controller
|
|
@@ -28,7 +28,9 @@ var _default = {
|
|
|
28
28
|
width: 500,
|
|
29
29
|
height: 500
|
|
30
30
|
},
|
|
31
|
+
includeAxes: true,
|
|
31
32
|
labels: {},
|
|
33
|
+
labelsEnabled: true,
|
|
32
34
|
coordinatesOnHover: false,
|
|
33
35
|
padding: true,
|
|
34
36
|
prompt: '',
|
|
@@ -40,7 +42,9 @@ var _default = {
|
|
|
40
42
|
axisLabel: 'y'
|
|
41
43
|
},
|
|
42
44
|
rationale: '',
|
|
45
|
+
standardGrid: false,
|
|
43
46
|
title: '',
|
|
47
|
+
titleEnabled: true,
|
|
44
48
|
toolbarTools: allTools,
|
|
45
49
|
promptEnabled: true,
|
|
46
50
|
rationaleEnabled: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["allTools","answers","arrows","left","right","up","down","backgroundMarks","domain","min","max","step","labelStep","axisLabel","graph","width","height","labels","coordinatesOnHover","padding","prompt","range","rationale","title","toolbarTools","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled"],"mappings":";;;;;;AAAA;AACA,IAAMA,QAAQ,GAAG,CACf,QADe,EAEf,MAFe,EAGf,OAHe,EAIf,UAJe,EAKf,OALe,EAMf,SANe,EAOf,KAPe,EAQf,SARe,EASf,MATe,EAUf,QAVe,CAAjB;
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["allTools","answers","arrows","left","right","up","down","backgroundMarks","domain","min","max","step","labelStep","axisLabel","graph","width","height","includeAxes","labels","labelsEnabled","coordinatesOnHover","padding","prompt","range","rationale","standardGrid","title","titleEnabled","toolbarTools","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled"],"mappings":";;;;;;AAAA;AACA,IAAMA,QAAQ,GAAG,CACf,QADe,EAEf,MAFe,EAGf,OAHe,EAIf,UAJe,EAKf,OALe,EAMf,SANe,EAOf,KAPe,EAQf,SARe,EASf,MATe,EAUf,QAVe,CAAjB;AAaA;;eACe;AACbC,EAAAA,OAAO,EAAE,EADI;AAEbC,EAAAA,MAAM,EAAE;AACNC,IAAAA,IAAI,EAAE,IADA;AAENC,IAAAA,KAAK,EAAE,IAFD;AAGNC,IAAAA,EAAE,EAAE,IAHE;AAINC,IAAAA,IAAI,EAAE;AAJA,GAFK;AAQbC,EAAAA,eAAe,EAAE,EARJ;AASbC,EAAAA,MAAM,EAAE;AACNC,IAAAA,GAAG,EAAE,CAAC,CADA;AAENC,IAAAA,GAAG,EAAE,CAFC;AAGNC,IAAAA,IAAI,EAAE,CAHA;AAINC,IAAAA,SAAS,EAAE,CAJL;AAKNC,IAAAA,SAAS,EAAE;AALL,GATK;AAgBbC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAE,GADF;AAELC,IAAAA,MAAM,EAAE;AAFH,GAhBM;AAoBbC,EAAAA,WAAW,EAAE,IApBA;AAqBbC,EAAAA,MAAM,EAAE,EArBK;AAsBbC,EAAAA,aAAa,EAAE,IAtBF;AAuBbC,EAAAA,kBAAkB,EAAE,KAvBP;AAwBbC,EAAAA,OAAO,EAAE,IAxBI;AAyBbC,EAAAA,MAAM,EAAE,EAzBK;AA0BbC,EAAAA,KAAK,EAAE;AACLd,IAAAA,GAAG,EAAE,CAAC,CADD;AAELC,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILC,IAAAA,SAAS,EAAE,CAJN;AAKLC,IAAAA,SAAS,EAAE;AALN,GA1BM;AAiCbW,EAAAA,SAAS,EAAE,EAjCE;AAkCbC,EAAAA,YAAY,EAAE,KAlCD;AAmCbC,EAAAA,KAAK,EAAE,EAnCM;AAoCbC,EAAAA,YAAY,EAAE,IApCD;AAqCbC,EAAAA,YAAY,EAAE5B,QArCD;AAsCb6B,EAAAA,aAAa,EAAE,IAtCF;AAuCbC,EAAAA,gBAAgB,EAAE,IAvCL;AAwCbC,EAAAA,0BAA0B,EAAE,IAxCf;AAyCbC,EAAAA,0BAA0B,EAAE;AAzCf,C","sourcesContent":["// TODO: This is lifted from @pie-lib/graphing, however importing this will break a controller build because it has jsx source in that package.\nconst allTools = [\n 'circle',\n 'line',\n 'label',\n 'parabola',\n 'point',\n 'polygon',\n 'ray',\n 'segment',\n 'sine',\n 'vector'\n];\n\n/* model defaults */\nexport default {\n answers: {},\n arrows: {\n left: true,\n right: true,\n up: true,\n down: true\n },\n backgroundMarks: [],\n domain: {\n min: -5,\n max: 5,\n step: 1,\n labelStep: 1,\n axisLabel: 'x'\n },\n graph: {\n width: 500,\n height: 500\n },\n includeAxes: true,\n labels: {},\n labelsEnabled: true,\n coordinatesOnHover: false,\n padding: true,\n prompt: '',\n range: {\n min: -5,\n max: 5,\n step: 1,\n labelStep: 1,\n axisLabel: 'y'\n },\n rationale: '',\n standardGrid: false,\n title: '',\n titleEnabled: true,\n toolbarTools: allTools,\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true\n};\n"],"file":"defaults.js"}
|
package/controller/lib/index.js
CHANGED
|
@@ -5,9 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.getBestAnswer = exports.getAnswerCorrected = exports.createCorrectResponseSession = exports.compareMarks = void 0;
|
|
8
9
|
exports.model = model;
|
|
10
|
+
exports.normalize = void 0;
|
|
9
11
|
exports.outcome = outcome;
|
|
10
|
-
exports.createCorrectResponseSession = exports.normalize = exports.getBestAnswer = exports.orderCorrectAnswers = exports.getAnswerCorrected = exports.compareMarks = void 0;
|
|
11
12
|
|
|
12
13
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
14
|
|
|
@@ -29,9 +30,11 @@ var _utils = require("./utils");
|
|
|
29
30
|
|
|
30
31
|
var _controllerUtils = require("@pie-lib/controller-utils");
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
var _excluded = ["defaultTool", "prompt", "promptEnabled", "graph", "answers", "toolbarTools"];
|
|
33
34
|
|
|
34
|
-
function
|
|
35
|
+
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; }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
35
38
|
|
|
36
39
|
var log = (0, _debug["default"])('@pie-element:graphing:controller');
|
|
37
40
|
|
|
@@ -89,26 +92,13 @@ var getPartialScoring = function getPartialScoring(_ref2) {
|
|
|
89
92
|
}, env);
|
|
90
93
|
};
|
|
91
94
|
|
|
92
|
-
var orderCorrectAnswers = function orderCorrectAnswers(questionPossibleAnswers) {
|
|
93
|
-
questionPossibleAnswers = questionPossibleAnswers || {};
|
|
94
|
-
|
|
95
|
-
if (!questionPossibleAnswers.hasOwnProperty('correctAnswer')) {
|
|
96
|
-
(0, _utils.sortedAnswers)(questionPossibleAnswers);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return Object.assign({
|
|
100
|
-
correctAnswer: questionPossibleAnswers.correctAnswer
|
|
101
|
-
}, (0, _utils.sortedAnswers)(questionPossibleAnswers));
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
exports.orderCorrectAnswers = orderCorrectAnswers;
|
|
105
|
-
|
|
106
95
|
var getBestAnswer = function getBestAnswer(question, session) {
|
|
107
96
|
var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
108
97
|
|
|
109
98
|
// questionPossibleAnswers contains all possible answers (correct response and alternates);
|
|
110
99
|
var _ref3 = question || {},
|
|
111
|
-
|
|
100
|
+
_ref3$answers = _ref3.answers,
|
|
101
|
+
questionPossibleAnswers = _ref3$answers === void 0 ? {} : _ref3$answers,
|
|
112
102
|
scoringType = _ref3.scoringType;
|
|
113
103
|
|
|
114
104
|
var _ref4 = session || {},
|
|
@@ -122,7 +112,9 @@ var getBestAnswer = function getBestAnswer(question, session) {
|
|
|
122
112
|
correctAnswer: initializeGraphMap()
|
|
123
113
|
};
|
|
124
114
|
} else {
|
|
125
|
-
|
|
115
|
+
questionPossibleAnswers = _objectSpread({
|
|
116
|
+
correctAnswer: questionPossibleAnswers.correctAnswer
|
|
117
|
+
}, (0, _utils.sortedAnswers)(questionPossibleAnswers));
|
|
126
118
|
}
|
|
127
119
|
|
|
128
120
|
var partialScoringEnabled = getPartialScoring({
|
|
@@ -201,11 +193,13 @@ function model(question, session, env) {
|
|
|
201
193
|
var normalizedQuestion = normalize(question);
|
|
202
194
|
|
|
203
195
|
var _ref5 = normalizedQuestion || {},
|
|
196
|
+
defaultTool = _ref5.defaultTool,
|
|
204
197
|
prompt = _ref5.prompt,
|
|
205
198
|
promptEnabled = _ref5.promptEnabled,
|
|
206
199
|
graph = _ref5.graph,
|
|
207
200
|
answers = _ref5.answers,
|
|
208
|
-
|
|
201
|
+
toolbarTools = _ref5.toolbarTools,
|
|
202
|
+
questionProps = (0, _objectWithoutProperties2["default"])(_ref5, _excluded);
|
|
209
203
|
|
|
210
204
|
var arrows = normalizedQuestion.arrows;
|
|
211
205
|
|
|
@@ -231,17 +225,25 @@ function model(question, session, env) {
|
|
|
231
225
|
down: false
|
|
232
226
|
};
|
|
233
227
|
}
|
|
234
|
-
}
|
|
228
|
+
} // added support for models without defaultTool defined; also used in packages/graphing/configure/src/index.js
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
var toolbarToolsNoLabel = (toolbarTools || []).filter(function (tool) {
|
|
232
|
+
return tool !== 'label';
|
|
233
|
+
});
|
|
234
|
+
var normalizedDefaultTool = defaultTool || toolbarToolsNoLabel.length && toolbarToolsNoLabel[0] || '';
|
|
235
235
|
|
|
236
236
|
var base = _objectSpread(_objectSpread({}, questionProps), {}, {
|
|
237
237
|
answers: answers,
|
|
238
|
+
arrows: arrows,
|
|
239
|
+
defaultTool: normalizedDefaultTool,
|
|
238
240
|
disabled: env.mode !== 'gather',
|
|
239
241
|
prompt: promptEnabled ? prompt : null,
|
|
240
242
|
rationale: null,
|
|
241
243
|
size: graph,
|
|
242
244
|
showToggle: env.mode === 'evaluate' && !(0, _isEmpty["default"])(answers),
|
|
243
245
|
teacherInstructions: null,
|
|
244
|
-
|
|
246
|
+
toolbarTools: toolbarTools
|
|
245
247
|
});
|
|
246
248
|
|
|
247
249
|
if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
|
|
@@ -267,7 +269,7 @@ function model(question, session, env) {
|
|
|
267
269
|
base.correctResponse = bestScoreAnswerKey ? (answers[bestScoreAnswerKey] || {}).marks : [];
|
|
268
270
|
base.showToggle = base.showToggle && bestScore !== 1;
|
|
269
271
|
} else {
|
|
270
|
-
base.answersCorrected = [];
|
|
272
|
+
base.answersCorrected = session && session.answer || [];
|
|
271
273
|
base.correctResponse = [];
|
|
272
274
|
}
|
|
273
275
|
}
|