@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.
- package/es/banks/api/banks.js +18 -97
- package/es/banks/components/SharingModal/index.js +6 -3
- package/es/banks/components/SharingModal/presenter.js +207 -131
- package/es/building/api/items.js +120 -24
- package/es/building/api/quizEntries.js +78 -15
- package/es/building/components/resources/quizEntry/QuizEntryShow/presenter.js +11 -2
- package/es/common/actions/sharedBanks.js +13 -1
- package/es/common/actions/sharingModal.js +7 -0
- package/es/common/components/resources/quiz/AddContent/Body/index.js +1 -1
- package/es/common/components/resources/quiz/AddContent/Body/presenter.js +129 -141
- package/es/common/components/resources/quiz/AddContent/Modal/presenter.js +59 -72
- package/es/common/components/resources/quiz/AddContent/Popover/presenter.js +126 -119
- package/es/common/components/shared/InteractionTypes/index.js +1 -4
- package/es/common/components/shared/InteractionTypes/presenter.js +1 -3
- package/es/common/middleware/sharedBanksMiddleware.js +243 -0
- package/es/common/records/Item.js +2 -1
- package/es/common/records/QuizEntry.js +7 -0
- package/es/common/reducers/sharingModal.js +17 -0
- package/es/common/util/useRemoteComponent.js +127 -0
- package/es/configureStore.js +4 -1
- package/es/index.js +3 -2
- package/lib/banks/api/banks.js +17 -96
- package/lib/banks/components/SharingModal/index.js +5 -2
- package/lib/banks/components/SharingModal/presenter.js +205 -129
- package/lib/building/api/items.js +120 -23
- package/lib/building/api/quizEntries.js +78 -14
- package/lib/building/components/resources/quizEntry/QuizEntryShow/presenter.js +10 -1
- package/lib/common/actions/sharedBanks.js +13 -1
- package/lib/common/actions/sharingModal.js +13 -0
- package/lib/common/components/resources/quiz/AddContent/Body/index.js +1 -1
- package/lib/common/components/resources/quiz/AddContent/Body/presenter.js +132 -141
- package/lib/common/components/resources/quiz/AddContent/Modal/presenter.js +59 -74
- package/lib/common/components/resources/quiz/AddContent/Popover/presenter.js +127 -119
- package/lib/common/components/shared/InteractionTypes/index.js +1 -4
- package/lib/common/components/shared/InteractionTypes/presenter.js +1 -3
- package/lib/common/middleware/sharedBanksMiddleware.js +250 -0
- package/lib/common/records/Item.js +2 -1
- package/lib/common/records/QuizEntry.js +7 -0
- package/lib/common/reducers/sharingModal.js +23 -0
- package/lib/common/util/useRemoteComponent.js +134 -0
- package/lib/configureStore.js +4 -1
- package/lib/index.js +22 -0
- 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
|
|
8
|
-
function
|
|
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
|
|
18
|
+
import AddContentButton from '../Button';
|
|
32
19
|
import generateStyle from './styles';
|
|
33
20
|
import generateComponentTheme from './theme';
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
}
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
})),
|
|
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
|
+
};
|
|
@@ -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
|
+
});
|