@pie-element/image-cloze-association 3.6.2 → 3.6.3-next.1016
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 +176 -0
- package/configure/CHANGELOG.md +117 -0
- package/configure/lib/defaults.js +11 -0
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +3 -3
- package/configure/lib/root.js +20 -7
- package/configure/lib/root.js.map +1 -1
- package/configure/package.json +2 -2
- package/configure/src/defaults.js +12 -1
- package/configure/src/root.jsx +34 -21
- package/controller/CHANGELOG.md +30 -0
- package/controller/lib/index.js +4 -3
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +3 -3
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +1 -1
- package/controller/src/utils.js +1 -2
- package/docs/config-schema.json +79 -0
- package/docs/config-schema.json.md +61 -1
- package/docs/pie-schema.json +28 -1
- package/docs/pie-schema.json.md +20 -0
- package/lib/image-container.js +7 -3
- package/lib/image-container.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 +11 -4
- package/lib/possible-response.js.map +1 -1
- package/lib/root.js +63 -14
- package/lib/root.js.map +1 -1
- package/lib/utils-correctness.js +31 -3
- package/lib/utils-correctness.js.map +1 -1
- package/package.json +6 -4
- package/src/__tests__/__snapshots__/root.test.jsx.snap +6 -0
- package/src/index.js +5 -0
- package/src/possible-response.jsx +12 -3
- package/src/root.jsx +78 -29
- package/src/utils-correctness.js +22 -0
- package/module/configure.js +0 -529
- package/module/controller.js +0 -18992
- package/module/demo.js +0 -93
- package/module/element.js +0 -1021
- package/module/index.html +0 -16
- package/module/manifest.json +0 -10
package/module/element.js
DELETED
|
@@ -1,1021 +0,0 @@
|
|
|
1
|
-
import {_dll_react, _dll_material_ui__core, _dll_prop_types, _dll_pie_lib__render_ui, _dll_pie_lib__drag, _dll_material_ui__core_styles, _dll_lodash, _dll_react_dom, _dll_pie_lib__math_rendering, _dll_pie_framework__pie_player_events} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
|
|
2
|
-
function unwrapExports(x) {
|
|
3
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
4
|
-
}
|
|
5
|
-
function createCommonjsModule(fn, module) {
|
|
6
|
-
return (module = {
|
|
7
|
-
exports: {}
|
|
8
|
-
}, fn(module, module.exports), module.exports);
|
|
9
|
-
}
|
|
10
|
-
var interopRequireDefault = createCommonjsModule(function (module) {
|
|
11
|
-
function _interopRequireDefault(obj) {
|
|
12
|
-
return obj && obj.__esModule ? obj : {
|
|
13
|
-
"default": obj
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
module.exports = _interopRequireDefault;
|
|
17
|
-
});
|
|
18
|
-
unwrapExports(interopRequireDefault);
|
|
19
|
-
var setPrototypeOf = createCommonjsModule(function (module) {
|
|
20
|
-
function _setPrototypeOf(o, p) {
|
|
21
|
-
module.exports = _setPrototypeOf = Object.setPrototypeOf || (function _setPrototypeOf(o, p) {
|
|
22
|
-
o.__proto__ = p;
|
|
23
|
-
return o;
|
|
24
|
-
});
|
|
25
|
-
return _setPrototypeOf(o, p);
|
|
26
|
-
}
|
|
27
|
-
module.exports = _setPrototypeOf;
|
|
28
|
-
});
|
|
29
|
-
function _inheritsLoose(subClass, superClass) {
|
|
30
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
31
|
-
subClass.prototype.constructor = subClass;
|
|
32
|
-
setPrototypeOf(subClass, superClass);
|
|
33
|
-
}
|
|
34
|
-
var inheritsLoose = _inheritsLoose;
|
|
35
|
-
var setStatic_1 = createCommonjsModule(function (module, exports) {
|
|
36
|
-
exports.__esModule = true;
|
|
37
|
-
exports.default = void 0;
|
|
38
|
-
var setStatic = function setStatic(key, value) {
|
|
39
|
-
return function (BaseComponent) {
|
|
40
|
-
BaseComponent[key] = value;
|
|
41
|
-
return BaseComponent;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
var _default = setStatic;
|
|
45
|
-
exports.default = _default;
|
|
46
|
-
});
|
|
47
|
-
unwrapExports(setStatic_1);
|
|
48
|
-
var setDisplayName_1 = createCommonjsModule(function (module, exports) {
|
|
49
|
-
exports.__esModule = true;
|
|
50
|
-
exports.default = void 0;
|
|
51
|
-
var _setStatic = interopRequireDefault(setStatic_1);
|
|
52
|
-
var setDisplayName = function setDisplayName(displayName) {
|
|
53
|
-
return (0, _setStatic.default)('displayName', displayName);
|
|
54
|
-
};
|
|
55
|
-
var _default = setDisplayName;
|
|
56
|
-
exports.default = _default;
|
|
57
|
-
});
|
|
58
|
-
unwrapExports(setDisplayName_1);
|
|
59
|
-
var getDisplayName_1 = createCommonjsModule(function (module, exports) {
|
|
60
|
-
exports.__esModule = true;
|
|
61
|
-
exports.default = void 0;
|
|
62
|
-
var getDisplayName = function getDisplayName(Component) {
|
|
63
|
-
if (typeof Component === 'string') {
|
|
64
|
-
return Component;
|
|
65
|
-
}
|
|
66
|
-
if (!Component) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
return Component.displayName || Component.name || 'Component';
|
|
70
|
-
};
|
|
71
|
-
var _default = getDisplayName;
|
|
72
|
-
exports.default = _default;
|
|
73
|
-
});
|
|
74
|
-
unwrapExports(getDisplayName_1);
|
|
75
|
-
var wrapDisplayName_1 = createCommonjsModule(function (module, exports) {
|
|
76
|
-
exports.__esModule = true;
|
|
77
|
-
exports.default = void 0;
|
|
78
|
-
var _getDisplayName = interopRequireDefault(getDisplayName_1);
|
|
79
|
-
var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
|
|
80
|
-
return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
|
|
81
|
-
};
|
|
82
|
-
var _default = wrapDisplayName;
|
|
83
|
-
exports.default = _default;
|
|
84
|
-
});
|
|
85
|
-
unwrapExports(wrapDisplayName_1);
|
|
86
|
-
const _react = _dll_react;
|
|
87
|
-
var shouldUpdate_1 = createCommonjsModule(function (module, exports) {
|
|
88
|
-
exports.__esModule = true;
|
|
89
|
-
exports.default = void 0;
|
|
90
|
-
var _inheritsLoose2 = interopRequireDefault(inheritsLoose);
|
|
91
|
-
var _setDisplayName = interopRequireDefault(setDisplayName_1);
|
|
92
|
-
var _wrapDisplayName = interopRequireDefault(wrapDisplayName_1);
|
|
93
|
-
var shouldUpdate = function shouldUpdate(test) {
|
|
94
|
-
return function (BaseComponent) {
|
|
95
|
-
var factory = (0, _react.createFactory)(BaseComponent);
|
|
96
|
-
var ShouldUpdate = (function (_Component) {
|
|
97
|
-
(0, _inheritsLoose2.default)(ShouldUpdate, _Component);
|
|
98
|
-
function ShouldUpdate() {
|
|
99
|
-
return _Component.apply(this, arguments) || this;
|
|
100
|
-
}
|
|
101
|
-
var _proto = ShouldUpdate.prototype;
|
|
102
|
-
_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
|
|
103
|
-
return test(this.props, nextProps);
|
|
104
|
-
};
|
|
105
|
-
_proto.render = function render() {
|
|
106
|
-
return factory(this.props);
|
|
107
|
-
};
|
|
108
|
-
return ShouldUpdate;
|
|
109
|
-
})(_react.Component);
|
|
110
|
-
{
|
|
111
|
-
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
var _default = shouldUpdate;
|
|
116
|
-
exports.default = _default;
|
|
117
|
-
});
|
|
118
|
-
unwrapExports(shouldUpdate_1);
|
|
119
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
120
|
-
function is(x, y) {
|
|
121
|
-
if (x === y) {
|
|
122
|
-
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
123
|
-
} else {
|
|
124
|
-
return x !== x && y !== y;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function shallowEqual(objA, objB) {
|
|
128
|
-
if (is(objA, objB)) {
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
var keysA = Object.keys(objA);
|
|
135
|
-
var keysB = Object.keys(objB);
|
|
136
|
-
if (keysA.length !== keysB.length) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
for (var i = 0; i < keysA.length; i++) {
|
|
140
|
-
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
141
|
-
return false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return true;
|
|
145
|
-
}
|
|
146
|
-
var shallowEqual_1 = shallowEqual;
|
|
147
|
-
var shallowEqual$1 = createCommonjsModule(function (module, exports) {
|
|
148
|
-
exports.__esModule = true;
|
|
149
|
-
exports.default = void 0;
|
|
150
|
-
var _shallowEqual = interopRequireDefault(shallowEqual_1);
|
|
151
|
-
var _default = _shallowEqual.default;
|
|
152
|
-
exports.default = _default;
|
|
153
|
-
});
|
|
154
|
-
unwrapExports(shallowEqual$1);
|
|
155
|
-
var pure_1 = createCommonjsModule(function (module, exports) {
|
|
156
|
-
exports.__esModule = true;
|
|
157
|
-
exports.default = void 0;
|
|
158
|
-
var _shouldUpdate = interopRequireDefault(shouldUpdate_1);
|
|
159
|
-
var _shallowEqual = interopRequireDefault(shallowEqual$1);
|
|
160
|
-
var _setDisplayName = interopRequireDefault(setDisplayName_1);
|
|
161
|
-
var _wrapDisplayName = interopRequireDefault(wrapDisplayName_1);
|
|
162
|
-
var pure = function pure(BaseComponent) {
|
|
163
|
-
var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
|
|
164
|
-
return !(0, _shallowEqual.default)(props, nextProps);
|
|
165
|
-
});
|
|
166
|
-
{
|
|
167
|
-
return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
var _default = pure;
|
|
171
|
-
exports.default = _default;
|
|
172
|
-
});
|
|
173
|
-
unwrapExports(pure_1);
|
|
174
|
-
const require$$0 = _dll_react;
|
|
175
|
-
const {SvgIcon: require$$2} = _dll_material_ui__core;
|
|
176
|
-
var createSvgIcon_1 = createCommonjsModule(function (module, exports) {
|
|
177
|
-
Object.defineProperty(exports, "__esModule", {
|
|
178
|
-
value: true
|
|
179
|
-
});
|
|
180
|
-
exports.default = void 0;
|
|
181
|
-
var _react = interopRequireDefault(require$$0);
|
|
182
|
-
var _pure = interopRequireDefault(pure_1);
|
|
183
|
-
var _SvgIcon = interopRequireDefault(require$$2);
|
|
184
|
-
function createSvgIcon(path, displayName) {
|
|
185
|
-
var Icon = function Icon(props) {
|
|
186
|
-
return _react.default.createElement(_SvgIcon.default, props, path);
|
|
187
|
-
};
|
|
188
|
-
Icon.displayName = ("").concat(displayName, "Icon");
|
|
189
|
-
Icon = (0, _pure.default)(Icon);
|
|
190
|
-
Icon.muiName = 'SvgIcon';
|
|
191
|
-
return Icon;
|
|
192
|
-
}
|
|
193
|
-
var _default = createSvgIcon;
|
|
194
|
-
exports.default = _default;
|
|
195
|
-
});
|
|
196
|
-
unwrapExports(createSvgIcon_1);
|
|
197
|
-
const require$$0$1 = _dll_react;
|
|
198
|
-
var Check = createCommonjsModule(function (module, exports) {
|
|
199
|
-
Object.defineProperty(exports, "__esModule", {
|
|
200
|
-
value: true
|
|
201
|
-
});
|
|
202
|
-
exports.default = void 0;
|
|
203
|
-
var _react = interopRequireDefault(require$$0$1);
|
|
204
|
-
var _createSvgIcon = interopRequireDefault(createSvgIcon_1);
|
|
205
|
-
var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
|
|
206
|
-
fill: "none",
|
|
207
|
-
d: "M0 0h24v24H0z"
|
|
208
|
-
}), _react.default.createElement("path", {
|
|
209
|
-
d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"
|
|
210
|
-
})), 'Check');
|
|
211
|
-
exports.default = _default;
|
|
212
|
-
});
|
|
213
|
-
var Check$1 = unwrapExports(Check);
|
|
214
|
-
const require$$0$2 = _dll_react;
|
|
215
|
-
var Close = createCommonjsModule(function (module, exports) {
|
|
216
|
-
Object.defineProperty(exports, "__esModule", {
|
|
217
|
-
value: true
|
|
218
|
-
});
|
|
219
|
-
exports.default = void 0;
|
|
220
|
-
var _react = interopRequireDefault(require$$0$2);
|
|
221
|
-
var _createSvgIcon = interopRequireDefault(createSvgIcon_1);
|
|
222
|
-
var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
|
|
223
|
-
d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
|
|
224
|
-
}), _react.default.createElement("path", {
|
|
225
|
-
fill: "none",
|
|
226
|
-
d: "M0 0h24v24H0z"
|
|
227
|
-
})), 'Close');
|
|
228
|
-
exports.default = _default;
|
|
229
|
-
});
|
|
230
|
-
var Close$1 = unwrapExports(Close);
|
|
231
|
-
const React = _dll_react;
|
|
232
|
-
const PropTypes = _dll_prop_types;
|
|
233
|
-
const {withStyles: withStyles} = _dll_material_ui__core;
|
|
234
|
-
const {color: color} = _dll_pie_lib__render_ui;
|
|
235
|
-
const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/evaluation-icon.jsx";
|
|
236
|
-
const getCorrectnessClass = (isCorrect, filled) => {
|
|
237
|
-
if (filled) {
|
|
238
|
-
return isCorrect ? 'correctFilled' : 'incorrectFilled';
|
|
239
|
-
}
|
|
240
|
-
return isCorrect ? 'correctEmpty' : 'incorrectEmpty';
|
|
241
|
-
};
|
|
242
|
-
const EvaluationIcon = ({classes, containerStyle, isCorrect, filled}) => {
|
|
243
|
-
const Icon = isCorrect ? Check$1 : Close$1;
|
|
244
|
-
const showCorrectness = isCorrect !== undefined;
|
|
245
|
-
const correctness = showCorrectness ? getCorrectnessClass(isCorrect, filled) : '';
|
|
246
|
-
return showCorrectness ? React.createElement(Icon, {
|
|
247
|
-
className: `${classes.icon} ${classes[correctness]}`,
|
|
248
|
-
style: containerStyle,
|
|
249
|
-
__self: undefined,
|
|
250
|
-
__source: {
|
|
251
|
-
fileName: _jsxFileName,
|
|
252
|
-
lineNumber: 22
|
|
253
|
-
}
|
|
254
|
-
}) : null;
|
|
255
|
-
};
|
|
256
|
-
EvaluationIcon.propTypes = {
|
|
257
|
-
classes: PropTypes.object,
|
|
258
|
-
containerStyle: PropTypes.object,
|
|
259
|
-
filled: PropTypes.bool,
|
|
260
|
-
isCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.number])
|
|
261
|
-
};
|
|
262
|
-
EvaluationIcon.defaultProps = {
|
|
263
|
-
classes: {},
|
|
264
|
-
containerStyle: {},
|
|
265
|
-
filled: false,
|
|
266
|
-
isCorrect: undefined
|
|
267
|
-
};
|
|
268
|
-
const styles = () => ({
|
|
269
|
-
correctEmpty: {
|
|
270
|
-
color: color.correct()
|
|
271
|
-
},
|
|
272
|
-
correctFilled: {
|
|
273
|
-
color: color.background(),
|
|
274
|
-
backgroundColor: color.correct()
|
|
275
|
-
},
|
|
276
|
-
incorrectEmpty: {
|
|
277
|
-
color: color.incorrect()
|
|
278
|
-
},
|
|
279
|
-
incorrectFilled: {
|
|
280
|
-
color: color.background(),
|
|
281
|
-
backgroundColor: color.incorrect()
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
var EvaluationIcon$1 = withStyles(styles)(EvaluationIcon);
|
|
285
|
-
var c = {
|
|
286
|
-
types: {
|
|
287
|
-
response: 'react-dnd-response'
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
const React$1 = _dll_react;
|
|
291
|
-
const PropTypes$1 = _dll_prop_types;
|
|
292
|
-
const {DragSource: DragSource} = _dll_pie_lib__drag;
|
|
293
|
-
const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
|
|
294
|
-
const {color: color$1} = _dll_pie_lib__render_ui;
|
|
295
|
-
const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/possible-response.jsx";
|
|
296
|
-
class PossibleResponse extends React$1.Component {
|
|
297
|
-
constructor(...args) {
|
|
298
|
-
super(...args);
|
|
299
|
-
PossibleResponse.prototype.__init.call(this);
|
|
300
|
-
}
|
|
301
|
-
__init() {
|
|
302
|
-
this.getClassname = () => {
|
|
303
|
-
const {classes, data: {isCorrect}} = this.props;
|
|
304
|
-
let styleProp;
|
|
305
|
-
switch (isCorrect) {
|
|
306
|
-
case undefined:
|
|
307
|
-
styleProp = null;
|
|
308
|
-
break;
|
|
309
|
-
case true:
|
|
310
|
-
styleProp = 'baseCorrect';
|
|
311
|
-
break;
|
|
312
|
-
default:
|
|
313
|
-
styleProp = 'baseIncorrect';
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
return styleProp ? classes[styleProp] : '';
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
render() {
|
|
320
|
-
const {classes, connectDragSource, containerStyle, data} = this.props;
|
|
321
|
-
const additionalClass = this.getClassname();
|
|
322
|
-
const evaluationStyle = {
|
|
323
|
-
alignSelf: 'center',
|
|
324
|
-
fontSize: 14,
|
|
325
|
-
paddingRight: 2
|
|
326
|
-
};
|
|
327
|
-
return connectDragSource(React$1.createElement('div', {
|
|
328
|
-
className: `${classes.base} ${additionalClass}`,
|
|
329
|
-
style: containerStyle,
|
|
330
|
-
__self: this,
|
|
331
|
-
__source: {
|
|
332
|
-
fileName: _jsxFileName$1,
|
|
333
|
-
lineNumber: 36
|
|
334
|
-
}
|
|
335
|
-
}, React$1.createElement('span', {
|
|
336
|
-
className: classes.span,
|
|
337
|
-
dangerouslySetInnerHTML: {
|
|
338
|
-
__html: data.value
|
|
339
|
-
},
|
|
340
|
-
__self: this,
|
|
341
|
-
__source: {
|
|
342
|
-
fileName: _jsxFileName$1,
|
|
343
|
-
lineNumber: 37
|
|
344
|
-
}
|
|
345
|
-
}), React$1.createElement(EvaluationIcon$1, {
|
|
346
|
-
isCorrect: data.isCorrect,
|
|
347
|
-
containerStyle: evaluationStyle,
|
|
348
|
-
__self: this,
|
|
349
|
-
__source: {
|
|
350
|
-
fileName: _jsxFileName$1,
|
|
351
|
-
lineNumber: 38
|
|
352
|
-
}
|
|
353
|
-
})));
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
PossibleResponse.propTypes = {
|
|
357
|
-
canDrag: PropTypes$1.bool.isRequired,
|
|
358
|
-
classes: PropTypes$1.object,
|
|
359
|
-
connectDragSource: PropTypes$1.func,
|
|
360
|
-
containerStyle: PropTypes$1.object,
|
|
361
|
-
data: PropTypes$1.object.isRequired,
|
|
362
|
-
onDragBegin: PropTypes$1.func.isRequired,
|
|
363
|
-
onDragEnd: PropTypes$1.func.isRequired
|
|
364
|
-
};
|
|
365
|
-
PossibleResponse.defaultProps = {
|
|
366
|
-
classes: {},
|
|
367
|
-
connectDragSource: () => {},
|
|
368
|
-
containerStyle: {}
|
|
369
|
-
};
|
|
370
|
-
const styles$1 = () => ({
|
|
371
|
-
base: {
|
|
372
|
-
backgroundColor: color$1.background(),
|
|
373
|
-
border: `1px solid ${color$1.primary()}`,
|
|
374
|
-
display: 'flex',
|
|
375
|
-
marginLeft: 2,
|
|
376
|
-
marginTop: 2,
|
|
377
|
-
width: 'fit-content'
|
|
378
|
-
},
|
|
379
|
-
baseCorrect: {
|
|
380
|
-
border: `2px solid ${color$1.correct()}`
|
|
381
|
-
},
|
|
382
|
-
baseIncorrect: {
|
|
383
|
-
border: `2px solid ${color$1.incorrect()}`
|
|
384
|
-
},
|
|
385
|
-
span: {
|
|
386
|
-
backgroundColor: color$1.background()
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
const Styled = withStyles$1(styles$1)(PossibleResponse);
|
|
390
|
-
const tileSource = {
|
|
391
|
-
canDrag(props) {
|
|
392
|
-
const {canDrag} = props;
|
|
393
|
-
return canDrag;
|
|
394
|
-
},
|
|
395
|
-
beginDrag(props) {
|
|
396
|
-
const {data, data: {id, value, containerIndex}, onDragBegin} = props;
|
|
397
|
-
onDragBegin(data);
|
|
398
|
-
return {
|
|
399
|
-
id,
|
|
400
|
-
value,
|
|
401
|
-
containerIndex
|
|
402
|
-
};
|
|
403
|
-
},
|
|
404
|
-
endDrag(props) {
|
|
405
|
-
props.onDragEnd();
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
var PossibleResponse$1 = DragSource(c.types.response, tileSource, (connect, monitor) => ({
|
|
409
|
-
connectDragSource: connect.dragSource(),
|
|
410
|
-
isDragging: monitor.isDragging()
|
|
411
|
-
}))(Styled);
|
|
412
|
-
const React$2 = _dll_react;
|
|
413
|
-
const PropTypes$2 = _dll_prop_types;
|
|
414
|
-
const {DropTarget: DropTarget} = _dll_pie_lib__drag;
|
|
415
|
-
const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
|
|
416
|
-
const {color: color$2} = _dll_pie_lib__render_ui;
|
|
417
|
-
const _jsxFileName$2 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/image-drop-target.jsx";
|
|
418
|
-
const ImageDropTarget = ({answers, canDrag, classes, containerStyle, draggingElement, duplicateResponses, onDragAnswerBegin, onDragAnswerEnd, connectDropTarget, isOverCurrent}) => connectDropTarget(React$2.createElement('div', {
|
|
419
|
-
className: `
|
|
420
|
-
${classes.responseContainer}
|
|
421
|
-
${draggingElement.id ? classes.responseContainerActive : ''}
|
|
422
|
-
`,
|
|
423
|
-
style: containerStyle,
|
|
424
|
-
__self: undefined,
|
|
425
|
-
__source: {
|
|
426
|
-
fileName: _jsxFileName$2,
|
|
427
|
-
lineNumber: 23
|
|
428
|
-
}
|
|
429
|
-
}, isOverCurrent && !duplicateResponses ? React$2.createElement('div', {
|
|
430
|
-
className: classes.dragOverContainer,
|
|
431
|
-
__self: undefined,
|
|
432
|
-
__source: {
|
|
433
|
-
fileName: _jsxFileName$2,
|
|
434
|
-
lineNumber: 32
|
|
435
|
-
}
|
|
436
|
-
}, React$2.createElement('span', {
|
|
437
|
-
dangerouslySetInnerHTML: {
|
|
438
|
-
__html: draggingElement.value
|
|
439
|
-
},
|
|
440
|
-
__self: undefined,
|
|
441
|
-
__source: {
|
|
442
|
-
fileName: _jsxFileName$2,
|
|
443
|
-
lineNumber: 33
|
|
444
|
-
}
|
|
445
|
-
})) : null, !isOverCurrent && answers.length || duplicateResponses && answers.length ? React$2.createElement('div', {
|
|
446
|
-
className: classes.answers,
|
|
447
|
-
__self: undefined,
|
|
448
|
-
__source: {
|
|
449
|
-
fileName: _jsxFileName$2,
|
|
450
|
-
lineNumber: 39
|
|
451
|
-
}
|
|
452
|
-
}, answers.map(answer => React$2.createElement(PossibleResponse$1, {
|
|
453
|
-
canDrag: canDrag,
|
|
454
|
-
containerStyle: answer.isCorrect === undefined ? {
|
|
455
|
-
borderWidth: 0
|
|
456
|
-
} : {},
|
|
457
|
-
key: answer.id,
|
|
458
|
-
data: answer,
|
|
459
|
-
onDragBegin: () => onDragAnswerBegin(answer),
|
|
460
|
-
onDragEnd: onDragAnswerEnd,
|
|
461
|
-
__self: undefined,
|
|
462
|
-
__source: {
|
|
463
|
-
fileName: _jsxFileName$2,
|
|
464
|
-
lineNumber: 41
|
|
465
|
-
}
|
|
466
|
-
}))) : null));
|
|
467
|
-
ImageDropTarget.propTypes = {
|
|
468
|
-
answer: PropTypes$2.object,
|
|
469
|
-
canDrag: PropTypes$2.bool.isRequired,
|
|
470
|
-
classes: PropTypes$2.object,
|
|
471
|
-
containerStyle: PropTypes$2.object.isRequired,
|
|
472
|
-
draggingElement: PropTypes$2.object.isRequired,
|
|
473
|
-
onDragAnswerBegin: PropTypes$2.func.isRequired,
|
|
474
|
-
onDragAnswerEnd: PropTypes$2.func.isRequired,
|
|
475
|
-
onDrop: PropTypes$2.func.isRequired
|
|
476
|
-
};
|
|
477
|
-
ImageDropTarget.defaultProps = {
|
|
478
|
-
answer: {},
|
|
479
|
-
classes: {}
|
|
480
|
-
};
|
|
481
|
-
const styles$2 = () => ({
|
|
482
|
-
answers: {
|
|
483
|
-
display: 'flex',
|
|
484
|
-
flexWrap: 'wrap'
|
|
485
|
-
},
|
|
486
|
-
dragOverContainer: {
|
|
487
|
-
backgroundColor: color$2.background(),
|
|
488
|
-
pointerEvents: 'none',
|
|
489
|
-
width: 'fit-content'
|
|
490
|
-
},
|
|
491
|
-
responseContainer: {
|
|
492
|
-
position: 'absolute'
|
|
493
|
-
},
|
|
494
|
-
responseContainerActive: {
|
|
495
|
-
border: `2px solid ${color$2.text()}`,
|
|
496
|
-
backgroundColor: 'rgba(230, 242, 252, .8)'
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
const Styled$1 = withStyles$2(styles$2)(ImageDropTarget);
|
|
500
|
-
const tileSource$1 = {
|
|
501
|
-
hover(props, monitor) {
|
|
502
|
-
monitor.isOver({
|
|
503
|
-
shallow: true
|
|
504
|
-
});
|
|
505
|
-
},
|
|
506
|
-
drop(props, monitor) {
|
|
507
|
-
const item = monitor.getItem();
|
|
508
|
-
props.onDrop(item);
|
|
509
|
-
}
|
|
510
|
-
};
|
|
511
|
-
var ImageDropTarget$1 = DropTarget(c.types.response, tileSource$1, (connect, monitor) => ({
|
|
512
|
-
connectDropTarget: connect.dropTarget(),
|
|
513
|
-
isOverCurrent: monitor.isOver({
|
|
514
|
-
shallow: true
|
|
515
|
-
})
|
|
516
|
-
}))(Styled$1);
|
|
517
|
-
const React$3 = _dll_react;
|
|
518
|
-
const {Component: Component} = _dll_react;
|
|
519
|
-
const PropTypes$3 = _dll_prop_types;
|
|
520
|
-
const {withStyles: withStyles$3} = _dll_material_ui__core;
|
|
521
|
-
const _jsxFileName$3 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/image-container.jsx";
|
|
522
|
-
class ImageContainer extends Component {
|
|
523
|
-
render() {
|
|
524
|
-
const {answers, canDrag, classes, draggingElement, duplicateResponses, image: {height, src, width}, onAnswerSelect, onDragAnswerBegin, onDragAnswerEnd, responseContainers} = this.props;
|
|
525
|
-
return React$3.createElement('div', {
|
|
526
|
-
className: classes.base,
|
|
527
|
-
__self: this,
|
|
528
|
-
__source: {
|
|
529
|
-
fileName: _jsxFileName$3,
|
|
530
|
-
lineNumber: 27
|
|
531
|
-
}
|
|
532
|
-
}, React$3.createElement('img', {
|
|
533
|
-
src: src,
|
|
534
|
-
height: height,
|
|
535
|
-
width: width,
|
|
536
|
-
__self: this,
|
|
537
|
-
__source: {
|
|
538
|
-
fileName: _jsxFileName$3,
|
|
539
|
-
lineNumber: 28
|
|
540
|
-
}
|
|
541
|
-
}), responseContainers.map((r, i) => {
|
|
542
|
-
const rHeight = r.height.replace('%', '') / 100 * height;
|
|
543
|
-
const rWidth = r.width.replace('%', '') / 100 * width;
|
|
544
|
-
const rLeft = r.x / 100 * width;
|
|
545
|
-
const rTop = r.y / 100 * height;
|
|
546
|
-
const answersParsed = answers.filter(a => a.containerIndex === r.index);
|
|
547
|
-
return React$3.createElement(ImageDropTarget$1, {
|
|
548
|
-
answers: answersParsed,
|
|
549
|
-
canDrag: canDrag,
|
|
550
|
-
containerStyle: {
|
|
551
|
-
height: rHeight,
|
|
552
|
-
width: rWidth,
|
|
553
|
-
left: rLeft,
|
|
554
|
-
top: rTop
|
|
555
|
-
},
|
|
556
|
-
duplicateResponses: duplicateResponses,
|
|
557
|
-
key: r.id + i,
|
|
558
|
-
draggingElement: draggingElement,
|
|
559
|
-
onDrop: item => onAnswerSelect(item, r.index),
|
|
560
|
-
onDragAnswerBegin: onDragAnswerBegin,
|
|
561
|
-
onDragAnswerEnd: onDragAnswerEnd,
|
|
562
|
-
__self: this,
|
|
563
|
-
__source: {
|
|
564
|
-
fileName: _jsxFileName$3,
|
|
565
|
-
lineNumber: 41
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
}));
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
ImageContainer.propTypes = {
|
|
572
|
-
answers: PropTypes$3.array.isRequired,
|
|
573
|
-
canDrag: PropTypes$3.bool.isRequired,
|
|
574
|
-
classes: PropTypes$3.object,
|
|
575
|
-
draggingElement: PropTypes$3.shape({}).isRequired,
|
|
576
|
-
duplicateResponses: PropTypes$3.bool,
|
|
577
|
-
image: PropTypes$3.object.isRequired,
|
|
578
|
-
onAnswerSelect: PropTypes$3.func.isRequired,
|
|
579
|
-
onDragAnswerBegin: PropTypes$3.func.isRequired,
|
|
580
|
-
onDragAnswerEnd: PropTypes$3.func.isRequired,
|
|
581
|
-
responseContainers: PropTypes$3.array.isRequired
|
|
582
|
-
};
|
|
583
|
-
ImageContainer.defaultProps = {
|
|
584
|
-
classes: {},
|
|
585
|
-
duplicateResponses: false
|
|
586
|
-
};
|
|
587
|
-
const styles$3 = theme => ({
|
|
588
|
-
base: {
|
|
589
|
-
margin: theme.spacing.unit * 2,
|
|
590
|
-
position: 'relative'
|
|
591
|
-
}
|
|
592
|
-
});
|
|
593
|
-
var Image = withStyles$3(styles$3)(ImageContainer);
|
|
594
|
-
const React$4 = _dll_react;
|
|
595
|
-
const PropTypes$4 = _dll_prop_types;
|
|
596
|
-
const {withStyles: withStyles$4} = _dll_material_ui__core;
|
|
597
|
-
const {color: color$3} = _dll_pie_lib__render_ui;
|
|
598
|
-
const _jsxFileName$4 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/interactive-section.jsx";
|
|
599
|
-
class InteractiveSection extends React$4.Component {
|
|
600
|
-
getClassname() {
|
|
601
|
-
const {classes, responseCorrect} = this.props;
|
|
602
|
-
let styleProp;
|
|
603
|
-
switch (responseCorrect) {
|
|
604
|
-
case undefined:
|
|
605
|
-
styleProp = 'interactiveDefault';
|
|
606
|
-
break;
|
|
607
|
-
case true:
|
|
608
|
-
styleProp = 'interactiveCorrect';
|
|
609
|
-
break;
|
|
610
|
-
default:
|
|
611
|
-
styleProp = 'interactiveIncorrect';
|
|
612
|
-
break;
|
|
613
|
-
}
|
|
614
|
-
return classes[styleProp];
|
|
615
|
-
}
|
|
616
|
-
render() {
|
|
617
|
-
const {children, responseCorrect} = this.props;
|
|
618
|
-
const classname = this.getClassname();
|
|
619
|
-
const evaluationStyle = {
|
|
620
|
-
display: 'flex',
|
|
621
|
-
margin: '0 auto',
|
|
622
|
-
marginTop: -14
|
|
623
|
-
};
|
|
624
|
-
return React$4.createElement('div', {
|
|
625
|
-
className: classname,
|
|
626
|
-
__self: this,
|
|
627
|
-
__source: {
|
|
628
|
-
fileName: _jsxFileName$4,
|
|
629
|
-
lineNumber: 34
|
|
630
|
-
}
|
|
631
|
-
}, React$4.createElement(EvaluationIcon$1, {
|
|
632
|
-
containerStyle: evaluationStyle,
|
|
633
|
-
filled: true,
|
|
634
|
-
isCorrect: responseCorrect,
|
|
635
|
-
__self: this,
|
|
636
|
-
__source: {
|
|
637
|
-
fileName: _jsxFileName$4,
|
|
638
|
-
lineNumber: 35
|
|
639
|
-
}
|
|
640
|
-
}), children);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
InteractiveSection.propTypes = {
|
|
644
|
-
classes: PropTypes$4.object,
|
|
645
|
-
children: PropTypes$4.oneOfType([PropTypes$4.element, PropTypes$4.array]).isRequired,
|
|
646
|
-
responseCorrect: PropTypes$4.oneOfType([PropTypes$4.bool, PropTypes$4.number])
|
|
647
|
-
};
|
|
648
|
-
InteractiveSection.defaultProps = {
|
|
649
|
-
classes: {},
|
|
650
|
-
responseCorrect: undefined
|
|
651
|
-
};
|
|
652
|
-
const styles$4 = () => ({
|
|
653
|
-
interactiveDefault: {
|
|
654
|
-
border: `1px solid ${color$3.disabled()}`
|
|
655
|
-
},
|
|
656
|
-
interactiveCorrect: {
|
|
657
|
-
border: `2px solid ${color$3.correct()}`
|
|
658
|
-
},
|
|
659
|
-
interactiveIncorrect: {
|
|
660
|
-
border: `2px solid ${color$3.incorrect()}`
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
var InteractiveSection$1 = withStyles$4(styles$4)(InteractiveSection);
|
|
664
|
-
const React$5 = _dll_react;
|
|
665
|
-
const PropTypes$5 = _dll_prop_types;
|
|
666
|
-
const {DropTarget: DropTarget$1} = _dll_pie_lib__drag;
|
|
667
|
-
const {withStyles: withStyles$5} = _dll_material_ui__core;
|
|
668
|
-
const {color: color$4} = _dll_pie_lib__render_ui;
|
|
669
|
-
const _jsxFileName$5 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/possible-responses.jsx";
|
|
670
|
-
const PossibleResponses = ({canDrag, classes, connectDropTarget, data, isOverCurrent, onDragBegin, onDragEnd}) => connectDropTarget(React$5.createElement('div', {
|
|
671
|
-
className: `${classes.base} ${isOverCurrent ? classes.active : ''}`,
|
|
672
|
-
__self: undefined,
|
|
673
|
-
__source: {
|
|
674
|
-
fileName: _jsxFileName$5,
|
|
675
|
-
lineNumber: 13
|
|
676
|
-
}
|
|
677
|
-
}, data.map(item => React$5.createElement(PossibleResponse$1, {
|
|
678
|
-
canDrag: canDrag,
|
|
679
|
-
key: item.id,
|
|
680
|
-
data: item,
|
|
681
|
-
onDragBegin: onDragBegin,
|
|
682
|
-
onDragEnd: onDragEnd,
|
|
683
|
-
__self: undefined,
|
|
684
|
-
__source: {
|
|
685
|
-
fileName: _jsxFileName$5,
|
|
686
|
-
lineNumber: 15
|
|
687
|
-
}
|
|
688
|
-
}))));
|
|
689
|
-
PossibleResponses.propTypes = {
|
|
690
|
-
canDrag: PropTypes$5.bool.isRequired,
|
|
691
|
-
classes: PropTypes$5.object,
|
|
692
|
-
data: PropTypes$5.array.isRequired,
|
|
693
|
-
onAnswerRemove: PropTypes$5.func.isRequired,
|
|
694
|
-
onDragBegin: PropTypes$5.func.isRequired,
|
|
695
|
-
onDragEnd: PropTypes$5.func.isRequired
|
|
696
|
-
};
|
|
697
|
-
PossibleResponses.defaultProps = {
|
|
698
|
-
classes: {}
|
|
699
|
-
};
|
|
700
|
-
const styles$5 = theme => ({
|
|
701
|
-
active: {
|
|
702
|
-
border: `1px solid ${color$4.primary()}`
|
|
703
|
-
},
|
|
704
|
-
base: {
|
|
705
|
-
backgroundColor: color$4.background(),
|
|
706
|
-
display: 'flex',
|
|
707
|
-
flexWrap: 'wrap',
|
|
708
|
-
justifyContent: 'center',
|
|
709
|
-
padding: theme.spacing.unit * 2
|
|
710
|
-
}
|
|
711
|
-
});
|
|
712
|
-
const Styled$2 = withStyles$5(styles$5)(PossibleResponses);
|
|
713
|
-
const tileSource$2 = {
|
|
714
|
-
hover(props, monitor) {
|
|
715
|
-
monitor.isOver({
|
|
716
|
-
shallow: true
|
|
717
|
-
});
|
|
718
|
-
},
|
|
719
|
-
drop(props, monitor) {
|
|
720
|
-
const item = monitor.getItem();
|
|
721
|
-
props.onAnswerRemove(item);
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
var PossibleResponses$1 = DropTarget$1(c.types.response, tileSource$2, (connect, monitor) => ({
|
|
725
|
-
connectDropTarget: connect.dropTarget(),
|
|
726
|
-
isOverCurrent: monitor.isOver({
|
|
727
|
-
shallow: true
|
|
728
|
-
})
|
|
729
|
-
}))(Styled$2);
|
|
730
|
-
const getAllCorrectAnswers = (answers, responses) => answers.map(answer => ({
|
|
731
|
-
...answer,
|
|
732
|
-
isCorrect: responses[answer.containerIndex].includes(answer.value)
|
|
733
|
-
}));
|
|
734
|
-
const getValidAnswer = (answer, response) => response[answer.containerIndex].filter(res => res === answer.value);
|
|
735
|
-
const getUniqueCorrectAnswers = (answers, validResponses) => {
|
|
736
|
-
let finalAnswers = answers;
|
|
737
|
-
answers.forEach(answer1 => {
|
|
738
|
-
const valuesToParse = answers.filter(answer2 => answer2.value === answer1.value && answer2.containerIndex === answer1.containerIndex);
|
|
739
|
-
if (valuesToParse.length > 1) {
|
|
740
|
-
valuesToParse.shift();
|
|
741
|
-
valuesToParse.forEach((value, index) => {
|
|
742
|
-
finalAnswers = finalAnswers.map(finalAnswer => {
|
|
743
|
-
if (finalAnswer.id === value.id) {
|
|
744
|
-
let valid = getValidAnswer(finalAnswer, validResponses);
|
|
745
|
-
return {
|
|
746
|
-
...finalAnswer,
|
|
747
|
-
isCorrect: valid.length > index + 1
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
return finalAnswer;
|
|
751
|
-
});
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
return finalAnswers;
|
|
756
|
-
};
|
|
757
|
-
const getAnswersCorrectness = (answers, validation) => {
|
|
758
|
-
const {validResponse: {value}, altResponses} = validation;
|
|
759
|
-
const allCorrect = getAllCorrectAnswers(answers, value);
|
|
760
|
-
const uniqueAnswers = getUniqueCorrectAnswers(allCorrect, value);
|
|
761
|
-
const noOfCorrect = uniqueAnswers.filter(answer => answer.isCorrect).length;
|
|
762
|
-
if (noOfCorrect < uniqueAnswers.length && (altResponses && altResponses.length)) {
|
|
763
|
-
const altUniqueStack = altResponses.map(altResponse => {
|
|
764
|
-
const altValue = altResponse.value;
|
|
765
|
-
const altAllCorrect = getAllCorrectAnswers(answers, altValue);
|
|
766
|
-
return getUniqueCorrectAnswers(altAllCorrect, altValue);
|
|
767
|
-
});
|
|
768
|
-
return altUniqueStack.sort((a, b) => b.filter(c => c.isCorrect).length - a.filter(c => c.isCorrect).length)[0];
|
|
769
|
-
}
|
|
770
|
-
return uniqueAnswers;
|
|
771
|
-
};
|
|
772
|
-
const React$6 = _dll_react;
|
|
773
|
-
const PropTypes$6 = _dll_prop_types;
|
|
774
|
-
const {Typography: Typography} = _dll_material_ui__core;
|
|
775
|
-
const {withDragContext: withDragContext} = _dll_pie_lib__drag;
|
|
776
|
-
const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
|
|
777
|
-
const _ = _dll_lodash;
|
|
778
|
-
const _jsxFileName$6 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/image-cloze-association/src/root.jsx";
|
|
779
|
-
const generateId = () => Math.random().toString(36).substring(2) + new Date().getTime().toString(36);
|
|
780
|
-
class ImageClozeAssociationComponent extends React$6.Component {
|
|
781
|
-
constructor(props) {
|
|
782
|
-
super(props);
|
|
783
|
-
ImageClozeAssociationComponent.prototype.__init.call(this);
|
|
784
|
-
ImageClozeAssociationComponent.prototype.__init2.call(this);
|
|
785
|
-
ImageClozeAssociationComponent.prototype.__init3.call(this);
|
|
786
|
-
ImageClozeAssociationComponent.prototype.__init4.call(this);
|
|
787
|
-
const {model: {possibleResponses, responseContainers, duplicateResponses, maxResponsePerZone}, session} = props;
|
|
788
|
-
let {answers} = session || ({});
|
|
789
|
-
const possibleResponsesWithIds = (possibleResponses || []).map((item, index) => ({
|
|
790
|
-
value: item,
|
|
791
|
-
id: `${index}`
|
|
792
|
-
}));
|
|
793
|
-
answers = _(answers || []).groupBy('containerIndex').map(grp => grp.slice(-(maxResponsePerZone || 1))).flatMap().map((answer, index) => ({
|
|
794
|
-
...answer,
|
|
795
|
-
id: `${index}`
|
|
796
|
-
})).filter(answer => answer.containerIndex < responseContainers.length).value();
|
|
797
|
-
const possibleResponsesFiltered = possibleResponsesWithIds.filter(response => !answers.find(answer => answer.value === response.value));
|
|
798
|
-
this.state = {
|
|
799
|
-
answers: answers || [],
|
|
800
|
-
draggingElement: {
|
|
801
|
-
id: '',
|
|
802
|
-
value: ''
|
|
803
|
-
},
|
|
804
|
-
possibleResponses: duplicateResponses ? possibleResponsesWithIds : possibleResponsesFiltered,
|
|
805
|
-
responseContainers: responseContainers.map((item, index) => ({
|
|
806
|
-
index,
|
|
807
|
-
...item,
|
|
808
|
-
id: `${index}`
|
|
809
|
-
})),
|
|
810
|
-
maxResponsePerZone: maxResponsePerZone || 1
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
__init() {
|
|
814
|
-
this.beginDrag = draggingElement => {
|
|
815
|
-
this.setState({
|
|
816
|
-
draggingElement
|
|
817
|
-
});
|
|
818
|
-
};
|
|
819
|
-
}
|
|
820
|
-
__init2() {
|
|
821
|
-
this.handleOnDragEnd = () => {
|
|
822
|
-
this.setState({
|
|
823
|
-
draggingElement: {
|
|
824
|
-
id: '',
|
|
825
|
-
value: ''
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
__init3() {
|
|
831
|
-
this.handleOnAnswerSelect = (answer, responseContainerIndex) => {
|
|
832
|
-
const {model: {duplicateResponses}, updateAnswer} = this.props;
|
|
833
|
-
const {answers, possibleResponses, maxResponsePerZone} = this.state;
|
|
834
|
-
let answersToStore;
|
|
835
|
-
if (maxResponsePerZone === answers.filter(a => a.containerIndex === responseContainerIndex).length) {
|
|
836
|
-
const answersInThisContainer = answers.filter(a => a.containerIndex === responseContainerIndex);
|
|
837
|
-
const answersInOtherContainers = answers.filter(b => b.containerIndex !== responseContainerIndex);
|
|
838
|
-
const shiftedItem = answersInThisContainer[0];
|
|
839
|
-
answersInThisContainer.shift();
|
|
840
|
-
if (!duplicateResponses) {
|
|
841
|
-
possibleResponses.push({
|
|
842
|
-
...shiftedItem,
|
|
843
|
-
containerIndex: '',
|
|
844
|
-
id: `${_.max(possibleResponses.map(c => parseInt(c.id)).filter(id => !isNaN(id))) + 1}`
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
answersToStore = [...answersInThisContainer, ...answersInOtherContainers.filter(a => duplicateResponses ? true : a.value !== answer.value), {
|
|
848
|
-
...answer,
|
|
849
|
-
containerIndex: responseContainerIndex,
|
|
850
|
-
...duplicateResponses ? {
|
|
851
|
-
id: generateId()
|
|
852
|
-
} : {}
|
|
853
|
-
}];
|
|
854
|
-
} else {
|
|
855
|
-
answersToStore = [...answers.filter(a => duplicateResponses ? true : a.value !== answer.value), {
|
|
856
|
-
...answer,
|
|
857
|
-
containerIndex: responseContainerIndex,
|
|
858
|
-
...duplicateResponses ? {
|
|
859
|
-
id: generateId()
|
|
860
|
-
} : {}
|
|
861
|
-
}];
|
|
862
|
-
}
|
|
863
|
-
this.setState({
|
|
864
|
-
answers: answersToStore,
|
|
865
|
-
possibleResponses: duplicateResponses ? possibleResponses : possibleResponses.filter(response => response.value !== answer.value)
|
|
866
|
-
});
|
|
867
|
-
updateAnswer(answersToStore);
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
|
-
__init4() {
|
|
871
|
-
this.handleOnAnswerRemove = answer => {
|
|
872
|
-
const {model: {duplicateResponses}, updateAnswer} = this.props;
|
|
873
|
-
const {answers, possibleResponses} = this.state;
|
|
874
|
-
const answersToStore = answers.filter(a => a.id !== answer.id);
|
|
875
|
-
const shouldNotPushInPossibleResponses = answer.containerIndex === undefined;
|
|
876
|
-
this.setState({
|
|
877
|
-
answers: answersToStore,
|
|
878
|
-
possibleResponses: duplicateResponses || shouldNotPushInPossibleResponses ? possibleResponses : [...possibleResponses, {
|
|
879
|
-
...answer,
|
|
880
|
-
containerIndex: undefined
|
|
881
|
-
}]
|
|
882
|
-
});
|
|
883
|
-
updateAnswer(answersToStore);
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
render() {
|
|
887
|
-
const {model: {disabled, duplicateResponses, image, stimulus, responseCorrect, validation, teacherInstructions}} = this.props;
|
|
888
|
-
const {answers, draggingElement, possibleResponses, responseContainers} = this.state;
|
|
889
|
-
const answersToShow = responseCorrect !== undefined ? getAnswersCorrectness(answers, validation) : answers;
|
|
890
|
-
return React$6.createElement('div', {
|
|
891
|
-
__self: this,
|
|
892
|
-
__source: {
|
|
893
|
-
fileName: _jsxFileName$6,
|
|
894
|
-
lineNumber: 217
|
|
895
|
-
}
|
|
896
|
-
}, teacherInstructions && React$6.createElement(Collapsible, {
|
|
897
|
-
labels: {
|
|
898
|
-
hidden: 'Show Teacher Instructions',
|
|
899
|
-
visible: 'Hide Teacher Instructions'
|
|
900
|
-
},
|
|
901
|
-
__self: this,
|
|
902
|
-
__source: {
|
|
903
|
-
fileName: _jsxFileName$6,
|
|
904
|
-
lineNumber: 219
|
|
905
|
-
}
|
|
906
|
-
}, React$6.createElement('div', {
|
|
907
|
-
dangerouslySetInnerHTML: {
|
|
908
|
-
__html: teacherInstructions
|
|
909
|
-
},
|
|
910
|
-
__self: this,
|
|
911
|
-
__source: {
|
|
912
|
-
fileName: _jsxFileName$6,
|
|
913
|
-
lineNumber: 225
|
|
914
|
-
}
|
|
915
|
-
})), React$6.createElement(Typography, {
|
|
916
|
-
__self: this,
|
|
917
|
-
__source: {
|
|
918
|
-
fileName: _jsxFileName$6,
|
|
919
|
-
lineNumber: 229
|
|
920
|
-
}
|
|
921
|
-
}, React$6.createElement('span', {
|
|
922
|
-
dangerouslySetInnerHTML: {
|
|
923
|
-
__html: stimulus
|
|
924
|
-
},
|
|
925
|
-
__self: this,
|
|
926
|
-
__source: {
|
|
927
|
-
fileName: _jsxFileName$6,
|
|
928
|
-
lineNumber: 230
|
|
929
|
-
}
|
|
930
|
-
})), React$6.createElement(InteractiveSection$1, {
|
|
931
|
-
responseCorrect: responseCorrect,
|
|
932
|
-
__self: this,
|
|
933
|
-
__source: {
|
|
934
|
-
fileName: _jsxFileName$6,
|
|
935
|
-
lineNumber: 233
|
|
936
|
-
}
|
|
937
|
-
}, React$6.createElement(Image, {
|
|
938
|
-
canDrag: !disabled,
|
|
939
|
-
answers: answersToShow,
|
|
940
|
-
draggingElement: draggingElement,
|
|
941
|
-
duplicateResponses: duplicateResponses,
|
|
942
|
-
image: image,
|
|
943
|
-
onAnswerSelect: this.handleOnAnswerSelect,
|
|
944
|
-
onDragAnswerBegin: this.beginDrag,
|
|
945
|
-
onDragAnswerEnd: this.handleOnDragEnd,
|
|
946
|
-
responseContainers: responseContainers,
|
|
947
|
-
__self: this,
|
|
948
|
-
__source: {
|
|
949
|
-
fileName: _jsxFileName$6,
|
|
950
|
-
lineNumber: 234
|
|
951
|
-
}
|
|
952
|
-
}), React$6.createElement(PossibleResponses$1, {
|
|
953
|
-
canDrag: !disabled,
|
|
954
|
-
data: possibleResponses,
|
|
955
|
-
onAnswerRemove: this.handleOnAnswerRemove,
|
|
956
|
-
onDragBegin: this.beginDrag,
|
|
957
|
-
onDragEnd: this.handleOnDragEnd,
|
|
958
|
-
__self: this,
|
|
959
|
-
__source: {
|
|
960
|
-
fileName: _jsxFileName$6,
|
|
961
|
-
lineNumber: 246
|
|
962
|
-
}
|
|
963
|
-
})));
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
ImageClozeAssociationComponent.propTypes = {
|
|
967
|
-
classes: PropTypes$6.object,
|
|
968
|
-
model: PropTypes$6.object.isRequired,
|
|
969
|
-
session: PropTypes$6.object,
|
|
970
|
-
updateAnswer: PropTypes$6.func.isRequired
|
|
971
|
-
};
|
|
972
|
-
ImageClozeAssociationComponent.defaultProps = {
|
|
973
|
-
classes: {}
|
|
974
|
-
};
|
|
975
|
-
var ImageClozeAssociationComponent$1 = withDragContext(ImageClozeAssociationComponent);
|
|
976
|
-
const React$7 = _dll_react;
|
|
977
|
-
const ReactDOM = _dll_react_dom;
|
|
978
|
-
const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
|
|
979
|
-
const {ModelSetEvent: ModelSetEvent} = _dll_pie_framework__pie_player_events;
|
|
980
|
-
const {SessionChangedEvent: SessionChangedEvent} = _dll_pie_framework__pie_player_events;
|
|
981
|
-
class ImageClozeAssociation extends HTMLElement {
|
|
982
|
-
set model(m) {
|
|
983
|
-
this._model = m;
|
|
984
|
-
this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
|
|
985
|
-
this._render();
|
|
986
|
-
}
|
|
987
|
-
isComplete() {
|
|
988
|
-
if (!this._session) {
|
|
989
|
-
return false;
|
|
990
|
-
}
|
|
991
|
-
return Array.isArray(this._session.answers) && this._session.answers.length > 0;
|
|
992
|
-
}
|
|
993
|
-
set session(s) {
|
|
994
|
-
if (s && !s.answers) {
|
|
995
|
-
s.answers = [];
|
|
996
|
-
}
|
|
997
|
-
this._session = s;
|
|
998
|
-
this._render();
|
|
999
|
-
}
|
|
1000
|
-
updateAnswer(data) {
|
|
1001
|
-
this._session.answers = data;
|
|
1002
|
-
this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
|
|
1003
|
-
this._render();
|
|
1004
|
-
}
|
|
1005
|
-
connectedCallback() {
|
|
1006
|
-
this._render();
|
|
1007
|
-
}
|
|
1008
|
-
_render() {
|
|
1009
|
-
if (this._model && this._session) {
|
|
1010
|
-
const el = React$7.createElement(ImageClozeAssociationComponent$1, {
|
|
1011
|
-
model: this._model,
|
|
1012
|
-
session: this._session,
|
|
1013
|
-
updateAnswer: this.updateAnswer.bind(this)
|
|
1014
|
-
});
|
|
1015
|
-
ReactDOM.render(el, this, () => {
|
|
1016
|
-
renderMath(this);
|
|
1017
|
-
});
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
export default ImageClozeAssociation;
|