@instructure/quiz-core 17.28.2-rc.1 → 17.28.2-rc.2

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.
@@ -13,18 +13,35 @@ import { handleError } from "../../common/api/helpers.js";
13
13
  import { BANKS_BANK_PAGINATION, BANKS_BANK_ENTRY_PAGINATION, DELETE_BANK_CALL, UPDATE_BANK_CALL, CAN_EDIT, REMOVED_ACCESS, SHARED_WITH_USER, SHARED_WITH_COURSE } from '@instructure/quiz-common';
14
14
  var banksApiEndpoint = '/api/banks';
15
15
  var DEFAULT_PAGE_SIZE = 100;
16
+
17
+ var _fetchBanks = function _fetchBanks(dispatch) {
18
+ var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
19
+ var fetcher = new PaginatedFetcher();
20
+ return fetcher.get(banksApiEndpoint, params).then(function (_ref) {
21
+ var _ref2 = _slicedToArray(_ref, 2),
22
+ response = _ref2[0],
23
+ pageData = _ref2[1];
24
+
25
+ dispatch(handleBanksResponse(response));
26
+ return pageData;
27
+ });
28
+ };
29
+
16
30
  export var getBanks = function getBanks() {
17
31
  var params = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
32
+ var getCourseAssignments = arguments.length > 1 ? arguments[1] : void 0;
18
33
  return function (dispatch, getState) {
19
- var fetcher = new PaginatedFetcher();
20
- return fetcher.get(banksApiEndpoint, params).then(function (_ref) {
21
- var _ref2 = _slicedToArray(_ref, 2),
22
- response = _ref2[0],
23
- pageData = _ref2[1];
24
-
25
- dispatch(handleBanksResponse(response));
26
- return pageData;
27
- });
34
+ if (params['course_id'] && getCourseAssignments) {
35
+ return getCourseAssignments(params['course_id']).then(function (assignments) {
36
+ return _fetchBanks(dispatch, _objectSpread(_objectSpread({}, params), {}, {
37
+ quiz_ids: assignments.json.map(function (a) {
38
+ return a.quiz_api_quiz_id;
39
+ })
40
+ }));
41
+ });
42
+ } else {
43
+ return _fetchBanks(dispatch, params);
44
+ }
28
45
  };
29
46
  };
30
47
  export var getAllBanks = function getAllBanks() {
@@ -106,7 +106,7 @@ export var Banks = (_dec = themeable(theme, styles), _dec(_class = (_temp = _cla
106
106
 
107
107
  return _this.props.getBanks(_objectSpread({
108
108
  page: page
109
- }, params));
109
+ }, params), _this.props.getCourseAssignments);
110
110
  };
111
111
 
