@instructure/quiz-core 17.46.2-rc.7 → 17.47.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 (34) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/es/banks/components/AddToBankModal/index.js +6 -0
  3. package/es/banks/components/AddToBankModal/presenter.js +128 -6
  4. package/es/banks/components/BankEntry/presenter.js +4 -3
  5. package/es/building/api/items.js +21 -5
  6. package/es/building/api/stimuli.js +21 -5
  7. package/es/building/components/resources/quizEntry/QuizEntryEdit/presenter.js +1 -0
  8. package/es/common/actions/config.js +7 -1
  9. package/es/common/components/ConfirmationModal/presenter.js +1 -1
  10. package/es/common/components/SDKApp/index.js +10 -2
  11. package/es/common/components/resources/entry/EntrySave/index.js +11 -5
  12. package/es/common/components/resources/entry/EntrySave/presenter.js +95 -21
  13. package/es/common/components/resources/stimulus/StimulusEdit/presenter.js +1 -0
  14. package/es/common/reducers/config.js +4 -1
  15. package/es/common/util/RceConfigProvider.js +42 -26
  16. package/es/common/util/rceChecker.js +1 -1
  17. package/es/common/util/windowChecks.js +4 -1
  18. package/lib/banks/components/AddToBankModal/index.js +9 -0
  19. package/lib/banks/components/AddToBankModal/presenter.js +135 -6
  20. package/lib/banks/components/BankEntry/presenter.js +4 -3
  21. package/lib/building/api/items.js +23 -5
  22. package/lib/building/api/stimuli.js +23 -5
  23. package/lib/building/components/resources/quizEntry/QuizEntryEdit/presenter.js +1 -0
  24. package/lib/common/actions/config.js +8 -0
  25. package/lib/common/components/ConfirmationModal/presenter.js +1 -1
  26. package/lib/common/components/SDKApp/index.js +9 -1
  27. package/lib/common/components/resources/entry/EntrySave/index.js +15 -2
  28. package/lib/common/components/resources/entry/EntrySave/presenter.js +96 -21
  29. package/lib/common/components/resources/stimulus/StimulusEdit/presenter.js +1 -0
  30. package/lib/common/reducers/config.js +3 -0
  31. package/lib/common/util/RceConfigProvider.js +41 -25
  32. package/lib/common/util/rceChecker.js +1 -1
  33. package/lib/common/util/windowChecks.js +8 -2
  34. package/package.json +10 -10
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.getItem = getItem;
9
+ exports.checkItemShareability = checkItemShareability;
9
10
  exports.createItem = createItem;
10
11
  exports.updateItem = updateItem;
11
12
 
@@ -50,6 +51,20 @@ function getItem(itemId) {
50
51
  };
51
52
  }
52
53
 
