@instructure/quiz-core 22.10.1 → 22.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/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
|
@@ -4,147 +4,144 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports["default"] = exports.AddContentBody = void 0;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
-
var _react = require("react");
|
|
15
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
-
var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
|
|
17
|
-
var _first = _interopRequireDefault(require("lodash/first"));
|
|
18
|
-
var _uiIcons = require("@instructure/ui-icons");
|
|
7
|
+
exports.quizGenerationButtonPropTypes = exports["default"] = exports.AddContentBody = void 0;
|
|
8
|
+
var _emotion = require("@instructure/emotion");
|
|
9
|
+
var _quizCommon = require("@instructure/quiz-common");
|
|
10
|
+
var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
|
|
19
11
|
var _uiButtons = require("@instructure/ui-buttons");
|
|
20
12
|
var _uiGrid = require("@instructure/ui-grid");
|
|
21
|
-
var
|
|
13
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
22
14
|
var _uiText = require("@instructure/ui-text");
|
|
23
|
-
var
|
|
15
|
+
var _uiView = require("@instructure/ui-view");
|
|
16
|
+
var _first = _interopRequireDefault(require("lodash/first"));
|
|
17
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
|
|
24
20
|
var _InteractionTypes = _interopRequireDefault(require("../../../../shared/InteractionTypes"));
|
|
25
|
-
var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
|
|
26
|
-
var _quizCommon = require("@instructure/quiz-common");
|
|
27
21
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
28
22
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
29
|
-
var
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
30
25
|
/** @jsx jsx */
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
|
|
27
|
+
function UnstyledAddContentBody(_ref) {
|
|
28
|
+
var allowStimulusCreation = _ref.allowStimulusCreation,
|
|
29
|
+
createItem = _ref.createItem,
|
|
30
|
+
createStimulus = _ref.createStimulus,
|
|
31
|
+
editingQuizEntry = _ref.editingQuizEntry,
|
|
32
|
+
interactionTypes = _ref.interactionTypes,
|
|
33
|
+
_ref$onOpenBankTray = _ref.onOpenBankTray,
|
|
34
|
+
onOpenBankTray = _ref$onOpenBankTray === void 0 ? function () {} : _ref$onOpenBankTray,
|
|
35
|
+
_ref$onAddItem = _ref.onAddItem,
|
|
36
|
+
onAddItem = _ref$onAddItem === void 0 ? function () {} : _ref$onAddItem,
|
|
37
|
+
parentEntryId = _ref.parentEntryId,
|
|
38
|
+
position = _ref.position,
|
|
39
|
+
quizEntryWithErrorsShowing = _ref.quizEntryWithErrorsShowing,
|
|
40
|
+
quizId = _ref.quizId,
|
|
41
|
+
screenreaderNotification = _ref.screenreaderNotification,
|
|
42
|
+
setNextQuizEntry = _ref.setNextQuizEntry,
|
|
43
|
+
setUi = _ref.setUi,
|
|
44
|
+
_ref$showHeaderText = _ref.showHeaderText,
|
|
45
|
+
showHeaderText = _ref$showHeaderText === void 0 ? true : _ref$showHeaderText,
|
|
46
|
+
stimulusId = _ref.stimulusId,
|
|
47
|
+
styles = _ref.styles,
|
|
48
|
+
_ref$slotProps = _ref.slotProps,
|
|
49
|
+
slotProps = _ref$slotProps === void 0 ? {} : _ref$slotProps;
|
|
50
|
+
var openBankTray = (0, _react.useCallback)(function () {
|
|
51
|
+
onOpenBankTray();
|
|
52
|
+
setUi(_quizCommon.BUILD_TRAY_OPEN, true);
|
|
53
|
+
setUi(_quizCommon.BUILD_TRAY_POSITION, position);
|
|
54
|
+
setUi(_quizCommon.BUILD_TRAY_STIMULUS_ID, parentEntryId);
|
|
55
|
+
}, [onOpenBankTray, setUi, position, parentEntryId]);
|
|
56
|
+
var addStimulus = (0, _react.useCallback)(function (isPassage) {
|
|
57
|
+
if (editingQuizEntry) {
|
|
58
|
+
setNextQuizEntry(null, quizId, position);
|
|
59
|
+
} else {
|
|
60
|
+
createStimulus(quizId, position, isPassage);
|
|
51
61
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
(0, _defineProperty2["default"])(_this2, "addStimulus", function (isPassage) {
|
|
63
|
-
if (_this2.props.editingQuizEntry) {
|
|
64
|
-
_this2.props.setNextQuizEntry(null, _this2.props.quizId, _this2.props.position);
|
|
65
|
-
} else {
|
|
66
|
-
_this2.props.createStimulus(_this2.props.quizId, _this2.props.position, isPassage);
|
|
67
|
-
}
|
|
68
|
-
_this2.props.onAddItem();
|
|
69
|
-
});
|
|
70
|
-
(0, _defineProperty2["default"])(_this2, "addItem", function (interactionTypeData) {
|
|
71
|
-
if (_this2.props.quizEntryWithErrorsShowing) {
|
|
72
|
-
_this2.props.screenreaderNotification((0, _formatMessage["default"])('Question {itemPosition, number} cannot be saved due to invalid input data', {
|
|
73
|
-
itemPosition: Math.ceil(_this2.props.quizEntryWithErrorsShowing.position)
|
|
74
|
-
}));
|
|
62
|
+
onAddItem();
|
|
63
|
+
}, [editingQuizEntry, setNextQuizEntry, quizId, position, createStimulus, onAddItem]);
|
|
64
|
+
var addItem = (0, _react.useCallback)(function (interactionTypeData) {
|
|
65
|
+
if (quizEntryWithErrorsShowing) {
|
|
66
|
+
screenreaderNotification((0, _formatMessage["default"])('Question {itemPosition, number} cannot be saved due to invalid input data', {
|
|
67
|
+
itemPosition: Math.ceil(quizEntryWithErrorsShowing.position)
|
|
68
|
+
}));
|
|
69
|
+
} else {
|
|
70
|
+
if (editingQuizEntry) {
|
|
71
|
+
setNextQuizEntry(interactionTypeData, quizId, position, stimulusId, parentEntryId);
|
|
75
72
|
} else {
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
id: interactionTypeData.id,
|
|
88
|
-
interactionData: defaultInteractionData,
|
|
89
|
-
itemBody: interactionTypeData.itemBody,
|
|
90
|
-
properties: interactionTypeData.defaultProperties,
|
|
91
|
-
scoringAlgorithm: interactionTypeData.scoringAlgorithmDefault,
|
|
92
|
-
scoringData: scoringData,
|
|
93
|
-
userResponseType: (0, _first["default"])(interactionTypeData.userResponseTypeOptions)
|
|
94
|
-
}, parentEntryId, stimulusId);
|
|
95
|
-
}
|
|
73
|
+
var defaultInteractionData = interactionTypeData.getDefaultInteractionData();
|
|
74
|
+
var scoringData = interactionTypeData.getDefaultScoringData(defaultInteractionData);
|
|
75
|
+
createItem(quizId, position, {
|
|
76
|
+
id: interactionTypeData.id,
|
|
77
|
+
interactionData: defaultInteractionData,
|
|
78
|
+
itemBody: interactionTypeData.itemBody,
|
|
79
|
+
properties: interactionTypeData.defaultProperties,
|
|
80
|
+
scoringAlgorithm: interactionTypeData.scoringAlgorithmDefault,
|
|
81
|
+
scoringData: scoringData,
|
|
82
|
+
userResponseType: (0, _first["default"])(interactionTypeData.userResponseTypeOptions)
|
|
83
|
+
}, parentEntryId, stimulusId);
|
|
96
84
|
}
|
|
97
|
-
_this2.props.onAddItem();
|
|
98
|
-
});
|
|
99
|
-
// ==============================
|
|
100
|
-
// RENDERING
|
|
101
|
-
// ==============================
|
|
102
|
-
(0, _defineProperty2["default"])(_this2, "renderBankButton", function () {
|
|
103
|
-
return (0, _emotion.jsx)(_uiButtons.IconButton, {
|
|
104
|
-
size: "large",
|
|
105
|
-
onClick: _this2.openBankTray,
|
|
106
|
-
"data-automation": "sdk-add-banked-content-button",
|
|
107
|
-
screenReaderLabel: (0, _formatMessage["default"])('Add banked content')
|
|
108
|
-
}, (0, _emotion.jsx)(_uiIcons.IconBankLine, null));
|
|
109
|
-
});
|
|
110
|
-
(0, _defineProperty2["default"])(_this2, "renderPopoverHeader", function () {
|
|
111
|
-
var text = _this2.props.showHeaderText ? (0, _formatMessage["default"])('Insert Content') : '';
|
|
112
|
-
return (0, _emotion.jsx)("div", {
|
|
113
|
-
css: _this2.props.styles.popoverHeaderBox
|
|
114
|
-
}, (0, _emotion.jsx)("div", {
|
|
115
|
-
css: _this2.props.styles.popoverHeader
|
|
116
|
-
}, (0, _emotion.jsx)(_uiGrid.Grid, {
|
|
117
|
-
vAlign: "middle",
|
|
118
|
-
colSpacing: "none",
|
|
119
|
-
rowSpacing: "none"
|
|
120
|
-
}, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, (0, _emotion.jsx)(_uiGrid.Grid.Col, null, (0, _emotion.jsx)(_uiText.Text, {
|
|
121
|
-
color: "primary"
|
|
122
|
-
}, text)), (0, _emotion.jsx)(_uiGrid.Grid.Col, {
|
|
123
|
-
width: "auto"
|
|
124
|
-
}, _this2.renderBankButton())))));
|
|
125
|
-
});
|
|
126
|
-
return _this2;
|
|
127
|
-
}
|
|
128
|
-
(0, _inherits2["default"])(AddContentBody, _Component);
|
|
129
|
-
return (0, _createClass2["default"])(AddContentBody, [{
|
|
130
|
-
key: "render",
|
|
131
|
-
value: function render() {
|
|
132
|
-
return (0, _emotion.jsx)("div", {
|
|
133
|
-
css: this.props.styles.popoverContent,
|
|
134
|
-
role: "dialog",
|
|
135
|
-
"aria-label": (0, _formatMessage["default"])('Insert Content')
|
|
136
|
-
}, this.renderPopoverHeader(), (0, _emotion.jsx)(_uiView.View, {
|
|
137
|
-
padding: "small"
|
|
138
|
-
}, (0, _emotion.jsx)(_InteractionTypes["default"], {
|
|
139
|
-
columns: 2,
|
|
140
|
-
addItem: this.addItem,
|
|
141
|
-
addStimulus: this.addStimulus,
|
|
142
|
-
allowStimulusCreation: this.props.allowStimulusCreation,
|
|
143
|
-
types: this.props.interactionTypes
|
|
144
|
-
})));
|
|
145
85
|
}
|
|
146
|
-
|
|
147
|
-
}
|
|
86
|
+
onAddItem();
|
|
87
|
+
}, [quizEntryWithErrorsShowing, screenreaderNotification, editingQuizEntry, setNextQuizEntry, quizId, position, stimulusId, parentEntryId, createItem, onAddItem]);
|
|
88
|
+
var renderBankButton = function renderBankButton() {
|
|
89
|
+
return (0, _emotion.jsx)(_uiButtons.IconButton, {
|
|
90
|
+
size: "large",
|
|
91
|
+
onClick: openBankTray,
|
|
92
|
+
"data-automation": "sdk-add-banked-content-button",
|
|
93
|
+
screenReaderLabel: (0, _formatMessage["default"])('Add banked content')
|
|
94
|
+
}, (0, _emotion.jsx)(_uiIcons.IconBankLine, null));
|
|
95
|
+
};
|
|
96
|
+
var renderPopoverHeader = function renderPopoverHeader() {
|
|
97
|
+
var _slotProps$quizGenera, _slotProps$quizGenera2, _slotProps$quizGenera3;
|
|
98
|
+
var text = showHeaderText ? (0, _formatMessage["default"])('Insert Content') : '';
|
|
99
|
+
return (0, _emotion.jsx)("div", {
|
|
100
|
+
css: styles.popoverHeaderBox
|
|
101
|
+
}, (0, _emotion.jsx)("div", {
|
|
102
|
+
css: styles.popoverHeader
|
|
103
|
+
}, (0, _emotion.jsx)(_uiGrid.Grid, {
|
|
104
|
+
vAlign: "middle",
|
|
105
|
+
colSpacing: "none",
|
|
106
|
+
rowSpacing: "none"
|
|
107
|
+
}, (0, _emotion.jsx)(_uiGrid.Grid.Row, null, (0, _emotion.jsx)(_uiGrid.Grid.Col, null, (0, _emotion.jsx)(_uiText.Text, {
|
|
108
|
+
color: "primary"
|
|
109
|
+
}, text)), (0, _emotion.jsx)(_uiGrid.Grid.Col, {
|
|
110
|
+
width: "auto"
|
|
111
|
+
}, renderBankButton())))), ((_slotProps$quizGenera = slotProps.quizGenerationButton) === null || _slotProps$quizGenera === void 0 ? void 0 : _slotProps$quizGenera.visible) && (0, _emotion.jsx)(_uiView.View, {
|
|
112
|
+
as: "div",
|
|
113
|
+
padding: "x-small 0 small"
|
|
114
|
+
}, (0, _emotion.jsx)(_uiButtons.Button, {
|
|
115
|
+
color: "ai-primary",
|
|
116
|
+
display: "block",
|
|
117
|
+
renderIcon: _uiIcons.IconAiSolid,
|
|
118
|
+
onClick: (_slotProps$quizGenera2 = slotProps.quizGenerationButton) === null || _slotProps$quizGenera2 === void 0 ? void 0 : _slotProps$quizGenera2.onClick,
|
|
119
|
+
disabled: (_slotProps$quizGenera3 = slotProps.quizGenerationButton) === null || _slotProps$quizGenera3 === void 0 ? void 0 : _slotProps$quizGenera3.disabled
|
|
120
|
+
}, (0, _formatMessage["default"])('Generate with AI'))));
|
|
121
|
+
};
|
|
122
|
+
return (0, _emotion.jsx)("div", {
|
|
123
|
+
css: styles.popoverContent,
|
|
124
|
+
role: "dialog",
|
|
125
|
+
"aria-label": (0, _formatMessage["default"])('Insert Content')
|
|
126
|
+
}, renderPopoverHeader(), (0, _emotion.jsx)(_uiView.View, {
|
|
127
|
+
padding: "small"
|
|
128
|
+
}, (0, _emotion.jsx)(_InteractionTypes["default"], {
|
|
129
|
+
columns: 2,
|
|
130
|
+
addItem: addItem,
|
|
131
|
+
addStimulus: addStimulus,
|
|
132
|
+
allowStimulusCreation: allowStimulusCreation,
|
|
133
|
+
types: interactionTypes
|
|
134
|
+
})));
|
|
135
|
+
}
|
|
136
|
+
var AddContentBody = exports.AddContentBody = (0, _quizCommon.withStyleOverrides)(_styles["default"], _theme["default"])(UnstyledAddContentBody);
|
|
137
|
+
var quizGenerationButtonPropTypes = exports.quizGenerationButtonPropTypes = _propTypes["default"].shape({
|
|
138
|
+
onClick: _propTypes["default"].func.isRequired,
|
|
139
|
+
visible: _propTypes["default"].bool,
|
|
140
|
+
disabled: _propTypes["default"].bool
|
|
141
|
+
});
|
|
142
|
+
AddContentBody.displayName = 'AddContentBody';
|
|
143
|
+
AddContentBody.componentId = "Quizzes".concat(AddContentBody.displayName);
|
|
144
|
+
AddContentBody.propTypes = {
|
|
148
145
|
allowStimulusCreation: _propTypes["default"].bool.isRequired,
|
|
149
146
|
createItem: _propTypes["default"].func.isRequired,
|
|
150
147
|
createStimulus: _propTypes["default"].func.isRequired,
|
|
@@ -161,15 +158,9 @@ var AddContentBody = exports.AddContentBody = (_dec = (0, _quizCommon.withStyleO
|
|
|
161
158
|
setUi: _propTypes["default"].func.isRequired,
|
|
162
159
|
showHeaderText: _propTypes["default"].bool,
|
|
163
160
|
stimulusId: _propTypes["default"].string,
|
|
164
|
-
styles: _propTypes["default"].object
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
parentEntryId: void 0,
|
|
170
|
-
onOpenBankTray: Function.prototype,
|
|
171
|
-
quizEntryWithErrorsShowing: void 0,
|
|
172
|
-
showHeaderText: true,
|
|
173
|
-
stimulusId: void 0
|
|
174
|
-
}), _AddContentBody)) || _class);
|
|
161
|
+
styles: _propTypes["default"].object,
|
|
162
|
+
slotProps: _propTypes["default"].shape({
|
|
163
|
+
quizGenerationButton: quizGenerationButtonPropTypes
|
|
164
|
+
})
|
|
165
|
+
};
|
|
175
166
|
var _default = exports["default"] = AddContentBody;
|
|
@@ -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;
|