@instructure/quiz-core 22.0.0 → 22.1.0

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.
Files changed (27) hide show
  1. package/es/banks/components/CopyMoveBankEntryModal/presenter.js +84 -15
  2. package/es/common/components/layout/sidebar/Stimulus/Collection/presenter.js +6 -3
  3. package/es/common/components/layout/sidebar/Stimulus/presenter.js +98 -38
  4. package/es/common/components/layout/sidebar/Stimulus/styles.js +2 -26
  5. package/es/common/components/layout/sidebar/Stimulus/theme.js +1 -10
  6. package/es/common/components/resources/BankSelection/presenter.js +31 -8
  7. package/es/common/components/resources/sessionItemResult/SessionItemResult/presenter.js +20 -20
  8. package/es/common/components/resources/stimulus/StimulusEdit/presenter.js +31 -29
  9. package/es/common/components/resources/stimulus/StimulusEditInfo/presenter.js +2 -1
  10. package/es/common/components/shared/GenericAsyncSearch/GenericAsyncSearch.js +10 -3
  11. package/es/common/records/QuizEntry.js +29 -17
  12. package/es/common/records/SessionItem.js +6 -0
  13. package/es/taking/api/taking.js +1 -1
  14. package/lib/banks/components/CopyMoveBankEntryModal/presenter.js +84 -15
  15. package/lib/common/components/layout/sidebar/Stimulus/Collection/presenter.js +6 -3
  16. package/lib/common/components/layout/sidebar/Stimulus/presenter.js +98 -38
  17. package/lib/common/components/layout/sidebar/Stimulus/styles.js +2 -26
  18. package/lib/common/components/layout/sidebar/Stimulus/theme.js +1 -10
  19. package/lib/common/components/resources/BankSelection/presenter.js +31 -8
  20. package/lib/common/components/resources/sessionItemResult/SessionItemResult/presenter.js +20 -20
  21. package/lib/common/components/resources/stimulus/StimulusEdit/presenter.js +31 -29
  22. package/lib/common/components/resources/stimulus/StimulusEditInfo/presenter.js +2 -1
  23. package/lib/common/components/shared/GenericAsyncSearch/GenericAsyncSearch.js +10 -3
  24. package/lib/common/records/QuizEntry.js +29 -17
  25. package/lib/common/records/SessionItem.js +6 -0
  26. package/lib/taking/api/taking.js +1 -1
  27. package/package.json +9 -9
@@ -26,6 +26,8 @@ var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/f
26
26
  var _quizCommon = require("@instructure/quiz-common");
27
27
  var _uiTooltip = require("@instructure/ui-tooltip");
28
28
  var _uiA11yContent = require("@instructure/ui-a11y-content");
29
+ var _uiView = require("@instructure/ui-view");
30
+ var _uiText = require("@instructure/ui-text");
29
31
  var _dec, _class, _SidebarStimulus;
30
32
  /** @jsx jsx */
