@pie-element/graphing-solution-set 1.8.1-next.1 → 1.8.1-next.6
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/lib/configure.js +398 -0
- package/configure/lib/configure.js.map +1 -0
- package/configure/lib/correct-response.js +601 -0
- package/configure/lib/correct-response.js.map +1 -0
- package/configure/lib/defaults.js +359 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/graphing-config.js +435 -0
- package/configure/lib/graphing-config.js.map +1 -0
- package/configure/lib/index.js +218 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +754 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +1 -1
- package/controller/lib/defaults.js +71 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +423 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +273 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/index.js +214 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +440 -0
- package/lib/main.js.map +1 -0
- package/lib/utils.js +604 -0
- package/lib/utils.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.CorrectResponse = void 0;
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var React = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
+
|
|
30
|
+
var _styles = require("@material-ui/core/styles");
|
|
31
|
+
|
|
32
|
+
var _graphingSolutionSet = require("@pie-lib/pie-toolbox/graphing-solution-set");
|
|
33
|
+
|
|
34
|
+
var _configUi = require("@pie-lib/pie-toolbox/config-ui");
|
|
35
|
+
|
|
36
|
+
var _lodash = require("lodash");
|
|
37
|
+
|
|
38
|
+
var _core = require("@material-ui/core");
|
|
39
|
+
|
|
40
|
+
var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));
|
|
41
|
+
|
|
42
|
+
var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
|
|
43
|
+
|
|
44
|
+
var _utils = require("./utils");
|
|
45
|
+
|
|
46
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
|
+
|
|
48
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
49
|
+
|
|
50
|
+
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; }
|
|
51
|
+
|
|
52
|
+
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; }
|
|
53
|
+
|
|
54
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
55
|
+
|
|
56
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
57
|
+
|
|
58
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
59
|
+
|
|
60
|
+
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); }; }
|
|
61
|
+
|
|
62
|
+
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; } }
|
|
63
|
+
|
|
64
|
+
var styles = function styles(theme) {
|
|
65
|
+
return {
|
|
66
|
+
column: {
|
|
67
|
+
flex: 1
|
|
68
|
+
},
|
|
69
|
+
graphingTools: {
|
|
70
|
+
color: theme.palette.grey['A200']
|
|
71
|
+
},
|
|
72
|
+
availableTool: {
|
|
73
|
+
cursor: 'pointer',
|
|
74
|
+
margin: theme.spacing.unit,
|
|
75
|
+
padding: theme.spacing.unit,
|
|
76
|
+
border: "2px solid ".concat(theme.palette.common.white),
|
|
77
|
+
textTransform: 'capitalize',
|
|
78
|
+
'&:hover': {
|
|
79
|
+
color: theme.palette.grey[800]
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
selectedTool: {
|
|
83
|
+
background: theme.palette.grey['A100'],
|
|
84
|
+
border: "2px solid ".concat(theme.palette.grey['A200'])
|
|
85
|
+
},
|
|
86
|
+
container: {
|
|
87
|
+
border: "2px solid ".concat(theme.palette.grey['A200']),
|
|
88
|
+
borderRadius: '4px',
|
|
89
|
+
padding: "0 ".concat(theme.spacing.unit * 4, "px ").concat(theme.spacing.unit * 2, "px"),
|
|
90
|
+
background: theme.palette.grey[50]
|
|
91
|
+
},
|
|
92
|
+
button: {
|
|
93
|
+
margin: "".concat(theme.spacing.unit * 2.5, "px 0"),
|
|
94
|
+
cursor: 'pointer',
|
|
95
|
+
background: theme.palette.grey[200],
|
|
96
|
+
padding: theme.spacing.unit * 1.5,
|
|
97
|
+
width: 'fit-content',
|
|
98
|
+
borderRadius: '4px',
|
|
99
|
+
'&:hover': {
|
|
100
|
+
background: theme.palette.grey['A100']
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
responseTitle: {
|
|
104
|
+
display: 'flex',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
marginTop: theme.spacing.unit * 2.5
|
|
107
|
+
},
|
|
108
|
+
iconButton: {
|
|
109
|
+
marginLeft: '6px',
|
|
110
|
+
color: theme.palette.grey[600],
|
|
111
|
+
'&:hover': {
|
|
112
|
+
cursor: 'pointer',
|
|
113
|
+
color: theme.palette.common.black
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
name: {
|
|
117
|
+
marginBottom: theme.spacing.unit / 2
|
|
118
|
+
},
|
|
119
|
+
tooltip: {
|
|
120
|
+
fontSize: theme.typography.fontSize - 2,
|
|
121
|
+
whiteSpace: 'pre',
|
|
122
|
+
maxWidth: '500px'
|
|
123
|
+
},
|
|
124
|
+
subtitleText: {
|
|
125
|
+
marginTop: theme.spacing.unit * 1.5,
|
|
126
|
+
marginBottom: theme.spacing.unit
|
|
127
|
+
},
|
|
128
|
+
toolsHeader: {
|
|
129
|
+
display: 'flex',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
justifyContent: 'space-between'
|
|
132
|
+
},
|
|
133
|
+
defaultTool: {
|
|
134
|
+
display: 'flex',
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
width: '300px'
|
|
137
|
+
},
|
|
138
|
+
defaultToolSelect: {
|
|
139
|
+
marginLeft: theme.spacing.unit,
|
|
140
|
+
textTransform: 'uppercase',
|
|
141
|
+
color: theme.palette.grey[800]
|
|
142
|
+
},
|
|
143
|
+
menuItem: {
|
|
144
|
+
textTransform: 'uppercase'
|
|
145
|
+
},
|
|
146
|
+
noDefaultTool: {
|
|
147
|
+
padding: theme.spacing.unit / 2
|
|
148
|
+
},
|
|
149
|
+
error: {
|
|
150
|
+
color: theme.palette.error.main
|
|
151
|
+
},
|
|
152
|
+
errorMessage: {
|
|
153
|
+
fontSize: theme.typography.fontSize - 2,
|
|
154
|
+
color: theme.palette.error.main,
|
|
155
|
+
marginTop: theme.spacing.unit
|
|
156
|
+
},
|
|
157
|
+
graphError: {
|
|
158
|
+
border: "2px solid ".concat(theme.palette.error.main)
|
|
159
|
+
},
|
|
160
|
+
radioButtonClass: {
|
|
161
|
+
height: '20px',
|
|
162
|
+
width: 'fit-content',
|
|
163
|
+
padding: '.5rem 0'
|
|
164
|
+
},
|
|
165
|
+
radioButton: {
|
|
166
|
+
color: '#000000 !important'
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var CorrectResponse = /*#__PURE__*/function (_React$Component) {
|
|
172
|
+
(0, _inherits2["default"])(CorrectResponse, _React$Component);
|
|
173
|
+
|
|
174
|
+
var _super = _createSuper(CorrectResponse);
|
|
175
|
+
|
|
176
|
+
function CorrectResponse() {
|
|
177
|
+
var _this;
|
|
178
|
+
|
|
179
|
+
(0, _classCallCheck2["default"])(this, CorrectResponse);
|
|
180
|
+
|
|
181
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
182
|
+
args[_key] = arguments[_key];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
186
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
187
|
+
dialog: {
|
|
188
|
+
open: false
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAlertDialog", function (open, callback) {
|
|
192
|
+
return _this.setState({
|
|
193
|
+
dialog: {
|
|
194
|
+
open: open
|
|
195
|
+
}
|
|
196
|
+
}, callback);
|
|
197
|
+
});
|
|
198
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeMarks", function (marks) {
|
|
199
|
+
var _this$props = _this.props,
|
|
200
|
+
model = _this$props.model,
|
|
201
|
+
onChange = _this$props.onChange;
|
|
202
|
+
var gssLineData = model.gssLineData;
|
|
203
|
+
|
|
204
|
+
if (gssLineData.selectedTool === 'lineA' && marks.length > 0) {
|
|
205
|
+
marks[0].fill = gssLineData['lineA'].lineType;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (gssLineData.selectedTool === 'lineB' && marks.length > 1) {
|
|
209
|
+
marks[1].fill = gssLineData['lineB'].lineType;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (marks.length === 0) {
|
|
213
|
+
gssLineData.selectedTool = 'lineA';
|
|
214
|
+
(0, _lodash.set)(model, "gssLineData", gssLineData);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
(0, _lodash.set)(model, "answers.correctAnswer.marks", marks);
|
|
218
|
+
onChange(model);
|
|
219
|
+
});
|
|
220
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onResetClick", function () {
|
|
221
|
+
var _this$props2 = _this.props,
|
|
222
|
+
model = _this$props2.model,
|
|
223
|
+
onChange = _this$props2.onChange;
|
|
224
|
+
var gssLineData = model.gssLineData,
|
|
225
|
+
answers = model.answers;
|
|
226
|
+
|
|
227
|
+
_this.setState({
|
|
228
|
+
dialog: {
|
|
229
|
+
open: true,
|
|
230
|
+
title: 'Warning',
|
|
231
|
+
text: "This will remove all the elements added on the graph and reset graph to original state. Are you sure you want to continue?",
|
|
232
|
+
onConfirm: function onConfirm() {
|
|
233
|
+
// Reset the graph to original state
|
|
234
|
+
answers.correctAnswer.marks = [];
|
|
235
|
+
gssLineData.selectedTool = 'lineA';
|
|
236
|
+
gssLineData.lineA.lineType = 'Solid';
|
|
237
|
+
if (gssLineData.lineB) gssLineData.lineB.lineType = 'Solid';
|
|
238
|
+
(0, _lodash.set)(model, "answers", answers);
|
|
239
|
+
(0, _lodash.set)(model, "gssLineData", gssLineData);
|
|
240
|
+
onChange(model);
|
|
241
|
+
|
|
242
|
+
_this.handleAlertDialog(false);
|
|
243
|
+
},
|
|
244
|
+
onClose: function onClose() {
|
|
245
|
+
return _this.handleAlertDialog(false);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeNumberOfLines", function (e, value) {
|
|
251
|
+
var model = _this.props.model;
|
|
252
|
+
var gssLineData = model.gssLineData;
|
|
253
|
+
|
|
254
|
+
if (gssLineData.selectedTool === 'solutionSet') {
|
|
255
|
+
_this.setState({
|
|
256
|
+
dialog: {
|
|
257
|
+
open: true,
|
|
258
|
+
title: 'Warning',
|
|
259
|
+
text: "Changing number of lines after adding solution set will remove added solution set. Are you sure you want to continue?",
|
|
260
|
+
onConfirm: function onConfirm() {
|
|
261
|
+
_this.changeLine(e, value);
|
|
262
|
+
|
|
263
|
+
_this.handleAlertDialog(false);
|
|
264
|
+
},
|
|
265
|
+
onClose: function onClose() {
|
|
266
|
+
return _this.handleAlertDialog(false);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
} else {
|
|
271
|
+
_this.changeLine(e, value);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeLine", function (e, value) {
|
|
275
|
+
var _this$props3 = _this.props,
|
|
276
|
+
model = _this$props3.model,
|
|
277
|
+
onChange = _this$props3.onChange;
|
|
278
|
+
var answers = model.answers;
|
|
279
|
+
var gssLineData = model.gssLineData; //remove polygon from correct answer
|
|
280
|
+
|
|
281
|
+
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(function (mark) {
|
|
282
|
+
return mark.type !== 'polygon';
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
if (Number.parseInt(value) === 1) {
|
|
286
|
+
//remove lineB from gssLineData and correct answer
|
|
287
|
+
delete gssLineData.lineB;
|
|
288
|
+
if (answers.correctAnswer.marks.length > 1) answers.correctAnswer.marks.pop();
|
|
289
|
+
gssLineData.numberOfLines = 1;
|
|
290
|
+
gssLineData.selectedTool = 'lineA';
|
|
291
|
+
} else {
|
|
292
|
+
gssLineData.numberOfLines = 2;
|
|
293
|
+
if (answers.correctAnswer.marks.length > 0) gssLineData.selectedTool = 'lineB';
|
|
294
|
+
gssLineData.lineB = {
|
|
295
|
+
lineType: 'Solid'
|
|
296
|
+
};
|
|
297
|
+
} //reset solution set
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
(0, _lodash.set)(model, "answers", answers);
|
|
301
|
+
(0, _lodash.set)(model, "gssLineData", gssLineData);
|
|
302
|
+
onChange(model);
|
|
303
|
+
});
|
|
304
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSolutionSetSelected", function (point) {
|
|
305
|
+
var _this$props4 = _this.props,
|
|
306
|
+
model = _this$props4.model,
|
|
307
|
+
onChange = _this$props4.onChange;
|
|
308
|
+
var answers = model.answers,
|
|
309
|
+
gssLineData = model.gssLineData;
|
|
310
|
+
|
|
311
|
+
var _iterator = _createForOfIteratorHelper(gssLineData.sections),
|
|
312
|
+
_step;
|
|
313
|
+
|
|
314
|
+
try {
|
|
315
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
316
|
+
var section = _step.value;
|
|
317
|
+
|
|
318
|
+
//check if the point is inside the polygon
|
|
319
|
+
if ((0, _utils.pointInsidePolygon)(point, section)) {
|
|
320
|
+
var polygon = {
|
|
321
|
+
points: section,
|
|
322
|
+
building: false,
|
|
323
|
+
type: 'polygon',
|
|
324
|
+
closed: true,
|
|
325
|
+
isSolution: true
|
|
326
|
+
}; //remove old answer section from correct answer
|
|
327
|
+
|
|
328
|
+
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(function (mark) {
|
|
329
|
+
return mark.type !== 'polygon';
|
|
330
|
+
}); //add new answer section to correct answer
|
|
331
|
+
|
|
332
|
+
answers.correctAnswer.marks.push(polygon);
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
} catch (err) {
|
|
337
|
+
_iterator.e(err);
|
|
338
|
+
} finally {
|
|
339
|
+
_iterator.f();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
(0, _lodash.set)(model, "answers", answers);
|
|
343
|
+
onChange(model);
|
|
344
|
+
});
|
|
345
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeGssLineData", function (gssLineData, oldSelectedTool) {
|
|
346
|
+
var model = _this.props.model;
|
|
347
|
+
var answers = model.answers,
|
|
348
|
+
domain = model.domain,
|
|
349
|
+
range = model.range; //handle solution set changes
|
|
350
|
+
|
|
351
|
+
if (gssLineData.selectedTool === 'solutionSet') {
|
|
352
|
+
var lines = answers.correctAnswer.marks.filter(function (mark) {
|
|
353
|
+
return mark.type !== 'polygon';
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
if (!(0, _utils.checkIfLinesAreAdded)(gssLineData, lines)) {
|
|
357
|
+
gssLineData.selectedTool = oldSelectedTool;
|
|
358
|
+
|
|
359
|
+
_this.setState({
|
|
360
|
+
dialog: {
|
|
361
|
+
open: true,
|
|
362
|
+
title: 'Warning',
|
|
363
|
+
text: "Please define the line(s) and then select a solution set for the item.",
|
|
364
|
+
onConfirm: function onConfirm() {
|
|
365
|
+
return _this.handleAlertDialog(false);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
} else {
|
|
370
|
+
var _lines = answers.correctAnswer.marks.filter(function (mark) {
|
|
371
|
+
return mark.type !== 'polygon';
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
gssLineData = (0, _utils.findSectionsInSolutionSet)(gssLineData, _lines, domain, range);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
_this.handleGssLineDataChange(gssLineData, answers);
|
|
378
|
+
} else {
|
|
379
|
+
var polygons = answers.correctAnswer.marks.filter(function (mark) {
|
|
380
|
+
return mark.type === 'polygon';
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
if (oldSelectedTool === 'solutionSet' && polygons.length > 0) {
|
|
384
|
+
_this.setState({
|
|
385
|
+
dialog: {
|
|
386
|
+
open: true,
|
|
387
|
+
title: 'Warning',
|
|
388
|
+
text: "Changing a line after adding a solution set will clear your selected solution set. Click 'Clear Solution Set' to change the line. Otherwise, click 'Cancel'.",
|
|
389
|
+
onConfirm: function onConfirm() {
|
|
390
|
+
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(function (mark) {
|
|
391
|
+
return mark.type !== 'polygon';
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
_this.handleGssLineDataChange(gssLineData, answers);
|
|
395
|
+
|
|
396
|
+
_this.handleAlertDialog(false);
|
|
397
|
+
},
|
|
398
|
+
onConfirmText: 'CLEAR SOLUTION SET',
|
|
399
|
+
onClose: function onClose() {
|
|
400
|
+
gssLineData.selectedTool = oldSelectedTool;
|
|
401
|
+
|
|
402
|
+
_this.handleGssLineDataChange(gssLineData, answers);
|
|
403
|
+
|
|
404
|
+
_this.handleAlertDialog(false);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
} else {
|
|
409
|
+
_this.handleGssLineDataChange(gssLineData, answers);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleGssLineDataChange", function (gssLineData, answers) {
|
|
414
|
+
var _this$props5 = _this.props,
|
|
415
|
+
model = _this$props5.model,
|
|
416
|
+
onChange = _this$props5.onChange; //handle line type changes from solid to dashed and vice versa
|
|
417
|
+
|
|
418
|
+
if (answers.correctAnswer.marks.length > 0 && answers.correctAnswer.marks[0] && gssLineData.lineA) {
|
|
419
|
+
answers.correctAnswer.marks[0].fill = gssLineData.lineA.lineType;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if (answers.correctAnswer.marks.length > 1 && answers.correctAnswer.marks[1] && gssLineData.lineB) {
|
|
423
|
+
answers.correctAnswer.marks[1].fill = gssLineData.lineB.lineType;
|
|
424
|
+
} //check if line is added to the graph before switching to lineB
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
if (gssLineData.selectedTool === 'lineB' && answers.correctAnswer.marks.length === 0 || gssLineData.selectedTool === 'lineB' && answers.correctAnswer.marks[0].building) {
|
|
428
|
+
_this.setState({
|
|
429
|
+
dialog: {
|
|
430
|
+
open: true,
|
|
431
|
+
title: 'Warning',
|
|
432
|
+
text: "Please add Line A to the graph before adding Line B",
|
|
433
|
+
onConfirm: function onConfirm() {
|
|
434
|
+
return _this.handleAlertDialog(false);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
gssLineData.selectedTool = 'lineA';
|
|
440
|
+
} //check if lineB is added to the graph before switching to lineA
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
if (gssLineData.selectedTool === 'lineA' && answers.correctAnswer.marks.length > 1 && answers.correctAnswer.marks[1].building) {
|
|
444
|
+
_this.setState({
|
|
445
|
+
dialog: {
|
|
446
|
+
open: true,
|
|
447
|
+
title: 'Warning',
|
|
448
|
+
text: "Please add Line B to the graph before switching to Line A",
|
|
449
|
+
onConfirm: function onConfirm() {
|
|
450
|
+
return _this.handleAlertDialog(false);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
gssLineData.selectedTool = 'lineB';
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
(0, _lodash.set)(model, "gssLineData", gssLineData);
|
|
459
|
+
(0, _lodash.set)(model, "answers", answers);
|
|
460
|
+
onChange(model);
|
|
461
|
+
});
|
|
462
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateModel", function (props) {
|
|
463
|
+
var _this$props6 = _this.props,
|
|
464
|
+
model = _this$props6.model,
|
|
465
|
+
onChange = _this$props6.onChange;
|
|
466
|
+
onChange(_objectSpread(_objectSpread({}, model), props));
|
|
467
|
+
});
|
|
468
|
+
return _this;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
(0, _createClass2["default"])(CorrectResponse, [{
|
|
472
|
+
key: "render",
|
|
473
|
+
value:
|
|
474
|
+
/*
|
|
475
|
+
* Render the component
|
|
476
|
+
* */
|
|
477
|
+
function render() {
|
|
478
|
+
var _this2 = this;
|
|
479
|
+
|
|
480
|
+
var _this$props7 = this.props,
|
|
481
|
+
classes = _this$props7.classes,
|
|
482
|
+
errors = _this$props7.errors,
|
|
483
|
+
model = _this$props7.model,
|
|
484
|
+
_this$props7$mathMlOp = _this$props7.mathMlOptions,
|
|
485
|
+
mathMlOptions = _this$props7$mathMlOp === void 0 ? {} : _this$props7$mathMlOp;
|
|
486
|
+
var dialog = this.state.dialog; //get the default values to GssLineData
|
|
487
|
+
|
|
488
|
+
var _ref = model || {},
|
|
489
|
+
_ref$gssLineData = _ref.gssLineData,
|
|
490
|
+
gssLineData = _ref$gssLineData === void 0 ? {
|
|
491
|
+
numberOfLines: 1,
|
|
492
|
+
selectedTool: 'lineA',
|
|
493
|
+
lineA: {
|
|
494
|
+
lineType: 'Solid'
|
|
495
|
+
}
|
|
496
|
+
} : _ref$gssLineData,
|
|
497
|
+
arrows = _ref.arrows,
|
|
498
|
+
coordinatesOnHover = _ref.coordinatesOnHover,
|
|
499
|
+
domain = _ref.domain,
|
|
500
|
+
_ref$graph = _ref.graph,
|
|
501
|
+
graph = _ref$graph === void 0 ? {} : _ref$graph,
|
|
502
|
+
labels = _ref.labels,
|
|
503
|
+
labelsEnabled = _ref.labelsEnabled,
|
|
504
|
+
range = _ref.range,
|
|
505
|
+
title = _ref.title,
|
|
506
|
+
titleEnabled = _ref.titleEnabled,
|
|
507
|
+
marks = _ref.marks,
|
|
508
|
+
answers = _ref.answers;
|
|
509
|
+
|
|
510
|
+
var _ref2 = errors || {},
|
|
511
|
+
_ref2$correctAnswerEr = _ref2.correctAnswerErrors,
|
|
512
|
+
correctAnswerErrors = _ref2$correctAnswerEr === void 0 ? '' : _ref2$correctAnswerEr;
|
|
513
|
+
|
|
514
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_core.Typography, {
|
|
515
|
+
component: "div",
|
|
516
|
+
variant: "subheading"
|
|
517
|
+
}, "Define Line Type(s) and Correct Response"), /*#__PURE__*/React.createElement(_core.Typography, {
|
|
518
|
+
component: "div",
|
|
519
|
+
variant: "body1",
|
|
520
|
+
className: classes.subtitleText
|
|
521
|
+
}, "Use this interface to choose how many lines students will be able to draw, and to define the correct answer."), /*#__PURE__*/React.createElement(_core.Typography, {
|
|
522
|
+
component: "div",
|
|
523
|
+
variant: "body1",
|
|
524
|
+
className: classes.subtitleText
|
|
525
|
+
}, "Choose Number of Lines"), /*#__PURE__*/React.createElement(_core.RadioGroup, {
|
|
526
|
+
name: "numberOfLines",
|
|
527
|
+
value: gssLineData.numberOfLines,
|
|
528
|
+
onChange: this.changeNumberOfLines
|
|
529
|
+
}, /*#__PURE__*/React.createElement(_FormControlLabel["default"], {
|
|
530
|
+
className: classes.radioButtonClass,
|
|
531
|
+
value: "1",
|
|
532
|
+
control: /*#__PURE__*/React.createElement(_Radio["default"], {
|
|
533
|
+
checked: gssLineData.numberOfLines === 1,
|
|
534
|
+
className: classes.radioButton
|
|
535
|
+
}),
|
|
536
|
+
label: "One"
|
|
537
|
+
}), /*#__PURE__*/React.createElement(_FormControlLabel["default"], {
|
|
538
|
+
className: classes.radioButtonClass,
|
|
539
|
+
value: "2",
|
|
540
|
+
control: /*#__PURE__*/React.createElement(_Radio["default"], {
|
|
541
|
+
checked: gssLineData.numberOfLines === 2,
|
|
542
|
+
className: classes.radioButton
|
|
543
|
+
}),
|
|
544
|
+
label: "Two"
|
|
545
|
+
})), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_graphingSolutionSet.GraphContainer, {
|
|
546
|
+
className: correctAnswerErrors['correctAnswer'] && classes.graphError,
|
|
547
|
+
axesSettings: {
|
|
548
|
+
includeArrows: arrows
|
|
549
|
+
},
|
|
550
|
+
backgroundMarks: [],
|
|
551
|
+
coordinatesOnHover: coordinatesOnHover,
|
|
552
|
+
disabledLabels: true,
|
|
553
|
+
disabledTitle: true,
|
|
554
|
+
domain: domain,
|
|
555
|
+
draggableTools: true,
|
|
556
|
+
labels: labels,
|
|
557
|
+
marks: answers && answers.correctAnswer && answers.correctAnswer.marks ? answers.correctAnswer.marks : [],
|
|
558
|
+
onChangeMarks: function onChangeMarks(newMarks) {
|
|
559
|
+
return _this2.changeMarks(newMarks);
|
|
560
|
+
},
|
|
561
|
+
onCustomReset: this.onResetClick,
|
|
562
|
+
range: range,
|
|
563
|
+
showLabels: labelsEnabled,
|
|
564
|
+
showTitle: titleEnabled,
|
|
565
|
+
size: {
|
|
566
|
+
width: graph.width,
|
|
567
|
+
height: graph.height
|
|
568
|
+
},
|
|
569
|
+
title: title,
|
|
570
|
+
gssLineData: gssLineData,
|
|
571
|
+
onChangeGssLineData: this.onChangeGssLineData,
|
|
572
|
+
onSolutionSetSelected: this.onSolutionSetSelected,
|
|
573
|
+
toolbarTools: ['line', 'polygon'],
|
|
574
|
+
mathMlOptions: mathMlOptions
|
|
575
|
+
}), correctAnswerErrors['correctAnswer'] && /*#__PURE__*/React.createElement("div", {
|
|
576
|
+
className: classes.errorMessage
|
|
577
|
+
}, correctAnswerErrors['correctAnswer'])), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
|
|
578
|
+
open: dialog.open,
|
|
579
|
+
title: dialog.title,
|
|
580
|
+
text: dialog.text,
|
|
581
|
+
onClose: dialog.onClose,
|
|
582
|
+
onConfirm: dialog.onConfirm,
|
|
583
|
+
onConfirmText: dialog.onConfirmText ? dialog.onConfirmText : 'OK'
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
}]);
|
|
587
|
+
return CorrectResponse;
|
|
588
|
+
}(React.Component);
|
|
589
|
+
|
|
590
|
+
exports.CorrectResponse = CorrectResponse;
|
|
591
|
+
(0, _defineProperty2["default"])(CorrectResponse, "propTypes", {
|
|
592
|
+
classes: _propTypes["default"].object.isRequired,
|
|
593
|
+
errors: _propTypes["default"].object,
|
|
594
|
+
model: _propTypes["default"].object.isRequired,
|
|
595
|
+
onChange: _propTypes["default"].func.isRequired
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
var _default = (0, _styles.withStyles)(styles)(CorrectResponse);
|
|
599
|
+
|
|
600
|
+
exports["default"] = _default;
|
|
601
|
+
//# sourceMappingURL=correct-response.js.map
|