@pie-element/math-inline 10.0.1 → 11.0.3-esm.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/package.json +7 -7
- package/controller/package.json +3 -3
- package/esm/configure.css +847 -0
- package/esm/configure.js +1769 -0
- package/esm/configure.js.map +1 -0
- package/esm/controller.css +847 -0
- package/esm/controller.js +79 -131
- package/esm/controller.js.map +1 -1
- package/esm/element.css +847 -0
- package/esm/element.js +1476 -0
- package/esm/element.js.map +1 -0
- package/esm/print.css +847 -0
- package/esm/print.js +1288 -0
- package/esm/print.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/module/configure.js +1 -0
- package/module/controller.js +4320 -0
- package/module/demo.js +66 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +14 -0
- package/module/print-demo.js +104 -0
- package/module/print.html +18 -0
- package/module/print.js +1 -0
- package/package.json +23 -8
package/esm/configure.js
ADDED
|
@@ -0,0 +1,1769 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
5
|
+
import { InputContainer, layout, FeedbackConfig, settings } from '@pie-lib/config-ui';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import debug from 'debug';
|
|
8
|
+
import EditableHtml from '@pie-lib/editable-html';
|
|
9
|
+
import cx from 'classnames';
|
|
10
|
+
import InputLabel from '@material-ui/core/InputLabel';
|
|
11
|
+
import Select from '@material-ui/core/Select';
|
|
12
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
13
|
+
import { MathToolbar } from '@pie-lib/math-toolbar';
|
|
14
|
+
import Card from '@material-ui/core/Card';
|
|
15
|
+
import CardContent from '@material-ui/core/CardContent';
|
|
16
|
+
import Button from '@material-ui/core/Button';
|
|
17
|
+
import FormControlLabel from '@material-ui/core/FormControlLabel';
|
|
18
|
+
import Typography from '@material-ui/core/Typography';
|
|
19
|
+
import Checkbox from '@material-ui/core/Checkbox';
|
|
20
|
+
import { color } from '@pie-lib/render-ui';
|
|
21
|
+
import isEqual from 'lodash/isEqual';
|
|
22
|
+
import MathQuill from '@pie-framework/mathquill';
|
|
23
|
+
import require$$3 from '@material-ui/core/SvgIcon';
|
|
24
|
+
import Tooltip from '@material-ui/core/Tooltip';
|
|
25
|
+
import isEmpty from 'lodash/isEmpty';
|
|
26
|
+
import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
|
|
27
|
+
|
|
28
|
+
function _extends() {
|
|
29
|
+
_extends = Object.assign || function (target) {
|
|
30
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
31
|
+
var source = arguments[i];
|
|
32
|
+
|
|
33
|
+
for (var key in source) {
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
35
|
+
target[key] = source[key];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return target;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return _extends.apply(this, arguments);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const styles$2 = theme => ({
|
|
47
|
+
responseContainer: {
|
|
48
|
+
marginBottom: theme.spacing.unit * 2.5,
|
|
49
|
+
width: '100%',
|
|
50
|
+
minWidth: '548px',
|
|
51
|
+
border: `1px solid ${theme.palette.grey[700]}`,
|
|
52
|
+
display: 'flex',
|
|
53
|
+
flexDirection: 'column',
|
|
54
|
+
justifyContent: 'space-between'
|
|
55
|
+
},
|
|
56
|
+
cardContent: {
|
|
57
|
+
paddingBottom: `${theme.spacing.unit * 2}px !important`
|
|
58
|
+
},
|
|
59
|
+
title: {
|
|
60
|
+
fontWeight: 700,
|
|
61
|
+
fontSize: '1.2rem',
|
|
62
|
+
flex: 3
|
|
63
|
+
},
|
|
64
|
+
selectContainer: {
|
|
65
|
+
flex: 2
|
|
66
|
+
},
|
|
67
|
+
inputContainer: {
|
|
68
|
+
marginBottom: theme.spacing.unit * 2
|
|
69
|
+
},
|
|
70
|
+
titleBar: {
|
|
71
|
+
display: 'flex',
|
|
72
|
+
alignItems: 'center',
|
|
73
|
+
justifyContent: 'space-between'
|
|
74
|
+
},
|
|
75
|
+
responseEditor: {
|
|
76
|
+
display: 'flex',
|
|
77
|
+
alignItems: 'center',
|
|
78
|
+
justifyContent: 'center',
|
|
79
|
+
width: '100%',
|
|
80
|
+
minWidth: '500px',
|
|
81
|
+
maxWidth: '900px',
|
|
82
|
+
height: 'auto',
|
|
83
|
+
minHeight: '40px'
|
|
84
|
+
},
|
|
85
|
+
mathToolbar: {
|
|
86
|
+
width: '100%'
|
|
87
|
+
},
|
|
88
|
+
alternateButton: {
|
|
89
|
+
border: `1px solid ${theme.palette.grey['A100']}`
|
|
90
|
+
},
|
|
91
|
+
removeAlternateButton: {
|
|
92
|
+
marginLeft: theme.spacing.unit * 2,
|
|
93
|
+
border: `1px solid ${theme.palette.grey['A100']}`,
|
|
94
|
+
color: 'gray',
|
|
95
|
+
fontSize: '0.8rem'
|
|
96
|
+
},
|
|
97
|
+
errorText: {
|
|
98
|
+
fontSize: theme.typography.fontSize - 2,
|
|
99
|
+
color: theme.palette.error.main,
|
|
100
|
+
paddingTop: theme.spacing.unit
|
|
101
|
+
},
|
|
102
|
+
customColor: {
|
|
103
|
+
color: `${color.tertiary()} !important`
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
class Response extends React.Component {
|
|
108
|
+
constructor(props) {
|
|
109
|
+
super(props);
|
|
110
|
+
|
|
111
|
+
this.onChange = name => evt => {
|
|
112
|
+
const {
|
|
113
|
+
response,
|
|
114
|
+
onResponseChange,
|
|
115
|
+
index
|
|
116
|
+
} = this.props;
|
|
117
|
+
|
|
118
|
+
const newResponse = _extends({}, response);
|
|
119
|
+
|
|
120
|
+
newResponse[name] = evt.target.value;
|
|
121
|
+
onResponseChange(newResponse, index);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
this.onConfigChanged = name => evt => {
|
|
125
|
+
const {
|
|
126
|
+
response,
|
|
127
|
+
onResponseChange,
|
|
128
|
+
index
|
|
129
|
+
} = this.props;
|
|
130
|
+
|
|
131
|
+
const newResponse = _extends({}, response);
|
|
132
|
+
|
|
133
|
+
newResponse[name] = evt.target.checked;
|
|
134
|
+
onResponseChange(newResponse, index);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
this.onLiteralOptionsChange = name => () => {
|
|
138
|
+
const {
|
|
139
|
+
response,
|
|
140
|
+
onResponseChange,
|
|
141
|
+
index
|
|
142
|
+
} = this.props;
|
|
143
|
+
|
|
144
|
+
const newResponse = _extends({}, response);
|
|
145
|
+
|
|
146
|
+
newResponse[name] = !response[name];
|
|
147
|
+
onResponseChange(newResponse, index);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
this.onAnswerChange = answer => {
|
|
151
|
+
const {
|
|
152
|
+
response,
|
|
153
|
+
onResponseChange,
|
|
154
|
+
index
|
|
155
|
+
} = this.props;
|
|
156
|
+
|
|
157
|
+
const newResponse = _extends({}, response);
|
|
158
|
+
|
|
159
|
+
newResponse.answer = answer;
|
|
160
|
+
onResponseChange(newResponse, index);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
this.onAlternateAnswerChange = alternateId => answer => {
|
|
164
|
+
const {
|
|
165
|
+
response,
|
|
166
|
+
onResponseChange,
|
|
167
|
+
index
|
|
168
|
+
} = this.props;
|
|
169
|
+
|
|
170
|
+
const newResponse = _extends({}, response);
|
|
171
|
+
|
|
172
|
+
newResponse.alternates[alternateId] = answer;
|
|
173
|
+
onResponseChange(newResponse, index);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
this.onAddAlternate = () => {
|
|
177
|
+
const {
|
|
178
|
+
response,
|
|
179
|
+
onResponseChange,
|
|
180
|
+
index
|
|
181
|
+
} = this.props;
|
|
182
|
+
const {
|
|
183
|
+
alternateIdCounter
|
|
184
|
+
} = this.state;
|
|
185
|
+
|
|
186
|
+
const newResponse = _extends({}, response);
|
|
187
|
+
|
|
188
|
+
if (!newResponse.alternates) {
|
|
189
|
+
newResponse.alternates = {};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
newResponse.alternates[alternateIdCounter] = '';
|
|
193
|
+
onResponseChange(newResponse, index);
|
|
194
|
+
this.setState({
|
|
195
|
+
alternateIdCounter: alternateIdCounter + 1
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
this.onRemoveAlternate = alternateId => () => {
|
|
200
|
+
const {
|
|
201
|
+
response,
|
|
202
|
+
onResponseChange,
|
|
203
|
+
index
|
|
204
|
+
} = this.props;
|
|
205
|
+
|
|
206
|
+
const newResponse = _extends({}, response);
|
|
207
|
+
|
|
208
|
+
delete newResponse.alternates[alternateId];
|
|
209
|
+
onResponseChange(newResponse, index);
|
|
210
|
+
this.setState(state => ({
|
|
211
|
+
showKeypad: _extends({}, state.showKeypad, {
|
|
212
|
+
openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount : state.showKeypad.openCount - 1
|
|
213
|
+
})
|
|
214
|
+
}));
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
this.onDone = () => {
|
|
218
|
+
this.setState(state => ({
|
|
219
|
+
showKeypad: _extends({}, state.showKeypad, {
|
|
220
|
+
openCount: state.showKeypad.openCount - 1,
|
|
221
|
+
main: false
|
|
222
|
+
})
|
|
223
|
+
}));
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
this.onFocus = () => {
|
|
227
|
+
this.setState(state => ({
|
|
228
|
+
showKeypad: _extends({}, state.showKeypad, {
|
|
229
|
+
openCount: !state.showKeypad.main ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
|
|
230
|
+
main: true
|
|
231
|
+
})
|
|
232
|
+
}));
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
this.onAlternateFocus = alternateId => () => {
|
|
236
|
+
this.setState(state => ({
|
|
237
|
+
showKeypad: _extends({}, state.showKeypad, {
|
|
238
|
+
openCount: !state.showKeypad[alternateId] ? state.showKeypad.openCount + 1 : state.showKeypad.openCount,
|
|
239
|
+
[alternateId]: true
|
|
240
|
+
})
|
|
241
|
+
}));
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
this.onAlternateDone = alternateId => () => {
|
|
245
|
+
this.setState(state => ({
|
|
246
|
+
showKeypad: _extends({}, state.showKeypad, {
|
|
247
|
+
openCount: state.showKeypad.openCount - 1,
|
|
248
|
+
[alternateId]: false
|
|
249
|
+
})
|
|
250
|
+
}));
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const {
|
|
254
|
+
response: {
|
|
255
|
+
alternates
|
|
256
|
+
} = {}
|
|
257
|
+
} = props || {};
|
|
258
|
+
const alternatesLength = Object.keys(alternates || {}).length;
|
|
259
|
+
this.state = {
|
|
260
|
+
alternateIdCounter: alternatesLength + 1,
|
|
261
|
+
showKeypad: {
|
|
262
|
+
openCount: 0,
|
|
263
|
+
main: false
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
render() {
|
|
269
|
+
const {
|
|
270
|
+
classes,
|
|
271
|
+
mode,
|
|
272
|
+
defaultResponse,
|
|
273
|
+
index,
|
|
274
|
+
response,
|
|
275
|
+
cAllowTrailingZeros,
|
|
276
|
+
cIgnoreOrder,
|
|
277
|
+
error
|
|
278
|
+
} = this.props;
|
|
279
|
+
const {
|
|
280
|
+
showKeypad
|
|
281
|
+
} = this.state;
|
|
282
|
+
const {
|
|
283
|
+
validation,
|
|
284
|
+
answer,
|
|
285
|
+
alternates,
|
|
286
|
+
ignoreOrder,
|
|
287
|
+
allowTrailingZeros
|
|
288
|
+
} = response;
|
|
289
|
+
const hasAlternates = Object.keys(alternates || {}).length > 0;
|
|
290
|
+
const classNames = {
|
|
291
|
+
editor: classes.responseEditor,
|
|
292
|
+
mathToolbar: classes.mathToolbar
|
|
293
|
+
};
|
|
294
|
+
const styles = {
|
|
295
|
+
minHeight: `${showKeypad.openCount > 0 ? 430 : 230}px`
|
|
296
|
+
};
|
|
297
|
+
return /*#__PURE__*/React.createElement(Card, {
|
|
298
|
+
className: classes.responseContainer,
|
|
299
|
+
style: styles
|
|
300
|
+
}, /*#__PURE__*/React.createElement(CardContent, {
|
|
301
|
+
className: classes.cardContent
|
|
302
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
303
|
+
className: classes.titleBar
|
|
304
|
+
}, /*#__PURE__*/React.createElement(Typography, {
|
|
305
|
+
className: classes.title,
|
|
306
|
+
component: "div"
|
|
307
|
+
}, "Response ", ''), /*#__PURE__*/React.createElement(InputContainer, {
|
|
308
|
+
label: "Validation",
|
|
309
|
+
className: classes.selectContainer
|
|
310
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
311
|
+
className: classes.select,
|
|
312
|
+
onChange: this.onChange('validation'),
|
|
313
|
+
value: validation || 'literal'
|
|
314
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
315
|
+
value: "literal"
|
|
316
|
+
}, "Literal Validation"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
317
|
+
value: "symbolic"
|
|
318
|
+
}, "Symbolic Validation")))), validation === 'literal' && /*#__PURE__*/React.createElement("div", {
|
|
319
|
+
className: classes.flexContainer
|
|
320
|
+
}, cAllowTrailingZeros.enabled && /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
321
|
+
label: cAllowTrailingZeros.label,
|
|
322
|
+
control: /*#__PURE__*/React.createElement(Checkbox, {
|
|
323
|
+
className: classes.customColor,
|
|
324
|
+
checked: allowTrailingZeros,
|
|
325
|
+
onChange: this.onLiteralOptionsChange('allowTrailingZeros')
|
|
326
|
+
})
|
|
327
|
+
}), cIgnoreOrder.enabled && /*#__PURE__*/React.createElement(FormControlLabel, {
|
|
328
|
+
label: cIgnoreOrder.label,
|
|
329
|
+
control: /*#__PURE__*/React.createElement(Checkbox, {
|
|
330
|
+
className: classes.customColor,
|
|
331
|
+
checked: ignoreOrder,
|
|
332
|
+
onChange: this.onLiteralOptionsChange('ignoreOrder')
|
|
333
|
+
})
|
|
334
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
335
|
+
className: classes.inputContainer
|
|
336
|
+
}, /*#__PURE__*/React.createElement(InputLabel, null, "Correct Answer"), /*#__PURE__*/React.createElement(MathToolbar, {
|
|
337
|
+
keypadMode: mode,
|
|
338
|
+
classNames: classNames,
|
|
339
|
+
controlledKeypad: true,
|
|
340
|
+
showKeypad: showKeypad.main,
|
|
341
|
+
latex: answer || '',
|
|
342
|
+
onChange: this.onAnswerChange,
|
|
343
|
+
onFocus: this.onFocus,
|
|
344
|
+
onDone: this.onDone,
|
|
345
|
+
error: error && error.answer
|
|
346
|
+
}), error && error.answer ? /*#__PURE__*/React.createElement("div", {
|
|
347
|
+
className: classes.errorText
|
|
348
|
+
}, error.answer) : null), hasAlternates && Object.keys(alternates).map((alternateId, altIdx) => /*#__PURE__*/React.createElement("div", {
|
|
349
|
+
className: classes.inputContainer,
|
|
350
|
+
key: alternateId
|
|
351
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
352
|
+
className: classes.alternateBar
|
|
353
|
+
}, /*#__PURE__*/React.createElement(InputLabel, null, "Alternate", Object.keys(alternates).length > 1 ? ` ${altIdx + 1}` : ''), /*#__PURE__*/React.createElement(Button, {
|
|
354
|
+
className: classes.removeAlternateButton,
|
|
355
|
+
type: "secondary",
|
|
356
|
+
onClick: this.onRemoveAlternate(alternateId)
|
|
357
|
+
}, "Remove")), /*#__PURE__*/React.createElement(MathToolbar, {
|
|
358
|
+
classNames: classNames,
|
|
359
|
+
controlledKeypad: true,
|
|
360
|
+
keypadMode: mode,
|
|
361
|
+
showKeypad: showKeypad[alternateId] || false,
|
|
362
|
+
latex: alternates[alternateId] || '',
|
|
363
|
+
onChange: this.onAlternateAnswerChange(alternateId),
|
|
364
|
+
onFocus: this.onAlternateFocus(alternateId),
|
|
365
|
+
onDone: this.onAlternateDone(alternateId),
|
|
366
|
+
error: error && error[alternateId]
|
|
367
|
+
}), error && error[alternateId] ? /*#__PURE__*/React.createElement("div", {
|
|
368
|
+
className: classes.errorText
|
|
369
|
+
}, error[alternateId]) : null)), /*#__PURE__*/React.createElement(Button, {
|
|
370
|
+
className: classes.alternateButton,
|
|
371
|
+
type: "primary",
|
|
372
|
+
onClick: this.onAddAlternate
|
|
373
|
+
}, "ADD ALTERNATE")));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
Response.propTypes = {
|
|
379
|
+
classes: PropTypes.object.isRequired,
|
|
380
|
+
defaultResponse: PropTypes.bool,
|
|
381
|
+
error: PropTypes.object,
|
|
382
|
+
mode: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
383
|
+
index: PropTypes.number,
|
|
384
|
+
onResponseChange: PropTypes.func.isRequired,
|
|
385
|
+
response: PropTypes.object.isRequired,
|
|
386
|
+
cIgnoreOrder: PropTypes.object.isRequired,
|
|
387
|
+
cAllowTrailingZeros: PropTypes.object.isRequired
|
|
388
|
+
};
|
|
389
|
+
Response.defaultProps = {
|
|
390
|
+
defaultResponse: false,
|
|
391
|
+
mode: 'miscellaneous'
|
|
392
|
+
};
|
|
393
|
+
var Response$1 = withStyles(styles$2)(Response);
|
|
394
|
+
|
|
395
|
+
const ResponseTypes = {
|
|
396
|
+
advanced: 'Advanced Multi',
|
|
397
|
+
simple: 'Simple'
|
|
398
|
+
};
|
|
399
|
+
const generateValidationMessage = (model = {}, config = {}) => {
|
|
400
|
+
const {
|
|
401
|
+
maxResponseAreas
|
|
402
|
+
} = config;
|
|
403
|
+
const {
|
|
404
|
+
responseType
|
|
405
|
+
} = model;
|
|
406
|
+
let responseAreasMessage = '';
|
|
407
|
+
const answersMessage = '\nAll correct answers (the primary and any alternates) should not be empty and should be unique.';
|
|
408
|
+
|
|
409
|
+
if (responseType === 'Advanced Multi') {
|
|
410
|
+
responseAreasMessage = '\nThere should be at least 1 ' + (maxResponseAreas ? `and at most ${maxResponseAreas} ` : '') + 'response area' + (maxResponseAreas ? 's' : '') + ' defined.';
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return 'Validation requirements:' + answersMessage + responseAreasMessage;
|
|
414
|
+
};
|
|
415
|
+
const getPluginProps = (props = {}, baseInputConfiguration = {}) => _extends({}, baseInputConfiguration, props);
|
|
416
|
+
|
|
417
|
+
var Info = {};
|
|
418
|
+
|
|
419
|
+
var interopRequireDefault = {exports: {}};
|
|
420
|
+
|
|
421
|
+
(function (module) {
|
|
422
|
+
function _interopRequireDefault(obj) {
|
|
423
|
+
return obj && obj.__esModule ? obj : {
|
|
424
|
+
"default": obj
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
429
|
+
}(interopRequireDefault));
|
|
430
|
+
|
|
431
|
+
var createSvgIcon$1 = {};
|
|
432
|
+
|
|
433
|
+
var pure$1 = {};
|
|
434
|
+
|
|
435
|
+
var shouldUpdate$1 = {};
|
|
436
|
+
|
|
437
|
+
var inheritsLoose = {exports: {}};
|
|
438
|
+
|
|
439
|
+
var setPrototypeOf = {exports: {}};
|
|
440
|
+
|
|
441
|
+
(function (module) {
|
|
442
|
+
function _setPrototypeOf(o, p) {
|
|
443
|
+
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
444
|
+
o.__proto__ = p;
|
|
445
|
+
return o;
|
|
446
|
+
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
447
|
+
return _setPrototypeOf(o, p);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
451
|
+
}(setPrototypeOf));
|
|
452
|
+
|
|
453
|
+
(function (module) {
|
|
454
|
+
var setPrototypeOf$1 = setPrototypeOf.exports;
|
|
455
|
+
|
|
456
|
+
function _inheritsLoose(subClass, superClass) {
|
|
457
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
458
|
+
subClass.prototype.constructor = subClass;
|
|
459
|
+
setPrototypeOf$1(subClass, superClass);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
module.exports = _inheritsLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
463
|
+
}(inheritsLoose));
|
|
464
|
+
|
|
465
|
+
var setDisplayName$1 = {};
|
|
466
|
+
|
|
467
|
+
var setStatic$1 = {};
|
|
468
|
+
|
|
469
|
+
setStatic$1.__esModule = true;
|
|
470
|
+
setStatic$1.default = void 0;
|
|
471
|
+
|
|
472
|
+
var setStatic = function setStatic(key, value) {
|
|
473
|
+
return function (BaseComponent) {
|
|
474
|
+
/* eslint-disable no-param-reassign */
|
|
475
|
+
BaseComponent[key] = value;
|
|
476
|
+
/* eslint-enable no-param-reassign */
|
|
477
|
+
|
|
478
|
+
return BaseComponent;
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
var _default$8 = setStatic;
|
|
483
|
+
setStatic$1.default = _default$8;
|
|
484
|
+
|
|
485
|
+
var _interopRequireDefault$6 = interopRequireDefault.exports;
|
|
486
|
+
|
|
487
|
+
setDisplayName$1.__esModule = true;
|
|
488
|
+
setDisplayName$1.default = void 0;
|
|
489
|
+
|
|
490
|
+
var _setStatic = _interopRequireDefault$6(setStatic$1);
|
|
491
|
+
|
|
492
|
+
var setDisplayName = function setDisplayName(displayName) {
|
|
493
|
+
return (0, _setStatic.default)('displayName', displayName);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
var _default$7 = setDisplayName;
|
|
497
|
+
setDisplayName$1.default = _default$7;
|
|
498
|
+
|
|
499
|
+
var wrapDisplayName$1 = {};
|
|
500
|
+
|
|
501
|
+
var getDisplayName$1 = {};
|
|
502
|
+
|
|
503
|
+
getDisplayName$1.__esModule = true;
|
|
504
|
+
getDisplayName$1.default = void 0;
|
|
505
|
+
|
|
506
|
+
var getDisplayName = function getDisplayName(Component) {
|
|
507
|
+
if (typeof Component === 'string') {
|
|
508
|
+
return Component;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (!Component) {
|
|
512
|
+
return undefined;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
return Component.displayName || Component.name || 'Component';
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
var _default$6 = getDisplayName;
|
|
519
|
+
getDisplayName$1.default = _default$6;
|
|
520
|
+
|
|
521
|
+
var _interopRequireDefault$5 = interopRequireDefault.exports;
|
|
522
|
+
|
|
523
|
+
wrapDisplayName$1.__esModule = true;
|
|
524
|
+
wrapDisplayName$1.default = void 0;
|
|
525
|
+
|
|
526
|
+
var _getDisplayName = _interopRequireDefault$5(getDisplayName$1);
|
|
527
|
+
|
|
528
|
+
var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
|
|
529
|
+
return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
var _default$5 = wrapDisplayName;
|
|
533
|
+
wrapDisplayName$1.default = _default$5;
|
|
534
|
+
|
|
535
|
+
var _interopRequireDefault$4 = interopRequireDefault.exports;
|
|
536
|
+
|
|
537
|
+
shouldUpdate$1.__esModule = true;
|
|
538
|
+
shouldUpdate$1.default = void 0;
|
|
539
|
+
|
|
540
|
+
var _inheritsLoose2 = _interopRequireDefault$4(inheritsLoose.exports);
|
|
541
|
+
|
|
542
|
+
var _react$2 = React__default;
|
|
543
|
+
|
|
544
|
+
var _setDisplayName$1 = _interopRequireDefault$4(setDisplayName$1);
|
|
545
|
+
|
|
546
|
+
var _wrapDisplayName$1 = _interopRequireDefault$4(wrapDisplayName$1);
|
|
547
|
+
|
|
548
|
+
var shouldUpdate = function shouldUpdate(test) {
|
|
549
|
+
return function (BaseComponent) {
|
|
550
|
+
var factory = (0, _react$2.createFactory)(BaseComponent);
|
|
551
|
+
|
|
552
|
+
var ShouldUpdate =
|
|
553
|
+
/*#__PURE__*/
|
|
554
|
+
function (_Component) {
|
|
555
|
+
(0, _inheritsLoose2.default)(ShouldUpdate, _Component);
|
|
556
|
+
|
|
557
|
+
function ShouldUpdate() {
|
|
558
|
+
return _Component.apply(this, arguments) || this;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
var _proto = ShouldUpdate.prototype;
|
|
562
|
+
|
|
563
|
+
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
564
|
+
return test(this.props, nextProps);
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
_proto.render = function render() {
|
|
568
|
+
return factory(this.props);
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
return ShouldUpdate;
|
|
572
|
+
}(_react$2.Component);
|
|
573
|
+
|
|
574
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
575
|
+
return (0, _setDisplayName$1.default)((0, _wrapDisplayName$1.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
return ShouldUpdate;
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
var _default$4 = shouldUpdate;
|
|
583
|
+
shouldUpdate$1.default = _default$4;
|
|
584
|
+
|
|
585
|
+
var shallowEqual$1 = {};
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
589
|
+
*
|
|
590
|
+
* This source code is licensed under the MIT license found in the
|
|
591
|
+
* LICENSE file in the root directory of this source tree.
|
|
592
|
+
*
|
|
593
|
+
* @typechecks
|
|
594
|
+
*
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
601
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
602
|
+
*/
|
|
603
|
+
function is(x, y) {
|
|
604
|
+
// SameValue algorithm
|
|
605
|
+
if (x === y) {
|
|
606
|
+
// Steps 1-5, 7-10
|
|
607
|
+
// Steps 6.b-6.e: +0 != -0
|
|
608
|
+
// Added the nonzero y check to make Flow happy, but it is redundant
|
|
609
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
610
|
+
} else {
|
|
611
|
+
// Step 6.a: NaN == NaN
|
|
612
|
+
return x !== x && y !== y;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* Performs equality by iterating through keys on an object and returning false
|
|
618
|
+
* when any key has values which are not strictly equal between the arguments.
|
|
619
|
+
* Returns true when the values of all keys are strictly equal.
|
|
620
|
+
*/
|
|
621
|
+
function shallowEqual(objA, objB) {
|
|
622
|
+
if (is(objA, objB)) {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
var keysA = Object.keys(objA);
|
|
631
|
+
var keysB = Object.keys(objB);
|
|
632
|
+
|
|
633
|
+
if (keysA.length !== keysB.length) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
// Test for A's keys different from B.
|
|
638
|
+
for (var i = 0; i < keysA.length; i++) {
|
|
639
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return true;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
var shallowEqual_1 = shallowEqual;
|
|
648
|
+
|
|
649
|
+
var _interopRequireDefault$3 = interopRequireDefault.exports;
|
|
650
|
+
|
|
651
|
+
shallowEqual$1.__esModule = true;
|
|
652
|
+
shallowEqual$1.default = void 0;
|
|
653
|
+
|
|
654
|
+
var _shallowEqual$1 = _interopRequireDefault$3(shallowEqual_1);
|
|
655
|
+
|
|
656
|
+
var _default$3 = _shallowEqual$1.default;
|
|
657
|
+
shallowEqual$1.default = _default$3;
|
|
658
|
+
|
|
659
|
+
var _interopRequireDefault$2 = interopRequireDefault.exports;
|
|
660
|
+
|
|
661
|
+
pure$1.__esModule = true;
|
|
662
|
+
pure$1.default = void 0;
|
|
663
|
+
|
|
664
|
+
var _shouldUpdate = _interopRequireDefault$2(shouldUpdate$1);
|
|
665
|
+
|
|
666
|
+
var _shallowEqual = _interopRequireDefault$2(shallowEqual$1);
|
|
667
|
+
|
|
668
|
+
var _setDisplayName = _interopRequireDefault$2(setDisplayName$1);
|
|
669
|
+
|
|
670
|
+
var _wrapDisplayName = _interopRequireDefault$2(wrapDisplayName$1);
|
|
671
|
+
|
|
672
|
+
var pure = function pure(BaseComponent) {
|
|
673
|
+
var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
|
|
674
|
+
return !(0, _shallowEqual.default)(props, nextProps);
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
678
|
+
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return hoc(BaseComponent);
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
var _default$2 = pure;
|
|
685
|
+
pure$1.default = _default$2;
|
|
686
|
+
|
|
687
|
+
var _interopRequireDefault$1 = interopRequireDefault.exports;
|
|
688
|
+
|
|
689
|
+
Object.defineProperty(createSvgIcon$1, "__esModule", {
|
|
690
|
+
value: true
|
|
691
|
+
});
|
|
692
|
+
createSvgIcon$1.default = void 0;
|
|
693
|
+
|
|
694
|
+
var _react$1 = _interopRequireDefault$1(React__default);
|
|
695
|
+
|
|
696
|
+
var _pure = _interopRequireDefault$1(pure$1);
|
|
697
|
+
|
|
698
|
+
var _SvgIcon = _interopRequireDefault$1(require$$3);
|
|
699
|
+
|
|
700
|
+
function createSvgIcon(path, displayName) {
|
|
701
|
+
var Icon = function Icon(props) {
|
|
702
|
+
return _react$1.default.createElement(_SvgIcon.default, props, path);
|
|
703
|
+
};
|
|
704
|
+
|
|
705
|
+
Icon.displayName = "".concat(displayName, "Icon");
|
|
706
|
+
Icon = (0, _pure.default)(Icon);
|
|
707
|
+
Icon.muiName = 'SvgIcon';
|
|
708
|
+
return Icon;
|
|
709
|
+
}
|
|
710
|
+
var _default$1 = createSvgIcon;
|
|
711
|
+
createSvgIcon$1.default = _default$1;
|
|
712
|
+
|
|
713
|
+
var _interopRequireDefault = interopRequireDefault.exports;
|
|
714
|
+
|
|
715
|
+
Object.defineProperty(Info, "__esModule", {
|
|
716
|
+
value: true
|
|
717
|
+
});
|
|
718
|
+
var default_1 = Info.default = void 0;
|
|
719
|
+
|
|
720
|
+
var _react = _interopRequireDefault(React__default);
|
|
721
|
+
|
|
722
|
+
var _createSvgIcon = _interopRequireDefault(createSvgIcon$1);
|
|
723
|
+
|
|
724
|
+
var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
|
|
725
|
+
fill: "none",
|
|
726
|
+
d: "M0 0h24v24H0z"
|
|
727
|
+
}), _react.default.createElement("path", {
|
|
728
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
|
|
729
|
+
})), 'Info');
|
|
730
|
+
|
|
731
|
+
default_1 = Info.default = _default;
|
|
732
|
+
|
|
733
|
+
let registered = false;
|
|
734
|
+
|
|
735
|
+
const styles$1 = theme => ({
|
|
736
|
+
container: {
|
|
737
|
+
display: 'flex',
|
|
738
|
+
flexDirection: 'column'
|
|
739
|
+
},
|
|
740
|
+
templateTitle: {
|
|
741
|
+
fontSize: '0.85rem'
|
|
742
|
+
},
|
|
743
|
+
title: {
|
|
744
|
+
fontSize: '1.1rem'
|
|
745
|
+
},
|
|
746
|
+
addResponseButton: {
|
|
747
|
+
border: `1px solid ${theme.palette.grey['A100']}`,
|
|
748
|
+
float: 'right',
|
|
749
|
+
width: '150px'
|
|
750
|
+
},
|
|
751
|
+
flexContainer: {
|
|
752
|
+
display: 'flex',
|
|
753
|
+
alignItems: 'center',
|
|
754
|
+
justifyContent: 'space-between'
|
|
755
|
+
},
|
|
756
|
+
selectContainer: {
|
|
757
|
+
flex: 'initial',
|
|
758
|
+
width: '40%',
|
|
759
|
+
marginTop: theme.spacing.unit * 2,
|
|
760
|
+
marginBottom: theme.spacing.unit * 2
|
|
761
|
+
},
|
|
762
|
+
responseTemplate: {
|
|
763
|
+
display: 'flex',
|
|
764
|
+
flexDirection: 'column'
|
|
765
|
+
},
|
|
766
|
+
responseEditor: {
|
|
767
|
+
display: 'flex',
|
|
768
|
+
justifyContent: 'center',
|
|
769
|
+
width: '100%',
|
|
770
|
+
// minWidth: '500px',
|
|
771
|
+
maxWidth: 'inherit',
|
|
772
|
+
height: 'auto',
|
|
773
|
+
minHeight: '130px',
|
|
774
|
+
textAlign: 'left',
|
|
775
|
+
padding: theme.spacing.unit
|
|
776
|
+
},
|
|
777
|
+
promptHolder: {
|
|
778
|
+
width: '100%',
|
|
779
|
+
paddingTop: theme.spacing.unit * 2,
|
|
780
|
+
marginBottom: theme.spacing.unit * 2
|
|
781
|
+
},
|
|
782
|
+
blockContainer: {
|
|
783
|
+
margin: theme.spacing.unit,
|
|
784
|
+
display: 'inline-flex',
|
|
785
|
+
border: '2px solid grey'
|
|
786
|
+
},
|
|
787
|
+
blockContainerGeneric: {
|
|
788
|
+
margin: theme.spacing.unit / 2
|
|
789
|
+
},
|
|
790
|
+
blockResponse: {
|
|
791
|
+
fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important',
|
|
792
|
+
flex: 2,
|
|
793
|
+
color: 'grey',
|
|
794
|
+
background: theme.palette.grey['A100'],
|
|
795
|
+
fontSize: '0.8rem',
|
|
796
|
+
padding: theme.spacing.unit / 2,
|
|
797
|
+
display: 'flex',
|
|
798
|
+
alignItems: 'center',
|
|
799
|
+
justifyContent: 'center',
|
|
800
|
+
borderRight: '2px solid grey'
|
|
801
|
+
},
|
|
802
|
+
blockResponseGeneric: {
|
|
803
|
+
borderRight: 0
|
|
804
|
+
},
|
|
805
|
+
blockMath: {
|
|
806
|
+
color: theme.palette.grey[400],
|
|
807
|
+
padding: theme.spacing.unit / 2,
|
|
808
|
+
display: 'flex',
|
|
809
|
+
alignItems: 'center',
|
|
810
|
+
justifyContent: 'center',
|
|
811
|
+
flex: 8,
|
|
812
|
+
'& > .mq-math-mode': {
|
|
813
|
+
'& > .mq-hasCursor': {
|
|
814
|
+
'& > .mq-cursor': {
|
|
815
|
+
display: 'none'
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
},
|
|
820
|
+
tooltip: {
|
|
821
|
+
fontSize: theme.typography.fontSize - 2,
|
|
822
|
+
whiteSpace: 'pre-wrap'
|
|
823
|
+
},
|
|
824
|
+
errorText: {
|
|
825
|
+
fontSize: theme.typography.fontSize - 2,
|
|
826
|
+
color: theme.palette.error.main,
|
|
827
|
+
paddingTop: theme.spacing.unit
|
|
828
|
+
},
|
|
829
|
+
advancedResponse: {
|
|
830
|
+
marginBottom: theme.spacing.unit * 2.5
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
const REGEX = /{{response}}/gm;
|
|
835
|
+
const TEMPORARY_RESPONSE_FIELD = /\\%response\\%/gm;
|
|
836
|
+
const ANSWER_BLOCK_REGEX = /\\embed\{answerBlock\}\[r\d*\]/g;
|
|
837
|
+
const NEWLINE_BLOCK = /\\embed\{newLine\}\[\]/g;
|
|
838
|
+
const NEWLINE_LATEX = /\\newline/g;
|
|
839
|
+
|
|
840
|
+
function prepareForStatic(expression) {
|
|
841
|
+
if (expression) {
|
|
842
|
+
let answerBlocks = 1; // assume one at least
|
|
843
|
+
|
|
844
|
+
return expression.replace(REGEX, () => `\\embed{answerBlock}[r${answerBlocks++}]`).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
function prepareForModel(expression) {
|
|
849
|
+
if (expression) {
|
|
850
|
+
return expression.replace(ANSWER_BLOCK_REGEX, () => '{{response}}').replace(TEMPORARY_RESPONSE_FIELD, () => '{{response}}').replace(NEWLINE_BLOCK, () => '\\newline');
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
class GeneralConfigBlock extends React.Component {
|
|
855
|
+
constructor(props) {
|
|
856
|
+
super(props);
|
|
857
|
+
|
|
858
|
+
this.onChange = name => evtOrValue => {
|
|
859
|
+
const {
|
|
860
|
+
model,
|
|
861
|
+
onChange
|
|
862
|
+
} = this.props;
|
|
863
|
+
|
|
864
|
+
const newModel = _extends({}, model);
|
|
865
|
+
|
|
866
|
+
if (typeof evtOrValue === 'object') {
|
|
867
|
+
newModel[name] = evtOrValue.target.value;
|
|
868
|
+
} else {
|
|
869
|
+
newModel[name] = evtOrValue;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
if (name === 'expression') {
|
|
873
|
+
newModel[name] = prepareForModel(evtOrValue);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
onChange(newModel);
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
this.onDone = () => {
|
|
880
|
+
this.setState({
|
|
881
|
+
showKeypad: false
|
|
882
|
+
});
|
|
883
|
+
};
|
|
884
|
+
|
|
885
|
+
this.onFocus = () => {
|
|
886
|
+
this.setState({
|
|
887
|
+
showKeypad: true
|
|
888
|
+
});
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
this.onPromptFocus = () => {
|
|
892
|
+
this.setState({
|
|
893
|
+
showKeypad: false
|
|
894
|
+
});
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
this.handleAnswerBlockDomUpdate = () => {
|
|
898
|
+
const {
|
|
899
|
+
model
|
|
900
|
+
} = this.props;
|
|
901
|
+
const responseAreas = {};
|
|
902
|
+
|
|
903
|
+
if (model && model.expression) {
|
|
904
|
+
let answerBlocks = 1; // assume one at least
|
|
905
|
+
// build out local state model using responses declared in expression
|
|
906
|
+
|
|
907
|
+
model.expression.replace(REGEX, () => {
|
|
908
|
+
responseAreas[`r${answerBlocks++}`] = {
|
|
909
|
+
value: ''
|
|
910
|
+
};
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
if (!isEqual(responseAreas, this.state.responseAreas)) {
|
|
915
|
+
this.setState({
|
|
916
|
+
responseAreas
|
|
917
|
+
}, () => {
|
|
918
|
+
if (this.root && Object.keys(responseAreas).length) {
|
|
919
|
+
Object.keys(responseAreas).forEach((responseId, idx) => {
|
|
920
|
+
const el = this.root.querySelector(`#${responseId}`);
|
|
921
|
+
const indexEl = this.root.querySelector(`#${responseId}Index`);
|
|
922
|
+
|
|
923
|
+
if (el) {
|
|
924
|
+
// const MathQuill = require('@pie-framework/mathquill');
|
|
925
|
+
let MQ = MathQuill.getInterface(2); // We no longer have individual answers, so we cannot set text content of blocks
|
|
926
|
+
// el.textContent = response.answer;
|
|
927
|
+
|
|
928
|
+
MQ.StaticMath(el);
|
|
929
|
+
indexEl.textContent = `R${idx + 1}`;
|
|
930
|
+
}
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
this.onAddResponse = () => {
|
|
938
|
+
const {
|
|
939
|
+
model,
|
|
940
|
+
onChange
|
|
941
|
+
} = this.props;
|
|
942
|
+
const {
|
|
943
|
+
responseIdCounter
|
|
944
|
+
} = this.state;
|
|
945
|
+
|
|
946
|
+
const newModel = _extends({}, model);
|
|
947
|
+
|
|
948
|
+
let newCounter = responseIdCounter;
|
|
949
|
+
|
|
950
|
+
while (model.responses.find(response => response.id === newCounter)) {
|
|
951
|
+
newCounter++;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const response = {
|
|
955
|
+
id: newCounter,
|
|
956
|
+
validation: 'literal',
|
|
957
|
+
answer: '',
|
|
958
|
+
alternates: {}
|
|
959
|
+
};
|
|
960
|
+
newModel.responses = newModel.responses.concat(response);
|
|
961
|
+
onChange(newModel);
|
|
962
|
+
this.setState({
|
|
963
|
+
responseIdCounter: response.id
|
|
964
|
+
});
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
this.onResponseChange = (response, index) => {
|
|
968
|
+
const {
|
|
969
|
+
model,
|
|
970
|
+
onChange
|
|
971
|
+
} = this.props;
|
|
972
|
+
|
|
973
|
+
const newModel = _extends({}, model);
|
|
974
|
+
|
|
975
|
+
newModel.responses[index] = response;
|
|
976
|
+
onChange(newModel);
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
const _responseAreas = {};
|
|
980
|
+
|
|
981
|
+
if (props.model && props.model.expression) {
|
|
982
|
+
let answerBlocks = 1; // assume one at least
|
|
983
|
+
// build out local state model using responses declared in expression
|
|
984
|
+
|
|
985
|
+
props.model.expression.replace(REGEX, () => {
|
|
986
|
+
_responseAreas[`r${answerBlocks++}`] = {
|
|
987
|
+
value: ''
|
|
988
|
+
};
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
this.state = {
|
|
993
|
+
showKeypad: false,
|
|
994
|
+
responseAreas: _responseAreas,
|
|
995
|
+
responseIdCounter: Object.keys(_responseAreas).length
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
UNSAFE_componentWillMount() {
|
|
1000
|
+
const {
|
|
1001
|
+
classes
|
|
1002
|
+
} = this.props;
|
|
1003
|
+
|
|
1004
|
+
if (typeof window !== 'undefined') {
|
|
1005
|
+
// const MathQuill = require('@pie-framework/mathquill');
|
|
1006
|
+
let MQ = MathQuill.getInterface(2);
|
|
1007
|
+
|
|
1008
|
+
if (!registered) {
|
|
1009
|
+
MQ.registerEmbed('answerBlock', data => {
|
|
1010
|
+
// not used until we implement individual answer tracking
|
|
1011
|
+
// const individualAnswerBlock = `<div class="${classes.blockContainer}">
|
|
1012
|
+
// <div class="${classes.blockResponse}" id="${data}Index">R</div>
|
|
1013
|
+
// <div class="${classes.blockMath}">
|
|
1014
|
+
// <span id="${data}"></span>
|
|
1015
|
+
// </div>
|
|
1016
|
+
// </div>`;
|
|
1017
|
+
const genericAnswerBlock = `<div class="${cx(classes.blockContainer, classes.blockContainerGeneric)}">
|
|
1018
|
+
<div class="${cx(classes.blockResponse, classes.blockResponseGeneric)}" id="${data}Index">Response</div>
|
|
1019
|
+
</div>`;
|
|
1020
|
+
return {
|
|
1021
|
+
htmlString: genericAnswerBlock,
|
|
1022
|
+
text: () => 'text',
|
|
1023
|
+
latex: () => `\\embed{answerBlock}[${data}]`
|
|
1024
|
+
};
|
|
1025
|
+
});
|
|
1026
|
+
registered = true;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
componentDidMount() {
|
|
1032
|
+
this.handleAnswerBlockDomUpdate();
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
componentDidUpdate() {
|
|
1036
|
+
this.handleAnswerBlockDomUpdate();
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
render() {
|
|
1040
|
+
const {
|
|
1041
|
+
classes,
|
|
1042
|
+
model,
|
|
1043
|
+
imageSupport,
|
|
1044
|
+
uploadSoundSupport,
|
|
1045
|
+
configuration,
|
|
1046
|
+
promptEnabled,
|
|
1047
|
+
rationaleEnabled,
|
|
1048
|
+
toolbarOpts
|
|
1049
|
+
} = this.props;
|
|
1050
|
+
const {
|
|
1051
|
+
showKeypad
|
|
1052
|
+
} = this.state;
|
|
1053
|
+
const {
|
|
1054
|
+
prompt,
|
|
1055
|
+
expression,
|
|
1056
|
+
equationEditor,
|
|
1057
|
+
promptEquationEditor = '8',
|
|
1058
|
+
responses,
|
|
1059
|
+
responseType,
|
|
1060
|
+
rationale,
|
|
1061
|
+
spellCheckEnabled,
|
|
1062
|
+
errors = {}
|
|
1063
|
+
} = model;
|
|
1064
|
+
const {
|
|
1065
|
+
baseInputConfiguration = {},
|
|
1066
|
+
rationale: cRationale = {},
|
|
1067
|
+
prompt: cPrompt = {},
|
|
1068
|
+
ignoreOrder: cIgnoreOrder = {},
|
|
1069
|
+
allowTrailingZeros: cAllowTrailingZeros = {},
|
|
1070
|
+
maxResponseAreas,
|
|
1071
|
+
maxImageWidth = {},
|
|
1072
|
+
maxImageHeight = {},
|
|
1073
|
+
mathMlOptions = {}
|
|
1074
|
+
} = configuration || {};
|
|
1075
|
+
const validationMessage = generateValidationMessage(configuration, model);
|
|
1076
|
+
const {
|
|
1077
|
+
prompt: promptError,
|
|
1078
|
+
rationale: rationaleError,
|
|
1079
|
+
responsesErrors,
|
|
1080
|
+
responseAreasError
|
|
1081
|
+
} = errors;
|
|
1082
|
+
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
1083
|
+
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
1084
|
+
const classNames = {
|
|
1085
|
+
editor: classes.responseEditor,
|
|
1086
|
+
mathToolbar: classes.mathToolbar
|
|
1087
|
+
};
|
|
1088
|
+
const responsesToUse = responseType === ResponseTypes.advanced ? responses : responses.slice(0, 1);
|
|
1089
|
+
const validationTooltip = /*#__PURE__*/React.createElement(Tooltip, {
|
|
1090
|
+
classes: {
|
|
1091
|
+
tooltip: classes.tooltip
|
|
1092
|
+
},
|
|
1093
|
+
disableFocusListener: true,
|
|
1094
|
+
disableTouchListener: true,
|
|
1095
|
+
placement: 'right',
|
|
1096
|
+
title: validationMessage
|
|
1097
|
+
}, /*#__PURE__*/React.createElement(default_1, {
|
|
1098
|
+
fontSize: 'small',
|
|
1099
|
+
color: 'primary',
|
|
1100
|
+
style: {
|
|
1101
|
+
marginLeft: '5px'
|
|
1102
|
+
}
|
|
1103
|
+
}));
|
|
1104
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
1105
|
+
ref: r => this.root = r || this.root,
|
|
1106
|
+
className: classes.container
|
|
1107
|
+
}, promptEnabled && /*#__PURE__*/React.createElement(InputContainer, {
|
|
1108
|
+
label: cPrompt.label,
|
|
1109
|
+
className: classes.promptHolder
|
|
1110
|
+
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
1111
|
+
onFocus: this.onPromptFocus,
|
|
1112
|
+
className: classes.prompt,
|
|
1113
|
+
markup: prompt || '',
|
|
1114
|
+
onChange: this.onChange('prompt'),
|
|
1115
|
+
imageSupport: imageSupport,
|
|
1116
|
+
nonEmpty: false,
|
|
1117
|
+
error: promptError,
|
|
1118
|
+
toolbarOpts: toolbarOpts,
|
|
1119
|
+
pluginProps: getPluginProps(cPrompt == null ? void 0 : cPrompt.inputConfiguration, baseInputConfiguration),
|
|
1120
|
+
spellCheck: spellCheckEnabled,
|
|
1121
|
+
maxImageWidth: defaultImageMaxWidth,
|
|
1122
|
+
maxImageHeight: defaultImageMaxHeight,
|
|
1123
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
1124
|
+
languageCharactersProps: [{
|
|
1125
|
+
language: 'spanish'
|
|
1126
|
+
}, {
|
|
1127
|
+
language: 'special'
|
|
1128
|
+
}],
|
|
1129
|
+
mathMlOptions: mathMlOptions
|
|
1130
|
+
}), promptError && /*#__PURE__*/React.createElement("div", {
|
|
1131
|
+
className: classes.errorText
|
|
1132
|
+
}, promptError)), responseType === ResponseTypes.advanced && /*#__PURE__*/React.createElement("div", {
|
|
1133
|
+
className: classes.advancedResponse
|
|
1134
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1135
|
+
className: classes.flexContainer,
|
|
1136
|
+
style: {
|
|
1137
|
+
justifyContent: 'flex-start'
|
|
1138
|
+
}
|
|
1139
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1140
|
+
className: classes.title
|
|
1141
|
+
}, "Define Response"), validationTooltip), /*#__PURE__*/React.createElement(InputContainer, {
|
|
1142
|
+
key: "templateEditorType",
|
|
1143
|
+
label: "Response Template Equation Editor",
|
|
1144
|
+
className: classes.selectContainer
|
|
1145
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
1146
|
+
className: classes.select,
|
|
1147
|
+
onChange: this.onChange('promptEquationEditor'),
|
|
1148
|
+
value: promptEquationEditor
|
|
1149
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
1150
|
+
value: "non-negative-integers"
|
|
1151
|
+
}, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1152
|
+
value: "integers"
|
|
1153
|
+
}, "Numeric - Integers"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1154
|
+
value: "decimals"
|
|
1155
|
+
}, "Numeric - Decimals"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1156
|
+
value: "fractions"
|
|
1157
|
+
}, "Numeric - Fractions"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1158
|
+
value: 1
|
|
1159
|
+
}, "Grade 1 - 2"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1160
|
+
value: 3
|
|
1161
|
+
}, "Grade 3 - 5"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1162
|
+
value: 6
|
|
1163
|
+
}, "Grade 6 - 7"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1164
|
+
value: 8
|
|
1165
|
+
}, "Grade 8 - HS"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1166
|
+
value: 'geometry'
|
|
1167
|
+
}, "Geometry"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1168
|
+
value: 'advanced-algebra'
|
|
1169
|
+
}, "Advanced Algebra"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1170
|
+
value: 'statistics'
|
|
1171
|
+
}, "Statistics"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1172
|
+
value: 'item-authoring'
|
|
1173
|
+
}, "Item Authoring"))), /*#__PURE__*/React.createElement("div", {
|
|
1174
|
+
className: classes.responseTemplate,
|
|
1175
|
+
key: "templateHolder"
|
|
1176
|
+
}, /*#__PURE__*/React.createElement(InputLabel, {
|
|
1177
|
+
className: classes.templateTitle
|
|
1178
|
+
}, "RESPONSE TEMPLATE"), /*#__PURE__*/React.createElement(MathToolbar, {
|
|
1179
|
+
classNames: classNames,
|
|
1180
|
+
allowAnswerBlock: true,
|
|
1181
|
+
keypadMode: promptEquationEditor,
|
|
1182
|
+
controlledKeypad: true,
|
|
1183
|
+
showKeypad: showKeypad,
|
|
1184
|
+
latex: prepareForStatic(expression) || '',
|
|
1185
|
+
onChange: this.onChange('expression'),
|
|
1186
|
+
onFocus: this.onFocus,
|
|
1187
|
+
onDone: this.onDone,
|
|
1188
|
+
maxResponseAreas: maxResponseAreas,
|
|
1189
|
+
error: responseAreasError
|
|
1190
|
+
})), responseAreasError && /*#__PURE__*/React.createElement("div", {
|
|
1191
|
+
className: classes.errorText
|
|
1192
|
+
}, responseAreasError)), /*#__PURE__*/React.createElement("div", {
|
|
1193
|
+
className: classes.flexContainer,
|
|
1194
|
+
style: {
|
|
1195
|
+
justifyContent: 'flex-start'
|
|
1196
|
+
}
|
|
1197
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
1198
|
+
className: classes.title
|
|
1199
|
+
}, "Define Correct Response"), responseType === ResponseTypes.simple ? validationTooltip : null), /*#__PURE__*/React.createElement(InputContainer, {
|
|
1200
|
+
label: "Equation Editor",
|
|
1201
|
+
className: classes.selectContainer
|
|
1202
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
1203
|
+
className: classes.select,
|
|
1204
|
+
onChange: this.onChange('equationEditor'),
|
|
1205
|
+
value: equationEditor
|
|
1206
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
1207
|
+
value: "non-negative-integers"
|
|
1208
|
+
}, "Numeric - Non-Negative Integers"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1209
|
+
value: "integers"
|
|
1210
|
+
}, "Numeric - Integers"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1211
|
+
value: "decimals"
|
|
1212
|
+
}, "Numeric - Decimals"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1213
|
+
value: "fractions"
|
|
1214
|
+
}, "Numeric - Fractions"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1215
|
+
value: 1
|
|
1216
|
+
}, "Grade 1 - 2"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1217
|
+
value: 3
|
|
1218
|
+
}, "Grade 3 - 5"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1219
|
+
value: 6
|
|
1220
|
+
}, "Grade 6 - 7"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1221
|
+
value: 8
|
|
1222
|
+
}, "Grade 8 - HS"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1223
|
+
value: 'geometry'
|
|
1224
|
+
}, "Geometry"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1225
|
+
value: 'advanced-algebra'
|
|
1226
|
+
}, "Advanced Algebra"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1227
|
+
value: 'statistics'
|
|
1228
|
+
}, "Statistics"), /*#__PURE__*/React.createElement(MenuItem, {
|
|
1229
|
+
value: 'item-authoring'
|
|
1230
|
+
}, "Item Authoring"))), responsesToUse.map((response, idx) => /*#__PURE__*/React.createElement(Response$1, {
|
|
1231
|
+
key: response.id,
|
|
1232
|
+
mode: equationEditor,
|
|
1233
|
+
response: response,
|
|
1234
|
+
defaultResponse: responseType === ResponseTypes.simple,
|
|
1235
|
+
onResponseChange: this.onResponseChange,
|
|
1236
|
+
index: idx,
|
|
1237
|
+
cIgnoreOrder: cIgnoreOrder,
|
|
1238
|
+
cAllowTrailingZeros: cAllowTrailingZeros,
|
|
1239
|
+
error: responsesErrors && responsesErrors[idx]
|
|
1240
|
+
})), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer, {
|
|
1241
|
+
label: cRationale.label,
|
|
1242
|
+
className: classes.promptHolder
|
|
1243
|
+
}, /*#__PURE__*/React.createElement(EditableHtml, {
|
|
1244
|
+
className: classes.prompt,
|
|
1245
|
+
markup: rationale || '',
|
|
1246
|
+
onChange: this.onChange('rationale'),
|
|
1247
|
+
imageSupport: imageSupport,
|
|
1248
|
+
nonEmpty: false,
|
|
1249
|
+
error: rationaleError,
|
|
1250
|
+
toolbarOpts: toolbarOpts,
|
|
1251
|
+
pluginProps: getPluginProps(cRationale == null ? void 0 : cRationale.inputConfiguration, _extends({}, baseInputConfiguration, {
|
|
1252
|
+
math: {
|
|
1253
|
+
controlledKeypadMode: false
|
|
1254
|
+
}
|
|
1255
|
+
})),
|
|
1256
|
+
spellCheck: spellCheckEnabled,
|
|
1257
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
1258
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
1259
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
1260
|
+
languageCharactersProps: [{
|
|
1261
|
+
language: 'spanish'
|
|
1262
|
+
}, {
|
|
1263
|
+
language: 'special'
|
|
1264
|
+
}],
|
|
1265
|
+
mathMlOptions: mathMlOptions
|
|
1266
|
+
}), rationaleError && /*#__PURE__*/React.createElement("div", {
|
|
1267
|
+
className: classes.errorText
|
|
1268
|
+
}, rationaleError)));
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
GeneralConfigBlock.propTypes = {
|
|
1274
|
+
classes: PropTypes.object.isRequired,
|
|
1275
|
+
model: PropTypes.object.isRequired,
|
|
1276
|
+
imageSupport: PropTypes.object,
|
|
1277
|
+
uploadSoundSupport: PropTypes.object,
|
|
1278
|
+
configuration: PropTypes.object,
|
|
1279
|
+
onChange: PropTypes.func.isRequired,
|
|
1280
|
+
promptEnabled: PropTypes.bool,
|
|
1281
|
+
rationaleEnabled: PropTypes.bool,
|
|
1282
|
+
toolbarOpts: PropTypes.object
|
|
1283
|
+
};
|
|
1284
|
+
var GeneralConfigBlock$1 = withStyles(styles$1)(GeneralConfigBlock);
|
|
1285
|
+
|
|
1286
|
+
const log$1 = debug('@pie-element:math-inline:configure');
|
|
1287
|
+
const {
|
|
1288
|
+
Panel,
|
|
1289
|
+
toggle,
|
|
1290
|
+
radio,
|
|
1291
|
+
dropdown
|
|
1292
|
+
} = settings;
|
|
1293
|
+
|
|
1294
|
+
const styles = theme => ({
|
|
1295
|
+
promptHolder: {
|
|
1296
|
+
width: '100%',
|
|
1297
|
+
paddingTop: theme.spacing.unit * 2,
|
|
1298
|
+
marginBottom: theme.spacing.unit * 2
|
|
1299
|
+
},
|
|
1300
|
+
errorText: {
|
|
1301
|
+
fontSize: theme.typography.fontSize - 2,
|
|
1302
|
+
color: theme.palette.error.main,
|
|
1303
|
+
paddingTop: theme.spacing.unit
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
|
|
1307
|
+
class Configure extends React__default.Component {
|
|
1308
|
+
constructor(...args) {
|
|
1309
|
+
super(...args);
|
|
1310
|
+
|
|
1311
|
+
this.onChange = model => {
|
|
1312
|
+
this.props.onModelChanged(model);
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
this.changeTeacherInstructions = teacherInstructions => {
|
|
1316
|
+
this.props.onModelChanged(_extends({}, this.props.model, {
|
|
1317
|
+
teacherInstructions
|
|
1318
|
+
}));
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
this.onFeedbackChange = feedback => {
|
|
1322
|
+
const {
|
|
1323
|
+
model,
|
|
1324
|
+
onModelChanged
|
|
1325
|
+
} = this.props;
|
|
1326
|
+
model.feedback = feedback;
|
|
1327
|
+
onModelChanged(model);
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
render() {
|
|
1332
|
+
const {
|
|
1333
|
+
classes,
|
|
1334
|
+
model,
|
|
1335
|
+
imageSupport,
|
|
1336
|
+
onModelChanged,
|
|
1337
|
+
configuration,
|
|
1338
|
+
onConfigurationChanged,
|
|
1339
|
+
uploadSoundSupport
|
|
1340
|
+
} = this.props;
|
|
1341
|
+
const {
|
|
1342
|
+
allowTrailingZeros = {},
|
|
1343
|
+
baseInputConfiguration = {},
|
|
1344
|
+
contentDimensions = {},
|
|
1345
|
+
feedback = {},
|
|
1346
|
+
ignoreOrder = {},
|
|
1347
|
+
maxImageWidth = {},
|
|
1348
|
+
maxImageHeight = {},
|
|
1349
|
+
prompt = {},
|
|
1350
|
+
rationale = {},
|
|
1351
|
+
responseType = {},
|
|
1352
|
+
scoringType = {},
|
|
1353
|
+
settingsPanelDisabled,
|
|
1354
|
+
spellCheck = {},
|
|
1355
|
+
studentInstructions = {},
|
|
1356
|
+
teacherInstructions = {},
|
|
1357
|
+
withRubric = {},
|
|
1358
|
+
mathMlOptions = {},
|
|
1359
|
+
language = {},
|
|
1360
|
+
languageChoices = {}
|
|
1361
|
+
} = configuration || {};
|
|
1362
|
+
const {
|
|
1363
|
+
errors = {},
|
|
1364
|
+
extraCSSRules,
|
|
1365
|
+
feedbackEnabled,
|
|
1366
|
+
promptEnabled,
|
|
1367
|
+
rationaleEnabled,
|
|
1368
|
+
spellCheckEnabled,
|
|
1369
|
+
teacherInstructionsEnabled,
|
|
1370
|
+
toolbarEditorPosition
|
|
1371
|
+
} = model || {};
|
|
1372
|
+
const {
|
|
1373
|
+
teacherInstructions: teacherInstructionsError
|
|
1374
|
+
} = errors;
|
|
1375
|
+
log$1('[render] model', model);
|
|
1376
|
+
const toolbarOpts = {
|
|
1377
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
1378
|
+
};
|
|
1379
|
+
const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
1380
|
+
const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
1381
|
+
const panelSettings = {
|
|
1382
|
+
responseType: responseType.settings && radio(responseType.label, [ResponseTypes.simple, ResponseTypes.advanced]),
|
|
1383
|
+
feedbackEnabled: feedback.settings && toggle(feedback.label),
|
|
1384
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
1385
|
+
'language.enabled': language.settings && toggle(language.label, true),
|
|
1386
|
+
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
|
|
1387
|
+
};
|
|
1388
|
+
const panelProperties = {
|
|
1389
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
1390
|
+
studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
|
|
1391
|
+
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
1392
|
+
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
1393
|
+
scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
|
|
1394
|
+
'ignoreOrder.enabled': ignoreOrder.settings && toggle(ignoreOrder.label),
|
|
1395
|
+
'allowTrailingZeros.enabled': allowTrailingZeros.settings && toggle(allowTrailingZeros.label),
|
|
1396
|
+
rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
|
|
1397
|
+
};
|
|
1398
|
+
return /*#__PURE__*/React__default.createElement(layout.ConfigLayout, {
|
|
1399
|
+
extraCSSRules: extraCSSRules,
|
|
1400
|
+
dimensions: contentDimensions,
|
|
1401
|
+
hideSettings: settingsPanelDisabled,
|
|
1402
|
+
settings: /*#__PURE__*/React__default.createElement(Panel, {
|
|
1403
|
+
model: model,
|
|
1404
|
+
configuration: configuration,
|
|
1405
|
+
onChangeModel: model => onModelChanged(model),
|
|
1406
|
+
onChangeConfiguration: config => onConfigurationChanged(config),
|
|
1407
|
+
groups: {
|
|
1408
|
+
Settings: panelSettings,
|
|
1409
|
+
Properties: panelProperties
|
|
1410
|
+
}
|
|
1411
|
+
})
|
|
1412
|
+
}, teacherInstructionsEnabled && /*#__PURE__*/React__default.createElement(InputContainer, {
|
|
1413
|
+
label: teacherInstructions.label,
|
|
1414
|
+
className: classes.promptHolder
|
|
1415
|
+
}, /*#__PURE__*/React__default.createElement(EditableHtml, {
|
|
1416
|
+
className: classes.prompt,
|
|
1417
|
+
markup: model.teacherInstructions || '',
|
|
1418
|
+
onChange: this.changeTeacherInstructions,
|
|
1419
|
+
imageSupport: imageSupport,
|
|
1420
|
+
nonEmpty: false,
|
|
1421
|
+
error: teacherInstructionsError,
|
|
1422
|
+
toolbarOpts: toolbarOpts,
|
|
1423
|
+
pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration, baseInputConfiguration),
|
|
1424
|
+
spellCheck: spellCheckEnabled,
|
|
1425
|
+
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
1426
|
+
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
1427
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
1428
|
+
languageCharactersProps: [{
|
|
1429
|
+
language: 'spanish'
|
|
1430
|
+
}, {
|
|
1431
|
+
language: 'special'
|
|
1432
|
+
}],
|
|
1433
|
+
mathMlOptions: mathMlOptions
|
|
1434
|
+
}), teacherInstructionsError && /*#__PURE__*/React__default.createElement("div", {
|
|
1435
|
+
className: classes.errorText
|
|
1436
|
+
}, teacherInstructionsError)), /*#__PURE__*/React__default.createElement(GeneralConfigBlock$1, {
|
|
1437
|
+
imageSupport: imageSupport,
|
|
1438
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
1439
|
+
model: model,
|
|
1440
|
+
configuration: configuration,
|
|
1441
|
+
onChange: this.onChange,
|
|
1442
|
+
rationaleEnabled: rationaleEnabled,
|
|
1443
|
+
promptEnabled: promptEnabled,
|
|
1444
|
+
toolbarOpts: toolbarOpts,
|
|
1445
|
+
spellCheck: spellCheckEnabled
|
|
1446
|
+
}), feedbackEnabled && /*#__PURE__*/React__default.createElement(FeedbackConfig, {
|
|
1447
|
+
feedback: model.feedback,
|
|
1448
|
+
onChange: this.onFeedbackChange,
|
|
1449
|
+
toolbarOpts: toolbarOpts
|
|
1450
|
+
}));
|
|
1451
|
+
}
|
|
1452
|
+
|
|
1453
|
+
}
|
|
1454
|
+
Configure.propTypes = {
|
|
1455
|
+
onModelChanged: PropTypes.func,
|
|
1456
|
+
onConfigurationChanged: PropTypes.func,
|
|
1457
|
+
classes: PropTypes.object,
|
|
1458
|
+
model: PropTypes.object.isRequired,
|
|
1459
|
+
configuration: PropTypes.object.isRequired,
|
|
1460
|
+
imageSupport: PropTypes.object,
|
|
1461
|
+
uploadSoundSupport: PropTypes.object
|
|
1462
|
+
};
|
|
1463
|
+
var Configure$1 = withStyles(styles)(Configure);
|
|
1464
|
+
|
|
1465
|
+
/** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
|
|
1466
|
+
* functionalities are not defined yet - the value for those can belong to
|
|
1467
|
+
* model or to configure
|
|
1468
|
+
*/
|
|
1469
|
+
|
|
1470
|
+
var defaults = {
|
|
1471
|
+
model: {
|
|
1472
|
+
allowTrailingZerosDefault: false,
|
|
1473
|
+
customKeys: [],
|
|
1474
|
+
equationEditor: '8',
|
|
1475
|
+
expression: '',
|
|
1476
|
+
feedback: {
|
|
1477
|
+
correct: {
|
|
1478
|
+
default: 'Correct',
|
|
1479
|
+
type: 'none'
|
|
1480
|
+
},
|
|
1481
|
+
incorrect: {
|
|
1482
|
+
default: 'Incorrect',
|
|
1483
|
+
type: 'none'
|
|
1484
|
+
},
|
|
1485
|
+
partial: {
|
|
1486
|
+
default: 'Nearly',
|
|
1487
|
+
type: 'none'
|
|
1488
|
+
}
|
|
1489
|
+
},
|
|
1490
|
+
feedbackEnabled: false,
|
|
1491
|
+
ignoreOrderDefault: false,
|
|
1492
|
+
partialScoring: true,
|
|
1493
|
+
prompt: '',
|
|
1494
|
+
promptEnabled: true,
|
|
1495
|
+
rationale: '',
|
|
1496
|
+
rationaleEnabled: true,
|
|
1497
|
+
responseType: ResponseTypes.advanced,
|
|
1498
|
+
responses: [],
|
|
1499
|
+
scoringType: 'auto',
|
|
1500
|
+
studentInstructionsEnabled: true,
|
|
1501
|
+
teacherInstructions: '',
|
|
1502
|
+
teacherInstructionsEnabled: true,
|
|
1503
|
+
toolbarEditorPosition: 'bottom',
|
|
1504
|
+
validationDefault: 'literal'
|
|
1505
|
+
},
|
|
1506
|
+
configuration: {
|
|
1507
|
+
baseInputConfiguration: {
|
|
1508
|
+
audio: {
|
|
1509
|
+
disabled: false
|
|
1510
|
+
},
|
|
1511
|
+
video: {
|
|
1512
|
+
disabled: false
|
|
1513
|
+
},
|
|
1514
|
+
image: {
|
|
1515
|
+
disabled: false
|
|
1516
|
+
},
|
|
1517
|
+
textAlign: {
|
|
1518
|
+
disabled: true
|
|
1519
|
+
},
|
|
1520
|
+
showParagraphs: {
|
|
1521
|
+
disabled: false
|
|
1522
|
+
},
|
|
1523
|
+
separateParagraphs: {
|
|
1524
|
+
disabled: true
|
|
1525
|
+
}
|
|
1526
|
+
},
|
|
1527
|
+
prompt: {
|
|
1528
|
+
settings: true,
|
|
1529
|
+
label: 'Prompt',
|
|
1530
|
+
inputConfiguration: {
|
|
1531
|
+
audio: {
|
|
1532
|
+
disabled: false
|
|
1533
|
+
},
|
|
1534
|
+
video: {
|
|
1535
|
+
disabled: false
|
|
1536
|
+
},
|
|
1537
|
+
image: {
|
|
1538
|
+
disabled: false
|
|
1539
|
+
}
|
|
1540
|
+
},
|
|
1541
|
+
required: false
|
|
1542
|
+
},
|
|
1543
|
+
feedback: {
|
|
1544
|
+
settings: true,
|
|
1545
|
+
label: 'Feedback'
|
|
1546
|
+
},
|
|
1547
|
+
responseType: {
|
|
1548
|
+
settings: true,
|
|
1549
|
+
label: 'Response type'
|
|
1550
|
+
},
|
|
1551
|
+
rationale: {
|
|
1552
|
+
settings: true,
|
|
1553
|
+
label: 'Rationale',
|
|
1554
|
+
inputConfiguration: {
|
|
1555
|
+
audio: {
|
|
1556
|
+
disabled: false
|
|
1557
|
+
},
|
|
1558
|
+
video: {
|
|
1559
|
+
disabled: false
|
|
1560
|
+
},
|
|
1561
|
+
image: {
|
|
1562
|
+
disabled: false
|
|
1563
|
+
}
|
|
1564
|
+
},
|
|
1565
|
+
required: false
|
|
1566
|
+
},
|
|
1567
|
+
settingsPanelDisabled: false,
|
|
1568
|
+
spellCheck: {
|
|
1569
|
+
label: 'Spellcheck',
|
|
1570
|
+
settings: false,
|
|
1571
|
+
enabled: true
|
|
1572
|
+
},
|
|
1573
|
+
scoringType: {
|
|
1574
|
+
settings: false,
|
|
1575
|
+
label: 'Scoring Type'
|
|
1576
|
+
},
|
|
1577
|
+
studentInstructions: {
|
|
1578
|
+
settings: false,
|
|
1579
|
+
label: 'Student Instructions'
|
|
1580
|
+
},
|
|
1581
|
+
teacherInstructions: {
|
|
1582
|
+
settings: true,
|
|
1583
|
+
label: 'Teacher Instructions',
|
|
1584
|
+
inputConfiguration: {
|
|
1585
|
+
audio: {
|
|
1586
|
+
disabled: false
|
|
1587
|
+
},
|
|
1588
|
+
video: {
|
|
1589
|
+
disabled: false
|
|
1590
|
+
},
|
|
1591
|
+
image: {
|
|
1592
|
+
disabled: false
|
|
1593
|
+
}
|
|
1594
|
+
},
|
|
1595
|
+
required: false
|
|
1596
|
+
},
|
|
1597
|
+
partialScoring: {
|
|
1598
|
+
settings: false,
|
|
1599
|
+
label: 'Allow Partial Scoring'
|
|
1600
|
+
},
|
|
1601
|
+
ignoreOrder: {
|
|
1602
|
+
settings: false,
|
|
1603
|
+
label: 'Ignore Order',
|
|
1604
|
+
enabled: true
|
|
1605
|
+
},
|
|
1606
|
+
allowTrailingZeros: {
|
|
1607
|
+
settings: false,
|
|
1608
|
+
label: 'Allow Trailing Zeros',
|
|
1609
|
+
enabled: true
|
|
1610
|
+
},
|
|
1611
|
+
maxImageWidth: {
|
|
1612
|
+
teacherInstructions: 300,
|
|
1613
|
+
prompt: 300,
|
|
1614
|
+
rationale: 300
|
|
1615
|
+
},
|
|
1616
|
+
maxImageHeight: {
|
|
1617
|
+
teacherInstructions: 300,
|
|
1618
|
+
prompt: 300,
|
|
1619
|
+
rationale: 300
|
|
1620
|
+
},
|
|
1621
|
+
withRubric: {
|
|
1622
|
+
settings: false,
|
|
1623
|
+
label: 'Add Rubric'
|
|
1624
|
+
},
|
|
1625
|
+
mathMlOptions: {
|
|
1626
|
+
mmlOutput: false,
|
|
1627
|
+
mmlEditing: false
|
|
1628
|
+
},
|
|
1629
|
+
language: {
|
|
1630
|
+
settings: false,
|
|
1631
|
+
label: 'Specify Language',
|
|
1632
|
+
enabled: false
|
|
1633
|
+
},
|
|
1634
|
+
languageChoices: {
|
|
1635
|
+
label: 'Language Choices',
|
|
1636
|
+
options: []
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1641
|
+
const log = debug('pie-elements:math-inline:configure');
|
|
1642
|
+
class MathInlineConfigure extends HTMLElement {
|
|
1643
|
+
constructor() {
|
|
1644
|
+
super();
|
|
1645
|
+
this._model = MathInlineConfigure.createDefaultModel();
|
|
1646
|
+
this._configuration = defaults.configuration;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
set model(m) {
|
|
1650
|
+
this._model = MathInlineConfigure.createDefaultModel(m);
|
|
1651
|
+
|
|
1652
|
+
this._render();
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
set configuration(c) {
|
|
1656
|
+
var _newConfiguration$lan;
|
|
1657
|
+
|
|
1658
|
+
const newConfiguration = _extends({}, defaults.configuration, c);
|
|
1659
|
+
|
|
1660
|
+
this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
|
|
1661
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
1662
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
1663
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
1664
|
+
|
|
1665
|
+
if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
|
|
1666
|
+
var _newConfiguration$lan2, _newConfiguration$lan3;
|
|
1667
|
+
|
|
1668
|
+
if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
|
|
1669
|
+
this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
|
|
1670
|
+
}
|
|
1671
|
+
} else if (newConfiguration.language.settings && this._model.language) {
|
|
1672
|
+
this._configuration.language.enabled = true;
|
|
1673
|
+
|
|
1674
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
1675
|
+
this._configuration.languageChoices.options = [];
|
|
1676
|
+
} // check if the language is already included in the languageChoices.options array
|
|
1677
|
+
// and if not, then add it.
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
1681
|
+
this._configuration.languageChoices.options.push({
|
|
1682
|
+
value: this._model.language,
|
|
1683
|
+
label: this._model.language
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
} else {
|
|
1687
|
+
delete this._model.language;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
this._render();
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
onModelChanged(model) {
|
|
1694
|
+
this._model = model;
|
|
1695
|
+
log('[onModelChanged]: ', this._model);
|
|
1696
|
+
|
|
1697
|
+
this._render();
|
|
1698
|
+
|
|
1699
|
+
this.dispatchEvent(new ModelUpdatedEvent(this._model));
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
onConfigurationChanged(c) {
|
|
1703
|
+
this._configuration = c;
|
|
1704
|
+
|
|
1705
|
+
if (this._model) {
|
|
1706
|
+
this.onModelChanged(this._model);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
this._render();
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
*
|
|
1713
|
+
* @param {done, progress, file} handler
|
|
1714
|
+
*/
|
|
1715
|
+
|
|
1716
|
+
|
|
1717
|
+
insertImage(handler) {
|
|
1718
|
+
this.dispatchEvent(new InsertImageEvent(handler));
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
onDeleteImage(src, done) {
|
|
1722
|
+
this.dispatchEvent(new DeleteImageEvent(src, done));
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
insertSound(handler) {
|
|
1726
|
+
this.dispatchEvent(new InsertSoundEvent(handler));
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
onDeleteSound(src, done) {
|
|
1730
|
+
this.dispatchEvent(new DeleteSoundEvent(src, done));
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
_render() {
|
|
1734
|
+
if (this._model) {
|
|
1735
|
+
const el = /*#__PURE__*/React__default.createElement(Configure$1, {
|
|
1736
|
+
onModelChanged: this.onModelChanged.bind(this),
|
|
1737
|
+
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
1738
|
+
model: this._model,
|
|
1739
|
+
configuration: this._configuration,
|
|
1740
|
+
imageSupport: {
|
|
1741
|
+
add: this.insertImage.bind(this),
|
|
1742
|
+
delete: this.onDeleteImage.bind(this)
|
|
1743
|
+
},
|
|
1744
|
+
uploadSoundSupport: {
|
|
1745
|
+
add: this.insertSound.bind(this),
|
|
1746
|
+
delete: this.onDeleteSound.bind(this)
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
ReactDOM.render(el, this);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
MathInlineConfigure.createDefaultModel = (model = {}) => {
|
|
1756
|
+
// making sure that defaults are set
|
|
1757
|
+
if (!isEmpty(model.responses)) {
|
|
1758
|
+
model.responses = model.responses.map(correctResponse => _extends({}, correctResponse, {
|
|
1759
|
+
validation: correctResponse.validation || defaults.model.validationDefault,
|
|
1760
|
+
allowTrailingZeros: correctResponse.allowTrailingZeros || defaults.model.allowTrailingZerosDefault,
|
|
1761
|
+
ignoreOrder: correctResponse.ignoreOrder || defaults.model.ignoreOrderDefault || false
|
|
1762
|
+
}));
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
return _extends({}, defaults.model, model);
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1768
|
+
export { MathInlineConfigure as default };
|
|
1769
|
+
//# sourceMappingURL=configure.js.map
|