@instructure/quiz-core 20.5.2-rc.2 → 20.5.2-rc.4

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.
@@ -425,8 +425,6 @@ export var StimulusEdit = (_dec = themeable(theme, styles), _dec(_class = (_temp
425
425
  guid: this.props.guid,
426
426
  stimulus: this.props.stimulus,
427
427
  isBankedContent: this.props.isBankedContent,
428
- parentId: this.props.quizId,
429
- parentType: "quiz",
430
428
  setTitleRef: this.setTitleRef
431
429
  }), this.renderAddToBankOptions())), /*#__PURE__*/React.createElement("div", {
432
430
  className: styles.footer
@@ -8,15 +8,13 @@ var _dec, _class, _class2, _temp;
8
8
  import React, { Component } from 'react';
9
9
  import PropTypes from 'prop-types';
10
10
  import ImmutablePropTypes from 'react-immutable-proptypes';
11
- import { List, Map } from 'immutable';
12
11
  import { ScreenReaderContent } from '@instructure/ui-a11y-content';
13
12
  import { TextInput } from '@instructure/ui-text-input';
14
- import { FormFieldLabel, FormFieldGroup } from '@instructure/ui-form-field';
13
+ import { FormField, FormFieldGroup } from '@instructure/ui-form-field';
15
14
  import { themeable } from '@instructure/ui-themeable';
16
15
  import { Heading } from '@instructure/ui-heading';
17
- import RichContentInput from "../../../RichContentInput/index.js";
16
+ import { RichContentInput, RCE_SINGLE_LINE_HEIGHT } from '@instructure/quiz-rce';
18
17
  import { toErrors } from "../../../../util/instUIMessages.js";
19
- import Errors from "../../../shared/errors/Errors.js";
20
18
  import { SimpleSelect } from '@instructure/ui-simple-select';
21
19
  import { IconUpdownLine } from '@instructure/ui-icons';
22
20
  import { ToggleDetails } from '@instructure/ui-toggle-details';
@@ -85,22 +83,6 @@ export var StimulusEditInfo = (_dec = themeable(theme, styles), _dec(_class = (_
85
83
  _this.props.modifyStimulus(newData);
86
84
  };
87
85
 
88
- _this.errorsList = function (field) {
89
- if (_this.props.errorsShowing) {
90
- var errorMap = _this.props.workingStimulus.getErrors() || Map();
91
- return errorMap.get(field) || List();
92
- }
93
- };
94
-
95
- _this.fileUploadUrl = function () {
96
- var _this$props = _this.props,
97
- stimulus = _this$props.stimulus,
98
- parentId = _this$props.parentId,
99
- parentType = _this$props.parentType;
100
- var resource = parentType === 'bank' ? 'banks' : 'quizzes';
101
- return "/api/".concat(resource, "/").concat(parentId, "/stimuli/").concat(stimulus.id, "/media_upload_url");
102
- };
103
-
104
86
  return _this;
105
87
  }
106
88
 
@@ -144,6 +126,8 @@ export var StimulusEditInfo = (_dec = themeable(theme, styles), _dec(_class = (_
144
126
  key: "render",
145
127
  value: function render() {
146
128
  var stimulus = this.props.workingStimulus;
129
+ var textAreaId = "stimulusBodyEdit_".concat(stimulus.id, "_").concat(this.props.isBankedContent);
130
+ var stimulusBodyId = "stimulusBodyEdit_".concat(stimulus.id, "_body");
147
131
  return /*#__PURE__*/React.createElement(FormFieldGroup, {
148
132
  messages: this.inputErrors('onSelf'),
149
133
  description: /*#__PURE__*/React.createElement(ScreenReaderContent, null, t('Edit Stimulus'))
@@ -168,18 +152,21 @@ export var StimulusEditInfo = (_dec = themeable(theme, styles), _dec(_class = (_
168
152
  value: stimulus.get('instructions')
169
153
  })), /*#__PURE__*/React.createElement("div", {
170
154
  className: styles.section
171
- }, /*#__PURE__*/React.createElement(FormFieldLabel, null, t('Content')), /*#__PURE__*/React.createElement(RichContentInput, {
172
- label: "" // eslint-disable-next-line react/jsx-no-literals
173
- ,
174
- textareaId: "stimulusBodyEdit_".concat(stimulus.id, "_").concat(this.props.isBankedContent),
155
+ }, /*#__PURE__*/React.createElement(FormField, {
156
+ id: stimulusBodyId,
157
+ label: t('Content'),
158
+ messages: this.inputErrors('body')
159
+ }, /*#__PURE__*/React.createElement(RichContentInput, {
160
+ actsAsInput: true,
161
+ label: "",
162
+ placeholder: t('Add Stimulus Content...'),
163
+ textareaId: textAreaId,
175
164
  defaultContent: stimulus.get('body'),
176
165
  onKeyUp: this.onBodyChange,
177
166
  onBlur: this.onBodyChange,
178
167
  onChange: this.onBodyChange,
179
- uploadPath: this.fileUploadUrl()
180
- }), /*#__PURE__*/React.createElement(Errors, {
181
- errorList: this.errorsList('body')
182
- })), /*#__PURE__*/React.createElement("div", {
168
+ height: RCE_SINGLE_LINE_HEIGHT
169
+ }))), /*#__PURE__*/React.createElement("div", {
183
170
  className: styles.section
184
171
  }, /*#__PURE__*/React.createElement(ToggleDetails, {
185
172
  defaultExpanded: true,
@@ -205,8 +192,6 @@ export var StimulusEditInfo = (_dec = themeable(theme, styles), _dec(_class = (_
205
192
  workingStimulus: ImmutablePropTypes.record.isRequired,
206
193
  errorsShowing: PropTypes.bool.isRequired,
207
194
  modifyStimulus: PropTypes.func.isRequired,
208
- parentId: PropTypes.string.isRequired,
209
- parentType: PropTypes.string.isRequired,
210
195
  setTitleRef: PropTypes.func,
211
196
  stimulusOrientationEnabled: PropTypes.bool.isRequired
212
197
  }, _class2.defaultProps = {
@@ -53,6 +53,10 @@ export var ChoiceGroupTypeTable = (_dec = withStyle(generateStyle, generateCompo
53
53
  }
54
54
  };
55
55
 
56
+ _this.getTranslatedEmptyMessage = function () {
57
+ return t('There are no entries for this open entry question.');
58
+ };
59
+
56
60
  _this.handleBodyToggle = function () {
57
61
  _this.setState({
58
62
  bodyExpanded: !_this.state.bodyExpanded
@@ -122,11 +126,29 @@ export var ChoiceGroupTypeTable = (_dec = withStyle(generateStyle, generateCompo
122
126
  })));
123
127
  };
124
128
 
129
+ _this.renderEmptyInfo = function () {
130
+ return jsx(Flex, {
131
+ direction: "column",
132
+ justifyItems: "start"
133
+ }, jsx(Flex.Item, {
134
+ shouldShrink: true,
135
+ shouldGrow: true,
136
+ padding: "none none x-small small"
137
+ }, jsx(Text, null, _this.getTranslatedEmptyMessage())));
138
+ };
139
+
125
140
  _this.render = function () {
141
+ var _this$props3 = _this.props,
142
+ styles = _this$props3.styles,
143
+ blank = _this$props3.blank;
144
+ var groupWrapper = styles.groupWrapper,
145
+ cardWrapper = styles.cardWrapper;
146
+ var areThereChoices = Array.isArray(blank.choices) && blank.choices.length > 0;
147
+ var bodyExpanded = _this.state.bodyExpanded;
126
148
  return jsx("div", {
127
- css: _this.props.styles.groupWrapper
149
+ css: groupWrapper
128
150
  }, jsx(Card, {
129
- css: _this.props.styles.cardWrapper
151
+ css: cardWrapper
130
152
  }, jsx(Flex, {
131
153
  direction: "column",
132
154
  justifyItems: "start"
@@ -142,10 +164,10 @@ export var ChoiceGroupTypeTable = (_dec = withStyle(generateStyle, generateCompo
142
164
  shouldShrink: true,
143
165
  padding: "x-small small x-small medium",
144
166
  overflowY: "hidden"
145
- }, _this.renderGroup()), _this.state.bodyExpanded && jsx(Flex.Item, {
167
+ }, _this.renderGroup()), bodyExpanded && jsx(Flex.Item, {
146
168
  shouldShrink: true,
147
169
  padding: "x-small small x-small small"
148
- }, _this.renderTable())))))));
170
+ }, areThereChoices ? _this.renderTable() : _this.renderEmptyInfo())))))));
149
171
  };
150
172
 
151
173
  return _this;
@@ -159,7 +181,7 @@ export var ChoiceGroupTypeTable = (_dec = withStyle(generateStyle, generateCompo
159
181
  blank_text: PropTypes.string.isRequired,
160
182
  blank_type: PropTypes.string.isRequired
161
183
  }).isRequired,
162
- blankInfo: PropTypes.node.isRequired,
184
+ blankInfo: PropTypes.node,
163
185
  index: PropTypes.number.isRequired,
164
186
  styles: PropTypes.object
165
187
  }.isRequired, _temp)) || _class);
@@ -462,8 +462,6 @@ var StimulusEdit = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles),
462
462
  guid: this.props.guid,