112
112
  _this.focusCreateBankButton = function () {
@@ -232,7 +232,7 @@ export var Banks = (_dec = themeable(theme, styles), _dec(_class = (_temp = _cla
232
232
  translation: this.props.newItemBankFilterNamesEnabled ? t('Banks Shared to Course') : t('All My Course Banks')
233
233
  }];
234
234
 
235
- if (this.props.scopeType == 'course') {
235
+ if (this.props.scope.uuid) {
236
236
  scopeOptions.push({
237
237
  slug: 'course',
238
238
  translation: this.props.newItemBankFilterNamesEnabled ? t('This Course') : t('Course Banks')
@@ -392,6 +392,8 @@ export var Banks = (_dec = themeable(theme, styles), _dec(_class = (_temp = _cla
392
392
  getShareableCourses: PropTypes.func,
393
393
  // from consumer
394
394
  getShareableUsers: PropTypes.func,
395
+ // from consumer,
396
+ getCourseAssignments: PropTypes.func,
395
397
  // from consumer
396
398
  minChars: PropTypes.number,
397
399
  isCompact: PropTypes.bool,
@@ -406,7 +408,7 @@ export var Banks = (_dec = themeable(theme, styles), _dec(_class = (_temp = _cla
406
408
  type: PropTypes.string,
407
409
  uuid: PropTypes.string,
408
410
  title: PropTypes.string
409
- })),
411
+ })).isRequired,
410
412
  returnToUrl: PropTypes.string,
411
413
  // from consumer
412
414
  filtersEnabled: PropTypes.bool,
@@ -422,6 +424,7 @@ export var Banks = (_dec = themeable(theme, styles), _dec(_class = (_temp = _cla
422
424
  getUserInfo: null,
423
425
  getShareableCourses: null,
424
426
  getShareableUsers: null,
427
+ getCourseAssignments: null,
425
428
  minChars: void 0,
426
429
  isCompact: false,
427
430
  navigateToBuild: null,
@@ -105,11 +105,13 @@ export var BanksTray = /*#__PURE__*/function (_Component) {
105
105
  currentUser: this.props.currentUser,
106
106
  navigateToBank: this.props.newActiveBank,
107
107
  getCourseInfo: this.props.getCourseInfo,
108
+ getCourseAssignments: this.props.getCourseAssignments,
108
109
  getUserInfo: this.props.getUserInfo,
109
110
  getShareableCourses: this.props.getShareableCourses,
110
111
  getShareableUsers: this.props.getShareableUsers,
111
112
  minChars: this.props.minChars,
112
- onShare: this.props.onShare
113
+ onShare: this.props.onShare,
114
+ scope: this.props.itemBanksScope
113
115
  });
114
116
  }
115
117
  }
@@ -174,6 +176,7 @@ BanksTray.propTypes = {
174
176
  account_name: PropTypes.string
175
177
  }),
176
178
  getCourseInfo: PropTypes.func,
179
+ getCourseAssignments: PropTypes.func,
177
180
  getUserInfo: PropTypes.func,
178
181
  getShareableCourses: PropTypes.func,
179
182
  getShareableUsers: PropTypes.func,
@@ -186,6 +189,11 @@ BanksTray.propTypes = {
186
189
  trayOpen: PropTypes.bool.isRequired,
187
190
  trayTrigger: PropTypes.shape({
188
191
  focus: PropTypes.func
192
+ }),
193
+ itemBanksScope: PropTypes.shape({
194
+ type: PropTypes.string,
195
+ uuid: PropTypes.string,
196
+ title: PropTypes.string
189
197
  })
190
198
  };
191
199
  BanksTray.defaultProps = {
@@ -196,8 +204,10 @@ BanksTray.defaultProps = {
196
204
  getShareableUsers: null,
197
205
  minChars: void 0,
198
206
  getCourseInfo: null,
207
+ getCourseAssignments: null,
199
208
  getUserInfo: null,
200
209
  onShare: function onShare() {},
201
- trayTrigger: null
210
+ trayTrigger: null,
211
+ itemBanksScope: {}
202
212
  };
203
213
  export default BanksTray;
@@ -37,18 +37,34 @@ var _quizCommon = require("@instructure/quiz-common");
37
37
  var banksApiEndpoint = '/api/banks';
38
38
  var DEFAULT_PAGE_SIZE = 100;
39
39
 
40
+ var _fetchBanks = function _fetchBanks(dispatch) {
41
+ var params = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
42
+ var fetcher = new _PaginatedFetcher.default();
43
+ return fetcher.get(banksApiEndpoint, params).then(function (_ref) {
44
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
45
+ response = _ref2[0],
46
+ pageData = _ref2[1];
47
+
48
+ dispatch((0, _callHandlers.handleBanksResponse)(response));
49
+ return pageData;
50
+ });
51
+ };
52
+
40
53
  var getBanks = function getBanks() {
41
54
  var params = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
55
+ var getCourseAssignments = arguments.length > 1 ? arguments[1] : void 0;
42
56
  return function (dispatch, getState) {
43
- var fetcher = new _PaginatedFetcher.default();
44
- return fetcher.get(banksApiEndpoint, params).then(function (_ref) {
45
- var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
46
- response = _ref2[0],
47
- pageData = _ref2[1];
48
-
49
- dispatch((0, _callHandlers.handleBanksResponse)(response));
50
- return pageData;
51
- });
57
+ if (params['course_id'] && getCourseAssignments) {
58
+ return getCourseAssignments(params['course_id']).then(function (assignments) {
59
+ return _fetchBanks(dispatch, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
60
+ quiz_ids: assignments.json.map(function (a) {
61
+ return a.quiz_api_quiz_id;
62
+ })
63
+ }));
64
+ });
65
+ } else {
66
+ return _fetchBanks(dispatch, params);
67
+ }
52
68
  };
53
69
  };
54
70
 
@@ -142,7 +142,7 @@ var Banks = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_c
142
142
 
143
143
  return _this.props.getBanks((0, _objectSpread2.default)({
144
144
  page: page
145
- }, params));
145
+ }, params), _this.props.getCourseAssignments);
146
146
  };
147
147
 
148
148
  _this.focusCreateBankButton = function () {
@@ -268,7 +268,7 @@ var Banks = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_c
268
268
  translation: this.props.newItemBankFilterNamesEnabled ? (0, _formatMessage.default)('Banks Shared to Course') : (0, _formatMessage.default)('All My Course Banks')
269
269
  }];
270
270
 
271
- if (this.props.scopeType == 'course') {
271
+ if (this.props.scope.uuid) {
272
272
  scopeOptions.push({
273
273
  slug: 'course',
274
274
  translation: this.props.newItemBankFilterNamesEnabled ? (0, _formatMessage.default)('This Course') : (0, _formatMessage.default)('Course Banks')
@@ -430,6 +430,8 @@ var Banks = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_c
430
430
  getShareableCourses: _propTypes.default.func,
431
431
  // from consumer
432
432
  getShareableUsers: _propTypes.default.func,
433
+ // from consumer,
434
+ getCourseAssignments: _propTypes.default.func,
433
435
  // from consumer
434
436
  minChars: _propTypes.default.number,
435
437
  isCompact: _propTypes.default.bool,
@@ -444,7 +446,7 @@ var Banks = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_c
444
446
  type: _propTypes.default.string,
445
447
  uuid: _propTypes.default.string,
446
448
  title: _propTypes.default.string
447
- })),
449
+ })).isRequired,
448
450
  returnToUrl: _propTypes.default.string,
