@pie-element/graphing-solution-set 4.3.4-next.0 → 5.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/configure.js +288 -376
- package/configure/lib/configure.js.map +1 -1
- package/configure/lib/correct-response.js +309 -475
- package/configure/lib/correct-response.js.map +1 -1
- package/configure/lib/defaults.js +2 -4
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/graphing-config.js +329 -363
- package/configure/lib/graphing-config.js.map +1 -1
- package/configure/lib/index.js +126 -181
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/utils.js +178 -301
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +11 -8
- package/controller/lib/defaults.js +2 -4
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +146 -218
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +85 -142
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +3 -3
- package/lib/index.js +120 -170
- package/lib/index.js.map +1 -1
- package/lib/main.js +261 -350
- package/lib/main.js.map +1 -1
- package/lib/utils.js +142 -231
- package/lib/utils.js.map +1 -1
- package/package.json +13 -10
|
@@ -1,287 +1,161 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
|
8
5
|
value: true
|
|
9
6
|
});
|
|
10
|
-
exports
|
|
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
|
-
|
|
7
|
+
exports.default = exports.CorrectResponse = void 0;
|
|
24
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
9
|
var React = _interopRequireWildcard(require("react"));
|
|
27
|
-
|
|
28
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
-
|
|
30
|
-
var _styles = require("@material-ui/core/styles");
|
|
31
|
-
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
32
12
|
var _graphingSolutionSet = require("@pie-lib/graphing-solution-set");
|
|
33
|
-
|
|
34
13
|
var _configUi = require("@pie-lib/config-ui");
|
|
35
|
-
|
|
36
14
|
var _lodash = require("lodash");
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));
|
|
41
|
-
|
|
42
|
-
var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));
|
|
43
|
-
|
|
15
|
+
var _material = require("@mui/material");
|
|
16
|
+
var _Radio = _interopRequireDefault(require("@mui/material/Radio"));
|
|
17
|
+
var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
|
|
44
18
|
var _utils = require("./utils");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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", {
|
|
19
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
20
|
+
const SubtitleText = (0, _styles.styled)(_material.Typography)(({
|
|
21
|
+
theme
|
|
22
|
+
}) => ({
|
|
23
|
+
marginTop: theme.spacing(1.5),
|
|
24
|
+
marginBottom: theme.spacing(1)
|
|
25
|
+
}));
|
|
26
|
+
const RadioButtonClass = (0, _styles.styled)(_FormControlLabel.default)({
|
|
27
|
+
height: '20px',
|
|
28
|
+
width: 'fit-content',
|
|
29
|
+
padding: '.5rem 0'
|
|
30
|
+
});
|
|
31
|
+
const StyledRadio = (0, _styles.styled)(_Radio.default)({
|
|
32
|
+
color: '#000000 !important'
|
|
33
|
+
});
|
|
34
|
+
const ErrorMessage = (0, _styles.styled)('div')(({
|
|
35
|
+
theme
|
|
36
|
+
}) => ({
|
|
37
|
+
fontSize: theme.typography.fontSize - 2,
|
|
38
|
+
color: theme.palette.error.main,
|
|
39
|
+
paddingTop: theme.spacing(1)
|
|
40
|
+
}));
|
|
41
|
+
class CorrectResponse extends React.Component {
|
|
42
|
+
constructor(...args) {
|
|
43
|
+
super(...args);
|
|
44
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
187
45
|
dialog: {
|
|
188
46
|
open: false
|
|
189
47
|
}
|
|
190
48
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
49
|
+
/*
|
|
50
|
+
* Function to handle the alert dialog open and close
|
|
51
|
+
* @param {boolean} open - open or close the dialog
|
|
52
|
+
* @param {function} callback - callback function to be called after setting the state
|
|
53
|
+
* */
|
|
54
|
+
(0, _defineProperty2.default)(this, "handleAlertDialog", (open, callback) => this.setState({
|
|
55
|
+
dialog: {
|
|
56
|
+
open
|
|
57
|
+
}
|
|
58
|
+
}, callback));
|
|
59
|
+
/*
|
|
60
|
+
* Function to change the marks on the graph
|
|
61
|
+
* @param {array} marks - marks to be added on the graph
|
|
62
|
+
* */
|
|
63
|
+
(0, _defineProperty2.default)(this, "changeMarks", marks => {
|
|
64
|
+
const {
|
|
65
|
+
model,
|
|
66
|
+
onChange
|
|
67
|
+
} = this.props;
|
|
68
|
+
const {
|
|
69
|
+
gssLineData
|
|
70
|
+
} = model;
|
|
204
71
|
if (gssLineData.selectedTool === 'lineA' && marks.length > 0) {
|
|
205
72
|
marks[0].fill = gssLineData['lineA'].lineType;
|
|
206
73
|
}
|
|
207
|
-
|
|
208
74
|
if (gssLineData.selectedTool === 'lineB' && marks.length > 1) {
|
|
209
75
|
marks[1].fill = gssLineData['lineB'].lineType;
|
|
210
76
|
}
|
|
211
|
-
|
|
212
77
|
if (marks.length === 0) {
|
|
213
78
|
gssLineData.selectedTool = 'lineA';
|
|
214
|
-
(0, _lodash.set)(model,
|
|
79
|
+
(0, _lodash.set)(model, 'gssLineData', gssLineData);
|
|
215
80
|
}
|
|
216
|
-
|
|
217
|
-
(0, _lodash.set)(model, "answers.correctAnswer.marks", marks);
|
|
81
|
+
(0, _lodash.set)(model, 'answers.correctAnswer.marks', marks);
|
|
218
82
|
onChange(model);
|
|
219
83
|
});
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
84
|
+
/*
|
|
85
|
+
* Reset the graph to original state and remove all the elements added on the graph
|
|
86
|
+
* */
|
|
87
|
+
(0, _defineProperty2.default)(this, "onResetClick", () => {
|
|
88
|
+
const {
|
|
89
|
+
model,
|
|
90
|
+
onChange
|
|
91
|
+
} = this.props;
|
|
92
|
+
const {
|
|
93
|
+
gssLineData,
|
|
94
|
+
answers
|
|
95
|
+
} = model;
|
|
96
|
+
this.setState({
|
|
228
97
|
dialog: {
|
|
229
98
|
open: true,
|
|
230
99
|
title: 'Warning',
|
|
231
|
-
text:
|
|
232
|
-
onConfirm:
|
|
100
|
+
text: 'This will remove all the elements added on the graph and reset graph to original state. Are you sure you want to continue?',
|
|
101
|
+
onConfirm: () => {
|
|
233
102
|
// Reset the graph to original state
|
|
234
103
|
answers.correctAnswer.marks = [];
|
|
235
104
|
gssLineData.selectedTool = 'lineA';
|
|
236
105
|
gssLineData.lineA.lineType = 'Solid';
|
|
237
106
|
if (gssLineData.lineB) gssLineData.lineB.lineType = 'Solid';
|
|
238
|
-
(0, _lodash.set)(model,
|
|
239
|
-
(0, _lodash.set)(model,
|
|
107
|
+
(0, _lodash.set)(model, 'answers', answers);
|
|
108
|
+
(0, _lodash.set)(model, 'gssLineData', gssLineData);
|
|
240
109
|
onChange(model);
|
|
241
|
-
|
|
242
|
-
_this.handleAlertDialog(false);
|
|
110
|
+
this.handleAlertDialog(false);
|
|
243
111
|
},
|
|
244
|
-
onClose:
|
|
245
|
-
return _this.handleAlertDialog(false);
|
|
246
|
-
}
|
|
112
|
+
onClose: () => this.handleAlertDialog(false)
|
|
247
113
|
}
|
|
248
114
|
});
|
|
249
115
|
});
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
116
|
+
/*
|
|
117
|
+
* Function to change the number of lines on the graph
|
|
118
|
+
* @param {object} e - event object
|
|
119
|
+
* @param {number} value - number of lines to be added on the graph
|
|
120
|
+
* */
|
|
121
|
+
(0, _defineProperty2.default)(this, "changeNumberOfLines", (e, value) => {
|
|
122
|
+
const {
|
|
123
|
+
model
|
|
124
|
+
} = this.props;
|
|
125
|
+
let gssLineData = model.gssLineData;
|
|
254
126
|
if (gssLineData.selectedTool === 'solutionSet') {
|
|
255
|
-
|
|
127
|
+
this.setState({
|
|
256
128
|
dialog: {
|
|
257
129
|
open: true,
|
|
258
130
|
title: 'Warning',
|
|
259
|
-
text:
|
|
260
|
-
onConfirm:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
_this.handleAlertDialog(false);
|
|
131
|
+
text: 'Changing number of lines after adding solution set will remove added solution set. Are you sure you want to continue?',
|
|
132
|
+
onConfirm: () => {
|
|
133
|
+
this.changeLine(e, value);
|
|
134
|
+
this.handleAlertDialog(false);
|
|
264
135
|
},
|
|
265
|
-
onClose:
|
|
266
|
-
return _this.handleAlertDialog(false);
|
|
267
|
-
}
|
|
136
|
+
onClose: () => this.handleAlertDialog(false)
|
|
268
137
|
}
|
|
269
138
|
});
|
|
270
139
|
} else {
|
|
271
|
-
|
|
140
|
+
this.changeLine(e, value);
|
|
272
141
|
}
|
|
273
142
|
});
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
143
|
+
/*
|
|
144
|
+
* Function to change the number of line on the graph
|
|
145
|
+
* @param {object} e - event object
|
|
146
|
+
* @param {number} value - number of lines to be added on the graph
|
|
147
|
+
* */
|
|
148
|
+
(0, _defineProperty2.default)(this, "changeLine", (e, value) => {
|
|
149
|
+
const {
|
|
150
|
+
model,
|
|
151
|
+
onChange
|
|
152
|
+
} = this.props;
|
|
153
|
+
const {
|
|
154
|
+
answers
|
|
155
|
+
} = model;
|
|
156
|
+
let gssLineData = model.gssLineData;
|
|
157
|
+
//remove polygon from correct answer
|
|
158
|
+
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(mark => mark.type !== 'polygon');
|
|
285
159
|
if (Number.parseInt(value) === 1) {
|
|
286
160
|
//remove lineB from gssLineData and correct answer
|
|
287
161
|
delete gssLineData.lineB;
|
|
@@ -294,308 +168,268 @@ var CorrectResponse = /*#__PURE__*/function (_React$Component) {
|
|
|
294
168
|
gssLineData.lineB = {
|
|
295
169
|
lineType: 'Solid'
|
|
296
170
|
};
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
(0, _lodash.set)(model,
|
|
301
|
-
(0, _lodash.set)(model, "gssLineData", gssLineData);
|
|
171
|
+
}
|
|
172
|
+
//reset solution set
|
|
173
|
+
(0, _lodash.set)(model, 'answers', answers);
|
|
174
|
+
(0, _lodash.set)(model, 'gssLineData', gssLineData);
|
|
302
175
|
onChange(model);
|
|
303
176
|
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
answers.correctAnswer.marks.push(polygon);
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
177
|
+
/*
|
|
178
|
+
* Function to handle the changes to solution set on the graph
|
|
179
|
+
* @param {object} point - point selected on the graph
|
|
180
|
+
* */
|
|
181
|
+
(0, _defineProperty2.default)(this, "onSolutionSetSelected", point => {
|
|
182
|
+
const {
|
|
183
|
+
model,
|
|
184
|
+
onChange
|
|
185
|
+
} = this.props;
|
|
186
|
+
const {
|
|
187
|
+
answers,
|
|
188
|
+
gssLineData
|
|
189
|
+
} = model;
|
|
190
|
+
for (const section of gssLineData.sections) {
|
|
191
|
+
//check if the point is inside the polygon
|
|
192
|
+
if ((0, _utils.pointInsidePolygon)(point, section)) {
|
|
193
|
+
let polygon = {
|
|
194
|
+
points: section,
|
|
195
|
+
building: false,
|
|
196
|
+
type: 'polygon',
|
|
197
|
+
closed: true,
|
|
198
|
+
isSolution: true
|
|
199
|
+
};
|
|
200
|
+
//remove old answer section from correct answer
|
|
201
|
+
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(mark => mark.type !== 'polygon');
|
|
202
|
+
//add new answer section to correct answer
|
|
203
|
+
answers.correctAnswer.marks.push(polygon);
|
|
204
|
+
break;
|
|
335
205
|
}
|
|
336
|
-
} catch (err) {
|
|
337
|
-
_iterator.e(err);
|
|
338
|
-
} finally {
|
|
339
|
-
_iterator.f();
|
|
340
206
|
}
|
|
341
|
-
|
|
342
|
-
(0, _lodash.set)(model, "answers", answers);
|
|
207
|
+
(0, _lodash.set)(model, 'answers', answers);
|
|
343
208
|
onChange(model);
|
|
344
209
|
});
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
210
|
+
/*
|
|
211
|
+
* Function to handle the changes to line data on the graph
|
|
212
|
+
* @param {object} gssLineData - line data on the graph
|
|
213
|
+
* @param {string} oldSelectedTool - old selected tool
|
|
214
|
+
* */
|
|
215
|
+
(0, _defineProperty2.default)(this, "onChangeGssLineData", (gssLineData, oldSelectedTool) => {
|
|
216
|
+
const {
|
|
217
|
+
model
|
|
218
|
+
} = this.props;
|
|
219
|
+
const {
|
|
220
|
+
answers,
|
|
221
|
+
domain,
|
|
222
|
+
range
|
|
223
|
+
} = model;
|
|
224
|
+
//handle solution set changes
|
|
351
225
|
if (gssLineData.selectedTool === 'solutionSet') {
|
|
352
|
-
|
|
353
|
-
return mark.type !== 'polygon';
|
|
354
|
-
});
|
|
355
|
-
|
|
226
|
+
let lines = answers.correctAnswer.marks.filter(mark => mark.type !== 'polygon');
|
|
356
227
|
if (!(0, _utils.checkIfLinesAreAdded)(gssLineData, lines)) {
|
|
357
228
|
gssLineData.selectedTool = oldSelectedTool;
|
|
358
|
-
|
|
359
|
-
_this.setState({
|
|
229
|
+
this.setState({
|
|
360
230
|
dialog: {
|
|
361
231
|
open: true,
|
|
362
232
|
title: 'Warning',
|
|
363
|
-
text:
|
|
364
|
-
onConfirm:
|
|
365
|
-
return _this.handleAlertDialog(false);
|
|
366
|
-
}
|
|
233
|
+
text: 'Please define the line(s) and then select a solution set for the item.',
|
|
234
|
+
onConfirm: () => this.handleAlertDialog(false)
|
|
367
235
|
}
|
|
368
236
|
});
|
|
369
237
|
} else {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
gssLineData = (0, _utils.findSectionsInSolutionSet)(gssLineData, _lines, domain, range);
|
|
238
|
+
let lines = answers.correctAnswer.marks.filter(mark => mark.type !== 'polygon');
|
|
239
|
+
gssLineData = (0, _utils.findSectionsInSolutionSet)(gssLineData, lines, domain, range);
|
|
375
240
|
}
|
|
376
|
-
|
|
377
|
-
_this.handleGssLineDataChange(gssLineData, answers);
|
|
241
|
+
this.handleGssLineDataChange(gssLineData, answers);
|
|
378
242
|
} else {
|
|
379
|
-
|
|
380
|
-
return mark.type === 'polygon';
|
|
381
|
-
});
|
|
382
|
-
|
|
243
|
+
let polygons = answers.correctAnswer.marks.filter(mark => mark.type === 'polygon');
|
|
383
244
|
if (oldSelectedTool === 'solutionSet' && polygons.length > 0) {
|
|
384
|
-
|
|
245
|
+
this.setState({
|
|
385
246
|
dialog: {
|
|
386
247
|
open: true,
|
|
387
248
|
title: 'Warning',
|
|
388
|
-
text:
|
|
389
|
-
onConfirm:
|
|
390
|
-
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
_this.handleGssLineDataChange(gssLineData, answers);
|
|
395
|
-
|
|
396
|
-
_this.handleAlertDialog(false);
|
|
249
|
+
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\'.',
|
|
250
|
+
onConfirm: () => {
|
|
251
|
+
answers.correctAnswer.marks = answers.correctAnswer.marks.filter(mark => mark.type !== 'polygon');
|
|
252
|
+
this.handleGssLineDataChange(gssLineData, answers);
|
|
253
|
+
this.handleAlertDialog(false);
|
|
397
254
|
},
|
|
398
255
|
onConfirmText: 'CLEAR SOLUTION SET',
|
|
399
|
-
onClose:
|
|
256
|
+
onClose: () => {
|
|
400
257
|
gssLineData.selectedTool = oldSelectedTool;
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
_this.handleAlertDialog(false);
|
|
258
|
+
this.handleGssLineDataChange(gssLineData, answers);
|
|
259
|
+
this.handleAlertDialog(false);
|
|
405
260
|
}
|
|
406
261
|
}
|
|
407
262
|
});
|
|
408
263
|
} else {
|
|
409
|
-
|
|
264
|
+
this.handleGssLineDataChange(gssLineData, answers);
|
|
410
265
|
}
|
|
411
266
|
}
|
|
412
267
|
});
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
268
|
+
/*
|
|
269
|
+
* Function to handle the changes to line data on the graph
|
|
270
|
+
* @param {object} gssLineData - line data on the graph
|
|
271
|
+
* @param {object} answers - correct answer
|
|
272
|
+
* */
|
|
273
|
+
(0, _defineProperty2.default)(this, "handleGssLineDataChange", (gssLineData, answers) => {
|
|
274
|
+
const {
|
|
275
|
+
model,
|
|
276
|
+
onChange
|
|
277
|
+
} = this.props;
|
|
278
|
+
//handle line type changes from solid to dashed and vice versa
|
|
418
279
|
if (answers.correctAnswer.marks.length > 0 && answers.correctAnswer.marks[0] && gssLineData.lineA) {
|
|
419
280
|
answers.correctAnswer.marks[0].fill = gssLineData.lineA.lineType;
|
|
420
281
|
}
|
|
421
|
-
|
|
422
282
|
if (answers.correctAnswer.marks.length > 1 && answers.correctAnswer.marks[1] && gssLineData.lineB) {
|
|
423
283
|
answers.correctAnswer.marks[1].fill = gssLineData.lineB.lineType;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
|
|
284
|
+
}
|
|
285
|
+
//check if line is added to the graph before switching to lineB
|
|
427
286
|
if (gssLineData.selectedTool === 'lineB' && answers.correctAnswer.marks.length === 0 || gssLineData.selectedTool === 'lineB' && answers.correctAnswer.marks[0].building) {
|
|
428
|
-
|
|
287
|
+
this.setState({
|
|
429
288
|
dialog: {
|
|
430
289
|
open: true,
|
|
431
290
|
title: 'Warning',
|
|
432
|
-
text:
|
|
433
|
-
onConfirm:
|
|
434
|
-
return _this.handleAlertDialog(false);
|
|
435
|
-
}
|
|
291
|
+
text: 'Please add Line A to the graph before adding Line B',
|
|
292
|
+
onConfirm: () => this.handleAlertDialog(false)
|
|
436
293
|
}
|
|
437
294
|
});
|
|
438
|
-
|
|
439
295
|
gssLineData.selectedTool = 'lineA';
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
296
|
+
}
|
|
297
|
+
//check if lineB is added to the graph before switching to lineA
|
|
443
298
|
if (gssLineData.selectedTool === 'lineA' && answers.correctAnswer.marks.length > 1 && answers.correctAnswer.marks[1].building) {
|
|
444
|
-
|
|
299
|
+
this.setState({
|
|
445
300
|
dialog: {
|
|
446
301
|
open: true,
|
|
447
302
|
title: 'Warning',
|
|
448
|
-
text:
|
|
449
|
-
onConfirm:
|
|
450
|
-
return _this.handleAlertDialog(false);
|
|
451
|
-
}
|
|
303
|
+
text: 'Please add Line B to the graph before switching to Line A',
|
|
304
|
+
onConfirm: () => this.handleAlertDialog(false)
|
|
452
305
|
}
|
|
453
306
|
});
|
|
454
|
-
|
|
455
307
|
gssLineData.selectedTool = 'lineB';
|
|
456
308
|
}
|
|
457
|
-
|
|
458
|
-
(0, _lodash.set)(model,
|
|
459
|
-
(0, _lodash.set)(model, "answers", answers);
|
|
309
|
+
(0, _lodash.set)(model, 'gssLineData', gssLineData);
|
|
310
|
+
(0, _lodash.set)(model, 'answers', answers);
|
|
460
311
|
onChange(model);
|
|
461
312
|
});
|
|
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
313
|
/*
|
|
475
|
-
*
|
|
314
|
+
* Function to update the model
|
|
315
|
+
* @param {object} props - updated props
|
|
476
316
|
* */
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
317
|
+
(0, _defineProperty2.default)(this, "updateModel", props => {
|
|
318
|
+
const {
|
|
319
|
+
model,
|
|
320
|
+
onChange
|
|
321
|
+
} = this.props;
|
|
322
|
+
onChange({
|
|
323
|
+
...model,
|
|
324
|
+
...props
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/*
|
|
329
|
+
* Render the component
|
|
330
|
+
* */
|
|
331
|
+
render() {
|
|
332
|
+
const {
|
|
333
|
+
errors,
|
|
334
|
+
model,
|
|
335
|
+
mathMlOptions = {}
|
|
336
|
+
} = this.props;
|
|
337
|
+
const {
|
|
338
|
+
dialog
|
|
339
|
+
} = this.state;
|
|
340
|
+
//get the default values to GssLineData
|
|
341
|
+
const {
|
|
342
|
+
gssLineData = {
|
|
491
343
|
numberOfLines: 1,
|
|
492
344
|
selectedTool: 'lineA',
|
|
493
345
|
lineA: {
|
|
494
346
|
lineType: 'Solid'
|
|
495
347
|
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
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
|
-
|
|
348
|
+
},
|
|
349
|
+
arrows,
|
|
350
|
+
coordinatesOnHover,
|
|
351
|
+
domain,
|
|
352
|
+
graph = {},
|
|
353
|
+
labels,
|
|
354
|
+
labelsEnabled,
|
|
355
|
+
range,
|
|
356
|
+
title,
|
|
357
|
+
titleEnabled,
|
|
358
|
+
answers
|
|
359
|
+
} = model || {};
|
|
360
|
+
const {
|
|
361
|
+
correctAnswerErrors = ''
|
|
362
|
+
} = errors || {};
|
|
363
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_material.Typography, {
|
|
364
|
+
component: "div",
|
|
365
|
+
variant: "h6"
|
|
366
|
+
}, "Define Line Type(s) and Correct Response"), /*#__PURE__*/React.createElement(SubtitleText, {
|
|
367
|
+
component: "div",
|
|
368
|
+
variant: "body1"
|
|
369
|
+
}, "Use this interface to choose how many lines students will be able to draw, and to define the correct answer."), /*#__PURE__*/React.createElement(SubtitleText, {
|
|
370
|
+
component: "div",
|
|
371
|
+
variant: "body1"
|
|
372
|
+
}, "Choose Number of Lines"), /*#__PURE__*/React.createElement(_material.RadioGroup, {
|
|
373
|
+
name: "numberOfLines",
|
|
374
|
+
value: gssLineData.numberOfLines,
|
|
375
|
+
onChange: this.changeNumberOfLines
|
|
376
|
+
}, /*#__PURE__*/React.createElement(RadioButtonClass, {
|
|
377
|
+
value: "1",
|
|
378
|
+
control: /*#__PURE__*/React.createElement(StyledRadio, {
|
|
379
|
+
checked: gssLineData.numberOfLines === 1
|
|
380
|
+
}),
|
|
381
|
+
label: "One"
|
|
382
|
+
}), /*#__PURE__*/React.createElement(RadioButtonClass, {
|
|
383
|
+
value: "2",
|
|
384
|
+
control: /*#__PURE__*/React.createElement(StyledRadio, {
|
|
385
|
+
checked: gssLineData.numberOfLines === 2
|
|
386
|
+
}),
|
|
387
|
+
label: "Two"
|
|
388
|
+
})), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_graphingSolutionSet.GraphContainer, {
|
|
389
|
+
style: correctAnswerErrors['correctAnswer'] && {
|
|
390
|
+
border: '2px solid red'
|
|
391
|
+
},
|
|
392
|
+
axesSettings: {
|
|
393
|
+
includeArrows: arrows
|
|
394
|
+
},
|
|
395
|
+
backgroundMarks: [],
|
|
396
|
+
coordinatesOnHover: coordinatesOnHover,
|
|
397
|
+
disabledLabels: true,
|
|
398
|
+
disabledTitle: true,
|
|
399
|
+
domain: domain,
|
|
400
|
+
draggableTools: true,
|
|
401
|
+
labels: labels,
|
|
402
|
+
marks: answers && answers.correctAnswer && answers.correctAnswer.marks ? answers.correctAnswer.marks : [],
|
|
403
|
+
onChangeMarks: newMarks => this.changeMarks(newMarks),
|
|
404
|
+
onCustomReset: this.onResetClick,
|
|
405
|
+
range: range,
|
|
406
|
+
showLabels: labelsEnabled,
|
|
407
|
+
showTitle: titleEnabled,
|
|
408
|
+
size: {
|
|
409
|
+
width: graph.width,
|
|
410
|
+
height: graph.height
|
|
411
|
+
},
|
|
412
|
+
title: title,
|
|
413
|
+
gssLineData: gssLineData,
|
|
414
|
+
onChangeGssLineData: this.onChangeGssLineData,
|
|
415
|
+
onSolutionSetSelected: this.onSolutionSetSelected,
|
|
416
|
+
toolbarTools: ['line', 'polygon'],
|
|
417
|
+
mathMlOptions: mathMlOptions
|
|
418
|
+
}), correctAnswerErrors['correctAnswer'] && /*#__PURE__*/React.createElement(ErrorMessage, null, correctAnswerErrors['correctAnswer'])), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
|
|
419
|
+
open: dialog.open,
|
|
420
|
+
title: dialog.title,
|
|
421
|
+
text: dialog.text,
|
|
422
|
+
onClose: dialog.onClose,
|
|
423
|
+
onConfirm: dialog.onConfirm,
|
|
424
|
+
onConfirmText: dialog.onConfirmText ? dialog.onConfirmText : 'OK'
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
}
|
|
590
428
|
exports.CorrectResponse = CorrectResponse;
|
|
591
|
-
(0, _defineProperty2
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
onChange: _propTypes["default"].func.isRequired
|
|
429
|
+
(0, _defineProperty2.default)(CorrectResponse, "propTypes", {
|
|
430
|
+
errors: _propTypes.default.object,
|
|
431
|
+
model: _propTypes.default.object.isRequired,
|
|
432
|
+
onChange: _propTypes.default.func.isRequired
|
|
596
433
|
});
|
|
597
|
-
|
|
598
|
-
var _default = (0, _styles.withStyles)(styles)(CorrectResponse);
|
|
599
|
-
|
|
600
|
-
exports["default"] = _default;
|
|
434
|
+
var _default = exports.default = CorrectResponse;
|
|
601
435
|
//# sourceMappingURL=correct-response.js.map
|