@instructure/quiz-core 17.57.0 → 17.57.1-rc.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.
@@ -8,9 +8,12 @@ import { generateImportModalId } from "../../../../../common/components/ImportMo
8
8
  import { BuildingButtons as BuildingButtonsPresenter } from "./presenter.js";
9
9
  import { getActiveQuiz } from "../../../../../common/selectors/quizzes.js";
10
10
  import { featureOn } from "../../../../../common/util/featureCheck.js";
11
+ import { startQuizExportJob } from "../../../../../common/actions/quizExport.js";
11
12
  export function mapStateToProps(state) {
12
13
  var quiz = getActiveQuiz(state);
13
14
  return {
15
+ activeQuizId: quiz.id,
16
+ canExport: !state.getIn(['quizExport', "activeQuiz".concat(quiz.id)]),
14
17
  canImport: quiz.canImport(),
15
18
  hasQuestions: quiz.hasQuestions(),
16
19
  isEditing: state.get('editing') && state.get('editing').some(function (elem) {
@@ -24,6 +27,7 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
24
27
  return {
25
28
  openBanksTray: bindActionCreators(setUI.bind(void 0, BUILD_TRAY_OPEN, true), dispatch),
26
29
  setBanksTrayButtonRef: bindActionCreators(partial(setUI, BUILD_TRAY_BUTTON_REF), dispatch),
30
+ startExport: bindActionCreators(startQuizExportJob, dispatch),
27
31
  openModal: bindActionCreators(modalActions.openModal.bind(modalActions, generateImportModalId('qtiImport')), dispatch)
28
32
  };
29
33
  };
@@ -51,6 +51,26 @@ export var BuildingButtons = (_dec = themeable(theme, styles), _dec(_class = (_t
51
51
  window.open(_this.props.speedgraderLink, '_blank');
52
52
  };
53
53
 
54
+ _this.startQuizExportJob = function () {
55
+ if (_this.props.canExport) {
56
+ var _this$props = _this.props,
57
+ activeQuizId = _this$props.activeQuizId,
58
+ contextUuid = _this$props.contextUuid;
59
+ var exportSettings = {
60
+ export_type: 'qti',
61
+ everything: false,
62
+ quizzes: [activeQuizId]
63
+ };
64
+
65
+ _this.props.contentExport({
66
+ contextUuid: contextUuid,
67
+ exportSettings: exportSettings
68
+ });
69
+
70
+ _this.props.startExport(activeQuizId);
71
+ }
72
+ };
73
+
54
74
  return _this;
55
75
  }
56
76
 
@@ -96,6 +116,8 @@ export var BuildingButtons = (_dec = themeable(theme, styles), _dec(_class = (_t
96
116
  if (this.props.contentExportEnabled) {
97
117
  menuItems.push( /*#__PURE__*/React.createElement(Menu.Item, {
98
118
  key: "export",
119
+ disabled: !this.props.canExport,
120
+ onSelect: this.startQuizExportJob,
99
121
  "data-automation": "sdk-export-content-menuitem"
100
122
  }, /*#__PURE__*/React.createElement(IconExportLine, {
101
123
  className: styles.menuIcon,
@@ -174,8 +196,11 @@ export var BuildingButtons = (_dec = themeable(theme, styles), _dec(_class = (_t
174
196
  return BuildingButtons;
175
197
  }(Component), _class2.propTypes = {
176
198
  app: PropTypes.string,
199
+ activeQuizId: PropTypes.string,
200
+ canExport: PropTypes.bool.isRequired,
177
201
  canImport: PropTypes.bool.isRequired,
178
202
  contentExportEnabled: PropTypes.bool,
203
+ contentExport: PropTypes.func,
179
204
  enableItemBanking: PropTypes.bool,
180
205
  hasQuestions: PropTypes.bool.isRequired,
181
206
  isEditing: PropTypes.bool.isRequired,
@@ -186,12 +211,17 @@ export var BuildingButtons = (_dec = themeable(theme, styles), _dec(_class = (_t
186
211
  printingEnabled: PropTypes.bool.isRequired,
187
212
  quizSaving: PropTypes.bool,
188
213
  setBanksTrayButtonRef: PropTypes.func.isRequired,
189
- speedgraderLink: PropTypes.string
214
+ speedgraderLink: PropTypes.string,
215
+ startExport: PropTypes.func.isRequired,
216
+ contextUuid: PropTypes.string
190
217
  }, _class2.defaultProps = {
218
+ activeQuizId: null,
191
219
  app: null,
192
220
  contentExportEnabled: false,
221
+ contentExport: null,
193
222
  enableItemBanking: true,
194
223
  quizSaving: false,
195
- speedgraderLink: null
224
+ speedgraderLink: null,
225
+ contextUuid: null
196
226
  }, _temp)) || _class);
197
227
  export default BuildingButtons;
@@ -0,0 +1,7 @@
1
+ import { START_QUIZ_EXPORT_JOB } from '@instructure/quiz-common';
2
+ export var startQuizExportJob = function startQuizExportJob(activeQuiz) {
3
+ return {
4
+ type: START_QUIZ_EXPORT_JOB,
5
+ payload: activeQuiz
6
+ };
7
+ };
@@ -0,0 +1,14 @@
1
+ import { START_QUIZ_EXPORT_JOB } from '@instructure/quiz-common';
2
+ import { fromJS } from 'immutable';
3
+ export default (function () {
4
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : fromJS({});
5
+ var action = arguments.length > 1 ? arguments[1] : void 0;
6
+
7
+ switch (action.type) {
8
+ case START_QUIZ_EXPORT_JOB:
9
+ return state.set("activeQuiz".concat(action.payload), true);
10
+
11
+ default:
12
+ return state;
13
+ }
14
+ });
@@ -18,6 +18,7 @@ import calls from "./common/reducers/calls.js";
18
18
  import configReducer from "./common/reducers/config.js";
19
19
  import editing from "./common/reducers/editing.js";
20
20
  import errorsShowing from "./common/reducers/errorsShowing.js";
21
+ import quizExport from "./common/reducers/quizExport.js";
21
22
  import features from "./common/reducers/features.js";
22
23
  import grading from "./common/reducers/grading.js";
23
24
  import interactionTypes from "./common/reducers/interactionTypes.js";
@@ -87,6 +88,7 @@ export function configureStore(_ref) {
87
88
  config: configReducer,
88
89
  editing: editing,
89
90
  errorsShowing: errorsShowing,
91
+ quizExport: quizExport,
90
92
  features: features,
91
93
  grading: grading,
92
94
  interactionTypes: interactionTypes,
package/es/index.js CHANGED
@@ -123,6 +123,7 @@ export { set, setActiveCalculatorId } from "./common/actions/ui.js";
123
123
  export { postToParent } from "./common/actions/postMessage.js";
124
124
  export { getResultInfo, newActiveQuizSession, clearActiveQuizSession } from "./common/actions/quizSessions.js";
125
125
  export { getSessionItems } from "./common/actions/quizSessions.js";
126
+ export { startQuizExportJob } from "./common/actions/quizExport.js";
126
127
  import * as modalActions from "./common/actions/modal.js";
127
128
  export { modalActions };
128
129
  import * as takingActionCreators from "./common/actions/taking.js";
@@ -30,9 +30,13 @@ var _quizzes = require("../../../../../common/selectors/quizzes.js");
30
30
 
31
31
  var _featureCheck = require("../../../../../common/util/featureCheck.js");
32
32
 
33
+ var _quizExport = require("../../../../../common/actions/quizExport.js");
34
+
33
35
  function mapStateToProps(state) {
34
36
  var quiz = (0, _quizzes.getActiveQuiz)(state);
35
37
  return {
38
+ activeQuizId: quiz.id,
39
+ canExport: !state.getIn(['quizExport', "activeQuiz".concat(quiz.id)]),
36
40
  canImport: quiz.canImport(),
37
41
  hasQuestions: quiz.hasQuestions(),
38
42
  isEditing: state.get('editing') && state.get('editing').some(function (elem) {
@@ -46,6 +50,7 @@ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
46
50
  return {
47
51
  openBanksTray: (0, _redux.bindActionCreators)(_ui.set.bind(void 0, _quizCommon.BUILD_TRAY_OPEN, true), dispatch),
48
52
  setBanksTrayButtonRef: (0, _redux.bindActionCreators)((0, _partial.default)(_ui.set, _quizCommon.BUILD_TRAY_BUTTON_REF), dispatch),
53
+ startExport: (0, _redux.bindActionCreators)(_quizExport.startQuizExportJob, dispatch),
49
54
  openModal: (0, _redux.bindActionCreators)(modalActions.openModal.bind(modalActions, (0, _index.generateImportModalId)('qtiImport')), dispatch)
50
55
  };
51
56
  };
@@ -76,6 +76,26 @@ var BuildingButtons = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles
76
76
  window.open(_this.props.speedgraderLink, '_blank');
77
77
  };
78
78
 
79
+ _this.startQuizExportJob = function () {
80
+ if (_this.props.canExport) {
81
+ var _this$props = _this.props,
82
+ activeQuizId = _this$props.activeQuizId,
83
+ contextUuid = _this$props.contextUuid;
84
+ var exportSettings = {
85
+ export_type: 'qti',
86
+ everything: false,
87
+ quizzes: [activeQuizId]
88
+ };
89
+
90
+ _this.props.contentExport({
91
+ contextUuid: contextUuid,
92
+ exportSettings: exportSettings
93
+ });
94
+
95
+ _this.props.startExport(activeQuizId);
96
+ }
97
+ };
98
+
79
99
  return _this;
80
100
  }
81
101
 
@@ -121,6 +141,8 @@ var BuildingButtons = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles
121
141
  if (this.props.contentExportEnabled) {
122
142
  menuItems.push( /*#__PURE__*/_react.default.createElement(_uiMenu.Menu.Item, {
123
143
  key: "export",
144
+ disabled: !this.props.canExport,
145
+ onSelect: this.startQuizExportJob,
124
146
  "data-automation": "sdk-export-content-menuitem"
125
147
  }, /*#__PURE__*/_react.default.createElement(_uiIcons.IconExportLine, {
126
148
  className: styles.menuIcon,
@@ -198,8 +220,11 @@ var BuildingButtons = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles
198
220
  return BuildingButtons;
199
221
  }(_react.Component), _class2.propTypes = {
200
222
  app: _propTypes.default.string,
223
+ activeQuizId: _propTypes.default.string,
224
+ canExport: _propTypes.default.bool.isRequired,
201
225
  canImport: _propTypes.default.bool.isRequired,
202
226
  contentExportEnabled: _propTypes.default.bool,
227
+ contentExport: _propTypes.default.func,
203
228
  enableItemBanking: _propTypes.default.bool,
204
229
  hasQuestions: _propTypes.default.bool.isRequired,
205
230
  isEditing: _propTypes.default.bool.isRequired,
@@ -210,13 +235,18 @@ var BuildingButtons = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles
210
235
  printingEnabled: _propTypes.default.bool.isRequired,
211
236
  quizSaving: _propTypes.default.bool,
212
237
  setBanksTrayButtonRef: _propTypes.default.func.isRequired,
213
- speedgraderLink: _propTypes.default.string
238
+ speedgraderLink: _propTypes.default.string,
239
+ startExport: _propTypes.default.func.isRequired,
240
+ contextUuid: _propTypes.default.string
214
241
  }, _class2.defaultProps = {
242
+ activeQuizId: null,
215
243
  app: null,
216
244
  contentExportEnabled: false,
245
+ contentExport: null,
217
246
  enableItemBanking: true,
218
247
  quizSaving: false,
219
- speedgraderLink: null
248
+ speedgraderLink: null,
249
+ contextUuid: null
220
250
  }, _temp)) || _class);
221
251
  exports.BuildingButtons = BuildingButtons;
222
252
  var _default = BuildingButtons;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.startQuizExportJob = void 0;
7
+
8
+ var _quizCommon = require("@instructure/quiz-common");
9
+
10
+ var startQuizExportJob = function startQuizExportJob(activeQuiz) {
11
+ return {
12
+ type: _quizCommon.START_QUIZ_EXPORT_JOB,
13
+ payload: activeQuiz
14
+ };
15
+ };
16
+
17
+ exports.startQuizExportJob = startQuizExportJob;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _quizCommon = require("@instructure/quiz-common");
9
+
10
+ var _immutable = require("immutable");
11
+
12
+ var _default = function _default() {
13
+ var state = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : (0, _immutable.fromJS)({});
14
+ var action = arguments.length > 1 ? arguments[1] : void 0;
15
+
16
+ switch (action.type) {
17
+ case _quizCommon.START_QUIZ_EXPORT_JOB:
18
+ return state.set("activeQuiz".concat(action.payload), true);
19
+
20
+ default:
21
+ return state;
22
+ }
23
+ };
24
+
25
+ exports.default = _default;
@@ -44,6 +44,8 @@ var _editing = _interopRequireDefault(require("./common/reducers/editing.js"));
44
44
 
45
45
  var _errorsShowing = _interopRequireDefault(require("./common/reducers/errorsShowing.js"));
46
46
 
47
+ var _quizExport = _interopRequireDefault(require("./common/reducers/quizExport.js"));
48
+
47
49
  var _features = _interopRequireDefault(require("./common/reducers/features.js"));
48
50
 
49
51
  var _grading = _interopRequireDefault(require("./common/reducers/grading.js"));
@@ -145,6 +147,7 @@ function configureStore(_ref) {
145
147
  config: _config.default,
146
148
  editing: _editing.default,
147
149
  errorsShowing: _errorsShowing.default,
150
+ quizExport: _quizExport.default,
148
151
  features: _features.default,
149
152
  grading: _grading.default,
150
153
  interactionTypes: _interactionTypes.default,
package/lib/index.js CHANGED
@@ -181,6 +181,7 @@ var _exportNames = {
181
181
  newActiveQuizSession: true,
182
182
  clearActiveQuizSession: true,
183
183
  getSessionItems: true,
184
+ startQuizExportJob: true,
184
185
  getQuizById: true,
185
186
  getActiveQuizId: true,
186
187
  getQuizEntryById: true,
@@ -1232,6 +1233,12 @@ Object.defineProperty(exports, "getSessionItems", {
1232
1233
  return _quizSessions3.getSessionItems;
1233
1234
  }
1234
1235
  });
1236
+ Object.defineProperty(exports, "startQuizExportJob", {
1237
+ enumerable: true,
1238
+ get: function get() {
1239
+ return _quizExport.startQuizExportJob;
1240
+ }
1241
+ });
1235
1242
  Object.defineProperty(exports, "getQuizById", {
1236
1243
  enumerable: true,
1237
1244
  get: function get() {
@@ -1574,6 +1581,8 @@ var _postMessage = require("./common/actions/postMessage.js");
1574
1581
 
1575
1582
  var _quizSessions3 = require("./common/actions/quizSessions.js");
1576
1583
 
1584
+ var _quizExport = require("./common/actions/quizExport.js");
1585
+
1577
1586
  var _quizzes3 = require("./common/selectors/quizzes.js");
1578
1587
 
1579
1588
  var _items2 = require("./common/selectors/items.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "17.57.0",
3
+ "version": "17.57.1-rc.0+146e6d941",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -41,11 +41,11 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@instructure/outcomes-ui": "^2.1.8",
44
- "@instructure/quiz-common": "^17.57.0",
45
- "@instructure/quiz-i18n": "^17.57.0",
46
- "@instructure/quiz-interactions": "^17.57.0",
47
- "@instructure/quiz-number-input": "^17.57.0",
48
- "@instructure/quiz-rce": "^17.57.0",
44
+ "@instructure/quiz-common": "17.57.1-rc.0+146e6d941",
45
+ "@instructure/quiz-i18n": "17.57.1-rc.0+146e6d941",
46
+ "@instructure/quiz-interactions": "17.57.1-rc.0+146e6d941",
47
+ "@instructure/quiz-number-input": "17.57.1-rc.0+146e6d941",
48
+ "@instructure/quiz-rce": "17.57.1-rc.0+146e6d941",
49
49
  "@instructure/ui-a11y-content": "^7.20.0",
50
50
  "@instructure/ui-alerts": "^7.20.0",
51
51
  "@instructure/ui-avatar": "^7.20.0",
@@ -106,7 +106,7 @@
106
106
  "eventemitter3": "^3.1.0",
107
107
  "humps": "^2.0.0",
108
108
  "immutable": "^3.8.1",
109
- "instructure-validations": "^17.57.0",
109
+ "instructure-validations": "17.57.1-rc.0+146e6d941",
110
110
  "ipaddr.js": "^1.5.4",
111
111
  "isomorphic-fetch": "^2.2.0",
112
112
  "isuuid": "^0.1.0",
@@ -137,7 +137,7 @@
137
137
  "uuid": "^3.2.1"
138
138
  },
139
139
  "devDependencies": {
140
- "@instructure/quiz-scripts": "^17.57.0",
140
+ "@instructure/quiz-scripts": "17.57.0",
141
141
  "@instructure/ui-axe-check": "^7.20.0",
142
142
  "@instructure/ui-babel-preset": "^7.20.0",
143
143
  "@instructure/ui-karma-config": "^7.20.0",
@@ -156,7 +156,7 @@
156
156
  "intl": "^1.2.4",
157
157
  "jquery": "^2.2.3",
158
158
  "most-subject": "^5.3.0",
159
- "quiz-presets": "^17.57.0",
159
+ "quiz-presets": "17.57.1-rc.0+146e6d941",
160
160
  "react": "^16.8.6",
161
161
  "react-addons-test-utils": "^15.6.2",
162
162
  "react-dom": "^16.8.6",
@@ -172,5 +172,5 @@
172
172
  "publishConfig": {
173
173
  "access": "public"
174
174
  },
175
- "gitHead": "27ef38fd2fe68b3281c94675e93a2264ca4b73fc"
175
+ "gitHead": "146e6d9416fe29a8c69897cee2d4317b81333c2e"
176
176
  }