@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
|
@@ -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
|
}
|
|
@@ -147,6 +147,7 @@ export var QuizEntryEditFooter = (_dec = withStyleOverrides(generateStyle, gener
|
|
|
147
147
|
}, {
|
|
148
148
|
key: "renderPointsSection",
|
|
149
149
|
value: function renderPointsSection() {
|
|
150
|
+
var currentPointsValue = this.state.points;
|
|
150
151
|
return jsx("div", {
|
|
151
152
|
css: this.props.styles.pointsSection
|
|
152
153
|
}, jsx("span", {
|
|
@@ -155,9 +156,10 @@ export var QuizEntryEditFooter = (_dec = withStyleOverrides(generateStyle, gener
|
|
|
155
156
|
renderLabel: jsx(ScreenReaderContent, null, t('Points Possible Input')),
|
|
156
157
|
onChange: this.handlePointsChange,
|
|
157
158
|
onBlur: this.handlePointsBlur,
|
|
158
|
-
value:
|
|
159
|
+
value: currentPointsValue,
|
|
159
160
|
disabled: this.pointsDisabled(),
|
|
160
|
-
"data-automation": "sdk-points-possible-numberinput"
|
|
161
|
+
"data-automation": "sdk-points-possible-numberinput",
|
|
162
|
+
"aria-valuetext": "".concat(currentPointsValue, " ").concat(t('Points'))
|
|
161
163
|
})), jsx(View, {
|
|
162
164
|
margin: "none none none x-small"
|
|
163
165
|
}, jsx(Text, {
|
|
@@ -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,
|
|
@@ -17,7 +17,16 @@ var generateStyle = function generateStyle(componentTheme, props) {
|
|
|
17
17
|
overflowY: 'auto'
|
|
18
18
|
}), {}, {
|
|
19
19
|
transition: componentTheme.contentTransition,
|
|
20
|
-
width: '100%'
|
|
20
|
+
width: '100%',
|
|
21
|
+
'.user_content p': {
|
|
22
|
+
margin: componentTheme.userContentMargin,
|
|
23
|
+
'&:first-of-type': {
|
|
24
|
+
marginTop: componentTheme.userContentZeroMargin
|
|
25
|
+
},
|
|
26
|
+
'&:last-child': {
|
|
27
|
+
marginBottom: componentTheme.userContentZeroMargin
|
|
28
|
+
}
|
|
29
|
+
}
|
|
21
30
|
})
|
|
22
31
|
};
|
|
23
32
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
2
2
|
var typography = _ref.typography,
|
|
3
3
|
breakpoints = _ref.breakpoints,
|
|
4
|
-
transitions = _ref.transitions
|
|
4
|
+
transitions = _ref.transitions,
|
|
5
|
+
spacing = _ref.spacing;
|
|
5
6
|
return {
|
|
6
7
|
fontFamily: typography.fontFamily,
|
|
7
|
-
contentTransition: "transform ".concat(transitions.duration)
|
|
8
|
+
contentTransition: "transform ".concat(transitions.duration),
|
|
9
|
+
userContentMargin: spacing.mediumSmall,
|
|
10
|
+
userContentZeroMargin: 0
|
|
8
11
|
};
|
|
9
12
|
};
|
|
10
13
|
export default generateComponentTheme;
|
|
@@ -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;
|
|
@@ -10,6 +10,15 @@ var generateStyle = function generateStyle(componentTheme) {
|
|
|
10
10
|
clear: 'both',
|
|
11
11
|
content: '""',
|
|
12
12
|
display: 'table'
|
|
13
|
+
},
|
|
14
|
+
'.user_content p': {
|
|
15
|
+
margin: componentTheme.userContentMargin,
|
|
16
|
+
'&:first-of-type': {
|
|
17
|
+
marginTop: componentTheme.userContentZeroMargin
|
|
18
|
+
},
|
|
19
|
+
'&:last-child': {
|
|
20
|
+
marginBottom: componentTheme.userContentMargin
|
|
21
|
+
}
|
|
13
22
|
}
|
|
14
23
|
},
|
|
15
24
|
text: {
|
|
@@ -3,7 +3,9 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
3
3
|
typography = _ref.typography;
|
|
4
4
|
return {
|
|
5
5
|
wrapperPadding: spacing.large,
|
|
6
|
-
textFontSize: typography.fontSizeMedium
|
|
6
|
+
textFontSize: typography.fontSizeMedium,
|
|
7
|
+
userContentMargin: spacing.mediumSmall,
|
|
8
|
+
userContentZeroMargin: 0
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
11
|
export default generateComponentTheme;
|
|
@@ -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
|
};
|