31
33
  function _callSuper(_this, derived, args) {
@@ -71,18 +73,26 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
71
73
  value: function componentDidUpdate() {
72
74
  this.props.makeStyles();
73
75
  }
76
+ }, {
77
+ key: "stimulusIsPassage",
78
+ value: function stimulusIsPassage() {
79
+ var _this$props$stimulus;
80
+ return (_this$props$stimulus = this.props.stimulus) === null || _this$props$stimulus === void 0 ? void 0 : _this$props$stimulus.isPassage;
81
+ }
74
82
  }, {
75
83
  key: "renderCollection",
76
84
  value: function renderCollection() {
77
- if (this.props.isDragging) {
78
- return;
79
- }
85
+ var _this$props$stimulus2;
80
86
  var _this$props = this.props,
81
87
  displayPosition = _this$props.displayPosition,
82
88
  isOver = _this$props.isOver,
83
89
  isShowingItems = _this$props.isShowingItems,
84
90
  renderSidebarItem = _this$props.renderSidebarItem,
85
- sidebarOpen = _this$props.sidebarOpen;
91
+ sidebarOpen = _this$props.sidebarOpen,
92
+ isDragging = _this$props.isDragging;
93
+ if (this.stimulusIsPassage() || isDragging) {
94
+ return null;
95
+ }
86
96
  return (0, _emotion.jsx)(_Collection["default"], {
87
97
  firstPosition: displayPosition,
88
98
  isOver: isOver,
@@ -90,22 +100,30 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
90
100
  itemCollection: this.props.childEntries,
91
101
  renderSidebarItem: renderSidebarItem,
92
102
  sidebarOpen: sidebarOpen,
93
- stimulusId: this.props.stimulus.id
103
+ stimulusId: this.props.stimulus.id,
104
+ isPassage: (_this$props$stimulus2 = this.props.stimulus) === null || _this$props$stimulus2 === void 0 ? void 0 : _this$props$stimulus2.isPassage
94
105
  });
95
106
  }
96
107
  }, {
97
108
  key: "renderButton",
98
109
  value: function renderButton() {
99
- var displayPosition = this.props.displayPosition;
100
- var textForNavigation = (0, _formatMessage["default"])('Navigate to stimulus at position {displayPosition}', {
110
+ var _this$props2 = this.props,
111
+ displayPosition = _this$props2.displayPosition,
112
+ sidebarOpen = _this$props2.sidebarOpen;
113
+ var itemName = this.stimulusIsPassage() ? 'passage' : 'stimulus';
114
+ var textForNavigation = (0, _formatMessage["default"])('Navigate to {itemName} at position {displayPosition}', {
115
+ itemName: itemName,
101
116
  displayPosition: displayPosition
102
117
  });
118
+ var content = sidebarOpen ? '' : textForNavigation;
119
+ var tip = (0, _emotion.jsx)(_uiText.Text, {
120
+ "aria-hidden": !sidebarOpen,
121
+ "aria-label": content
122
+ }, content);
103
123
  return (0, _emotion.jsx)(_uiTooltip.Tooltip, {
104
- renderTip: this.props.sidebarOpen ? '' : (0, _emotion.jsx)("span", {
105
- "aria-hidden": "true"
106
- }, textForNavigation),
124
+ renderTip: tip,
107
125
  placement: "start",
108
- on: this.props.sidebarOpen ? [] : ['hover', 'focus']
126
+ on: sidebarOpen ? [] : ['hover', 'focus']
109
127
  }, (0, _emotion.jsx)(_uiLink.Link, {
110
128
  href: "#",
111
129
  margin: "small",
@@ -117,33 +135,82 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
117
135
  className: _quizCommon.END_EDITING_TRIGGER_CLASSNAME
118
136
  }, (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, textForNavigation)));
119
137
  }
138
+ }, {
139
+ key: "infoHeaderLabel",
140
+ value: function infoHeaderLabel() {
141
+ return this.stimulusIsPassage() ? (0, _formatMessage["default"])('Passage') : (0, _formatMessage["default"])('Stimulus');
142
+ }
143
+ }, {
144
+ key: "renderSummary",
145
+ value: function renderSummary() {
146
+ var _this$props3 = this.props,
147
+ displayPosition = _this$props3.displayPosition,
148
+ isDragging = _this$props3.isDragging,
149
+ isShowingItems = _this$props3.isShowingItems,
150
+ sidebarOpen = _this$props3.sidebarOpen,
151
+ stimulus = _this$props3.stimulus;
152
+ if (this.stimulusIsPassage()) {
153
+ return null;
154
+ }
155
+ return (0, _emotion.jsx)(_Summary["default"], {
156
+ startPosition: displayPosition,
157
+ isDragging: isDragging,
158
+ isShowingItems: isShowingItems,
159
+ stimulusId: stimulus.id,
160
+ sidebarOpen: sidebarOpen,
161
+ numberOfItems: this.props.childEntries.size
162
+ });
163
+ }
164
+ }, {
165
+ key: "stimulusHoverCss",
166
+ value: function stimulusHoverCss() {
167
+ return {
168
+ // TODO: figure out how to get rid of the last of these styles.
169
+ ':hover': this.props.styles.onHover
170
+ };
171
+ }
120
172
  }, {
121
173
  key: "renderClosed",
122
174
  value: function renderClosed() {
123
- return (0, _emotion.jsx)("div", {
124
- css: this.props.styles.sidebarItem
125
- }, (0, _emotion.jsx)("div", {
126
- css: this.props.styles.sidebarItemClosedButton
175
+ return (0, _emotion.jsx)(_uiView.View, {
176
+ borderWidth: "0 0 small 0",
177
+ borderColor: "primary",
178
+ as: "div"
179
+ }, (0, _emotion.jsx)(_uiView.View, {
180
+ textAlign: "center",
181
+ padding: "xx-small 0",
182
+ borderWidth: "none large none none",
183
+ borderColor: "transparent",
184
+ css: this.stimulusHoverCss(),
185
+ as: "div"
127
186
  }, this.renderButton()), this.renderCollection());
128
187
  }
129
188
  }, {
130
189
  key: "renderOpen",
131
190
  value: function renderOpen() {
132
- var _this$props2 = this.props,
133
- children = _this$props2.children,
134
- displayPosition = _this$props2.displayPosition,
135
- isDragging = _this$props2.isDragging,
136
- isShowingItems = _this$props2.isShowingItems,
137
- sidebarOpen = _this$props2.sidebarOpen,
138
- stimulus = _this$props2.stimulus;
139
- return (0, _emotion.jsx)("div", {
140
- css: this.props.styles.sidebarItem
141
- }, (0, _emotion.jsx)("div", {
142
- css: this.props.styles.stimulusHeader
143
- }, (0, _emotion.jsx)("div", {
144
- css: this.props.styles.infoHeader
145
- }, (0, _formatMessage["default"])('Stimulus')), (0, _emotion.jsx)("div", {
146
- css: this.props.styles.stimulusBody
191
+ var _this$props4 = this.props,
192
+ stimulus = _this$props4.stimulus,
193
+ children = _this$props4.children;
194
+ return (0, _emotion.jsx)(_uiView.View, {
195
+ borderWidth: "0 0 small 0",
196
+ borderColor: "primary",
197
+ as: "div"
198
+ }, (0, _emotion.jsx)(_uiView.View, {
199
+ padding: "small 0",
200
+ borderWidth: "none large none none",
201
+ borderColor: "transparent",
202
+ css: this.stimulusHoverCss(),
203
+ as: "div"
204
+ }, (0, _emotion.jsx)(_uiView.View, {
205
+ margin: "auto auto x-small x-small",
206
+ padding: "auto auto auto x-small",
207
+ as: "div"
208
+ }, (0, _emotion.jsx)(_uiText.Text, {
209
+ size: "x-small",
210
+ color: "secondary"
211
+ }, this.infoHeaderLabel())), (0, _emotion.jsx)(_uiView.View, {
212
+ margin: "auto auto auto small",
213
+ as: "div"
147
214
  }, (0, _emotion.jsx)(_quizCommon.Flex, {
148
215
  justifyItems: "space-between"
149
216
  }, (0, _emotion.jsx)(_quizCommon.Flex.Item, null, this.renderButton()), (0, _emotion.jsx)(_quizCommon.Flex.Item, {
@@ -153,14 +220,7 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
153
220
  tabIndex: "-1"
154
221
  }, (0, _emotion.jsx)(_Title["default"], {
155
222
  title: stimulus.title
156
- })), (0, _emotion.jsx)(_quizCommon.Flex.Item, null, children)), (0, _emotion.jsx)(_Summary["default"], {
157
- startPosition: displayPosition,
158
- isDragging: isDragging,
159
- isShowingItems: isShowingItems,
160
- sidebarOpen: sidebarOpen,
161
- stimulusId: stimulus.id,
162
- numberOfItems: this.props.childEntries.size
163
- }))), this.renderCollection());
223
+ })), (0, _emotion.jsx)(_quizCommon.Flex.Item, null, children)), this.renderSummary())), this.renderCollection());
164
224
  }
165
225
  }, {
166
226
  key: "render",
@@ -6,32 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports["default"] = void 0;
7
7
  var generateStyle = function generateStyle(componentTheme) {
8
8
  return {
9
- sidebarItem: {
10
- borderBottom: "".concat(componentTheme.sidebarItemBorderWidth, " solid ").concat(componentTheme.sidebarItemBorderColor)
11
- },
12
- sidebarItemClosedButton: {
13
- borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.borderColor),
14
- padding: componentTheme.sidebarClosedButtonPadding,
15
- textAlign: 'center',
16
- '&:hover': {
17
- borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.hoverBorderColor)
18
- }
19
- },
20
- stimulusHeader: {
21
- padding: "".concat(componentTheme.sidebarHeaderPadding, " 0"),
22
- borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.borderColor),
23
- '&:hover:': {
24
- borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.hoverBorderColor)
25
- }
26
- },
27
- stimulusBody: {
28
- marginLeft: '5%'
29
- },
30
- infoHeader: {
31
- fontSize: componentTheme.sidebarIsOpenInfoHeaderFontSize,
32
- color: componentTheme.sidebarIsOpenInfoHeaderColor,
33
- marginBottom: componentTheme.sidebarIsOpenInfoHeaderMargin,
34
- paddingLeft: componentTheme.sidebarIsOpenInfoHeaderPadding
9
+ onHover: {
10
+ borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.hoverBorderColor)
35
11
  }
36
12
  };
