@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.
- package/configure/lib/defaults.js +2 -5
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/design/builder.js +15 -33
- package/configure/lib/design/builder.js.map +1 -1
- package/configure/lib/design/buttons.js +41 -95
- package/configure/lib/design/buttons.js.map +1 -1
- package/configure/lib/design/categories/RowLabel.js +32 -45
- package/configure/lib/design/categories/RowLabel.js.map +1 -1
- package/configure/lib/design/categories/alternateResponses.js +96 -251
- package/configure/lib/design/categories/alternateResponses.js.map +1 -1
- package/configure/lib/design/categories/category.js +135 -208
- package/configure/lib/design/categories/category.js.map +1 -1
- package/configure/lib/design/categories/choice-preview.js +61 -126
- package/configure/lib/design/categories/choice-preview.js.map +1 -1
- package/configure/lib/design/categories/droppable-placeholder.js +73 -165
- package/configure/lib/design/categories/droppable-placeholder.js.map +1 -1
- package/configure/lib/design/categories/index.js +195 -384
- package/configure/lib/design/categories/index.js.map +1 -1
- package/configure/lib/design/choices/choice.js +155 -264
- package/configure/lib/design/choices/choice.js.map +1 -1
- package/configure/lib/design/choices/config.js +42 -98
- package/configure/lib/design/choices/config.js.map +1 -1
- package/configure/lib/design/choices/index.js +148 -236
- package/configure/lib/design/choices/index.js.map +1 -1
- package/configure/lib/design/header.js +57 -111
- package/configure/lib/design/header.js.map +1 -1
- package/configure/lib/design/index.js +631 -476
- package/configure/lib/design/index.js.map +1 -1
- package/configure/lib/design/input-header.js +93 -149
- package/configure/lib/design/input-header.js.map +1 -1
- package/configure/lib/design/utils.js +4 -15
- package/configure/lib/design/utils.js.map +1 -1
- package/configure/lib/index.js +120 -183
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +30 -74
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/utils.js +22 -32
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +15 -15
- package/controller/lib/defaults.js +2 -5
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +237 -318
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +28 -65
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +5 -5
- package/lib/categorize/categories.js +106 -164
- package/lib/categorize/categories.js.map +1 -1
- package/lib/categorize/category.js +73 -123
- package/lib/categorize/category.js.map +1 -1
- package/lib/categorize/choice.js +118 -245
- package/lib/categorize/choice.js.map +1 -1
- package/lib/categorize/choices.js +66 -131
- package/lib/categorize/choices.js.map +1 -1
- package/lib/categorize/droppable-placeholder.js +46 -103
- package/lib/categorize/droppable-placeholder.js.map +1 -1
- package/lib/categorize/grid-content.js +39 -87
- package/lib/categorize/grid-content.js.map +1 -1
- package/lib/categorize/index.js +341 -317
- package/lib/categorize/index.js.map +1 -1
- package/lib/index.js +285 -306
- package/lib/index.js.map +1 -1
- package/package.json +16 -14
package/configure/lib/index.js
CHANGED
|
@@ -1,210 +1,147 @@
|
|
|
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
|
|
9
|
-
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
|
|
23
|
-
|
|
7
|
+
exports.default = void 0;
|
|
24
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
9
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
29
|
-
|
|
10
|
+
var _client = require("react-dom/client");
|
|
30
11
|
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
31
|
-
|
|
32
12
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
33
|
-
|
|
34
13
|
var _main = _interopRequireDefault(require("./main"));
|
|
35
|
-
|
|
36
14
|
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
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); }; }
|
|
45
|
-
|
|
46
|
-
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; } }
|
|
47
|
-
|
|
48
|
-
var CategorizeConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
49
|
-
(0, _inherits2["default"])(CategorizeConfigure, _HTMLElement);
|
|
50
|
-
|
|
51
|
-
var _super = _createSuper(CategorizeConfigure);
|
|
52
|
-
|
|
53
|
-
// PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)
|
|
54
|
-
// this function is used in controller, too
|
|
55
|
-
function CategorizeConfigure() {
|
|
56
|
-
var _this;
|
|
57
|
-
|
|
58
|
-
(0, _classCallCheck2["default"])(this, CategorizeConfigure);
|
|
59
|
-
_this = _super.call(this);
|
|
60
|
-
_this._model = CategorizeConfigure.createDefaultModel();
|
|
61
|
-
_this._configuration = _defaults["default"].configuration;
|
|
62
|
-
return _this;
|
|
15
|
+
class CategorizeConfigure extends HTMLElement {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this._root = null;
|
|
19
|
+
this._model = CategorizeConfigure.createDefaultModel();
|
|
20
|
+
this._configuration = _defaults.default.configuration;
|
|
63
21
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (m.choices && m.choices.length >= m.maxAnswerChoices) {
|
|
71
|
-
this._model.maxAnswerChoices = m.choices.length;
|
|
72
|
-
console.warn("Max Answer Choices can't be less than choices length!");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
this.render();
|
|
22
|
+
set model(m) {
|
|
23
|
+
this._model = CategorizeConfigure.createDefaultModel(m);
|
|
24
|
+
if (m.choices && m.choices.length >= m.maxAnswerChoices) {
|
|
25
|
+
this._model.maxAnswerChoices = m.choices.length;
|
|
26
|
+
console.warn("Max Answer Choices can't be less than choices length!");
|
|
76
27
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this._configuration.
|
|
98
|
-
|
|
99
|
-
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
100
|
-
this._configuration.languageChoices.options = [];
|
|
101
|
-
} // check if the language is already included in the languageChoices.options array
|
|
102
|
-
// and if not, then add it.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (!this._configuration.languageChoices.options.find(function (option) {
|
|
106
|
-
return option.value === _this2._model.language;
|
|
107
|
-
})) {
|
|
108
|
-
this._configuration.languageChoices.options.push({
|
|
109
|
-
value: this._model.language,
|
|
110
|
-
label: this._model.language
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
delete this._model.language;
|
|
28
|
+
this.render();
|
|
29
|
+
}
|
|
30
|
+
set configuration(c) {
|
|
31
|
+
const newConfiguration = {
|
|
32
|
+
..._defaults.default.configuration,
|
|
33
|
+
...c
|
|
34
|
+
};
|
|
35
|
+
this._configuration = newConfiguration;
|
|
36
|
+
|
|
37
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
38
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
39
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
40
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
41
|
+
if (newConfiguration?.language?.enabled) {
|
|
42
|
+
if (newConfiguration?.languageChoices?.options?.length) {
|
|
43
|
+
this._model.language = newConfiguration?.languageChoices.options[0].value;
|
|
44
|
+
}
|
|
45
|
+
} else if (newConfiguration.language.settings && this._model.language) {
|
|
46
|
+
this._configuration.language.enabled = true;
|
|
47
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
48
|
+
this._configuration.languageChoices.options = [];
|
|
115
49
|
}
|
|
116
50
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
key: "onConfigurationChanged",
|
|
128
|
-
value: function onConfigurationChanged(c) {
|
|
129
|
-
this._configuration = c;
|
|
130
|
-
this.render();
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
133
|
-
key: "connectedCallback",
|
|
134
|
-
value: function connectedCallback() {
|
|
135
|
-
this.render();
|
|
51
|
+
// check if the language is already included in the languageChoices.options array
|
|
52
|
+
// and if not, then add it.
|
|
53
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
54
|
+
this._configuration.languageChoices.options.push({
|
|
55
|
+
value: this._model.language,
|
|
56
|
+
label: this._model.language
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
delete this._model.language;
|
|
136
61
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
62
|
+
this.render();
|
|
63
|
+
}
|
|
64
|
+
onModelChanged(m) {
|
|
65
|
+
this._model = m;
|
|
66
|
+
this.render();
|
|
67
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model, false));
|
|
68
|
+
}
|
|
69
|
+
onConfigurationChanged(c) {
|
|
70
|
+
this._configuration = c;
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
connectedCallback() {
|
|
74
|
+
this.render();
|
|
75
|
+
}
|
|
141
76
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @param {done, progress, file} handler
|
|
80
|
+
*/
|
|
81
|
+
insertImage(handler) {
|
|
82
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
|
|
83
|
+
}
|
|
84
|
+
onDeleteImage(src, done) {
|
|
85
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
86
|
+
}
|
|
87
|
+
insertSound(handler) {
|
|
88
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
89
|
+
}
|
|
90
|
+
onDeleteSound(src, done) {
|
|
91
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
92
|
+
}
|
|
93
|
+
render() {
|
|
94
|
+
const el = /*#__PURE__*/_react.default.createElement(_main.default, {
|
|
95
|
+
model: this._model,
|
|
96
|
+
configuration: this._configuration,
|
|
97
|
+
onModelChanged: this.onModelChanged.bind(this),
|
|
98
|
+
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
99
|
+
imageSupport: {
|
|
100
|
+
add: this.insertImage.bind(this),
|
|
101
|
+
delete: this.onDeleteImage.bind(this)
|
|
102
|
+
},
|
|
103
|
+
uploadSoundSupport: {
|
|
104
|
+
add: this.insertSound.bind(this),
|
|
105
|
+
delete: this.onDeleteSound.bind(this)
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
if (!this._root) {
|
|
109
|
+
this._root = (0, _client.createRoot)(this);
|
|
161
110
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
onModelChanged: this.onModelChanged.bind(this),
|
|
171
|
-
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
172
|
-
imageSupport: {
|
|
173
|
-
add: this.insertImage.bind(this),
|
|
174
|
-
"delete": this.onDeleteImage.bind(this)
|
|
175
|
-
},
|
|
176
|
-
uploadSoundSupport: {
|
|
177
|
-
add: this.insertSound.bind(this),
|
|
178
|
-
"delete": this.onDeleteSound.bind(this)
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
_reactDom["default"].render(el, this, function () {
|
|
183
|
-
(0, _mathRendering.renderMath)(_this3);
|
|
184
|
-
});
|
|
111
|
+
this._root.render(el);
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
(0, _mathRendering.renderMath)(this);
|
|
114
|
+
}, 0);
|
|
115
|
+
}
|
|
116
|
+
disconnectedCallback() {
|
|
117
|
+
if (this._root) {
|
|
118
|
+
this._root.unmount();
|
|
185
119
|
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
(0, _defineProperty2
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.default = CategorizeConfigure;
|
|
123
|
+
(0, _defineProperty2.default)(CategorizeConfigure, "createDefaultModel", (model = {}) => ({
|
|
124
|
+
..._defaults.default.model,
|
|
125
|
+
...model
|
|
126
|
+
}));
|
|
127
|
+
// PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)
|
|
128
|
+
// this function is used in controller, too
|
|
129
|
+
(0, _defineProperty2.default)(CategorizeConfigure, "disableAlternateResponses", m => {
|
|
130
|
+
let {
|
|
131
|
+
correctResponse
|
|
132
|
+
} = m || {};
|
|
199
133
|
correctResponse = correctResponse || [];
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
134
|
+
const mappedCorrectResponse = correctResponse.map(cr => {
|
|
135
|
+
const {
|
|
136
|
+
alternateResponses,
|
|
137
|
+
...response
|
|
138
|
+
} = cr;
|
|
203
139
|
return response;
|
|
204
140
|
});
|
|
205
|
-
return
|
|
141
|
+
return {
|
|
142
|
+
...m,
|
|
206
143
|
correctResponse: mappedCorrectResponse,
|
|
207
144
|
allowAlternateEnabled: false
|
|
208
|
-
}
|
|
145
|
+
};
|
|
209
146
|
});
|
|
210
147
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["CategorizeConfigure","_model","createDefaultModel","_configuration","defaults","configuration","m","choices","length","maxAnswerChoices","console","warn","render","c","newConfiguration","language","enabled","languageChoices","options","value","settings","find","option","push","label","dispatchEvent","ModelUpdatedEvent","handler","InsertImageEvent","src","done","DeleteImageEvent","InsertSoundEvent","DeleteSoundEvent","el","React","createElement","Main","model","onModelChanged","bind","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","HTMLElement","correctResponse","mappedCorrectResponse","map","cr","alternateResponses","response","allowAlternateEnabled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAOA;;AAEA;;AAEA;;;;;;;;;;;;IAEqBA,mB;;;;;AAMnB;AACA;AAeA,iCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAcD,mBAAmB,CAACE,kBAApB,EAAd;AACA,UAAKC,cAAL,GAAsBC,qBAASC,aAA/B;AAHY;AAIb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKL,MAAL,GAAcD,mBAAmB,CAACE,kBAApB,CAAuCI,CAAvC,CAAd;;AAEA,UAAIA,CAAC,CAACC,OAAF,IAAaD,CAAC,CAACC,OAAF,CAAUC,MAAV,IAAoBF,CAAC,CAACG,gBAAvC,EAAyD;AACvD,aAAKR,MAAL,CAAYQ,gBAAZ,GAA+BH,CAAC,CAACC,OAAF,CAAUC,MAAzC;AACAE,QAAAA,OAAO,CAACC,IAAR,CAAa,uDAAb;AACD;;AAED,WAAKC,MAAL;AACD;;;SAED,aAAkBC,CAAlB,EAAqB;AAAA;AAAA;;AACnB,UAAMC,gBAAgB,mCACjBV,qBAASC,aADQ,GAEjBQ,CAFiB,CAAtB;;AAKA,WAAKV,cAAL,GAAsBW,gBAAtB,CANmB,CAQnB;AACA;AACA;AACA;;AACA,UAAIA,gBAAJ,aAAIA,gBAAJ,wCAAIA,gBAAgB,CAAEC,Q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B;AASnCM,QAAAA,kBAAkB,EAAE;AAClBH,UAAAA,GAAG,EAAE,KAAKI,WAAL,CAAiBP,IAAjB,CAAsB,IAAtB,CADa;AAElB,oBAAQ,KAAKQ,aAAL,CAAmBR,IAAnB,CAAwB,IAAxB;AAFU;AATe,OAA1B,CAAX;;AAeAS,2BAASrC,MAAT,CAAgBsB,EAAhB,EAAoB,IAApB,EAA0B,YAAM;AAC9B,uCAAW,MAAX;AACD,OAFD;AAGD;;;kDApI8CgB,W;;;iCAA5BlD,mB,wBACS;AAAA,MAACsC,KAAD,uEAAS,EAAT;AAAA,yCACvBlC,qBAASkC,KADc,GAEvBA,KAFuB;AAAA,C;iCADTtC,mB,+BAQgB,UAACM,CAAD,EAAO;AACxC,aAA0BA,CAAC,IAAI,EAA/B;AAAA,MAAM6C,eAAN,QAAMA,eAAN;;AACAA,EAAAA,eAAe,GAAGA,eAAe,IAAI,EAArC;AACA,MAAMC,qBAAqB,GAAGD,eAAe,CAACE,GAAhB,CAAoB,UAACC,EAAD,EAAQ;AACxD,QAAQC,kBAAR,GAA4CD,EAA5C,CAAQC,kBAAR;AAAA,QAA+BC,QAA/B,6CAA4CF,EAA5C;AACA,WAAOE,QAAP;AACD,GAH6B,CAA9B;AAIA,yCACKlD,CADL;AAEE6C,IAAAA,eAAe,EAAEC,qBAFnB;AAGEK,IAAAA,qBAAqB,EAAE;AAHzB;AAKD,C","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport Main from './main';\n\nimport defaults from './defaults';\n\nexport default class CategorizeConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...defaults.model,\n ...model,\n });\n\n // PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)\n // this function is used in controller, too\n static disableAlternateResponses = (m) => {\n let { correctResponse } = m || {};\n correctResponse = correctResponse || [];\n const mappedCorrectResponse = correctResponse.map((cr) => {\n const { alternateResponses, ...response } = cr;\n return response;\n });\n return {\n ...m,\n correctResponse: mappedCorrectResponse,\n allowAlternateEnabled: false,\n };\n };\n\n constructor() {\n super();\n this._model = CategorizeConfigure.createDefaultModel();\n this._configuration = defaults.configuration;\n }\n\n set model(m) {\n this._model = CategorizeConfigure.createDefaultModel(m);\n\n if (m.choices && m.choices.length >= m.maxAnswerChoices) {\n this._model.maxAnswerChoices = m.choices.length;\n console.warn(\"Max Answer Choices can't be less than choices length!\");\n }\n\n this.render();\n }\n\n set configuration(c) {\n const newConfiguration = {\n ...defaults.configuration,\n ...c,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this.render();\n }\n\n onModelChanged(m) {\n this._model = m;\n\n this.render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model, false));\n }\n\n onConfigurationChanged(c) {\n this._configuration = c;\n this.render();\n }\n\n connectedCallback() {\n this.render();\n }\n\n /**\n *\n * @param {done, progress, file} handler\n */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n render() {\n const el = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n ReactDOM.render(el, this, () => {\n renderMath(this);\n });\n }\n}\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_pieConfigureEvents","_mathRendering","_main","_defaults","CategorizeConfigure","HTMLElement","constructor","_root","_model","createDefaultModel","_configuration","defaults","configuration","model","m","choices","length","maxAnswerChoices","console","warn","render","c","newConfiguration","language","enabled","languageChoices","options","value","settings","find","option","push","label","onModelChanged","dispatchEvent","ModelUpdatedEvent","onConfigurationChanged","connectedCallback","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","el","React","createElement","Main","bind","imageSupport","add","delete","uploadSoundSupport","createRoot","setTimeout","renderMath","disconnectedCallback","unmount","exports","default","_defineProperty2","correctResponse","mappedCorrectResponse","map","cr","alternateResponses","response","allowAlternateEnabled"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport Main from './main';\n\nimport defaults from './defaults';\n\nexport default class CategorizeConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...defaults.model,\n ...model,\n });\n\n // PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)\n // this function is used in controller, too\n static disableAlternateResponses = (m) => {\n let { correctResponse } = m || {};\n correctResponse = correctResponse || [];\n const mappedCorrectResponse = correctResponse.map((cr) => {\n const { alternateResponses, ...response } = cr;\n return response;\n });\n return {\n ...m,\n correctResponse: mappedCorrectResponse,\n allowAlternateEnabled: false,\n };\n };\n\n constructor() {\n super();\n this._root = null;\n this._model = CategorizeConfigure.createDefaultModel();\n this._configuration = defaults.configuration;\n }\n\n set model(m) {\n this._model = CategorizeConfigure.createDefaultModel(m);\n\n if (m.choices && m.choices.length >= m.maxAnswerChoices) {\n this._model.maxAnswerChoices = m.choices.length;\n console.warn(\"Max Answer Choices can't be less than choices length!\");\n }\n\n this.render();\n }\n\n set configuration(c) {\n const newConfiguration = {\n ...defaults.configuration,\n ...c,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find((option) => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this.render();\n }\n\n onModelChanged(m) {\n this._model = m;\n\n this.render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model, false));\n }\n\n onConfigurationChanged(c) {\n this._configuration = c;\n this.render();\n }\n\n connectedCallback() {\n this.render();\n }\n\n /**\n *\n * @param {done, progress, file} handler\n */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n render() {\n const el = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(el);\n\n setTimeout(() => {\n renderMath(this);\n }, 0);\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAOA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,KAAA,GAAAL,sBAAA,CAAAC,OAAA;AAEA,IAAAK,SAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEe,MAAMM,mBAAmB,SAASC,WAAW,CAAC;EAsB3DC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,MAAM,GAAGJ,mBAAmB,CAACK,kBAAkB,CAAC,CAAC;IACtD,IAAI,CAACC,cAAc,GAAGC,iBAAQ,CAACC,aAAa;EAC9C;EAEA,IAAIC,KAAKA,CAACC,CAAC,EAAE;IACX,IAA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iBAAQ,CAACE,KAAK;EACjB,GAAGA;AACL,CAAC,CAAC;AAEF;AACA;AAAA,IAAAoD,gBAAA,CAAAD,OAAA,EAPmB5D,mBAAmB,+BAQFU,CAAC,IAAK;EACxC,IAAI;IAAEoD;EAAgB,CAAC,GAAGpD,CAAC,IAAI,CAAC,CAAC;EACjCoD,eAAe,GAAGA,eAAe,IAAI,EAAE;EACvC,MAAMC,qBAAqB,GAAGD,eAAe,CAACE,GAAG,CAAEC,EAAE,IAAK;IACxD,MAAM;MAAEC,kBAAkB;MAAE,GAAGC;IAAS,CAAC,GAAGF,EAAE;IAC9C,OAAOE,QAAQ;EACjB,CAAC,CAAC;EACF,OAAO;IACL,GAAGzD,CAAC;IACJoD,eAAe,EAAEC,qBAAqB;IACtCK,qBAAqB,EAAE;EACzB,CAAC;AACH,CAAC","ignoreList":[]}
|
package/configure/lib/main.js
CHANGED
|
@@ -1,88 +1,44 @@
|
|
|
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
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
|
|
16
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
|
|
7
|
+
exports.default = exports.Main = void 0;
|
|
20
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
-
|
|
22
9
|
var _react = _interopRequireDefault(require("react"));
|
|
23
|
-
|
|
24
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
25
|
-
|
|
26
|
-
var _styles = require("@material-ui/core/styles");
|
|
27
|
-
|
|
28
11
|
var _design = _interopRequireDefault(require("./design"));
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
12
|
+
class Main extends _react.default.Component {
|
|
13
|
+
render() {
|
|
14
|
+
const {
|
|
15
|
+
model,
|
|
16
|
+
onModelChanged,
|
|
17
|
+
configuration,
|
|
18
|
+
onConfigurationChanged,
|
|
19
|
+
imageSupport,
|
|
20
|
+
uploadSoundSupport
|
|
21
|
+
} = this.props;
|
|
22
|
+
return /*#__PURE__*/_react.default.createElement(_design.default, {
|
|
23
|
+
imageSupport: imageSupport,
|
|
24
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
25
|
+
title: "Design",
|
|
26
|
+
model: model,
|
|
27
|
+
configuration: configuration,
|
|
28
|
+
onChange: onModelChanged,
|
|
29
|
+
onConfigurationChanged: onConfigurationChanged
|
|
30
|
+
});
|
|
42
31
|
}
|
|
43
|
-
|
|
44
|
-
(0, _createClass2["default"])(Main, [{
|
|
45
|
-
key: "render",
|
|
46
|
-
value: function render() {
|
|
47
|
-
var _this$props = this.props,
|
|
48
|
-
model = _this$props.model,
|
|
49
|
-
onModelChanged = _this$props.onModelChanged,
|
|
50
|
-
configuration = _this$props.configuration,
|
|
51
|
-
onConfigurationChanged = _this$props.onConfigurationChanged,
|
|
52
|
-
imageSupport = _this$props.imageSupport,
|
|
53
|
-
uploadSoundSupport = _this$props.uploadSoundSupport;
|
|
54
|
-
return /*#__PURE__*/_react["default"].createElement(_design["default"], {
|
|
55
|
-
imageSupport: imageSupport,
|
|
56
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
57
|
-
title: "Design",
|
|
58
|
-
model: model,
|
|
59
|
-
configuration: configuration,
|
|
60
|
-
onChange: onModelChanged,
|
|
61
|
-
onConfigurationChanged: onConfigurationChanged
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}]);
|
|
65
|
-
return Main;
|
|
66
|
-
}(_react["default"].Component);
|
|
67
|
-
|
|
32
|
+
}
|
|
68
33
|
exports.Main = Main;
|
|
69
|
-
(0, _defineProperty2
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
imageSupport: _propTypes["default"].object,
|
|
77
|
-
uploadSoundSupport: _propTypes["default"].object
|
|
34
|
+
(0, _defineProperty2.default)(Main, "propTypes", {
|
|
35
|
+
configuration: _propTypes.default.object,
|
|
36
|
+
onConfigurationChanged: _propTypes.default.func,
|
|
37
|
+
model: _propTypes.default.object.isRequired,
|
|
38
|
+
onModelChanged: _propTypes.default.func.isRequired,
|
|
39
|
+
imageSupport: _propTypes.default.object,
|
|
40
|
+
uploadSoundSupport: _propTypes.default.object
|
|
78
41
|
});
|
|
79
|
-
(0, _defineProperty2
|
|
80
|
-
|
|
81
|
-
var styles = function styles() {
|
|
82
|
-
return {};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var _default = (0, _styles.withStyles)(styles)(Main);
|
|
86
|
-
|
|
87
|
-
exports["default"] = _default;
|
|
42
|
+
(0, _defineProperty2.default)(Main, "defaultProps", {});
|
|
43
|
+
var _default = exports.default = Main;
|
|
88
44
|
//# sourceMappingURL=main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_design","Main","React","Component","render","model","onModelChanged","configuration","onConfigurationChanged","imageSupport","uploadSoundSupport","props","default","createElement","title","onChange","exports","_defineProperty2","PropTypes","object","func","isRequired","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Design from './design';\n\nexport class Main extends React.Component {\n static propTypes = {\n configuration: PropTypes.object,\n onConfigurationChanged: PropTypes.func,\n model: PropTypes.object.isRequired,\n onModelChanged: PropTypes.func.isRequired,\n imageSupport: PropTypes.object,\n uploadSoundSupport: PropTypes.object,\n };\n\n static defaultProps = {};\n\n render() {\n const { model, onModelChanged, configuration, onConfigurationChanged, imageSupport, uploadSoundSupport } =\n this.props;\n\n return (\n <Design\n imageSupport={imageSupport}\n uploadSoundSupport={uploadSoundSupport}\n title=\"Design\"\n model={model}\n configuration={configuration}\n onChange={onModelChanged}\n onConfigurationChanged={onConfigurationChanged}\n />\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEO,MAAMG,IAAI,SAASC,cAAK,CAACC,SAAS,CAAC;EAYxCC,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEC,KAAK;MAAEC,cAAc;MAAEC,aAAa;MAAEC,sBAAsB;MAAEC,YAAY;MAAEC;IAAmB,CAAC,GACtG,IAAI,CAACC,KAAK;IAEZ,oBACEf,MAAA,CAAAgB,OAAA,CAAAC,aAAA,CAACb,OAAA,CAAAY,OAAM;MACLH,YAAY,EAAEA,YAAa;MAC3BC,kBAAkB,EAAEA,kBAAmB;MACvCI,KAAK,EAAC,QAAQ;MACdT,KAAK,EAAEA,KAAM;MACbE,aAAa,EAAEA,aAAc;MAC7BQ,QAAQ,EAAET,cAAe;MACzBE,sBAAsB,EAAEA;IAAuB,CAChD,CAAC;EAEN;AACF;AAACQ,OAAA,CAAAf,IAAA,GAAAA,IAAA;AAAA,IAAAgB,gBAAA,CAAAL,OAAA,EA5BYX,IAAI,eACI;EACjBM,aAAa,EAAEW,kBAAS,CAACC,MAAM;EAC/BX,sBAAsB,EAAEU,kBAAS,CAACE,IAAI;EACtCf,KAAK,EAAEa,kBAAS,CAACC,MAAM,CAACE,UAAU;EAClCf,cAAc,EAAEY,kBAAS,CAACE,IAAI,CAACC,UAAU;EACzCZ,YAAY,EAAES,kBAAS,CAACC,MAAM;EAC9BT,kBAAkB,EAAEQ,kBAAS,CAACC;AAChC,CAAC;AAAA,IAAAF,gBAAA,CAAAL,OAAA,EARUX,IAAI,kBAUO,CAAC,CAAC;AAAA,IAAAqB,QAAA,GAAAN,OAAA,CAAAJ,OAAA,GAoBXX,IAAI","ignoreList":[]}
|
package/configure/lib/utils.js
CHANGED
|
@@ -4,50 +4,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.multiplePlacements = exports.maxLength = exports.getMaxCategoryChoices = exports.generateValidationMessage = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const generateValidationMessage = config => {
|
|
8
|
+
let {
|
|
9
|
+
minChoices,
|
|
10
|
+
maxChoices,
|
|
11
|
+
maxCategories
|
|
12
|
+
} = config || {};
|
|
14
13
|
minChoices = minChoices || 1;
|
|
15
|
-
|
|
14
|
+
const validationMessage = '\nThe choices content should ' + 'not be empty and should be unique.\nThere should be at least 1 ' + (maxCategories ? `and at most ${maxCategories} ` : '') + 'category' + (maxCategories ? 's' : '') + ' defined.' + (minChoices ? `\nThere should be at least ${minChoices} choices defined.` : '') + (maxChoices ? `\nNo more than ${maxChoices} choices should be defined.` : '') + '\nAt least one token should be assigned to at least one category.';
|
|
16
15
|
return 'Validation requirements:' + validationMessage;
|
|
17
|
-
};
|
|
18
|
-
|
|
16
|
+
};
|
|
19
17
|
|
|
18
|
+
// used in controller too, for consistency modify it there too
|
|
20
19
|
exports.generateValidationMessage = generateValidationMessage;
|
|
21
|
-
|
|
20
|
+
const multiplePlacements = exports.multiplePlacements = {
|
|
22
21
|
enabled: 'Yes',
|
|
23
22
|
disabled: 'No',
|
|
24
23
|
perChoice: 'Set Per Choice'
|
|
25
|
-
}; // Find the length of the largest array from an array
|
|
26
|
-
|
|
27
|
-
exports.multiplePlacements = multiplePlacements;
|
|
28
|
-
|
|
29
|
-
var maxLength = function maxLength(array) {
|
|
30
|
-
return (array || []).reduce(function (max, arr) {
|
|
31
|
-
return Math.max(max, arr.length);
|
|
32
|
-
}, 0);
|
|
33
24
|
};
|
|
34
25
|
|
|
26
|
+
// Find the length of the largest array from an array
|
|
27
|
+
const maxLength = array => (array || []).reduce((max, arr) => {
|
|
28
|
+
return Math.max(max, arr.length);
|
|
29
|
+
}, 0);
|
|
35
30
|
exports.maxLength = maxLength;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var correctRespLength = (correctRes === null || correctRes === void 0 ? void 0 : (_correctRes$choices = correctRes.choices) === null || _correctRes$choices === void 0 ? void 0 : _correctRes$choices.length) || 0;
|
|
46
|
-
var alternates = (correctRes === null || correctRes === void 0 ? void 0 : correctRes.alternateResponses) || [];
|
|
47
|
-
var maxChoices = Math.max(correctRespLength, maxLength(alternates));
|
|
31
|
+
const getMaxCategoryChoices = model => {
|
|
32
|
+
const {
|
|
33
|
+
correctResponse = []
|
|
34
|
+
} = model || {};
|
|
35
|
+
return correctResponse.reduce((max, correctRes) => {
|
|
36
|
+
const correctRespLength = correctRes?.choices?.length || 0;
|
|
37
|
+
const alternates = correctRes?.alternateResponses || [];
|
|
38
|
+
const maxChoices = Math.max(correctRespLength, maxLength(alternates));
|
|
48
39
|
return maxChoices > max ? maxChoices : max;
|
|
49
40
|
}, 0);
|
|
50
41
|
};
|
|
51
|
-
|
|
52
42
|
exports.getMaxCategoryChoices = getMaxCategoryChoices;
|
|
53
43
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["generateValidationMessage","config","minChoices","maxChoices","maxCategories","validationMessage","exports","multiplePlacements","enabled","disabled","perChoice","maxLength","array","reduce","max","arr","Math","length","getMaxCategoryChoices","model","correctResponse","correctRes","correctRespLength","choices","alternates","alternateResponses"],"sources":["../src/utils.js"],"sourcesContent":["export const generateValidationMessage = (config) => {\n let { minChoices, maxChoices, maxCategories } = config || {};\n minChoices = minChoices || 1;\n\n const validationMessage =\n '\\nThe choices content should ' +\n 'not be empty and should be unique.\\nThere should be at least 1 ' +\n (maxCategories ? `and at most ${maxCategories} ` : '') +\n 'category' +\n (maxCategories ? 's' : '') +\n ' defined.' +\n (minChoices ? `\\nThere should be at least ${minChoices} choices defined.` : '') +\n (maxChoices ? `\\nNo more than ${maxChoices} choices should be defined.` : '') +\n '\\nAt least one token should be assigned to at least one category.';\n\n return 'Validation requirements:' + validationMessage;\n};\n\n// used in controller too, for consistency modify it there too\nexport const multiplePlacements = { enabled: 'Yes', disabled: 'No', perChoice: 'Set Per Choice' };\n\n// Find the length of the largest array from an array\nexport const maxLength = (array) =>\n (array || []).reduce((max, arr) => {\n return Math.max(max, arr.length);\n }, 0);\n\nexport const getMaxCategoryChoices = (model) => {\n const { correctResponse = [] } = model || {};\n return correctResponse.reduce((max, correctRes) => {\n const correctRespLength = correctRes?.choices?.length || 0;\n const alternates = correctRes?.alternateResponses || [];\n const maxChoices = Math.max(correctRespLength, maxLength(alternates));\n return maxChoices > max ? maxChoices : max;\n }, 0);\n};\n"],"mappings":";;;;;;AAAO,MAAMA,yBAAyB,GAAIC,MAAM,IAAK;EACnD,IAAI;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAc,CAAC,GAAGH,MAAM,IAAI,CAAC,CAAC;EAC5DC,UAAU,GAAGA,UAAU,IAAI,CAAC;EAE5B,MAAMG,iBAA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