@pie-element/categorize 11.0.5-esm.1 → 11.2.0-mui-update.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 (81) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/configure/CHANGELOG.md +74 -0
  3. package/configure/lib/defaults.js +2 -5
  4. package/configure/lib/defaults.js.map +1 -1
  5. package/configure/lib/design/builder.js +15 -33
  6. package/configure/lib/design/builder.js.map +1 -1
  7. package/configure/lib/design/buttons.js +44 -95
  8. package/configure/lib/design/buttons.js.map +1 -1
  9. package/configure/lib/design/categories/RowLabel.js +32 -45
  10. package/configure/lib/design/categories/RowLabel.js.map +1 -1
  11. package/configure/lib/design/categories/alternateResponses.js +102 -251
  12. package/configure/lib/design/categories/alternateResponses.js.map +1 -1
  13. package/configure/lib/design/categories/category.js +138 -208
  14. package/configure/lib/design/categories/category.js.map +1 -1
  15. package/configure/lib/design/categories/choice-preview.js +59 -126
  16. package/configure/lib/design/categories/choice-preview.js.map +1 -1
  17. package/configure/lib/design/categories/droppable-placeholder.js +76 -165
  18. package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
  19. package/configure/lib/design/categories/index.js +199 -384
  20. package/configure/lib/design/categories/index.js.map +1 -1
  21. package/configure/lib/design/choices/choice.js +160 -263
  22. package/configure/lib/design/choices/choice.js.map +1 -1
  23. package/configure/lib/design/choices/config.js +46 -98
  24. package/configure/lib/design/choices/config.js.map +1 -1
  25. package/configure/lib/design/choices/index.js +152 -236
  26. package/configure/lib/design/choices/index.js.map +1 -1
  27. package/configure/lib/design/header.js +62 -111
  28. package/configure/lib/design/header.js.map +1 -1
  29. package/configure/lib/design/index.js +632 -476
  30. package/configure/lib/design/index.js.map +1 -1
  31. package/configure/lib/design/input-header.js +97 -149
  32. package/configure/lib/design/input-header.js.map +1 -1
  33. package/configure/lib/design/utils.js +4 -15
  34. package/configure/lib/design/utils.js.map +1 -1
  35. package/configure/lib/index.js +120 -183
  36. package/configure/lib/index.js.map +1 -1
  37. package/configure/lib/main.js +31 -74
  38. package/configure/lib/main.js.map +1 -1
  39. package/configure/lib/utils.js +22 -32
  40. package/configure/lib/utils.js.map +1 -1
  41. package/configure/package.json +15 -14
  42. package/controller/CHANGELOG.md +62 -0
  43. package/controller/lib/defaults.js +2 -5
  44. package/controller/lib/defaults.js.map +1 -1
  45. package/controller/lib/index.js +238 -315
  46. package/controller/lib/index.js.map +1 -1
  47. package/controller/lib/utils.js +40 -31
  48. package/controller/lib/utils.js.map +1 -1
  49. package/controller/package.json +5 -5
  50. package/lib/categorize/categories.js +110 -164
  51. package/lib/categorize/categories.js.map +1 -1
  52. package/lib/categorize/category.js +72 -122
  53. package/lib/categorize/category.js.map +1 -1
  54. package/lib/categorize/choice.js +116 -245
  55. package/lib/categorize/choice.js.map +1 -1
  56. package/lib/categorize/choices.js +66 -131
  57. package/lib/categorize/choices.js.map +1 -1
  58. package/lib/categorize/droppable-placeholder.js +49 -103
  59. package/lib/categorize/droppable-placeholder.js.map +1 -1
  60. package/lib/categorize/grid-content.js +39 -87
  61. package/lib/categorize/grid-content.js.map +1 -1
  62. package/lib/categorize/index.js +341 -316
  63. package/lib/categorize/index.js.map +1 -1
  64. package/lib/index.js +286 -271
  65. package/lib/index.js.map +1 -1
  66. package/package.json +17 -31
  67. package/LICENSE.md +0 -5
  68. package/esm/configure.js +0 -5025
  69. package/esm/configure.js.map +0 -1
  70. package/esm/controller.js +0 -456
  71. package/esm/controller.js.map +0 -1
  72. package/esm/element.js +0 -3118
  73. package/esm/element.js.map +0 -1
  74. package/module/configure.js +0 -1
  75. package/module/controller.js +0 -6076
  76. package/module/demo.js +0 -382
  77. package/module/element.js +0 -1
  78. package/module/index.html +0 -21
  79. package/module/manifest.json +0 -22
  80. package/module/print-demo.js +0 -420
  81. package/module/print.html +0 -18