37
13
  };
@@ -11,16 +11,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
11
11
  typography = _ref.typography;
12
12
  return {
13
13
  borderColor: colors.contrasts.white1010,
14
- hoverBorderColor: colors.contrasts.blue4570,
15
- hoverBorderWidth: borders.widthLarge,
16
- sidebarClosedButtonPadding: "".concat(spacing.xxSmall, " 0"),
17
- sidebarHeaderPadding: spacing.small,
18
- sidebarItemBorderWidth: borders.widthSmall,
19
- sidebarItemBorderColor: colors.contrasts.grey1214,
20
- sidebarIsOpenInfoHeaderFontSize: typography.fontSizeXSmall,
21
- sidebarIsOpenInfoHeaderPadding: spacing.xSmall,
22
- sidebarIsOpenInfoHeaderMargin: spacing.xSmall,
23
- sidebarIsOpenInfoHeaderColor: colors.contrasts.grey4570
14
+ hoverBorderColor: colors.contrasts.blue4570
24
15
  };
25
16
  };
26
17
  var _default = exports["default"] = generateComponentTheme;
@@ -36,13 +36,15 @@ function _callSuper(_this, derived, args) {
36
36
  return (0, _possibleConstructorReturn2["default"])(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], (0, _getPrototypeOf2["default"])(_this).constructor) : derived.apply(_this, args));
