@pie-element/categorize 11.3.4-next.0 → 12.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.
Files changed (63) hide show
  1. package/configure/lib/defaults.js +2 -5
  2. package/configure/lib/defaults.js.map +1 -1
  3. package/configure/lib/design/builder.js +15 -33
  4. package/configure/lib/design/builder.js.map +1 -1
  5. package/configure/lib/design/buttons.js +41 -95
  6. package/configure/lib/design/buttons.js.map +1 -1
  7. package/configure/lib/design/categories/RowLabel.js +32 -45
  8. package/configure/lib/design/categories/RowLabel.js.map +1 -1
  9. package/configure/lib/design/categories/alternateResponses.js +96 -251
  10. package/configure/lib/design/categories/alternateResponses.js.map +1 -1
  11. package/configure/lib/design/categories/category.js +135 -208
  12. package/configure/lib/design/categories/category.js.map +1 -1
  13. package/configure/lib/design/categories/choice-preview.js +61 -126
  14. package/configure/lib/design/categories/choice-preview.js.map +1 -1
  15. package/configure/lib/design/categories/droppable-placeholder.js +73 -165
  16. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
  17. package/configure/lib/design/categories/index.js +195 -384
  18. package/configure/lib/design/categories/index.js.map +1 -1
  19. package/configure/lib/design/choices/choice.js +155 -264
  20. package/configure/lib/design/choices/choice.js.map +1 -1
  21. package/configure/lib/design/choices/config.js +42 -98
  22. package/configure/lib/design/choices/config.js.map +1 -1
  23. package/configure/lib/design/choices/index.js +148 -236
  24. package/configure/lib/design/choices/index.js.map +1 -1
  25. package/configure/lib/design/header.js +57 -111
  26. package/configure/lib/design/header.js.map +1 -1
  27. package/configure/lib/design/index.js +631 -476
  28. package/configure/lib/design/index.js.map +1 -1
  29. package/configure/lib/design/input-header.js +93 -149
  30. package/configure/lib/design/input-header.js.map +1 -1
  31. package/configure/lib/design/utils.js +4 -15
  32. package/configure/lib/design/utils.js.map +1 -1
  33. package/configure/lib/index.js +120 -183
  34. package/configure/lib/index.js.map +1 -1
  35. package/configure/lib/main.js +30 -74
  36. package/configure/lib/main.js.map +1 -1
  37. package/configure/lib/utils.js +22 -32
  38. package/configure/lib/utils.js.map +1 -1
  39. package/configure/package.json +15 -15
  40. package/controller/lib/defaults.js +2 -5
  41. package/controller/lib/defaults.js.map +1 -1
  42. package/controller/lib/index.js +237 -318
  43. package/controller/lib/index.js.map +1 -1
  44. package/controller/lib/utils.js +28 -65
  45. package/controller/lib/utils.js.map +1 -1
  46. package/controller/package.json +5 -5
  47. package/lib/categorize/categories.js +106 -164
  48. package/lib/categorize/categories.js.map +1 -1
  49. package/lib/categorize/category.js +73 -123
  50. package/lib/categorize/category.js.map +1 -1
  51. package/lib/categorize/choice.js +118 -245
  52. package/lib/categorize/choice.js.map +1 -1
  53. package/lib/categorize/choices.js +66 -131
  54. package/lib/categorize/choices.js.map +1 -1
  55. package/lib/categorize/droppable-placeholder.js +46 -103
  56. package/lib/categorize/droppable-placeholder.js.map +1 -1
  57. package/lib/categorize/grid-content.js +39 -87
  58. package/lib/categorize/grid-content.js.map +1 -1
  59. package/lib/categorize/index.js +341 -317
  60. package/lib/categorize/index.js.map +1 -1
  61. package/lib/index.js +285 -306
  62. package/lib/index.js.map +1 -1
  63. package/package.json +16 -14
@@ -1,545 +1,700 @@
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.Design = 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.Design = 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
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
- var _styles = require("@material-ui/core/styles");
33
-
12
+ var _styles = require("@mui/material/styles");
13
+ var _core = require("@dnd-kit/core");
34
14
  var _configUi = require("@pie-lib/config-ui");
35
-
36
15
  var _categorize = require("@pie-lib/categorize");
37
-
38
16
  var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
39
-
40
17
  var _drag = require("@pie-lib/drag");
41
-
18
+ var _mathRendering = require("@pie-lib/math-rendering");
42
19
  var _categories = _interopRequireDefault(require("./categories"));
43
-
44
20
  var _alternateResponses = _interopRequireDefault(require("./categories/alternateResponses"));
45
-
46
21
  var _choices = _interopRequireDefault(require("./choices"));
47
-
22
+ var _choice = _interopRequireDefault(require("./choices/choice"));
23
+ var _choicePreview = _interopRequireDefault(require("./categories/choice-preview"));
48
24
  var _builder = require("./builder");
49
-
50
25
  var _header = _interopRequireDefault(require("./header"));
51
-
52
26
  var _utils2 = require("../utils");
53
-
54
27
  var _translator = _interopRequireDefault(require("@pie-lib/translator"));