54
+ function checkItemShareability(item, canvasOrigin) {
55
+ var url = '/api/items/check_shareability';
56
+ var requestBody = JSON.stringify({
57
+ item: updateItemParams(item),
58
+ source_origin: canvasOrigin
59
+ });
60
+ var fetcher = new _Fetcher.default({
61
+ onError: function onError() {}
62
+ });
63
+ return fetcher.post(url, {
64
+ body: requestBody
65
+ });
66
+ }
67
+
53
68
  function createItem(item, parentId, parentType) {
54
69
  var parentItemId = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
55
70
  var resource = parentType === 'bank' ? 'banks' : 'quizzes';
@@ -157,10 +172,8 @@ function createItem(item, parentId, parentType) {
157
172
  // =====================
158
173
 
159
174
 
160
- function updateItem(item, parentId, parentType) {
161
- var resource = parentType === 'bank' ? 'banks' : 'quizzes';
162
- var url = "/api/".concat(resource, "/").concat(parentId, "/items/").concat(item.id);
163
- var itemData = {
175
+ function updateItemParams(item) {
176
+ return {
164
177
  item_body: item.itemBody,
165
178
  title: item.title,
166
179
  scoring_data: item.scoringData,
@@ -172,8 +185,13 @@ function updateItem(item, parentId, parentType) {
172
185
  calculator_type: item.calculatorType,
173
186
  answer_feedback: item.answerFeedback
174
187
  };
188
+ }
189
+
190
+ function updateItem(item, parentId, parentType) {
191
+ var resource = parentType === 'bank' ? 'banks' : 'quizzes';
192
+ var url = "/api/".concat(resource, "/").concat(parentId, "/items/").concat(item.id);
175
193
  var reqBody = JSON.stringify({
176
- item: itemData
194
+ item: updateItemParams(item)
177
195
  });
178
196
  return function (dispatch, getState) {
179
197
  var updateItemParams = {
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.createStimulus = createStimulus;
9
9
  exports.updateStimulus = updateStimulus;
10
+ exports.checkStimulusShareability = checkStimulusShareability;
10
11
 
11
12
  var _quizCommon = require("@instructure/quiz-common");
12
13
 
@@ -61,18 +62,21 @@ function createStimulus(stimulus, parentId, parentType) {
61
62
  // =====================
62
63
 
63
64
 
64
- function updateStimulus(stimulus, parentId, parentType) {
65
- var resource = parentType === 'bank' ? 'banks' : 'quizzes';
66
- var url = "/api/".concat(resource, "/").concat(parentId, "/stimuli/").concat(stimulus.id);
67
- var stimulusData = {
65
+ function updateStimulusParams(stimulus) {
66
+ return {
68
67
  orientation: stimulus.orientation,
69
68
  title: stimulus.title,
70
69
  instructions: stimulus.instructions,
71
70
  body: stimulus.body,
72
71
  source_url: stimulus.sourceUrl
73
72
  };
73
+ }
74
+
75
+ function updateStimulus(stimulus, parentId, parentType) {
76
+ var resource = parentType === 'bank' ? 'banks' : 'quizzes';
77
+ var url = "/api/".concat(resource, "/").concat(parentId, "/stimuli/").concat(stimulus.id);
74
78
  var reqBody = JSON.stringify({
75
- stimulus: stimulusData
79
+ stimulus: updateStimulusParams(stimulus)
76
80
  });
77
81
  return function (dispatch, getState) {
78
82
  var updateStimulusParams = {
@@ -89,4 +93,18 @@ function updateStimulus(stimulus, parentId, parentType) {
89
93
  return stimulusData;
90
94
  });
91
95
  };
96
+ }
97
+
98
+ function checkStimulusShareability(stimulus, canvasOrigin) {
99
+ var url = '/api/stimuli/check_shareability';
100
+ var requestBody = JSON.stringify({
101
+ stimulus: updateStimulusParams(stimulus),
102
+ source_origin: canvasOrigin
103
+ });
104
+ var fetcher = new _Fetcher.default({
105
+ onError: function onError() {}
106
+ });
107
+ return fetcher.post(url, {
108
+ body: requestBody
109
+ });
92
110
  }
@@ -424,6 +424,7 @@ var QuizEntryEdit = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles),
424
424
  onContinue: this.handleAddToBankContinue,
425
425
  onAdd: this.handleAddToBank,
426
426
  getEntry: this.getEntryForBank,
427
+ workingEntry: this.props.workingEntry,
427
428
  entryId: this.props.guid,
428
429
  entryType: this.props.quizEntry.entryType,
429
430
  handleValidationErrorsFromApi: this.props.handleValidationErrorsFromApi
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.setAPIEndpoint = setAPIEndpoint;
7
7
  exports.setUserToken = setUserToken;
8
+ exports.setCanvasOrigin = setCanvasOrigin;
8
9
 
9
10
  var _quizCommon = require("@instructure/quiz-common");
10
11
 
@@ -20,4 +21,11 @@ function setUserToken(token) {
20
21
  type: _quizCommon.SET_USER_TOKEN,
21
22
  payload: token
22
23
  };
24
+ }
25
+
26
+ function setCanvasOrigin(canvasHost) {
27
+ return {
28
+ type: _quizCommon.SET_CANVAS_ORIGIN,
29
+ payload: canvasHost
30
+ };
23
31
  }
@@ -105,7 +105,7 @@ var ConfirmationModal = /*#__PURE__*/function (_Component) {
105
105
  as: "h2",
106
106
  "data-automation": "sdk-confirmation-modal-heading"
107
107
  }, title || (0, _formatMessage.default)('Confirm')), /*#__PURE__*/_react.default.createElement(_uiButtons.CloseButton, {
108
- onClick: this.props.closeModal,
108
+ onClick: this.cancelAction,
109
109
  placement: "end",
110
110
  offset: "medium",
111
111
  screenReaderLabel: (0, _formatMessage.default)('Close')
@@ -108,7 +108,9 @@ var SDKApp = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_
108
108
  }, {
109
109
  key: "componentWillMount",
110
110
  value: function componentWillMount() {
111
- this.store.dispatch([(0, _config.setAPIEndpoint)(this.props.apiEndpoint), this.setAppContainer(this.props.appContainer), (0, _config.setUserToken)(this.props.userToken), (0, _outcomes.setOutcomesEndpoint)(this.props.outcomesEndpoint), (0, _outcomes.setOutcomesToken)(this.props.outcomesToken), (0, _outcomes.setContextUuid)(this.props.contextUuid)]);
111
+ var _this$props$rceConfig;
112
+
113
+ this.store.dispatch([(0, _config.setAPIEndpoint)(this.props.apiEndpoint), (0, _config.setCanvasOrigin)((_this$props$rceConfig = this.props.rceConfig) === null || _this$props$rceConfig === void 0 ? void 0 : _this$props$rceConfig.canvasOrigin), this.setAppContainer(this.props.appContainer), (0, _config.setUserToken)(this.props.userToken), (0, _outcomes.setOutcomesEndpoint)(this.props.outcomesEndpoint), (0, _outcomes.setOutcomesToken)(this.props.outcomesToken), (0, _outcomes.setContextUuid)(this.props.contextUuid)]);
112
114
  this.store.dispatch((0, _features.getFeatures)());
113
115
 
114
116
  if (this.props.itemBankSharingEnabled) {
@@ -125,10 +127,16 @@ var SDKApp = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_
125
127
  }, {
126
128
  key: "componentWillReceiveProps",
127
129
  value: function componentWillReceiveProps(newProps) {
130
+ var _newProps$rceConfig, _this$props$rceConfig2;
131
+
128
132
  if (newProps.apiEndpoint !== this.props.apiEndpoint) {
129
133
  this.store.dispatch((0, _config.setAPIEndpoint)(newProps.apiEndpoint));
130
134
  }
131
135
 
136
+ if (((_newProps$rceConfig = newProps.rceConfig) === null || _newProps$rceConfig === void 0 ? void 0 : _newProps$rceConfig.canvasOrigin) !== ((_this$props$rceConfig2 = this.props.rceConfig) === null || _this$props$rceConfig2 === void 0 ? void 0 : _this$props$rceConfig2.canvasOrigin)) {
137
+ this.store.dispatch((0, _config.setCanvasOrigin)(newProps.rceConfig.canvasOrigin));
138
+ }
139
+
132
140
  if (newProps.appContainer !== this.props.appContainer) {
133
141
  this.store.dispatch(this.setAppContainer(newProps.appContainer));
134
142
  }
@@ -5,10 +5,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.mapStateToProps = mapStateToProps;
8
9
  exports.default = void 0;
9
10
 
10
11
  var _reactRedux = require("../../../../react-redux.js");
11
12
 
13
+ var _items = require("../../../../../building/api/items.js");
14
+
15
+ var _stimuli = require("../../../../../building/api/stimuli.js");
16
+
12
17
  var _makeEditable = _interopRequireDefault(require("../../../shared/functionality/makeEditable.js"));
13
18
 
14
19
  var _errorsShowing = require("../../../../actions/errorsShowing.js");
@@ -17,6 +22,10 @@ var _alerts = require("../../../../actions/alerts.js");
17
22
 
18
23
  var _modifications = require("../../../../actions/modifications.js");
19
24
 
25
+ var _modal = require("../../../../actions/modal.js");
26
+
27
+ var _featureCheck = require("../../../../util/featureCheck.js");
28
+
20
29
  var _presenter = _interopRequireDefault(require("./presenter.js"));
21
30
 
22
31
  function mapStateToProps(state, props) {
@@ -24,15 +33,19 @@ function mapStateToProps(state, props) {
24
33
  var workingEntry = props.entry.getWorkingInstance();
25
34
  var isValid = props.isValid !== void 0 ? props.isValid : workingEntry.isValid();
26
35
  return {
36
+ canvasOrigin: state.getIn(['config', 'canvasOrigin']),
37
+ checkBankedContentShareabilityEnabled: (0, _featureCheck.featureOn)('check_banked_content_shareability'),
38
+ checkContentShareability: props.entry.isStimulus ? _stimuli.checkStimulusShareability : _items.checkItemShareability,
27
39
  isValid: isValid
28
40
  };
29
41
  }
30
42
 
31
43
  var mapDispatchToProps = {
32
44
  clearNextQuizEntry: _modifications.clearNextQuizEntry,
33
- showError: _errorsShowing.showError,
34
45
  hideError: _errorsShowing.hideError,
35
- screenreaderNotification: _alerts.screenreaderNotification
46
+ screenreaderNotification: _alerts.screenreaderNotification,
47
+ showError: _errorsShowing.showError,
48
+ withConfirm: _modal.withConfirm
36
49
  };
37
50
 
38
51
  var _default = (0, _makeEditable.default)((0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_presenter.default));
@@ -25,6 +25,8 @@ var _react = _interopRequireWildcard(require("react"));
25
25
 
26
26
  var _propTypes = _interopRequireDefault(require("prop-types"));
27
27
 
28
+ var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
29
+
28
30
  var _uiButtons = require("@instructure/ui-buttons");
29
31
 
30
32
  var _uiView = require("@instructure/ui-view");
@@ -63,11 +65,75 @@ var EntrySave = /*#__PURE__*/function (_Component) {
63
65
  _this.props.screenreaderNotification(msg);
64
66
  };
65
67
 
68
+ _this.confirmShareableContent = function () {
69
+ var _this$props = _this.props,
70
+ canvasOrigin = _this$props.canvasOrigin,
71
+ checkContentShareability = _this$props.checkContentShareability,
72
+ entry = _this$props.entry,
73
+ withConfirm = _this$props.withConfirm;
74
+
75
+ _this.setState({
76
+ canSubmit: false
77
+ });
78
+
79
+ checkContentShareability(entry.getWorkingInstance(), canvasOrigin).then(function () {
80
+ _this.successfulSubmit();
81
+ }).catch( /*#__PURE__*/function () {
82
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(err) {
83
+ var _err$response, _err$response2;
84
+
85
+ var body, text;
86
+ return _regenerator.default.wrap(function _callee$(_context) {
87
+ while (1) {
88
+ switch (_context.prev = _context.next) {
89
+ case 0:
90
+ _context.next = 2;
91
+ return (_err$response = err.response) === null || _err$response === void 0 ? void 0 : _err$response.json();
92
+
93
+ case 2:
94
+ body = _context.sent;
95
+ text = (0, _formatMessage.default)('There was an error attempting to validate shareability.');
96
+
97
+ if (((_err$response2 = err.response) === null || _err$response2 === void 0 ? void 0 : _err$response2.status) === 400 && body.shareable === false) {
98
+ text = (0, _formatMessage.default)('You are attempting to save content containing course links which may not work when used in other courses.');
99
+ }
100
+
101
+ withConfirm(function () {
102
+ _this.successfulSubmit();
103
+ }, {
104
+ title: (0, _formatMessage.default)('Are you sure?'),
105
+ text: text,
106
+ continueText: (0, _formatMessage.default)('Save anyway'),
107
+ onCancel: function onCancel() {
108
+ _this.setState({
109
+ canSubmit: true
110
+ });
111
+ }
112
+ });
113
+
114
+ case 6:
115
+ case "end":
116
+ return _context.stop();
117
+ }
118
+ }
119
+ }, _callee);
120
+ }));
121
+
122
+ return function (_x) {
123
+ return _ref.apply(this, arguments);
124
+ };
125
+ }());
126
+ };
127
+
66
128
  _this.onSubmit = function (e) {
67
129
  e.preventDefault();
68
130
 
69
131
  if (_this.props.isValid) {
70
- _this.successfulSubmit();
132
+ if (_this.props.checkBankedContentShareabilityEnabled && _this.props.shouldValidateShareableContent) {
133
+ _this.confirmShareableContent();
134
+ } else {
135
+ _this.successfulSubmit();
136
+ }
71
137
  } else {
72
138
  _this.createScreenReaderNotification();
73
139
 
@@ -111,24 +177,24 @@ var EntrySave = /*#__PURE__*/function (_Component) {
111
177
  }, {
112
178
  key: "successfulSubmit",
113
179
  value: function () {
114
- var _successfulSubmit = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
180
+ var _successfulSubmit = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
115
181
  var validationResult;
116
- return _regenerator.default.wrap(function _callee$(_context) {
182
+ return _regenerator.default.wrap(function _callee2$(_context2) {
117
183
  while (1) {
118
- switch (_context.prev = _context.next) {
184
+ switch (_context2.prev = _context2.next) {
119
185
  case 0:
120
186
  this.setState({
121
187
  canSubmit: false
122
188
  });
123
- _context.prev = 1;
124
- _context.next = 4;
189
+ _context2.prev = 1;
190
+ _context2.next = 4;
125
191
  return this.props.submitHandler();
126
192
 
127
193
  case 4:
128
- validationResult = _context.sent;
194
+ validationResult = _context2.sent;
129
195
 
130
196
  if (!(validationResult === _quizCommon.API_INPUT_VALIDATION_ERROR)) {
131
- _context.next = 8;
197
+ _context2.next = 8;
132
198
  break;
133
199
  }
134
200
 
@@ -136,16 +202,16 @@ var EntrySave = /*#__PURE__*/function (_Component) {
136
202
  throw new Error('User input validation error received from API.');
137
203
 
138
204
  case 8:
139
- _context.next = 14;
205
+ _context2.next = 14;
140
206
  break;
141
207
 
142
208
  case 10:
143
- _context.prev = 10;
144
- _context.t0 = _context["catch"](1);
209
+ _context2.prev = 10;
210
+ _context2.t0 = _context2["catch"](1);
145
211
  this.setState({
146
212
  canSubmit: true
147
213
  });
148
- return _context.abrupt("return");
214
+ return _context2.abrupt("return");
149
215
 
150
216
  case 14:
151
217
  this.props.switchOffEditing();
@@ -154,10 +220,10 @@ var EntrySave = /*#__PURE__*/function (_Component) {
154
220
 
155
221
  case 17:
156
222
  case "end":
157
- return _context.stop();
223
+ return _context2.stop();
158
224
  }
159
225
  }
160
- }, _callee, this, [[1, 10]]);
226
+ }, _callee2, this, [[1, 10]]);
161
227
  }));
162
228
 
163
229
  function successfulSubmit() {
@@ -193,29 +259,38 @@ var EntrySave = /*#__PURE__*/function (_Component) {
193
259
 
194
260
  exports.EntrySave = EntrySave;
195
261
  EntrySave.propTypes = {
196
- displayPosition: _propTypes.default.number,
197
- disableSubmit: _propTypes.default.bool,
198
- guid: _propTypes.default.string,
199
- submitHandler: _propTypes.default.func.isRequired,
200
262
  cancelHandler: _propTypes.default.func,
263
+ canvasOrigin: _propTypes.default.string,
264
+ checkBankedContentShareabilityEnabled: _propTypes.default.bool,
265
+ checkContentShareability: _propTypes.default.func.isRequired,
201
266
  clearChanges: _propTypes.default.func.isRequired,
202
267
  // From connected component
203
268
  clearNextQuizEntry: _propTypes.default.func.isRequired,
269
+ disableSubmit: _propTypes.default.bool,
270
+ displayPosition: _propTypes.default.number,
271
+ entry: _reactImmutableProptypes.default.record.isRequired,
272
+ guid: _propTypes.default.string,
204
273
  hideError: _propTypes.default.func.isRequired,
274
+ initialFocusId: _propTypes.default.string,
205
275
  isValid: _propTypes.default.bool.isRequired,
206
276
  showError: _propTypes.default.func.isRequired,
207
277
  screenreaderNotification: _propTypes.default.func.isRequired,
278
+ shouldValidateShareableContent: _propTypes.default.bool,
279
+ submitHandler: _propTypes.default.func.isRequired,
208
280
  // from makescrollable / from props being passed in occasionally
209
281
  switchOnEditing: _propTypes.default.func.isRequired,
210
282
  switchOffEditing: _propTypes.default.func.isRequired,
211
- initialFocusId: _propTypes.default.string
283
+ withConfirm: _propTypes.default.func.isRequired
212
284
  };
213
285
  EntrySave.defaultProps = {
214
- displayPosition: null,
215
286
  cancelHandler: _noop.default,
287
+ canvasOrigin: '',
288
+ checkBankedContentShareabilityEnabled: false,
289
+ displayPosition: null,
216
290
  disableSubmit: false,
217
291
  guid: null,
218
- initialFocusId: null
292
+ initialFocusId: null,
293
+ shouldValidateShareableContent: false
219
294
  };
220
295
  var _default = EntrySave;
221
296
  exports.default = _default;
@@ -413,6 +413,7 @@ var StimulusEdit = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles),
413
413
  onAdd: this.handleAddToBank,
414
414
  onContinue: this.handleAddToBankContinue,
415
415
  getEntry: this.getEntryForBank,
416
+ workingEntry: this.props.workingStimulus,
416
417
  entryId: this.props.guid,
417
418
  entryType: this.props.quizEntry.entryType
418
419
  });
@@ -21,6 +21,9 @@ var _default = function _default() {
21
21
  case _quizCommon.SET_API_ENDPOINT:
22
22
  return state.set('apiEndpoint', action.payload);
23
23
 
24
+ case _quizCommon.SET_CANVAS_ORIGIN:
25
+ return state.set('canvasOrigin', action.payload);
26
+
24
27
  case _quizCommon.SET_USER_TOKEN:
25
28
  return state.set('userToken', action.payload);
26
29
 
@@ -77,39 +77,37 @@ var RceConfigProviderComponent = function RceConfigProviderComponent(props) {
77
77
  switch (_context.prev = _context.next) {
78
78
  case 0:
79
79
  if (hasAllPropsForRcs()) {
80
- _context.next = 3;
80
+ _context.next = 2;
81
81
  break;
82
82
  }
83
83
 
84
- handleErrorFunc('Invalid RCS configuration');
85
84
  return _context.abrupt("return");
86
85
 
87
- case 3:
88
- _context.next = 5;
86
+ case 2:
87
+ _context.next = 4;
89
88
  return props.rcsJwtRefreshFn(jwt);
90
89
 
91
- case 5:
90
+ case 4:
92
91
  response = _context.sent;
93
92
  refreshedToken = response === null || response === void 0 ? void 0 : (_response$json = response.json) === null || _response$json === void 0 ? void 0 : _response$json.token; // inst-redux-service-middleware response structure
94
93
 
95
94
  if (refreshedToken) {
96
- _context.next = 13;
95
+ _context.next = 11;
97
96
  break;
98
97
  }
99
98
 
100
- handleErrorFunc('Unable to refresh RCS token');
101
99
  normalizedStem = questionStem !== null && questionStem !== void 0 ? questionStem : 'Unknown stem';
102
100
  extractedText = (0, _quizInteractions.extractTextFromHtml)(normalizedStem);
103
- setErrorIfDuringTaking((0, _formatMessage.default)('Error while answering "{stem}": Full functionality of the Rich Content Editor may not have been available to the user.', {
101
+ handleError((0, _formatMessage.default)('Error while answering "{stem}": Full functionality of the Rich Content Editor may not have been available to the user.', {
104
102
  stem: extractedText
105
103
  }));
106
104
  return _context.abrupt("return");
107
105
 
108
- case 13:
106
+ case 11:
109
107
  setJwt(refreshedToken);
110
108
  setTokenFn(refreshedToken);
111
109
 
112
- case 15:
110
+ case 13:
113
111
  case "end":
114
112
  return _context.stop();
115
113
  }
@@ -122,8 +120,34 @@ var RceConfigProviderComponent = function RceConfigProviderComponent(props) {
122
120
  };
123
121
  }();
124
122
 
125
- var handleErrorFunc = function handleErrorFunc(errorMessage) {
126
- _reduxStore.default.dispatch((0, _alerts.addError)(errorMessage));
123
+ var handleError = function handleError(quizLogMessage) {
124
+ if (shouldAlertUser()) {
125
+ alertTheUser(alertMessage());
126
+ }
127
+
128
+ if (shouldsetEventToQuizLog()) {
129
+ setEventToQuizLog(quizLogMessage);
130
+ }
131
+ };
132
+
133
+ var alertTheUser = function alertTheUser(message) {
134
+ _reduxStore.default.dispatch((0, _alerts.addError)(message));
135
+ };
136
+
137
+ var setEventToQuizLog = function setEventToQuizLog(message) {
138
+ props.setEventToQuizLog(message);
139
+ };
140
+
141
+ var alertMessage = function alertMessage() {
142
+ return (0, _windowChecks.isQuizTaking)() ? (0, _formatMessage.default)('The Rich Content Editor has encountered an issue. ' + 'It has been logged for your instructor to review. Please refresh and try again.') : (0, _formatMessage.default)('The Rich Content Editor has encountered an issue. Please refresh and try again.');
143
+ };
144
+
145
+ var shouldAlertUser = function shouldAlertUser() {
146
+ return (0, _windowChecks.isQuizTaking)() || (0, _windowChecks.isQuizBuilding)();
147
+ };
148
+
149
+ var shouldsetEventToQuizLog = function shouldsetEventToQuizLog() {
150
+ return (0, _windowChecks.isQuizTaking)();
127
151
  };
128
152
 
129
153
  var getConfig = function getConfig() {
@@ -136,14 +160,6 @@ var RceConfigProviderComponent = function RceConfigProviderComponent(props) {
136
160
  };
137
161
  };
138
162
 
139
- var setErrorIfDuringTaking = function setErrorIfDuringTaking(errorMessage) {
140
- if (!(0, _windowChecks.isQuizTaking)()) {
141
- return;
142
- }
143
-
144
- props.setRCEError(errorMessage);
145
- };
146
-
147
163
  (0, _react.useEffect)(function () {
148
164
  (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
149
165
  var host, base, url, response, json;
@@ -166,7 +182,7 @@ var RceConfigProviderComponent = function RceConfigProviderComponent(props) {
166
182
  break;
167
183
  }
168
184
 
169
- setErrorIfDuringTaking((0, _formatMessage.default)('Error: Full functionality of the Rich Content Editor may not have been available to the user.'));
185
+ handleError((0, _formatMessage.default)('Error: Full functionality of the Rich Content Editor may not have been available to the user.'));
170
186
  return _context2.abrupt("return");
171
187
 
172
188
  case 6:
@@ -190,7 +206,7 @@ var RceConfigProviderComponent = function RceConfigProviderComponent(props) {
190
206
  case 16:
191
207
  json = _context2.sent;
192
208
  setCanvasConfig(json);
193
- setErrorIfDuringTaking(null);
209
+ setEventToQuizLog(null);
194
210
  _context2.next = 25;
195
211
  break;
196
212
 
@@ -198,7 +214,7 @@ var RceConfigProviderComponent = function RceConfigProviderComponent(props) {
198
214
  _context2.prev = 21;
199
215
  _context2.t0 = _context2["catch"](2);
200
216
  setCanvasConfig(null);
201
- setErrorIfDuringTaking((0, _formatMessage.default)('Error: Full functionality of the Rich Content Editor including accessibility features may not have been available to the user.'));
217
+ handleError((0, _formatMessage.default)('Error: Full functionality of the Rich Content Editor including accessibility features may not have been available to the user.'));
202
218
 
203
219
  case 25:
204
220
  _context2.prev = 25;
@@ -235,7 +251,7 @@ RceConfigProviderComponent.propTypes = {
235
251
  isNewRCEEnabled: _propTypes.default.bool.isRequired,
236
252
  rce5Renderer: _propTypes.default.bool.isRequired,
237
253
  isNewRCEAppsEnabled: _propTypes.default.bool,
238
- setRCEError: _propTypes.default.func.isRequired,
254
+ setEventToQuizLog: _propTypes.default.func.isRequired,
239
255
  contextId: _propTypes.default.string,
240
256
  contextType: _propTypes.default.string,
241
257
  canvasUserId: _propTypes.default.string,
@@ -267,7 +283,7 @@ var mapStateToProps = function mapStateToProps(state, ownProps) {
267
283
  };
268
284
 
269
285
  var mapDispatchToProps = {
270
- setRCEError: _rce.setRCEError
286
+ setEventToQuizLog: _rce.setRCEError
271
287
  };
272
288
  var RceConfigProvider = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(RceConfigProviderComponent);
273
289
  exports.RceConfigProvider = RceConfigProvider;
@@ -11,7 +11,7 @@ exports.default = void 0;
11
11
  var _featureCheck = require("./featureCheck.js");
12
12
 
13
13
  var newRCEFeatureName = 'use_new_rce';
14
- var newRCEAppsFeatureName = 'use_new_rce_apps';
14
+ var newRCEAppsFeatureName = 'rce5_apps';
15
15
  var rce5RendererFeatureName = 'rce5_renderer';
16
16
 
17
17
  function isNewRCEEnabled() {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isQuizTaking = exports.onTablet = exports.onPhone = exports.media = void 0;
6
+ exports.isQuizBuilding = exports.isQuizTaking = exports.onTablet = exports.onPhone = exports.media = void 0;
7
7
 
8
8
  var _quizCommon = require("@instructure/quiz-common");
9
9
 
@@ -33,4 +33,10 @@ var isQuizTaking = function isQuizTaking() {
33
33
  return (0, _quizCommon.isDuringQuizTake)();
34
34
  };
35
35
 
36
- exports.isQuizTaking = isQuizTaking;
36
+ exports.isQuizTaking = isQuizTaking;
37
+
38
+ var isQuizBuilding = function isQuizBuilding() {
39
+ return (0, _quizCommon.isDuringQuizBuild)();
40
+ };
41
+
42
+ exports.isQuizBuilding = isQuizBuilding;