37
37
  }
38
38
  var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
39
- function BankSelection() {
39
+ function BankSelection(props) {
40
40
  var _this2;
41
41
  (0, _classCallCheck2["default"])(this, BankSelection);
42
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
- args[_key] = arguments[_key];
44
- }
45
- _this2 = _callSuper(this, BankSelection, [].concat(args));
42
+ _this2 = _callSuper(this, BankSelection, [props]);
43
+ (0, _defineProperty2["default"])(_this2, "setInputRef", function (ref) {
44
+ var _this2$props$inputRef, _this2$props;
45
+ _this2.inputRef = ref;
46
+ (_this2$props$inputRef = (_this2$props = _this2.props).inputRef) === null || _this2$props$inputRef === void 0 || _this2$props$inputRef.call(_this2$props, ref);
47
+ });
46
48
  (0, _defineProperty2["default"])(_this2, "searchBanks", function (search) {
47
49
  return _this2.props.simpleFetchBanks({
48
50
  search: search
@@ -65,18 +67,31 @@ var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
65
67
  archived: bankOption.archived
66
68
  });
67
69
  });
70
+ _this2.inputRef = null;
68
71
  return _this2;
69
72
  }
70
73
  (0, _inherits2["default"])(BankSelection, _Component);
71
74
  return (0, _createClass2["default"])(BankSelection, [{
75
+ key: "focusSelectField",
76
+ value: function focusSelectField() {
77
+ if (this.inputRef) {
78
+ this.inputRef.focus();
79
+ }
80
+ }
81
+ }, {
72
82
  key: "getErrors",
73
83
  value: function getErrors() {
74
84
  var selectedBank = this.props.selectedBank;
75
85
  if (selectedBank && selectedBank.archived) {
86
+ this.focusSelectField();
76
87
  return (0, _instUIMessages.toErrors)([(0, _formatMessage["default"])('The item bank "{ bankTitle }" no longer exists. Please select a valid bank.', {
77
88
  bankTitle: selectedBank.title
78
89
  })]);
79
90
  }
91
+ if (this.props.externalError) {
92
+ this.focusSelectField();
93
+ return this.props.externalError;
94
+ }
80
95
  }
81
96
  }, {
82
97
  key: "selectedOption",
@@ -92,13 +107,15 @@ var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
92
107
  key: "render",
93
108
  value: function render() {
94
109
  return /*#__PURE__*/_react["default"].createElement(_GenericAsyncSearch.GenericAsyncSearch, {
110
+ inputRef: this.setInputRef,
95
111
  onSelectionChange: this.onSelect,
96
112
  label: this.props.label || (0, _formatMessage["default"])('Select the destination bank'),
97
113
  placeholder: (0, _formatMessage["default"])('Search for a bank'),
98
114
  selectedOption: this.selectedOption(),
99
115
  getOptions: this.searchBanks,
100
116
  messages: this.getErrors(),
101
- selectAutomation: 'sdk-item-bank-modal'
117
+ selectAutomation: 'sdk-item-bank-modal',
118
+ isRequired: this.props.isRequired
102
119
  });
103
120
  }
104
121
  }]);