@@ -1,545 +1,701 @@
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
+
220
+ // Always clear activeDragItem when drag ends
221
+ this.setState({
222
+ activeDragItem: null
223
+ });
224
+ if (!over || !active) {
225
+ console.log('Missing over or active:', {
226
+ over,
227
+ active
228
+ });
229
+ return;
230
+ }
231
+ const {
232
+ model
233
+ } = this.props;
234
+ const {
235
+ allowAlternateEnabled
236
+ } = model;
237
+ const activeData = active.data.current;
238
+ const overData = over.data.current;
239
+
240
+ // moving a choice between categories (correct response)
241
+ if (activeData.type === 'choice-preview' && overData.type === 'category') {
242
+ this.moveChoice(activeData.id, activeData.categoryId, overData.id, 0);
243
+ }
280
244
 
281
- var _ref4 = errors || {},
282
- promptError = _ref4.prompt,
283
- rationaleError = _ref4.rationale,
284
- teacherInstructionsError = _ref4.teacherInstructions;
245
+ // placing a choice into a category (correct response)
246
+ if (activeData.type === 'choice' && overData.type === 'category') {
247
+ this.addChoiceToCategory({
248
+ id: activeData.id
249
+ }, overData.id);
250
+ }
285
251
 
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
252
+ // moving a choice between categories (alternate response)
253
+ if (activeData.type === 'choice-preview' && overData.type === 'category-alternate') {
254
+ const toAlternateIndex = overData.alternateResponseIndex;
255
+ this.moveChoiceInAlternate(activeData.id, activeData.categoryId, overData.id, 0, toAlternateIndex);
256
+ }
298
257
 
