@instructure/quiz-core 20.35.1-rc.6 → 20.35.1-rc.7
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/presenter.js +0 -1
- 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/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/presenter.js +0 -1
- 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/stimulus/StimulusEdit/presenter.js +0 -1
- package/package.json +9 -9
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { connect } from "../../../common/react-redux.js";
|
|
2
2
|
import { createBank } from "../../api/banks.js";
|
|
3
3
|
import { createBankEntry, moveBankEntryFromQuizEntry } from "../../api/bankEntries.js";
|
|
4
|
-
import { checkItemShareability } from "../../../building/api/items.js";
|
|
5
|
-
import { checkStimulusShareability } from "../../../building/api/stimuli.js";
|
|
6
4
|
import AddToBankModal from "./presenter.js";
|
|
7
5
|
import * as modalActions from "../../../common/actions/modal.js";
|
|
8
6
|
import { disassociateEntry } from "../../../common/actions/banks.js";
|
|
@@ -11,8 +9,6 @@ import { ADD_TO_BANK_MODAL } from '@instructure/quiz-common';
|
|
|
11
9
|
import { getModalTrigger } from "../../../common/util/modalHelpers.js";
|
|
12
10
|
export function mapStateToProps(state, props) {
|
|
13
11
|
return {
|
|
14
|
-
canvasOrigin: state.getIn(['config', 'canvasOrigin']),
|
|
15
|
-
checkContentShareability: props.entryType === 'Item' ? checkItemShareability : checkStimulusShareability,
|
|
16
12
|
modalTrigger: getModalTrigger(state),
|
|
17
13
|
modalOpen: state.getIn(['modal', 'isOpen']) === [ADD_TO_BANK_MODAL, props.entryType, props.entryId].join(':')
|
|
18
14
|
};
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
1
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
2
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
5
|
import React, { Component } from 'react';
|
|
8
6
|
import PropTypes from 'prop-types';
|
|
9
|
-
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
10
7
|
import { Button, CloseButton } from '@instructure/ui-buttons';
|
|
11
8
|
import { Heading } from '@instructure/ui-heading';
|
|
12
9
|
import { TextInput } from '@instructure/ui-text-input';
|
|
@@ -14,24 +11,10 @@ import { RadioInputGroup, RadioInput } from '@instructure/ui-radio-input';
|
|
|
14
11
|
import { ScreenReaderContent } from '@instructure/ui-a11y-content';
|
|
15
12
|
import Bank from "../../../common/records/Bank.js";
|
|
16
13
|
import BankSelection from "../../../common/components/resources/BankSelection/presenter.js";
|
|
17
|
-
import { Spinner } from '@instructure/ui-spinner';
|
|
18
|
-
import { Text } from '@instructure/ui-text';
|
|
19
|
-
import { IconNoLine, IconWarningLine } from '@instructure/ui-icons';
|
|
20
|
-
import { View } from '@instructure/ui-view';
|
|
21
|
-
import { Flex } from '@instructure/ui-flex';
|
|
22
14
|
import t from '@instructure/quiz-i18n/es/format-message';
|
|
23
15
|
import { Modal, ModalHeader, ModalBody, ModalFooter, XSMALL_SIDE_MARGIN } from '@instructure/quiz-common';
|
|
24
16
|
import { featureOn } from "../../../common/util/featureCheck.js";
|
|
25
|
-
var
|
|
26
|
-
padding: "0 small 0 0"
|
|
27
|
-
}, /*#__PURE__*/React.createElement(IconNoLine, {
|
|
28
|
-
color: "error",
|
|
29
|
-
size: "small"
|
|
30
|
-
}));
|
|
31
|
-
var _ref3 = /*#__PURE__*/React.createElement(IconWarningLine, {
|
|
32
|
-
color: "warning"
|
|
33
|
-
});
|
|
34
|
-
var _ref4 = /*#__PURE__*/React.createElement("br", null);
|
|
17
|
+
var _ref = /*#__PURE__*/React.createElement("br", null);
|
|
35
18
|
export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
36
19
|
_inherits(AddToBankModal, _Component);
|
|
37
20
|
var _super = _createSuper(AddToBankModal);
|
|
@@ -44,7 +27,6 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
44
27
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
45
28
|
_this.state = {
|
|
46
29
|
bankType: 'existing',
|
|
47
|
-
contentShareable: 'loading',
|
|
48
30
|
newBankTitle: '',
|
|
49
31
|
selectedBank: null
|
|
50
32
|
};
|
|
@@ -105,57 +87,6 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
105
87
|
return _this;
|
|
106
88
|
}
|
|
107
89
|
_createClass(AddToBankModal, [{
|
|
108
|
-
key: "componentDidUpdate",
|
|
109
|
-
value: function componentDidUpdate(prevProps) {
|
|
110
|
-
var _this2 = this;
|
|
111
|
-
var _this$props = this.props,
|
|
112
|
-
canvasOrigin = _this$props.canvasOrigin,
|
|
113
|
-
modalOpen = _this$props.modalOpen,
|
|
114
|
-
checkContentShareability = _this$props.checkContentShareability,
|
|
115
|
-
workingEntry = _this$props.workingEntry;
|
|
116
|
-
if (modalOpen && !prevProps.modalOpen) {
|
|
117
|
-
this.setState({
|
|
118
|
-
contentShareable: 'loading'
|
|
119
|
-
});
|
|
120
|
-
checkContentShareability(workingEntry, canvasOrigin).then(function () {
|
|
121
|
-
_this2.setState({
|
|
122
|
-
contentShareable: 'true'
|
|
123
|
-
});
|
|
124
|
-
}).catch(/*#__PURE__*/function () {
|
|
125
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(err) {
|
|
126
|
-
var _err$response, _err$response2;
|
|
127
|
-
var body;
|
|
128
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
129
|
-
while (1) {
|
|
130
|
-
switch (_context.prev = _context.next) {
|
|
131
|
-
case 0:
|
|
132
|
-
_context.next = 2;
|
|
133
|
-
return (_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.json();
|
|
134
|
-
case 2:
|
|
135
|
-
body = _context.sent;
|
|
136
|
-
if (((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.status) === 400 && body.shareable === false) {
|
|
137
|
-
_this2.setState({
|
|
138
|
-
contentShareable: 'false'
|
|
139
|
-
});
|
|
140
|
-
} else {
|
|
141
|
-
_this2.setState({
|
|
142
|
-
contentShareable: 'unknown'
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
case 4:
|
|
146
|
-
case "end":
|
|
147
|
-
return _context.stop();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}, _callee);
|
|
151
|
-
}));
|
|
152
|
-
return function (_x) {
|
|
153
|
-
return _ref.apply(this, arguments);
|
|
154
|
-
};
|
|
155
|
-
}());
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}, {
|
|
159
90
|
key: "cancelButton",
|
|
160
91
|
value: function cancelButton() {
|
|
161
92
|
return /*#__PURE__*/React.createElement(Button, {
|
|
@@ -168,10 +99,8 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
168
99
|
value: function addToBankButton() {
|
|
169
100
|
var _this$state = this.state,
|
|
170
101
|
bankType = _this$state.bankType,
|
|
171
|
-
newBankTitle = _this$state.newBankTitle
|
|
172
|
-
|
|
173
|
-
var contentShareableLoading = contentShareable === 'loading';
|
|
174
|
-
var disabled = bankType === 'existing' && !this.state.selectedBank || bankType === 'new' && (!newBankTitle || !newBankTitle.trim()) || contentShareableLoading;
|
|
102
|
+
newBankTitle = _this$state.newBankTitle;
|
|
103
|
+
var disabled = bankType === 'existing' && !this.state.selectedBank || bankType === 'new' && (!newBankTitle || !newBankTitle.trim());
|
|
175
104
|
return /*#__PURE__*/React.createElement(Button, {
|
|
176
105
|
type: "button",
|
|
177
106
|
color: "primary",
|
|
@@ -179,7 +108,7 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
179
108
|
disabled: disabled,
|
|
180
109
|
margin: XSMALL_SIDE_MARGIN,
|
|
181
110
|
"data-automation": "sdk-add-to-bank-button"
|
|
182
|
-
},
|
|
111
|
+
}, t('Add'));
|
|
183
112
|
}
|
|
184
113
|
}, {
|
|
185
114
|
key: "renderBankTypeContent",
|
|
@@ -198,35 +127,6 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
198
127
|
type: "text"
|
|
199
128
|
});
|
|
200
129
|
}
|
|
201
|
-
}, {
|
|
202
|
-
key: "renderContentShareabilityMessage",
|
|
203
|
-
value: function renderContentShareabilityMessage() {
|
|
204
|
-
var content = null;
|
|
205
|
-
if (this.state.contentShareable === 'loading') {
|
|
206
|
-
content = /*#__PURE__*/React.createElement(Text, null, /*#__PURE__*/React.createElement(Spinner, {
|
|
207
|
-
size: "x-small",
|
|
208
|
-
renderTitle: t('Checking content shareability...')
|
|
209
|
-
}), "\xA0", t('Validating content...'));
|
|
210
|
-
} else if (this.state.contentShareable === 'true') {
|
|
211
|
-
// No message needed. The API call to check shareability is very fast in most cases,
|
|
212
|
-
// so the user may be distracted by a message here.
|
|
213
|
-
content = null;
|
|
214
|
-
} else if (this.state.contentShareable === 'false') {
|
|
215
|
-
content = /*#__PURE__*/React.createElement(Flex, null, _ref2, /*#__PURE__*/React.createElement(Flex.Item, {
|
|
216
|
-
shouldShrink: true
|
|
217
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
218
|
-
color: "danger"
|
|
219
|
-
}, t('You are attempting to add content containing course links which may not work when used in other courses.'))));
|
|
220
|
-
} else {
|
|
221
|
-
content = /*#__PURE__*/React.createElement(Text, {
|
|
222
|
-
color: "warning"
|
|
223
|
-
}, _ref3, "\xA0", t('There was an error attempting to validate shareability.'));
|
|
224
|
-
}
|
|
225
|
-
return /*#__PURE__*/React.createElement(View, {
|
|
226
|
-
as: "div",
|
|
227
|
-
margin: "small 0 0 0"
|
|
228
|
-
}, content);
|
|
229
|
-
}
|
|
230
130
|
}, {
|
|
231
131
|
key: "renderContent",
|
|
232
132
|
value: function renderContent() {
|
|
@@ -241,7 +141,7 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
241
141
|
}), /*#__PURE__*/React.createElement(RadioInput, {
|
|
242
142
|
value: "new",
|
|
243
143
|
label: t('New item bank')
|
|
244
|
-
})),
|
|
144
|
+
})), _ref, this.renderBankTypeContent());
|
|
245
145
|
}
|
|
246
146
|
}, {
|
|
247
147
|
key: "render",
|
|
@@ -267,8 +167,6 @@ export var AddToBankModal = /*#__PURE__*/function (_Component) {
|
|
|
267
167
|
return AddToBankModal;
|
|
268
168
|
}(Component);
|
|
269
169
|
AddToBankModal.propTypes = {
|
|
270
|
-
canvasOrigin: PropTypes.string,
|
|
271
|
-
checkContentShareability: PropTypes.func.isRequired,
|
|
272
170
|
closeModal: PropTypes.func.isRequired,
|
|
273
171
|
createBank: PropTypes.func.isRequired,
|
|
274
172
|
moveBankEntryFromQuizEntry: PropTypes.func.isRequired,
|
|
@@ -287,11 +185,9 @@ AddToBankModal.propTypes = {
|
|
|
287
185
|
onAdd: PropTypes.func,
|
|
288
186
|
onContinue: PropTypes.func,
|
|
289
187
|
uiSet: PropTypes.func.isRequired,
|
|
290
|
-
workingEntry: ImmutablePropTypes.record.isRequired,
|
|
291
188
|
quizId: PropTypes.string.isRequired
|
|
292
189
|
};
|
|
293
190
|
AddToBankModal.defaultProps = {
|
|
294
|
-
canvasOrigin: '',
|
|
295
191
|
handleValidationErrorsFromApi: function handleValidationErrorsFromApi() {},
|
|
296
192
|
onAdd: function onAdd() {},
|
|
297
193
|
onContinue: function onContinue() {}
|
|
@@ -148,14 +148,12 @@ export var BankEntry = (_dec = withStyleOverrides(generateStyle, generateCompone
|
|
|
148
148
|
clearChanges: _this.clearChanges,
|
|
149
149
|
clearValidationErrorsFromApi: _this.clearValidationErrorsFromApi,
|
|
150
150
|
contextUuid: null,
|
|
151
|
-
disableSubmit: Boolean(_this.state.validationErrorsFromApi && Object.values(_this.state.validationErrorsFromApi).length),
|
|
152
151
|
entry: entry,
|
|
153
152
|
guid: "".concat(_this.props.bankEntry.id, "_bank_entry_edit"),
|
|
154
153
|
handleQuizEntryPointsChange: _this.handlePointsChange,
|
|
155
154
|
itemEditArea: _this.itemEditArea,
|
|
156
155
|
parentId: _this.props.bankId,
|
|
157
156
|
parentType: PARENT_TYPE_BANK,
|
|
158
|
-
shouldValidateShareableContent: true,
|
|
159
157
|
stimulus: entry,
|
|
160
158
|
submitHandler: _this.submitHandler,
|
|
161
159
|
validationErrorsFromApi: _this.state.validationErrorsFromApi,
|
package/es/building/api/items.js
CHANGED
|
@@ -34,19 +34,6 @@ export function getItem(itemId) {
|
|
|
34
34
|
});
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
export function checkItemShareability(item, canvasOrigin) {
|
|
38
|
-
var url = '/api/items/check_shareability';
|
|
39
|
-
var requestBody = JSON.stringify({
|
|
40
|
-
item: updateItemParams(item),
|
|
41
|
-
source_origin: canvasOrigin
|
|
42
|
-
});
|
|
43
|
-
var fetcher = new Fetcher({
|
|
44
|
-
onError: function onError() {}
|
|
45
|
-
});
|
|
46
|
-
return fetcher.post(url, {
|
|
47
|
-
body: requestBody
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
37
|
export function createItem(item, parentId, parentType) {
|
|
51
38
|
var parentItemId = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
|
52
39
|
var resource = parentType === 'bank' ? 'banks' : 'quizzes';
|
|
@@ -79,17 +79,4 @@ export function updateStimulus(stimulus, parentId, parentType) {
|
|
|
79
79
|
return stimulusData;
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
|
-
}
|
|
83
|
-
export function checkStimulusShareability(stimulus, canvasOrigin) {
|
|
84
|
-
var url = '/api/stimuli/check_shareability';
|
|
85
|
-
var requestBody = JSON.stringify({
|
|
86
|
-
stimulus: updateStimulusParams(stimulus),
|
|
87
|
-
source_origin: canvasOrigin
|
|
88
|
-
});
|
|
89
|
-
var fetcher = new Fetcher({
|
|
90
|
-
onError: function onError() {}
|
|
91
|
-
});
|
|
92
|
-
return fetcher.post(url, {
|
|
93
|
-
body: requestBody
|
|
94
|
-
});
|
|
95
82
|
}
|
|
@@ -325,7 +325,6 @@ var QuizEntryEdit = (_dec = withStyleOverrides(generateStyle, generateComponentT
|
|
|
325
325
|
onContinue: this.handleAddToBankContinue,
|
|
326
326
|
onAdd: this.handleAddToBank,
|
|
327
327
|
getEntry: this.getEntryForBank,
|
|
328
|
-
workingEntry: this.props.workingEntry,
|
|
329
328
|
entryId: this.props.guid,
|
|
330
329
|
entryType: this.props.quizEntry.entryType,
|
|
331
330
|
quizId: this.props.quizId,
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { connect } from "../../../../react-redux.js";
|
|
2
|
-
import { checkItemShareability } from "../../../../../building/api/items.js";
|
|
3
|
-
import { checkStimulusShareability } from "../../../../../building/api/stimuli.js";
|
|
4
2
|
import makeEditable from "../../../shared/functionality/makeEditable.js";
|
|
5
3
|
import { showError, hideError } from "../../../../actions/errorsShowing.js";
|
|
6
4
|
import { screenreaderNotification } from "../../../../actions/alerts.js";
|
|
7
5
|
import { clearNextQuizEntry } from "../../../../actions/modifications.js";
|
|
8
|
-
import { withConfirm } from "../../../../actions/modal.js";
|
|
9
6
|
import EntrySave from "./presenter.js";
|
|
10
7
|
export function mapStateToProps(state, props) {
|
|
11
8
|
// Error Related:
|
|
12
9
|
var workingEntry = props.entry.getWorkingInstance();
|
|
13
10
|
var isValid = props.isValid !== void 0 ? props.isValid : workingEntry.isValid();
|
|
14
11
|
return {
|
|
15
|
-
canvasOrigin: state.getIn(['config', 'canvasOrigin']),
|
|
16
|
-
checkContentShareability: props.entry.isStimulus ? checkStimulusShareability : checkItemShareability,
|
|
17
12
|
isValid: isValid
|
|
18
13
|
};
|
|
19
14
|
}
|
|
@@ -21,7 +16,6 @@ var mapDispatchToProps = {
|
|
|
21
16
|
clearNextQuizEntry: clearNextQuizEntry,
|
|
22
17
|
hideError: hideError,
|
|
23
18
|
screenreaderNotification: screenreaderNotification,
|
|
24
|
-
showError: showError
|
|
25
|
-
withConfirm: withConfirm
|
|
19
|
+
showError: showError
|
|
26
20
|
};
|
|
27
21
|
export default makeEditable(connect(mapStateToProps, mapDispatchToProps)(EntrySave));
|
|
@@ -6,7 +6,6 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
6
6
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
7
|
import React, { Component } from 'react';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
|
-
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
10
9
|
import ReactDOM from 'react-dom';
|
|
11
10
|
import { Button } from '@instructure/ui-buttons';
|
|
12
11
|
import { View } from '@instructure/ui-view';
|
|
@@ -33,91 +32,36 @@ export var EntrySave = /*#__PURE__*/function (_Component) {
|
|
|
33
32
|
});
|
|
34
33
|
_this.props.screenreaderNotification(msg);
|
|
35
34
|
};
|
|
36
|
-
_this.confirmShareableContent = function () {
|
|
37
|
-
var _this$props = _this.props,
|
|
38
|
-
canvasOrigin = _this$props.canvasOrigin,
|
|
39
|
-
checkContentShareability = _this$props.checkContentShareability,
|
|
40
|
-
entry = _this$props.entry,
|
|
41
|
-
withConfirm = _this$props.withConfirm;
|
|
42
|
-
_this.setState({
|
|
43
|
-
canSubmit: false
|
|
44
|
-
});
|
|
45
|
-
checkContentShareability(entry.getWorkingInstance(), canvasOrigin).then(function () {
|
|
46
|
-
_this.successfulSubmit();
|
|
47
|
-
}).catch(/*#__PURE__*/function () {
|
|
48
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(err) {
|
|
49
|
-
var _err$response, _err$response2;
|
|
50
|
-
var body, text;
|
|
51
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
52
|
-
while (1) {
|
|
53
|
-
switch (_context.prev = _context.next) {
|
|
54
|
-
case 0:
|
|
55
|
-
_context.next = 2;
|
|
56
|
-
return (_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.json();
|
|
57
|
-
case 2:
|
|
58
|
-
body = _context.sent;
|
|
59
|
-
text = t('There was an error attempting to validate shareability.');
|
|
60
|
-
if (((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.status) === 400 && body.shareable === false) {
|
|
61
|
-
text = t('You are attempting to save content containing course links which may not work when used in other courses.');
|
|
62
|
-
}
|
|
63
|
-
withConfirm(function () {
|
|
64
|
-
_this.successfulSubmit();
|
|
65
|
-
}, {
|
|
66
|
-
title: t('Are you sure?'),
|
|
67
|
-
text: text,
|
|
68
|
-
continueText: t('Save anyway'),
|
|
69
|
-
onCancel: function onCancel() {
|
|
70
|
-
_this.setState({
|
|
71
|
-
canSubmit: true
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
case 6:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}, _callee);
|
|
81
|
-
}));
|
|
82
|
-
return function (_x) {
|
|
83
|
-
return _ref.apply(this, arguments);
|
|
84
|
-
};
|
|
85
|
-
}());
|
|
86
|
-
};
|
|
87
35
|
_this.onSubmit = /*#__PURE__*/function () {
|
|
88
|
-
var
|
|
89
|
-
return _regeneratorRuntime.wrap(function
|
|
36
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(e) {
|
|
37
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
90
38
|
while (1) {
|
|
91
|
-
switch (
|
|
39
|
+
switch (_context.prev = _context.next) {
|
|
92
40
|
case 0:
|
|
93
41
|
e.preventDefault();
|
|
94
42
|
if (!_this.props.isValid) {
|
|
95
|
-
|
|
43
|
+
_context.next = 5;
|
|
96
44
|
break;
|
|
97
45
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
} else {
|
|
101
|
-
_this.successfulSubmit();
|
|
102
|
-
}
|
|
103
|
-
_context2.next = 10;
|
|
46
|
+
_this.successfulSubmit();
|
|
47
|
+
_context.next = 10;
|
|
104
48
|
break;
|
|
105
49
|
case 5:
|
|
106
50
|
_this.createScreenReaderNotification();
|
|
107
|
-
|
|
51
|
+
_context.next = 8;
|
|
108
52
|
return _this.props.showError(_this.props.guid);
|
|
109
53
|
case 8:
|
|
110
54
|
_this.props.clearNextQuizEntry();
|
|
111
55
|
_this.focusFirstErrorField();
|
|
112
56
|
case 10:
|
|
113
57
|
case "end":
|
|
114
|
-
return
|
|
58
|
+
return _context.stop();
|
|
115
59
|
}
|
|
116
60
|
}
|
|
117
|
-
},
|
|
61
|
+
}, _callee);
|
|
118
62
|
}));
|
|
119
|
-
return function (
|
|
120
|
-
return
|
|
63
|
+
return function (_x) {
|
|
64
|
+
return _ref.apply(this, arguments);
|
|
121
65
|
};
|
|
122
66
|
}();
|
|
123
67
|
_this.focusFirstErrorField = function () {
|
|
@@ -155,46 +99,46 @@ export var EntrySave = /*#__PURE__*/function (_Component) {
|
|
|
155
99
|
}, {
|
|
156
100
|
key: "successfulSubmit",
|
|
157
101
|
value: function () {
|
|
158
|
-
var _successfulSubmit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
102
|
+
var _successfulSubmit = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
159
103
|
var validationResult;
|
|
160
|
-
return _regeneratorRuntime.wrap(function
|
|
104
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
161
105
|
while (1) {
|
|
162
|
-
switch (
|
|
106
|
+
switch (_context2.prev = _context2.next) {
|
|
163
107
|
case 0:
|
|
164
108
|
this.setState({
|
|
165
109
|
canSubmit: false
|
|
166
110
|
});
|
|
167
|
-
|
|
168
|
-
|
|
111
|
+
_context2.prev = 1;
|
|
112
|
+
_context2.next = 4;
|
|
169
113
|
return this.props.submitHandler();
|
|
170
114
|
case 4:
|
|
171
|
-
validationResult =
|
|
115
|
+
validationResult = _context2.sent;
|
|
172
116
|
if (!(validationResult === API_INPUT_VALIDATION_ERROR)) {
|
|
173
|
-
|
|
117
|
+
_context2.next = 8;
|
|
174
118
|
break;
|
|
175
119
|
}
|
|
176
120
|
this.createScreenReaderNotification();
|
|
177
121
|
throw new Error('User input validation error received from API.');
|
|
178
122
|
case 8:
|
|
179
|
-
|
|
123
|
+
_context2.next = 14;
|
|
180
124
|
break;
|
|
181
125
|
case 10:
|
|
182
|
-
|
|
183
|
-
|
|
126
|
+
_context2.prev = 10;
|
|
127
|
+
_context2.t0 = _context2["catch"](1);
|
|
184
128
|
this.setState({
|
|
185
129
|
canSubmit: true
|
|
186
130
|
});
|
|
187
|
-
return
|
|
131
|
+
return _context2.abrupt("return");
|
|
188
132
|
case 14:
|
|
189
133
|
this.props.switchOffEditing();
|
|
190
134
|
this.props.hideError(this.props.guid);
|
|
191
135
|
this.props.screenreaderNotification(t('Changes to question saved.'));
|
|
192
136
|
case 17:
|
|
193
137
|
case "end":
|
|
194
|
-
return
|
|
138
|
+
return _context2.stop();
|
|
195
139
|
}
|
|
196
140
|
}
|
|
197
|
-
},
|
|
141
|
+
}, _callee2, this, [[1, 10]]);
|
|
198
142
|
}));
|
|
199
143
|
function successfulSubmit() {
|
|
200
144
|
return _successfulSubmit.apply(this, arguments);
|
|
@@ -227,14 +171,11 @@ export var EntrySave = /*#__PURE__*/function (_Component) {
|
|
|
227
171
|
}(Component);
|
|
228
172
|
EntrySave.propTypes = {
|
|
229
173
|
cancelHandler: PropTypes.func,
|
|
230
|
-
canvasOrigin: PropTypes.string,
|
|
231
|
-
checkContentShareability: PropTypes.func.isRequired,
|
|
232
174
|
clearChanges: PropTypes.func.isRequired,
|
|
233
175
|
// From connected component
|
|
234
176
|
clearNextQuizEntry: PropTypes.func.isRequired,
|
|
235
177
|
disableSubmit: PropTypes.bool,
|
|
236
178
|
displayPosition: PropTypes.number,
|
|
237
|
-
entry: ImmutablePropTypes.record.isRequired,
|
|
238
179
|
guid: PropTypes.string,
|
|
239
180
|
hideError: PropTypes.func.isRequired,
|
|
240
181
|
initialFocusId: PropTypes.string,
|
|
@@ -242,21 +183,17 @@ EntrySave.propTypes = {
|
|
|
242
183
|
itemEditArea: PropTypes.object,
|
|
243
184
|
showError: PropTypes.func.isRequired,
|
|
244
185
|
screenreaderNotification: PropTypes.func.isRequired,
|
|
245
|
-
shouldValidateShareableContent: PropTypes.bool,
|
|
246
186
|
submitHandler: PropTypes.func.isRequired,
|
|
247
187
|
// from makescrollable / from props being passed in occasionally
|
|
248
188
|
switchOnEditing: PropTypes.func.isRequired,
|
|
249
|
-
switchOffEditing: PropTypes.func.isRequired
|
|
250
|
-
withConfirm: PropTypes.func.isRequired
|
|
189
|
+
switchOffEditing: PropTypes.func.isRequired
|
|
251
190
|
};
|
|
252
191
|
EntrySave.defaultProps = {
|
|
253
192
|
cancelHandler: noop,
|
|
254
|
-
canvasOrigin: '',
|
|
255
|
-
displayPosition: null,
|
|
256
193
|
disableSubmit: false,
|
|
194
|
+
displayPosition: null,
|
|
257
195
|
guid: null,
|
|
258
196
|
initialFocusId: null,
|
|
259
|
-
itemEditArea: null
|
|
260
|
-
shouldValidateShareableContent: false
|
|
197
|
+
itemEditArea: null
|
|
261
198
|
};
|
|
262
199
|
export default EntrySave;
|
|
@@ -310,7 +310,6 @@ export var StimulusEdit = (_dec = withStyleOverrides(generateStyle, generateComp
|
|
|
310
310
|
onAdd: this.handleAddToBank,
|
|
311
311
|
onContinue: this.handleAddToBankContinue,
|
|
312
312
|
getEntry: this.getEntryForBank,
|
|
313
|
-
workingEntry: this.props.workingStimulus,
|
|
314
313
|
quizId: this.props.quizId,
|
|
315
314
|
entryId: this.props.guid,
|
|
316
315
|
entryType: this.props.quizEntry.entryType
|
|
@@ -10,8 +10,6 @@ exports.default = void 0;
|
|
|
10
10
|
var _reactRedux = require("../../../common/react-redux.js");
|
|
11
11
|
var _banks = require("../../api/banks.js");
|
|
12
12
|
var _bankEntries = require("../../api/bankEntries.js");
|
|
13
|
-
var _items = require("../../../building/api/items.js");
|
|
14
|
-
var _stimuli = require("../../../building/api/stimuli.js");
|
|
15
13
|
var _presenter = _interopRequireDefault(require("./presenter.js"));
|
|
16
14
|
var modalActions = _interopRequireWildcard(require("../../../common/actions/modal.js"));
|
|
17
15
|
var _banks2 = require("../../../common/actions/banks.js");
|
|
@@ -20,8 +18,6 @@ var _quizCommon = require("@instructure/quiz-common");
|
|
|
20
18
|
var _modalHelpers = require("../../../common/util/modalHelpers.js");
|
|
21
19
|
function mapStateToProps(state, props) {
|
|
22
20
|
return {
|
|
23
|
-
canvasOrigin: state.getIn(['config', 'canvasOrigin']),
|
|
24
|
-
checkContentShareability: props.entryType === 'Item' ? _items.checkItemShareability : _stimuli.checkStimulusShareability,
|
|
25
21
|
modalTrigger: (0, _modalHelpers.getModalTrigger)(state),
|
|
26
22
|
modalOpen: state.getIn(['modal', 'isOpen']) === [_quizCommon.ADD_TO_BANK_MODAL, props.entryType, props.entryId].join(':')
|
|
27
23
|
};
|
|
@@ -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
|
}
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/quiz-core",
|
|
3
|
-
"version": "20.35.1-rc.
|
|
3
|
+
"version": "20.35.1-rc.7+bcb836a94",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Quiz React SDK by Instructure Inc.",
|
|
6
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"@instructure/emotion": "^8.56.3",
|
|
47
47
|
"@instructure/grading-utils": "^1.0.0",
|
|
48
48
|
"@instructure/outcomes-ui": "^3.2.2",
|
|
49
|
-
"@instructure/quiz-common": "^20.35.1-rc.
|
|
50
|
-
"@instructure/quiz-i18n": "^20.35.1-rc.
|
|
51
|
-
"@instructure/quiz-interactions": "^20.35.1-rc.
|
|
52
|
-
"@instructure/quiz-number-input": "^20.35.1-rc.
|
|
53
|
-
"@instructure/quiz-rce": "^20.35.1-rc.
|
|
49
|
+
"@instructure/quiz-common": "^20.35.1-rc.7+bcb836a94",
|
|
50
|
+
"@instructure/quiz-i18n": "^20.35.1-rc.7+bcb836a94",
|
|
51
|
+
"@instructure/quiz-interactions": "^20.35.1-rc.7+bcb836a94",
|
|
52
|
+
"@instructure/quiz-number-input": "^20.35.1-rc.7+bcb836a94",
|
|
53
|
+
"@instructure/quiz-rce": "^20.35.1-rc.7+bcb836a94",
|
|
54
54
|
"@instructure/ui-a11y-content": "^8.56.3",
|
|
55
55
|
"@instructure/ui-alerts": "^8.56.3",
|
|
56
56
|
"@instructure/ui-avatar": "^8.56.3",
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"file-saver": "~2.0.5",
|
|
115
115
|
"humps": "^2.0.0",
|
|
116
116
|
"immutable": "^3.8.1",
|
|
117
|
-
"instructure-validations": "^20.35.1-rc.
|
|
117
|
+
"instructure-validations": "^20.35.1-rc.7+bcb836a94",
|
|
118
118
|
"ipaddr.js": "^1.5.4",
|
|
119
119
|
"isomorphic-fetch": "^2.2.0",
|
|
120
120
|
"isuuid": "^0.1.0",
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
"jquery": "^2.2.3",
|
|
164
164
|
"karma-junit-reporter": "^2.0.1",
|
|
165
165
|
"most-subject": "^5.3.0",
|
|
166
|
-
"quiz-presets": "^20.35.1-rc.
|
|
166
|
+
"quiz-presets": "^20.35.1-rc.7+bcb836a94",
|
|
167
167
|
"react": "^16.8.6",
|
|
168
168
|
"react-addons-test-utils": "^15.6.2",
|
|
169
169
|
"react-dom": "^16.8.6",
|
|
@@ -179,5 +179,5 @@
|
|
|
179
179
|
"publishConfig": {
|
|
180
180
|
"access": "public"
|
|
181
181
|
},
|
|
182
|
-
"gitHead": "
|
|
182
|
+
"gitHead": "bcb836a9499e1012f66e72175dc5672b6fe041e7"
|
|
183
183
|
}
|