@instructure/quiz-core 22.10.2 → 22.11.1

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 (43) hide show
  1. package/es/banks/api/banks.js +18 -97
  2. package/es/banks/components/SharingModal/index.js +6 -3
  3. package/es/banks/components/SharingModal/presenter.js +207 -131
  4. package/es/building/api/items.js +120 -24
  5. package/es/building/api/quizEntries.js +78 -15
  6. package/es/building/components/resources/quizEntry/QuizEntryShow/presenter.js +11 -2
  7. package/es/common/actions/sharedBanks.js +13 -1
  8. package/es/common/actions/sharingModal.js +7 -0
  9. package/es/common/components/resources/quiz/AddContent/Body/index.js +1 -1
  10. package/es/common/components/resources/quiz/AddContent/Body/presenter.js +129 -141
  11. package/es/common/components/resources/quiz/AddContent/Modal/presenter.js +59 -72
  12. package/es/common/components/resources/quiz/AddContent/Popover/presenter.js +126 -119
  13. package/es/common/components/shared/InteractionTypes/index.js +1 -4
  14. package/es/common/components/shared/InteractionTypes/presenter.js +1 -3
  15. package/es/common/middleware/sharedBanksMiddleware.js +243 -0
  16. package/es/common/records/Item.js +2 -1
  17. package/es/common/records/QuizEntry.js +7 -0
  18. package/es/common/reducers/sharingModal.js +17 -0
  19. package/es/common/util/useRemoteComponent.js +127 -0
  20. package/es/configureStore.js +4 -1
  21. package/es/index.js +3 -2
  22. package/lib/banks/api/banks.js +17 -96
  23. package/lib/banks/components/SharingModal/index.js +5 -2
  24. package/lib/banks/components/SharingModal/presenter.js +205 -129
  25. package/lib/building/api/items.js +120 -23
  26. package/lib/building/api/quizEntries.js +78 -14
  27. package/lib/building/components/resources/quizEntry/QuizEntryShow/presenter.js +10 -1
  28. package/lib/common/actions/sharedBanks.js +13 -1
  29. package/lib/common/actions/sharingModal.js +13 -0
  30. package/lib/common/components/resources/quiz/AddContent/Body/index.js +1 -1
  31. package/lib/common/components/resources/quiz/AddContent/Body/presenter.js +132 -141
  32. package/lib/common/components/resources/quiz/AddContent/Modal/presenter.js +59 -74
  33. package/lib/common/components/resources/quiz/AddContent/Popover/presenter.js +127 -119
  34. package/lib/common/components/shared/InteractionTypes/index.js +1 -4
  35. package/lib/common/components/shared/InteractionTypes/presenter.js +1 -3
  36. package/lib/common/middleware/sharedBanksMiddleware.js +250 -0
  37. package/lib/common/records/Item.js +2 -1
  38. package/lib/common/records/QuizEntry.js +7 -0
  39. package/lib/common/reducers/sharingModal.js +23 -0
  40. package/lib/common/util/useRemoteComponent.js +134 -0
  41. package/lib/configureStore.js +4 -1
  42. package/lib/index.js +22 -0
  43. package/package.json +8 -8
@@ -1,125 +1,135 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
4
- import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
5
- import _inherits from "@babel/runtime/helpers/esm/inherits";
6
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- var _dec, _class, _AddContentPopover;
8
- function _callSuper(_this, derived, args) {
9
- function isNativeReflectConstruct() {
10
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
11
- if (Reflect.construct.sham) return false;
12
- if (typeof Proxy === "function") return true;
13
- try {
14
- return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
15
- } catch (e) {
16
- return false;
17
- }
18
- }
19
- derived = _getPrototypeOf(derived);
20
- return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
21
- }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
22
4
  /** @jsx jsx */
23
- import { Component } from 'react';
24
- import PropTypes from 'prop-types';
25
- import { Popover } from '@instructure/ui-popover';
26
5
  import { jsx } from '@instructure/emotion';
6
+ import { DELETED_QUIZ_ENTRY, withStyleOverrides } from '@instructure/quiz-common';
7
+ import { Popover } from '@instructure/ui-popover';
8
+ import PropTypes from 'prop-types';
9
+ import React, { useCallback, useEffect, useRef } from 'react';
10
+ import { bindActionCreators } from 'redux';
11
+ import { createBulkItems } from '../../../../../../building/api/items';
12
+ import { createBulkQuizEntries } from '../../../../../../building/api/quizEntries';
13
+ import { addAlert } from '../../../../../../common/actions/alerts';
14
+ import { connect } from '../../../../../../common/react-redux';
27
15
  import CustomPropTypes from '../../../../../util/CustomPropTypes';