28
+ const {
29
+ translator
30
+ } = _translator.default;
31
+ const {
32
+ dropdown,
33
+ Panel,
34
+ toggle,
35
+ radio,
36
+ numberField
37
+ } = _configUi.settings;
38
+ const {
39
+ Provider: IdProvider
40
+ } = _drag.uid;
41
+
42
+ // Simple wrapper to render math in DragOverlay portal
43
+ class DragPreviewWrapper extends _react.default.Component {
44
+ constructor(...args) {
45
+ super(...args);
46
+ (0, _defineProperty2.default)(this, "containerRef", /*#__PURE__*/_react.default.createRef());
47
+ }
48
+ componentDidMount() {
49
+ if (this.containerRef.current) {
50
+ setTimeout(() => (0, _mathRendering.renderMath)(this.containerRef.current), 0);
51
+ }
52
+ }
53
+ render() {
54
+ return /*#__PURE__*/_react.default.createElement("div", {
55
+ ref: this.containerRef
56
+ }, this.props.children);
57
+ }
58
+ }
59
+ const StyledHeader = (0, _styles.styled)(_header.default)(({
60
+ theme
61
+ }) => ({
62
+ marginBottom: theme.spacing(2)
63
+ }));
64
+ const StyledInputContainer = (0, _styles.styled)(_configUi.InputContainer)(({
65
+ theme
66
+ }) => ({
67
+ width: '100%',
68
+ paddingTop: theme.spacing(2),
69
+ marginBottom: theme.spacing(2)
70
+ }));
71
+ const ErrorText = (0, _styles.styled)('div')(({
72
+ theme
73
+ }) => ({
74
+ fontSize: theme.typography.fontSize - 2,
75
+ color: theme.palette.error.main,
76
+ paddingTop: theme.spacing(1)
77
+ }));
78
+ class Design extends _react.default.Component {
79
+ constructor(_props) {
80
+ super(_props);
81
+ (0, _defineProperty2.default)(this, "updateModel", props => {
82
+ const {
83
+ model,
84
+ onChange
85
+ } = this.props;
86
+ const updatedModel = {
87
+ ...model,
88
+ ...props
89
+ };
90
+ updatedModel.choices = updatedModel.choices.map(c => ({
91
+ ...c,
92
+ categoryCount: this.checkAllowMultiplePlacements(updatedModel.allowMultiplePlacementsEnabled, c)
93
+ }));
55
94
 
56
- 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; }
57
-
58
- 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; }
59
-
60
- 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); }; }
61
-
62
- 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; } }
63
-
64
- var translator = _translator["default"].translator;
65
- var dropdown = _configUi.settings.dropdown,
66
- Panel = _configUi.settings.Panel,
67
- toggle = _configUi.settings.toggle,
68
- radio = _configUi.settings.radio,
69
- numberField = _configUi.settings.numberField;
70
- var IdProvider = _drag.uid.Provider;
71
-
72
- var Design = /*#__PURE__*/function (_React$Component) {
73
- (0, _inherits2["default"])(Design, _React$Component);
74
-
75
- var _super = _createSuper(Design);
76
-
77
- function Design(_props) {
78
- var _this;
79
-
80
- (0, _classCallCheck2["default"])(this, Design);
81
- _this = _super.call(this, _props);
82
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateModel", function (props) {
83
- var _this$props = _this.props,
84
- model = _this$props.model,
85
- onChange = _this$props.onChange;
86
-
87
- var updatedModel = _objectSpread(_objectSpread({}, model), props);
88
-
89
- updatedModel.choices = updatedModel.choices.map(function (c) {
90
- return _objectSpread(_objectSpread({}, c), {}, {
91
- categoryCount: _this.checkAllowMultiplePlacements(updatedModel.allowMultiplePlacementsEnabled, c)
92
- });
93
- }); //Ensure that there are no extra choices in correctResponse, if the user has decided that only one choice may be used.
94
-
95
- updatedModel.correctResponse = (0, _categorize.ensureNoExtraChoicesInAnswer)(updatedModel.correctResponse || [], updatedModel.choices); //Ensure that there are no extra choices in alternate responses, if the user has decided that only one choice may be used.
95
+ //Ensure that there are no extra choices in correctResponse, if the user has decided that only one choice may be used.
96
+ updatedModel.correctResponse = (0, _categorize.ensureNoExtraChoicesInAnswer)(updatedModel.correctResponse || [], updatedModel.choices);
96
97
 
97
- updatedModel.correctResponse = (0, _categorize.ensureNoExtraChoicesInAlternate)(updatedModel.correctResponse || [], updatedModel.choices); //clean categories
98
+ //Ensure that there are no extra choices in alternate responses, if the user has decided that only one choice may be used.
99
+ updatedModel.correctResponse = (0, _categorize.ensureNoExtraChoicesInAlternate)(updatedModel.correctResponse || [], updatedModel.choices);
98
100
 
99
- updatedModel.categories = updatedModel.categories.map(function (c) {
100
- return {
101
- id: c.id,
102
- label: c.label
103
- };
104
- });
105
- updatedModel.choices = updatedModel.choices.map(function (h) {
106
- return {
107
- id: h.id,
108
- content: h.content,
109
- categoryCount: h.categoryCount
110
- };
111
- }); // ensure that maxChoicesPerCategory is reset if author switch back the corresponding switch (allowMaxChoicesPerCategory)
101
+ //clean categories
102
+ updatedModel.categories = updatedModel.categories.map(c => ({
103
+ id: c.id,
104
+ label: c.label
105
+ }));
106
+ updatedModel.choices = updatedModel.choices.map(h => ({
107
+ id: h.id,
108
+ content: h.content,
109
+ categoryCount: h.categoryCount
110
+ }));
112
111
 
112
+ // ensure that maxChoicesPerCategory is reset if author switch back the corresponding switch (allowMaxChoicesPerCategory)
113
113
  updatedModel.maxChoicesPerCategory = updatedModel.allowMaxChoicesPerCategory ? updatedModel.maxChoicesPerCategory : 0;
114
114
  onChange(updatedModel);
115
115
  });
116
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeRationale", function (rationale) {
117
- var _this$props2 = _this.props,
118
- model = _this$props2.model,
119
- onChange = _this$props2.onChange;
120
- onChange(_objectSpread(_objectSpread({}, model), {}, {
121
- rationale: rationale
122
- }));
123
- });
124
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeTeacherInstructions", function (teacherInstructions) {
125
- var _this$props3 = _this.props,
126
- model = _this$props3.model,
127
- onChange = _this$props3.onChange;
128
- onChange(_objectSpread(_objectSpread({}, model), {}, {
129
- teacherInstructions: teacherInstructions
130
- }));
116
+ (0, _defineProperty2.default)(this, "changeRationale", rationale => {
117
+ const {
118
+ model,
119
+ onChange
120
+ } = this.props;
121
+ onChange({
122
+ ...model,
123
+ rationale
124
+ });
131
125
  });