463
463
  stimulus: this.props.stimulus,
464
464
  isBankedContent: this.props.isBankedContent,
465
- parentId: this.props.quizId,
466
- parentType: "quiz",
467
465
  setTitleRef: this.setTitleRef
468
466
  }), this.renderAddToBankOptions())), /*#__PURE__*/_react.default.createElement("div", {
469
467
  className: styles.footer
@@ -23,8 +23,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
23
23
 
24
24
  var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
25
25
 
26
- var _immutable = require("immutable");
27
-
28
26
  var _uiA11yContent = require("@instructure/ui-a11y-content");
29
27
 
30
28
  var _uiTextInput = require("@instructure/ui-text-input");
@@ -35,12 +33,10 @@ var _uiThemeable = require("@instructure/ui-themeable");
35
33
 
36
34
  var _uiHeading = require("@instructure/ui-heading");
37
35
 
38
- var _index = _interopRequireDefault(require("../../../RichContentInput/index.js"));
36
+ var _quizRce = require("@instructure/quiz-rce");
39
37
 
40
38
  var _instUIMessages = require("../../../../util/instUIMessages.js");
41
39
 
42
- var _Errors = _interopRequireDefault(require("../../../shared/errors/Errors.js"));
43
-
44
40
  var _uiSimpleSelect = require("@instructure/ui-simple-select");
45
41
 
46
42
  var _uiIcons = require("@instructure/ui-icons");
@@ -117,22 +113,6 @@ var StimulusEditInfo = (_dec = (0, _uiThemeable.themeable)(_theme.default, style
117
113
  _this.props.modifyStimulus(newData);
118
114
  };
119
115
 
120
- _this.errorsList = function (field) {
121
- if (_this.props.errorsShowing) {
122
- var errorMap = _this.props.workingStimulus.getErrors() || (0, _immutable.Map)();
123
- return errorMap.get(field) || (0, _immutable.List)();
124
- }
125
- };
126
-
127
- _this.fileUploadUrl = function () {
128
- var _this$props = _this.props,
129
- stimulus = _this$props.stimulus,
130
- parentId = _this$props.parentId,
131
- parentType = _this$props.parentType;
132
- var resource = parentType === 'bank' ? 'banks' : 'quizzes';
133
- return "/api/".concat(resource, "/").concat(parentId, "/stimuli/").concat(stimulus.id, "/media_upload_url");
134
- };
135
-
136
116
  return _this;
137
117
  }
138
118
 
@@ -176,6 +156,8 @@ var StimulusEditInfo = (_dec = (0, _uiThemeable.themeable)(_theme.default, style
176
156
  key: "render",
177
157
  value: function render() {
178
158
  var stimulus = this.props.workingStimulus;
159
+ var textAreaId = "stimulusBodyEdit_".concat(stimulus.id, "_").concat(this.props.isBankedContent);
160
+ var stimulusBodyId = "stimulusBodyEdit_".concat(stimulus.id, "_body");
179
161
  return /*#__PURE__*/_react.default.createElement(_uiFormField.FormFieldGroup, {
180
162
  messages: this.inputErrors('onSelf'),
181
163
  description: /*#__PURE__*/_react.default.createElement(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage.default)('Edit Stimulus'))
@@ -200,18 +182,21 @@ var StimulusEditInfo = (_dec = (0, _uiThemeable.themeable)(_theme.default, style
200
182
  value: stimulus.get('instructions')
201
183
  })), /*#__PURE__*/_react.default.createElement("div", {
202
184
  className: styles.section
203
- }, /*#__PURE__*/_react.default.createElement(_uiFormField.FormFieldLabel, null, (0, _formatMessage.default)('Content')), /*#__PURE__*/_react.default.createElement(_index.default, {
204
- label: "" // eslint-disable-next-line react/jsx-no-literals
205
- ,
206
- textareaId: "stimulusBodyEdit_".concat(stimulus.id, "_").concat(this.props.isBankedContent),
185
+ }, /*#__PURE__*/_react.default.createElement(_uiFormField.FormField, {
186
+ id: stimulusBodyId,
187
+ label: (0, _formatMessage.default)('Content'),
188
+ messages: this.inputErrors('body')
189
+ }, /*#__PURE__*/_react.default.createElement(_quizRce.RichContentInput, {
190
+ actsAsInput: true,
191
+ label: "",
192
+ placeholder: (0, _formatMessage.default)('Add Stimulus Content...'),
193
+ textareaId: textAreaId,
207
194
  defaultContent: stimulus.get('body'),
208
195
  onKeyUp: this.onBodyChange,
209
196
  onBlur: this.onBodyChange,
210
197
  onChange: this.onBodyChange,
211
- uploadPath: this.fileUploadUrl()
212
- }), /*#__PURE__*/_react.default.createElement(_Errors.default, {
213
- errorList: this.errorsList('body')
214
- })), /*#__PURE__*/_react.default.createElement("div", {
198
+ height: _quizRce.RCE_SINGLE_LINE_HEIGHT
199
+ }))), /*#__PURE__*/_react.default.createElement("div", {
215
200
  className: styles.section
216
201
  }, /*#__PURE__*/_react.default.createElement(_uiToggleDetails.ToggleDetails, {
217
202
  defaultExpanded: true,
@@ -236,8 +221,6 @@ var StimulusEditInfo = (_dec = (0, _uiThemeable.themeable)(_theme.default, style
236
221
  workingStimulus: _reactImmutableProptypes.default.record.isRequired,
237
222
  errorsShowing: _propTypes.default.bool.isRequired,
238
223
  modifyStimulus: _propTypes.default.func.isRequired,
239
- parentId: _propTypes.default.string.isRequired,
240
- parentType: _propTypes.default.string.isRequired,
241
224
  setTitleRef: _propTypes.default.func,
242
225
  stimulusOrientationEnabled: _propTypes.default.bool.isRequired
243
226
  }, _class2.defaultProps = {
@@ -76,6 +76,10 @@ var ChoiceGroupTypeTable = (_dec = (0, _emotion.withStyle)(_styles.default, _the
76
76
  }
77
77
  };
78
78
 
79
+ _this.getTranslatedEmptyMessage = function () {
80
+ return (0, _formatMessage.default)('There are no entries for this open entry question.');
81
+ };
82
+
79
83
  _this.handleBodyToggle = function () {
80
84
  _this.setState({
81
85
  bodyExpanded: !_this.state.bodyExpanded
@@ -145,11 +149,29 @@ var ChoiceGroupTypeTable = (_dec = (0, _emotion.withStyle)(_styles.default, _the
145
149
  })));
146
150
  };
147
151
 
152
+ _this.renderEmptyInfo = function () {
153
+ return (0, _emotion.jsx)(_uiFlex.Flex, {
154
+ direction: "column",
155
+ justifyItems: "start"
156
+ }, (0, _emotion.jsx)(_uiFlex.Flex.Item, {
157
+ shouldShrink: true,
158
+ shouldGrow: true,
159
+ padding: "none none x-small small"
160
+ }, (0, _emotion.jsx)(_uiText.Text, null, _this.getTranslatedEmptyMessage())));
161
+ };
162
+
148
163
  _this.render = function () {
164
+ var _this$props3 = _this.props,
165
+ styles = _this$props3.styles,
166
+ blank = _this$props3.blank;
167
+ var groupWrapper = styles.groupWrapper,
168
+ cardWrapper = styles.cardWrapper;
169
+ var areThereChoices = Array.isArray(blank.choices) && blank.choices.length > 0;
170
+ var bodyExpanded = _this.state.bodyExpanded;
149
171
  return (0, _emotion.jsx)("div", {
150
- css: _this.props.styles.groupWrapper
172
+ css: groupWrapper
151
173
  }, (0, _emotion.jsx)(_index2.default, {
152
- css: _this.props.styles.cardWrapper
174
+ css: cardWrapper
153
175
  }, (0, _emotion.jsx)(_uiFlex.Flex, {
154
176
  direction: "column",
155
177
  justifyItems: "start"
@@ -165,10 +187,10 @@ var ChoiceGroupTypeTable = (_dec = (0, _emotion.withStyle)(_styles.default, _the
165
187
  shouldShrink: true,
166
188
  padding: "x-small small x-small medium",
167
189
  overflowY: "hidden"
168
- }, _this.renderGroup()), _this.state.bodyExpanded && (0, _emotion.jsx)(_uiFlex.Flex.Item, {
190
+ }, _this.renderGroup()), bodyExpanded && (0, _emotion.jsx)(_uiFlex.Flex.Item, {
169
191
  shouldShrink: true,
170
192
  padding: "x-small small x-small small"
171
- }, _this.renderTable())))))));
193
+ }, areThereChoices ? _this.renderTable() : _this.renderEmptyInfo())))))));
172
194
  };