28
16
  import { onPhone, onTablet } from '../../../../../util/windowChecks';
29
- import AddContentButton from '../Button';
30
17
  import AddContentBody from '../Body';
31
- import { DELETED_QUIZ_ENTRY, withStyleOverrides } from '@instructure/quiz-common';
18
+ import AddContentButton from '../Button';
32
19
  import generateStyle from './styles';
33
20
  import generateComponentTheme from './theme';
34
- export var AddContentPopover = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_AddContentPopover = /*#__PURE__*/function (_Component) {
35
- function AddContentPopover() {
36
- var _this2;
37
- _classCallCheck(this, AddContentPopover);
38
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
39
- args[_key] = arguments[_key];
21
+ import { quizGenerationButtonPropTypes } from '../Body/presenter';
22
+ function UnstyledAddContentPopover(_ref) {
23
+ var _ref$allowStimulusCre = _ref.allowStimulusCreation,
24
+ allowStimulusCreation = _ref$allowStimulusCre === void 0 ? true : _ref$allowStimulusCre,
25
+ clearUi = _ref.clearUi,
26
+ isEditing = _ref.isEditing,
27
+ _ref$isMobile = _ref.isMobile,
28
+ isMobile = _ref$isMobile === void 0 ? onPhone() || onTablet() : _ref$isMobile,
29
+ openAddContentModal = _ref.openAddContentModal,
30
+ _ref$parentEntryId = _ref.parentEntryId,
31
+ parentEntryId = _ref$parentEntryId === void 0 ? null : _ref$parentEntryId,
32
+ position = _ref.position,
33
+ quizId = _ref.quizId,
34
+ shouldFocus = _ref.shouldFocus,
35
+ _ref$stimulusId = _ref.stimulusId,
36
+ stimulusId = _ref$stimulusId === void 0 ? null : _ref$stimulusId,
37
+ switchOffEditing = _ref.switchOffEditing,
38
+ switchOnEditing = _ref.switchOnEditing,
39
+ _ref$useStimulusTrigg = _ref.useStimulusTrigger,
40
+ useStimulusTrigger = _ref$useStimulusTrigg === void 0 ? false : _ref$useStimulusTrigg,
41
+ styles = _ref.styles,
42
+ _ref$slotProps = _ref.slotProps,
43
+ slotProps = _ref$slotProps === void 0 ? {} : _ref$slotProps;
44
+ var popoverTrigger = useRef(null);
45
+ useEffect(function () {
46
+ if (shouldFocus) {
47
+ setTimeout(function () {
48
+ if (popoverTrigger.current) popoverTrigger.current.focus();
49
+ clearUi(DELETED_QUIZ_ENTRY);
50
+ }, 100);
40
51
  }
41
- _this2 = _callSuper(this, AddContentPopover, [].concat(args));
42
- _defineProperty(_this2, "showContent", function () {
43
- _this2.props.switchOnEditing();
44
- });
45
- _defineProperty(_this2, "hideContent", function () {
46
- _this2.props.switchOffEditing();
47
- });
48
- _defineProperty(_this2, "storePopoverTriggerRef", function (b) {
49
- _this2.popoverTrigger = b;
50
- });
51
- _defineProperty(_this2, "renderPopoverButton", function () {
52
- return jsx(Popover, {
53
- on: "click",
54
- onShowContent: _this2.showContent,
55
- onHideContent: _this2.hideContent,
56
- isShowingContent: _this2.props.isEditing,
57
- shouldCloseOnEscape: true,
58
- shouldContainFocus: true,
59
- renderTrigger: _this2.renderAddContentButton()
60
- }, jsx(AddContentBody, {
61
- allowStimulusCreation: _this2.props.allowStimulusCreation,
62
- onOpenBankTray: _this2.props.switchOffEditing,
63
- onAddItem: _this2.props.switchOffEditing,
64
- parentEntryId: _this2.props.parentEntryId,
65
- position: _this2.props.position,
66
- quizId: _this2.props.quizId,
67
- stimulusId: _this2.props.stimulusId
68
- }));
69
- });
70
- _defineProperty(_this2, "openAddContentModal", function () {
71
- _this2.props.openAddContentModal({
72
- allowStimulusCreation: _this2.props.allowStimulusCreation,
73
- parentEntryId: _this2.props.parentEntryId,
74
- position: _this2.props.position,
75
- quizId: _this2.props.quizId,
76
- stimulusId: _this2.props.stimulusId
77
- });
78
- });
79
- return _this2;
52
+ }, [shouldFocus, clearUi]);
53
+ function handleGenerateWithAiClick() {
54
+ var _slotProps$quizGenera, _slotProps$quizGenera2;
55
+ slotProps === null || slotProps === void 0 || (_slotProps$quizGenera = slotProps.quizGenerationButton) === null || _slotProps$quizGenera === void 0 || (_slotProps$quizGenera2 = _slotProps$quizGenera.onClick) === null || _slotProps$quizGenera2 === void 0 || _slotProps$quizGenera2.call(_slotProps$quizGenera);
56
+ switchOffEditing();
80
57
  }
81
- _inherits(AddContentPopover, _Component);
82
- return _createClass(AddContentPopover, [{
83
- key: "componentDidUpdate",
84
- value: function componentDidUpdate() {
85
- var _this3 = this;
86
- if (this.props.shouldFocus) {
87
- setTimeout(function () {
88
- _this3.popoverTrigger && _this3.popoverTrigger.focus();
89
- _this3.props.clearUi(DELETED_QUIZ_ENTRY);
90
- }, 100); // force after modal attempt to refocus delete button
58
+ var showContent = useCallback(function () {
59
+ switchOnEditing();
60
+ }, [switchOnEditing]);
61
+ var hideContent = useCallback(function () {
62
+ switchOffEditing();
63
+ }, [switchOffEditing]);
64
+ var storePopoverTriggerRef = useCallback(function (b) {
65
+ popoverTrigger.current = b;
66
+ }, []);
67
+ var renderAddContentButton = function renderAddContentButton() {
68
+ var onClick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
69
+ return jsx(AddContentButton, {
70
+ ref: storePopoverTriggerRef,
71
+ onClick: onClick,
72
+ isEditing: isEditing,
73
+ useStimulusTrigger: useStimulusTrigger
74
+ });
75
+ };
76
+ var renderPopoverButton = function renderPopoverButton() {
77
+ return jsx(Popover, {
78
+ on: "click",
79
+ onShowContent: showContent,
80
+ onHideContent: hideContent,
81
+ isShowingContent: isEditing,
82
+ shouldCloseOnEscape: true,
83
+ shouldContainFocus: true,
84
+ renderTrigger: renderAddContentButton()
85
+ }, jsx(AddContentBody, {
86
+ allowStimulusCreation: allowStimulusCreation,
87
+ onOpenBankTray: switchOffEditing,
88
+ onAddItem: switchOffEditing,
89
+ parentEntryId: parentEntryId,
90
+ position: position,
91
+ quizId: quizId,
92
+ stimulusId: stimulusId,
93
+ slotProps: {
94
+ quizGenerationButton: _objectSpread(_objectSpread({}, (slotProps === null || slotProps === void 0 ? void 0 : slotProps.quizGenerationButton) || {}), {}, {
95
+ onClick: handleGenerateWithAiClick
96
+ })
91
97
  }
92
- }
93
- }, {
94
- key: "renderAddContentButton",
95
- value: function renderAddContentButton() {
96
- var onClick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
97
- return jsx(AddContentButton, {
98
- ref: this.storePopoverTriggerRef,
99
- onClick: onClick,
100
- isEditing: this.props.isEditing,
101
- useStimulusTrigger: this.props.useStimulusTrigger
102
- });
103
- }
104
- }, {
105
- key: "renderModalButton",
106
- value: function renderModalButton() {
107
- return this.renderAddContentButton(this.openAddContentModal);
108
- }
109
- }, {
110
- key: "render",
111
- value: function render() {
112
- var borderLine = this.props.useStimulusTrigger ? null : jsx("div", {
113
- css: this.props.styles.borderLine
114
- });
115
- var button = this.props.isMobile ? this.renderModalButton() : this.renderPopoverButton();
116
- return jsx("div", {
117
- css: this.props.styles.wrapper,
118
- "data-automation": "sdk-build-add-content"
119
- }, borderLine, button);
120
- }
121
- }]);
122
- }(Component), _defineProperty(_AddContentPopover, "displayName", 'AddContentPopover'), _defineProperty(_AddContentPopover, "componentId", "Quizzes".concat(_AddContentPopover.displayName)), _defineProperty(_AddContentPopover, "propTypes", {
98
+ }));
99
+ };
100
+ var openAddContentModalHandler = useCallback(function () {
101
+ openAddContentModal({
102
+ allowStimulusCreation: allowStimulusCreation,
103
+ parentEntryId: parentEntryId,
104
+ position: position,
105
+ quizId: quizId,
106
+ stimulusId: stimulusId
107
+ });
108
+ }, [openAddContentModal, allowStimulusCreation, parentEntryId, position, quizId, stimulusId]);
109
+ var renderModalButton = function renderModalButton() {
110
+ return renderAddContentButton(openAddContentModalHandler);
111
+ };
112
+ var borderLine = useStimulusTrigger ? null : jsx("div", {
113
+ css: styles.borderLine
114
+ });
115
+ var button = isMobile ? renderModalButton() : renderPopoverButton();
116
+ return jsx("div", {
117
+ css: styles.wrapper,
118
+ "data-automation": "sdk-build-add-content"
119
+ }, borderLine, button);
120
+ }
121
+ var AddContentPopoverWithStyles = withStyleOverrides(generateStyle, generateComponentTheme)(UnstyledAddContentPopover);
122
+ var mapDispatchToProps = function mapDispatchToProps(dispatch) {
123
+ return {
124
+ addAlert: addAlert,
125
+ createBulkItems: bindActionCreators(createBulkItems, dispatch),
126
+ createBulkQuizEntries: bindActionCreators(createBulkQuizEntries, dispatch)
127
+ };
128
+ };
129
+ export var AddContentPopover = connect(null, mapDispatchToProps)(AddContentPopoverWithStyles);
130
+ AddContentPopover.displayName = 'AddContentPopover';
131
+ AddContentPopover.componentId = "Quizzes".concat(AddContentPopover.displayName);
132
+ AddContentPopover.propTypes = {
123
133
  appContainer: CustomPropTypes.selectors.isRequired,
124
134
  allowStimulusCreation: PropTypes.bool,
125
135
  clearUi: PropTypes.func.isRequired,
@@ -134,12 +144,9 @@ export var AddContentPopover = (_dec = withStyleOverrides(generateStyle, generat
134
144
  switchOffEditing: PropTypes.func.isRequired,
135
145
  switchOnEditing: PropTypes.func.isRequired,
136
146
  useStimulusTrigger: PropTypes.bool,
137
- styles: PropTypes.object
138
- }), _defineProperty(_AddContentPopover, "defaultProps", {
139
- allowStimulusCreation: true,
140
- isMobile: onPhone() || onTablet(),
141
- parentEntryId: null,
142
- stimulusId: null,
143
- useStimulusTrigger: false
144
- }), _AddContentPopover)) || _class);
147
+ styles: PropTypes.object,
148
+ slotProps: PropTypes.shape({
149
+ quizGenerationButton: quizGenerationButtonPropTypes
150
+ })
151
+ };
145
152
  export default AddContentPopover;
@@ -1,9 +1,6 @@
1
1
  import { connect } from '../../../react-redux';
2
2
  import InteractionTypes from './presenter';
3
- import { featureOn } from '../../../../common/util/featureCheck';
4
3
  function mapStateToProps(state) {
5
- return {
6
- allowPassageCreation: featureOn('passage')
7
- };
4
+ return {};
8
5
  }
9
6
  export default connect(mapStateToProps)(InteractionTypes);
@@ -146,7 +146,7 @@ export var InteractionTypes = (_dec = withStyleOverrides(generateStyle, generate
146
146
  }, _this2.renderInteractionTypeButton({
147
147
  name: 'Stimulus',
148
148
  slug: 'stimulus'
149
- })), _this2.props.allowPassageCreation && jsx(Grid.Col, {
149
+ })), jsx(Grid.Col, {
150
150
  width: 12 / _this2.props.columns,
151
151
  key: "passage"
152
152
  }, _this2.renderInteractionTypeButton({
@@ -174,12 +174,10 @@ export var InteractionTypes = (_dec = withStyleOverrides(generateStyle, generate
174
174
  addItem: PropTypes.func.isRequired,
175
175
  addStimulus: PropTypes.func.isRequired,
176
176
  allowStimulusCreation: PropTypes.bool,
177
- allowPassageCreation: PropTypes.bool,
178
177
  types: ImmutablePropTypes.list,
179
178
  styles: PropTypes.object
180
179
  }), _defineProperty(_InteractionTypes, "defaultProps", {
181
180
  allowStimulusCreation: true,
182
- allowPassageCreation: false,
183
181
  types: List()
184
182
  }), _InteractionTypes)) || _class);