449
451
  // from consumer
450
452
  filtersEnabled: _propTypes.default.bool,
@@ -460,6 +462,7 @@ var Banks = (_dec = (0, _uiThemeable.themeable)(_theme.default, styles), _dec(_c
460
462
  getUserInfo: null,
461
463
  getShareableCourses: null,
462
464
  getShareableUsers: null,
465
+ getCourseAssignments: null,
463
466
  minChars: void 0,
464
467
  isCompact: false,
465
468
  navigateToBuild: null,
@@ -133,11 +133,13 @@ var BanksTray = /*#__PURE__*/function (_Component) {
133
133
  currentUser: this.props.currentUser,
134
134
  navigateToBank: this.props.newActiveBank,
135
135
  getCourseInfo: this.props.getCourseInfo,
136
+ getCourseAssignments: this.props.getCourseAssignments,
136
137
  getUserInfo: this.props.getUserInfo,
137
138
  getShareableCourses: this.props.getShareableCourses,
138
139
  getShareableUsers: this.props.getShareableUsers,
139
140
  minChars: this.props.minChars,
140
- onShare: this.props.onShare
141
+ onShare: this.props.onShare,
142
+ scope: this.props.itemBanksScope
141
143
  });
142
144
  }
143
145
  }
@@ -203,6 +205,7 @@ BanksTray.propTypes = {
203
205
  account_name: _propTypes.default.string
204
206
  }),
205
207
  getCourseInfo: _propTypes.default.func,
208
+ getCourseAssignments: _propTypes.default.func,
206
209
  getUserInfo: _propTypes.default.func,
207
210
  getShareableCourses: _propTypes.default.func,
208
211
  getShareableUsers: _propTypes.default.func,
@@ -215,6 +218,11 @@ BanksTray.propTypes = {
215
218
  trayOpen: _propTypes.default.bool.isRequired,
216
219
  trayTrigger: _propTypes.default.shape({
217
220
  focus: _propTypes.default.func
221
+ }),
222
+ itemBanksScope: _propTypes.default.shape({
223
+ type: _propTypes.default.string,
224
+ uuid: _propTypes.default.string,
225
+ title: _propTypes.default.string
218
226
  })
219
227
  };
220
228
  BanksTray.defaultProps = {
@@ -225,9 +233,11 @@ BanksTray.defaultProps = {
225
233
  getShareableUsers: null,
226
234
  minChars: void 0,
227
235
  getCourseInfo: null,
236
+ getCourseAssignments: null,
228
237
  getUserInfo: null,
229
238
  onShare: function onShare() {},
230
- trayTrigger: null
239
+ trayTrigger: null,
240
+ itemBanksScope: {}
231
241
  };
232
242
  var _default = BanksTray;
233
243
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "17.28.2-rc.1+c89471e1f",
3
+ "version": "17.28.2-rc.2+b632a9c42",
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.2",
44
- "@instructure/quiz-common": "17.28.2-rc.1+c89471e1f",
45
- "@instructure/quiz-i18n": "17.28.2-rc.1+c89471e1f",
46
- "@instructure/quiz-interactions": "17.28.2-rc.1+c89471e1f",
47
- "@instructure/quiz-number-input": "17.28.2-rc.1+c89471e1f",
48
- "@instructure/quiz-rce": "17.28.2-rc.1+c89471e1f",
44
+ "@instructure/quiz-common": "17.28.2-rc.2+b632a9c42",
45
+ "@instructure/quiz-i18n": "17.28.2-rc.2+b632a9c42",
46
+ "@instructure/quiz-interactions": "17.28.2-rc.2+b632a9c42",
47
+ "@instructure/quiz-number-input": "17.28.2-rc.2+b632a9c42",
48
+ "@instructure/quiz-rce": "17.28.2-rc.2+b632a9c42",
49
49
  "@instructure/ui-a11y-content": "^7.11.0",
50
50
  "@instructure/ui-alerts": "^7.11.0",
51
51
  "@instructure/ui-avatar": "^7.11.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.28.2-rc.1+c89471e1f",
109
+ "instructure-validations": "17.28.2-rc.2+b632a9c42",
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.28.2-rc.1+c89471e1f",
140
+ "@instructure/quiz-scripts": "17.28.2-rc.2+b632a9c42",
141
141
  "@instructure/ui-axe-check": "^7.11.0",
142
142
  "@instructure/ui-babel-preset": "^7.11.0",
143
143
  "@instructure/ui-karma-config": "^7.11.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.28.2-rc.1+c89471e1f",
159
+ "quiz-presets": "17.28.2-rc.2+b632a9c42",
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": "c89471e1fa85bbf18abb341503f405c45ce63a4b"
175
+ "gitHead": "b632a9c42fe35cd0371865e435dec8d1762100e9"
176
176
  }