@instructure/quiz-core 20.17.0 → 20.17.1-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/BankEntry/presenter.js +7 -1
- package/es/building/components/resources/AddToBankOptions/index.js +42 -15
- package/es/building/components/resources/quizEntry/QuizEntry/presenter.js +10 -0
- package/es/common/components/resources/stimulus/StimulusEdit/presenter.js +1 -0
- package/lib/banks/components/BankEntry/presenter.js +7 -1
- package/lib/building/components/resources/AddToBankOptions/index.js +48 -19
- package/lib/building/components/resources/quizEntry/QuizEntry/presenter.js +12 -0
- package/lib/common/components/resources/stimulus/StimulusEdit/presenter.js +1 -0
- package/package.json +10 -10
|
@@ -155,6 +155,10 @@ export var BankEntry = (_dec = withStyle(generateStyle, generateComponentTheme),
|
|
|
155
155
|
}, _callee, null, [[0, 10]]);
|
|
156
156
|
}));
|
|
157
157
|
|
|
158
|
+
_this.handleRef = function (node) {
|
|
159
|
+
_this.itemEditArea = node;
|
|
160
|
+
};
|
|
161
|
+
|
|
158
162
|
_this.clearChanges = function () {
|
|
159
163
|
_this.clearValidationErrorsFromApi(CLEAR_ALL_INPUT_VALIDATION_ERRORS);
|
|
160
164
|
|
|
@@ -185,6 +189,7 @@ export var BankEntry = (_dec = withStyle(generateStyle, generateComponentTheme),
|
|
|
185
189
|
entry: entry,
|
|
186
190
|
guid: "".concat(_this.props.bankEntry.id, "_bank_entry_edit"),
|
|
187
191
|
handleQuizEntryPointsChange: _this.handlePointsChange,
|
|
192
|
+
itemEditArea: _this.itemEditArea,
|
|
188
193
|
parentId: _this.props.bankId,
|
|
189
194
|
parentType: PARENT_TYPE_BANK,
|
|
190
195
|
shouldValidateShareableContent: true,
|
|
@@ -643,7 +648,8 @@ export var BankEntry = (_dec = withStyle(generateStyle, generateComponentTheme),
|
|
|
643
648
|
}
|
|
644
649
|
|
|
645
650
|
return jsx(Page, null, this.renderNav(), jsx("div", {
|
|
646
|
-
css: this.props.styles.content
|
|
651
|
+
css: this.props.styles.content,
|
|
652
|
+
ref: this.handleRef
|
|
647
653
|
}, this.props.iceTopNavBarEnabled && jsx("div", {
|
|
648
654
|
css: this.props.styles.breadcrumb
|
|
649
655
|
}, jsx(HeaderBreadCrumb, {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
1
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
5
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
@@ -30,25 +32,47 @@ export var AddToBankOptions = (_dec = withStyle(generateStyle, generateComponent
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
35
|
+
_this.openAddToBankModal = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
36
|
+
var displayPosition, msg;
|
|
37
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
38
|
+
while (1) {
|
|
39
|
+
switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
displayPosition = _this.props.displayPosition;
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
if (!_this.props.isValid) {
|
|
44
|
+
_context.next = 5;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
} else {
|
|
42
|
-
var msg = t('{entryType} {displayPosition, number} cannot be saved due to invalid input data.', {
|
|
43
|
-
entryType: _this.props.entryType,
|
|
44
|
-
displayPosition: displayPosition
|
|
45
|
-
});
|
|
48
|
+
_this.props.openModal([ADD_TO_BANK_MODAL, _this.props.entryType, _this.props.guid].join(':'), {
|
|
49
|
+
modalTrigger: _this.addToBankLink
|
|
50
|
+
});
|
|
46
51
|
|
|
47
|
-
|
|
52
|
+
_context.next = 10;
|
|
53
|
+
break;
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
case 5:
|
|
56
|
+
msg = t('{entryType} {displayPosition, number} cannot be saved due to invalid input data.', {
|
|
57
|
+
entryType: _this.props.entryType,
|
|
58
|
+
displayPosition: displayPosition
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
_this.props.screenreaderNotification(msg);
|
|
62
|
+
|
|
63
|
+
_context.next = 9;
|
|
64
|
+
return _this.props.showError(_this.props.guid);
|
|
65
|
+
|
|
66
|
+
case 9:
|
|
67
|
+
_this.props.focusFirstErrorField();
|
|
68
|
+
|
|
69
|
+
case 10:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, _callee);
|
|
75
|
+
}));
|
|
52
76
|
|
|
53
77
|
_this.storeAddToBankLinkRef = function (c) {
|
|
54
78
|
_this.addToBankLink = c;
|
|
@@ -78,11 +102,14 @@ export var AddToBankOptions = (_dec = withStyle(generateStyle, generateComponent
|
|
|
78
102
|
}(Component), _class2.propTypes = {
|
|
79
103
|
displayPosition: PropTypes.number.isRequired,
|
|
80
104
|
entryType: PropTypes.string.isRequired,
|
|
105
|
+
focusFirstErrorField: PropTypes.func,
|
|
81
106
|
guid: PropTypes.string.isRequired,
|
|
82
107
|
isValid: PropTypes.bool.isRequired,
|
|
83
108
|
openModal: PropTypes.func.isRequired,
|
|
84
109
|
screenreaderNotification: PropTypes.func.isRequired,
|
|
85
110
|
showError: PropTypes.func.isRequired,
|
|
86
111
|
styles: PropTypes.object
|
|
112
|
+
}, _class2.defaultProps = {
|
|
113
|
+
focusFirstErrorField: function focusFirstErrorField() {}
|
|
87
114
|
}, _temp)) || _class);
|
|
88
115
|
export default AddToBankOptions;
|
|
@@ -14,6 +14,7 @@ import { List } from 'immutable';
|
|
|
14
14
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
15
15
|
import pick from 'lodash/pick';
|
|
16
16
|
import partial from 'lodash/partial';
|
|
17
|
+
import ReactDOM from 'react-dom';
|
|
17
18
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
18
19
|
import t from '@instructure/quiz-i18n/es/format-message';
|
|
19
20
|
import WarningWrapper from "../../../../../common/components/resources/WarningWrapper/index.js";
|
|
@@ -63,6 +64,7 @@ export var QuizEntry = (_dec = withStyle(generateStyle, generateComponentTheme),
|
|
|
63
64
|
return jsx(AddToBankOptions, {
|
|
64
65
|
displayPosition: _this.props.displayPosition,
|
|
65
66
|
entryType: _this.props.quizEntry.entryType,
|
|
67
|
+
focusFirstErrorField: _this.focusFirstErrorField,
|
|
66
68
|
guid: _this.props.guid,
|
|
67
69
|
isValid: _this.props.workingEntry.isValid(),
|
|
68
70
|
openModal: _this.props.openModal,
|
|
@@ -84,6 +86,14 @@ export var QuizEntry = (_dec = withStyle(generateStyle, generateComponentTheme),
|
|
|
84
86
|
_this.itemEditArea = node;
|
|
85
87
|
};
|
|
86
88
|
|
|
89
|
+
_this.focusFirstErrorField = function () {
|
|
90
|
+
if (_this.itemEditArea) {
|
|
91
|
+
var editArea = ReactDOM.findDOMNode(_this.itemEditArea);
|
|
92
|
+
var firstErrorField = editArea === null || editArea === void 0 ? void 0 : editArea.querySelector('[aria-invalid="true"]');
|
|
93
|
+
firstErrorField && firstErrorField.focus();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
87
97
|
_this.renderPrintableItemBankSample = function (sampleItem, index) {
|
|
88
98
|
var quizEntry = QuizEntryRecord.create(sampleItem.toObject());
|
|
89
99
|
var entryMutable = quizEntry.entry.toJS();
|
|
@@ -381,6 +381,7 @@ export var StimulusEdit = (_dec = withStyle(generateStyle, generateComponentThem
|
|
|
381
381
|
}, jsx(AddToBankOptions, {
|
|
382
382
|
displayPosition: this.props.displayPosition,
|
|
383
383
|
entryType: this.props.quizEntry.entryType,
|
|
384
|
+
focusFirstErrorField: this.focusFirstErrorField,
|
|
384
385
|
guid: this.props.guid,
|
|
385
386
|
isValid: this.props.workingStimulus.isValid(),
|
|
386
387
|
openModal: this.props.openModal,
|
|
@@ -205,6 +205,10 @@ var BankEntry = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
|
|
|
205
205
|
}, _callee, null, [[0, 10]]);
|
|
206
206
|
}));
|
|
207
207
|
|
|
208
|
+
_this.handleRef = function (node) {
|
|
209
|
+
_this.itemEditArea = node;
|
|
210
|
+
};
|
|
211
|
+
|
|
208
212
|
_this.clearChanges = function () {
|
|
209
213
|
_this.clearValidationErrorsFromApi(_quizCommon.CLEAR_ALL_INPUT_VALIDATION_ERRORS);
|
|
210
214
|
|
|
@@ -235,6 +239,7 @@ var BankEntry = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
|
|
|
235
239
|
entry: entry,
|
|
236
240
|
guid: "".concat(_this.props.bankEntry.id, "_bank_entry_edit"),
|
|
237
241
|
handleQuizEntryPointsChange: _this.handlePointsChange,
|
|
242
|
+
itemEditArea: _this.itemEditArea,
|
|
238
243
|
parentId: _this.props.bankId,
|
|
239
244
|
parentType: _quizCommon.PARENT_TYPE_BANK,
|
|
240
245
|
shouldValidateShareableContent: true,
|
|
@@ -693,7 +698,8 @@ var BankEntry = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
|
|
|
693
698
|
}
|
|
694
699
|
|
|
695
700
|
return (0, _emotion.jsx)(_index6.default, null, this.renderNav(), (0, _emotion.jsx)("div", {
|
|
696
|
-
css: this.props.styles.content
|
|
701
|
+
css: this.props.styles.content,
|
|
702
|
+
ref: this.handleRef
|
|
697
703
|
}, this.props.iceTopNavBarEnabled && (0, _emotion.jsx)("div", {
|
|
698
704
|
css: this.props.styles.breadcrumb
|
|
699
705
|
}, (0, _emotion.jsx)(_index.HeaderBreadCrumb, {
|
|
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = exports.AddToBankOptions = void 0;
|
|
9
9
|
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
10
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
15
|
|
|
12
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -50,25 +54,47 @@ var AddToBankOptions = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.d
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
_this.openAddToBankModal = /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
58
|
+
var displayPosition, msg;
|
|
59
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
60
|
+
while (1) {
|
|
61
|
+
switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
displayPosition = _this.props.displayPosition;
|
|
64
|
+
|
|
65
|
+
if (!_this.props.isValid) {
|
|
66
|
+
_context.next = 5;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_this.props.openModal([_quizCommon.ADD_TO_BANK_MODAL, _this.props.entryType, _this.props.guid].join(':'), {
|
|
71
|
+
modalTrigger: _this.addToBankLink
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
_context.next = 10;
|
|
75
|
+
break;
|
|
76
|
+
|
|
77
|
+
case 5:
|
|
78
|
+
msg = (0, _formatMessage.default)('{entryType} {displayPosition, number} cannot be saved due to invalid input data.', {
|
|
79
|
+
entryType: _this.props.entryType,
|
|
80
|
+
displayPosition: displayPosition
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
_this.props.screenreaderNotification(msg);
|
|
84
|
+
|
|
85
|
+
_context.next = 9;
|
|
86
|
+
return _this.props.showError(_this.props.guid);
|
|
87
|
+
|
|
88
|
+
case 9:
|
|
89
|
+
_this.props.focusFirstErrorField();
|
|
90
|
+
|
|
91
|
+
case 10:
|
|
92
|
+
case "end":
|
|
93
|
+
return _context.stop();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}, _callee);
|
|
97
|
+
}));
|
|
72
98
|
|
|
73
99
|
_this.storeAddToBankLinkRef = function (c) {
|
|
74
100
|
_this.addToBankLink = c;
|
|
@@ -97,12 +123,15 @@ var AddToBankOptions = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.d
|
|
|
97
123
|
}(_react.Component), _class2.propTypes = {
|
|
98
124
|
displayPosition: _propTypes.default.number.isRequired,
|
|
99
125
|
entryType: _propTypes.default.string.isRequired,
|
|
126
|
+
focusFirstErrorField: _propTypes.default.func,
|
|
100
127
|
guid: _propTypes.default.string.isRequired,
|
|
101
128
|
isValid: _propTypes.default.bool.isRequired,
|
|
102
129
|
openModal: _propTypes.default.func.isRequired,
|
|
103
130
|
screenreaderNotification: _propTypes.default.func.isRequired,
|
|
104
131
|
showError: _propTypes.default.func.isRequired,
|
|
105
132
|
styles: _propTypes.default.object
|
|
133
|
+
}, _class2.defaultProps = {
|
|
134
|
+
focusFirstErrorField: function focusFirstErrorField() {}
|
|
106
135
|
}, _temp)) || _class);
|
|
107
136
|
exports.AddToBankOptions = AddToBankOptions;
|
|
108
137
|
var _default = AddToBankOptions;
|
|
@@ -31,6 +31,8 @@ var _pick = _interopRequireDefault(require("lodash/pick"));
|
|
|
31
31
|
|
|
32
32
|
var _partial = _interopRequireDefault(require("lodash/partial"));
|
|
33
33
|
|
|
34
|
+
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
35
|
+
|
|
34
36
|
var _emotion = require("@instructure/emotion");
|
|
35
37
|
|
|
36
38
|
var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
|
|
@@ -101,6 +103,7 @@ var QuizEntry = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
|
|
|
101
103
|
return (0, _emotion.jsx)(_index7.default, {
|
|
102
104
|
displayPosition: _this.props.displayPosition,
|
|
103
105
|
entryType: _this.props.quizEntry.entryType,
|
|
106
|
+
focusFirstErrorField: _this.focusFirstErrorField,
|
|
104
107
|
guid: _this.props.guid,
|
|
105
108
|
isValid: _this.props.workingEntry.isValid(),
|
|
106
109
|
openModal: _this.props.openModal,
|
|
@@ -122,6 +125,15 @@ var QuizEntry = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default)
|
|
|
122
125
|
_this.itemEditArea = node;
|
|
123
126
|
};
|
|
124
127
|
|
|
128
|
+
_this.focusFirstErrorField = function () {
|
|
129
|
+
if (_this.itemEditArea) {
|
|
130
|
+
var editArea = _reactDom.default.findDOMNode(_this.itemEditArea);
|
|
131
|
+
|
|
132
|
+
var firstErrorField = editArea === null || editArea === void 0 ? void 0 : editArea.querySelector('[aria-invalid="true"]');
|
|
133
|
+
firstErrorField && firstErrorField.focus();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
125
137
|
_this.renderPrintableItemBankSample = function (sampleItem, index) {
|
|
126
138
|
var quizEntry = _QuizEntry.default.create(sampleItem.toObject());
|
|
127
139
|
|
|
@@ -416,6 +416,7 @@ var StimulusEdit = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.defau
|
|
|
416
416
|
}, (0, _emotion.jsx)(_index2.default, {
|
|
417
417
|
displayPosition: this.props.displayPosition,
|
|
418
418
|
entryType: this.props.quizEntry.entryType,
|
|
419
|
+
focusFirstErrorField: this.focusFirstErrorField,
|
|
419
420
|
guid: this.props.guid,
|
|
420
421
|
isValid: this.props.workingStimulus.isValid(),
|
|
421
422
|
openModal: this.props.openModal,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/quiz-core",
|
|
3
|
-
"version": "20.17.
|
|
3
|
+
"version": "20.17.1-rc.1+0dec4f96a",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "The Quiz React SDK by Instructure Inc.",
|
|
6
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"@instructure/emotion": "^8.51.0",
|
|
45
45
|
"@instructure/grading-utils": "^1.0.0",
|
|
46
46
|
"@instructure/outcomes-ui": "^3.2.2",
|
|
47
|
-
"@instructure/quiz-common": "
|
|
48
|
-
"@instructure/quiz-i18n": "
|
|
49
|
-
"@instructure/quiz-interactions": "
|
|
50
|
-
"@instructure/quiz-number-input": "
|
|
51
|
-
"@instructure/quiz-rce": "
|
|
47
|
+
"@instructure/quiz-common": "20.17.1-rc.1+0dec4f96a",
|
|
48
|
+
"@instructure/quiz-i18n": "20.17.1-rc.1+0dec4f96a",
|
|
49
|
+
"@instructure/quiz-interactions": "20.17.1-rc.1+0dec4f96a",
|
|
50
|
+
"@instructure/quiz-number-input": "20.17.1-rc.1+0dec4f96a",
|
|
51
|
+
"@instructure/quiz-rce": "20.17.1-rc.1+0dec4f96a",
|
|
52
52
|
"@instructure/ui-a11y-content": "^8.51.0",
|
|
53
53
|
"@instructure/ui-alerts": "^8.51.0",
|
|
54
54
|
"@instructure/ui-avatar": "^8.51.0",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"file-saver": "~2.0.5",
|
|
112
112
|
"humps": "^2.0.0",
|
|
113
113
|
"immutable": "^3.8.1",
|
|
114
|
-
"instructure-validations": "
|
|
114
|
+
"instructure-validations": "20.17.1-rc.1+0dec4f96a",
|
|
115
115
|
"ipaddr.js": "^1.5.4",
|
|
116
116
|
"isomorphic-fetch": "^2.2.0",
|
|
117
117
|
"isuuid": "^0.1.0",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"uuid": "^3.2.1"
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|
|
145
|
-
"@instructure/quiz-scripts": "
|
|
145
|
+
"@instructure/quiz-scripts": "20.17.0",
|
|
146
146
|
"@instructure/ui-axe-check": "^8.51.0",
|
|
147
147
|
"@instructure/ui-babel-preset": "^7.22.1",
|
|
148
148
|
"@instructure/ui-karma-config": "^7.22.1",
|
|
@@ -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": "
|
|
166
|
+
"quiz-presets": "20.17.1-rc.1+0dec4f96a",
|
|
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": "0dec4f96afef7862bbe01bd73e5641952467fcf6"
|
|
183
183
|
}
|