185
183
  export default InteractionTypes;
@@ -0,0 +1,243 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+ import Fetcher from '../util/Fetcher';
4
+ import t from '@instructure/quiz-i18n/es/format-message';
5
+ import { handleError } from '../api/helpers';
6
+ import { handleShareBanksResponse } from '../api/callHandlers';
7
+ import { CAN_EDIT, SHARED_WITH_USER, SHARED_WITH_COURSE, SHARED_WITH_ACCOUNT, GET_SHARED_BANKS } from '@instructure/quiz-common';
8
+ import { sharedBankLoadingAction } from '../../common/actions/sharingModal';
9
+ var banksApiEndpoint = '/api/banks';
10
+ var chunkSize = 200;
11
+ function getAllinfo(_x, _x2) {
12
+ return _getAllinfo.apply(this, arguments);
13
+ }
14
+ function _getAllinfo() {
15
+ _getAllinfo = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(func, uuids) {
16
+ var info, i, nextChunk, nextData, result;
17
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
18
+ while (1) switch (_context2.prev = _context2.next) {
19
+ case 0:
20
+ info = [];
21
+ for (i = 0; i < uuids.length; i += chunkSize) {
22
+ nextChunk = uuids.slice(i, i + chunkSize);
23
+ nextData = func(nextChunk);
24
+ info.push(nextData);
25
+ }
26
+ _context2.prev = 2;
27
+ _context2.next = 5;
28
+ return Promise.all(info);
29
+ case 5:
30
+ result = _context2.sent;
31
+ return _context2.abrupt("return", result.flat());
32
+ case 9:
33
+ _context2.prev = 9;
34
+ _context2.t0 = _context2["catch"](2);
35
+ console.error('Error fetching user info', _context2.t0);
36
+ return _context2.abrupt("return", []);
37
+ case 13:
38
+ case "end":
39
+ return _context2.stop();
40
+ }
41
+ }, _callee2, null, [[2, 9]]);
42
+ }));
43
+ return _getAllinfo.apply(this, arguments);
44
+ }
45
+ function getSharedBankUsers(_x3, _x4) {
46
+ return _getSharedBankUsers.apply(this, arguments);
47
+ }
48
+ function _getSharedBankUsers() {
49
+ _getSharedBankUsers = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(sharedBanksInfo, getUserInfo) {
50
+ var userSharedBanks, userUuids, usersInfo;
51
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
52
+ while (1) switch (_context3.prev = _context3.next) {
53
+ case 0:
54
+ userSharedBanks = [];
55
+ userUuids = sharedBanksInfo.filter(function (sb) {
56
+ return sb.entity_type === SHARED_WITH_USER;
57
+ }).map(function (sb) {
58
+ return sb.entity_id;
59
+ });
60
+ _context3.next = 4;
61
+ return getAllinfo(getUserInfo, userUuids);
62
+ case 4:
63
+ usersInfo = _context3.sent;
64
+ usersInfo.forEach(function (userInfo) {
65
+ var sharedBankInfo = sharedBanksInfo.find(function (sb) {
66
+ return sb.entity_type === SHARED_WITH_USER && sb.entity_id === userInfo.uuid;
67
+ });
68
+ if (sharedBankInfo) {
69
+ userSharedBanks.push({
70
+ id: sharedBankInfo.id,
71
+ entityType: sharedBankInfo.entity_type,
72
+ entityId: sharedBankInfo.entity_id,
73
+ title: userInfo.fullName,
74
+ avatar: userInfo.avatar,
75
+ permission: sharedBankInfo.permission,
76
+ bankId: sharedBankInfo.bank_id
77
+ });
78
+ }
79
+ });
80
+ return _context3.abrupt("return", userSharedBanks);
81
+ case 7:
82
+ case "end":
83
+ return _context3.stop();
84
+ }
85
+ }, _callee3);
86
+ }));
87
+ return _getSharedBankUsers.apply(this, arguments);
88
+ }
89
+ function getSharedBankCourses(_x5, _x6) {
90
+ return _getSharedBankCourses.apply(this, arguments);
91
+ }
92
+ function _getSharedBankCourses() {
93
+ _getSharedBankCourses = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(sharedBanksInfo, getCourseInfo) {
94
+ var courseSharedBanks, courseUuids, coursesInfo;
95
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
96
+ while (1) switch (_context4.prev = _context4.next) {
97
+ case 0:
98
+ courseSharedBanks = [];
99
+ courseUuids = sharedBanksInfo.filter(function (sb) {
100
+ return sb.entity_type === SHARED_WITH_COURSE;
101
+ }).map(function (sb) {
102
+ return sb.entity_id;
103
+ });
104
+ _context4.next = 4;
105
+ return getAllinfo(getCourseInfo, courseUuids);
106
+ case 4:
107
+ coursesInfo = _context4.sent;
108
+ coursesInfo.forEach(function (courseInfo) {
109
+ var sharedBankInfo = sharedBanksInfo.find(function (sb) {
110
+ return sb.entity_type === SHARED_WITH_COURSE && sb.entity_id === courseInfo.uuid;
111
+ });
112
+ if (sharedBankInfo) {
113
+ courseSharedBanks.push({
114
+ id: sharedBankInfo.id,
115
+ entityType: sharedBankInfo.entity_type,
116
+ entityId: sharedBankInfo.entity_id,
117
+ title: courseInfo.title,
118
+ permission: sharedBankInfo.permission,
119
+ bankId: sharedBankInfo.bank_id
120
+ });
121
+ }
122
+ });
123
+ return _context4.abrupt("return", courseSharedBanks);
124
+ case 7:
125
+ case "end":
126
+ return _context4.stop();
127
+ }
128
+ }, _callee4);
129
+ }));
130
+ return _getSharedBankCourses.apply(this, arguments);
131
+ }
132
+ function getSharedBankAccounts(_x7, _x8) {
133
+ return _getSharedBankAccounts.apply(this, arguments);
134
+ }
135
+ function _getSharedBankAccounts() {
136
+ _getSharedBankAccounts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(sharedBanksInfo, getAccountInfo) {
137
+ var accountSharedBanks, accountUuids, accountsInfo;
138
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
139
+ while (1) switch (_context5.prev = _context5.next) {
140
+ case 0:
141
+ accountSharedBanks = [];
142
+ accountUuids = sharedBanksInfo.filter(function (sb) {
143
+ return sb.entity_type === SHARED_WITH_ACCOUNT;
144
+ }).map(function (sb) {
145
+ return sb.entity_id;
146
+ });
147
+ _context5.next = 4;
148
+ return getAllinfo(getAccountInfo, accountUuids);
149
+ case 4:
150
+ accountsInfo = _context5.sent;
151
+ accountsInfo.forEach(function (accountInfo) {
152
+ var sharedBankInfo = sharedBanksInfo.find(function (sb) {
153
+ return sb.entity_type === SHARED_WITH_ACCOUNT && sb.entity_id === accountInfo.uuid;
154
+ });
155
+ if (sharedBankInfo) {
156
+ accountSharedBanks.push({
157
+ id: sharedBankInfo.id,
158
+ entityType: sharedBankInfo.entity_type,
159
+ entityId: sharedBankInfo.entity_id,
160
+ title: accountInfo.name,
161
+ permission: sharedBankInfo.permission,
162
+ bankId: sharedBankInfo.bank_id
163
+ });
164
+ }
165
+ });
166
+ return _context5.abrupt("return", accountSharedBanks);
167
+ case 7:
168
+ case "end":
169
+ return _context5.stop();
170
+ }
171
+ }, _callee5);
172
+ }));
173
+ return _getSharedBankAccounts.apply(this, arguments);
174
+ }
175
+ export var createSharedBanksMiddleware = function createSharedBanksMiddleware() {
176
+ return function (store) {
177
+ return function (next) {
178
+ return /*#__PURE__*/function () {
179
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(action) {
180
+ var _action$payload, bank, getUserInfo, getCourseInfo, getAccountInfo, dispatch, url, startLoading, fetcher, sharedBanksInfo, users, courses, accounts, endLoading;
181
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
182
+ while (1) switch (_context.prev = _context.next) {
183
+ case 0:
184
+ if (!(action.type === GET_SHARED_BANKS)) {
185
+ _context.next = 23;
186
+ break;
187
+ }
188
+ _action$payload = action.payload, bank = _action$payload.bank, getUserInfo = _action$payload.getUserInfo, getCourseInfo = _action$payload.getCourseInfo, getAccountInfo = _action$payload.getAccountInfo;
189
+ dispatch = store.dispatch;
190
+ url = "".concat(banksApiEndpoint, "/").concat(bank.id, "/shared_banks");
191
+ startLoading = {
192
+ loading: true
193
+ };
194
+ dispatch(sharedBankLoadingAction(startLoading));
195
+ fetcher = new Fetcher({
196
+ onError: handleError(dispatch, t('Failed to fetch shared banks.'))
197
+ });
198
+ _context.next = 9;
199
+ return fetcher.get(url);
200
+ case 9:
201
+ sharedBanksInfo = _context.sent;
202
+ // Add bank creator if no data
203
+ if (sharedBanksInfo.length === 0) {
204
+ sharedBanksInfo.push({
205
+ id: '-1',
206
+ entity_type: SHARED_WITH_USER,
207
+ entity_id: bank.creator,
208
+ permission: CAN_EDIT,
209
+ bank_id: bank.id
210
+ });
211
+ }
212
+ _context.next = 13;
213
+ return getSharedBankUsers(sharedBanksInfo, getUserInfo);
214
+ case 13:
215
+ users = _context.sent;
216
+ _context.next = 16;
217
+ return getSharedBankCourses(sharedBanksInfo, getCourseInfo);
218
+ case 16:
219
+ courses = _context.sent;
220
+ _context.next = 19;
221
+ return getSharedBankAccounts(sharedBanksInfo, getAccountInfo);
222
+ case 19:
223
+ accounts = _context.sent;
224
+ dispatch(handleShareBanksResponse(users.concat(courses).concat(accounts)));
225
+ endLoading = {
226
+ loading: false
227
+ };
228
+ dispatch(sharedBankLoadingAction(endLoading));
229
+ case 23:
230
+ return _context.abrupt("return", next(action));
231
+ case 24:
232
+ case "end":
233
+ return _context.stop();
234
+ }
235
+ }, _callee);
236
+ }));
237
+ return function (_x9) {
238
+ return _ref.apply(this, arguments);
239
+ };
240
+ }();
241
+ };
242
+ };
243
+ };
@@ -142,6 +142,7 @@ export var Item = /*#__PURE__*/function (_ReduxRecord) {
142
142
  feedback: Map(),
143
143
  answerFeedback: Map(),
144
144
  stimulusId: null,
145
- calculatorType: 'none'
145
+ calculatorType: 'none',
146
+ metadata: Map()
146
147
  }));
