@pie-element/inline-dropdown 5.4.1-next.42 → 5.4.1-next.45
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/defaults.js +94 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +209 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/inline-dropdown-toolbar.js +568 -0
- package/configure/lib/inline-dropdown-toolbar.js.map +1 -0
- package/configure/lib/main.js +723 -0
- package/configure/lib/main.js.map +1 -0
- package/configure/lib/markupUtils.js +70 -0
- package/configure/lib/markupUtils.js.map +1 -0
- package/configure/lib/utils.js +17 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +1 -1
- package/controller/lib/defaults.js +11 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +357 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/lib/utils.js +40 -0
- package/controller/lib/utils.js.map +1 -0
- package/controller/package.json +1 -1
- package/lib/index.js +118 -0
- package/lib/index.js.map +1 -0
- package/lib/inline-dropdown.js +238 -0
- package/lib/inline-dropdown.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.Main = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _react = _interopRequireDefault(require("react"));
|
|
25
|
+
|
|
26
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
27
|
+
|
|
28
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
+
|
|
30
|
+
var _editableHtml = require("@pie-lib/pie-toolbox/editable-html");
|
|
31
|
+
|
|
32
|
+
var _configUi = require("@pie-lib/pie-toolbox/config-ui");
|
|
33
|
+
|
|
34
|
+
var _mathRendering = require("@pie-lib/pie-toolbox/math-rendering");
|
|
35
|
+
|
|
36
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
37
|
+
|
|
38
|
+
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
39
|
+
|
|
40
|
+
var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
|
|
41
|
+
|
|
42
|
+
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
43
|
+
|
|
44
|
+
var _reduce = _interopRequireDefault(require("lodash/reduce"));
|
|
45
|
+
|
|
46
|
+
var _max = _interopRequireDefault(require("lodash/max"));
|
|
47
|
+
|
|
48
|
+
var _styles = require("@material-ui/core/styles");
|
|
49
|
+
|
|
50
|
+
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
51
|
+
|
|
52
|
+
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
53
|
+
|
|
54
|
+
var _ExpansionPanel = _interopRequireDefault(require("@material-ui/core/ExpansionPanel"));
|
|
55
|
+
|
|
56
|
+
var _ExpansionPanelSummary = _interopRequireDefault(require("@material-ui/core/ExpansionPanelSummary"));
|
|
57
|
+
|
|
58
|
+
var _ExpansionPanelDetails = _interopRequireDefault(require("@material-ui/core/ExpansionPanelDetails"));
|
|
59
|
+
|
|
60
|
+
var _ExpandMore = _interopRequireDefault(require("@material-ui/icons/ExpandMore"));
|
|
61
|
+
|
|
62
|
+
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
63
|
+
|
|
64
|
+
var _inlineDropdownToolbar = _interopRequireDefault(require("./inline-dropdown-toolbar"));
|
|
65
|
+
|
|
66
|
+
var _utils = require("./utils");
|
|
67
|
+
|
|
68
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
69
|
+
|
|
70
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
71
|
+
|
|
72
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
73
|
+
|
|
74
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
75
|
+
|
|
76
|
+
var toggle = _configUi.settings.toggle,
|
|
77
|
+
Panel = _configUi.settings.Panel,
|
|
78
|
+
dropdown = _configUi.settings.dropdown;
|
|
79
|
+
|
|
80
|
+
var styles = function styles(theme) {
|
|
81
|
+
return {
|
|
82
|
+
promptHolder: {
|
|
83
|
+
width: '100%',
|
|
84
|
+
paddingTop: theme.spacing.unit * 2,
|
|
85
|
+
marginBottom: theme.spacing.unit * 2
|
|
86
|
+
},
|
|
87
|
+
markup: {
|
|
88
|
+
minHeight: '100px',
|
|
89
|
+
width: '100%',
|
|
90
|
+
'& [data-slate-editor="true"]': {
|
|
91
|
+
minHeight: '100px'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
choiceConfiguration: {
|
|
95
|
+
paddingTop: theme.spacing.unit * 2,
|
|
96
|
+
paddingBottom: theme.spacing.unit * 2
|
|
97
|
+
},
|
|
98
|
+
text: {
|
|
99
|
+
fontSize: theme.typography.fontSize + 2,
|
|
100
|
+
marginRight: theme.spacing.unit
|
|
101
|
+
},
|
|
102
|
+
rationaleLabel: {
|
|
103
|
+
display: 'flex',
|
|
104
|
+
whiteSpace: 'break-spaces'
|
|
105
|
+
},
|
|
106
|
+
rationaleChoices: {
|
|
107
|
+
marginBottom: theme.spacing.unit * 2.5
|
|
108
|
+
},
|
|
109
|
+
responseArea: {
|
|
110
|
+
paddingBottom: theme.spacing.unit * 2.5
|
|
111
|
+
},
|
|
112
|
+
panelDetails: {
|
|
113
|
+
display: 'block',
|
|
114
|
+
paddingTop: 0,
|
|
115
|
+
paddingBottom: 0
|
|
116
|
+
},
|
|
117
|
+
flexContainer: {
|
|
118
|
+
display: 'flex',
|
|
119
|
+
alignItems: 'center',
|
|
120
|
+
marginBottom: theme.spacing.unit
|
|
121
|
+
},
|
|
122
|
+
tooltip: {
|
|
123
|
+
fontSize: theme.typography.fontSize - 2,
|
|
124
|
+
whiteSpace: 'pre',
|
|
125
|
+
maxWidth: '500px'
|
|
126
|
+
},
|
|
127
|
+
errorText: {
|
|
128
|
+
fontSize: theme.typography.fontSize - 2,
|
|
129
|
+
color: theme.palette.error.main,
|
|
130
|
+
paddingTop: theme.spacing.unit
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var createElementFromHTML = function createElementFromHTML(htmlString) {
|
|
136
|
+
var div = document.createElement('div');
|
|
137
|
+
div.innerHTML = (htmlString || '').trim();
|
|
138
|
+
return div;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var prepareVal = function prepareVal(html) {
|
|
142
|
+
var tmp = document.createElement('DIV');
|
|
143
|
+
tmp.innerHTML = html;
|
|
144
|
+
var value = tmp.textContent || tmp.innerText || '';
|
|
145
|
+
return value.trim();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
var Main = /*#__PURE__*/function (_React$Component) {
|
|
149
|
+
(0, _inherits2["default"])(Main, _React$Component);
|
|
150
|
+
|
|
151
|
+
var _super = _createSuper(Main);
|
|
152
|
+
|
|
153
|
+
function Main() {
|
|
154
|
+
var _this;
|
|
155
|
+
|
|
156
|
+
(0, _classCallCheck2["default"])(this, Main);
|
|
157
|
+
|
|
158
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
159
|
+
args[_key] = arguments[_key];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
163
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
164
|
+
warning: {
|
|
165
|
+
open: false
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelChange", function (newVal) {
|
|
169
|
+
_this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), newVal));
|
|
170
|
+
});
|
|
171
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
|
|
172
|
+
_this.onModelChange({
|
|
173
|
+
prompt: prompt
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
|
|
177
|
+
_this.onModelChange({
|
|
178
|
+
rationale: rationale
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceRationaleChanged", function (index, choice) {
|
|
182
|
+
var model = _this.props.model;
|
|
183
|
+
var indexOfChoice = model.choices && model.choices[index] && model.choices[index].findIndex(function (elem) {
|
|
184
|
+
return elem.label === choice.label && elem.value === choice.value;
|
|
185
|
+
});
|
|
186
|
+
model.choices[index] && model.choices[index].splice(indexOfChoice, 1, choice);
|
|
187
|
+
|
|
188
|
+
_this.onModelChange(model);
|
|
189
|
+
});
|
|
190
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
|
|
191
|
+
_this.onModelChange({
|
|
192
|
+
teacherInstructions: teacherInstructions
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onMarkupChanged", function (slateMarkup) {
|
|
196
|
+
_this.onModelChange({
|
|
197
|
+
slateMarkup: slateMarkup
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCheck", function (callback) {
|
|
201
|
+
_this.setState({
|
|
202
|
+
warning: {
|
|
203
|
+
open: true,
|
|
204
|
+
text: 'Response areas with under 2 options or with no correct answers will be discarded.',
|
|
205
|
+
onClose: function onClose() {
|
|
206
|
+
_this.setState({
|
|
207
|
+
warning: {
|
|
208
|
+
open: false
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
onConfirm: function onConfirm() {
|
|
213
|
+
_this.setState({
|
|
214
|
+
warning: {
|
|
215
|
+
open: false
|
|
216
|
+
}
|
|
217
|
+
}, callback);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (markup) {
|
|
223
|
+
var respAreaChoices = _this.state.respAreaChoices;
|
|
224
|
+
var domMarkup = createElementFromHTML(markup);
|
|
225
|
+
var allRespAreas = domMarkup.querySelectorAll('[data-type="inline_dropdown"]');
|
|
226
|
+
var allChoices = {};
|
|
227
|
+
allRespAreas.forEach(function (el) {
|
|
228
|
+
allChoices[el.dataset.index] = el.dataset.value || '';
|
|
229
|
+
});
|
|
230
|
+
var existingRespAreaChoices = (0, _reduce["default"])(respAreaChoices, function (obj, choices, key) {
|
|
231
|
+
if (!(0, _isUndefined["default"])(allChoices[key])) {
|
|
232
|
+
obj[key] = respAreaChoices[key];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return obj;
|
|
236
|
+
}, {});
|
|
237
|
+
var newRespAreaChoices = {};
|
|
238
|
+
var shouldWarn = false;
|
|
239
|
+
allRespAreas.forEach(function (el, index) {
|
|
240
|
+
var newChoices = existingRespAreaChoices[el.dataset.index] || [];
|
|
241
|
+
|
|
242
|
+
if (newChoices.length < 2 || !newChoices.find(function (c) {
|
|
243
|
+
return c.correct;
|
|
244
|
+
})) {
|
|
245
|
+
el.remove();
|
|
246
|
+
shouldWarn = true;
|
|
247
|
+
} else {
|
|
248
|
+
newRespAreaChoices[index] = existingRespAreaChoices[el.dataset.index] || [];
|
|
249
|
+
el.dataset.index = index;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (shouldWarn) {
|
|
254
|
+
_this.setState({
|
|
255
|
+
warning: {
|
|
256
|
+
open: true,
|
|
257
|
+
text: 'Response areas with under 2 options or with no correct answers will be discarded.',
|
|
258
|
+
onClose: function onClose() {
|
|
259
|
+
_this.setState({
|
|
260
|
+
warning: {
|
|
261
|
+
open: false
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
onConfirm: function onConfirm() {
|
|
266
|
+
_this.setState({
|
|
267
|
+
warning: {
|
|
268
|
+
open: false
|
|
269
|
+
}
|
|
270
|
+
}, function () {
|
|
271
|
+
return _this.onModelChange({
|
|
272
|
+
choices: (0, _cloneDeep["default"])(newRespAreaChoices),
|
|
273
|
+
slateMarkup: domMarkup.innerHTML
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
} else {
|
|
280
|
+
_this.onModelChange({
|
|
281
|
+
choices: (0, _cloneDeep["default"])(newRespAreaChoices),
|
|
282
|
+
slateMarkup: domMarkup.innerHTML
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function (index, label, choiceIndex) {
|
|
287
|
+
var _respAreaChoices$inde;
|
|
288
|
+
|
|
289
|
+
var respAreaChoices = _this.state.respAreaChoices;
|
|
290
|
+
var maxResponseAreaChoices = _this.props.configuration.maxResponseAreaChoices;
|
|
291
|
+
|
|
292
|
+
if (respAreaChoices[index] && respAreaChoices[index].length >= maxResponseAreaChoices) {
|
|
293
|
+
_this.setState({
|
|
294
|
+
warning: {
|
|
295
|
+
open: true,
|
|
296
|
+
text: "There are only ".concat(maxResponseAreaChoices, " answers allowed per choice."),
|
|
297
|
+
onClose: undefined,
|
|
298
|
+
onConfirm: function onConfirm() {
|
|
299
|
+
_this.setState({
|
|
300
|
+
warning: {
|
|
301
|
+
open: false
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (!respAreaChoices[index]) {
|
|
312
|
+
respAreaChoices[index] = [];
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if ((respAreaChoices[index] || []).find(function (r) {
|
|
316
|
+
return prepareVal(r.label) === prepareVal(label);
|
|
317
|
+
})) {
|
|
318
|
+
// show warning for duplicated answers
|
|
319
|
+
_this.setState({
|
|
320
|
+
warning: {
|
|
321
|
+
open: true,
|
|
322
|
+
text: 'Duplicate answers are not allowed.',
|
|
323
|
+
onClose: undefined,
|
|
324
|
+
onConfirm: function onConfirm() {
|
|
325
|
+
_this.setState({
|
|
326
|
+
warning: {
|
|
327
|
+
open: false
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (choiceIndex >= 0 && (_respAreaChoices$inde = respAreaChoices[index]) !== null && _respAreaChoices$inde !== void 0 && _respAreaChoices$inde[choiceIndex]) {
|
|
338
|
+
// we need to update the choice label with the new value
|
|
339
|
+
respAreaChoices[index][choiceIndex].label = label;
|
|
340
|
+
} else {
|
|
341
|
+
// add a new choice
|
|
342
|
+
var value = respAreaChoices[index] && (0, _max["default"])(respAreaChoices[index].map(function (c) {
|
|
343
|
+
return parseInt(c.value);
|
|
344
|
+
}).filter(function (val) {
|
|
345
|
+
return !isNaN(val);
|
|
346
|
+
})) || 0;
|
|
347
|
+
respAreaChoices[index].push({
|
|
348
|
+
label: label,
|
|
349
|
+
value: "".concat(value + 1),
|
|
350
|
+
correct: false
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
_this.onModelChange({
|
|
355
|
+
choices: (0, _cloneDeep["default"])(respAreaChoices)
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveChoice", function (respIndex, index) {
|
|
359
|
+
var respAreaChoices = _this.state.respAreaChoices;
|
|
360
|
+
respAreaChoices[respIndex].splice(index, 1);
|
|
361
|
+
|
|
362
|
+
_this.onModelChange({
|
|
363
|
+
choices: (0, _cloneDeep["default"])(respAreaChoices)
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onSelectChoice", function (respIndex, selectedIndex) {
|
|
367
|
+
var respAreaChoices = _this.state.respAreaChoices;
|
|
368
|
+
respAreaChoices[respIndex] = respAreaChoices[respIndex].map(function (choice, index) {
|
|
369
|
+
return _objectSpread(_objectSpread({}, choice), {}, {
|
|
370
|
+
correct: index === selectedIndex
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
_this.onModelChange({
|
|
375
|
+
choices: (0, _cloneDeep["default"])(respAreaChoices)
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
return _this;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
(0, _createClass2["default"])(Main, [{
|
|
382
|
+
key: "componentDidMount",
|
|
383
|
+
value: function componentDidMount() {
|
|
384
|
+
var choices = this.props.model.choices;
|
|
385
|
+
this.setState({
|
|
386
|
+
respAreaChoices: (0, _cloneDeep["default"])(choices)
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}, {
|
|
390
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
391
|
+
value: function UNSAFE_componentWillReceiveProps(nProps) {
|
|
392
|
+
var newState = {};
|
|
393
|
+
|
|
394
|
+
if (!(0, _isEqual["default"])(nProps.model.choices, this.props.model.choices) || !(0, _isEqual["default"])(nProps.model.choices, this.state.respAreaChoices)) {
|
|
395
|
+
newState.respAreaChoices = (0, _cloneDeep["default"])(nProps.model.choices);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (!(0, _isEmpty["default"])(newState)) {
|
|
399
|
+
this.setState(newState);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}, {
|
|
403
|
+
key: "componentDidUpdate",
|
|
404
|
+
value: function componentDidUpdate() {
|
|
405
|
+
//eslint-disable-next-line
|
|
406
|
+
var domNode = _reactDom["default"].findDOMNode(this);
|
|
407
|
+
|
|
408
|
+
(0, _mathRendering.renderMath)(domNode);
|
|
409
|
+
}
|
|
410
|
+
}, {
|
|
411
|
+
key: "render",
|
|
412
|
+
value: function render() {
|
|
413
|
+
var _this2 = this;
|
|
414
|
+
|
|
415
|
+
var warning = this.state.warning;
|
|
416
|
+
var _this$props = this.props,
|
|
417
|
+
classes = _this$props.classes,
|
|
418
|
+
model = _this$props.model,
|
|
419
|
+
configuration = _this$props.configuration,
|
|
420
|
+
onConfigurationChanged = _this$props.onConfigurationChanged,
|
|
421
|
+
imageSupport = _this$props.imageSupport,
|
|
422
|
+
uploadSoundSupport = _this$props.uploadSoundSupport;
|
|
423
|
+
|
|
424
|
+
var _ref = configuration || {},
|
|
425
|
+
_ref$choiceRationale = _ref.choiceRationale,
|
|
426
|
+
choiceRationale = _ref$choiceRationale === void 0 ? {} : _ref$choiceRationale,
|
|
427
|
+
_ref$contentDimension = _ref.contentDimensions,
|
|
428
|
+
contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension,
|
|
429
|
+
_ref$lockChoiceOrder = _ref.lockChoiceOrder,
|
|
430
|
+
lockChoiceOrder = _ref$lockChoiceOrder === void 0 ? {} : _ref$lockChoiceOrder,
|
|
431
|
+
maxResponseAreas = _ref.maxResponseAreas,
|
|
432
|
+
_ref$maxImageWidth = _ref.maxImageWidth,
|
|
433
|
+
maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
|
|
434
|
+
_ref$maxImageHeight = _ref.maxImageHeight,
|
|
435
|
+
maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
|
|
436
|
+
_ref$partialScoring = _ref.partialScoring,
|
|
437
|
+
partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
|
|
438
|
+
_ref$prompt = _ref.prompt,
|
|
439
|
+
prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
|
|
440
|
+
_ref$rationale = _ref.rationale,
|
|
441
|
+
rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
|
|
442
|
+
settingsPanelDisabled = _ref.settingsPanelDisabled,
|
|
443
|
+
_ref$spellCheck = _ref.spellCheck,
|
|
444
|
+
spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
|
|
445
|
+
_ref$teacherInstructi = _ref.teacherInstructions,
|
|
446
|
+
teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
|
|
447
|
+
_ref$withRubric = _ref.withRubric,
|
|
448
|
+
withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric,
|
|
449
|
+
_ref$mathMlOptions = _ref.mathMlOptions,
|
|
450
|
+
mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions,
|
|
451
|
+
_ref$language = _ref.language,
|
|
452
|
+
language = _ref$language === void 0 ? {} : _ref$language,
|
|
453
|
+
_ref$languageChoices = _ref.languageChoices,
|
|
454
|
+
languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices;
|
|
455
|
+
|
|
456
|
+
var _ref2 = model || {},
|
|
457
|
+
choiceRationaleEnabled = _ref2.choiceRationaleEnabled,
|
|
458
|
+
choices = _ref2.choices,
|
|
459
|
+
errors = _ref2.errors,
|
|
460
|
+
promptEnabled = _ref2.promptEnabled,
|
|
461
|
+
rationaleEnabled = _ref2.rationaleEnabled,
|
|
462
|
+
spellCheckEnabled = _ref2.spellCheckEnabled,
|
|
463
|
+
teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
|
|
464
|
+
toolbarEditorPosition = _ref2.toolbarEditorPosition;
|
|
465
|
+
|
|
466
|
+
var _ref3 = errors || {},
|
|
467
|
+
promptError = _ref3.prompt,
|
|
468
|
+
rationaleError = _ref3.rationale,
|
|
469
|
+
responseAreasError = _ref3.responseAreasError,
|
|
470
|
+
responseAreaChoicesError = _ref3.responseAreaChoicesError,
|
|
471
|
+
teacherInstructionsError = _ref3.teacherInstructions;
|
|
472
|
+
|
|
473
|
+
var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
|
|
474
|
+
var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
|
|
475
|
+
|
|
476
|
+
var renderChoiceRationale = function renderChoiceRationale() {
|
|
477
|
+
return (Object.keys(choices) || []).map(function (key, index) {
|
|
478
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
479
|
+
key: key,
|
|
480
|
+
className: classes.rationaleChoices
|
|
481
|
+
}, /*#__PURE__*/_react["default"].createElement(_ExpansionPanel["default"], null, /*#__PURE__*/_react["default"].createElement(_ExpansionPanelSummary["default"], {
|
|
482
|
+
expandIcon: /*#__PURE__*/_react["default"].createElement(_ExpandMore["default"], null)
|
|
483
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
484
|
+
className: classes.text
|
|
485
|
+
}, "Rationale for response area #".concat(index + 1))), /*#__PURE__*/_react["default"].createElement(_ExpansionPanelDetails["default"], {
|
|
486
|
+
className: classes.panelDetails
|
|
487
|
+
}, (choices[key] || []).map(function (choice) {
|
|
488
|
+
return /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
489
|
+
key: choice.label,
|
|
490
|
+
label: /*#__PURE__*/_react["default"].createElement("span", {
|
|
491
|
+
className: classes.rationaleLabel,
|
|
492
|
+
dangerouslySetInnerHTML: {
|
|
493
|
+
__html: "".concat(rationale.label, " for ").concat(choice.label, " (").concat(choice.correct ? 'correct' : 'incorrect', ")")
|
|
494
|
+
}
|
|
495
|
+
}),
|
|
496
|
+
className: classes.promptHolder
|
|
497
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
498
|
+
className: classes.prompt,
|
|
499
|
+
markup: choice.rationale || '',
|
|
500
|
+
spellCheck: spellCheckEnabled,
|
|
501
|
+
onChange: function onChange(c) {
|
|
502
|
+
return _this2.onChoiceRationaleChanged(key, _objectSpread(_objectSpread({}, choice), {}, {
|
|
503
|
+
rationale: c
|
|
504
|
+
}));
|
|
505
|
+
},
|
|
506
|
+
imageSupport: imageSupport,
|
|
507
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
508
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
509
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
510
|
+
mathMlOptions: mathMlOptions
|
|
511
|
+
}));
|
|
512
|
+
}))));
|
|
513
|
+
});
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
var toolbarOpts = {
|
|
517
|
+
position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
|
|
518
|
+
};
|
|
519
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
520
|
+
var panelSettings = {
|
|
521
|
+
partialScoring: partialScoring.settings && toggle(partialScoring.label),
|
|
522
|
+
lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
|
|
523
|
+
'language.enabled': language.settings && toggle(language.label, true),
|
|
524
|
+
language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
|
|
525
|
+
};
|
|
526
|
+
var panelProperties = {
|
|
527
|
+
teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
|
|
528
|
+
rationaleEnabled: rationale.settings && toggle(rationale.label),
|
|
529
|
+
choiceRationaleEnabled: choiceRationale.settings && toggle(choiceRationale.label),
|
|
530
|
+
promptEnabled: prompt.settings && toggle(prompt.label),
|
|
531
|
+
spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
|
|
532
|
+
rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
|
|
533
|
+
};
|
|
534
|
+
return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
|
|
535
|
+
dimensions: contentDimensions,
|
|
536
|
+
hideSettings: settingsPanelDisabled,
|
|
537
|
+
settings: /*#__PURE__*/_react["default"].createElement(Panel, {
|
|
538
|
+
model: model,
|
|
539
|
+
configuration: configuration,
|
|
540
|
+
onChangeModel: function onChangeModel(model) {
|
|
541
|
+
return _this2.onModelChange(model);
|
|
542
|
+
},
|
|
543
|
+
onChangeConfiguration: function onChangeConfiguration(configuration) {
|
|
544
|
+
return onConfigurationChanged(configuration, true);
|
|
545
|
+
},
|
|
546
|
+
groups: {
|
|
547
|
+
Settings: panelSettings,
|
|
548
|
+
Properties: panelProperties
|
|
549
|
+
}
|
|
550
|
+
})
|
|
551
|
+
}, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
552
|
+
label: teacherInstructions.label,
|
|
553
|
+
className: classes.promptHolder
|
|
554
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
555
|
+
className: classes.prompt,
|
|
556
|
+
markup: model.teacherInstructions || '',
|
|
557
|
+
onChange: this.onTeacherInstructionsChanged,
|
|
558
|
+
imageSupport: imageSupport,
|
|
559
|
+
nonEmpty: false,
|
|
560
|
+
error: teacherInstructionsError,
|
|
561
|
+
toolbarOpts: toolbarOpts,
|
|
562
|
+
spellCheck: spellCheckEnabled,
|
|
563
|
+
maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
|
|
564
|
+
maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
|
|
565
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
566
|
+
languageCharactersProps: [{
|
|
567
|
+
language: 'spanish'
|
|
568
|
+
}, {
|
|
569
|
+
language: 'special'
|
|
570
|
+
}],
|
|
571
|
+
mathMlOptions: mathMlOptions
|
|
572
|
+
}), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
573
|
+
className: classes.errorText
|
|
574
|
+
}, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
575
|
+
label: prompt.label,
|
|
576
|
+
className: classes.promptHolder
|
|
577
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
578
|
+
className: classes.prompt,
|
|
579
|
+
markup: model.prompt,
|
|
580
|
+
onChange: this.onPromptChanged,
|
|
581
|
+
imageSupport: imageSupport,
|
|
582
|
+
nonEmpty: false,
|
|
583
|
+
disableUnderline: true,
|
|
584
|
+
error: promptError,
|
|
585
|
+
toolbarOpts: toolbarOpts,
|
|
586
|
+
spellCheck: spellCheckEnabled,
|
|
587
|
+
maxImageWidth: defaultImageMaxWidth,
|
|
588
|
+
maxImageHeight: defaultImageMaxHeight,
|
|
589
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
590
|
+
languageCharactersProps: [{
|
|
591
|
+
language: 'spanish'
|
|
592
|
+
}, {
|
|
593
|
+
language: 'special'
|
|
594
|
+
}],
|
|
595
|
+
mathMlOptions: mathMlOptions
|
|
596
|
+
}), promptError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
597
|
+
className: classes.errorText
|
|
598
|
+
}, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
|
|
599
|
+
className: classes.flexContainer
|
|
600
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
601
|
+
className: classes.text
|
|
602
|
+
}, "Define Template, Choices, and Correct Responses"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
603
|
+
classes: {
|
|
604
|
+
tooltip: classes.tooltip
|
|
605
|
+
},
|
|
606
|
+
disableFocusListener: true,
|
|
607
|
+
disableTouchListener: true,
|
|
608
|
+
placement: 'right',
|
|
609
|
+
title: validationMessage
|
|
610
|
+
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
611
|
+
fontSize: 'small',
|
|
612
|
+
color: 'primary'
|
|
613
|
+
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
614
|
+
className: classes.responseArea
|
|
615
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
616
|
+
activePlugins: _editableHtml.ALL_PLUGINS,
|
|
617
|
+
toolbarOpts: {
|
|
618
|
+
position: 'top'
|
|
619
|
+
},
|
|
620
|
+
responseAreaProps: {
|
|
621
|
+
type: 'inline-dropdown',
|
|
622
|
+
options: {
|
|
623
|
+
duplicates: true
|
|
624
|
+
},
|
|
625
|
+
maxResponseAreas: maxResponseAreas,
|
|
626
|
+
respAreaToolbar: function respAreaToolbar(node, value, onToolbarDone) {
|
|
627
|
+
var respAreaChoices = _this2.state.respAreaChoices;
|
|
628
|
+
return function () {
|
|
629
|
+
return /*#__PURE__*/_react["default"].createElement(_inlineDropdownToolbar["default"], {
|
|
630
|
+
onAddChoice: _this2.onAddChoice,
|
|
631
|
+
onCheck: _this2.onCheck,
|
|
632
|
+
onRemoveChoice: function onRemoveChoice(index) {
|
|
633
|
+
return _this2.onRemoveChoice(node.data.get('index'), index);
|
|
634
|
+
},
|
|
635
|
+
onSelectChoice: function onSelectChoice(index) {
|
|
636
|
+
return _this2.onSelectChoice(node.data.get('index'), index);
|
|
637
|
+
},
|
|
638
|
+
node: node,
|
|
639
|
+
value: value,
|
|
640
|
+
onToolbarDone: onToolbarDone,
|
|
641
|
+
choices: respAreaChoices[node.data.get('index')],
|
|
642
|
+
spellCheck: spellCheckEnabled,
|
|
643
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
644
|
+
mathMlOptions: mathMlOptions
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
spellCheck: spellCheckEnabled,
|
|
650
|
+
className: classes.markup,
|
|
651
|
+
markup: model.slateMarkup || '',
|
|
652
|
+
onChange: this.onChange,
|
|
653
|
+
imageSupport: imageSupport,
|
|
654
|
+
disableImageAlignmentButtons: true,
|
|
655
|
+
disabled: false,
|
|
656
|
+
highlightShape: false,
|
|
657
|
+
error: responseAreasError,
|
|
658
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
659
|
+
languageCharactersProps: [{
|
|
660
|
+
language: 'spanish'
|
|
661
|
+
}, {
|
|
662
|
+
language: 'special'
|
|
663
|
+
}],
|
|
664
|
+
mathMlOptions: mathMlOptions
|
|
665
|
+
}), responseAreasError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
666
|
+
className: classes.errorText
|
|
667
|
+
}, responseAreasError), responseAreaChoicesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
668
|
+
className: classes.errorText
|
|
669
|
+
}, responseAreaChoicesError)), choiceRationaleEnabled && renderChoiceRationale(), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
|
|
670
|
+
label: rationale.label,
|
|
671
|
+
className: classes.promptHolder
|
|
672
|
+
}, /*#__PURE__*/_react["default"].createElement(_editableHtml.EditableHtml, {
|
|
673
|
+
className: classes.prompt,
|
|
674
|
+
markup: model.rationale || '',
|
|
675
|
+
onChange: this.onRationaleChanged,
|
|
676
|
+
imageSupport: imageSupport,
|
|
677
|
+
error: rationaleError,
|
|
678
|
+
toolbarOpts: toolbarOpts,
|
|
679
|
+
spellCheck: spellCheckEnabled,
|
|
680
|
+
maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
|
|
681
|
+
maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
|
|
682
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
683
|
+
languageCharactersProps: [{
|
|
684
|
+
language: 'spanish'
|
|
685
|
+
}, {
|
|
686
|
+
language: 'special'
|
|
687
|
+
}],
|
|
688
|
+
mathMlOptions: mathMlOptions
|
|
689
|
+
}), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
690
|
+
className: classes.errorText
|
|
691
|
+
}, rationaleError)), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
692
|
+
open: warning.open,
|
|
693
|
+
title: "Warning",
|
|
694
|
+
text: warning.text,
|
|
695
|
+
onClose: warning.onClose,
|
|
696
|
+
onConfirm: warning.onConfirm
|
|
697
|
+
}));
|
|
698
|
+
}
|
|
699
|
+
}]);
|
|
700
|
+
return Main;
|
|
701
|
+
}(_react["default"].Component);
|
|
702
|
+
|
|
703
|
+
exports.Main = Main;
|
|
704
|
+
(0, _defineProperty2["default"])(Main, "propTypes", {
|
|
705
|
+
configuration: _propTypes["default"].object.isRequired,
|
|
706
|
+
model: _propTypes["default"].object.isRequired,
|
|
707
|
+
disableSidePanel: _propTypes["default"].bool,
|
|
708
|
+
onModelChanged: _propTypes["default"].func.isRequired,
|
|
709
|
+
onConfigurationChanged: _propTypes["default"].func.isRequired,
|
|
710
|
+
classes: _propTypes["default"].object.isRequired,
|
|
711
|
+
imageSupport: _propTypes["default"].shape({
|
|
712
|
+
add: _propTypes["default"].func.isRequired,
|
|
713
|
+
"delete": _propTypes["default"].func.isRequired
|
|
714
|
+
}),
|
|
715
|
+
uploadSoundSupport: _propTypes["default"].shape({
|
|
716
|
+
add: _propTypes["default"].func.isRequired,
|
|
717
|
+
"delete": _propTypes["default"].func.isRequired
|
|
718
|
+
})
|
|
719
|
+
});
|
|
720
|
+
var Styled = (0, _styles.withStyles)(styles)(Main);
|
|
721
|
+
var _default = Styled;
|
|
722
|
+
exports["default"] = _default;
|
|
723
|
+
//# sourceMappingURL=main.js.map
|