@pie-element/drag-in-the-blank 4.6.1-beta.0 → 4.6.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/package.json +4 -4
- package/package.json +4 -4
- package/configure/lib/choice.js +0 -126
- package/configure/lib/choice.js.map +0 -1
- package/configure/lib/choices.js +0 -347
- package/configure/lib/choices.js.map +0 -1
- package/configure/lib/defaults.js +0 -77
- package/configure/lib/defaults.js.map +0 -1
- package/configure/lib/index.js +0 -179
- package/configure/lib/index.js.map +0 -1
- package/configure/lib/main.js +0 -413
- package/configure/lib/main.js.map +0 -1
- package/configure/lib/markupUtils.js +0 -105
- package/configure/lib/markupUtils.js.map +0 -1
- package/controller/lib/defaults.js +0 -14
- package/controller/lib/defaults.js.map +0 -1
- package/controller/lib/index.js +0 -277
- package/controller/lib/index.js.map +0 -1
- package/controller/lib/utils.js +0 -53
- package/controller/lib/utils.js.map +0 -1
- package/lib/index.js +0 -106
- package/lib/index.js.map +0 -1
- package/lib/main.js +0 -156
- package/lib/main.js.map +0 -1
package/configure/package.json
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"@material-ui/core": "^3.9.2",
|
|
10
10
|
"@material-ui/icons": "^3.0.1",
|
|
11
11
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
12
|
-
"@pie-lib/config-ui": "12.0.0-beta.
|
|
12
|
+
"@pie-lib/config-ui": "12.0.0-beta.5",
|
|
13
13
|
"@pie-lib/drag": "^2.1.12",
|
|
14
|
-
"@pie-lib/editable-html": "10.0.0-beta.
|
|
14
|
+
"@pie-lib/editable-html": "10.0.0-beta.7",
|
|
15
15
|
"@pie-lib/math-rendering": "^2.5.12",
|
|
16
16
|
"@types/is-hotkey": "^0.1.1",
|
|
17
17
|
"@types/lodash": "^4.14.149",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react-dnd": "^14.0.5",
|
|
26
26
|
"react-dom": "^16.8.1",
|
|
27
27
|
"scroll-into-view-if-needed": "^2.2.20",
|
|
28
|
-
"slate": "^0.
|
|
28
|
+
"slate": "^0.94.1",
|
|
29
29
|
"slate-dev-environment": "^0.2.5",
|
|
30
30
|
"slate-edit-list": "^0.12.1",
|
|
31
31
|
"slate-edit-table": "^0.18.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"slate-hyperscript": "^0.77.0",
|
|
35
35
|
"slate-plain-serializer": "^0.7.13",
|
|
36
36
|
"slate-prop-types": "^0.5.44",
|
|
37
|
-
"slate-react": "0.
|
|
37
|
+
"slate-react": "0.97.2",
|
|
38
38
|
"tiny-invariant": "1.0.6"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "4.6.1-beta.
|
|
7
|
+
"version": "4.6.1-beta.3+e0e0490c5",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@material-ui/core": "^3.9.2",
|
|
15
15
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
16
16
|
"@pie-lib/correct-answer-toggle": "^2.3.62",
|
|
17
|
-
"@pie-lib/mask-markup": "2.0.0-beta.
|
|
17
|
+
"@pie-lib/mask-markup": "2.0.0-beta.2",
|
|
18
18
|
"@pie-lib/math-rendering": "^2.5.12",
|
|
19
19
|
"@pie-lib/render-ui": "^4.14.12",
|
|
20
20
|
"classnames": "^2.2.5",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"prop-types": "^15.6.1",
|
|
24
24
|
"react": "^16.8.1",
|
|
25
25
|
"react-dom": "^16.8.1",
|
|
26
|
-
"slate-react": "0.
|
|
26
|
+
"slate-react": "0.97.2"
|
|
27
27
|
},
|
|
28
28
|
"author": "",
|
|
29
29
|
"license": "ISC",
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "e0e0490c5b040c67f504c0bdfd00f6b834a28481",
|
|
31
31
|
"main": "lib/index.js",
|
|
32
32
|
"module": "src/index.js"
|
|
33
33
|
}
|
package/configure/lib/choice.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.tileSource = exports["default"] = exports.BlankContent = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
|
|
13
|
-
|
|
14
|
-
var _Delete = _interopRequireDefault(require("@material-ui/icons/Delete"));
|
|
15
|
-
|
|
16
|
-
var _reactDnd = require("react-dnd");
|
|
17
|
-
|
|
18
|
-
var _styles = require("@material-ui/core/styles");
|
|
19
|
-
|
|
20
|
-
var _markupUtils = require("./markupUtils");
|
|
21
|
-
|
|
22
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
23
|
-
|
|
24
|
-
var GripIcon = function GripIcon(_ref) {
|
|
25
|
-
var style = _ref.style;
|
|
26
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
27
|
-
style: style
|
|
28
|
-
}, /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], {
|
|
29
|
-
style: {
|
|
30
|
-
margin: '0 -16px'
|
|
31
|
-
}
|
|
32
|
-
}), /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], null));
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
GripIcon.propTypes = {
|
|
36
|
-
style: _propTypes["default"].object
|
|
37
|
-
};
|
|
38
|
-
var BlankContent = (0, _styles.withStyles)(function (theme) {
|
|
39
|
-
return {
|
|
40
|
-
choice: {
|
|
41
|
-
display: 'inline-flex',
|
|
42
|
-
minWidth: '178px',
|
|
43
|
-
minHeight: '36px',
|
|
44
|
-
background: '#FFF',
|
|
45
|
-
boxSizing: 'border-box',
|
|
46
|
-
borderRadius: '3px',
|
|
47
|
-
overflow: 'hidden',
|
|
48
|
-
position: 'relative',
|
|
49
|
-
padding: '8px 35px 8px 35px',
|
|
50
|
-
cursor: 'grab'
|
|
51
|
-
},
|
|
52
|
-
deleteIcon: {
|
|
53
|
-
position: 'absolute',
|
|
54
|
-
top: '6px',
|
|
55
|
-
right: '0',
|
|
56
|
-
color: '#9B9B9B',
|
|
57
|
-
zIndex: 2,
|
|
58
|
-
'& :hover': {
|
|
59
|
-
cursor: 'pointer',
|
|
60
|
-
color: '#000000'
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
})(function (props) {
|
|
65
|
-
var classes = props.classes,
|
|
66
|
-
connectDragSource = props.connectDragSource,
|
|
67
|
-
choice = props.choice,
|
|
68
|
-
onClick = props.onClick,
|
|
69
|
-
onRemoveChoice = props.onRemoveChoice,
|
|
70
|
-
error = props.error;
|
|
71
|
-
return connectDragSource( /*#__PURE__*/_react["default"].createElement("div", {
|
|
72
|
-
className: classes.choice,
|
|
73
|
-
style: {
|
|
74
|
-
border: "1px solid ".concat(error ? 'red' : '#C0C3CF')
|
|
75
|
-
},
|
|
76
|
-
onClick: onClick
|
|
77
|
-
}, /*#__PURE__*/_react["default"].createElement(GripIcon, {
|
|
78
|
-
style: {
|
|
79
|
-
position: 'absolute',
|
|
80
|
-
top: '6px',
|
|
81
|
-
left: '15px',
|
|
82
|
-
color: '#9B9B9B',
|
|
83
|
-
zIndex: 2
|
|
84
|
-
}
|
|
85
|
-
}), /*#__PURE__*/_react["default"].createElement("span", {
|
|
86
|
-
dangerouslySetInnerHTML: {
|
|
87
|
-
__html: choice.value
|
|
88
|
-
}
|
|
89
|
-
}), /*#__PURE__*/_react["default"].createElement(_Delete["default"], {
|
|
90
|
-
className: classes.deleteIcon,
|
|
91
|
-
onClick: function onClick(e) {
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
onRemoveChoice(e);
|
|
95
|
-
}
|
|
96
|
-
})));
|
|
97
|
-
});
|
|
98
|
-
exports.BlankContent = BlankContent;
|
|
99
|
-
var tileSource = {
|
|
100
|
-
canDrag: function canDrag(props) {
|
|
101
|
-
if ((0, _markupUtils.choiceIsEmpty)(props.choice)) {
|
|
102
|
-
alert('You need to define a value for an answer choice before it can be associated with a response area.');
|
|
103
|
-
return false;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return !props.disabled;
|
|
107
|
-
},
|
|
108
|
-
beginDrag: function beginDrag(props) {
|
|
109
|
-
return {
|
|
110
|
-
id: props.targetId,
|
|
111
|
-
value: props.choice,
|
|
112
|
-
instanceId: props.instanceId
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
exports.tileSource = tileSource;
|
|
117
|
-
|
|
118
|
-
var _default = (0, _reactDnd.DragSource)('drag-in-the-blank-choice', tileSource, function (connect, monitor) {
|
|
119
|
-
return {
|
|
120
|
-
connectDragSource: connect.dragSource(),
|
|
121
|
-
isDragging: monitor.isDragging()
|
|
122
|
-
};
|
|
123
|
-
})(BlankContent);
|
|
124
|
-
|
|
125
|
-
exports["default"] = _default;
|
|
126
|
-
//# sourceMappingURL=choice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/choice.jsx"],"names":["GripIcon","style","margin","propTypes","PropTypes","object","BlankContent","theme","choice","display","minWidth","minHeight","background","boxSizing","borderRadius","overflow","position","padding","cursor","deleteIcon","top","right","color","zIndex","props","classes","connectDragSource","onClick","onRemoveChoice","error","border","left","__html","value","e","preventDefault","stopPropagation","tileSource","canDrag","alert","disabled","beginDrag","id","targetId","instanceId","connect","monitor","dragSource","isDragging"],"m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,EASP;AACf,WAAO;AACLkB,MAAAA,EAAE,EAAElB,KAAK,CAACmB,QADL;AAELV,MAAAA,KAAK,EAAET,KAAK,CAAChB,MAFR;AAGLoC,MAAAA,UAAU,EAAEpB,KAAK,CAACoB;AAHb,KAAP;AAKD;AAfuB,CAAnB;;;eAkBQ,0BAAW,0BAAX,EAAuCP,UAAvC,EAAmD,UAACQ,OAAD,EAAUC,OAAV;AAAA,SAAuB;AACvFpB,IAAAA,iBAAiB,EAAEmB,OAAO,CAACE,UAAR,EADoE;AAEvFC,IAAAA,UAAU,EAAEF,OAAO,CAACE,UAAR;AAF2E,GAAvB;AAAA,CAAnD,EAGX1C,YAHW,C","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"],"file":"choice.js"}
|
package/configure/lib/choices.js
DELETED
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.Choices = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
|
-
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
29
|
-
|
|
30
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
31
|
-
|
|
32
|
-
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
33
|
-
|
|
34
|
-
var _mathRendering = require("@pie-lib/math-rendering");
|
|
35
|
-
|
|
36
|
-
var _find = _interopRequireDefault(require("lodash/find"));
|
|
37
|
-
|
|
38
|
-
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
39
|
-
|
|
40
|
-
var _choice = _interopRequireDefault(require("./choice"));
|
|
41
|
-
|
|
42
|
-
var _markupUtils = require("./markupUtils");
|
|
43
|
-
|
|
44
|
-
var _styles = require("@material-ui/core/styles");
|
|
45
|
-
|
|
46
|
-
var _configUi = require("@pie-lib/config-ui");
|
|
47
|
-
|
|
48
|
-
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; }
|
|
49
|
-
|
|
50
|
-
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; }
|
|
51
|
-
|
|
52
|
-
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); }; }
|
|
53
|
-
|
|
54
|
-
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; } }
|
|
55
|
-
|
|
56
|
-
window.renMath = _mathRendering.renderMath;
|
|
57
|
-
|
|
58
|
-
var styles = function styles(theme) {
|
|
59
|
-
return {
|
|
60
|
-
design: {
|
|
61
|
-
marginTop: theme.spacing.unit * 2
|
|
62
|
-
},
|
|
63
|
-
altChoices: {
|
|
64
|
-
alignItems: 'flex-start',
|
|
65
|
-
display: 'flex',
|
|
66
|
-
flexWrap: 'wrap',
|
|
67
|
-
justifyContent: 'space-evenly',
|
|
68
|
-
margin: "".concat(theme.spacing.unit, "px 0"),
|
|
69
|
-
'& > *': {
|
|
70
|
-
margin: theme.spacing.unit
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
errorText: {
|
|
74
|
-
fontSize: theme.typography.fontSize - 2,
|
|
75
|
-
color: 'red',
|
|
76
|
-
paddingBottom: theme.spacing.unit * 2
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
var Choices = /*#__PURE__*/function (_React$Component) {
|
|
82
|
-
(0, _inherits2["default"])(Choices, _React$Component);
|
|
83
|
-
|
|
84
|
-
var _super = _createSuper(Choices);
|
|
85
|
-
|
|
86
|
-
function Choices() {
|
|
87
|
-
var _this;
|
|
88
|
-
|
|
89
|
-
(0, _classCallCheck2["default"])(this, Choices);
|
|
90
|
-
|
|
91
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
92
|
-
args[_key] = arguments[_key];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
96
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "editorInstance", null);
|
|
97
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
98
|
-
showWarning: false
|
|
99
|
-
});
|
|
100
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rerenderMath", function () {
|
|
101
|
-
//eslint-disable-next-line
|
|
102
|
-
var domNode = _reactDom["default"].findDOMNode((0, _assertThisInitialized2["default"])(_this));
|
|
103
|
-
|
|
104
|
-
(0, _mathRendering.renderMath)(domNode);
|
|
105
|
-
});
|
|
106
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (prevValue, val, key) {
|
|
107
|
-
var _this$props = _this.props,
|
|
108
|
-
onChange = _this$props.onChange,
|
|
109
|
-
model = _this$props.model;
|
|
110
|
-
var choices = model.choices,
|
|
111
|
-
correctResponse = model.correctResponse,
|
|
112
|
-
alternateResponses = model.alternateResponses;
|
|
113
|
-
var duplicatedValue = (choices || []).find(function (c) {
|
|
114
|
-
return c.value === val && c.id !== key;
|
|
115
|
-
}); // discard the new added choice or the changes if the choice would be a duplicate to one that already exists
|
|
116
|
-
|
|
117
|
-
if (duplicatedValue) {
|
|
118
|
-
if (prevValue === '') {
|
|
119
|
-
// remove the new added choice from choices
|
|
120
|
-
var _newChoices = (choices || []).filter(function (c) {
|
|
121
|
-
return c.id !== key;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
onChange(_newChoices);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
_this.setState({
|
|
128
|
-
showWarning: true
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var newChoices = (choices === null || choices === void 0 ? void 0 : choices.map(function (choice) {
|
|
135
|
-
return choice.id === key ? _objectSpread(_objectSpread({}, choice), {}, {
|
|
136
|
-
value: val
|
|
137
|
-
}) : choice;
|
|
138
|
-
})) || [];
|
|
139
|
-
|
|
140
|
-
if ((0, _markupUtils.choiceIsEmpty)({
|
|
141
|
-
value: val
|
|
142
|
-
})) {
|
|
143
|
-
// if the edited content is empty, its usage has to be searched in the correct response definitions
|
|
144
|
-
var usedForResponse = false;
|
|
145
|
-
|
|
146
|
-
if (correctResponse) {
|
|
147
|
-
Object.keys(correctResponse).forEach(function (responseKey) {
|
|
148
|
-
if (correctResponse[responseKey] === key) {
|
|
149
|
-
usedForResponse = true;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (alternateResponses) {
|
|
155
|
-
Object.values(alternateResponses).forEach(function (alternate) {
|
|
156
|
-
if (alternate.indexOf(key) >= 0) {
|
|
157
|
-
usedForResponse = true;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (usedForResponse) {
|
|
163
|
-
alert('Answer choices cannot be blank.');
|
|
164
|
-
} else {
|
|
165
|
-
if (!(0, _markupUtils.choiceIsEmpty)({
|
|
166
|
-
value: prevValue
|
|
167
|
-
})) {
|
|
168
|
-
// if the previous value was not empty, it means that the choice can be deleted
|
|
169
|
-
var newChoicesWithoutTheEmptyOne = newChoices.filter(function (choice) {
|
|
170
|
-
return choice.id !== key;
|
|
171
|
-
});
|
|
172
|
-
onChange(newChoicesWithoutTheEmptyOne);
|
|
173
|
-
} else {
|
|
174
|
-
onChange(newChoices);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
} else {
|
|
178
|
-
onChange(newChoices);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceFocus", function (id) {
|
|
182
|
-
return _this.setState({
|
|
183
|
-
focusedEl: id
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAddChoice", function () {
|
|
187
|
-
var _this$props2 = _this.props,
|
|
188
|
-
oldChoices = _this$props2.model.choices,
|
|
189
|
-
onChange = _this$props2.onChange;
|
|
190
|
-
|
|
191
|
-
_this.setState({
|
|
192
|
-
focusedEl: "".concat(oldChoices.length)
|
|
193
|
-
}, function () {
|
|
194
|
-
onChange([].concat((0, _toConsumableArray2["default"])(oldChoices), [{
|
|
195
|
-
id: "".concat(oldChoices.length),
|
|
196
|
-
value: ''
|
|
197
|
-
}]));
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceRemove", function (id) {
|
|
201
|
-
var _this$props3 = _this.props,
|
|
202
|
-
onChange = _this$props3.onChange,
|
|
203
|
-
choices = _this$props3.model.choices;
|
|
204
|
-
var newChoices = (choices || []).filter(function (choice) {
|
|
205
|
-
return choice.id !== id;
|
|
206
|
-
});
|
|
207
|
-
onChange(newChoices);
|
|
208
|
-
});
|
|
209
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getVisibleChoices", function () {
|
|
210
|
-
var _this$props4 = _this.props,
|
|
211
|
-
duplicates = _this$props4.duplicates,
|
|
212
|
-
_this$props4$model = _this$props4.model,
|
|
213
|
-
choices = _this$props4$model.choices,
|
|
214
|
-
correctResponse = _this$props4$model.correctResponse;
|
|
215
|
-
|
|
216
|
-
if (!choices) {
|
|
217
|
-
return [];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (duplicates) {
|
|
221
|
-
return choices;
|
|
222
|
-
} // if duplicates not allowed, remove the choices that are used to define the correct response
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return choices.filter(function (choice) {
|
|
226
|
-
return !(0, _find["default"])(correctResponse, function (v) {
|
|
227
|
-
return v === choice.id;
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
return _this;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
(0, _createClass2["default"])(Choices, [{
|
|
235
|
-
key: "componentDidMount",
|
|
236
|
-
value: function componentDidMount() {
|
|
237
|
-
this.rerenderMath();
|
|
238
|
-
}
|
|
239
|
-
}, {
|
|
240
|
-
key: "componentDidUpdate",
|
|
241
|
-
value: function componentDidUpdate() {
|
|
242
|
-
this.rerenderMath();
|
|
243
|
-
}
|
|
244
|
-
}, {
|
|
245
|
-
key: "render",
|
|
246
|
-
value: function render() {
|
|
247
|
-
var _this2 = this;
|
|
248
|
-
|
|
249
|
-
var _this$state = this.state,
|
|
250
|
-
focusedEl = _this$state.focusedEl,
|
|
251
|
-
showWarning = _this$state.showWarning;
|
|
252
|
-
var _this$props5 = this.props,
|
|
253
|
-
classes = _this$props5.classes,
|
|
254
|
-
duplicates = _this$props5.duplicates,
|
|
255
|
-
error = _this$props5.error,
|
|
256
|
-
maxChoices = _this$props5.maxChoices,
|
|
257
|
-
choices = _this$props5.model.choices,
|
|
258
|
-
toolbarOpts = _this$props5.toolbarOpts,
|
|
259
|
-
uploadSoundSupport = _this$props5.uploadSoundSupport;
|
|
260
|
-
var visibleChoices = this.getVisibleChoices() || [];
|
|
261
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
262
|
-
className: classes.design
|
|
263
|
-
}, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
264
|
-
className: classes.addButton,
|
|
265
|
-
variant: "contained",
|
|
266
|
-
color: "primary",
|
|
267
|
-
onClick: this.onAddChoice,
|
|
268
|
-
disabled: maxChoices && choices && maxChoices === choices.length
|
|
269
|
-
}, "Add Choice"), /*#__PURE__*/_react["default"].createElement("div", {
|
|
270
|
-
className: classes.altChoices
|
|
271
|
-
}, visibleChoices.map(function (choice, index) {
|
|
272
|
-
return focusedEl === choice.id ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
273
|
-
key: index,
|
|
274
|
-
style: {
|
|
275
|
-
minWidth: '100%',
|
|
276
|
-
zIndex: '100'
|
|
277
|
-
}
|
|
278
|
-
}, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
|
|
279
|
-
onEditor: function onEditor(editor) {
|
|
280
|
-
return _this2.editorInstance = editor;
|
|
281
|
-
},
|
|
282
|
-
className: classes.prompt,
|
|
283
|
-
markup: choice.value,
|
|
284
|
-
pluginProps: {
|
|
285
|
-
video: {
|
|
286
|
-
disabled: true
|
|
287
|
-
},
|
|
288
|
-
audio: {
|
|
289
|
-
disabled: true
|
|
290
|
-
}
|
|
291
|
-
},
|
|
292
|
-
onChange: function onChange(val) {
|
|
293
|
-
return _this2.onChoiceChanged(choice.value, val, choice.id);
|
|
294
|
-
},
|
|
295
|
-
onDone: function onDone() {
|
|
296
|
-
_this2.setState({
|
|
297
|
-
focusedEl: undefined
|
|
298
|
-
});
|
|
299
|
-
},
|
|
300
|
-
disableUnderline: true,
|
|
301
|
-
toolbarOpts: toolbarOpts,
|
|
302
|
-
uploadSoundSupport: uploadSoundSupport
|
|
303
|
-
})) : /*#__PURE__*/_react["default"].createElement(_choice["default"], {
|
|
304
|
-
key: index,
|
|
305
|
-
duplicates: duplicates,
|
|
306
|
-
targetId: "0",
|
|
307
|
-
choice: choice,
|
|
308
|
-
error: error,
|
|
309
|
-
onClick: function onClick() {
|
|
310
|
-
return _this2.onChoiceFocus(choice.id);
|
|
311
|
-
},
|
|
312
|
-
onRemoveChoice: function onRemoveChoice() {
|
|
313
|
-
return _this2.onChoiceRemove(choice.id);
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
})), error && /*#__PURE__*/_react["default"].createElement("div", {
|
|
317
|
-
className: classes.errorText
|
|
318
|
-
}, error), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
|
|
319
|
-
open: showWarning,
|
|
320
|
-
title: "Warning",
|
|
321
|
-
text: "Identical answer choices are not allowed and the changes will be discarded.",
|
|
322
|
-
onConfirm: function onConfirm() {
|
|
323
|
-
return _this2.setState({
|
|
324
|
-
showWarning: false
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
}));
|
|
328
|
-
}
|
|
329
|
-
}]);
|
|
330
|
-
return Choices;
|
|
331
|
-
}(_react["default"].Component);
|
|
332
|
-
|
|
333
|
-
exports.Choices = Choices;
|
|
334
|
-
(0, _defineProperty2["default"])(Choices, "propTypes", {
|
|
335
|
-
duplicates: _propTypes["default"].bool,
|
|
336
|
-
error: _propTypes["default"].string,
|
|
337
|
-
model: _propTypes["default"].object.isRequired,
|
|
338
|
-
onChange: _propTypes["default"].func.isRequired,
|
|
339
|
-
classes: _propTypes["default"].object.isRequired,
|
|
340
|
-
toolbarOpts: _propTypes["default"].object,
|
|
341
|
-
maxChoices: _propTypes["default"].number,
|
|
342
|
-
uploadSoundSupport: _propTypes["default"].object
|
|
343
|
-
});
|
|
344
|
-
var Styled = (0, _styles.withStyles)(styles)(Choices);
|
|
345
|
-
var _default = Styled;
|
|
346
|
-
exports["default"] = _default;
|
|
347
|
-
//# sourceMappingURL=choices.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/choices.jsx"],"names":["window","renMath","renderMath","styles","theme","design","marginTop","spacing","unit","altChoices","alignItems","display","flexWrap","justifyContent","margin","errorText","fontSize","typography","color","paddingBottom","Choices","showWarning","domNode","ReactDOM","findDOMNode","prevValue","val","key","props","onChange","model","choices","correctResponse","alternateResponses","duplicatedValue","find","c","value","id","newChoices","filter","setState","map","choice","usedForResponse","Object","keys","forEach","responseKey","values","alternate","indexOf","alert","newChoicesWithoutTheEmptyOne","focusedEl","oldChoices","length","duplicates","v","rerenderMath","state","classes","error","maxChoices","toolbarOpts","uploadSoundSupport","visibleChoices","getVisibleChoices","addButton","onAddChoice","index","minWidth","zIndex","editor","editorInstance","prompt","video","disabled","audio","onChoiceChanged","undefined","onChoiceFocus","onChoiceRemove","React","Component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;AAIjB5D,EAAAA,QAAQ,EAAEwD,sBAAUK,IAAV,CAAeD,UAJR;AAKjB5B,EAAAA,OAAO,EAAEwB,sBAAUG,MAAV,CAAiBC,UALT;AAMjBzB,EAAAA,WAAW,EAAEqB,sBAAUG,MANN;AAOjBzB,EAAAA,UAAU,EAAEsB,sBAAUM,MAPL;AAQjB1B,EAAAA,kBAAkB,EAAEoB,sBAAUG;AARb,C;AAkOrB,IAAMI,MAAM,GAAG,wBAAWzF,MAAX,EAAmBiB,OAAnB,CAAf;eAEewE,M","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"],"file":"choices.js"}
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/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"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,QAAQ,EAAE,KADL;AAELC,IAAAA,IAAI,EAAE,QAFD;AAGLC,IAAAA,MAAM,EAAE,yCAHH;AAILC,IAAAA,MAAM,EAAE,EAJH;AAKLC,IAAAA,OAAO,EAAE,EALJ;AAMLC,IAAAA,eAAe,EAAE,OANZ;AAOLC,IAAAA,eAAe,EAAE,EAPZ;AAQLC,IAAAA,UAAU,EAAE,IARP;AASLC,IAAAA,gBAAgB,EAAE,IATb;AAULC,IAAAA,aAAa,EAAE,IAVV;AAWLC,IAAAA,0BAA0B,EAAE,IAXvB;AAYLC,IAAAA,0BAA0B,EAAE,IAZvB;AAaLC,IAAAA,qBAAqB,EAAE;AAblB,GADM;AAgBbC,EAAAA,aAAa,EAAE;AACbC,IAAAA,UAAU,EAAE;AACVC,MAAAA,K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KAAK,EAAE;AAFG;AA/CC;AAhBF,C","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"],"file":"defaults.js"}
|