147
148
  export default Item;
@@ -307,6 +307,13 @@ export var QuizEntry = (_dec = withStateCache(function () {
307
307
  get: function get() {
308
308
  return !isNaN(parseInt(this.stimulusQuizEntryId, 10));
309
309
  }
310
+ }, {
311
+ key: "isAiGenerated",
312
+ get: function get() {
313
+ var _this$getEntry;
314
+ var tags = ((_this$getEntry = this.getEntry()) === null || _this$getEntry === void 0 || (_this$getEntry = _this$getEntry.metadata) === null || _this$getEntry === void 0 ? void 0 : _this$getEntry.get('tags', List())) || List();
315
+ return tags.includes('ai-generated');
316
+ }
310
317
  }, {
311
318
  key: "isTemporary",
312
319
  get: function get() {
@@ -0,0 +1,17 @@
1
+ import { fromJS } from 'immutable';
2
+ import { CHANGE_MODAL_LOADING } from '@instructure/quiz-common';
3
+ var changeLoading = function changeLoading(state, payload) {
4
+ return state.merge({
5
+ loading: payload.loading !== undefined ? payload.loading : state.loading
6
+ });
7
+ };
8
+ export default (function () {
9
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : fromJS({});
10
+ var action = arguments.length > 1 ? arguments[1] : undefined;
11
+ switch (action.type) {
12
+ case CHANGE_MODAL_LOADING:
13
+ return changeLoading(state, action.payload);
14
+ default:
15
+ return state;
16
+ }
17
+ });