173
195
 
174
196
  return _this;
@@ -182,7 +204,7 @@ var ChoiceGroupTypeTable = (_dec = (0, _emotion.withStyle)(_styles.default, _the
182
204
  blank_text: _propTypes.default.string.isRequired,
183
205
  blank_type: _propTypes.default.string.isRequired
184
206
  }).isRequired,
185
- blankInfo: _propTypes.default.node.isRequired,
207
+ blankInfo: _propTypes.default.node,
186
208
  index: _propTypes.default.number.isRequired,
187
209
  styles: _propTypes.default.object
188
210
  }.isRequired, _temp)) || _class);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.5.2-rc.2+8427bde12",
3
+ "version": "20.5.2-rc.4+803df26e2",
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.1.0",
47
- "@instructure/quiz-common": "20.5.2-rc.2+8427bde12",
48
- "@instructure/quiz-i18n": "20.5.2-rc.2+8427bde12",
49
- "@instructure/quiz-interactions": "20.5.2-rc.2+8427bde12",
50
- "@instructure/quiz-number-input": "20.5.2-rc.2+8427bde12",
51
- "@instructure/quiz-rce": "20.5.2-rc.2+8427bde12",
47
+ "@instructure/quiz-common": "20.5.2-rc.4+803df26e2",
48
+ "@instructure/quiz-i18n": "20.5.2-rc.4+803df26e2",
49
+ "@instructure/quiz-interactions": "20.5.2-rc.4+803df26e2",
50
+ "@instructure/quiz-number-input": "20.5.2-rc.4+803df26e2",
51
+ "@instructure/quiz-rce": "20.5.2-rc.4+803df26e2",
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",
@@ -112,7 +112,7 @@
112
112
  "file-saver": "~2.0.5",
113
113
  "humps": "^2.0.0",
114
114
  "immutable": "^3.8.1",
115
- "instructure-validations": "20.5.2-rc.2+8427bde12",
115
+ "instructure-validations": "20.5.2-rc.4+803df26e2",
116
116
  "ipaddr.js": "^1.5.4",
117
117
  "isomorphic-fetch": "^2.2.0",
118
118
  "isuuid": "^0.1.0",
@@ -163,7 +163,7 @@
163
163
  "intl": "^1.2.4",
164
164
  "jquery": "^2.2.3",
165
165
  "most-subject": "^5.3.0",
166
- "quiz-presets": "20.5.2-rc.2+8427bde12",
166
+ "quiz-presets": "20.5.2-rc.4+803df26e2",
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": "8427bde127939d727962cc942f84156a8b97bfd4"
182
+ "gitHead": "803df26e28d3a74c5da47c537c4785a667938418"
183
183
  }