@pie-element/match 11.0.5-esm.0 → 11.1.0-next.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/configure/CHANGELOG.md +63 -0
  3. package/configure/lib/add-row.js +27 -73
  4. package/configure/lib/add-row.js.map +1 -1
  5. package/configure/lib/answer-config-block.js +262 -335
  6. package/configure/lib/answer-config-block.js.map +1 -1
  7. package/configure/lib/common.js +18 -33
  8. package/configure/lib/common.js.map +1 -1
  9. package/configure/lib/configure.js +330 -420
  10. package/configure/lib/configure.js.map +1 -1
  11. package/configure/lib/defaults.js +5 -4
  12. package/configure/lib/defaults.js.map +1 -1
  13. package/configure/lib/general-config-block.js +123 -190
  14. package/configure/lib/general-config-block.js.map +1 -1
  15. package/configure/lib/index.js +117 -190
  16. package/configure/lib/index.js.map +1 -1
  17. package/configure/lib/row.js +269 -377
  18. package/configure/lib/row.js.map +1 -1
  19. package/configure/lib/utils.js +4 -15
  20. package/configure/lib/utils.js.map +1 -1
  21. package/configure/package.json +15 -14
  22. package/controller/CHANGELOG.md +49 -0
  23. package/controller/lib/defaults.js +2 -3
  24. package/controller/lib/defaults.js.map +1 -1
  25. package/controller/lib/index.js +173 -301
  26. package/controller/lib/index.js.map +1 -1
  27. package/controller/package.json +6 -6
  28. package/lib/answer-grid.js +142 -242
  29. package/lib/answer-grid.js.map +1 -1
  30. package/lib/index.js +59 -108
  31. package/lib/index.js.map +1 -1
  32. package/lib/main.js +123 -191
  33. package/lib/main.js.map +1 -1
  34. package/package.json +18 -29
  35. package/esm/configure.js +0 -3936
  36. package/esm/configure.js.map +0 -1
  37. package/esm/controller.js +0 -428
  38. package/esm/controller.js.map +0 -1
  39. package/esm/element.js +0 -472
  40. package/esm/element.js.map +0 -1
@@ -1,500 +1,410 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = exports.Config = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
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.Config = void 0;
24
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
26
9
  var _utils = require("./utils");
27
-
28
10
  var _react = _interopRequireDefault(require("react"));
29
-
30
- var _styles = require("@material-ui/core/styles");
31
-
11
+ var _styles = require("@mui/material/styles");
32
12
  var _configUi = require("@pie-lib/config-ui");
33
-
34
- var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
35
-
36
- var _drag = require("@pie-lib/drag");
37
-
13
+ var _editableHtmlTipTap = _interopRequireDefault(require("@pie-lib/editable-html-tip-tap"));
38
14
  var _propTypes = _interopRequireDefault(require("prop-types"));
39
-
40
15
  var _debug = _interopRequireDefault(require("debug"));
41
-
42
16
  var _generalConfigBlock = _interopRequireDefault(require("./general-config-block"));
43
-
44
17
  var _answerConfigBlock = _interopRequireDefault(require("./answer-config-block"));
