@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
|
@@ -5,128 +5,139 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = exports.AddContentPopover = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
var _react = require("react");
|
|
15
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
-
var _uiPopover = require("@instructure/ui-popover");
|
|
17
9
|
var _emotion = require("@instructure/emotion");
|
|
10
|
+
var _quizCommon = require("@instructure/quiz-common");
|
|
11
|
+
var _uiPopover = require("@instructure/ui-popover");
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _redux = require("redux");
|
|
15
|
+
var _items = require("../../../../../../building/api/items");
|
|
16
|
+
var _quizEntries = require("../../../../../../building/api/quizEntries");
|
|
17
|
+
var _alerts = require("../../../../../../common/actions/alerts");
|
|
18
|
+
var _reactRedux = require("../../../../../../common/react-redux");
|
|
18
19
|
var _CustomPropTypes = _interopRequireDefault(require("../../../../../util/CustomPropTypes"));
|
|
19
20
|
var _windowChecks = require("../../../../../util/windowChecks");
|
|
20
|
-
var _Button = _interopRequireDefault(require("../Button"));
|
|
21
21
|
var _Body = _interopRequireDefault(require("../Body"));
|
|
22
|
-
var
|
|
22
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
23
23
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
24
24
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
var _presenter = require("../Body/presenter");
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
28
|
+
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; }
|
|
29
|
+
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) { (0, _defineProperty2["default"])(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; } /** @jsx jsx */
|
|
30
|
+
function UnstyledAddContentPopover(_ref) {
|
|
31
|
+
var _ref$allowStimulusCre = _ref.allowStimulusCreation,
|
|
32
|
+
allowStimulusCreation = _ref$allowStimulusCre === void 0 ? true : _ref$allowStimulusCre,
|
|
33
|
+
clearUi = _ref.clearUi,
|
|
34
|
+
isEditing = _ref.isEditing,
|
|
35
|
+
_ref$isMobile = _ref.isMobile,
|
|
36
|
+
isMobile = _ref$isMobile === void 0 ? (0, _windowChecks.onPhone)() || (0, _windowChecks.onTablet)() : _ref$isMobile,
|
|
37
|
+
openAddContentModal = _ref.openAddContentModal,
|
|
38
|
+
_ref$parentEntryId = _ref.parentEntryId,
|
|
39
|
+
parentEntryId = _ref$parentEntryId === void 0 ? null : _ref$parentEntryId,
|
|
40
|
+
position = _ref.position,
|
|
41
|
+
quizId = _ref.quizId,
|
|
42
|
+
shouldFocus = _ref.shouldFocus,
|
|
43
|
+
_ref$stimulusId = _ref.stimulusId,
|
|
44
|
+
stimulusId = _ref$stimulusId === void 0 ? null : _ref$stimulusId,
|
|
45
|
+
switchOffEditing = _ref.switchOffEditing,
|
|
46
|
+
switchOnEditing = _ref.switchOnEditing,
|
|
47
|
+
_ref$useStimulusTrigg = _ref.useStimulusTrigger,
|
|
48
|
+
useStimulusTrigger = _ref$useStimulusTrigg === void 0 ? false : _ref$useStimulusTrigg,
|
|
49
|
+
styles = _ref.styles,
|
|
50
|
+
_ref$slotProps = _ref.slotProps,
|
|
51
|
+
slotProps = _ref$slotProps === void 0 ? {} : _ref$slotProps;
|
|
52
|
+
var popoverTrigger = (0, _react.useRef)(null);
|
|
53
|
+
(0, _react.useEffect)(function () {
|
|
54
|
+
if (shouldFocus) {
|
|
55
|
+
setTimeout(function () {
|
|
56
|
+
if (popoverTrigger.current) popoverTrigger.current.focus();
|
|
57
|
+
clearUi(_quizCommon.DELETED_QUIZ_ENTRY);
|
|
58
|
+
}, 100);
|
|
36
59
|
}
|
|
60
|
+
}, [shouldFocus, clearUi]);
|
|
61
|
+
function handleGenerateWithAiClick() {
|
|
62
|
+
var _slotProps$quizGenera, _slotProps$quizGenera2;
|
|
63
|
+
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);
|
|
64
|
+
switchOffEditing();
|
|
37
65
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(0,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
66
|
+
var showContent = (0, _react.useCallback)(function () {
|
|
67
|
+
switchOnEditing();
|
|
68
|
+
}, [switchOnEditing]);
|
|
69
|
+
var hideContent = (0, _react.useCallback)(function () {
|
|
70
|
+
switchOffEditing();
|
|
71
|
+
}, [switchOffEditing]);
|
|
72
|
+
var storePopoverTriggerRef = (0, _react.useCallback)(function (b) {
|
|
73
|
+
popoverTrigger.current = b;
|
|
74
|
+
}, []);
|
|
75
|
+
var renderAddContentButton = function renderAddContentButton() {
|
|
76
|
+
var onClick = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
77
|
+
return (0, _emotion.jsx)(_Button["default"], {
|
|
78
|
+
ref: storePopoverTriggerRef,
|
|
79
|
+
onClick: onClick,
|
|
80
|
+
isEditing: isEditing,
|
|
81
|
+
useStimulusTrigger: useStimulusTrigger
|
|
54
82
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(0, _defineProperty2["default"])(_this2, "openAddContentModal", function () {
|
|
78
|
-
_this2.props.openAddContentModal({
|
|
79
|
-
allowStimulusCreation: _this2.props.allowStimulusCreation,
|
|
80
|
-
parentEntryId: _this2.props.parentEntryId,
|
|
81
|
-
position: _this2.props.position,
|
|
82
|
-
quizId: _this2.props.quizId,
|
|
83
|
-
stimulusId: _this2.props.stimulusId
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
return _this2;
|
|
87
|
-
}
|
|
88
|
-
(0, _inherits2["default"])(AddContentPopover, _Component);
|
|
89
|
-
return (0, _createClass2["default"])(AddContentPopover, [{
|
|
90
|
-
key: "componentDidUpdate",
|
|
91
|
-
value: function componentDidUpdate() {
|
|
92
|
-
var _this3 = this;
|
|
93
|
-
if (this.props.shouldFocus) {
|
|
94
|
-
setTimeout(function () {
|
|
95
|
-
_this3.popoverTrigger && _this3.popoverTrigger.focus();
|
|
96
|
-
_this3.props.clearUi(_quizCommon.DELETED_QUIZ_ENTRY);
|
|
97
|
-
}, 100); // force after modal attempt to refocus delete button
|
|
83
|
+
};
|
|
84
|
+
var renderPopoverButton = function renderPopoverButton() {
|
|
85
|
+
return (0, _emotion.jsx)(_uiPopover.Popover, {
|
|
86
|
+
on: "click",
|
|
87
|
+
onShowContent: showContent,
|
|
88
|
+
onHideContent: hideContent,
|
|
89
|
+
isShowingContent: isEditing,
|
|
90
|
+
shouldCloseOnEscape: true,
|
|
91
|
+
shouldContainFocus: true,
|
|
92
|
+
renderTrigger: renderAddContentButton()
|
|
93
|
+
}, (0, _emotion.jsx)(_Body["default"], {
|
|
94
|
+
allowStimulusCreation: allowStimulusCreation,
|
|
95
|
+
onOpenBankTray: switchOffEditing,
|
|
96
|
+
onAddItem: switchOffEditing,
|
|
97
|
+
parentEntryId: parentEntryId,
|
|
98
|
+
position: position,
|
|
99
|
+
quizId: quizId,
|
|
100
|
+
stimulusId: stimulusId,
|
|
101
|
+
slotProps: {
|
|
102
|
+
quizGenerationButton: _objectSpread(_objectSpread({}, (slotProps === null || slotProps === void 0 ? void 0 : slotProps.quizGenerationButton) || {}), {}, {
|
|
103
|
+
onClick: handleGenerateWithAiClick
|
|
104
|
+
})
|
|
98
105
|
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
}
|
|
106
|
+
}));
|
|
107
|
+
};
|
|
108
|
+
var openAddContentModalHandler = (0, _react.useCallback)(function () {
|
|
109
|
+
openAddContentModal({
|
|
110
|
+
allowStimulusCreation: allowStimulusCreation,
|
|
111
|
+
parentEntryId: parentEntryId,
|
|
112
|
+
position: position,
|
|
113
|
+
quizId: quizId,
|
|
114
|
+
stimulusId: stimulusId
|
|
115
|
+
});
|
|
116
|
+
}, [openAddContentModal, allowStimulusCreation, parentEntryId, position, quizId, stimulusId]);
|
|
117
|
+
var renderModalButton = function renderModalButton() {
|
|
118
|
+
return renderAddContentButton(openAddContentModalHandler);
|
|
119
|
+
};
|
|
120
|
+
var borderLine = useStimulusTrigger ? null : (0, _emotion.jsx)("div", {
|
|
121
|
+
css: styles.borderLine
|
|
122
|
+
});
|
|
123
|
+
var button = isMobile ? renderModalButton() : renderPopoverButton();
|
|
124
|
+
return (0, _emotion.jsx)("div", {
|
|
125
|
+
css: styles.wrapper,
|
|
126
|
+
"data-automation": "sdk-build-add-content"
|
|
127
|
+
}, borderLine, button);
|
|
128
|
+
}
|
|
129
|
+
var AddContentPopoverWithStyles = (0, _quizCommon.withStyleOverrides)(_styles["default"], _theme["default"])(UnstyledAddContentPopover);
|
|
130
|
+
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
131
|
+
return {
|
|
132
|
+
addAlert: _alerts.addAlert,
|
|
133
|
+
createBulkItems: (0, _redux.bindActionCreators)(_items.createBulkItems, dispatch),
|
|
134
|
+
createBulkQuizEntries: (0, _redux.bindActionCreators)(_quizEntries.createBulkQuizEntries, dispatch)
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
var AddContentPopover = exports.AddContentPopover = (0, _reactRedux.connect)(null, mapDispatchToProps)(AddContentPopoverWithStyles);
|
|
138
|
+
AddContentPopover.displayName = 'AddContentPopover';
|
|
139
|
+
AddContentPopover.componentId = "Quizzes".concat(AddContentPopover.displayName);
|
|
140
|
+
AddContentPopover.propTypes = {
|
|
130
141
|
appContainer: _CustomPropTypes["default"].selectors.isRequired,
|
|
131
142
|
allowStimulusCreation: _propTypes["default"].bool,
|
|
132
143
|
clearUi: _propTypes["default"].func.isRequired,
|
|
@@ -141,12 +152,9 @@ var AddContentPopover = exports.AddContentPopover = (_dec = (0, _quizCommon.with
|
|
|
141
152
|
switchOffEditing: _propTypes["default"].func.isRequired,
|
|
142
153
|
switchOnEditing: _propTypes["default"].func.isRequired,
|
|
143
154
|
useStimulusTrigger: _propTypes["default"].bool,
|
|
144
|
-
styles: _propTypes["default"].object
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
stimulusId: null,
|
|
150
|
-
useStimulusTrigger: false
|
|
151
|
-
}), _AddContentPopover)) || _class);
|
|
155
|
+
styles: _propTypes["default"].object,
|
|
156
|
+
slotProps: _propTypes["default"].shape({
|
|
157
|
+
quizGenerationButton: _presenter.quizGenerationButtonPropTypes
|
|
158
|
+
})
|
|
159
|
+
};
|
|
152
160
|
var _default = exports["default"] = AddContentPopover;
|
|
@@ -7,10 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _reactRedux = require("../../../react-redux");
|
|
9
9
|
var _presenter = _interopRequireDefault(require("./presenter"));
|
|
10
|
-
var _featureCheck = require("../../../../common/util/featureCheck");
|
|
11
10
|
function mapStateToProps(state) {
|
|
12
|
-
return {
|
|
13
|
-
allowPassageCreation: (0, _featureCheck.featureOn)('passage')
|
|
14
|
-
};
|
|
11
|
+
return {};
|
|
15
12
|
}
|
|
16
13
|
var _default = exports["default"] = (0, _reactRedux.connect)(mapStateToProps)(_presenter["default"]);
|
|
@@ -153,7 +153,7 @@ var InteractionTypes = exports.InteractionTypes = (_dec = (0, _quizCommon.withSt
|
|
|
153
153
|
}, _this2.renderInteractionTypeButton({
|
|
154
154
|
name: 'Stimulus',
|
|
155
155
|
slug: 'stimulus'
|
|
156
|
-
})),
|
|
156
|
+
})), (0, _emotion.jsx)(_uiGrid.Grid.Col, {
|
|
157
157
|
width: 12 / _this2.props.columns,
|
|
158
158
|
key: "passage"
|
|
159
159
|
}, _this2.renderInteractionTypeButton({
|
|
@@ -181,12 +181,10 @@ var InteractionTypes = exports.InteractionTypes = (_dec = (0, _quizCommon.withSt
|
|
|
181
181
|
addItem: _propTypes["default"].func.isRequired,
|
|
182
182
|
addStimulus: _propTypes["default"].func.isRequired,
|
|
183
183
|
allowStimulusCreation: _propTypes["default"].bool,
|
|
184
|
-
allowPassageCreation: _propTypes["default"].bool,
|
|
185
184
|
types: _reactImmutableProptypes["default"].list,
|
|
186
185
|
styles: _propTypes["default"].object
|
|
187
186
|
}), (0, _defineProperty2["default"])(_InteractionTypes, "defaultProps", {
|
|
188
187
|
allowStimulusCreation: true,
|
|
189
|
-
allowPassageCreation: false,
|
|
190
188
|
types: (0, _immutable.List)()
|
|
191
189
|
}), _InteractionTypes)) || _class);
|
|
192
190
|
var _default = exports["default"] = InteractionTypes;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createSharedBanksMiddleware = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _Fetcher = _interopRequireDefault(require("../util/Fetcher"));
|
|
11
|
+
var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
|
|
12
|
+
var _helpers = require("../api/helpers");
|
|
13
|
+
var _callHandlers = require("../api/callHandlers");
|
|
14
|
+
var _quizCommon = require("@instructure/quiz-common");
|
|
15
|
+
var _sharingModal = require("../../common/actions/sharingModal");
|
|
16
|
+
var banksApiEndpoint = '/api/banks';
|
|
17
|
+
var chunkSize = 200;
|
|
18
|
+
function getAllinfo(_x, _x2) {
|
|
19
|
+
return _getAllinfo.apply(this, arguments);
|
|
20
|
+
}
|
|
21
|
+
function _getAllinfo() {
|
|
22
|
+
_getAllinfo = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(func, uuids) {
|
|
23
|
+
var info, i, nextChunk, nextData, result;
|
|
24
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
25
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
26
|
+
case 0:
|
|
27
|
+
info = [];
|
|
28
|
+
for (i = 0; i < uuids.length; i += chunkSize) {
|
|
29
|
+
nextChunk = uuids.slice(i, i + chunkSize);
|
|
30
|
+
nextData = func(nextChunk);
|
|
31
|
+
info.push(nextData);
|
|
32
|
+
}
|
|
33
|
+
_context2.prev = 2;
|
|
34
|
+
_context2.next = 5;
|
|
35
|
+
return Promise.all(info);
|
|
36
|
+
case 5:
|
|
37
|
+
result = _context2.sent;
|
|
38
|
+
return _context2.abrupt("return", result.flat());
|
|
39
|
+
case 9:
|
|
40
|
+
_context2.prev = 9;
|
|
41
|
+
_context2.t0 = _context2["catch"](2);
|
|
42
|
+
console.error('Error fetching user info', _context2.t0);
|
|
43
|
+
return _context2.abrupt("return", []);
|
|
44
|
+
case 13:
|
|
45
|
+
case "end":
|
|
46
|
+
return _context2.stop();
|
|
47
|
+
}
|
|
48
|
+
}, _callee2, null, [[2, 9]]);
|
|
49
|
+
}));
|
|
50
|
+
return _getAllinfo.apply(this, arguments);
|
|
51
|
+
}
|
|
52
|
+
function getSharedBankUsers(_x3, _x4) {
|
|
53
|
+
return _getSharedBankUsers.apply(this, arguments);
|
|
54
|
+
}
|
|
55
|
+
function _getSharedBankUsers() {
|
|
56
|
+
_getSharedBankUsers = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3(sharedBanksInfo, getUserInfo) {
|
|
57
|
+
var userSharedBanks, userUuids, usersInfo;
|
|
58
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
59
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
userSharedBanks = [];
|
|
62
|
+
userUuids = sharedBanksInfo.filter(function (sb) {
|
|
63
|
+
return sb.entity_type === _quizCommon.SHARED_WITH_USER;
|
|
64
|
+
}).map(function (sb) {
|
|
65
|
+
return sb.entity_id;
|
|
66
|
+
});
|
|
67
|
+
_context3.next = 4;
|
|
68
|
+
return getAllinfo(getUserInfo, userUuids);
|
|
69
|
+
case 4:
|
|
70
|
+
usersInfo = _context3.sent;
|
|
71
|
+
usersInfo.forEach(function (userInfo) {
|
|
72
|
+
var sharedBankInfo = sharedBanksInfo.find(function (sb) {
|
|
73
|
+
return sb.entity_type === _quizCommon.SHARED_WITH_USER && sb.entity_id === userInfo.uuid;
|
|
74
|
+
});
|
|
75
|
+
if (sharedBankInfo) {
|
|
76
|
+
userSharedBanks.push({
|
|
77
|
+
id: sharedBankInfo.id,
|
|
78
|
+
entityType: sharedBankInfo.entity_type,
|
|
79
|
+
entityId: sharedBankInfo.entity_id,
|
|
80
|
+
title: userInfo.fullName,
|
|
81
|
+
avatar: userInfo.avatar,
|
|
82
|
+
permission: sharedBankInfo.permission,
|
|
83
|
+
bankId: sharedBankInfo.bank_id
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return _context3.abrupt("return", userSharedBanks);
|
|
88
|
+
case 7:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context3.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee3);
|
|
93
|
+
}));
|
|
94
|
+
return _getSharedBankUsers.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
function getSharedBankCourses(_x5, _x6) {
|
|
97
|
+
return _getSharedBankCourses.apply(this, arguments);
|
|
98
|
+
}
|
|
99
|
+
function _getSharedBankCourses() {
|
|
100
|
+
_getSharedBankCourses = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4(sharedBanksInfo, getCourseInfo) {
|
|
101
|
+
var courseSharedBanks, courseUuids, coursesInfo;
|
|
102
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
103
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
104
|
+
case 0:
|
|
105
|
+
courseSharedBanks = [];
|
|
106
|
+
courseUuids = sharedBanksInfo.filter(function (sb) {
|
|
107
|
+
return sb.entity_type === _quizCommon.SHARED_WITH_COURSE;
|
|
108
|
+
}).map(function (sb) {
|
|
109
|
+
return sb.entity_id;
|
|
110
|
+
});
|
|
111
|
+
_context4.next = 4;
|
|
112
|
+
return getAllinfo(getCourseInfo, courseUuids);
|
|
113
|
+
case 4:
|
|
114
|
+
coursesInfo = _context4.sent;
|
|
115
|
+
coursesInfo.forEach(function (courseInfo) {
|
|
116
|
+
var sharedBankInfo = sharedBanksInfo.find(function (sb) {
|
|
117
|
+
return sb.entity_type === _quizCommon.SHARED_WITH_COURSE && sb.entity_id === courseInfo.uuid;
|
|
118
|
+
});
|
|
119
|
+
if (sharedBankInfo) {
|
|
120
|
+
courseSharedBanks.push({
|
|
121
|
+
id: sharedBankInfo.id,
|
|
122
|
+
entityType: sharedBankInfo.entity_type,
|
|
123
|
+
entityId: sharedBankInfo.entity_id,
|
|
124
|
+
title: courseInfo.title,
|
|
125
|
+
permission: sharedBankInfo.permission,
|
|
126
|
+
bankId: sharedBankInfo.bank_id
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return _context4.abrupt("return", courseSharedBanks);
|
|
131
|
+
case 7:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context4.stop();
|
|
134
|
+
}
|
|
135
|
+
}, _callee4);
|
|
136
|
+
}));
|
|
137
|
+
return _getSharedBankCourses.apply(this, arguments);
|
|
138
|
+
}
|
|
139
|
+
function getSharedBankAccounts(_x7, _x8) {
|
|
140
|
+
return _getSharedBankAccounts.apply(this, arguments);
|
|
141
|
+
}
|
|
142
|
+
function _getSharedBankAccounts() {
|
|
143
|
+
_getSharedBankAccounts = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(sharedBanksInfo, getAccountInfo) {
|
|
144
|
+
var accountSharedBanks, accountUuids, accountsInfo;
|
|
145
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
146
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
147
|
+
case 0:
|
|
148
|
+
accountSharedBanks = [];
|
|
149
|
+
accountUuids = sharedBanksInfo.filter(function (sb) {
|
|
150
|
+
return sb.entity_type === _quizCommon.SHARED_WITH_ACCOUNT;
|
|
151
|
+
}).map(function (sb) {
|
|
152
|
+
return sb.entity_id;
|
|
153
|
+
});
|
|
154
|
+
_context5.next = 4;
|
|
155
|
+
return getAllinfo(getAccountInfo, accountUuids);
|
|
156
|
+
case 4:
|
|
157
|
+
accountsInfo = _context5.sent;
|
|
158
|
+
accountsInfo.forEach(function (accountInfo) {
|
|
159
|
+
var sharedBankInfo = sharedBanksInfo.find(function (sb) {
|
|
160
|
+
return sb.entity_type === _quizCommon.SHARED_WITH_ACCOUNT && sb.entity_id === accountInfo.uuid;
|
|
161
|
+
});
|
|
162
|
+
if (sharedBankInfo) {
|
|
163
|
+
accountSharedBanks.push({
|
|
164
|
+
id: sharedBankInfo.id,
|
|
165
|
+
entityType: sharedBankInfo.entity_type,
|
|
166
|
+
entityId: sharedBankInfo.entity_id,
|
|
167
|
+
title: accountInfo.name,
|
|
168
|
+
permission: sharedBankInfo.permission,
|
|
169
|
+
bankId: sharedBankInfo.bank_id
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return _context5.abrupt("return", accountSharedBanks);
|
|
174
|
+
case 7:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context5.stop();
|
|
177
|
+
}
|
|
178
|
+
}, _callee5);
|
|
179
|
+
}));
|
|
180
|
+
return _getSharedBankAccounts.apply(this, arguments);
|
|
181
|
+
}
|
|
182
|
+
var createSharedBanksMiddleware = exports.createSharedBanksMiddleware = function createSharedBanksMiddleware() {
|
|
183
|
+
return function (store) {
|
|
184
|
+
return function (next) {
|
|
185
|
+
return /*#__PURE__*/function () {
|
|
186
|
+
var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(action) {
|
|
187
|
+
var _action$payload, bank, getUserInfo, getCourseInfo, getAccountInfo, dispatch, url, startLoading, fetcher, sharedBanksInfo, users, courses, accounts, endLoading;
|
|
188
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
189
|
+
while (1) switch (_context.prev = _context.next) {
|
|
190
|
+
case 0:
|
|
191
|
+
if (!(action.type === _quizCommon.GET_SHARED_BANKS)) {
|
|
192
|
+
_context.next = 23;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
_action$payload = action.payload, bank = _action$payload.bank, getUserInfo = _action$payload.getUserInfo, getCourseInfo = _action$payload.getCourseInfo, getAccountInfo = _action$payload.getAccountInfo;
|
|
196
|
+
dispatch = store.dispatch;
|
|
197
|
+
url = "".concat(banksApiEndpoint, "/").concat(bank.id, "/shared_banks");
|
|
198
|
+
startLoading = {
|
|
199
|
+
loading: true
|
|
200
|
+
};
|
|
201
|
+
dispatch((0, _sharingModal.sharedBankLoadingAction)(startLoading));
|
|
202
|
+
fetcher = new _Fetcher["default"]({
|
|
203
|
+
onError: (0, _helpers.handleError)(dispatch, (0, _formatMessage["default"])('Failed to fetch shared banks.'))
|
|
204
|
+
});
|
|
205
|
+
_context.next = 9;
|
|
206
|
+
return fetcher.get(url);
|
|
207
|
+
case 9:
|
|
208
|
+
sharedBanksInfo = _context.sent;
|
|
209
|
+
// Add bank creator if no data
|
|
210
|
+
if (sharedBanksInfo.length === 0) {
|
|
211
|
+
sharedBanksInfo.push({
|
|
212
|
+
id: '-1',
|
|
213
|
+
entity_type: _quizCommon.SHARED_WITH_USER,
|
|
214
|
+
entity_id: bank.creator,
|
|
215
|
+
permission: _quizCommon.CAN_EDIT,
|
|
216
|
+
bank_id: bank.id
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
_context.next = 13;
|
|
220
|
+
return getSharedBankUsers(sharedBanksInfo, getUserInfo);
|
|
221
|
+
case 13:
|
|
222
|
+
users = _context.sent;
|
|
223
|
+
_context.next = 16;
|
|
224
|
+
return getSharedBankCourses(sharedBanksInfo, getCourseInfo);
|
|
225
|
+
case 16:
|
|
226
|
+
courses = _context.sent;
|
|
227
|
+
_context.next = 19;
|
|
228
|
+
return getSharedBankAccounts(sharedBanksInfo, getAccountInfo);
|
|
229
|
+
case 19:
|
|
230
|
+
accounts = _context.sent;
|
|
231
|
+
dispatch((0, _callHandlers.handleShareBanksResponse)(users.concat(courses).concat(accounts)));
|
|
232
|
+
endLoading = {
|
|
233
|
+
loading: false
|
|
234
|
+
};
|
|
235
|
+
dispatch((0, _sharingModal.sharedBankLoadingAction)(endLoading));
|
|
236
|
+
case 23:
|
|
237
|
+
return _context.abrupt("return", next(action));
|
|
238
|
+
case 24:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context.stop();
|
|
241
|
+
}
|
|
242
|
+
}, _callee);
|
|
243
|
+
}));
|
|
244
|
+
return function (_x9) {
|
|
245
|
+
return _ref.apply(this, arguments);
|
|
246
|
+
};
|
|
247
|
+
}();
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
};
|
|
@@ -149,6 +149,7 @@ var Item = exports.Item = /*#__PURE__*/function (_ReduxRecord) {
|
|
|
149
149
|
feedback: (0, _immutable.Map)(),
|
|
150
150
|
answerFeedback: (0, _immutable.Map)(),
|
|
151
151
|
stimulusId: null,
|
|
152
|
-
calculatorType: 'none'
|
|
152
|
+
calculatorType: 'none',
|
|
153
|
+
metadata: (0, _immutable.Map)()
|
|
153
154
|
}));
|
|
154
155
|
var _default = exports["default"] = Item;
|
|
@@ -316,6 +316,13 @@ var QuizEntry = exports.QuizEntry = (_dec = (0, _withStateCache["default"])(func
|
|
|
316
316
|
get: function get() {
|
|
317
317
|
return !isNaN(parseInt(this.stimulusQuizEntryId, 10));
|
|
318
318
|
}
|
|
319
|
+
}, {
|
|
320
|
+
key: "isAiGenerated",
|
|
321
|
+
get: function get() {
|
|
322
|
+
var _this$getEntry;
|
|
323
|
+
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', (0, _immutable.List)())) || (0, _immutable.List)();
|
|
324
|
+
return tags.includes('ai-generated');
|
|
325
|
+
}
|
|
319
326
|
}, {
|
|
320
327
|
key: "isTemporary",
|
|
321
328
|
get: function get() {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _immutable = require("immutable");
|
|
8
|
+
var _quizCommon = require("@instructure/quiz-common");
|
|
9
|
+
var changeLoading = function changeLoading(state, payload) {
|
|
10
|
+
return state.merge({
|
|
11
|
+
loading: payload.loading !== undefined ? payload.loading : state.loading
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var _default = exports["default"] = function _default() {
|
|
15
|
+
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : (0, _immutable.fromJS)({});
|
|
16
|
+
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
17
|
+
switch (action.type) {
|
|
18
|
+
case _quizCommon.CHANGE_MODAL_LOADING:
|
|
19
|
+
return changeLoading(state, action.payload);
|
|
20
|
+
default:
|
|
21
|
+
return state;
|
|
22
|
+
}
|
|
23
|
+
};
|