@pie-element/image-cloze-association 3.5.0 → 3.5.1-beta.587
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/CHANGELOG.md +478 -0
- package/configure/CHANGELOG.md +390 -0
- package/configure/lib/defaults.js +16 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +17 -3
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/root.js +43 -13
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +4 -3
- package/configure/src/__tests__/index.test.js +12 -15
- package/configure/src/defaults.js +20 -4
- package/configure/src/index.js +23 -3
- package/configure/src/root.jsx +41 -25
- package/controller/CHANGELOG.md +63 -0
- package/controller/lib/index.js +9 -8
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +4 -4
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +2 -2
- package/controller/src/__tests__/index.test.js +108 -62
- package/controller/src/index.js +40 -28
- package/controller/src/utils.js +10 -10
- package/docs/config-schema.json +160 -0
- package/docs/config-schema.json.md +127 -0
- package/docs/demo/config.js +2 -2
- package/docs/demo/generate.js +30 -25
- package/docs/demo/session.js +1 -1
- package/docs/pie-schema.json +378 -0
- package/docs/pie-schema.json.md +295 -0
- package/lib/constants.js.map +1 -1
- package/lib/evaluation-icon.js.map +1 -1
- package/lib/image-container.js +13 -6
- package/lib/image-container.js.map +1 -1
- package/lib/image-drop-target.js +7 -2
- package/lib/image-drop-target.js.map +1 -1
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/interactive-section.js +1 -1
- package/lib/interactive-section.js.map +1 -1
- package/lib/possible-response.js +17 -5
- package/lib/possible-response.js.map +1 -1
- package/lib/possible-responses.js.map +1 -1
- package/lib/root.js +140 -19
- package/lib/root.js.map +1 -1
- package/lib/utils-correctness.js +33 -5
- package/lib/utils-correctness.js.map +1 -1
- package/package.json +8 -5
- package/src/__tests__/__snapshots__/{image-container-test.jsx.snap → image-container.test.jsx.snap} +20 -0
- package/src/__tests__/__snapshots__/possible-response.test.jsx.snap +5 -0
- package/src/__tests__/__snapshots__/root.test.jsx.snap +50 -0
- package/src/__tests__/{image-container-test.jsx → image-container.test.jsx} +12 -5
- package/src/__tests__/{possible-response-test.jsx → possible-response.test.jsx} +5 -3
- package/src/__tests__/{root-test.jsx → root.test.jsx} +4 -3
- package/src/__tests__/utils.test.js +207 -0
- package/src/constants.js +3 -3
- package/src/evaluation-icon.jsx +8 -17
- package/src/image-container.jsx +14 -19
- package/src/image-drop-target.jsx +45 -38
- package/src/index.js +10 -18
- package/src/interactive-section.jsx +15 -22
- package/src/possible-response.jsx +43 -23
- package/src/possible-responses.jsx +17 -25
- package/src/root.jsx +174 -100
- package/src/utils-correctness.js +44 -14
- package/src/__tests__/__snapshots__/possible-response-test.jsx.snap +0 -13
- package/src/__tests__/__snapshots__/root-test.jsx.snap +0 -38
- package/src/__tests__/utils-test.js +0 -211
package/lib/root.js
CHANGED
|
@@ -31,6 +31,16 @@ var _Typography = _interopRequireDefault(require("@material-ui/core/Typography")
|
|
|
31
31
|
|
|
32
32
|
var _drag = require("@pie-lib/drag");
|
|
33
33
|
|
|
34
|
+
var _reactTransitionGroup = require("react-transition-group");
|
|
35
|
+
|
|
36
|
+
var _icons = require("@pie-lib/icons");
|
|
37
|
+
|
|
38
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
39
|
+
|
|
40
|
+
var _styles = require("@material-ui/core/styles");
|
|
41
|
+
|
|
42
|
+
var _correctAnswerToggle = _interopRequireDefault(require("@pie-lib/correct-answer-toggle"));
|
|
43
|
+
|
|
34
44
|
var _imageContainer = _interopRequireDefault(require("./image-container"));
|
|
35
45
|
|
|
36
46
|
var _interactiveSection = _interopRequireDefault(require("./interactive-section"));
|
|
@@ -39,17 +49,15 @@ var _possibleResponses2 = _interopRequireDefault(require("./possible-responses")
|
|
|
39
49
|
|
|
40
50
|
var _utilsCorrectness = require("./utils-correctness");
|
|
41
51
|
|
|
42
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
43
|
-
|
|
44
52
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
45
53
|
|
|
46
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
54
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
55
|
|
|
48
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
56
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
49
57
|
|
|
50
58
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
51
59
|
|
|
52
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try {
|
|
60
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
61
|
|
|
54
62
|
var generateId = function generateId() {
|
|
55
63
|
return Math.random().toString(36).substring(2) + new Date().getTime().toString(36);
|
|
@@ -98,8 +106,17 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
98
106
|
return b.containerIndex !== responseContainerIndex;
|
|
99
107
|
});
|
|
100
108
|
var shiftedItem = answersInThisContainer[0];
|
|
101
|
-
|
|
102
|
-
|
|
109
|
+
|
|
110
|
+
if (maxResponsePerZone === 1) {
|
|
111
|
+
answersInThisContainer.shift(); // FIFO
|
|
112
|
+
} else {
|
|
113
|
+
_this.setState({
|
|
114
|
+
maxResponsePerZoneWarning: true
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
return;
|
|
118
|
+
} // if duplicates are not allowed, make sure to put the shifted value back in possible responses
|
|
119
|
+
|
|
103
120
|
|
|
104
121
|
if (!duplicateResponses) {
|
|
105
122
|
possibleResponses.push(_objectSpread(_objectSpread({}, shiftedItem), {}, {
|
|
@@ -127,11 +144,11 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
127
144
|
} : {})]);
|
|
128
145
|
} else {
|
|
129
146
|
// answers will be:
|
|
130
|
-
// + if duplicatesAllowed, all the other answers
|
|
147
|
+
// + if duplicatesAllowed, all the other answers, except the one that was dragged
|
|
131
148
|
// else: all the answers that are not having the same value
|
|
132
149
|
// + new answer
|
|
133
150
|
answersToStore = [].concat((0, _toConsumableArray2["default"])(answers.filter(function (a) {
|
|
134
|
-
return duplicateResponses ?
|
|
151
|
+
return duplicateResponses ? a.id !== answer.id : a.value !== answer.value;
|
|
135
152
|
})), [_objectSpread(_objectSpread({}, answer), {}, {
|
|
136
153
|
containerIndex: responseContainerIndex
|
|
137
154
|
}, duplicateResponses ? {
|
|
@@ -140,6 +157,7 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
140
157
|
}
|
|
141
158
|
|
|
142
159
|
_this.setState({
|
|
160
|
+
maxResponsePerZoneWarning: false,
|
|
143
161
|
answers: answersToStore,
|
|
144
162
|
possibleResponses: // for single response per container remove answer from possible responses
|
|
145
163
|
duplicateResponses ? possibleResponses : possibleResponses.filter(function (response) {
|
|
@@ -162,6 +180,7 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
162
180
|
var shouldNotPushInPossibleResponses = answer.containerIndex === undefined; // don't duplicate possible responses
|
|
163
181
|
|
|
164
182
|
_this.setState({
|
|
183
|
+
maxResponsePerZoneWarning: false,
|
|
165
184
|
answers: answersToStore,
|
|
166
185
|
// push back into possible responses the removed answer if responses cannot be duplicated
|
|
167
186
|
possibleResponses: duplicateResponses || shouldNotPushInPossibleResponses ? possibleResponses : [].concat((0, _toConsumableArray2["default"])(possibleResponses), [_objectSpread(_objectSpread({}, answer), {}, {
|
|
@@ -171,6 +190,11 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
171
190
|
|
|
172
191
|
updateAnswer(answersToStore);
|
|
173
192
|
});
|
|
193
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "toggleCorrect", function (showCorrect) {
|
|
194
|
+
return _this.setState({
|
|
195
|
+
showCorrect: showCorrect
|
|
196
|
+
});
|
|
197
|
+
});
|
|
174
198
|
var _props$model = props.model,
|
|
175
199
|
_possibleResponses = _props$model.possibleResponses,
|
|
176
200
|
responseContainers = _props$model.responseContainers,
|
|
@@ -221,7 +245,8 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
221
245
|
id: "".concat(index)
|
|
222
246
|
});
|
|
223
247
|
}),
|
|
224
|
-
maxResponsePerZone: _maxResponsePerZone || 1
|
|
248
|
+
maxResponsePerZone: _maxResponsePerZone || 1,
|
|
249
|
+
showCorrect: false
|
|
225
250
|
};
|
|
226
251
|
return _this;
|
|
227
252
|
}
|
|
@@ -236,27 +261,76 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
236
261
|
stimulus = _this$props$model.stimulus,
|
|
237
262
|
responseCorrect = _this$props$model.responseCorrect,
|
|
238
263
|
validation = _this$props$model.validation,
|
|
239
|
-
teacherInstructions = _this$props$model.teacherInstructions
|
|
264
|
+
teacherInstructions = _this$props$model.teacherInstructions,
|
|
265
|
+
prompt = _this$props$model.prompt,
|
|
266
|
+
showDashedBorder = _this$props$model.showDashedBorder,
|
|
267
|
+
mode = _this$props$model.mode;
|
|
240
268
|
var _this$state3 = this.state,
|
|
241
269
|
answers = _this$state3.answers,
|
|
242
270
|
draggingElement = _this$state3.draggingElement,
|
|
243
271
|
possibleResponses = _this$state3.possibleResponses,
|
|
244
|
-
responseContainers = _this$state3.responseContainers
|
|
272
|
+
responseContainers = _this$state3.responseContainers,
|
|
273
|
+
maxResponsePerZone = _this$state3.maxResponsePerZone,
|
|
274
|
+
maxResponsePerZoneWarning = _this$state3.maxResponsePerZoneWarning,
|
|
275
|
+
showCorrect = _this$state3.showCorrect;
|
|
276
|
+
var isEvaluateMode = mode === 'evaluate';
|
|
277
|
+
var showToggle = isEvaluateMode && !responseCorrect;
|
|
278
|
+
|
|
279
|
+
var _ref2 = validation || {},
|
|
280
|
+
validResponse = _ref2.validResponse;
|
|
281
|
+
|
|
282
|
+
var correctAnswers = [];
|
|
283
|
+
|
|
284
|
+
if (validResponse) {
|
|
285
|
+
(validResponse.value || []).forEach(function (container, i) {
|
|
286
|
+
(container.images || []).forEach(function (v) {
|
|
287
|
+
correctAnswers.push({
|
|
288
|
+
value: v,
|
|
289
|
+
containerIndex: i
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
var warningMessage = "You\u2019ve reached the limit of ".concat(maxResponsePerZone, " responses per area.") + 'To add another response, one must first be removed.';
|
|
245
296
|
var answersToShow = responseCorrect !== undefined ? (0, _utilsCorrectness.getAnswersCorrectness)(answers, validation, duplicateResponses) : answers;
|
|
246
|
-
|
|
297
|
+
|
|
298
|
+
if (responseCorrect === false && maxResponsePerZone === 1) {
|
|
299
|
+
answersToShow = [].concat((0, _toConsumableArray2["default"])(answersToShow), (0, _toConsumableArray2["default"])((0, _utilsCorrectness.getUnansweredAnswers)(answersToShow, validation)));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
303
|
+
className: "prompt",
|
|
304
|
+
prompt: prompt
|
|
305
|
+
}), teacherInstructions && /*#__PURE__*/_react["default"].createElement(_renderUi.Collapsible, {
|
|
247
306
|
labels: {
|
|
248
307
|
hidden: 'Show Teacher Instructions',
|
|
249
308
|
visible: 'Hide Teacher Instructions'
|
|
250
309
|
}
|
|
251
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
252
|
-
|
|
253
|
-
__html: teacherInstructions
|
|
254
|
-
}
|
|
310
|
+
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
311
|
+
prompt: teacherInstructions
|
|
255
312
|
})), /*#__PURE__*/_react["default"].createElement(_Typography["default"], null, /*#__PURE__*/_react["default"].createElement("span", {
|
|
256
313
|
dangerouslySetInnerHTML: {
|
|
257
314
|
__html: stimulus
|
|
258
315
|
}
|
|
259
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
316
|
+
})), /*#__PURE__*/_react["default"].createElement(_correctAnswerToggle["default"], {
|
|
317
|
+
show: showToggle,
|
|
318
|
+
toggled: showCorrect,
|
|
319
|
+
onToggle: this.toggleCorrect
|
|
320
|
+
}), /*#__PURE__*/_react["default"].createElement("br", null), showCorrect && showToggle ? /*#__PURE__*/_react["default"].createElement(_interactiveSection["default"], {
|
|
321
|
+
responseCorrect: true
|
|
322
|
+
}, /*#__PURE__*/_react["default"].createElement(_imageContainer["default"], {
|
|
323
|
+
canDrag: false,
|
|
324
|
+
answers: correctAnswers,
|
|
325
|
+
draggingElement: draggingElement,
|
|
326
|
+
duplicateResponses: duplicateResponses,
|
|
327
|
+
image: image,
|
|
328
|
+
onAnswerSelect: this.handleOnAnswerSelect,
|
|
329
|
+
onDragAnswerBegin: this.beginDrag,
|
|
330
|
+
onDragAnswerEnd: this.handleOnDragEnd,
|
|
331
|
+
responseContainers: responseContainers,
|
|
332
|
+
showDashedBorder: showDashedBorder
|
|
333
|
+
})) : /*#__PURE__*/_react["default"].createElement(_interactiveSection["default"], {
|
|
260
334
|
responseCorrect: responseCorrect
|
|
261
335
|
}, /*#__PURE__*/_react["default"].createElement(_imageContainer["default"], {
|
|
262
336
|
canDrag: !disabled,
|
|
@@ -267,7 +341,10 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
267
341
|
onAnswerSelect: this.handleOnAnswerSelect,
|
|
268
342
|
onDragAnswerBegin: this.beginDrag,
|
|
269
343
|
onDragAnswerEnd: this.handleOnDragEnd,
|
|
270
|
-
responseContainers: responseContainers
|
|
344
|
+
responseContainers: responseContainers,
|
|
345
|
+
showDashedBorder: showDashedBorder
|
|
346
|
+
}), maxResponsePerZoneWarning && /*#__PURE__*/_react["default"].createElement(WarningInfo, {
|
|
347
|
+
message: warningMessage
|
|
271
348
|
}), /*#__PURE__*/_react["default"].createElement(_possibleResponses2["default"], {
|
|
272
349
|
canDrag: !disabled,
|
|
273
350
|
data: possibleResponses,
|
|
@@ -280,6 +357,50 @@ var ImageClozeAssociationComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
280
357
|
return ImageClozeAssociationComponent;
|
|
281
358
|
}(_react["default"].Component);
|
|
282
359
|
|
|
360
|
+
var WarningInfo = (0, _styles.withStyles)({
|
|
361
|
+
warning: {
|
|
362
|
+
margin: '0 16px',
|
|
363
|
+
backgroundColor: '#dddddd',
|
|
364
|
+
padding: '10px',
|
|
365
|
+
display: 'flex',
|
|
366
|
+
alignItems: 'center',
|
|
367
|
+
width: 'fit-content',
|
|
368
|
+
'& svg': {
|
|
369
|
+
height: '30px'
|
|
370
|
+
},
|
|
371
|
+
'& h1': {
|
|
372
|
+
padding: '0px',
|
|
373
|
+
margin: '0px'
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
message: {
|
|
377
|
+
paddingLeft: '5px',
|
|
378
|
+
userSelect: 'none'
|
|
379
|
+
}
|
|
380
|
+
})(function (_ref3) {
|
|
381
|
+
var classes = _ref3.classes,
|
|
382
|
+
message = _ref3.message;
|
|
383
|
+
return /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.TransitionGroup, null, /*#__PURE__*/_react["default"].createElement(_reactTransitionGroup.CSSTransition, {
|
|
384
|
+
classNames: 'fb',
|
|
385
|
+
key: "fb",
|
|
386
|
+
timeout: 300
|
|
387
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
388
|
+
key: "panel",
|
|
389
|
+
className: classes.warning
|
|
390
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons.ShowRationale, {
|
|
391
|
+
iconSet: "emoji",
|
|
392
|
+
shape: "square"
|
|
393
|
+
}), /*#__PURE__*/_react["default"].createElement("span", {
|
|
394
|
+
className: classes.message,
|
|
395
|
+
dangerouslySetInnerHTML: {
|
|
396
|
+
__html: message
|
|
397
|
+
}
|
|
398
|
+
}))));
|
|
399
|
+
});
|
|
400
|
+
WarningInfo.propTypes = {
|
|
401
|
+
message: _propTypes["default"].string,
|
|
402
|
+
classes: _propTypes["default"].object.isRequired
|
|
403
|
+
};
|
|
283
404
|
ImageClozeAssociationComponent.propTypes = {
|
|
284
405
|
classes: _propTypes["default"].object,
|
|
285
406
|
model: _propTypes["default"].object.isRequired,
|
package/lib/root.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/root.jsx"],"names":["generateId","Math","random","toString","substring","Date","getTime","ImageClozeAssociationComponent","props","draggingElement","setState","id","value","answer","responseContainerIndex","duplicateResponses","model","updateAnswer","state","answers","possibleResponses","maxResponsePerZone","answersToStore","filter","a","containerIndex","length","answersInThisContainer","answersInOtherContainers","b","shiftedItem","shift","push","_","max","map","c","parseInt","isNaN","response","shouldNotPushInPossibleResponses","undefined","responseContainers","session","possibleResponsesWithIds","item","index","groupBy","grp","slice","flatMap","possibleResponsesFiltered","find","disabled","image","stimulus","responseCorrect","validation","teacherInstructions","answersToShow","hidden","visible","__html","handleOnAnswerSelect","beginDrag","handleOnDragEnd","handleOnAnswerRemove","React","Component","propTypes","classes","PropTypes","object","isRequired","func","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa;AAAA,SACjBC,IAAI,CAACC,MAAL,GACGC,QADH,CACY,EADZ,EAEGC,SAFH,CAEa,CAFb,IAEkB,IAAIC,IAAJ,GAAWC,OAAX,GAAqBH,QAArB,CAA8B,EAA9B,CAHD;AAAA,CAAnB;;IAKMI,8B;;;;;AACJ,0CAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,kGAkDP,UAAAC,eAAe,EAAI;AAC7B,YAAKC,QAAL,CAAc;AACZD,QAAAA,eAAe,EAAfA;AADY,OAAd;AAGD,KAtDkB;AAAA,wGAwDD,YAAM;AACtB,YAAKC,QAAL,CAAc;AACZD,QAAAA,eAAe,EAAE;AAAEE,UAAAA,EAAE,EAAE,EAAN;AAAUC,UAAAA,KAAK,EAAE;AAAjB;AADL,OAAd;AAGD,KA5DkB;AAAA,6GA8DI,UAACC,MAAD,EAASC,sBAAT,EAAoC;AAAA,wBAIrD,MAAKN,KAJgD;AAAA,UAE9CO,kBAF8C,eAEvDC,KAFuD,CAE9CD,kBAF8C;AAAA,UAGvDE,YAHuD,eAGvDA,YAHuD;AAAA,wBAKE,MAAKC,KALP;AAAA,UAKjDC,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C,S;;AAgPnD7D,8BAA8B,CAAC8D,SAA/B,GAA2C;AACzCC,EAAAA,OAAO,EAAEC,sBAAUC,MADsB;AAEzCxD,EAAAA,KAAK,EAAEuD,sBAAUC,MAAV,CAAiBC,UAFiB;AAGzC9B,EAAAA,OAAO,EAAE4B,sBAAUC,MAHsB;AAIzCvD,EAAAA,YAAY,EAAEsD,sBAAUG,IAAV,CAAeD;AAJY,CAA3C;AAOAlE,8BAA8B,CAACoE,YAA/B,GAA8C;AAC5CL,EAAAA,OAAO,EAAE;AADmC,CAA9C;;eAIe,2BAAgB/D,8BAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Typography from '@material-ui/core/Typography';\nimport { withDragContext } from '@pie-lib/drag';\n\nimport Image from './image-container';\nimport InteractiveSection from './interactive-section';\nimport PossibleResponses from './possible-responses';\n\nimport { getAnswersCorrectness } from './utils-correctness';\nimport { Collapsible } from '@pie-lib/render-ui';\nimport _ from 'lodash';\n\nconst generateId = () =>\n Math.random()\n .toString(36)\n .substring(2) + new Date().getTime().toString(36);\n\nclass ImageClozeAssociationComponent extends React.Component {\n constructor(props) {\n super(props);\n const {\n model: {\n possibleResponses,\n responseContainers,\n duplicateResponses,\n maxResponsePerZone\n },\n session\n } = props;\n let { answers } = session || {};\n // set id for each possible response\n const possibleResponsesWithIds = (possibleResponses || []).map(\n (item, index) => ({\n value: item,\n id: `${index}`\n })\n );\n\n answers = _(answers || [])\n .groupBy('containerIndex')\n // keep only last maxResponsePerZone answers for each zone\n .map(grp => grp.slice(-(maxResponsePerZone || 1)))\n .flatMap()\n // set id for each answer\n .map((answer, index) => ({ ...answer, id: `${index}` }))\n // return only answer which have a valid container index\n .filter(answer => answer.containerIndex < responseContainers.length)\n .value();\n\n const possibleResponsesFiltered = possibleResponsesWithIds.filter(\n response => !answers.find(answer => answer.value === response.value)\n );\n this.state = {\n answers: answers || [],\n draggingElement: { id: '', value: '' },\n possibleResponses: duplicateResponses\n ? possibleResponsesWithIds\n : possibleResponsesFiltered,\n // set id for each response containers\n responseContainers: responseContainers.map((item, index) => ({\n index,\n ...item,\n id: `${index}`\n })),\n maxResponsePerZone: maxResponsePerZone || 1\n };\n }\n\n beginDrag = draggingElement => {\n this.setState({\n draggingElement\n });\n };\n\n handleOnDragEnd = () => {\n this.setState({\n draggingElement: { id: '', value: '' }\n });\n };\n\n handleOnAnswerSelect = (answer, responseContainerIndex) => {\n const {\n model: { duplicateResponses },\n updateAnswer\n } = this.props;\n const { answers, possibleResponses, maxResponsePerZone } = this.state;\n let answersToStore;\n\n if (\n maxResponsePerZone ===\n answers.filter(a => a.containerIndex === responseContainerIndex).length\n ) {\n const answersInThisContainer = answers.filter(\n a => a.containerIndex === responseContainerIndex\n );\n const answersInOtherContainers = answers.filter(\n b => b.containerIndex !== responseContainerIndex\n );\n\n const shiftedItem = answersInThisContainer[0];\n answersInThisContainer.shift(); // FIFO\n\n // if duplicates are not allowed, make sure to put the shifted value back in possible responses\n if (!duplicateResponses) {\n possibleResponses.push({\n ...shiftedItem,\n containerIndex: '',\n id: `${_.max(\n possibleResponses.map(c => parseInt(c.id)).filter(id => !isNaN(id))\n ) + 1}`\n });\n }\n\n // answers will be:\n // + shifted answers for the current container\n // + if duplicatesAllowed, all the other answers from other containers\n // else: all the answers from other containers that are not having the same value\n // + new answer\n answersToStore = [\n ...answersInThisContainer, // shifted\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answersInOtherContainers.filter(a =>\n duplicateResponses ? true : a.value !== answer.value\n ), // un-shifted\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {})\n }\n ];\n } else {\n // answers will be:\n // + if duplicatesAllowed, all the other answers\n // else: all the answers that are not having the same value\n // + new answer\n answersToStore = [\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answers.filter(a =>\n duplicateResponses ? true : a.value !== answer.value\n ),\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {})\n }\n ];\n }\n\n this.setState({\n answers: answersToStore,\n possibleResponses:\n // for single response per container remove answer from possible responses\n duplicateResponses\n ? possibleResponses\n : possibleResponses.filter(\n response => response.value !== answer.value\n )\n });\n updateAnswer(answersToStore);\n };\n\n handleOnAnswerRemove = answer => {\n const {\n model: { duplicateResponses },\n updateAnswer\n } = this.props;\n const { answers, possibleResponses } = this.state;\n const answersToStore = answers.filter(a => a.id !== answer.id);\n const shouldNotPushInPossibleResponses =\n answer.containerIndex === undefined; // don't duplicate possible responses\n\n this.setState({\n answers: answersToStore,\n // push back into possible responses the removed answer if responses cannot be duplicated\n possibleResponses:\n duplicateResponses || shouldNotPushInPossibleResponses\n ? possibleResponses\n : [\n ...possibleResponses,\n {\n ...answer,\n containerIndex: undefined\n }\n ]\n });\n updateAnswer(answersToStore);\n };\n\n render() {\n const {\n model: {\n disabled,\n duplicateResponses,\n image,\n stimulus,\n responseCorrect,\n validation,\n teacherInstructions\n }\n } = this.props;\n const {\n answers,\n draggingElement,\n possibleResponses,\n responseContainers\n } = this.state;\n\n const answersToShow =\n responseCorrect !== undefined\n ? getAnswersCorrectness(answers, validation, duplicateResponses)\n : answers;\n\n return (\n <div>\n {teacherInstructions && (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions'\n }}\n >\n <div dangerouslySetInnerHTML={{ __html: teacherInstructions }} />\n </Collapsible>\n )}\n\n <Typography>\n <span dangerouslySetInnerHTML={{ __html: stimulus }} />\n </Typography>\n\n <InteractiveSection responseCorrect={responseCorrect}>\n <Image\n canDrag={!disabled}\n answers={answersToShow}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n />\n\n <PossibleResponses\n canDrag={!disabled}\n data={possibleResponses}\n onAnswerRemove={this.handleOnAnswerRemove}\n onDragBegin={this.beginDrag}\n onDragEnd={this.handleOnDragEnd}\n />\n </InteractiveSection>\n </div>\n );\n }\n}\n\nImageClozeAssociationComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n session: PropTypes.object,\n updateAnswer: PropTypes.func.isRequired\n};\n\nImageClozeAssociationComponent.defaultProps = {\n classes: {}\n};\n\nexport default withDragContext(ImageClozeAssociationComponent);\n"],"file":"root.js"}
|
|
1
|
+
{"version":3,"sources":["../src/root.jsx"],"names":["generateId","Math","random","toString","substring","Date","getTime","ImageClozeAssociationComponent","props","draggingElement","setState","id","value","answer","responseContainerIndex","duplicateResponses","model","updateAnswer","state","answers","possibleResponses","maxResponsePerZone","answersToStore","filter","a","containerIndex","length","answersInThisContainer","answersInOtherContainers","b","shiftedItem","shift","maxResponsePerZoneWarning","push","_","max","map","c","parseInt","isNaN","response","shouldNotPushInPossibleResponses","undefined","showCorrect","responseContainers","session","possibleResponsesWithIds","item","index","groupBy","grp","slice","flatMap","possibleResponsesFiltered","find","disabled","image","stimulus","responseCorrect","validation","teacherInstructions","prompt","showDashedBorder","mode","isEvaluateMode","showToggle","validResponse","correctAnswers","forEach","container","i","images","v","warningMessage","answersToShow","hidden","visible","__html","toggleCorrect","handleOnAnswerSelect","beginDrag","handleOnDragEnd","handleOnAnswerRemove","React","Component","WarningInfo","warning","margin","backgroundColor","padding","display","alignItems","width","height","message","paddingLeft","userSelect","classes","propTypes","PropTypes","string","object","isRequired","func","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa;AAAA,SAAMC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAA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C,oBAAD;AAAe,IAAA,OAAO,EAAC,OAAvB;AAA+B,IAAA,KAAK,EAAC;AAArC,IADF,eAEE;AAAM,IAAA,SAAS,EAAEW,OAAO,CAACH,OAAzB;AAAkC,IAAA,uBAAuB,EAAE;AAAEjB,MAAAA,MAAM,EAAEiB;AAAV;AAA3D,IAFF,CADF,CADF,CADC;AAAA,CApBiB,CAApB;AA+BAT,WAAW,CAACa,SAAZ,GAAwB;AACtBJ,EAAAA,OAAO,EAAEK,sBAAUC,MADG;AAEtBH,EAAAA,OAAO,EAAEE,sBAAUE,MAAV,CAAiBC;AAFJ,CAAxB;AAKA/F,8BAA8B,CAAC2F,SAA/B,GAA2C;AACzCD,EAAAA,OAAO,EAAEE,sBAAUE,MADsB;AAEzCrF,EAAAA,KAAK,EAAEmF,sBAAUE,MAAV,CAAiBC,UAFiB;AAGzCzD,EAAAA,OAAO,EAAEsD,sBAAUE,MAHsB;AAIzCpF,EAAAA,YAAY,EAAEkF,sBAAUI,IAAV,CAAeD;AAJY,CAA3C;AAOA/F,8BAA8B,CAACiG,YAA/B,GAA8C;AAC5CP,EAAAA,OAAO,EAAE;AADmC,CAA9C;;eAIe,2BAAgB1F,8BAAhB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Typography from '@material-ui/core/Typography';\nimport { withDragContext } from '@pie-lib/drag';\nimport { CSSTransition, TransitionGroup } from 'react-transition-group';\nimport { ShowRationale } from '@pie-lib/icons';\nimport { Collapsible, PreviewPrompt } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport CorrectAnswerToggle from '@pie-lib/correct-answer-toggle';\n\nimport Image from './image-container';\nimport InteractiveSection from './interactive-section';\nimport PossibleResponses from './possible-responses';\nimport { getUnansweredAnswers, getAnswersCorrectness } from './utils-correctness';\nimport _ from 'lodash';\n\nconst generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);\n\nclass ImageClozeAssociationComponent extends React.Component {\n constructor(props) {\n super(props);\n const {\n model: { possibleResponses, responseContainers, duplicateResponses, maxResponsePerZone },\n session,\n } = props;\n let { answers } = session || {};\n // set id for each possible response\n const possibleResponsesWithIds = (possibleResponses || []).map((item, index) => ({\n value: item,\n id: `${index}`,\n }));\n\n answers = _(answers || [])\n .groupBy('containerIndex')\n // keep only last maxResponsePerZone answers for each zone\n .map((grp) => grp.slice(-(maxResponsePerZone || 1)))\n .flatMap()\n // set id for each answer\n .map((answer, index) => ({ ...answer, id: `${index}` }))\n // return only answer which have a valid container index\n .filter((answer) => answer.containerIndex < responseContainers.length)\n .value();\n\n const possibleResponsesFiltered = possibleResponsesWithIds.filter(\n (response) => !answers.find((answer) => answer.value === response.value),\n );\n this.state = {\n answers: answers || [],\n draggingElement: { id: '', value: '' },\n possibleResponses: duplicateResponses ? possibleResponsesWithIds : possibleResponsesFiltered,\n // set id for each response containers\n responseContainers: responseContainers.map((item, index) => ({\n index,\n ...item,\n id: `${index}`,\n })),\n maxResponsePerZone: maxResponsePerZone || 1,\n showCorrect: false,\n };\n }\n\n beginDrag = (draggingElement) => {\n this.setState({\n draggingElement,\n });\n };\n\n handleOnDragEnd = () => {\n this.setState({\n draggingElement: { id: '', value: '' },\n });\n };\n\n handleOnAnswerSelect = (answer, responseContainerIndex) => {\n const {\n model: { duplicateResponses },\n updateAnswer,\n } = this.props;\n const { answers, possibleResponses, maxResponsePerZone } = this.state;\n let answersToStore;\n\n if (maxResponsePerZone === answers.filter((a) => a.containerIndex === responseContainerIndex).length) {\n const answersInThisContainer = answers.filter((a) => a.containerIndex === responseContainerIndex);\n const answersInOtherContainers = answers.filter((b) => b.containerIndex !== responseContainerIndex);\n\n const shiftedItem = answersInThisContainer[0];\n if (maxResponsePerZone === 1) {\n answersInThisContainer.shift(); // FIFO\n } else {\n this.setState({ maxResponsePerZoneWarning: true });\n return;\n }\n\n // if duplicates are not allowed, make sure to put the shifted value back in possible responses\n if (!duplicateResponses) {\n possibleResponses.push({\n ...shiftedItem,\n containerIndex: '',\n id: `${_.max(possibleResponses.map((c) => parseInt(c.id)).filter((id) => !isNaN(id))) + 1}`,\n });\n }\n\n // answers will be:\n // + shifted answers for the current container\n // + if duplicatesAllowed, all the other answers from other containers\n // else: all the answers from other containers that are not having the same value\n // + new answer\n answersToStore = [\n ...answersInThisContainer, // shifted\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answersInOtherContainers.filter((a) => (duplicateResponses ? true : a.value !== answer.value)), // un-shifted\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {}),\n },\n ];\n } else {\n // answers will be:\n // + if duplicatesAllowed, all the other answers, except the one that was dragged\n // else: all the answers that are not having the same value\n // + new answer\n answersToStore = [\n // TODO allow duplicates case Question: should we remove answer from a container if dragged to another container?\n // if yes, this should do it: add a.id !== answer.id instead of 'true'\n ...answers.filter((a) => (duplicateResponses ? a.id !== answer.id : a.value !== answer.value)),\n {\n ...answer,\n containerIndex: responseContainerIndex,\n ...(duplicateResponses ? { id: generateId() } : {}),\n },\n ];\n }\n\n this.setState({\n maxResponsePerZoneWarning: false,\n answers: answersToStore,\n possibleResponses:\n // for single response per container remove answer from possible responses\n duplicateResponses\n ? possibleResponses\n : possibleResponses.filter((response) => response.value !== answer.value),\n });\n updateAnswer(answersToStore);\n };\n\n handleOnAnswerRemove = (answer) => {\n const {\n model: { duplicateResponses },\n updateAnswer,\n } = this.props;\n const { answers, possibleResponses } = this.state;\n const answersToStore = answers.filter((a) => a.id !== answer.id);\n const shouldNotPushInPossibleResponses = answer.containerIndex === undefined; // don't duplicate possible responses\n\n this.setState({\n maxResponsePerZoneWarning: false,\n answers: answersToStore,\n // push back into possible responses the removed answer if responses cannot be duplicated\n possibleResponses:\n duplicateResponses || shouldNotPushInPossibleResponses\n ? possibleResponses\n : [\n ...possibleResponses,\n {\n ...answer,\n containerIndex: undefined,\n },\n ],\n });\n updateAnswer(answersToStore);\n };\n\n toggleCorrect = (showCorrect) => this.setState({ showCorrect });\n\n render() {\n const {\n model: {\n disabled,\n duplicateResponses,\n image,\n stimulus,\n responseCorrect,\n validation,\n teacherInstructions,\n prompt,\n showDashedBorder,\n mode,\n },\n } = this.props;\n const {\n answers,\n draggingElement,\n possibleResponses,\n responseContainers,\n maxResponsePerZone,\n maxResponsePerZoneWarning,\n showCorrect,\n } = this.state;\n const isEvaluateMode = mode === 'evaluate';\n const showToggle = isEvaluateMode && !responseCorrect;\n\n const { validResponse } = validation || {};\n const correctAnswers = [];\n\n if (validResponse) {\n (validResponse.value || []).forEach((container, i) => {\n (container.images || []).forEach((v) => {\n correctAnswers.push({\n value: v,\n containerIndex: i,\n });\n });\n });\n }\n\n const warningMessage =\n `You’ve reached the limit of ${maxResponsePerZone} responses per area.` +\n 'To add another response, one must first be removed.';\n\n let answersToShow =\n responseCorrect !== undefined ? getAnswersCorrectness(answers, validation, duplicateResponses) : answers;\n\n if (responseCorrect === false && maxResponsePerZone === 1) {\n answersToShow = [...answersToShow, ...getUnansweredAnswers(answersToShow, validation)];\n }\n\n return (\n <div>\n <PreviewPrompt className=\"prompt\" prompt={prompt} />\n\n {teacherInstructions && (\n <Collapsible\n labels={{\n hidden: 'Show Teacher Instructions',\n visible: 'Hide Teacher Instructions',\n }}\n >\n <PreviewPrompt prompt={teacherInstructions} />\n </Collapsible>\n )}\n\n <Typography>\n <span dangerouslySetInnerHTML={{ __html: stimulus }} />\n </Typography>\n\n <CorrectAnswerToggle show={showToggle} toggled={showCorrect} onToggle={this.toggleCorrect} />\n <br />\n\n {showCorrect && showToggle ? (\n <InteractiveSection responseCorrect={true}>\n <Image\n canDrag={false}\n answers={correctAnswers}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n showDashedBorder={showDashedBorder}\n />\n </InteractiveSection>\n ) : (\n <InteractiveSection responseCorrect={responseCorrect}>\n <Image\n canDrag={!disabled}\n answers={answersToShow}\n draggingElement={draggingElement}\n duplicateResponses={duplicateResponses}\n image={image}\n onAnswerSelect={this.handleOnAnswerSelect}\n onDragAnswerBegin={this.beginDrag}\n onDragAnswerEnd={this.handleOnDragEnd}\n responseContainers={responseContainers}\n showDashedBorder={showDashedBorder}\n />\n\n {maxResponsePerZoneWarning && <WarningInfo message={warningMessage} />}\n\n <PossibleResponses\n canDrag={!disabled}\n data={possibleResponses}\n onAnswerRemove={this.handleOnAnswerRemove}\n onDragBegin={this.beginDrag}\n onDragEnd={this.handleOnDragEnd}\n />\n </InteractiveSection>\n )}\n </div>\n );\n }\n}\n\nconst WarningInfo = withStyles({\n warning: {\n margin: '0 16px',\n backgroundColor: '#dddddd',\n padding: '10px',\n display: 'flex',\n alignItems: 'center',\n width: 'fit-content',\n '& svg': {\n height: '30px',\n },\n '& h1': {\n padding: '0px',\n margin: '0px',\n },\n },\n message: {\n paddingLeft: '5px',\n userSelect: 'none',\n },\n})(({ classes, message }) => (\n <TransitionGroup>\n <CSSTransition classNames={'fb'} key=\"fb\" timeout={300}>\n <div key=\"panel\" className={classes.warning}>\n <ShowRationale iconSet=\"emoji\" shape=\"square\" />\n <span className={classes.message} dangerouslySetInnerHTML={{ __html: message }} />\n </div>\n </CSSTransition>\n </TransitionGroup>\n));\n\nWarningInfo.propTypes = {\n message: PropTypes.string,\n classes: PropTypes.object.isRequired,\n};\n\nImageClozeAssociationComponent.propTypes = {\n classes: PropTypes.object,\n model: PropTypes.object.isRequired,\n session: PropTypes.object,\n updateAnswer: PropTypes.func.isRequired,\n};\n\nImageClozeAssociationComponent.defaultProps = {\n classes: {},\n};\n\nexport default withDragContext(ImageClozeAssociationComponent);\n"],"file":"root.js"}
|
package/lib/utils-correctness.js
CHANGED
|
@@ -5,24 +5,26 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getAnswersCorrectness = void 0;
|
|
8
|
+
exports.getUnansweredAnswers = exports.getAnswersCorrectness = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
11
|
|
|
10
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
13
|
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
14
|
+
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; }
|
|
13
15
|
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
16
|
+
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; }
|
|
15
17
|
|
|
16
18
|
var getAllCorrectAnswers = function getAllCorrectAnswers(answers, responses) {
|
|
17
19
|
return answers.map(function (answer) {
|
|
18
20
|
return _objectSpread(_objectSpread({}, answer), {}, {
|
|
19
|
-
isCorrect: responses[answer.containerIndex].includes(answer.value)
|
|
21
|
+
isCorrect: (responses[answer.containerIndex].images || []).includes(answer.value)
|
|
20
22
|
});
|
|
21
23
|
});
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
var getValidAnswer = function getValidAnswer(answer, response) {
|
|
25
|
-
return response[answer.containerIndex].filter(function (res) {
|
|
27
|
+
return (response[answer.containerIndex].images || []).filter(function (res) {
|
|
26
28
|
return res === answer.value;
|
|
27
29
|
});
|
|
28
30
|
};
|
|
@@ -55,6 +57,32 @@ var getUniqueCorrectAnswers = function getUniqueCorrectAnswers(answers, validRes
|
|
|
55
57
|
return finalAnswers;
|
|
56
58
|
};
|
|
57
59
|
|
|
60
|
+
var getUnansweredAnswers = function getUnansweredAnswers(answers, validation) {
|
|
61
|
+
var _validation$validResp = validation.validResponse;
|
|
62
|
+
_validation$validResp = _validation$validResp === void 0 ? {} : _validation$validResp;
|
|
63
|
+
var value = _validation$validResp.value;
|
|
64
|
+
var unansweredAnswers = (value || []).reduce(function (unanswered, response, index) {
|
|
65
|
+
var isAnswered = !!answers.find(function (answer) {
|
|
66
|
+
return answer.containerIndex === index;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (!isAnswered) {
|
|
70
|
+
return [].concat((0, _toConsumableArray2["default"])(unanswered), [{
|
|
71
|
+
id: "unanswered-".concat(index),
|
|
72
|
+
value: response.images[0] || '',
|
|
73
|
+
containerIndex: index,
|
|
74
|
+
isCorrect: false,
|
|
75
|
+
hidden: true
|
|
76
|
+
}]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return unanswered;
|
|
80
|
+
}, []);
|
|
81
|
+
return unansweredAnswers;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.getUnansweredAnswers = getUnansweredAnswers;
|
|
85
|
+
|
|
58
86
|
var getAnswersCorrectness = function getAnswersCorrectness(answers, validation) {
|
|
59
87
|
var value = validation.validResponse.value,
|
|
60
88
|
altResponses = validation.altResponses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils-correctness.js"],"names":["getAllCorrectAnswers","answers","responses","map","answer","isCorrect","containerIndex","includes","value","getValidAnswer","response","filter","res","getUniqueCorrectAnswers","validResponses","finalAnswers","forEach","answer1","valuesToParse","answer2","length","shift","index","finalAnswer","id","valid","
|
|
1
|
+
{"version":3,"sources":["../src/utils-correctness.js"],"names":["getAllCorrectAnswers","answers","responses","map","answer","isCorrect","containerIndex","images","includes","value","getValidAnswer","response","filter","res","getUniqueCorrectAnswers","validResponses","finalAnswers","forEach","answer1","valuesToParse","answer2","length","shift","index","finalAnswer","id","valid","getUnansweredAnswers","validation","validResponse","unansweredAnswers","reduce","unanswered","isAnswered","find","hidden","getAnswersCorrectness","altResponses","allCorrect","uniqueAnswers","noOfCorrect","altUniqueStack","altResponse","altValue","altAllCorrect","sort","a","b","c"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,OAAD,EAAUC,SAAV;AAAA,SAC3BD,OAAO,CAACE,GAAR,CAAY,UAACC,MAAD;AAAA,2CACPA,MADO;AAEVC,MAAAA,SAAS,EAAE,CAACH,SAAS,CAACE,MAAM,CAACE,cAAR,CAAT,CAAiCC,MAAjC,IAA2C,EAA5C,EAAgDC,QAAhD,CAAyDJ,MAAM,CAACK,KAAhE;AAFD;AAAA,GAAZ,CAD2B;AAAA,CAA7B;;AAMA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CAACN,MAAD,EAASO,QAAT;AAAA,SACrB,CAACA,QAAQ,CAACP,MAAM,CAACE,cAAR,CAAR,CAAgCC,MAAhC,IAA0C,EAA3C,EAA+CK,MAA/C,CAAsD,UAACC,GAAD;AAAA,WAASA,GAAG,KAAKT,MAAM,CAACK,KAAxB;AAAA,GAAtD,CADqB;AAAA,CAAvB;;AAGA,IAAMK,uBAAuB,GAAG,SAA1BA,uBAA0B,CAACb,OAAD,EAAUc,cAAV,EAA6B;AAC3D,MAAIC,YAAY,GAAGf,OAAnB;AAEAA,EAAAA,OAAO,CAACgB,OAAR,CAAgB,UAACC,OAAD,EAAa;AAC3B,QAAMC,aAAa,GAAGlB,OAAO,CA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I,IAAf,CAAoB,UAACC,CAAD,EAAIC,CAAJ;AAAA,aAAUA,CAAC,CAACnC,MAAF,CAAS,UAACoC,CAAD;AAAA,eAAOA,CAAC,CAAC3C,SAAT;AAAA,OAAT,EAA6BgB,MAA7B,GAAsCyB,CAAC,CAAClC,MAAF,CAAS,UAACoC,CAAD;AAAA,eAAOA,CAAC,CAAC3C,SAAT;AAAA,OAAT,EAA6BgB,MAA7E;AAAA,KAApB,EAAyG,CAAzG,CAAP;AACD;;AACD,SAAOkB,aAAP;AACD,CAtBM","sourcesContent":["const getAllCorrectAnswers = (answers, responses) =>\n answers.map((answer) => ({\n ...answer,\n isCorrect: (responses[answer.containerIndex].images || []).includes(answer.value),\n }));\n\nconst getValidAnswer = (answer, response) =>\n (response[answer.containerIndex].images || []).filter((res) => res === answer.value);\n\nconst getUniqueCorrectAnswers = (answers, validResponses) => {\n let finalAnswers = answers;\n\n answers.forEach((answer1) => {\n const valuesToParse = answers.filter(\n (answer2) => answer2.value === answer1.value && answer2.containerIndex === answer1.containerIndex,\n );\n\n if (valuesToParse.length > 1) {\n // point only to duplicates but first\n valuesToParse.shift();\n // mark duplicates as incorrect\n valuesToParse.forEach((value, index) => {\n finalAnswers = finalAnswers.map((finalAnswer) => {\n if (finalAnswer.id === value.id) {\n let valid = getValidAnswer(finalAnswer, validResponses);\n\n return {\n ...finalAnswer,\n isCorrect: valid.length > index + 1,\n };\n }\n return finalAnswer;\n });\n });\n }\n });\n return finalAnswers;\n};\n\nexport const getUnansweredAnswers = (answers, validation) => {\n const { validResponse: { value } = {} } = validation;\n\n const unansweredAnswers = (value || []).reduce((unanswered, response, index) => {\n const isAnswered = !!answers.find((answer) => answer.containerIndex === index);\n\n if (!isAnswered) {\n return [\n ...unanswered,\n {\n id: `unanswered-${index}`,\n value: response.images[0] || '',\n containerIndex: index,\n isCorrect: false,\n hidden: true,\n },\n ];\n }\n\n return unanswered;\n }, []);\n\n return unansweredAnswers;\n};\n\nexport const getAnswersCorrectness = (answers, validation) => {\n const {\n validResponse: { value },\n altResponses,\n } = validation;\n\n const allCorrect = getAllCorrectAnswers(answers, value);\n const uniqueAnswers = getUniqueCorrectAnswers(allCorrect, value);\n const noOfCorrect = uniqueAnswers.filter((answer) => answer.isCorrect).length;\n\n // Look for alternate correct responses if there are incorrect responses.\n if (noOfCorrect < uniqueAnswers.length && altResponses && altResponses.length) {\n const altUniqueStack = altResponses.map((altResponse) => {\n const altValue = altResponse.value;\n\n const altAllCorrect = getAllCorrectAnswers(answers, altValue);\n return getUniqueCorrectAnswers(altAllCorrect, altValue);\n });\n // Return the one with most correct answers.\n return altUniqueStack.sort((a, b) => b.filter((c) => c.isCorrect).length - a.filter((c) => c.isCorrect).length)[0];\n }\n return uniqueAnswers;\n};\n"],"file":"utils-correctness.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/image-cloze-association",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1-beta.587+40df32c2f",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,16 +10,19 @@
|
|
|
10
10
|
"@material-ui/core": "^3.9.3",
|
|
11
11
|
"@material-ui/icons": "^3.0.1",
|
|
12
12
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
13
|
-
"@pie-lib/
|
|
14
|
-
"@pie-lib/
|
|
15
|
-
"@pie-lib/
|
|
13
|
+
"@pie-lib/correct-answer-toggle": "^2.3.62",
|
|
14
|
+
"@pie-lib/drag": "^2.1.12",
|
|
15
|
+
"@pie-lib/math-rendering": "^2.5.12",
|
|
16
|
+
"@pie-lib/render-ui": "^4.14.12",
|
|
17
|
+
"classnames": "^2.2.6",
|
|
18
|
+
"is-plain-object": "^5.0.0",
|
|
16
19
|
"prop-types": "^15.6.1",
|
|
17
20
|
"react": "^16.8.1",
|
|
18
21
|
"react-dom": "^16.8.1"
|
|
19
22
|
},
|
|
20
23
|
"author": "pie framework developers",
|
|
21
24
|
"license": "ISC",
|
|
22
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "40df32c2f78966706cb168843567c9df174f1d88",
|
|
23
26
|
"scripts": {
|
|
24
27
|
"postpublish": "../../scripts/postpublish"
|
|
25
28
|
},
|
package/src/__tests__/__snapshots__/{image-container-test.jsx.snap → image-container.test.jsx.snap}
RENAMED
|
@@ -134,3 +134,23 @@ exports[`Image Container snapshots responseContainers renders 1`] = `
|
|
|
134
134
|
responseContainers={Array []}
|
|
135
135
|
/>
|
|
136
136
|
`;
|
|
137
|
+
|
|
138
|
+
exports[`Image Container snapshots showDashedBorder renders 1`] = `
|
|
139
|
+
<ImageContainer
|
|
140
|
+
answers={Array []}
|
|
141
|
+
canDrag={true}
|
|
142
|
+
classes={
|
|
143
|
+
Object {
|
|
144
|
+
"base": "ImageContainer-base-1",
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
draggingElement={Object {}}
|
|
148
|
+
duplicateResponses={false}
|
|
149
|
+
image={Object {}}
|
|
150
|
+
onAnswerSelect={[Function]}
|
|
151
|
+
onDragAnswerBegin={[Function]}
|
|
152
|
+
onDragAnswerEnd={[Function]}
|
|
153
|
+
responseContainers={Array []}
|
|
154
|
+
showDashedBorder={true}
|
|
155
|
+
/>
|
|
156
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Root snapshots model renders 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<WithStyles(PreviewPrompt)
|
|
6
|
+
className="prompt"
|
|
7
|
+
/>
|
|
8
|
+
<WithStyles(Typography)>
|
|
9
|
+
<span
|
|
10
|
+
dangerouslySetInnerHTML={
|
|
11
|
+
Object {
|
|
12
|
+
"__html": undefined,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/>
|
|
16
|
+
</WithStyles(Typography)>
|
|
17
|
+
<WithStyles(CorrectAnswerToggle)
|
|
18
|
+
onToggle={[Function]}
|
|
19
|
+
show={false}
|
|
20
|
+
toggled={false}
|
|
21
|
+
/>
|
|
22
|
+
<br />
|
|
23
|
+
<WithStyles(InteractiveSection)>
|
|
24
|
+
<WithStyles(ImageContainer)
|
|
25
|
+
answers={Array []}
|
|
26
|
+
canDrag={true}
|
|
27
|
+
draggingElement={
|
|
28
|
+
Object {
|
|
29
|
+
"id": "",
|
|
30
|
+
"value": "",
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
duplicateResponses={false}
|
|
34
|
+
image={Object {}}
|
|
35
|
+
onAnswerSelect={[Function]}
|
|
36
|
+
onDragAnswerBegin={[Function]}
|
|
37
|
+
onDragAnswerEnd={[Function]}
|
|
38
|
+
responseContainers={Array []}
|
|
39
|
+
showDashedBorder={true}
|
|
40
|
+
/>
|
|
41
|
+
<[object Object]
|
|
42
|
+
canDrag={true}
|
|
43
|
+
data={Array []}
|
|
44
|
+
onAnswerRemove={[Function]}
|
|
45
|
+
onDragBegin={[Function]}
|
|
46
|
+
onDragEnd={[Function]}
|
|
47
|
+
/>
|
|
48
|
+
</WithStyles(InteractiveSection)>
|
|
49
|
+
</div>
|
|
50
|
+
`;
|
|
@@ -11,13 +11,13 @@ const container1 = {
|
|
|
11
11
|
x: 0,
|
|
12
12
|
y: 0,
|
|
13
13
|
height: '0%',
|
|
14
|
-
width: '0%'
|
|
14
|
+
width: '0%',
|
|
15
15
|
};
|
|
16
16
|
const container2 = {
|
|
17
17
|
x: 1,
|
|
18
18
|
y: 1,
|
|
19
19
|
height: '1%',
|
|
20
|
-
width: '1%'
|
|
20
|
+
width: '1%',
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
describe('Image Container', () => {
|
|
@@ -33,9 +33,9 @@ describe('Image Container', () => {
|
|
|
33
33
|
onAnswerSelect: () => {},
|
|
34
34
|
onDragAnswerBegin: () => {},
|
|
35
35
|
onDragAnswerEnd: () => {},
|
|
36
|
-
responseContainers: []
|
|
36
|
+
responseContainers: [],
|
|
37
37
|
},
|
|
38
|
-
opts
|
|
38
|
+
opts,
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
return shallow(<ImageContainer {...opts} />);
|
|
@@ -73,7 +73,7 @@ describe('Image Container', () => {
|
|
|
73
73
|
src: 'https://picsum.photos/id/102/200/300',
|
|
74
74
|
width: 0,
|
|
75
75
|
scale: false,
|
|
76
|
-
height: 0
|
|
76
|
+
height: 0,
|
|
77
77
|
});
|
|
78
78
|
expect(wrapper).toMatchSnapshot();
|
|
79
79
|
});
|
|
@@ -85,5 +85,12 @@ describe('Image Container', () => {
|
|
|
85
85
|
expect(wrapper).toMatchSnapshot();
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
+
|
|
89
|
+
describe('showDashedBorder', () => {
|
|
90
|
+
it('renders', () => {
|
|
91
|
+
const wrapper = mkWrapper({ showDashedBorder: true });
|
|
92
|
+
expect(wrapper).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
88
95
|
});
|
|
89
96
|
});
|