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