@@ -107,12 +124,18 @@ var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
107
124
  label: _propTypes["default"].string,
108
125
  onBankSelection: _propTypes["default"].func,
109
126
  selectedBank: _reactImmutableProptypes["default"].record,
110
- simpleFetchBanks: _propTypes["default"].func
127
+ simpleFetchBanks: _propTypes["default"].func,
128
+ externalError: _reactImmutableProptypes["default"].record,
129
+ inputRef: _propTypes["default"].func,
130
+ isRequired: _propTypes["default"].bool
111
131
  });
112
132
  (0, _defineProperty2["default"])(BankSelection, "defaultProps", {
113
133
  label: null,
114
134
  onBankSelection: function onBankSelection() {},
115
135
  selectedBank: null,
116
- simpleFetchBanks: _banks.simpleFetchBanks
136
+ simpleFetchBanks: _banks.simpleFetchBanks,
137
+ externalError: null,
138
+ inputRef: function inputRef() {},
139
+ isRequired: false
117
140
  });
118
141
  var _default = exports["default"] = BankSelection;
@@ -98,9 +98,9 @@ var SessionItemResult = exports.SessionItemResult = (_dec = (0, _quizCommon.with
98
98
  return typeof this.pointsPossible === 'number';
99
99
  }
100
100
  }, {
101
- key: "position",
102
- value: function position() {
103
- return this.props.sessionItem.position;
101
+ key: "questionNumber",
102
+ value: function questionNumber() {
103
+ return this.props.sessionItem.questionNumber;
104
104
  }
105
105
  }, {
106
106
  key: "unscorable",
@@ -186,38 +186,38 @@ var SessionItemResult = exports.SessionItemResult = (_dec = (0, _quizCommon.with
186
186
  value: function renderHeader() {
187
187
  return (0, _emotion.jsx)("div", {
188
188
  css: this.props.styles.sessionItemResultHeader
189
- }, this.renderResultPosition(), !this.props.restrictQuantitativeData && (this.hasRegradeInfo() ? this.renderRegradePoints() : this.renderPoints()));
189
+ }, this.renderResultQuestionNumber(), !this.props.restrictQuantitativeData && (this.hasRegradeInfo() ? this.renderRegradePoints() : this.renderPoints()));
190
190
  }
191
191
  }, {
192
- key: "renderResultPosition",
193
- value: function renderResultPosition() {
194
- var position = this.position();
195
- var positionText;
192
+ key: "renderResultQuestionNumber",
193
+ value: function renderResultQuestionNumber() {
194
+ var questionNumber = this.questionNumber();
195
+ var questionNumberText;
196
196
  if (this.regraded() && this.unscorable()) {
197
- positionText = (0, _formatMessage["default"])('Results for question {position, number}. There was a problem grading this question. This question has been regraded.', {
198
- position: position
197
+ questionNumberText = (0, _formatMessage["default"])('Results for question {questionNumber, number}. There was a problem grading this question. This question has been regraded.', {
198
+ questionNumber: questionNumber
199
199
  });
200
200
  } else if (this.regraded()) {
201
- positionText = (0, _formatMessage["default"])('Results for question {position, number}. This question has been regraded.', {
202
- position: position
201
+ questionNumberText = (0, _formatMessage["default"])('Results for question {questionNumber, number}. This question has been regraded.', {
202
+ questionNumber: questionNumber
203
203
  });
204
204
  } else if (this.unscorable() && this.props.editGraderFeedback) {
205
- positionText = (0, _formatMessage["default"])('Results for question {position, number}. There was a problem grading this question.', {
206
- position: position
205
+ questionNumberText = (0, _formatMessage["default"])('Results for question {questionNumber, number}. There was a problem grading this question.', {
206
+ questionNumber: questionNumber
207
207
  });
208
208
  } else if (this.unscorable()) {
209
- positionText = (0, _formatMessage["default"])('Results for question {position, number}. There was a problem grading this question. Please inform your instructor.', {
210
- position: position
209
+ questionNumberText = (0, _formatMessage["default"])('Results for question {questionNumber, number}. There was a problem grading this question. Please inform your instructor.', {
210
+ questionNumber: questionNumber
211
211
  });
212
212
  } else {
213
- positionText = (0, _formatMessage["default"])('Results for question {position, number}.', {
214
- position: position
213
+ questionNumberText = (0, _formatMessage["default"])('Results for question {questionNumber, number}.', {
214
+ questionNumber: questionNumber
215
215
  });
216
216
  }
217
217
  return (0, _emotion.jsx)(_PositionBox["default"], {
218
- position: position,
218
+ position: questionNumber,
219
219
  headingLevel: "h3",
220
- headingText: positionText
220
+ headingText: questionNumberText
221
221
  });
222
222
  }
223
223
  }, {
@@ -152,73 +152,74 @@ var StimulusEdit = exports.StimulusEdit = (_dec = (0, _quizCommon.withStyleOverr
152
152
  });
153
153
  (0, _defineProperty2["default"])(_this2, "onSubmit", /*#__PURE__*/function () {
154
154
  var _ref2 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(e) {
155
- var _this2$props2, stimulus, workingStimulus, quizId, quizEntry, stimulusData;
155
+ var _this2$props2, stimulus, workingStimulus, quizId, quizEntry, message, stimulusData;
156
156
  return _regenerator["default"].wrap(function _callee2$(_context2) {
157
157
  while (1) switch (_context2.prev = _context2.next) {
158
158
  case 0:
159
159
  _this2$props2 = _this2.props, stimulus = _this2$props2.stimulus, workingStimulus = _this2$props2.workingStimulus, quizId = _this2$props2.quizId, quizEntry = _this2$props2.quizEntry;
160
160
  if (workingStimulus.isValid()) {
161
- _context2.next = 8;
161
+ _context2.next = 9;
162
162
  break;
163
163
  }
164
- _context2.next = 4;
164
+ message = _this2.isPassage() ? (0, _formatMessage["default"])('Passage not saved due to validation errors with the data.') : (0, _formatMessage["default"])('Stimulus not saved due to validation errors with the data.');
165
+ _context2.next = 5;
165
166
  return _this2.props.showError(_this2.props.guid);
166
- case 4:
167
- _this2.props.screenreaderNotification((0, _formatMessage["default"])('Simulus not saved due to validation errors with the data.'));
167
+ case 5:
168
+ _this2.props.screenreaderNotification(message);
168
169
  _this2.props.clearNextQuizEntry();
169
170
  _this2.focusFirstErrorField();
170
171
  return _context2.abrupt("return");
171
- case 8:
172
+ case 9:
172
173
  _this2.setState({
173
174
  canSubmit: false
174
175
  });
175
176
  _this2.props.hideError(_this2.props.guid);
176
- _context2.prev = 10;
177
+ _context2.prev = 11;
177
178
  if (!stimulus.isTemporary()) {
178
- _context2.next = 17;
179
+ _context2.next = 18;
179
180
  break;
180
181
  }
181
- _context2.next = 14;
182
+ _context2.next = 15;
182
183
  return _this2.props.createStimulusAndQuizEntry(quizId, workingStimulus.toJS(), quizEntry);
183
- case 14:
184
+ case 15:
184
185
  _this2.props.clearTemporaryStimulus(quizId);
185
- _context2.next = 28;
186
+ _context2.next = 29;
186
187
  break;
187
- case 17:
188
+ case 18:
188
189
  if (!_this2.props.shouldClone) {
189
- _context2.next = 26;
190
+ _context2.next = 27;
190
191
  break;
191
192
  }
192
- _context2.next = 20;
193
+ _context2.next = 21;
193
194
  return _this2.props.createStimulus(workingStimulus, _this2.props.quizId, 'quiz', workingStimulus.id);
194
- case 20:
195
+ case 21:
195
196
  stimulusData = _context2.sent;
196
- _context2.next = 23;
197
+ _context2.next = 24;
197
198
  return _this2.handleStimulusCreated(stimulusData);
198
- case 23:
199
+ case 24:
199
200
  _this2.props.clearTemporaryStimulus(quizId);
200
- _context2.next = 28;
201
+ _context2.next = 29;
201
202
  break;
202
- case 26:
203
- _context2.next = 28;
203
+ case 27:
204
+ _context2.next = 29;
204
205
  return _this2.props.updateStimulus(workingStimulus.toJS(), quizId);
205
- case 28:
206
- _context2.next = 34;
206
+ case 29:
207
+ _context2.next = 35;
207
208
  break;
208
- case 30:
209
- _context2.prev = 30;
210
- _context2.t0 = _context2["catch"](10);
209
+ case 31:
210
+ _context2.prev = 31;
211
+ _context2.t0 = _context2["catch"](11);
211
212
  _this2.setState({
212
213
  canSubmit: true
213
214
  });
214
215
  throw _context2.t0;
215
- case 34:
216
- _this2.afterSubmit();
217
216
  case 35:
217
+ _this2.afterSubmit();
218
+ case 36:
218
219
  case "end":
219
220
  return _context2.stop();
220
221
  }
221
- }, _callee2, null, [[10, 30]]);
222
+ }, _callee2, null, [[11, 31]]);
222
223
  }));
223
224
  return function (_x2) {
224
225
  return _ref2.apply(this, arguments);
@@ -322,10 +323,11 @@ var StimulusEdit = exports.StimulusEdit = (_dec = (0, _quizCommon.withStyleOverr
322
323
  }, {
323
324
  key: "afterSubmit",
324
325
  value: function afterSubmit() {
326
+ var message = this.isPassage() ? (0, _formatMessage["default"])('Changes to passage saved.') : (0, _formatMessage["default"])('Changes to stimulus saved.');
325
327
  this.props.switchOffEditing();
326
328
  this.clearModifications();
327
329
  this.props.setUi(_quizCommon.SHOULD_CLONE_ITEM, false);
328
- this.props.screenreaderNotification((0, _formatMessage["default"])('Changes to stimulus saved.'));
330
+ this.props.screenreaderNotification(message);
329
331
  if (this.props.nextQuizEntry) {
330
332
  this.createNextQuizEntry();
331
333
  }
@@ -171,9 +171,10 @@ var StimulusEditInfo = exports.StimulusEditInfo = (_dec = (0, _quizCommon.withSt
171
171
  var textAreaId = "stimulusBodyEdit_".concat(stimulus.id, "_").concat(this.props.isBankedContent);
172
172
  var stimulusBodyId = "stimulusBodyEdit_".concat(stimulus.id, "_body");
173
173
  var automationPrefix = stimulus.passage ? 'passage' : 'stimulus';
174
+ var message = stimulus.passage ? (0, _formatMessage["default"])('Edit Passage') : (0, _formatMessage["default"])('Edit Stimulus');
174
175
  return (0, _emotion.jsx)(_quizCommon.FormFieldGroup, {
175
176
  messages: this.inputErrors('onSelf'),
176
- description: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage["default"])('Edit Stimulus'))
177
+ description: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, message)
177
178
  }, (0, _emotion.jsx)(_uiHeading.Heading, {
178
179
  level: "h3",
179
180
  as: "h2"
@@ -39,7 +39,9 @@ var GenericAsyncSearch = exports.GenericAsyncSearch = /*#__PURE__*/function (_Co
39
39
  (0, _classCallCheck2["default"])(this, GenericAsyncSearch);
40
40
  _this2 = _callSuper(this, GenericAsyncSearch, arguments);
41
41
  (0, _defineProperty2["default"])(_this2, "setInputRef", function (inputRef) {
42
+ var _this2$props$inputRef, _this2$props;
42
43
  _this2.inputRef = inputRef;
44
+ (_this2$props$inputRef = (_this2$props = _this2.props).inputRef) === null || _this2$props$inputRef === void 0 || _this2$props$inputRef.call(_this2$props, inputRef);
43
45
  });
44
46
  (0, _defineProperty2["default"])(_this2, "state", {
45
47
  inputValue: _this2.props.selectedOption ? _this2.props.selectedOption.text : '',
@@ -170,7 +172,8 @@ var GenericAsyncSearch = exports.GenericAsyncSearch = /*#__PURE__*/function (_Co
170
172
  onRequestHighlightOption: this.handleHighlightOption,
171
173
  onRequestSelectOption: this.handleSelectOption,
172
174
  onKeyDown: this.handleKeyDown,
173
- messages: this.props.messages
175
+ messages: this.props.messages,
176
+ isRequired: this.props.isRequired
174
177
  }, this.renderOptions());
175
178
  }
176
179
  }]);
@@ -187,13 +190,17 @@ var GenericAsyncSearch = exports.GenericAsyncSearch = /*#__PURE__*/function (_Co
187
190
  }),
188
191
  messages: _propTypes["default"].array,
189
192
  selectAutomation: _propTypes["default"].string,
190
- getOptions: _propTypes["default"].func.isRequired
193
+ getOptions: _propTypes["default"].func.isRequired,
194
+ inputRef: _propTypes["default"].func,
195
+ isRequired: _propTypes["default"].bool
191
196
  });
192
197
  (0, _defineProperty2["default"])(GenericAsyncSearch, "defaultProps", {
193
198
  debounceDelay: 500,
194
199
  minChars: 3,
195
200
  label: null,
196
201
  placeholder: null,
197
- selectAutomation: null
202
+ selectAutomation: null,
203
+ inputRef: function inputRef() {},
204
+ isRequired: false
198
205
  });
199
206
  var _default = exports["default"] = GenericAsyncSearch;