@instructure/quiz-core 20.35.2 → 20.35.3-rc.1
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/es/banks/components/AddToBankModal/index.js +0 -4
- package/es/banks/components/AddToBankModal/presenter.js +5 -109
- package/es/banks/components/BankEntry/presenter.js +0 -2
- package/es/building/api/items.js +0 -13
- package/es/building/api/stimuli.js +0 -13
- package/es/building/components/resources/quizEntry/QuizEntryEdit/Footer/presenter.js +4 -2
- package/es/building/components/resources/quizEntry/QuizEntryEdit/presenter.js +0 -1
- package/es/common/components/layout/Page/styles.js +10 -1
- package/es/common/components/layout/Page/theme.js +5 -2
- package/es/common/components/resources/entry/EntrySave/index.js +1 -7
- package/es/common/components/resources/entry/EntrySave/presenter.js +27 -90
- package/es/common/components/resources/quiz/instructions/styles.js +9 -0
- package/es/common/components/resources/quiz/instructions/theme.js +3 -1
- package/es/common/components/resources/stimulus/StimulusEdit/presenter.js +0 -1
- package/lib/banks/components/AddToBankModal/index.js +0 -4
- package/lib/banks/components/AddToBankModal/presenter.js +5 -109
- package/lib/banks/components/BankEntry/presenter.js +0 -2
- package/lib/building/api/items.js +0 -14
- package/lib/building/api/stimuli.js +0 -14
- package/lib/building/components/resources/quizEntry/QuizEntryEdit/Footer/presenter.js +4 -2
- package/lib/building/components/resources/quizEntry/QuizEntryEdit/presenter.js +0 -1
- package/lib/common/components/layout/Page/styles.js +10 -1
- package/lib/common/components/layout/Page/theme.js +5 -2
- package/lib/common/components/resources/entry/EntrySave/index.js +1 -7
- package/lib/common/components/resources/entry/EntrySave/presenter.js +27 -90
- package/lib/common/components/resources/quiz/instructions/styles.js +9 -0
- package/lib/common/components/resources/quiz/instructions/theme.js +3 -1
- package/lib/common/components/resources/stimulus/StimulusEdit/presenter.js +0 -1
- package/package.json +31 -30
|
@@ -6,15 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.AddToBankModal = void 0;
|
|
9
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
12
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
15
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
|
|
18
15
|
var _uiButtons = require("@instructure/ui-buttons");
|
|
19
16
|
var _uiHeading = require("@instructure/ui-heading");
|
|
20
17
|
var _uiTextInput = require("@instructure/ui-text-input");
|
|
@@ -22,24 +19,10 @@ var _uiRadioInput = require("@instructure/ui-radio-input");
|
|
|
22
19
|
var _uiA11yContent = require("@instructure/ui-a11y-content");
|
|
23
20
|
var _Bank = _interopRequireDefault(require("../../../common/records/Bank.js"));
|
|
24
21
|
var _presenter = _interopRequireDefault(require("../../../common/components/resources/BankSelection/presenter.js"));
|
|
25
|
-
var _uiSpinner = require("@instructure/ui-spinner");
|
|
26
|
-
var _uiText = require("@instructure/ui-text");
|
|
27
|
-
var _uiIcons = require("@instructure/ui-icons");
|
|
28
|
-
var _uiView = require("@instructure/ui-view");
|
|
29
|
-
var _uiFlex = require("@instructure/ui-flex");
|
|
30
22
|
var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
|
|
31
23
|
var _quizCommon = require("@instructure/quiz-common");
|
|
32
24
|
var _featureCheck = require("../../../common/util/featureCheck.js");
|
|
33
|
-
var
|
|
34
|
-
padding: "0 small 0 0"
|
|
35
|
-
}, /*#__PURE__*/_react.default.createElement(_uiIcons.IconNoLine, {
|
|
36
|
-
color: "error",
|
|
37
|
-
size: "small"
|
|
38
|
-
}));
|
|
39
|
-
var _ref3 = /*#__PURE__*/_react.default.createElement(_uiIcons.IconWarningLine, {
|
|
40
|
-
color: "warning"
|
|
41
|
-
});
|
|
42
|
-
var _ref4 = /*#__PURE__*/_react.default.createElement("br", null);
|
|
25
|
+
var _ref = /*#__PURE__*/_react.default.createElement("br", null);
|
|
43
26
|
var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
44
27
|
(0, _inherits2.default)(AddToBankModal, _Component);
|
|
45
28
|
var _super = (0, _createSuper2.default)(AddToBankModal);
|
|
@@ -52,7 +35,6 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
52
35
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
53
36
|
_this.state = {
|
|
54
37
|
bankType: 'existing',
|
|
55
|
-
contentShareable: 'loading',
|
|
56
38
|
newBankTitle: '',
|
|
57
39
|
selectedBank: null
|
|
58
40
|
};
|
|
@@ -113,57 +95,6 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
113
95
|
return _this;
|
|
114
96
|
}
|
|
115
97
|
(0, _createClass2.default)(AddToBankModal, [{
|
|
116
|
-
key: "componentDidUpdate",
|
|
117
|
-
value: function componentDidUpdate(prevProps) {
|
|
118
|
-
var _this2 = this;
|
|
119
|
-
var _this$props = this.props,
|
|
120
|
-
canvasOrigin = _this$props.canvasOrigin,
|
|
121
|
-
modalOpen = _this$props.modalOpen,
|
|
122
|
-
checkContentShareability = _this$props.checkContentShareability,
|
|
123
|
-
workingEntry = _this$props.workingEntry;
|
|
124
|
-
if (modalOpen && !prevProps.modalOpen) {
|
|
125
|
-
this.setState({
|
|
126
|
-
contentShareable: 'loading'
|
|
127
|
-
});
|
|
128
|
-
checkContentShareability(workingEntry, canvasOrigin).then(function () {
|
|
129
|
-
_this2.setState({
|
|
130
|
-
contentShareable: 'true'
|
|
131
|
-
});
|
|
132
|
-
}).catch(/*#__PURE__*/function () {
|
|
133
|
-
var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(err) {
|
|
134
|
-
var _err$response, _err$response2;
|
|
135
|
-
var body;
|
|
136
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
137
|
-
while (1) {
|
|
138
|
-
switch (_context.prev = _context.next) {
|
|
139
|
-
case 0:
|
|
140
|
-
_context.next = 2;
|
|
141
|
-
return (_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.json();
|
|
142
|
-
case 2:
|
|
143
|
-
body = _context.sent;
|
|
144
|
-
if (((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.status) === 400 && body.shareable === false) {
|
|
145
|
-
_this2.setState({
|
|
146
|
-
contentShareable: 'false'
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
_this2.setState({
|
|
150
|
-
contentShareable: 'unknown'
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
case 4:
|
|
154
|
-
case "end":
|
|
155
|
-
return _context.stop();
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}, _callee);
|
|
159
|
-
}));
|
|
160
|
-
return function (_x) {
|
|
161
|
-
return _ref.apply(this, arguments);
|
|
162
|
-
};
|
|
163
|
-
}());
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}, {
|
|
167
98
|
key: "cancelButton",
|
|
168
99
|
value: function cancelButton() {
|
|
169
100
|
return /*#__PURE__*/_react.default.createElement(_uiButtons.Button, {
|
|
@@ -176,10 +107,8 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
176
107
|
value: function addToBankButton() {
|
|
177
108
|
var _this$state = this.state,
|
|
178
109
|
bankType = _this$state.bankType,
|
|
179
|
-
newBankTitle = _this$state.newBankTitle
|
|
180
|
-
|
|
181
|
-
var contentShareableLoading = contentShareable === 'loading';
|
|
182
|
-
var disabled = bankType === 'existing' && !this.state.selectedBank || bankType === 'new' && (!newBankTitle || !newBankTitle.trim()) || contentShareableLoading;
|
|
110
|
+
newBankTitle = _this$state.newBankTitle;
|
|
111
|
+
var disabled = bankType === 'existing' && !this.state.selectedBank || bankType === 'new' && (!newBankTitle || !newBankTitle.trim());
|
|
183
112
|
return /*#__PURE__*/_react.default.createElement(_uiButtons.Button, {
|
|
184
113
|
type: "button",
|
|
185
114
|
color: "primary",
|
|
@@ -187,7 +116,7 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
187
116
|
disabled: disabled,
|
|
188
117
|
margin: _quizCommon.XSMALL_SIDE_MARGIN,
|
|
189
118
|
"data-automation": "sdk-add-to-bank-button"
|
|
190
|
-
},
|
|
119
|
+
}, (0, _formatMessage.default)('Add'));
|
|
191
120
|
}
|
|
192
121
|
}, {
|
|
193
122
|
key: "renderBankTypeContent",
|
|
@@ -206,35 +135,6 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
206
135
|
type: "text"
|
|
207
136
|
});
|
|
208
137
|
}
|
|
209
|
-
}, {
|
|
210
|
-
key: "renderContentShareabilityMessage",
|
|
211
|
-
value: function renderContentShareabilityMessage() {
|
|
212
|
-
var content = null;
|
|
213
|
-
if (this.state.contentShareable === 'loading') {
|
|
214
|
-
content = /*#__PURE__*/_react.default.createElement(_uiText.Text, null, /*#__PURE__*/_react.default.createElement(_uiSpinner.Spinner, {
|
|
215
|
-
size: "x-small",
|
|
216
|
-
renderTitle: (0, _formatMessage.default)('Checking content shareability...')
|
|
217
|
-
}), "\xA0", (0, _formatMessage.default)('Validating content...'));
|
|
218
|
-
} else if (this.state.contentShareable === 'true') {
|
|
219
|
-
// No message needed. The API call to check shareability is very fast in most cases,
|
|
220
|
-
// so the user may be distracted by a message here.
|
|
221
|
-
content = null;
|
|
222
|
-
} else if (this.state.contentShareable === 'false') {
|
|
223
|
-
content = /*#__PURE__*/_react.default.createElement(_uiFlex.Flex, null, _ref2, /*#__PURE__*/_react.default.createElement(_uiFlex.Flex.Item, {
|
|
224
|
-
shouldShrink: true
|
|
225
|
-
}, /*#__PURE__*/_react.default.createElement(_uiText.Text, {
|
|
226
|
-
color: "danger"
|
|
227
|
-
}, (0, _formatMessage.default)('You are attempting to add content containing course links which may not work when used in other courses.'))));
|
|
228
|
-
} else {
|
|
229
|
-
content = /*#__PURE__*/_react.default.createElement(_uiText.Text, {
|
|
230
|
-
color: "warning"
|
|
231
|
-
}, _ref3, "\xA0", (0, _formatMessage.default)('There was an error attempting to validate shareability.'));
|
|
232
|
-
}
|
|
233
|
-
return /*#__PURE__*/_react.default.createElement(_uiView.View, {
|
|
234
|
-
as: "div",
|
|
235
|
-
margin: "small 0 0 0"
|
|
236
|
-
}, content);
|
|
237
|
-
}
|
|
238
138
|
}, {
|
|
239
139
|
key: "renderContent",
|
|
240
140
|
value: function renderContent() {
|
|
@@ -249,7 +149,7 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
249
149
|
}), /*#__PURE__*/_react.default.createElement(_uiRadioInput.RadioInput, {
|
|
250
150
|
value: "new",
|
|
251
151
|
label: (0, _formatMessage.default)('New item bank')
|
|
252
|
-
})),
|
|
152
|
+
})), _ref, this.renderBankTypeContent());
|
|
253
153
|
}
|
|
254
154
|
}, {
|
|
255
155
|
key: "render",
|
|
@@ -276,8 +176,6 @@ var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
276
176
|
}(_react.Component);
|
|
277
177
|
exports.AddToBankModal = AddToBankModal;
|
|
278
178
|
AddToBankModal.propTypes = {
|
|
279
|
-
canvasOrigin: _propTypes.default.string,
|
|
280
|
-
checkContentShareability: _propTypes.default.func.isRequired,
|
|
281
179
|
closeModal: _propTypes.default.func.isRequired,
|
|
282
180
|
createBank: _propTypes.default.func.isRequired,
|
|
283
181
|
moveBankEntryFromQuizEntry: _propTypes.default.func.isRequired,
|
|
@@ -296,11 +194,9 @@ AddToBankModal.propTypes = {
|
|
|
296
194
|
onAdd: _propTypes.default.func,
|
|
297
195
|
onContinue: _propTypes.default.func,
|
|
298
196
|
uiSet: _propTypes.default.func.isRequired,
|
|
299
|
-
workingEntry: _reactImmutableProptypes.default.record.isRequired,
|
|
300
197
|
quizId: _propTypes.default.string.isRequired
|
|
301
198
|
};
|
|
302
199
|
AddToBankModal.defaultProps = {
|
|
303
|
-
canvasOrigin: '',
|
|
304
200
|
handleValidationErrorsFromApi: function handleValidationErrorsFromApi() {},
|
|
305
201
|
onAdd: function onAdd() {},
|
|
306
202
|
onContinue: function onContinue() {}
|
|
@@ -155,14 +155,12 @@ var BankEntry = (_dec = (0, _quizCommon.withStyleOverrides)(_styles.default, _th
|
|
|
155
155
|
clearChanges: _this.clearChanges,
|
|
156
156
|
clearValidationErrorsFromApi: _this.clearValidationErrorsFromApi,
|
|
157
157
|
contextUuid: null,
|
|
158
|
-
disableSubmit: Boolean(_this.state.validationErrorsFromApi && Object.values(_this.state.validationErrorsFromApi).length),
|
|
159
158
|
entry: entry,
|
|
160
159
|
guid: "".concat(_this.props.bankEntry.id, "_bank_entry_edit"),
|
|
161
160
|
handleQuizEntryPointsChange: _this.handlePointsChange,
|
|
162
161
|
itemEditArea: _this.itemEditArea,
|
|
163
162
|
parentId: _this.props.bankId,
|
|
164
163
|
parentType: _quizCommon.PARENT_TYPE_BANK,
|
|
165
|
-
shouldValidateShareableContent: true,
|
|
166
164
|
stimulus: entry,
|
|
167
165
|
submitHandler: _this.submitHandler,
|
|
168
166
|
validationErrorsFromApi: _this.state.validationErrorsFromApi,
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.getItem = getItem;
|
|
8
|
-
exports.checkItemShareability = checkItemShareability;
|
|
9
8
|
exports.createItem = createItem;
|
|
10
9
|
exports.updateItem = updateItem;
|
|
11
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
@@ -43,19 +42,6 @@ function getItem(itemId) {
|
|
|
43
42
|
});
|
|
44
43
|
};
|
|
45
44
|
}
|
|
46
|
-
function checkItemShareability(item, canvasOrigin) {
|
|
47
|
-
var url = '/api/items/check_shareability';
|
|
48
|
-
var requestBody = JSON.stringify({
|
|
49
|
-
item: updateItemParams(item),
|
|
50
|
-
source_origin: canvasOrigin
|
|
51
|
-
});
|
|
52
|
-
var fetcher = new _Fetcher.default({
|
|
53
|
-
onError: function onError() {}
|
|
54
|
-
});
|
|
55
|
-
return fetcher.post(url, {
|
|
56
|
-
body: requestBody
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
45
|
function createItem(item, parentId, parentType) {
|
|
60
46
|
var parentItemId = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
|
61
47
|
var resource = parentType === 'bank' ? 'banks' : 'quizzes';
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.createStimulus = createStimulus;
|
|
8
8
|
exports.updateStimulus = updateStimulus;
|
|
9
|
-
exports.checkStimulusShareability = checkStimulusShareability;
|
|
10
9
|
var _quizCommon = require("@instructure/quiz-common");
|
|
11
10
|
var _alerts = require("../../common/actions/alerts.js");
|
|
12
11
|
var _callHandlers = require("../../common/api/callHandlers.js");
|
|
@@ -87,17 +86,4 @@ function updateStimulus(stimulus, parentId, parentType) {
|
|
|
87
86
|
return stimulusData;
|
|
88
87
|
});
|
|
89
88
|
};
|
|
90
|
-
}
|
|
91
|
-
function checkStimulusShareability(stimulus, canvasOrigin) {
|
|
92
|
-
var url = '/api/stimuli/check_shareability';
|
|
93
|
-
var requestBody = JSON.stringify({
|
|
94
|
-
stimulus: updateStimulusParams(stimulus),
|
|
95
|
-
source_origin: canvasOrigin
|
|
96
|
-
});
|
|
97
|
-
var fetcher = new _Fetcher.default({
|
|
98
|
-
onError: function onError() {}
|
|
99
|
-
});
|
|
100
|
-
return fetcher.post(url, {
|
|
101
|
-
body: requestBody
|
|
102
|
-
});
|
|
103
89
|
}
|
|
@@ -154,6 +154,7 @@ var QuizEntryEditFooter = (_dec = (0, _quizCommon.withStyleOverrides)(_styles.de
|
|
|
154
154
|
}, {
|
|
155
155
|
key: "renderPointsSection",
|
|
156
156
|
value: function renderPointsSection() {
|
|
157
|
+
var currentPointsValue = this.state.points;
|
|
157
158
|
return (0, _emotion.jsx)("div", {
|
|
158
159
|
css: this.props.styles.pointsSection
|
|
159
160
|
}, (0, _emotion.jsx)("span", {
|
|
@@ -162,9 +163,10 @@ var QuizEntryEditFooter = (_dec = (0, _quizCommon.withStyleOverrides)(_styles.de
|
|
|
162
163
|
renderLabel: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('Points Possible Input')),
|
|
163
164
|
onChange: this.handlePointsChange,
|
|
164
165
|
onBlur: this.handlePointsBlur,
|
|
165
|
-
value:
|
|
166
|
+
value: currentPointsValue,
|
|
166
167
|
disabled: this.pointsDisabled(),
|
|
167
|
-
"data-automation": "sdk-points-possible-numberinput"
|
|
168
|
+
"data-automation": "sdk-points-possible-numberinput",
|
|
169
|
+
"aria-valuetext": "".concat(currentPointsValue, " ").concat((0, _formatMessage.default)('Points'))
|
|
168
170
|
})), (0, _emotion.jsx)(_uiView.View, {
|
|
169
171
|
margin: "none none none x-small"
|
|
170
172
|
}, (0, _emotion.jsx)(_uiText.Text, {
|
|
@@ -333,7 +333,6 @@ var QuizEntryEdit = (_dec = (0, _quizCommon.withStyleOverrides)(_styles.default,
|
|
|
333
333
|
onContinue: this.handleAddToBankContinue,
|
|
334
334
|
onAdd: this.handleAddToBank,
|
|
335
335
|
getEntry: this.getEntryForBank,
|
|
336
|
-
workingEntry: this.props.workingEntry,
|
|
337
336
|
entryId: this.props.guid,
|
|
338
337
|
entryType: this.props.quizEntry.entryType,
|
|
339
338
|
quizId: this.props.quizId,
|
|
@@ -24,7 +24,16 @@ var generateStyle = function generateStyle(componentTheme, props) {
|
|
|
24
24
|
overflowY: 'auto'
|
|
25
25
|
}), {}, {
|
|
26
26
|
transition: componentTheme.contentTransition,
|
|
27
|
-
width: '100%'
|
|
27
|
+
width: '100%',
|
|
28
|
+
'.user_content p': {
|
|
29
|
+
margin: componentTheme.userContentMargin,
|
|
30
|
+
'&:first-of-type': {
|
|
31
|
+
marginTop: componentTheme.userContentZeroMargin
|
|
32
|
+
},
|
|
33
|
+
'&:last-child': {
|
|
34
|
+
marginBottom: componentTheme.userContentZeroMargin
|
|
35
|
+
}
|
|
36
|
+
}
|
|
28
37
|
})
|
|
29
38
|
};
|
|
30
39
|
};
|
|
@@ -7,10 +7,13 @@ exports.default = void 0;
|
|
|
7
7
|
var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
8
8
|
var typography = _ref.typography,
|
|
9
9
|
breakpoints = _ref.breakpoints,
|
|
10
|
-
transitions = _ref.transitions
|
|
10
|
+
transitions = _ref.transitions,
|
|
11
|
+
spacing = _ref.spacing;
|
|
11
12
|
return {
|
|
12
13
|
fontFamily: typography.fontFamily,
|
|
13
|
-
contentTransition: "transform ".concat(transitions.duration)
|
|
14
|
+
contentTransition: "transform ".concat(transitions.duration),
|
|
15
|
+
userContentMargin: spacing.mediumSmall,
|
|
16
|
+
userContentZeroMargin: 0
|
|
14
17
|
};
|
|
15
18
|
};
|
|
16
19
|
var _default = generateComponentTheme;
|
|
@@ -7,21 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.mapStateToProps = mapStateToProps;
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _reactRedux = require("../../../../react-redux.js");
|
|
10
|
-
var _items = require("../../../../../building/api/items.js");
|
|
11
|
-
var _stimuli = require("../../../../../building/api/stimuli.js");
|
|
12
10
|
var _makeEditable = _interopRequireDefault(require("../../../shared/functionality/makeEditable.js"));
|
|
13
11
|
var _errorsShowing = require("../../../../actions/errorsShowing.js");
|
|
14
12
|
var _alerts = require("../../../../actions/alerts.js");
|
|
15
13
|
var _modifications = require("../../../../actions/modifications.js");
|
|
16
|
-
var _modal = require("../../../../actions/modal.js");
|
|
17
14
|
var _presenter = _interopRequireDefault(require("./presenter.js"));
|
|
18
15
|
function mapStateToProps(state, props) {
|
|
19
16
|
// Error Related:
|
|
20
17
|
var workingEntry = props.entry.getWorkingInstance();
|
|
21
18
|
var isValid = props.isValid !== void 0 ? props.isValid : workingEntry.isValid();
|
|
22
19
|
return {
|
|
23
|
-
canvasOrigin: state.getIn(['config', 'canvasOrigin']),
|
|
24
|
-
checkContentShareability: props.entry.isStimulus ? _stimuli.checkStimulusShareability : _items.checkItemShareability,
|
|
25
20
|
isValid: isValid
|
|
26
21
|
};
|
|
27
22
|
}
|
|
@@ -29,8 +24,7 @@ var mapDispatchToProps = {
|
|
|
29
24
|
clearNextQuizEntry: _modifications.clearNextQuizEntry,
|
|
30
25
|
hideError: _errorsShowing.hideError,
|
|
31
26
|
screenreaderNotification: _alerts.screenreaderNotification,
|
|
32
|
-
showError: _errorsShowing.showError
|
|
33
|
-
withConfirm: _modal.withConfirm
|
|
27
|
+
showError: _errorsShowing.showError
|
|
34
28
|
};
|
|
35
29
|
var _default = (0, _makeEditable.default)((0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_presenter.default));
|
|
36
30
|
exports.default = _default;
|
|
@@ -14,7 +14,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
14
14
|
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
15
15
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
|
|
18
17
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
19
18
|
var _uiButtons = require("@instructure/ui-buttons");
|
|
20
19
|
var _uiView = require("@instructure/ui-view");
|
|
@@ -41,91 +40,36 @@ var EntrySave = /*#__PURE__*/function (_Component) {
|
|
|
41
40
|
});
|
|
42
41
|
_this.props.screenreaderNotification(msg);
|
|
43
42
|
};
|
|
44
|
-
_this.confirmShareableContent = function () {
|
|
45
|
-
var _this$props = _this.props,
|
|
46
|
-
canvasOrigin = _this$props.canvasOrigin,
|
|
47
|
-
checkContentShareability = _this$props.checkContentShareability,
|
|
48
|
-
entry = _this$props.entry,
|
|
49
|
-
withConfirm = _this$props.withConfirm;
|
|
50
|
-
_this.setState({
|
|
51
|
-
canSubmit: false
|
|
52
|
-
});
|
|
53
|
-
checkContentShareability(entry.getWorkingInstance(), canvasOrigin).then(function () {
|
|
54
|
-
_this.successfulSubmit();
|
|
55
|
-
}).catch(/*#__PURE__*/function () {
|
|
56
|
-
var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(err) {
|
|
57
|
-
var _err$response, _err$response2;
|
|
58
|
-
var body, text;
|
|
59
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
60
|
-
while (1) {
|
|
61
|
-
switch (_context.prev = _context.next) {
|
|
62
|
-
case 0:
|
|
63
|
-
_context.next = 2;
|
|
64
|
-
return (_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.json();
|
|
65
|
-
case 2:
|
|
66
|
-
body = _context.sent;
|
|
67
|
-
text = (0, _formatMessage.default)('There was an error attempting to validate shareability.');
|
|
68
|
-
if (((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.status) === 400 && body.shareable === false) {
|
|
69
|
-
text = (0, _formatMessage.default)('You are attempting to save content containing course links which may not work when used in other courses.');
|
|
70
|
-
}
|
|
71
|
-
withConfirm(function () {
|
|
72
|
-
_this.successfulSubmit();
|
|
73
|
-
}, {
|
|
74
|
-
title: (0, _formatMessage.default)('Are you sure?'),
|
|
75
|
-
text: text,
|
|
76
|
-
continueText: (0, _formatMessage.default)('Save anyway'),
|
|
77
|
-
onCancel: function onCancel() {
|
|
78
|
-
_this.setState({
|
|
79
|
-
canSubmit: true
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
case 6:
|
|
84
|
-
case "end":
|
|
85
|
-
return _context.stop();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, _callee);
|
|
89
|
-
}));
|
|
90
|
-
return function (_x) {
|
|
91
|
-
return _ref.apply(this, arguments);
|
|
92
|
-
};
|
|
93
|
-
}());
|
|
94
|
-
};
|
|
95
43
|
_this.onSubmit = /*#__PURE__*/function () {
|
|
96
|
-
var
|
|
97
|
-
return _regenerator.default.wrap(function
|
|
44
|
+
var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(e) {
|
|
45
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
98
46
|
while (1) {
|
|
99
|
-
switch (
|
|
47
|
+
switch (_context.prev = _context.next) {
|
|
100
48
|
case 0:
|
|
101
49
|
e.preventDefault();
|
|
102
50
|
if (!_this.props.isValid) {
|
|
103
|
-
|
|
51
|
+
_context.next = 5;
|
|
104
52
|
break;
|
|
105
53
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} else {
|
|
109
|
-
_this.successfulSubmit();
|
|
110
|
-
}
|
|
111
|
-
_context2.next = 10;
|
|
54
|
+
_this.successfulSubmit();
|
|
55
|
+
_context.next = 10;
|
|
112
56
|
break;
|
|
113
57
|
case 5:
|
|
114
58
|
_this.createScreenReaderNotification();
|
|
115
|
-
|
|
59
|
+
_context.next = 8;
|
|
116
60
|
return _this.props.showError(_this.props.guid);
|
|
117
61
|
case 8:
|
|
118
62
|
_this.props.clearNextQuizEntry();
|
|
119
63
|
_this.focusFirstErrorField();
|
|
120
64
|
case 10:
|
|
121
65
|
case "end":
|
|
122
|
-
return
|
|
66
|
+
return _context.stop();
|
|
123
67
|
}
|
|
124
68
|
}
|
|
125
|
-
},
|
|
69
|
+
}, _callee);
|
|
126
70
|
}));
|
|
127
|
-
return function (
|
|
128
|
-
return
|
|
71
|
+
return function (_x) {
|
|
72
|
+
return _ref.apply(this, arguments);
|
|
129
73
|
};
|
|
130
74
|
}();
|
|
131
75
|
_this.focusFirstErrorField = function () {
|
|
@@ -163,46 +107,46 @@ var EntrySave = /*#__PURE__*/function (_Component) {
|
|
|
163
107
|
}, {
|
|
164
108
|
key: "successfulSubmit",
|
|
165
109
|
value: function () {
|
|
166
|
-
var _successfulSubmit = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function
|
|
110
|
+
var _successfulSubmit = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
167
111
|
var validationResult;
|
|
168
|
-
return _regenerator.default.wrap(function
|
|
112
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
169
113
|
while (1) {
|
|
170
|
-
switch (
|
|
114
|
+
switch (_context2.prev = _context2.next) {
|
|
171
115
|
case 0:
|
|
172
116
|
this.setState({
|
|
173
117
|
canSubmit: false
|
|
174
118
|
});
|
|
175
|
-
|
|
176
|
-
|
|
119
|
+
_context2.prev = 1;
|
|
120
|
+
_context2.next = 4;
|
|
177
121
|
return this.props.submitHandler();
|
|
178
122
|
case 4:
|
|
179
|
-
validationResult =
|
|
123
|
+
validationResult = _context2.sent;
|
|
180
124
|
if (!(validationResult === _quizCommon.API_INPUT_VALIDATION_ERROR)) {
|
|
181
|
-
|
|
125
|
+
_context2.next = 8;
|
|
182
126
|
break;
|
|
183
127
|
}
|
|
184
128
|
this.createScreenReaderNotification();
|
|
185
129
|
throw new Error('User input validation error received from API.');
|
|
186
130
|
case 8:
|
|
187
|
-
|
|
131
|
+
_context2.next = 14;
|
|
188
132
|
break;
|
|
189
133
|
case 10:
|
|
190
|
-
|
|
191
|
-
|
|
134
|
+
_context2.prev = 10;
|
|
135
|
+
_context2.t0 = _context2["catch"](1);
|
|
192
136
|
this.setState({
|
|
193
137
|
canSubmit: true
|
|
194
138
|
});
|
|
195
|
-
return
|
|
139
|
+
return _context2.abrupt("return");
|
|
196
140
|
case 14:
|
|
197
141
|
this.props.switchOffEditing();
|
|
198
142
|
this.props.hideError(this.props.guid);
|
|
199
143
|
this.props.screenreaderNotification((0, _formatMessage.default)('Changes to question saved.'));
|
|
200
144
|
case 17:
|
|
201
145
|
case "end":
|
|
202
|
-
return
|
|
146
|
+
return _context2.stop();
|
|
203
147
|
}
|
|
204
148
|
}
|
|
205
|
-
},
|
|
149
|
+
}, _callee2, this, [[1, 10]]);
|
|
206
150
|
}));
|
|
207
151
|
function successfulSubmit() {
|
|
208
152
|
return _successfulSubmit.apply(this, arguments);
|
|
@@ -236,14 +180,11 @@ var EntrySave = /*#__PURE__*/function (_Component) {
|
|
|
236
180
|
exports.EntrySave = EntrySave;
|
|
237
181
|
EntrySave.propTypes = {
|
|
238
182
|
cancelHandler: _propTypes.default.func,
|
|
239
|
-
canvasOrigin: _propTypes.default.string,
|
|
240
|
-
checkContentShareability: _propTypes.default.func.isRequired,
|
|
241
183
|
clearChanges: _propTypes.default.func.isRequired,
|
|
242
184
|
// From connected component
|
|
243
185
|
clearNextQuizEntry: _propTypes.default.func.isRequired,
|
|
244
186
|
disableSubmit: _propTypes.default.bool,
|
|
245
187
|
displayPosition: _propTypes.default.number,
|
|
246
|
-
entry: _reactImmutableProptypes.default.record.isRequired,
|
|
247
188
|
guid: _propTypes.default.string,
|
|
248
189
|
hideError: _propTypes.default.func.isRequired,
|
|
249
190
|
initialFocusId: _propTypes.default.string,
|
|
@@ -251,22 +192,18 @@ EntrySave.propTypes = {
|
|
|
251
192
|
itemEditArea: _propTypes.default.object,
|
|
252
193
|
showError: _propTypes.default.func.isRequired,
|
|
253
194
|
screenreaderNotification: _propTypes.default.func.isRequired,
|
|
254
|
-
shouldValidateShareableContent: _propTypes.default.bool,
|
|
255
195
|
submitHandler: _propTypes.default.func.isRequired,
|
|
256
196
|
// from makescrollable / from props being passed in occasionally
|
|
257
197
|
switchOnEditing: _propTypes.default.func.isRequired,
|
|
258
|
-
switchOffEditing: _propTypes.default.func.isRequired
|
|
259
|
-
withConfirm: _propTypes.default.func.isRequired
|
|
198
|
+
switchOffEditing: _propTypes.default.func.isRequired
|
|
260
199
|
};
|
|
261
200
|
EntrySave.defaultProps = {
|
|
262
201
|
cancelHandler: _noop.default,
|
|
263
|
-
canvasOrigin: '',
|
|
264
|
-
displayPosition: null,
|
|
265
202
|
disableSubmit: false,
|
|
203
|
+
displayPosition: null,
|
|
266
204
|
guid: null,
|
|
267
205
|
initialFocusId: null,
|
|
268
|
-
itemEditArea: null
|
|
269
|
-
shouldValidateShareableContent: false
|
|
206
|
+
itemEditArea: null
|
|
270
207
|
};
|
|
271
208
|
var _default = EntrySave;
|
|
272
209
|
exports.default = _default;
|
|
@@ -16,6 +16,15 @@ var generateStyle = function generateStyle(componentTheme) {
|
|
|
16
16
|
clear: 'both',
|
|
17
17
|
content: '""',
|
|
18
18
|
display: 'table'
|
|
19
|
+
},
|
|
20
|
+
'.user_content p': {
|
|
21
|
+
margin: componentTheme.userContentMargin,
|
|
22
|
+
'&:first-of-type': {
|
|
23
|
+
marginTop: componentTheme.userContentZeroMargin
|
|
24
|
+
},
|
|
25
|
+
'&:last-child': {
|
|
26
|
+
marginBottom: componentTheme.userContentMargin
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
29
|
},
|
|
21
30
|
text: {
|
|
@@ -9,7 +9,9 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
9
9
|
typography = _ref.typography;
|
|
10
10
|
return {
|
|
11
11
|
wrapperPadding: spacing.large,
|
|
12
|
-
textFontSize: typography.fontSizeMedium
|
|
12
|
+
textFontSize: typography.fontSizeMedium,
|
|
13
|
+
userContentMargin: spacing.mediumSmall,
|
|
14
|
+
userContentZeroMargin: 0
|
|
13
15
|
};
|
|
14
16
|
};
|
|
15
17
|
var _default = generateComponentTheme;
|
|
@@ -317,7 +317,6 @@ var StimulusEdit = (_dec = (0, _quizCommon.withStyleOverrides)(_styles.default,
|
|
|
317
317
|
onAdd: this.handleAddToBank,
|
|
318
318
|
onContinue: this.handleAddToBankContinue,
|
|
319
319
|
getEntry: this.getEntryForBank,
|
|
320
|
-
workingEntry: this.props.workingStimulus,
|
|
321
320
|
quizId: this.props.quizId,
|
|
322
321
|
entryId: this.props.guid,
|
|
323
322
|
entryType: this.props.quizEntry.entryType
|