@pie-element/drag-in-the-blank 4.6.1-beta.1 → 4.6.1-beta.4

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.
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.tileSource = exports["default"] = exports.BlankContent = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
10
+ var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
11
+ var _reactDnd = require("react-dnd");
12
+ var _styles = require("@material-ui/core/styles");
13
+ var _markupUtils = require("./markupUtils");
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+ var GripIcon = function GripIcon(_ref) {
16
+ var style = _ref.style;
17
+ return /*#__PURE__*/_react["default"].createElement("span", {
18
+ style: style
19
+ }, /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], {
20
+ style: {
21
+ margin: '0 -16px'
22
+ }
23
+ }), /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], null));
24
+ };
25
+ GripIcon.propTypes = {
26
+ style: _propTypes["default"].object
27
+ };
28
+ var BlankContent = (0, _styles.withStyles)(function (theme) {
29
+ return {
30
+ choice: {
31
+ display: 'inline-flex',
32
+ minWidth: '178px',
33
+ minHeight: '36px',
34
+ background: '#FFF',
35
+ boxSizing: 'border-box',
36
+ borderRadius: '3px',
37
+ overflow: 'hidden',
38
+ position: 'relative',
39
+ padding: '8px 35px 8px 35px',
40
+ cursor: 'grab'
41
+ },
42
+ deleteIcon: {
43
+ position: 'absolute',
44
+ top: '6px',
45
+ right: '0',
46
+ color: '#9B9B9B',
47
+ zIndex: 2,
48
+ '& :hover': {
49
+ cursor: 'pointer',
50
+ color: '#000000'
51
+ }
52
+ }
53
+ };
54
+ })(function (props) {
55
+ var classes = props.classes,
56
+ connectDragSource = props.connectDragSource,
57
+ choice = props.choice,
58
+ onClick = props.onClick,
59
+ onRemoveChoice = props.onRemoveChoice,
60
+ error = props.error;
61
+ return connectDragSource( /*#__PURE__*/_react["default"].createElement("div", {
62
+ className: classes.choice,
63
+ style: {
64
+ border: "1px solid ".concat(error ? 'red' : '#C0C3CF')
65
+ },
66
+ onClick: onClick
67
+ }, /*#__PURE__*/_react["default"].createElement(GripIcon, {
68
+ style: {
69
+ position: 'absolute',
70
+ top: '6px',
71
+ left: '15px',
72
+ color: '#9B9B9B',
73
+ zIndex: 2
74
+ }
75
+ }), /*#__PURE__*/_react["default"].createElement("span", {
76
+ dangerouslySetInnerHTML: {
77
+ __html: choice.value
78
+ }
79
+ }), /*#__PURE__*/_react["default"].createElement(_Delete["default"], {
80
+ className: classes.deleteIcon,
81
+ onClick: function onClick(e) {
82
+ e.preventDefault();
83
+ e.stopPropagation();
84
+ onRemoveChoice(e);
85
+ }
86
+ })));
87
+ });
88
+ exports.BlankContent = BlankContent;
89
+ var tileSource = {
90
+ canDrag: function canDrag(props) {
91
+ if ((0, _markupUtils.choiceIsEmpty)(props.choice)) {
92
+ alert('You need to define a value for an answer choice before it can be associated with a response area.');
93
+ return false;
94
+ }
95
+ return !props.disabled;
96
+ },
97
+ beginDrag: function beginDrag(props) {
98
+ return {
99
+ id: props.targetId,
100
+ value: props.choice,
101
+ instanceId: props.instanceId
102
+ };
103
+ }
104
+ };
105
+ exports.tileSource = tileSource;
106
+ var _default = (0, _reactDnd.DragSource)('drag-in-the-blank-choice', tileSource, function (connect, monitor) {
107
+ return {
108
+ connectDragSource: connect.dragSource(),
109
+ isDragging: monitor.isDragging()
110
+ };
111
+ })(BlankContent);
112
+ exports["default"] = _default;
113
+ //# sourceMappingURL=choice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_MoreVert","_Delete","_reactDnd","_styles","_markupUtils","_propTypes","GripIcon","_ref","style","createElement","margin","propTypes","PropTypes","object","BlankContent","withStyles","theme","choice","display","minWidth","minHeight","background","boxSizing","borderRadius","overflow","position","padding","cursor","deleteIcon","top","right","color","zIndex","props","classes","connectDragSource","onClick","onRemoveChoice","error","className","border","concat","left","dangerouslySetInnerHTML","__html","value","e","preventDefault","stopPropagation","exports","tileSource","canDrag","choiceIsEmpty","alert","disabled","beginDrag","id","targetId","instanceId","_default","DragSource","connect","monitor","dragSource","isDragging"],"sources":["../src/choice.jsx"],"sourcesContent":["import React from 'react';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport Delete from '@material-ui/icons/Delete';\nimport { DragSource } from 'react-dnd';\nimport { withStyles } from '@material-ui/core/styles';\nimport { choiceIsEmpty } from './markupUtils';\nimport PropTypes from 'prop-types';\n\nconst GripIcon = ({ style }) => {\n return (\n <span style={style}>\n <MoreVert style={{ margin: '0 -16px' }} />\n <MoreVert />\n </span>\n );\n};\n\nGripIcon.propTypes = {\n style: PropTypes.object,\n};\n\nexport const BlankContent = withStyles((theme) => ({\n choice: {\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: '#FFF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 35px 8px 35px',\n cursor: 'grab',\n },\n deleteIcon: {\n position: 'absolute',\n top: '6px',\n right: '0',\n color: '#9B9B9B',\n zIndex: 2,\n\n '& :hover': {\n cursor: 'pointer',\n color: '#000000',\n },\n },\n}))((props) => {\n const { classes, connectDragSource, choice, onClick, onRemoveChoice, error } = props;\n\n return connectDragSource(\n <div className={classes.choice} style={{ border: `1px solid ${error ? 'red' : '#C0C3CF'}` }} onClick={onClick}>\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: '#9B9B9B',\n zIndex: 2,\n }}\n />\n\n <span dangerouslySetInnerHTML={{ __html: choice.value }} />\n\n <Delete\n className={classes.deleteIcon}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n\n onRemoveChoice(e);\n }}\n />\n </div>,\n );\n});\n\nexport const tileSource = {\n canDrag(props) {\n if (choiceIsEmpty(props.choice)) {\n alert('You need to define a value for an answer choice before it can be associated with a response area.');\n return false;\n }\n\n return !props.disabled;\n },\n beginDrag(props) {\n return {\n id: props.targetId,\n value: props.choice,\n instanceId: props.instanceId,\n };\n },\n};\n\nexport default DragSource('drag-in-the-blank-choice', tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging(),\n}))(BlankContent);\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAP,sBAAA,CAAAC,OAAA;AAEA,IAAMO,QAAQ,GAAG,SAAXA,QAAQA,CAAAC,IAAA,EAAkB;EAAA,IAAZC,KAAK,GAAAD,IAAA,CAALC,KAAK;EACvB,oBACEX,MAAA,YAAAY,aAAA;IAAMD,KAAK,EAAEA;EAAM,gBACjBX,MAAA,YAAAY,aAAA,CAACT,SAAA,WAAQ;IAACQ,KAAK,EAAE;MAAEE,MAAM,EAAE;IAAU;EAAE,CAAE,CAAC,eAC1Cb,MAAA,YAAAY,aAAA,CAACT,SAAA,WAAQ,MAAE,CACP,CAAC;AAEX,CAAC;AAEDM,QAAQ,CAACK,SAAS,GAAG;EACnBH,KAAK,EAAEI,qBAAS,CAACC;AACnB,CAAC;AAEM,IAAMC,YAAY,GAAG,IAAAC,kBAAU,EAAC,UAACC,KAAK;EAAA,OAAM;IACjDC,MAAM,EAAE;MACNC,OAAO,EAAE,aAAa;MACtBC,QAAQ,EAAE,OAAO;MACjBC,SAAS,EAAE,MAAM;MACjBC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AC,eAE3DhD,MAAA,YAAAY,aAAA,CAACR,OAAA,WAAM;IACLsC,SAAS,EAAEL,OAAO,CAACN,UAAW;IAC9BQ,OAAO,EAAE,SAAAA,QAACU,CAAC,EAAK;MACdA,CAAC,CAACC,cAAc,CAAC,CAAC;MAClBD,CAAC,CAACE,eAAe,CAAC,CAAC;MAEnBX,cAAc,CAACS,CAAC,CAAC;IACnB;EAAE,CACH,CACE,CACP,CAAC;AACH,CAAC,CAAC;AAACG,OAAA,CAAAnC,YAAA,GAAAA,YAAA;AAEI,IAAMoC,UAAU,GAAG;EACxBC,OAAO,WAAAA,QAAClB,KAAK,EAAE;IACb,IAAI,IAAAmB,0BAAa,EAACnB,KAAK,CAAChB,MAAM,CAAC,EAAE;MAC/BoC,KAAK,CAAC,mGAAmG,CAAC;MAC1G,OAAO,KAAK;IACd;IAEA,OAAO,CAACpB,KAAK,CAACqB,QAAQ;EACxB,CAAC;EACDC,SAAS,WAAAA,UAACtB,KAAK,EAAE;IACf,OAAO;MACLuB,EAAE,EAAEvB,KAAK,CAACwB,QAAQ;MAClBZ,KAAK,EAAEZ,KAAK,CAAChB,MAAM;MACnByC,UAAU,EAAEzB,KAAK,CAACyB;IACpB,CAAC;EACH;AACF,CAAC;AAACT,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAAA,IAAAS,QAAA,GAEa,IAAAC,oBAAU,EAAC,0BAA0B,EAAEV,UAAU,EAAE,UAACW,OAAO,EAAEC,OAAO;EAAA,OAAM;IACvF3B,iBAAiB,EAAE0B,OAAO,CAACE,UAAU,CAAC,CAAC;IACvCC,UAAU,EAAEF,OAAO,CAACE,UAAU,CAAC;EACjC,CAAC;AAAA,CAAC,CAAC,CAAClD,YAAY,CAAC;AAAAmC,OAAA,cAAAU,QAAA"}
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = exports.Choices = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _react = _interopRequireDefault(require("react"));
17
+ var _reactDom = _interopRequireDefault(require("react-dom"));
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+ var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
20
+ var _mathRendering = require("@pie-lib/math-rendering");
21
+ var _find = _interopRequireDefault(require("lodash/find"));
22
+ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
23
+ var _choice = _interopRequireDefault(require("./choice"));
24
+ var _markupUtils = require("./markupUtils");
25
+ var _styles = require("@material-ui/core/styles");
26
+ var _configUi = require("@pie-lib/config-ui");
27
+ 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; }
28
+ 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; }
29
+ 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); }; }
30
+ 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; } }
31
+ window.renMath = _mathRendering.renderMath;
32
+ var styles = function styles(theme) {
33
+ return {
34
+ design: {
35
+ marginTop: theme.spacing.unit * 2
36
+ },
37
+ altChoices: {
38
+ alignItems: 'flex-start',
39
+ display: 'flex',
40
+ flexWrap: 'wrap',
41
+ justifyContent: 'space-evenly',
42
+ margin: "".concat(theme.spacing.unit, "px 0"),
43
+ '& > *': {
44
+ margin: theme.spacing.unit
45
+ }
46
+ },
47
+ errorText: {
48
+ fontSize: theme.typography.fontSize - 2,
49
+ color: 'red',
50
+ paddingBottom: theme.spacing.unit * 2
51
+ }
52
+ };
53
+ };
54
+ var Choices = /*#__PURE__*/function (_React$Component) {
55
+ (0, _inherits2["default"])(Choices, _React$Component);
56
+ var _super = _createSuper(Choices);
57
+ function Choices() {
58
+ var _this;
59
+ (0, _classCallCheck2["default"])(this, Choices);
60
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
61
+ args[_key] = arguments[_key];
62
+ }
63
+ _this = _super.call.apply(_super, [this].concat(args));
64
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "editorInstance", null);
65
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
66
+ showWarning: false
67
+ });
68
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rerenderMath", function () {
69
+ //eslint-disable-next-line
70
+ var domNode = _reactDom["default"].findDOMNode((0, _assertThisInitialized2["default"])(_this));
71
+ (0, _mathRendering.renderMath)(domNode);
72
+ });
73
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (prevValue, val, key) {
74
+ var _this$props = _this.props,
75
+ onChange = _this$props.onChange,
76
+ model = _this$props.model;
77
+ var choices = model.choices,
78
+ correctResponse = model.correctResponse,
79
+ alternateResponses = model.alternateResponses;
80
+ var duplicatedValue = (choices || []).find(function (c) {
81
+ return c.value === val && c.id !== key;
82
+ });
83
+
84
+ // discard the new added choice or the changes if the choice would be a duplicate to one that already exists
85
+ if (duplicatedValue) {
86
+ if (prevValue === '') {
87
+ // remove the new added choice from choices
88
+ var _newChoices = (choices || []).filter(function (c) {
89
+ return c.id !== key;
90
+ });
91
+ onChange(_newChoices);
92
+ }
93
+ _this.setState({
94
+ showWarning: true
95
+ });
96
+ return;
97
+ }
98
+ var newChoices = (choices === null || choices === void 0 ? void 0 : choices.map(function (choice) {
99
+ return choice.id === key ? _objectSpread(_objectSpread({}, choice), {}, {
100
+ value: val
101
+ }) : choice;
102
+ })) || [];
103
+ if ((0, _markupUtils.choiceIsEmpty)({
104
+ value: val
105
+ })) {
106
+ // if the edited content is empty, its usage has to be searched in the correct response definitions
107
+ var usedForResponse = false;
108
+ if (correctResponse) {
109
+ Object.keys(correctResponse).forEach(function (responseKey) {
110
+ if (correctResponse[responseKey] === key) {
111
+ usedForResponse = true;
112
+ }
113
+ });
114
+ }
115
+ if (alternateResponses) {
116
+ Object.values(alternateResponses).forEach(function (alternate) {
117
+ if (alternate.indexOf(key) >= 0) {
118
+ usedForResponse = true;
119
+ }
120
+ });
121
+ }
122
+ if (usedForResponse) {
123
+ alert('Answer choices cannot be blank.');
124
+ } else {
125
+ if (!(0, _markupUtils.choiceIsEmpty)({
126
+ value: prevValue
127
+ })) {
128
+ // if the previous value was not empty, it means that the choice can be deleted
129
+ var newChoicesWithoutTheEmptyOne = newChoices.filter(function (choice) {
130
+ return choice.id !== key;
131
+ });
132
+ onChange(newChoicesWithoutTheEmptyOne);
133
+ } else {
134
+ onChange(newChoices);
135
+ }
136
+ }
137
+ } else {
138
+ onChange(newChoices);
139
+ }
140
+ });
141
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceFocus", function (id) {
142
+ return _this.setState({
143
+ focusedEl: id
144
+ });
145
+ });
146
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function () {
147
+ var _this$props2 = _this.props,
148
+ oldChoices = _this$props2.model.choices,
149
+ onChange = _this$props2.onChange;
150
+ _this.setState({
151
+ focusedEl: "".concat(oldChoices.length)
152
+ }, function () {
153
+ onChange([].concat((0, _toConsumableArray2["default"])(oldChoices), [{
154
+ id: "".concat(oldChoices.length),
155
+ value: ''
156
+ }]));
157
+ });
158
+ });
159
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceRemove", function (id) {
160
+ var _this$props3 = _this.props,
161
+ onChange = _this$props3.onChange,
162
+ choices = _this$props3.model.choices;
163
+ var newChoices = (choices || []).filter(function (choice) {
164
+ return choice.id !== id;
165
+ });
166
+ onChange(newChoices);
167
+ });
168
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getVisibleChoices", function () {
169
+ var _this$props4 = _this.props,
170
+ duplicates = _this$props4.duplicates,
171
+ _this$props4$model = _this$props4.model,
172
+ choices = _this$props4$model.choices,
173
+ correctResponse = _this$props4$model.correctResponse;
174
+ if (!choices) {
175
+ return [];
176
+ }
177
+ if (duplicates) {
178
+ return choices;
179
+ }
180
+
181
+ // if duplicates not allowed, remove the choices that are used to define the correct response
182
+ return choices.filter(function (choice) {
183
+ return !(0, _find["default"])(correctResponse, function (v) {
184
+ return v === choice.id;
185
+ });
186
+ });
187
+ });
188
+ return _this;
189
+ }
190
+ (0, _createClass2["default"])(Choices, [{
191
+ key: "componentDidMount",
192
+ value: function componentDidMount() {
193
+ this.rerenderMath();
194
+ }
195
+ }, {
196
+ key: "componentDidUpdate",
197
+ value: function componentDidUpdate() {
198
+ this.rerenderMath();
199
+ }
200
+ }, {
201
+ key: "render",
202
+ value: function render() {
203
+ var _this2 = this;
204
+ var _this$state = this.state,
205
+ focusedEl = _this$state.focusedEl,
206
+ showWarning = _this$state.showWarning;
207
+ var _this$props5 = this.props,
208
+ classes = _this$props5.classes,
209
+ duplicates = _this$props5.duplicates,
210
+ error = _this$props5.error,
211
+ maxChoices = _this$props5.maxChoices,
212
+ choices = _this$props5.model.choices,
213
+ toolbarOpts = _this$props5.toolbarOpts,
214
+ uploadSoundSupport = _this$props5.uploadSoundSupport;
215
+ var visibleChoices = this.getVisibleChoices() || [];
216
+ return /*#__PURE__*/_react["default"].createElement("div", {
217
+ className: classes.design
218
+ }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
219
+ className: classes.addButton,
220
+ variant: "contained",
221
+ color: "primary",
222
+ onClick: this.onAddChoice,
223
+ disabled: maxChoices && choices && maxChoices === choices.length
224
+ }, "Add Choice"), /*#__PURE__*/_react["default"].createElement("div", {
225
+ className: classes.altChoices
226
+ }, visibleChoices.map(function (choice, index) {
227
+ return focusedEl === choice.id ? /*#__PURE__*/_react["default"].createElement("div", {
228
+ key: index,
229
+ style: {
230
+ minWidth: '100%',
231
+ zIndex: '100'
232
+ }
233
+ }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
234
+ onEditor: function onEditor(editor) {
235
+ return _this2.editorInstance = editor;
236
+ },
237
+ className: classes.prompt,
238
+ markup: choice.value,
239
+ pluginProps: {
240
+ video: {
241
+ disabled: true
242
+ },
243
+ audio: {
244
+ disabled: true
245
+ }
246
+ },
247
+ onChange: function onChange(val) {
248
+ return _this2.onChoiceChanged(choice.value, val, choice.id);
249
+ },
250
+ onDone: function onDone() {
251
+ _this2.setState({
252
+ focusedEl: undefined
253
+ });
254
+ },
255
+ disableUnderline: true,
256
+ toolbarOpts: toolbarOpts,
257
+ uploadSoundSupport: uploadSoundSupport
258
+ })) : /*#__PURE__*/_react["default"].createElement(_choice["default"], {
259
+ key: index,
260
+ duplicates: duplicates,
261
+ targetId: "0",
262
+ choice: choice,
263
+ error: error,
264
+ onClick: function onClick() {
265
+ return _this2.onChoiceFocus(choice.id);
266
+ },
267
+ onRemoveChoice: function onRemoveChoice() {
268
+ return _this2.onChoiceRemove(choice.id);
269
+ }
270
+ });
271
+ })), error && /*#__PURE__*/_react["default"].createElement("div", {
272
+ className: classes.errorText
273
+ }, error), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
274
+ open: showWarning,
275
+ title: "Warning",
276
+ text: "Identical answer choices are not allowed and the changes will be discarded.",
277
+ onConfirm: function onConfirm() {
278
+ return _this2.setState({
279
+ showWarning: false
280
+ });
281
+ }
282
+ }));
283
+ }
284
+ }]);
285
+ return Choices;
286
+ }(_react["default"].Component);
287
+ exports.Choices = Choices;
288
+ (0, _defineProperty2["default"])(Choices, "propTypes", {
289
+ duplicates: _propTypes["default"].bool,
290
+ error: _propTypes["default"].string,
291
+ model: _propTypes["default"].object.isRequired,
292
+ onChange: _propTypes["default"].func.isRequired,
293
+ classes: _propTypes["default"].object.isRequired,
294
+ toolbarOpts: _propTypes["default"].object,
295
+ maxChoices: _propTypes["default"].number,
296
+ uploadSoundSupport: _propTypes["default"].object
297
+ });
298
+ var Styled = (0, _styles.withStyles)(styles)(Choices);
299
+ var _default = Styled;
300
+ exports["default"] = _default;
301
+ //# sourceMappingURL=choices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"choices.js","names":["_react","_interopRequireDefault","require","_reactDom","_propTypes","_editableHtml","_mathRendering","_find","_Button","_choice","_markupUtils","_styles","_configUi","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","result","NewTarget","constructor","Reflect","construct","_possibleConstructorReturn2","sham","Proxy","Boolean","prototype","valueOf","call","e","window","renMath","renderMath","styles","theme","design","marginTop","spacing","unit","altChoices","alignItems","display","flexWrap","justifyContent","margin","concat","errorText","fontSize","typography","color","paddingBottom","Choices","_React$Component","_inherits2","_super","_this","_classCallCheck2","_len","args","Array","_key","_assertThisInitialized2","showWarning","domNode","ReactDOM","findDOMNode","prevValue","val","_this$props","props","onChange","model","choices","correctResponse","alternateResponses","duplicatedValue","find","c","value","id","newChoices","setState","map","choice","choiceIsEmpty","usedForResponse","responseKey","values","alternate","indexOf","alert","newChoicesWithoutTheEmptyOne","focusedEl","_this$props2","oldChoices","_toConsumableArray2","_this$props3","_this$props4","duplicates","_this$props4$model","v","_createClass2","componentDidMount","rerenderMath","componentDidUpdate","render","_this2","_this$state","state","_this$props5","classes","error","maxChoices","toolbarOpts","uploadSoundSupport","visibleChoices","getVisibleChoices","createElement","className","addButton","variant","onClick","onAddChoice","disabled","index","style","minWidth","zIndex","onEditor","editor","editorInstance","prompt","markup","pluginProps","video","audio","onChoiceChanged","onDone","undefined","disableUnderline","targetId","onChoiceFocus","onRemoveChoice","onChoiceRemove","AlertDialog","open","title","text","onConfirm","React","Component","exports","PropTypes","bool","string","isRequired","func","number","Styled","withStyles","_default"],"sources":["../src/choices.jsx"],"sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport find from 'lodash/find';\nimport Button from '@material-ui/core/Button';\nimport Choice from './choice';\nimport { choiceIsEmpty } from './markupUtils';\nimport { withStyles } from '@material-ui/core/styles';\nimport { AlertDialog } from '@pie-lib/config-ui';\n\nwindow.renMath = renderMath;\n\nconst styles = (theme) => ({\n design: {\n marginTop: theme.spacing.unit * 2,\n },\n altChoices: {\n alignItems: 'flex-start',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'space-evenly',\n margin: `${theme.spacing.unit}px 0`,\n\n '& > *': {\n margin: theme.spacing.unit,\n },\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: 'red',\n paddingBottom: theme.spacing.unit * 2,\n },\n});\n\nexport class Choices extends React.Component {\n static propTypes = {\n duplicates: PropTypes.bool,\n error: PropTypes.string,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n toolbarOpts: PropTypes.object,\n maxChoices: PropTypes.number,\n uploadSoundSupport: PropTypes.object,\n };\n\n editorInstance = null;\n state = { showWarning: false };\n\n componentDidMount() {\n this.rerenderMath();\n }\n\n componentDidUpdate() {\n this.rerenderMath();\n }\n\n rerenderMath = () => {\n //eslint-disable-next-line\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n };\n\n onChoiceChanged = (prevValue, val, key) => {\n const { onChange, model } = this.props;\n const { choices, correctResponse, alternateResponses } = model;\n const duplicatedValue = (choices || []).find((c) => c.value === val && c.id !== key);\n\n // discard the new added choice or the changes if the choice would be a duplicate to one that already exists\n if (duplicatedValue) {\n if (prevValue === '') {\n // remove the new added choice from choices\n const newChoices = (choices || []).filter((c) => c.id !== key);\n\n onChange(newChoices);\n }\n\n this.setState({ showWarning: true });\n\n return;\n }\n\n const newChoices = choices?.map((choice) => (choice.id === key ? { ...choice, value: val } : choice)) || [];\n\n if (choiceIsEmpty({ value: val })) {\n // if the edited content is empty, its usage has to be searched in the correct response definitions\n let usedForResponse = false;\n\n if (correctResponse) {\n Object.keys(correctResponse).forEach((responseKey) => {\n if (correctResponse[responseKey] === key) {\n usedForResponse = true;\n }\n });\n }\n\n if (alternateResponses) {\n Object.values(alternateResponses).forEach((alternate) => {\n if (alternate.indexOf(key) >= 0) {\n usedForResponse = true;\n }\n });\n }\n\n if (usedForResponse) {\n alert('Answer choices cannot be blank.');\n } else {\n if (!choiceIsEmpty({ value: prevValue })) {\n // if the previous value was not empty, it means that the choice can be deleted\n const newChoicesWithoutTheEmptyOne = newChoices.filter((choice) => choice.id !== key);\n\n onChange(newChoicesWithoutTheEmptyOne);\n } else {\n onChange(newChoices);\n }\n }\n } else {\n onChange(newChoices);\n }\n };\n\n onChoiceFocus = (id) =>\n this.setState({\n focusedEl: id,\n });\n\n onAddChoice = () => {\n const {\n model: { choices: oldChoices },\n onChange,\n } = this.props;\n\n this.setState(\n {\n focusedEl: `${oldChoices.length}`,\n },\n () => {\n onChange([\n ...oldChoices,\n {\n id: `${oldChoices.length}`,\n value: '',\n },\n ]);\n },\n );\n };\n\n onChoiceRemove = (id) => {\n const {\n onChange,\n model: { choices },\n } = this.props;\n const newChoices = (choices || []).filter((choice) => choice.id !== id);\n\n onChange(newChoices);\n };\n\n getVisibleChoices = () => {\n const {\n duplicates,\n model: { choices, correctResponse },\n } = this.props;\n\n if (!choices) {\n return [];\n }\n\n if (duplicates) {\n return choices;\n }\n\n // if duplicates not allowed, remove the choices that are used to define the correct response\n return choices.filter((choice) => !find(correctResponse, (v) => v === choice.id));\n };\n\n render() {\n const { focusedEl, showWarning } = this.state;\n const {\n classes,\n duplicates,\n error,\n maxChoices,\n model: { choices },\n toolbarOpts,\n uploadSoundSupport,\n } = this.props;\n const visibleChoices = this.getVisibleChoices() || [];\n\n return (\n <div className={classes.design}>\n <Button\n className={classes.addButton}\n variant=\"contained\"\n color=\"primary\"\n onClick={this.onAddChoice}\n disabled={maxChoices && choices && maxChoices === choices.length}\n >\n Add Choice\n </Button>\n\n <div className={classes.altChoices}>\n {visibleChoices.map((choice, index) =>\n focusedEl === choice.id ? (\n <div\n key={index}\n style={{\n minWidth: '100%',\n zIndex: '100',\n }}\n >\n <EditableHtml\n onEditor={editor => (this.editorInstance = editor)}\n className={classes.prompt}\n markup={choice.value}\n pluginProps={{\n video: {\n disabled: true,\n },\n audio: {\n disabled: true,\n },\n }}\n onChange={(val) => this.onChoiceChanged(choice.value, val, choice.id)}\n onDone={() => {\n this.setState({\n focusedEl: undefined,\n });\n }}\n disableUnderline\n toolbarOpts={toolbarOpts}\n uploadSoundSupport={uploadSoundSupport}\n />\n </div>\n ) : (\n <Choice\n key={index}\n duplicates={duplicates}\n targetId=\"0\"\n choice={choice}\n error={error}\n onClick={() => this.onChoiceFocus(choice.id)}\n onRemoveChoice={() => this.onChoiceRemove(choice.id)}\n />\n ),\n )}\n </div>\n {error && <div className={classes.errorText}>{error}</div>}\n\n <AlertDialog\n open={showWarning}\n title=\"Warning\"\n text=\"Identical answer choices are not allowed and the changes will be discarded.\"\n onConfirm={() => this.setState({ showWarning: false })}\n />\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Choices);\n\nexport default Styled;\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,OAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,OAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AAAiD,SAAAW,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ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,WAAW,EAAE;UAAM,CAAC,CAAC;QAAA;MAAC,CACxD,CACE,CAAC;IAEV;EAAC;EAAA,OAAAX,OAAA;AAAA,EAhO0BkG,iBAAK,CAACC,SAAS;AAAAC,OAAA,CAAApG,OAAA,GAAAA,OAAA;AAAA,IAAA7C,gBAAA,aAA/B6C,OAAO,eACC;EACjB+C,UAAU,EAAEsD,qBAAS,CAACC,IAAI;EAC1B1C,KAAK,EAAEyC,qBAAS,CAACE,MAAM;EACvBnF,KAAK,EAAEiF,qBAAS,CAACtK,MAAM,CAACyK,UAAU;EAClCrF,QAAQ,EAAEkF,qBAAS,CAACI,IAAI,CAACD,UAAU;EACnC7C,OAAO,EAAE0C,qBAAS,CAACtK,MAAM,CAACyK,UAAU;EACpC1C,WAAW,EAAEuC,qBAAS,CAACtK,MAAM;EAC7B8H,UAAU,EAAEwC,qBAAS,CAACK,MAAM;EAC5B3C,kBAAkB,EAAEsC,qBAAS,CAACtK;AAChC,CAAC;AAyNH,IAAM4K,MAAM,GAAG,IAAAC,kBAAU,EAAC9H,MAAM,CAAC,CAACkB,OAAO,CAAC;AAAC,IAAA6G,QAAA,GAE5BF,MAAM;AAAAP,OAAA,cAAAS,QAAA"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _default = {
8
+ model: {
9
+ disabled: false,
10
+ mode: 'gather',
11
+ prompt: 'Use the inputs to complete the sentence',
12
+ markup: '',
13
+ choices: [],
14
+ choicesPosition: 'below',
15
+ correctResponse: {},
16
+ duplicates: true,
17
+ rationaleEnabled: true,
18
+ promptEnabled: true,
19
+ teacherInstructionsEnabled: true,
20
+ studentInstructionsEnabled: true,
21
+ toolbarEditorPosition: 'bottom'
22
+ },
23
+ configuration: {
24
+ spellCheck: {
25
+ label: 'Spellcheck',
26
+ settings: false,
27
+ enabled: true
28
+ },
29
+ choicesPosition: {
30
+ settings: true,
31
+ label: 'Choices Position'
32
+ },
33
+ prompt: {
34
+ settings: true,
35
+ label: 'Prompt'
36
+ },
37
+ duplicates: {
38
+ settings: true,
39
+ label: 'Duplicates'
40
+ },
41
+ lockChoiceOrder: {
42
+ settings: true,
43
+ label: 'Lock Choice Order'
44
+ },
45
+ partialScoring: {
46
+ settings: false,
47
+ label: 'Allow Partial Scoring'
48
+ },
49
+ rationale: {
50
+ settings: true,
51
+ label: 'Rationale'
52
+ },
53
+ settingsPanelDisabled: false,
54
+ teacherInstructions: {
55
+ settings: true,
56
+ label: 'Teacher Instructions'
57
+ },
58
+ minChoices: 2,
59
+ maxResponseAreas: 10,
60
+ maxImageWidth: {
61
+ teacherInstructions: 300,
62
+ prompt: 300,
63
+ rationale: 300
64
+ },
65
+ maxImageHeight: {
66
+ teacherInstructions: 300,
67
+ prompt: 300,
68
+ rationale: 300
69
+ },
70
+ withRubric: {
71
+ settings: false,
72
+ label: 'Add Rubric'
73
+ }
74
+ }
75
+ };
76
+ exports["default"] = _default;
77
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","names":["model","disabled","mode","prompt","markup","choices","choicesPosition","correctResponse","duplicates","rationaleEnabled","promptEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","toolbarEditorPosition","configuration","spellCheck","label","settings","enabled","lockChoiceOrder","partialScoring","rationale","settingsPanelDisabled","teacherInstructions","minChoices","maxResponseAreas","maxImageWidth","maxImageHeight","withRubric","exports","_default"],"sources":["../src/defaults.js"],"sourcesContent":["export default {\n model: {\n disabled: false,\n mode: 'gather',\n prompt: 'Use the inputs to complete the sentence',\n markup: '',\n choices: [],\n choicesPosition: 'below',\n correctResponse: {},\n duplicates: true,\n rationaleEnabled: true,\n promptEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n toolbarEditorPosition: 'bottom',\n },\n configuration: {\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n choicesPosition: {\n settings: true,\n label: 'Choices Position',\n },\n prompt: {\n settings: true,\n label: 'Prompt',\n },\n duplicates: {\n settings: true,\n label: 'Duplicates',\n },\n lockChoiceOrder: {\n settings: true,\n label: 'Lock Choice Order',\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring',\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n },\n settingsPanelDisabled: false,\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n },\n minChoices: 2,\n maxResponseAreas: 10,\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n },\n};\n"],"mappings":";;;;;;eAAe;EACbA,KAAK,EAAE;IACLC,QAAQ,EAAE,KAAK;IACfC,IAAI,EAAE,QAAQ;IACdC,MAAM,EAAE,yCAAyC;IACjDC,MAAM,EAAE,EAAE;IACVC,OAAO,EAAE,EAAE;IACXC,eAAe,EAAE,OAAO;IACxBC,eAAe,EAAE,CAAC,CAAC;IACnBC,UAAU,EAAE,IAAI;IAChBC,gBAAgB,EAAE,IAAI;IACtBC,aAAa,EAAE,IAAI;IACnBC,0BAA0B,EAAE,IAAI;IAChCC,0BAA0B,EAAE,IAAI;IAChCC,qBAAqB,EAAE;EACzB,CAAC;EACDC,aAAa,EAAE;IACbC,UAAU,EAAE;MACVC,KAAK,EAAE,YAAY;MACnBC,QAAQ,EAAE,KAAK;MACfC,OAAO,EAAE;IACX,CAAC;IACDZ,eAAe,EAAE;MACfW,QAAQ,EAAE,IAAI;MACdD,KAAK,EAAE;IACT,CAAC;IACDb,MAAM,EAAE;MACNc,QAAQ,EAAE,IAAI;MACdD,KAAK,EAAE;IACT,CAAC;IACDR,UAAU,EAAE;MACVS,QAAQ,EAAE,IAAI;MACdD,KAAK,EAAE;IACT,CAAC;IACDG,eAAe,EAAE;MACfF,QAAQ,EAAE,IAAI;MACdD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