299
- c.categoryCount = _this2.checkAllowMultiplePlacements(model.allowMultiplePlacementsEnabled, c);
300
- return c;
258
+ // placing a choice into a category (alternate response)
259
+ if (allowAlternateEnabled && activeData.type === 'choice' && overData.type === 'category-alternate') {
260
+ const choiceId = activeData.id;
261
+ const categoryId = overData.id;
262
+ const toAlternateResponseIndex = overData.alternateResponseIndex;
263
+ this.addChoiceToAlternateCategory({
264
+ id: choiceId
265
+ }, categoryId, toAlternateResponseIndex);
266
+ }
267
+ });
268
+ (0, _defineProperty2.default)(this, "addChoiceToCategory", (addedChoice, categoryId) => {
269
+ const {
270
+ model
271
+ } = this.props;
272
+ let {
273
+ choices = [],
274
+ correctResponse = [],
275
+ maxChoicesPerCategory = 0
276
+ } = model || {};
277
+ const choice = (choices || []).find(choice => choice.id === addedChoice.id);
278
+ let newCorrectResponse = (0, _categorize.moveChoiceToCategory)(addedChoice.id, undefined, categoryId, 0, correctResponse);
279
+ if (choice.categoryCount !== 0) {
280
+ newCorrectResponse = (0, _categorize.verifyAllowMultiplePlacements)(addedChoice, categoryId, newCorrectResponse);
281
+ }
282
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
283
+ this.updateModel({
284
+ correctResponse: newCorrectResponse,
285
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
301
286
  });
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
287
+ });
288
+ (0, _defineProperty2.default)(this, "deleteChoiceFromCategory", (category, choice, choiceIndex) => {
289
+ const {
290
+ model
291
+ } = this.props;
292
+ const correctResponse = (0, _categorize.removeChoiceFromCategory)(choice.id, category.id, choiceIndex, model.correctResponse);
293
+ this.updateModel({
294
+ correctResponse
343
295
  });
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,
296
+ });
297
+ (0, _defineProperty2.default)(this, "moveChoice", (choiceId, from, to, choiceIndex) => {
298
+ const {
299
+ model
300
+ } = this.props;
301
+ let {
302
+ choices,
303
+ correctResponse = [],
304
+ maxChoicesPerCategory = 0
305
+ } = model || {};
306
+ const choice = (choices || []).find(choice => choice.id === choiceId);
307
+ if (to === from || !choice) {
308
+ return;
309
+ }
310
+ if (choice.categoryCount !== 0) {
311
+ correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, from, to, choiceIndex, correctResponse);
312
+ correctResponse = (0, _categorize.verifyAllowMultiplePlacements)(choice, to, correctResponse);
313
+ } else if (choice.categoryCount === 0) {
314
+ correctResponse = (0, _categorize.moveChoiceToCategory)(choice.id, undefined, to, 0, correctResponse);
315
+ }
316
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
317
+ // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
318
+ this.updateModel({
319
+ correctResponse,
320
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
321
+ });
322
+ });
323
+ // Choice manipulation methods for alternate responses
324
+ (0, _defineProperty2.default)(this, "addChoiceToAlternateCategory", (addedChoice, categoryId, altIndex) => {
325
+ const {
326
+ model
327
+ } = this.props;
328
+ const {
329
+ correctResponse,
330
+ choices,
331
+ maxChoicesPerCategory = 0
332
+ } = model;
333
+ const choice = choices.find(c => c.id === addedChoice.id);
334
+ correctResponse.forEach(a => {
335
+ if (a.category === categoryId) {
336
+ a.alternateResponses = a.alternateResponses || [];
337
+ if (a.alternateResponses[altIndex] === undefined) {
338
+ a.alternateResponses[altIndex] = [];
339
+ }
340
+ a.alternateResponses[altIndex].push(addedChoice.id);
341
+ if (choice.categoryCount && choice.categoryCount !== 0) {
342
+ a.alternateResponses[altIndex] = a.alternateResponses[altIndex].reduce((acc, currentValue) => {
343
+ if (currentValue === choice.id) {
344
+ const foundIndex = acc.findIndex(c => c === choice.id);
345
+ if (foundIndex === -1) {
346
+ acc.push(currentValue);
347
+ }
348
+ } else {
349
+ acc.push(currentValue);
350
+ }
351
+ return acc;
352
+ }, []);
353
+ }
354
+ return a;
355
+ } else {
356
+ if (a.alternateResponses[altIndex] && choice.categoryCount !== 0) {
357
+ a.alternateResponses[altIndex] = a.alternateResponses[altIndex].filter(c => c !== addedChoice.id);
358
+ return a;
359
+ }
360
+ }
361
+ return a;
362
+ });
363
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
364
+ // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
365
+ this.updateModel({
366
+ correctResponse,
367
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
368
+ });
369
+ });
370
+ (0, _defineProperty2.default)(this, "moveChoiceInAlternate", (choiceId, from, to, choiceIndex, alternateIndex) => {
371
+ const {
372
+ model
373
+ } = this.props;
374
+ let {
375
+ choices,
376
+ correctResponse = [],
377
+ maxChoicesPerCategory = 0
378
+ } = model || {};
379
+ const choice = (choices || []).find(choice => choice.id === choiceId);
380
+ correctResponse = (0, _categorize.moveChoiceToAlternate)(choiceId, from, to, choiceIndex, correctResponse, alternateIndex, choice?.categoryCount);
381
+ const maxCategoryChoices = (0, _utils2.getMaxCategoryChoices)(model);
382
+ // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
383
+ this.updateModel({
384
+ correctResponse,
385
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
386
+ });
387
+ });
388
+ (0, _defineProperty2.default)(this, "deleteChoiceFromAlternateCategory", (category, choice, choiceIndex, altIndex) => {
389
+ const {
390
+ model
391
+ } = this.props;
392
+ const correctResponse = (0, _categorize.removeChoiceFromAlternate)(choice.id, category.id, choiceIndex, altIndex, model.correctResponse);
393
+ this.updateModel({
394
+ correctResponse
395
+ });
396
+ });
397
+ (0, _defineProperty2.default)(this, "renderDragOverlay", () => {
398
+ const {
399
+ activeDragItem
400
+ } = this.state;
401
+ const {
402
+ model,
403
+ configuration
404
+ } = this.props;
405
+ if (!activeDragItem) return null;
406
+ if (activeDragItem.type === 'choice') {
407
+ const choice = model.choices?.find(c => c.id === activeDragItem.id);
408
+ if (!choice) return null;
409
+ return /*#__PURE__*/_react.default.createElement(_choice.default, {
410
+ choice: choice,
411
+ configuration: configuration
412
+ });
413
+ } else if (activeDragItem.type === 'choice-preview' && activeDragItem.alternateResponseIndex === undefined) {
414
+ const choice = model.choices?.find(c => c.id === activeDragItem.id);
415
+ if (!choice) return null;
416
+ return /*#__PURE__*/_react.default.createElement(_choicePreview.default, {
417
+ choice: choice
418
+ });
419
+ } else if (activeDragItem.type === 'choice-preview' && activeDragItem.alternateResponseIndex !== undefined) {
420
+ const choice = model.choices?.find(c => c.id === activeDragItem.id);
421
+ if (!choice) return null;
422
+ return /*#__PURE__*/_react.default.createElement(_choicePreview.default, {
423
+ choice: choice,
424
+ alternateResponseIndex: activeDragItem.alternateResponseIndex
425
+ });
426
+ }
427
+ return null;
428
+ });
429
+ this.uid = _props.uid || _drag.uid.generateId();
430
+ this.state = {
431
+ activeDragItem: null
432
+ };
433
+ }
434
+ render() {
435
+ const {
436
+ configuration,
437
+ imageSupport,
438
+ model,
439
+ uploadSoundSupport,
440
+ onConfigurationChanged
441
+ } = this.props;
442
+ const {
443
+ allowAlternate = {},
444
+ allowMultiplePlacements = {},
445
+ baseInputConfiguration = {},
446
+ categoriesPerRow = {},
447
+ choicesPosition = {},
448
+ contentDimensions = {},
449
+ feedback = {},
450
+ lockChoiceOrder = {},
451
+ maxImageHeight = {},
452
+ maxImageWidth = {},
453
+ maxPlacements = {},
454
+ minCategoriesPerRow = 1,
455
+ partialScoring = {},
456
+ prompt = {},
457
+ rationale = {},
458
+ scoringType = {},
459
+ settingsPanelDisabled,
460
+ spellCheck = {},
461
+ studentInstructions = {},
462
+ teacherInstructions = {},
463
+ withRubric = {},
464
+ mathMlOptions = {},
465
+ language = {},
466
+ languageChoices = {},
467
+ allowMaxAnswerChoices = {}
468
+ } = configuration || {};
469
+ const {
470
+ allowAlternateEnabled,
471
+ allowMaxChoicesPerCategory,
472
+ errors,
473
+ feedbackEnabled,
474
+ maxChoicesPerCategory,
475
+ promptEnabled,
476
+ rationaleEnabled,
477
+ spellCheckEnabled,
478
+ teacherInstructionsEnabled,
479
+ toolbarEditorPosition,
480
+ extraCSSRules
481
+ } = model || {};
482
+ const {
483
+ prompt: promptError,
484
+ rationale: rationaleError,
485
+ teacherInstructions: teacherInstructionsError
486
+ } = errors || {};
487
+ const toolbarOpts = {
488
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
489
+ };
490
+ const config = model.config || {};
491
+ config.choices = config.choices || {
492
+ label: '',
493
+ columns: 2
494
+ };
495
+ const categories = (0, _builder.buildCategories)(model.categories || [], model.choices || [], model.correctResponse || []);
496
+ const alternateResponses = (0, _builder.buildAlternateResponses)(model.categories || [], model.choices || [], model.correctResponse || []);
497
+ const choices = model.choices.map(c => {
498
+ c.correctResponseCount = this.countChoiceInCorrectResponse(c);
499
+ // ensure categoryCount is set even though updatedModel hasn't been called
500
+ c.categoryCount = this.checkAllowMultiplePlacements(model.allowMultiplePlacementsEnabled, c);
501
+ return c;
502
+ });
503
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
504
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
505
+ const panelSettings = {
506
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
507
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
508
+ categoriesPerRow: categoriesPerRow.settings && numberField(categoriesPerRow.label, {
509
+ label: categoriesPerRow.label,
510
+ min: minCategoriesPerRow,
511
+ max: 6
512
+ }),
513
+ choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),
514
+ allowMultiplePlacementsEnabled: allowMultiplePlacements.settings && dropdown(allowMultiplePlacements.label, [_utils2.multiplePlacements.enabled, _utils2.multiplePlacements.disabled, _utils2.multiplePlacements.perChoice]),
515
+ maxAnswerChoices: allowMaxAnswerChoices.settings && numberField(allowMaxAnswerChoices.label, {
516
+ label: '',
517
+ min: choices?.length || 0,
518
+ max: 30
519
+ }),
520
+ allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),
521
+ maxChoicesPerCategory: allowMaxChoicesPerCategory === true && numberField(maxPlacements.label, {
522
+ label: '',
523
+ min: 0,
524
+ max: 30
525
+ }),
526
+ promptEnabled: prompt.settings && toggle(prompt.label),
527
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
528
+ allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),
529
+ 'language.enabled': language.settings && toggle(language.label, true),
530
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
531
+ };
532
+ const panelProperties = {
533
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
534
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
535
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
536
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
537
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
538
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
539
+ };
540
+ const isOpened = this.isAlertModalOpened();
541
+ const alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {
542
+ lng: model.language,
543
+ maxChoicesPerCategory
544
+ });
545
+ return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, {
546
+ onDragStart: this.onDragStart,
547
+ onDragEnd: this.onDragEnd
548
+ }, /*#__PURE__*/_react.default.createElement(IdProvider, {
549
+ value: this.uid
550
+ }, /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
551
+ extraCSSRules: extraCSSRules,
552
+ dimensions: contentDimensions,
553
+ hideSettings: settingsPanelDisabled,
554
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
418
555
  model: model,
419
- categories: categories || [],
420
- onModelChanged: this.updateModel,
421
- toolbarOpts: toolbarOpts,
422
- spellCheck: spellCheckEnabled,
556
+ onChangeModel: this.updateModel,
423
557
  configuration: configuration,
424
- defaultImageMaxWidth: defaultImageMaxWidth,
425
- defaultImageMaxHeight: defaultImageMaxHeight,
426
- mathMlOptions: mathMlOptions
427
- }), /*#__PURE__*/_react["default"].createElement(_choices["default"], {
558
+ onChangeConfiguration: onConfigurationChanged,
559
+ groups: {
560
+ Settings: panelSettings,
561
+ Properties: panelProperties
562
+ },
563
+ modal: /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
564
+ title: 'Warning',
565
+ text: alertMaxChoicesMsg,
566
+ open: isOpened,
567
+ onClose: this.onAlertModalCancel
568
+ })
569
+ })
570
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
571
+ label: teacherInstructions.label
572
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
573
+ markup: model.teacherInstructions || '',
574
+ onChange: this.changeTeacherInstructions,
575
+ imageSupport: imageSupport,
576
+ error: teacherInstructionsError,
577
+ nonEmpty: false,
578
+ toolbarOpts: toolbarOpts,
579
+ pluginProps: (0, _utils.getPluginProps)(teacherInstructions?.inputConfiguration, baseInputConfiguration),
580
+ spellCheck: spellCheckEnabled,
581
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
582
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
583
+ uploadSoundSupport: uploadSoundSupport,
584
+ languageCharactersProps: [{
585
+ language: 'spanish'
586
+ }, {
587
+ language: 'special'
588
+ }],
589
+ mathMlOptions: mathMlOptions
590
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
591
+ label: prompt.label
592
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
593
+ markup: model.prompt || '',
594
+ onChange: this.onPromptChanged,
595
+ imageSupport: imageSupport,
596
+ error: promptError,
597
+ nonEmpty: false,
598
+ disableUnderline: true,
599
+ toolbarOpts: toolbarOpts,
600
+ pluginProps: (0, _utils.getPluginProps)(prompt?.inputConfiguration, baseInputConfiguration),
601
+ spellCheck: spellCheckEnabled,
602
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
603
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
604
+ uploadSoundSupport: uploadSoundSupport,
605
+ languageCharactersProps: [{
606
+ language: 'spanish'
607
+ }, {
608
+ language: 'special'
609
+ }],
610
+ mathMlOptions: mathMlOptions
611
+ }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError)), /*#__PURE__*/_react.default.createElement(_categories.default, {
612
+ imageSupport: imageSupport,
613
+ uploadSoundSupport: uploadSoundSupport,
614
+ model: model,
615
+ categories: categories || [],
616
+ onModelChanged: this.updateModel,
617
+ toolbarOpts: toolbarOpts,
618
+ spellCheck: spellCheckEnabled,
619
+ configuration: configuration,
620
+ defaultImageMaxWidth: defaultImageMaxWidth,
621
+ defaultImageMaxHeight: defaultImageMaxHeight,
622
+ mathMlOptions: mathMlOptions
623
+ }), /*#__PURE__*/_react.default.createElement(_choices.default, {
624
+ imageSupport: imageSupport,
625
+ uploadSoundSupport: uploadSoundSupport,
626
+ choices: choices,
627
+ model: model,
628
+ onModelChanged: this.updateModel,
629
+ toolbarOpts: toolbarOpts,
630
+ spellCheck: spellCheckEnabled,
631
+ configuration: configuration,
632
+ defaultImageMaxWidth: defaultImageMaxWidth,
633
+ defaultImageMaxHeight: defaultImageMaxHeight
634
+ }), allowAlternateEnabled && /*#__PURE__*/_react.default.createElement(StyledHeader, {
635
+ label: "Alternate Responses",
636
+ buttonLabel: "ADD AN ALTERNATE RESPONSE",
637
+ onAdd: this.onAddAlternateResponse
638
+ }), allowAlternateEnabled && alternateResponses.map((categoriesList, index) => {
639
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
640
+ key: index
641
+ }, /*#__PURE__*/_react.default.createElement(StyledHeader, {
642
+ variant: 'subtitle1',
643
+ label: "Alternate Response",
644
+ buttonLabel: "REMOVE ALTERNATE RESPONSE",
645
+ onAdd: () => this.onRemoveAlternateResponse(index)
646
+ }), /*#__PURE__*/_react.default.createElement(_alternateResponses.default, {
647
+ altIndex: index,
428
648
  imageSupport: imageSupport,
429
- uploadSoundSupport: uploadSoundSupport,
430
- choices: choices,
431
649
  model: model,
432
- onModelChanged: this.updateModel,
433
- toolbarOpts: toolbarOpts,
434
- spellCheck: spellCheckEnabled,
435
650
  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,
651
+ categories: categoriesList,
652
+ onModelChanged: this.updateModel,
479
653
  uploadSoundSupport: uploadSoundSupport,
480
- languageCharactersProps: [{
481
- language: 'spanish'
482
- }, {
483
- language: 'special'
484
- }],
485
654
  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
-
655
+ }));
656
+ }), rationaleEnabled && /*#__PURE__*/_react.default.createElement(StyledInputContainer, {
657
+ label: rationale.label
658
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
659
+ markup: model.rationale || '',
660
+ onChange: this.changeRationale,
661
+ imageSupport: imageSupport,
662
+ error: rationaleError,
663
+ nonEmpty: false,
664
+ toolbarOpts: toolbarOpts,
665
+ pluginProps: (0, _utils.getPluginProps)(prompt?.inputConfiguration, baseInputConfiguration),
666
+ spellCheck: spellCheckEnabled,
667
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
668
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
669
+ uploadSoundSupport: uploadSoundSupport,
670
+ languageCharactersProps: [{
671
+ language: 'spanish'
672
+ }, {
673
+ language: 'special'
674
+ }],
675
+ mathMlOptions: mathMlOptions
676
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError)), feedbackEnabled && /*#__PURE__*/_react.default.createElement(_configUi.FeedbackConfig, {
677
+ feedback: model.feedback,
678
+ onChange: this.changeFeedback,
679
+ toolbarOpts: toolbarOpts
680
+ })), /*#__PURE__*/_react.default.createElement(_core.DragOverlay, null, /*#__PURE__*/_react.default.createElement(DragPreviewWrapper, null, this.renderDragOverlay()))));
681
+ }
682
+ }
498
683
  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
684
+ (0, _defineProperty2.default)(Design, "propTypes", {
685
+ configuration: _propTypes.default.object,
686
+ className: _propTypes.default.string,
687
+ onConfigurationChanged: _propTypes.default.func,
688
+ model: _propTypes.default.object.isRequired,
689
+ onChange: _propTypes.default.func.isRequired,
690
+ uid: _propTypes.default.string,
691
+ imageSupport: _propTypes.default.shape({
692
+ add: _propTypes.default.func.isRequired,
693
+ delete: _propTypes.default.func.isRequired
510
694
  }),
511
- uploadSoundSupport: _propTypes["default"].shape({
512
- add: _propTypes["default"].func.isRequired,
513
- "delete": _propTypes["default"].func.isRequired
695
+ uploadSoundSupport: _propTypes.default.shape({
696
+ add: _propTypes.default.func.isRequired,
697
+ delete: _propTypes.default.func.isRequired
514
698
  })
515
699
  });
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;
700
+ var _default = exports.default = Design;
545
701
  //# sourceMappingURL=index.js.map