132
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeFeedback", function (feedback) {
133
- _this.updateModel({
134
- feedback: feedback
126
+ (0, _defineProperty2.default)(this, "changeTeacherInstructions", teacherInstructions => {
127
+ const {
128
+ model,
129
+ onChange
130
+ } = this.props;
131
+ onChange({
132
+ ...model,
133
+ teacherInstructions
135
134
  });
136
135
  });
137
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddAlternateResponse", function () {
138
- var correctResponse = _this.props.model.correctResponse;
139
-
140
- _this.updateModel({
141
- correctResponse: (correctResponse || []).map(function (cr) {
142
- return _objectSpread(_objectSpread({}, cr), {}, {
143
- alternateResponses: [].concat((0, _toConsumableArray2["default"])(cr.alternateResponses || []), [[]])
144
- });
145
- })
136
+ (0, _defineProperty2.default)(this, "changeFeedback", feedback => {
137
+ this.updateModel({
138
+ feedback
146
139
  });
147
140
  });
148
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onPromptChanged", function (prompt) {
149
- return _this.updateModel({
150
- prompt: prompt
141
+ (0, _defineProperty2.default)(this, "onAddAlternateResponse", () => {
142
+ const {
143
+ model: {
144
+ correctResponse
145
+ }
146
+ } = this.props;
147
+ this.updateModel({
148
+ correctResponse: (correctResponse || []).map(cr => ({
149
+ ...cr,
150
+ alternateResponses: [...(cr.alternateResponses || []), []]
151
+ }))
151
152
  });
152
153
  });
153
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRemoveAlternateResponse", function (index) {
154
- var correctResponse = _this.props.model.correctResponse;
155
-
156
- _this.updateModel({
157
- correctResponse: (correctResponse || []).map(function (cr) {
158
- return _objectSpread(_objectSpread({}, cr), {}, {
159
- alternateResponses: (cr.alternateResponses || []).filter(function (alt, altIndex) {
160
- return altIndex !== index;
161
- })
162
- });
163
- })
154
+ (0, _defineProperty2.default)(this, "onPromptChanged", prompt => this.updateModel({
155
+ prompt
156
+ }));
157
+ (0, _defineProperty2.default)(this, "onRemoveAlternateResponse", index => {
158
+ const {
159
+ model: {
160
+ correctResponse
161
+ }
162
+ } = this.props;
163
+ this.updateModel({
164
+ correctResponse: (correctResponse || []).map(cr => ({
165
+ ...cr,
166
+ alternateResponses: (cr.alternateResponses || []).filter((alt, altIndex) => altIndex !== index)
167
+ }))
164
168
  });
165
169
  });
166
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "countChoiceInCorrectResponse", function (choice) {
167
- var model = _this.props.model;
170
+ (0, _defineProperty2.default)(this, "countChoiceInCorrectResponse", choice => {
171
+ const {
172
+ model
173
+ } = this.props;
168
174
  return (0, _categorize.countInAnswer)(choice.id, model.correctResponse);
169
175
  });
170
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "checkAllowMultiplePlacements", function (allowMultiplePlacements, c) {
176
+ (0, _defineProperty2.default)(this, "checkAllowMultiplePlacements", (allowMultiplePlacements, c) => {
171
177
  if (allowMultiplePlacements === _utils2.multiplePlacements.enabled) {
172
178
  return 0;
173
179
  }
174
-
175
180
  if (allowMultiplePlacements === _utils2.multiplePlacements.disabled) {
176
181
  return 1;
177
182
  }
178
-
179
183
  return c.categoryCount || 0;
180
184
  });
181
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "isAlertModalOpened", function () {
182
- var model = _this.props.model;
183
-
184
- var _ref = model || {},
185
- _ref$maxChoicesPerCat = _ref.maxChoicesPerCategory,
186
- maxChoicesPerCategory = _ref$maxChoicesPerCat === void 0 ? 0 : _ref$maxChoicesPerCat;
187
-
188
- var maxChoices = (0, _utils2.getMaxCategoryChoices)(model); // when maxChoicesPerCategory is set to 0, there is no limit so modal should not be opened
189
-
185
+ (0, _defineProperty2.default)(this, "isAlertModalOpened", () => {
186
+ const {
187
+ model
188
+ } = this.props;
189
+ const {
190
+ maxChoicesPerCategory = 0
191
+ } = model || {};
192
+ const maxChoices = (0, _utils2.getMaxCategoryChoices)(model);
193
+ // when maxChoicesPerCategory is set to 0, there is no limit so modal should not be opened
190
194
  return maxChoicesPerCategory !== 0 ? maxChoices > maxChoicesPerCategory : false;
191
195
  });
192
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAlertModalCancel", function () {
193
- var model = _this.props.model;
194
- var maxChoices = (0, _utils2.getMaxCategoryChoices)(model);
195
-
196
- _this.updateModel({
196
+ (0, _defineProperty2.default)(this, "onAlertModalCancel", () => {
197
+ const {
198
+ model
199
+ } = this.props;
200
+ const maxChoices = (0, _utils2.getMaxCategoryChoices)(model);
201
+ this.updateModel({
197
202
  maxChoicesPerCategory: maxChoices
198
203
  });
199
204
  });
200
- _this.uid = _props.uid || _drag.uid.generateId();
201
- return _this;
202
- }
203
-
204
- (0, _createClass2["default"])(Design, [{
205
- key: "render",
206
- value: function render() {
207
- var _this2 = this;
208
-
209
- var _this$props4 = this.props,
210
- classes = _this$props4.classes,
211
- configuration = _this$props4.configuration,
212
- imageSupport = _this$props4.imageSupport,
213
- model = _this$props4.model,
214
- uploadSoundSupport = _this$props4.uploadSoundSupport,
215
- onConfigurationChanged = _this$props4.onConfigurationChanged;
216
-
217
- var _ref2 = configuration || {},
218
- _ref2$allowAlternate = _ref2.allowAlternate,
219
- allowAlternate = _ref2$allowAlternate === void 0 ? {} : _ref2$allowAlternate,
220
- _ref2$allowMultiplePl = _ref2.allowMultiplePlacements,
221
- allowMultiplePlacements = _ref2$allowMultiplePl === void 0 ? {} : _ref2$allowMultiplePl,
222
- _ref2$baseInputConfig = _ref2.baseInputConfiguration,
223
- baseInputConfiguration = _ref2$baseInputConfig === void 0 ? {} : _ref2$baseInputConfig,
224
- _ref2$categoriesPerRo = _ref2.categoriesPerRow,
225
- categoriesPerRow = _ref2$categoriesPerRo === void 0 ? {} : _ref2$categoriesPerRo,
226
- _ref2$choicesPosition = _ref2.choicesPosition,
227
- choicesPosition = _ref2$choicesPosition === void 0 ? {} : _ref2$choicesPosition,
228
- _ref2$contentDimensio = _ref2.contentDimensions,
229
- contentDimensions = _ref2$contentDimensio === void 0 ? {} : _ref2$contentDimensio,
230
- _ref2$feedback = _ref2.feedback,
231
- feedback = _ref2$feedback === void 0 ? {} : _ref2$feedback,
232
- _ref2$lockChoiceOrder = _ref2.lockChoiceOrder,
233
- lockChoiceOrder = _ref2$lockChoiceOrder === void 0 ? {} : _ref2$lockChoiceOrder,
234
- _ref2$maxImageHeight = _ref2.maxImageHeight,
235
- maxImageHeight = _ref2$maxImageHeight === void 0 ? {} : _ref2$maxImageHeight,
236
- _ref2$maxImageWidth = _ref2.maxImageWidth,
237
- maxImageWidth = _ref2$maxImageWidth === void 0 ? {} : _ref2$maxImageWidth,
238
- _ref2$maxPlacements = _ref2.maxPlacements,
239
- maxPlacements = _ref2$maxPlacements === void 0 ? {} : _ref2$maxPlacements,
240
- _ref2$minCategoriesPe = _ref2.minCategoriesPerRow,
241
- minCategoriesPerRow = _ref2$minCategoriesPe === void 0 ? 1 : _ref2$minCategoriesPe,
242
- _ref2$partialScoring = _ref2.partialScoring,
243
- partialScoring = _ref2$partialScoring === void 0 ? {} : _ref2$partialScoring,
244
- _ref2$prompt = _ref2.prompt,
245
- prompt = _ref2$prompt === void 0 ? {} : _ref2$prompt,
246
- _ref2$rationale = _ref2.rationale,
247
- rationale = _ref2$rationale === void 0 ? {} : _ref2$rationale,
248
- _ref2$scoringType = _ref2.scoringType,
249
- scoringType = _ref2$scoringType === void 0 ? {} : _ref2$scoringType,
250
- settingsPanelDisabled = _ref2.settingsPanelDisabled,
251
- _ref2$spellCheck = _ref2.spellCheck,
252
- spellCheck = _ref2$spellCheck === void 0 ? {} : _ref2$spellCheck,
253
- _ref2$studentInstruct = _ref2.studentInstructions,
254
- studentInstructions = _ref2$studentInstruct === void 0 ? {} : _ref2$studentInstruct,
255
- _ref2$teacherInstruct = _ref2.teacherInstructions,
256
- teacherInstructions = _ref2$teacherInstruct === void 0 ? {} : _ref2$teacherInstruct,
257
- _ref2$withRubric = _ref2.withRubric,
258
- withRubric = _ref2$withRubric === void 0 ? {} : _ref2$withRubric,
259
- _ref2$mathMlOptions = _ref2.mathMlOptions,
260
- mathMlOptions = _ref2$mathMlOptions === void 0 ? {} : _ref2$mathMlOptions,
261
- _ref2$language = _ref2.language,
262
- language = _ref2$language === void 0 ? {} : _ref2$language,
263
- _ref2$languageChoices = _ref2.languageChoices,
264
- languageChoices = _ref2$languageChoices === void 0 ? {} : _ref2$languageChoices,
265
- _ref2$allowMaxAnswerC = _ref2.allowMaxAnswerChoices,
266
- allowMaxAnswerChoices = _ref2$allowMaxAnswerC === void 0 ? {} : _ref2$allowMaxAnswerC;
267
-
268
- var _ref3 = model || {},
269
- allowAlternateEnabled = _ref3.allowAlternateEnabled,
270
- allowMaxChoicesPerCategory = _ref3.allowMaxChoicesPerCategory,
271
- errors = _ref3.errors,
272
- feedbackEnabled = _ref3.feedbackEnabled,
273
- maxChoicesPerCategory = _ref3.maxChoicesPerCategory,
274
- promptEnabled = _ref3.promptEnabled,
275
- rationaleEnabled = _ref3.rationaleEnabled,
276
- spellCheckEnabled = _ref3.spellCheckEnabled,
277
- teacherInstructionsEnabled = _ref3.teacherInstructionsEnabled,
278
- toolbarEditorPosition = _ref3.toolbarEditorPosition,
279
- extraCSSRules = _ref3.extraCSSRules;
205
+ (0, _defineProperty2.default)(this, "onDragStart", event => {
206
+ const {
207
+ active
208
+ } = event;
209
+ const draggedItem = active.data.current;
210
+ this.setState({
211
+ activeDragItem: draggedItem
212
+ });
213
+ });
214
+ (0, _defineProperty2.default)(this, "onDragEnd", event => {
215
+ const {
216
+ active,
217
+ over
218
+ } = event;
219
+ this.setState({
220
+ activeDragItem: null
221
+ });
222
+ if (!over || !active) {
223
+ return;
224
+ }
225
+ const {
226
+ model
227
+ } = this.props;
228
+ const {
229
+ allowAlternateEnabled
230
+ } = model;
231
+ const activeData = active.data.current;
232
+ const overData = over.data.current;
233
+
234
+ // moving a choice between categories (correct response)
235
+ if (activeData.type === 'choice-preview' && overData.type === 'category') {
236
+ // Extract original choice.id - if DraggableChoice uses the unique id in data, extract the first part
237
+ // Format: ${choice.id}-${categoryId}-${choiceIndex} or ${choice.id}-${categoryId}-${choiceIndex}-alt-${alternateResponseIndex}
238
+ const choiceId = activeData.choice?.id || (typeof activeData.id === 'string' ? activeData.id.split('-')[0] : activeData.id);
239
+ this.moveChoice(choiceId, activeData.categoryId, overData.id, activeData.choiceIndex || 0);
240
+ }
280
241
 
281
- var _ref4 = errors || {},
282
- promptError = _ref4.prompt,
283
- rationaleError = _ref4.rationale,
284
- teacherInstructionsError = _ref4.teacherInstructions;
242
+ // placing a choice into a category (correct response)
243
+ if (activeData.type === 'choice' && overData.type === 'category') {
244
+ this.addChoiceToCategory({
245
+ id: activeData.id
246
+ }, overData.id);
247
+ }
285
248
 
286
- var toolbarOpts = {
287
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
288
- };
289
- var config = model.config || {};
290
- config.choices = config.choices || {
291
- label: '',
292
- columns: 2
293
- };
294
- var categories = (0, _builder.buildCategories)(model.categories || [], model.choices || [], model.correctResponse || []);
295
- var alternateResponses = (0, _builder.buildAlternateResponses)(model.categories || [], model.choices || [], model.correctResponse || []);
296
- var choices = model.choices.map(function (c) {
297
- c.correctResponseCount = _this2.countChoiceInCorrectResponse(c); // ensure categoryCount is set even though updatedModel hasn't been called
249
+ // moving a choice between categories (alternate response)
250
+ if (activeData.type === 'choice-preview' && overData.type === 'category-alternate') {
251
+ const toAlternateIndex = overData.alternateResponseIndex;
252
+ // Extract original choice.id - if DraggableChoice uses the unique id in data, extract the first part
253
+ const choiceId = activeData.choice?.id || (typeof activeData.id === 'string' ? activeData.id.split('-')[0] : activeData.id);
254
+ this.moveChoiceInAlternate(choiceId, activeData.categoryId, overData.id, activeData.choiceIndex || 0, toAlternateIndex);
255
+ }
298
256
 
299
- c.categoryCount = _this2.checkAllowMultiplePlacements(model.allowMultiplePlacementsEnabled, c);
300
- return c;
257
+ // placing a choice into a category (alternate response)
258
+ if (allowAlternateEnabled && activeData.type === 'choice' && overData.type === 'category-alternate') {
259
+ const choiceId = activeData.id;
260
+ const categoryId = overData.id;
261
+ const toAlternateResponseIndex = overData.alternateResponseIndex;
262
+ this.addChoiceToAlternateCategory({
263
+ id: choiceId
264
+ }, categoryId, toAlternateResponseIndex);
265
+ }
266
+ });
267
+ (0, _defineProperty2.default)(this, "addChoiceToCategory", (addedChoice, categoryId) => {
268
+ const {
269
+ model
270
+ } = this.props;
271
+ let {
272
+ choices = [],
273
+ correctResponse = [],
274
+ maxChoicesPerCategory = 0
275
+ } = model || {};
276
+ const choice = (choices || []).find(choice => choice.id === addedChoice.id);
277
+ let newCorrectResponse = (0, _categorize.moveChoiceToCategory)(addedChoice.id, undefined, categoryId, 0, correctResponse);
278
+ if (choice.categoryCount !== 0) {
279
+ newCorrectResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, newCorrectResponse);
280
+ }
281
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
282
+ this.updateModel({
283
+ correctResponse: newCorrectResponse,
284
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
301
285
  });
302
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
303
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
304
- var panelSettings = {
305
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
306
- lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
307
- categoriesPerRow: categoriesPerRow.settings && numberField(categoriesPerRow.label, {
308
- label: categoriesPerRow.label,
309
- min: minCategoriesPerRow,
310
- max: 6
311
- }),
312
- choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),
313
- allowMultiplePlacementsEnabled: allowMultiplePlacements.settings && dropdown(allowMultiplePlacements.label, [_utils2.multiplePlacements.enabled, _utils2.multiplePlacements.disabled, _utils2.multiplePlacements.perChoice]),
314
- maxAnswerChoices: allowMaxAnswerChoices.settings && numberField(allowMaxAnswerChoices.label, {
315
- label: '',
316
- min: (choices === null || choices === void 0 ? void 0 : choices.length) || 0,
317
- max: 30
318
- }),
319
- allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),
320
- maxChoicesPerCategory: allowMaxChoicesPerCategory === true && numberField(maxPlacements.label, {
321
- label: '',
322
- min: 0,
323
- max: 30
324
- }),
325
- promptEnabled: prompt.settings && toggle(prompt.label),
326
- feedbackEnabled: feedback.settings && toggle(feedback.label),
327
- allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),
328
- 'language.enabled': language.settings && toggle(language.label, true),
329
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
330
- };
331
- var panelProperties = {
332
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
333
- studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
334
- rationaleEnabled: rationale.settings && toggle(rationale.label),
335
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
336
- scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
337
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
338
- };
339
- var isOpened = this.isAlertModalOpened();
340
- var alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {
341
- lng: model.language,
342
- maxChoicesPerCategory: maxChoicesPerCategory
286
+ });
287
+ (0, _defineProperty2.default)(this, "deleteChoiceFromCategory", (category, choice, choiceIndex) => {
288
+ const {
289
+ model
290
+ } = this.props;
291
+ const correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
292
+ this.updateModel({
293
+ correctResponse
343
294
  });
344
- return /*#__PURE__*/_react["default"].createElement(IdProvider, {
345
- value: this.uid
346
- }, /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
347
- extraCSSRules: extraCSSRules,
348
- dimensions: contentDimensions,
349
- hideSettings: settingsPanelDisabled,
350
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
351
- model: model,
352
- onChangeModel: this.updateModel,
353
- configuration: configuration,
354
- onChangeConfiguration: onConfigurationChanged,
355
- groups: {
356
- Settings: panelSettings,
357
- Properties: panelProperties
358
- },
359
- modal: /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
360
- title: 'Warning',
361
- text: alertMaxChoicesMsg,
362
- open: isOpened,
363
- onClose: this.onAlertModalCancel
364
- })
365
- })
366
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
367
- label: teacherInstructions.label,
368
- className: classes.inputContainer
369
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
370
- className: classes.input,
371
- markup: model.teacherInstructions || '',
372
- onChange: this.changeTeacherInstructions,
373
- imageSupport: imageSupport,
374
- error: teacherInstructionsError,
375
- nonEmpty: false,
376
- toolbarOpts: toolbarOpts,
377
- pluginProps: (0, _utils.getPluginProps)(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration, baseInputConfiguration),
378
- spellCheck: spellCheckEnabled,
379
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
380
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
381
- uploadSoundSupport: uploadSoundSupport,
382
- languageCharactersProps: [{
383
- language: 'spanish'
384
- }, {
385
- language: 'special'
386
- }],
387
- mathMlOptions: mathMlOptions
388
- }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
389
- className: classes.errorText
390
- }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
391
- label: prompt.label,
392
- className: classes.inputContainer
393
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
394
- className: classes.input,
395
- markup: model.prompt || '',
396
- onChange: this.onPromptChanged,
397
- imageSupport: imageSupport,
398
- error: promptError,
399
- nonEmpty: false,
400
- disableUnderline: true,
401
- toolbarOpts: toolbarOpts,
402
- pluginProps: (0, _utils.getPluginProps)(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
403
- spellCheck: spellCheckEnabled,
404
- maxImageWidth: maxImageWidth && maxImageWidth.prompt,
405
- maxImageHeight: maxImageHeight && maxImageHeight.prompt,
406
- uploadSoundSupport: uploadSoundSupport,
407
- languageCharactersProps: [{
408
- language: 'spanish'
409
- }, {
410
- language: 'special'
411
- }],
412
- mathMlOptions: mathMlOptions
413
- }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
414
- className: classes.errorText
415
- }, promptError)), /*#__PURE__*/_react["default"].createElement(_categories["default"], {
416
- imageSupport: imageSupport,
417
- uploadSoundSupport: uploadSoundSupport,
295
+ });
296
+ (0, _defineProperty2.default)(this, "moveChoice", (choiceId, from, to, choiceIndex) => {
297
+ const {
298
+ model
299
+ } = this.props;
300
+ let {
301
+ choices,
302
+ correctResponse = [],
303
+ maxChoicesPerCategory = 0
304
+ } = model || {};
305
+ const choice = (choices || []).find(choice => choice.id === choiceId);
306
+ if (to === from || !choice) {
307
+ return;
308
+ }
309
+ if (choice.categoryCount !== 0) {
310
+ correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, from, to, choiceIndex, correctResponse);
311
+ correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(choice, to, correctResponse);
312
+ } else if (choice.categoryCount === 0) {
313
+ correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
314
+ }
315
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
316
+ // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
317
+ this.updateModel({
318
+ correctResponse,
319
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
320
+ });
321
+ });
322
+ // methods for alternate responses
323
+ (0, _defineProperty2.default)(this, "addChoiceToAlternateCategory", (addedChoice, categoryId, altIndex) => {
324
+ const {
325
+ model
326
+ } = this.props;
327
+ const {
328
+ correctResponse,
329
+ choices,
330
+ maxChoicesPerCategory = 0
331
+ } = model;
332
+ const choice = choices.find(c => c.id === addedChoice.id);
333
+ correctResponse.forEach(a => {
334
+ if (a.category === categoryId) {
335
+ a.alternateResponses = a.alternateResponses || [];
336
+ if (a.alternateResponses[altIndex] === undefined) {
337
+ a.alternateResponses[altIndex] = [];
338
+ }
339
+ a.alternateResponses[altIndex].push(addedChoice.id);
340
+ if (choice.categoryCount && choice.categoryCount !== 0) {
341
+ a.alternateResponses[altIndex] = a.alternateResponses[altIndex].reduce((acc, currentValue) => {
342
+ if (currentValue === choice.id) {
343
+ const foundIndex = acc.findIndex(c => c === choice.id);
344
+ if (foundIndex === -1) {
345
+ acc.push(currentValue);
346
+ }
347
+ } else {
348
+ acc.push(currentValue);
349
+ }
350
+ return acc;
351
+ }, []);
352
+ }
353
+ return a;
354
+ } else {
355
+ if (a.alternateResponses[altIndex] && choice.categoryCount !== 0) {
356
+ a.alternateResponses[altIndex] = a.alternateResponses[altIndex].filter(c => c !== addedChoice.id);
357
+ return a;
358
+ }
359
+ }
360
+ return a;
361
+ });
362
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
363
+ // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
364
+ this.updateModel({
365
+ correctResponse,
366
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
367
+ });
368
+ });
369
+ (0, _defineProperty2.default)(this, "moveChoiceInAlternate", (choiceId, from, to, choiceIndex, alternateIndex) => {
370
+ const {
371
+ model
372
+ } = this.props;
373
+ let {
374
+ choices,
375
+ correctResponse = [],
376
+ maxChoicesPerCategory = 0
377
+ } = model || {};
378
+ const choice = (choices || []).find(choice => choice.id === choiceId);
379
+ correctResponse = (0, _categorize.moveChoiceToAlternate)(choiceId, from, to, choiceIndex, correctResponse, alternateIndex, choice?.categoryCount);
380
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
381
+ // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
382
+ this.updateModel({
383
+ correctResponse,
384
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
385
+ });
386
+ });
387
+ (0, _defineProperty2.default)(this, "deleteChoiceFromAlternateCategory", (category, choice, choiceIndex, altIndex) => {
388
+ const {
389
+ model
390
+ } = this.props;
391
+ const correctResponse = (0, _categorize.removeChoiceFromAlternate)(choice.id, category.id, choiceIndex, altIndex, model.correctResponse);
392
+ this.updateModel({
393
+ correctResponse
394
+ });
395
+ });
396
+ (0, _defineProperty2.default)(this, "renderDragOverlay", () => {
397
+ const {
398
+ activeDragItem
399
+ } = this.state;
400
+ const {
401
+ model,
402
+ configuration
403
+ } = this.props;
404
+ if (!activeDragItem) return null;
405
+ if (activeDragItem.type === 'choice') {
406
+ const choice = model.choices?.find(c => c.id === activeDragItem.id);
407
+ if (!choice) return null;
408
+ return /*#__PURE__*/_react.default.createElement(_choice.default, {
409
+ choice: choice,
410
+ configuration: configuration
411
+ });
412
+ } else if (activeDragItem.type === 'choice-preview' && activeDragItem.alternateResponseIndex === undefined) {
413
+ const choice = model.choices?.find(c => c.id === activeDragItem.id);
414
+ if (!choice) return null;
415
+ return /*#__PURE__*/_react.default.createElement(_choicePreview.default, {
416
+ choice: choice
417
+ });
418
+ } else if (activeDragItem.type === 'choice-preview' && activeDragItem.alternateResponseIndex !== undefined) {
419
+ const choice = model.choices?.find(c => c.id === activeDragItem.id);
420
+ if (!choice) return null;
421
+ return /*#__PURE__*/_react.default.createElement(_choicePreview.default, {
422
+ choice: choice,
423
+ alternateResponseIndex: activeDragItem.alternateResponseIndex
424
+ });
425
+ }
426
+ return null;
427
+ });
428
+ this.uid = _props.uid || _drag.uid.generateId();
429
+ this.state = {
430
+ activeDragItem: null
431
+ };
432
+ }
433
+ render() {
434
+ const {
435
+ configuration,
436
+ imageSupport,
437
+ model,
438
+ uploadSoundSupport,
439
+ onConfigurationChanged
440
+ } = this.props;
441
+ const {
442
+ allowAlternate = {},
443
+ allowMultiplePlacements = {},
444
+ baseInputConfiguration = {},
445
+ categoriesPerRow = {},
446
+ choicesPosition = {},
447
+ contentDimensions = {},
448
+ feedback = {},
449
+ lockChoiceOrder = {},
450
+ maxImageHeight = {},
451
+ maxImageWidth = {},
452
+ maxPlacements = {},
453
+ minCategoriesPerRow = 1,
454
+ partialScoring = {},
455
+ prompt = {},
456
+ rationale = {},
457
+ scoringType = {},
458
+ settingsPanelDisabled,
459
+ spellCheck = {},
460
+ studentInstructions = {},
461
+ teacherInstructions = {},
462
+ withRubric = {},
463
+ mathMlOptions = {},
464
+ language = {},
465
+ languageChoices = {},
466
+ allowMaxAnswerChoices = {}
467
+ } = configuration || {};
468
+ const {
469
+ allowAlternateEnabled,
470
+ allowMaxChoicesPerCategory,
471
+ errors,
472
+ feedbackEnabled,
473
+ maxChoicesPerCategory,
474
+ promptEnabled,
475
+ rationaleEnabled,
476
+ spellCheckEnabled,
477
+ teacherInstructionsEnabled,
478
+ toolbarEditorPosition,
479
+ extraCSSRules
480
+ } = model || {};
481
+ const {
482
+ prompt: promptError,
483
+ rationale: rationaleError,
484
+ teacherInstructions: teacherInstructionsError
485
+ } = errors || {};
486
+ const toolbarOpts = {
487
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
488
+ };
489
+ const config = model.config || {};
490
+ config.choices = config.choices || {
491
+ label: '',
492
+ columns: 2
493
+ };
494
+ const categories = (0, _builder.buildCategories)(model.categories || [], model.choices || [], model.correctResponse || []);
495
+ const alternateResponses = (0, _builder.buildAlternateResponses)(model.categories || [], model.choices || [], model.correctResponse || []);
496
+ const choices = model.choices.map(c => {
497
+ c.correctResponseCount = this.countChoiceInCorrectResponse(c);
498
+ // ensure categoryCount is set even though updatedModel hasn't been called
499
+ c.categoryCount = this.checkAllowMultiplePlacements(model.allowMultiplePlacementsEnabled, c);
500
+ return c;
501
+ });
502
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
503
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
504
+ const panelSettings = {
505
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
506
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
507
+ categoriesPerRow: categoriesPerRow.settings && numberField(categoriesPerRow.label, {
508
+ label: categoriesPerRow.label,
509
+ min: minCategoriesPerRow,
510
+ max: 6
511
+ }),
512
+ choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),
513
+ allowMultiplePlacementsEnabled: allowMultiplePlacements.settings && dropdown(allowMultiplePlacements.label, [_utils2.multiplePlacements.enabled, _utils2.multiplePlacements.disabled, _utils2.multiplePlacements.perChoice]),
514
+ maxAnswerChoices: allowMaxAnswerChoices.settings && numberField(allowMaxAnswerChoices.label, {
515
+ label: '',
516
+ min: choices?.length || 0,
517
+ max: 30
518
+ }),
519
+ allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),
520
+ maxChoicesPerCategory: allowMaxChoicesPerCategory === true && numberField(maxPlacements.label, {
521
+ label: '',
522
+ min: 0,
523
+ max: 30
524
+ }),
525
+ promptEnabled: prompt.settings && toggle(prompt.label),
526
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
527
+ allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),
528
+ 'language.enabled': language.settings && toggle(language.label, true),
529
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
530
+ };
531
+ const panelProperties = {
532
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
533
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
534
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
535
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
536
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
537
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
538
+ };
539
+ const isOpened = this.isAlertModalOpened();
540
+ const alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {
541
+ lng: model.language,
542
+ maxChoicesPerCategory
543
+ });
544
+ return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, {
545
+ onDragStart: this.onDragStart,
546
+ onDragEnd: this.onDragEnd
547
+ }, /*#__PURE__*/_react.default.createElement(IdProvider, {
548
+ value: this.uid
549
+ }, /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
550
+ extraCSSRules: extraCSSRules,
551
+ dimensions: contentDimensions,
552
+ hideSettings: settingsPanelDisabled,
553
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
418
554
  model: model,
419
- categories: categories || [],
420
- onModelChanged: this.updateModel,
421
- toolbarOpts: toolbarOpts,
422
- spellCheck: spellCheckEnabled,
555
+ onChangeModel: this.updateModel,
423
556
  configuration: configuration,
424
- defaultImageMaxWidth: defaultImageMaxWidth,
425
- defaultImageMaxHeight: defaultImageMaxHeight,
426
- mathMlOptions: mathMlOptions
427
- }), /*#__PURE__*/_react["default"].createElement(_choices["default"], {
557
+ onChangeConfiguration: onConfigurationChanged,
558
+ groups: {
559
+ Settings: panelSettings,
560
+ Properties: panelProperties
561
+ },
562
+ modal: /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
563
+ title: 'Warning',
564
+ text: alertMaxChoicesMsg,
565
+ open: isOpened,
566
+ onClose: this.onAlertModalCancel
567
+ })
568
+ })
569
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
570
+ label: teacherInstructions.label
571
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
572
+ markup: model.teacherInstructions || '',
573
+ onChange: this.changeTeacherInstructions,
574
+ imageSupport: imageSupport,
575
+ error: teacherInstructionsError,
576
+ nonEmpty: false,
577
+ toolbarOpts: toolbarOpts,
578
+ pluginProps: (0, _utils.getPluginProps)(teacherInstructions?.inputConfiguration, baseInputConfiguration),
579
+ spellCheck: spellCheckEnabled,
580
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
581
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
582
+ uploadSoundSupport: uploadSoundSupport,
583
+ languageCharactersProps: [{
584
+ language: 'spanish'
585
+ }, {
586
+ language: 'special'
587
+ }],
588
+ mathMlOptions: mathMlOptions
589
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
590
+ label: prompt.label
591
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
592
+ markup: model.prompt || '',
593
+ onChange: this.onPromptChanged,
594
+ imageSupport: imageSupport,
595
+ error: promptError,
596
+ nonEmpty: false,
597
+ disableUnderline: true,
598
+ toolbarOpts: toolbarOpts,
599
+ pluginProps: (0, _utils.getPluginProps)(prompt?.inputConfiguration, baseInputConfiguration),
600
+ spellCheck: spellCheckEnabled,
601
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
602
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
603
+ uploadSoundSupport: uploadSoundSupport,
604
+ languageCharactersProps: [{
605
+ language: 'spanish'
606
+ }, {
607
+ language: 'special'
608
+ }],
609
+ mathMlOptions: mathMlOptions
610
+ }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError)), /*#__PURE__*/_react.default.createElement(_categories.default, {
611
+ imageSupport: imageSupport,
612
+ uploadSoundSupport: uploadSoundSupport,
613
+ model: model,
614
+ categories: categories || [],
615
+ onModelChanged: this.updateModel,
616
+ toolbarOpts: toolbarOpts,
617
+ spellCheck: spellCheckEnabled,
618
+ configuration: configuration,
619
+ defaultImageMaxWidth: defaultImageMaxWidth,
620
+ defaultImageMaxHeight: defaultImageMaxHeight,
621
+ mathMlOptions: mathMlOptions
622
+ }), /*#__PURE__*/_react.default.createElement(_choices.default, {
623
+ imageSupport: imageSupport,
624
+ uploadSoundSupport: uploadSoundSupport,
625
+ choices: choices,
626
+ model: model,
627
+ onModelChanged: this.updateModel,
628
+ toolbarOpts: toolbarOpts,
629
+ spellCheck: spellCheckEnabled,
630
+ configuration: configuration,
631
+ defaultImageMaxWidth: defaultImageMaxWidth,
632
+ defaultImageMaxHeight: defaultImageMaxHeight
633
+ }), allowAlternateEnabled && /*#__PURE__*/_react.default.createElement(StyledHeader, {
634
+ label: "Alternate Responses",
635
+ buttonLabel: "ADD AN ALTERNATE RESPONSE",
636
+ onAdd: this.onAddAlternateResponse
637
+ }), allowAlternateEnabled && alternateResponses.map((categoriesList, index) => {
638
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
639
+ key: index
640
+ }, /*#__PURE__*/_react.default.createElement(StyledHeader, {
641
+ variant: 'subtitle1',
642
+ label: "Alternate Response",
643
+ buttonLabel: "REMOVE ALTERNATE RESPONSE",
644
+ onAdd: () => this.onRemoveAlternateResponse(index)
645
+ }), /*#__PURE__*/_react.default.createElement(_alternateResponses.default, {
646
+ altIndex: index,
428
647
  imageSupport: imageSupport,
429
- uploadSoundSupport: uploadSoundSupport,
430
- choices: choices,
431
648
  model: model,
432
- onModelChanged: this.updateModel,
433
- toolbarOpts: toolbarOpts,
434
- spellCheck: spellCheckEnabled,
435
649
  configuration: configuration,
436
- defaultImageMaxWidth: defaultImageMaxWidth,
437
- defaultImageMaxHeight: defaultImageMaxHeight
438
- }), allowAlternateEnabled && /*#__PURE__*/_react["default"].createElement(_header["default"], {
439
- className: classes.alternatesHeader,
440
- label: "Alternate Responses",
441
- buttonLabel: "ADD AN ALTERNATE RESPONSE",
442
- onAdd: this.onAddAlternateResponse
443
- }), allowAlternateEnabled && alternateResponses.map(function (categoriesList, index) {
444
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, {
445
- key: index
446
- }, /*#__PURE__*/_react["default"].createElement(_header["default"], {
447
- className: classes.alternatesHeader,
448
- variant: 'subtitle1',
449
- label: "Alternate Response",
450
- buttonLabel: "REMOVE ALTERNATE RESPONSE",
451
- onAdd: function onAdd() {
452
- return _this2.onRemoveAlternateResponse(index);
453
- }
454
- }), /*#__PURE__*/_react["default"].createElement(_alternateResponses["default"], {
455
- altIndex: index,
456
- imageSupport: imageSupport,
457
- model: model,
458
- configuration: configuration,
459
- categories: categoriesList,
460
- onModelChanged: _this2.updateModel,
461
- uploadSoundSupport: uploadSoundSupport,
462
- mathMlOptions: mathMlOptions
463
- }));
464
- }), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
465
- label: rationale.label,
466
- className: classes.inputContainer
467
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
468
- className: classes.input,
469
- markup: model.rationale || '',
470
- onChange: this.changeRationale,
471
- imageSupport: imageSupport,
472
- error: rationaleError,
473
- nonEmpty: false,
474
- toolbarOpts: toolbarOpts,
475
- pluginProps: (0, _utils.getPluginProps)(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
476
- spellCheck: spellCheckEnabled,
477
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
478
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
650
+ categories: categoriesList,
651
+ onModelChanged: this.updateModel,
479
652
  uploadSoundSupport: uploadSoundSupport,
480
- languageCharactersProps: [{
481
- language: 'spanish'
482
- }, {
483
- language: 'special'
484
- }],
485
653
  mathMlOptions: mathMlOptions
486
- }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
487
- className: classes.errorText
488
- }, rationaleError)), feedbackEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.FeedbackConfig, {
489
- feedback: model.feedback,
490
- onChange: this.changeFeedback,
491
- toolbarOpts: toolbarOpts
492
- })));
493
- }
494
- }]);
495
- return Design;
496
- }(_react["default"].Component);
497
-
654
+ }));
655
+ }), rationaleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
656
+ label: rationale.label
657
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
658
+ markup: model.rationale || '',
659
+ onChange: this.changeRationale,
660
+ imageSupport: imageSupport,
661
+ error: rationaleError,
662
+ nonEmpty: false,
663
+ toolbarOpts: toolbarOpts,
664
+ pluginProps: (0, _utils.getPluginProps)(prompt?.inputConfiguration, baseInputConfiguration),
665
+ spellCheck: spellCheckEnabled,
666
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
667
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
668
+ uploadSoundSupport: uploadSoundSupport,
669
+ languageCharactersProps: [{
670
+ language: 'spanish'
671
+ }, {
672
+ language: 'special'
673
+ }],
674
+ mathMlOptions: mathMlOptions
675
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError)), feedbackEnabled && /*#__PURE__*/_react.default.createElement(_configUi.FeedbackConfig, {
676
+ feedback: model.feedback,
677
+ onChange: this.changeFeedback,
678
+ toolbarOpts: toolbarOpts
679
+ })), /*#__PURE__*/_react.default.createElement(_core.DragOverlay, null, /*#__PURE__*/_react.default.createElement(DragPreviewWrapper, null, this.renderDragOverlay()))));
680
+ }
681
+ }
498
682
  exports.Design = Design;