45
-
46
- 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; }
47
-
48
- 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; }
49
-
50
- 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); }; }
51
-
52
- 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; } }
53
-
54
- var log = (0, _debug["default"])('@pie-element:match:configure');
55
- var Panel = _configUi.settings.Panel,
56
- toggle = _configUi.settings.toggle,
57
- radio = _configUi.settings.radio,
58
- dropdown = _configUi.settings.dropdown;
59
-
60
- var styles = function styles(theme) {
61
- return {
62
- promptHolder: {
63
- width: '100%',
64
- paddingTop: theme.spacing.unit * 2,
65
- marginBottom: theme.spacing.unit * 2
66
- },
67
- errorText: {
68
- fontSize: theme.typography.fontSize - 2,
69
- color: theme.palette.error.main,
70
- paddingTop: theme.spacing.unit
71
- }
72
- };
73
- };
74
-
75
- var Configure = /*#__PURE__*/function (_React$Component) {
76
- (0, _inherits2["default"])(Configure, _React$Component);
77
-
78
- var _super = _createSuper(Configure);
79
-
80
- function Configure(props) {
81
- var _this;
82
-
83
- (0, _classCallCheck2["default"])(this, Configure);
84
- _this = _super.call(this, props);
85
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTabChange", function (event, value) {
86
- _this.setState({
18
+ const log = (0, _debug.default)('@pie-element:match:configure');
19
+ const {
20
+ Panel,
21
+ toggle,
22
+ radio,
23
+ dropdown
24
+ } = _configUi.settings;
25
+ const MainLayout = (0, _styles.styled)('div')(() => ({
26
+ '& .promptHolder': {
27
+ width: '100%'
28
+ }
29
+ }));
30
+ const PromptHolder = (0, _styles.styled)('div')(({
31
+ theme
32
+ }) => ({
33
+ width: '100%',
34
+ paddingTop: theme.spacing(2),
35
+ marginBottom: theme.spacing(2)
36
+ }));
37
+ const ErrorText = (0, _styles.styled)('div')(({
38
+ theme
39
+ }) => ({
40
+ fontSize: theme.typography.fontSize - 2,
41
+ color: theme.palette.error.main,
42
+ paddingTop: theme.spacing(1)
43
+ }));
44
+ class Configure extends _react.default.Component {
45
+ constructor(props) {
46
+ super(props);
47
+ (0, _defineProperty2.default)(this, "onTabChange", (event, value) => {
48
+ this.setState({
87
49
  activeTab: value
88
50
  });
89
51
  });
90
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeTabIndex", function (index) {
91
- _this.setState({
52
+ (0, _defineProperty2.default)(this, "onChangeTabIndex", index => {
53
+ this.setState({
92
54
  activeTab: index
93
55
  });
94
56
  });
95
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChange", function (model) {
96
- _this.props.onModelChanged(model);
57
+ (0, _defineProperty2.default)(this, "onChange", model => {
58
+ this.props.onModelChanged(model);
97
59
  });
98
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFeedbackChange", function (feedback) {
99
- var _this$props = _this.props,
100
- model = _this$props.model,
101
- onModelChanged = _this$props.onModelChanged;
60
+ (0, _defineProperty2.default)(this, "onFeedbackChange", feedback => {
61
+ const {
62
+ model,
63
+ onModelChanged
64
+ } = this.props;
102
65
  model.feedback = feedback;
103
66
  onModelChanged(model);
104
67
  });
105
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDeleteRow", function (rowIndex) {
106
- var model = _this.props.model;
107
-
108
- var newModel = _objectSpread({}, model);
109
-
68
+ (0, _defineProperty2.default)(this, "onDeleteRow", rowIndex => {
69
+ const {
70
+ model
71
+ } = this.props;
72
+ const newModel = {
73
+ ...model
74
+ };
110
75
  newModel.rows.splice(rowIndex, 1);
111
-
112
- _this.onChange(newModel);
76
+ this.onChange(newModel);
113
77
  });
114
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddRow", function () {
115
- var _this$props2 = _this.props,
116
- model = _this$props2.model,
117
- configuration = _this$props2.configuration;
118
-
119
- var newModel = _objectSpread({}, model);
120
-
121
- var _ref = configuration || {},
122
- maxQuestions = _ref.maxQuestions;
123
-
78
+ (0, _defineProperty2.default)(this, "onAddRow", () => {
79
+ const {
80
+ model,
81
+ configuration
82
+ } = this.props;
83
+ const newModel = {
84
+ ...model
85
+ };
86
+ const {
87
+ maxQuestions
88
+ } = configuration || {};
124
89
  if (maxQuestions && (newModel.rows || []).length >= maxQuestions) {
125
- _this.setState({
90
+ this.setState({
126
91
  dialog: {
127
92
  open: true,
128
- text: "There can be maximum ".concat(maxQuestions, " question row") + (maxQuestions > 1 ? 's' : '') + '.'
93
+ text: `There can be maximum ${maxQuestions} question row` + (maxQuestions > 1 ? 's' : '') + '.'
129
94
  }
130
95
  });
131
-
132
96
  return;
133
97
  }
134
-
135
98
  newModel.rows = newModel.rows.concat({
136
- id: _this.rowIdCounter + 1,
137
- title: "Question Text ".concat((newModel.rows || []).length + 1),
99
+ id: this.rowIdCounter + 1,
100
+ title: `Question Text ${(newModel.rows || []).length + 1}`,
138
101
  values: new Array(model.layout - 1).fill(false)
139
102
  });
140
- _this.rowIdCounter += 1;
141
-
142
- _this.onChange(newModel);
103
+ this.rowIdCounter += 1;
104
+ this.onChange(newModel);
143
105
  });
144
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLayoutChange", function (newLayout) {
145
- var model = _this.props.model;
146
- var oldLayout = model.layout;
147
-
148
- var newModel = _objectSpread({}, model);
149
-
106
+ (0, _defineProperty2.default)(this, "onLayoutChange", newLayout => {
107
+ const {
108
+ model
109
+ } = this.props;
110
+ const oldLayout = model.layout;
111
+ const newModel = {
112
+ ...model
113
+ };
150
114
  if (newLayout > oldLayout) {
151
- for (var i = 0; i < newLayout - oldLayout; i++) {
152
- newModel.headers.push("Column ".concat(newModel.headers.length + 1));
115
+ for (let i = 0; i < newLayout - oldLayout; i++) {
116
+ newModel.headers.push(`Column ${newModel.headers.length + 1}`);
153
117
  }
154
-
155
- newModel.rows.forEach(function (row) {
156
- for (var _i = 0; _i < newLayout - oldLayout; _i++) {
118
+ newModel.rows.forEach(row => {
119
+ for (let i = 0; i < newLayout - oldLayout; i++) {
157
120
  row.values.push(false);
158
121
  }
159
122
  });
160
123
  } else if (newLayout < oldLayout) {
161
124
  newModel.headers.splice(newLayout);
162
- newModel.rows.forEach(function (row) {
125
+ newModel.rows.forEach(row => {
163
126
  row.values.splice(newLayout - 1);
164
127
  });
165
128
  }
166
-
167
129
  newModel.layout = newLayout;
168
-
169
- _this.onChange(newModel);
130
+ this.onChange(newModel);
170
131
  });
171
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onResponseTypeChange", function (newChoiceMode) {
172
- var model = _this.props.model;
173
-
174
- var newModel = _objectSpread({}, model); // if we're switching to radio and we have more than one true, reset
175
-
132
+ (0, _defineProperty2.default)(this, "onResponseTypeChange", newChoiceMode => {
133
+ const {
134
+ model
135
+ } = this.props;
136
+ const newModel = {
137
+ ...model
138
+ };
176
139
 
140
+ // if we're switching to radio and we have more than one true, reset
177
141
  if (newChoiceMode === 'radio') {
178
- newModel.rows.forEach(function (row) {
179
- var trueCount = row.values.reduce(function (total, current) {
180
- return current === true ? total + 1 : total;
181
- });
182
-
142
+ newModel.rows.forEach(row => {
143
+ const trueCount = row.values.reduce((total, current) => current === true ? total + 1 : total);
183
144
  if (trueCount > 1) {
184
145
  row.values = new Array(model.layout - 1).fill(false);
185
146
  }
186
147
  });
187
148
  }
188
-
189
149
  newModel.choiceMode = newChoiceMode;
190
-
191
- _this.onChange(newModel);
150
+ this.onChange(newModel);
192
151
  });
193
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPartialScoringChange", function (partialScoring) {
194
- _this.props.model.partialScoring = partialScoring;
195
-
196
- _this.props.onModelChanged(_this.props.model);
152
+ (0, _defineProperty2.default)(this, "onPartialScoringChange", partialScoring => {
153
+ this.props.model.partialScoring = partialScoring;
154
+ this.props.onModelChanged(this.props.model);
197
155
  });
198
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
199
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
200
- prompt: prompt
201
- }));
156
+ (0, _defineProperty2.default)(this, "onPromptChanged", prompt => {
157
+ this.props.onModelChanged({
158
+ ...this.props.model,
159
+ prompt
160
+ });
202
161
  });
203
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onTeacherInstructionsChanged", function (teacherInstructions) {
204
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
205
- teacherInstructions: teacherInstructions
206
- }));
162
+ (0, _defineProperty2.default)(this, "onTeacherInstructionsChanged", teacherInstructions => {
163
+ this.props.onModelChanged({
164
+ ...this.props.model,
165
+ teacherInstructions
166
+ });
207
167
  });
208
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChanged", function (rationale) {
209
- _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
210
- rationale: rationale
211
- }));
168
+ (0, _defineProperty2.default)(this, "onRationaleChanged", rationale => {
169
+ this.props.onModelChanged({
170
+ ...this.props.model,
171
+ rationale
172
+ });
212
173
  });
213
- var maxId = 0;
214
-
174
+ let maxId = 0;
215
175
  if (props.model.rows && props.model.rows.length > 0) {
216
- maxId = Math.max.apply(Math, (0, _toConsumableArray2["default"])(props.model.rows.map(function (row) {
217
- return row.id;
218
- })));
176
+ maxId = Math.max(...props.model.rows.map(row => row.id));
219
177
  }
220
-
221
- _this.rowIdCounter = maxId + 1;
222
- _this.state = {
178
+ this.rowIdCounter = maxId + 1;
179
+ this.state = {
223
180
  activeTab: 0,
224
181
  dialog: {
225
182
  open: false,
226
183
  text: ''
227
184
  }
228
185
  };
229
- return _this;
230
186
  }
231
-
232
- (0, _createClass2["default"])(Configure, [{
233
- key: "componentDidMount",
234
- value: function componentDidMount() {
235
- var _this$validateRowsID = this.validateRowsID(this.props.model.rows),
236
- updatedRows = _this$validateRowsID.updatedRows,
237
- wasChanged = _this$validateRowsID.wasChanged;
238
-
239
- if (wasChanged) {
240
- var newModel = _objectSpread(_objectSpread({}, this.props.model), {}, {
241
- rows: updatedRows
242
- });
243
-
244
- this.props.onModelChanged(newModel);
245
- }
246
- }
247
- }, {
248
- key: "validateRowsID",
249
- value: function validateRowsID(rows) {
250
- var wasChanged = false;
251
- var updatedRows = (rows || []).map(function (row, index) {
252
- if (row.id !== index + 1) {
253
- wasChanged = true;
254
- return _objectSpread(_objectSpread({}, row), {}, {
255
- id: index + 1
256
- });
257
- }
258
-
259
- return row;
260
- });
261
- return {
262
- updatedRows: updatedRows,
263
- wasChanged: wasChanged
187
+ componentDidMount() {
188
+ const {
189
+ updatedRows,
190
+ wasChanged
191
+ } = this.validateRowsID(this.props.model.rows);
192
+ if (wasChanged) {
193
+ const newModel = {
194
+ ...this.props.model,
195
+ rows: updatedRows
264
196
  };
197
+ this.props.onModelChanged(newModel);
265
198
  }
266
- }, {
267
- key: "render",
268
- value: function render() {
269
- var _this2 = this;
270
-
271
- var _this$props3 = this.props,
272
- classes = _this$props3.classes,
273
- model = _this$props3.model,
274
- imageSupport = _this$props3.imageSupport,
275
- onModelChanged = _this$props3.onModelChanged,
276
- configuration = _this$props3.configuration,
277
- onConfigurationChanged = _this$props3.onConfigurationChanged,
278
- uploadSoundSupport = _this$props3.uploadSoundSupport;
279
-
280
- var _ref2 = configuration || {},
281
- _ref2$baseInputConfig = _ref2.baseInputConfiguration,
282
- baseInputConfiguration = _ref2$baseInputConfig === void 0 ? {} : _ref2$baseInputConfig,
283
- _ref2$contentDimensio = _ref2.contentDimensions,
284
- contentDimensions = _ref2$contentDimensio === void 0 ? {} : _ref2$contentDimensio,
285
- _ref2$feedback = _ref2.feedback,
286
- feedback = _ref2$feedback === void 0 ? {} : _ref2$feedback,
287
- _ref2$lockChoiceOrder = _ref2.lockChoiceOrder,
288
- lockChoiceOrder = _ref2$lockChoiceOrder === void 0 ? {} : _ref2$lockChoiceOrder,
289
- _ref2$maxImageWidth = _ref2.maxImageWidth,
290
- maxImageWidth = _ref2$maxImageWidth === void 0 ? {} : _ref2$maxImageWidth,
291
- _ref2$maxImageHeight = _ref2.maxImageHeight,
292
- maxImageHeight = _ref2$maxImageHeight === void 0 ? {} : _ref2$maxImageHeight,
293
- _ref2$partialScoring = _ref2.partialScoring,
294
- partialScoring = _ref2$partialScoring === void 0 ? {} : _ref2$partialScoring,
295
- _ref2$prompt = _ref2.prompt,
296
- prompt = _ref2$prompt === void 0 ? {} : _ref2$prompt,
297
- _ref2$rationale = _ref2.rationale,
298
- rationale = _ref2$rationale === void 0 ? {} : _ref2$rationale,
299
- settingsPanelDisabled = _ref2.settingsPanelDisabled,
300
- _ref2$scoringType = _ref2.scoringType,
301
- scoringType = _ref2$scoringType === void 0 ? {} : _ref2$scoringType,
302
- _ref2$spellCheck = _ref2.spellCheck,
303
- spellCheck = _ref2$spellCheck === void 0 ? {} : _ref2$spellCheck,
304
- _ref2$studentInstruct = _ref2.studentInstructions,
305
- studentInstructions = _ref2$studentInstruct === void 0 ? {} : _ref2$studentInstruct,
306
- _ref2$teacherInstruct = _ref2.teacherInstructions,
307
- teacherInstructions = _ref2$teacherInstruct === void 0 ? {} : _ref2$teacherInstruct,
308
- _ref2$withRubric = _ref2.withRubric,
309
- withRubric = _ref2$withRubric === void 0 ? {} : _ref2$withRubric,
310
- _ref2$language = _ref2.language,
311
- language = _ref2$language === void 0 ? {} : _ref2$language,
312
- _ref2$languageChoices = _ref2.languageChoices,
313
- languageChoices = _ref2$languageChoices === void 0 ? {} : _ref2$languageChoices;
314
-
315
- var _ref3 = model || {},
316
- errors = _ref3.errors,
317
- extraCSSRules = _ref3.extraCSSRules,
318
- feedbackEnabled = _ref3.feedbackEnabled,
319
- promptEnabled = _ref3.promptEnabled,
320
- rationaleEnabled = _ref3.rationaleEnabled,
321
- spellCheckEnabled = _ref3.spellCheckEnabled,
322
- teacherInstructionsEnabled = _ref3.teacherInstructionsEnabled,
323
- toolbarEditorPosition = _ref3.toolbarEditorPosition;
324
-
325
- var _ref4 = errors || {},
326
- promptError = _ref4.prompt,
327
- rationaleError = _ref4.rationale,
328
- teacherInstructionsError = _ref4.teacherInstructions;
329
-
330
- var dialog = this.state.dialog;
331
- var toolbarOpts = {
332
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
333
- };
334
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
335
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
336
- var panelSettings = {
337
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
338
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
339
- feedbackEnabled: feedback.settings && toggle(feedback.label),
340
- 'language.enabled': language.settings && toggle(language.label, true),
341
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
342
- };
343
- var panelProperties = {
344
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
345
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
346
- promptEnabled: prompt.settings && toggle(prompt.label),
347
- rationaleEnabled: rationale.settings && toggle(rationale.label),
348
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
349
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
350
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
351
- };
352
- log('[render] model', model);
353
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
354
- extraCSSRules: extraCSSRules,
355
- dimensions: contentDimensions,
356
- hideSettings: settingsPanelDisabled,
357
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
358
- model: model,
359
- configuration: configuration,
360
- onChangeModel: function onChangeModel(model) {
361
- return onModelChanged(model);
362
- },
363
- onChangeConfiguration: function onChangeConfiguration(config) {
364
- return onConfigurationChanged(config);
365
- },
366
- groups: {
367
- Settings: panelSettings,
368
- Properties: panelProperties
369
- }
370
- })
371
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
372
- label: teacherInstructions.label,
373
- className: classes.promptHolder
374
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
375
- className: classes.prompt,
376
- markup: model.teacherInstructions || '',
377
- onChange: this.onTeacherInstructionsChanged,
378
- imageSupport: imageSupport,
379
- error: teacherInstructionsError,
380
- nonEmpty: false,
381
- toolbarOpts: toolbarOpts,
382
- pluginProps: (0, _utils.getPluginProps)(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration, baseInputConfiguration),
383
- spellCheck: spellCheckEnabled,
384
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
385
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
386
- uploadSoundSupport: uploadSoundSupport,
387
- languageCharactersProps: [{
388
- language: 'spanish'
389
- }, {
390
- language: 'special'
391
- }]
392
- }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
393
- className: classes.errorText
394
- }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
395
- label: prompt.label,
396
- className: classes.promptHolder
397
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
398
- className: classes.prompt,
399
- markup: model.prompt,
400
- onChange: this.onPromptChanged,
401
- imageSupport: imageSupport,
402
- error: promptError,
403
- nonEmpty: false,
404
- disableUnderline: true,
405
- toolbarOpts: toolbarOpts,
406
- pluginProps: (0, _utils.getPluginProps)(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
407
- spellCheck: spellCheckEnabled,
408
- maxImageWidth: maxImageWidth && maxImageWidth.prompt,
409
- maxImageHeight: maxImageHeight && maxImageHeight.prompt,
410
- uploadSoundSupport: uploadSoundSupport,
411
- languageCharactersProps: [{
412
- language: 'spanish'
413
- }, {
414
- language: 'special'
415
- }]
416
- }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
417
- className: classes.errorText
418
- }, promptError)), /*#__PURE__*/_react["default"].createElement(_generalConfigBlock["default"], {
419
- model: model,
420
- configuration: configuration,
421
- onResponseTypeChange: this.onResponseTypeChange,
422
- onLayoutChange: this.onLayoutChange
423
- }), /*#__PURE__*/_react["default"].createElement(_answerConfigBlock["default"], {
199
+ }
200
+ validateRowsID(rows) {
201
+ let wasChanged = false;
202
+ const updatedRows = (rows || []).map((row, index) => {
203
+ if (row.id !== index + 1) {
204
+ wasChanged = true;
205
+ return {
206
+ ...row,
207
+ id: index + 1
208
+ };
209
+ }
210
+ return row;
211
+ });
212
+ return {
213
+ updatedRows,
214
+ wasChanged
215
+ };
216
+ }
217
+ render() {
218
+ const {
219
+ model,
220
+ imageSupport,
221
+ onModelChanged,
222
+ configuration,
223
+ onConfigurationChanged,
224
+ uploadSoundSupport
225
+ } = this.props;
226
+ const {
227
+ baseInputConfiguration = {},
228
+ contentDimensions = {},
229
+ feedback = {},
230
+ lockChoiceOrder = {},
231
+ maxImageWidth = {},
232
+ maxImageHeight = {},
233
+ partialScoring = {},
234
+ prompt = {},
235
+ rationale = {},
236
+ settingsPanelDisabled,
237
+ scoringType = {},
238
+ spellCheck = {},
239
+ studentInstructions = {},
240
+ teacherInstructions = {},
241
+ withRubric = {},
242
+ language = {},
243
+ languageChoices = {}
244
+ } = configuration || {};
245
+ const {
246
+ errors,
247
+ extraCSSRules,
248
+ feedbackEnabled,
249
+ promptEnabled,
250
+ rationaleEnabled,
251
+ spellCheckEnabled,
252
+ teacherInstructionsEnabled,
253
+ toolbarEditorPosition
254
+ } = model || {};
255
+ const {
256
+ prompt: promptError,
257
+ rationale: rationaleError,
258
+ teacherInstructions: teacherInstructionsError
259
+ } = errors || {};
260
+ const {
261
+ dialog
262
+ } = this.state;
263
+ const toolbarOpts = {
264
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
265
+ };
266
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
267
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
268
+ const panelSettings = {
269
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
270
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
271
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
272
+ 'language.enabled': language.settings && toggle(language.label, true),
273
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
274
+ };
275
+ const panelProperties = {
276
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
277
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
278
+ promptEnabled: prompt.settings && toggle(prompt.label),
279
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
280
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
281
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
282
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
283
+ };
284
+ log('[render] model', model);
285
+ return /*#__PURE__*/_react.default.createElement(MainLayout, null, /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
286
+ extraCSSRules: extraCSSRules,
287
+ dimensions: contentDimensions,
288
+ hideSettings: settingsPanelDisabled,
289
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
424
290
  model: model,
425
291
  configuration: configuration,
426
- imageSupport: imageSupport,
427
- onChange: this.onChange,
428
- onAddRow: this.onAddRow,
429
- onDeleteRow: this.onDeleteRow,
430
- toolbarOpts: toolbarOpts,
431
- spellCheck: spellCheckEnabled,
432
- uploadSoundSupport: uploadSoundSupport
433
- }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
434
- label: rationale.label,
435
- className: classes.promptHolder
436
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
437
- className: classes.prompt,
438
- markup: model.rationale || '',
439
- onChange: this.onRationaleChanged,
440
- imageSupport: imageSupport,
441
- error: rationaleError,
442
- toolbarOpts: toolbarOpts,
443
- pluginProps: (0, _utils.getPluginProps)(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration, baseInputConfiguration),
444
- spellCheck: spellCheckEnabled,
445
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
446
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
447
- uploadSoundSupport: uploadSoundSupport,
448
- languageCharactersProps: [{
449
- language: 'spanish'
450
- }, {
451
- language: 'special'
452
- }]
453
- }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
454
- className: classes.errorText
455
- }, rationaleError)), feedbackEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.FeedbackConfig, {
456
- feedback: model.feedback,
457
- onChange: this.onFeedbackChange,
458
- toolbarOpts: toolbarOpts
459
- }), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
460
- open: dialog.open,
461
- title: "Warning",
462
- text: dialog.text,
463
- onConfirm: function onConfirm() {
464
- return _this2.setState({
465
- dialog: {
466
- open: false
467
- }
468
- });
292
+ onChangeModel: model => onModelChanged(model),
293
+ onChangeConfiguration: config => onConfigurationChanged(config),
294
+ groups: {
295
+ Settings: panelSettings,
296
+ Properties: panelProperties
469
297
  }
470
- }));
471
- }
472
- }]);
473
- return Configure;
474
- }(_react["default"].Component);
475
-
476
- (0, _defineProperty2["default"])(Configure, "propTypes", {
477
- onModelChanged: _propTypes["default"].func,
478
- onConfigurationChanged: _propTypes["default"].func,
479
- classes: _propTypes["default"].object,
480
- model: _propTypes["default"].object.isRequired,
481
- configuration: _propTypes["default"].object.isRequired,
482
- imageSupport: _propTypes["default"].shape({
483
- add: _propTypes["default"].func.isRequired,
484
- "delete": _propTypes["default"].func.isRequired
298
+ })
299
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(_configUi.InputContainer, {
300
+ label: teacherInstructions.label,
301
+ className: "promptHolder"
302
+ }, /*#__PURE__*/_react.default.createElement(PromptHolder, null, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
303
+ className: "prompt",
304
+ markup: model.teacherInstructions || '',
305
+ onChange: this.onTeacherInstructionsChanged,
306
+ imageSupport: imageSupport,
307
+ error: teacherInstructionsError,
308
+ nonEmpty: false,
309
+ toolbarOpts: toolbarOpts,
310
+ pluginProps: (0, _utils.getPluginProps)(teacherInstructions?.inputConfiguration, baseInputConfiguration),
311
+ spellCheck: spellCheckEnabled,
312
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
313
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
314
+ uploadSoundSupport: uploadSoundSupport,
315
+ languageCharactersProps: [{
316
+ language: 'spanish'
317
+ }, {
318
+ language: 'special'
319
+ }]
320
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError))), promptEnabled && /*#__PURE__*/_react.default.createElement(_configUi.InputContainer, {
321
+ label: prompt.label,
322
+ className: "promptHolder"
323
+ }, /*#__PURE__*/_react.default.createElement(PromptHolder, null, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
324
+ className: "prompt",
325
+ markup: model.prompt,
326
+ onChange: this.onPromptChanged,
327
+ imageSupport: imageSupport,
328
+ error: promptError,
329
+ nonEmpty: false,
330
+ disableUnderline: true,
331
+ toolbarOpts: toolbarOpts,
332
+ pluginProps: (0, _utils.getPluginProps)(prompt?.inputConfiguration, baseInputConfiguration),
333
+ spellCheck: spellCheckEnabled,
334
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
335
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
336
+ uploadSoundSupport: uploadSoundSupport,
337
+ languageCharactersProps: [{
338
+ language: 'spanish'
339
+ }, {
340
+ language: 'special'
341
+ }]
342
+ }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError))), /*#__PURE__*/_react.default.createElement(_generalConfigBlock.default, {
343
+ model: model,
344
+ configuration: configuration,
345
+ onResponseTypeChange: this.onResponseTypeChange,
346
+ onLayoutChange: this.onLayoutChange
347
+ }), /*#__PURE__*/_react.default.createElement(_answerConfigBlock.default, {
348
+ model: model,
349
+ configuration: configuration,
350
+ imageSupport: imageSupport,
351
+ onChange: this.onChange,
352
+ onAddRow: this.onAddRow,
353
+ onDeleteRow: this.onDeleteRow,
354
+ toolbarOpts: toolbarOpts,
355
+ spellCheck: spellCheckEnabled,
356
+ uploadSoundSupport: uploadSoundSupport
357
+ }), rationaleEnabled && /*#__PURE__*/_react.default.createElement(_configUi.InputContainer, {
358
+ label: rationale.label,
359
+ className: "promptHolder"
360
+ }, /*#__PURE__*/_react.default.createElement(PromptHolder, null, /*#__PURE__*/_react.default.createElement(_editableHtmlTipTap.default, {
361
+ className: "prompt",
362
+ markup: model.rationale || '',
363
+ onChange: this.onRationaleChanged,
364
+ imageSupport: imageSupport,
365
+ error: rationaleError,
366
+ toolbarOpts: toolbarOpts,
367
+ pluginProps: (0, _utils.getPluginProps)(rationale?.inputConfiguration, baseInputConfiguration),
368
+ spellCheck: spellCheckEnabled,
369
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
370
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
371
+ uploadSoundSupport: uploadSoundSupport,
372
+ languageCharactersProps: [{
373
+ language: 'spanish'
374
+ }, {
375
+ language: 'special'
376
+ }]
377
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError))), feedbackEnabled && /*#__PURE__*/_react.default.createElement(_configUi.FeedbackConfig, {
378
+ feedback: model.feedback,
379
+ onChange: this.onFeedbackChange,
380
+ toolbarOpts: toolbarOpts
381
+ }), /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
382
+ open: dialog.open,
383
+ title: "Warning",
384
+ text: dialog.text,
385
+ onConfirm: () => this.setState({
386
+ dialog: {
387
+ open: false
388
+ }
389
+ })
390
+ })));
391
+ }
392
+ }
393
+ (0, _defineProperty2.default)(Configure, "propTypes", {
394
+ onModelChanged: _propTypes.default.func,
395
+ onConfigurationChanged: _propTypes.default.func,
396
+ model: _propTypes.default.object.isRequired,
397
+ configuration: _propTypes.default.object.isRequired,
398
+ imageSupport: _propTypes.default.shape({
399
+ add: _propTypes.default.func.isRequired,
400
+ delete: _propTypes.default.func.isRequired
485
401
  }),
486
- uploadSoundSupport: _propTypes["default"].shape({
487
- add: _propTypes["default"].func.isRequired,
488
- "delete": _propTypes["default"].func.isRequired
402
+ uploadSoundSupport: _propTypes.default.shape({
403
+ add: _propTypes.default.func.isRequired,
404
+ delete: _propTypes.default.func.isRequired
489
405
  })
490
406
  });
491
- (0, _defineProperty2["default"])(Configure, "defaultProps", {
492
- classes: {}
493
- });
494
- var Config = Configure;
495
- exports.Config = Config;
496
-
497
- var _default = (0, _drag.withDragContext)((0, _styles.withStyles)(styles)(Configure));
498
-
499
- exports["default"] = _default;
407
+ (0, _defineProperty2.default)(Configure, "defaultProps", {});
408
+ const Config = exports.Config = Configure;
409
+ var _default = exports.default = Configure;
500
410
  //# sourceMappingURL=configure.js.map