499
- (0, _defineProperty2["default"])(Design, "propTypes", {
500
- classes: _propTypes["default"].object.isRequired,
501
- configuration: _propTypes["default"].object,
502
- className: _propTypes["default"].string,
503
- onConfigurationChanged: _propTypes["default"].func,
504
- model: _propTypes["default"].object.isRequired,
505
- onChange: _propTypes["default"].func.isRequired,
506
- uid: _propTypes["default"].string,
507
- imageSupport: _propTypes["default"].shape({
508
- add: _propTypes["default"].func.isRequired,
509
- "delete": _propTypes["default"].func.isRequired
683
+ (0, _defineProperty2.default)(Design, "propTypes", {
684
+ configuration: _propTypes.default.object,
685
+ className: _propTypes.default.string,
686
+ onConfigurationChanged: _propTypes.default.func,
687
+ model: _propTypes.default.object.isRequired,
688
+ onChange: _propTypes.default.func.isRequired,
689
+ uid: _propTypes.default.string,
690
+ imageSupport: _propTypes.default.shape({
691
+ add: _propTypes.default.func.isRequired,
692
+ delete: _propTypes.default.func.isRequired
510
693
  }),
511
- uploadSoundSupport: _propTypes["default"].shape({
512
- add: _propTypes["default"].func.isRequired,
513
- "delete": _propTypes["default"].func.isRequired
694
+ uploadSoundSupport: _propTypes.default.shape({
695
+ add: _propTypes.default.func.isRequired,
696
+ delete: _propTypes.default.func.isRequired
514
697
  })
515
698
  });
516
-
517
- var styles = function styles(theme) {
518
- return {
519
- alternatesHeader: {
520
- marginBottom: theme.spacing.unit * 2
521
- },
522
- text: {
523
- paddingTop: theme.spacing.unit * 2,
524
- paddingBottom: theme.spacing.unit * 2
525
- },
526
- inputContainer: {
527
- width: '100%',
528
- paddingTop: theme.spacing.unit * 2,
529
- marginBottom: theme.spacing.unit * 2
530
- },
531
- title: {
532
- marginBottom: theme.spacing.unit * 4
533
- },
534
- errorText: {
535
- fontSize: theme.typography.fontSize - 2,
536
- color: theme.palette.error.main,
537
- paddingTop: theme.spacing.unit
538
- }
539
- };
540
- };
541
-
542
- var _default = (0, _drag.withDragContext)((0, _styles.withStyles)(styles)(Design));
543
-
544
- exports["default"] = _default;
699
+ var _default = exports.default = Design;
545
700
  //# sourceMappingURL=index.js.map