@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.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/cjs/components/eb-sortable/EbDraggable.js +33 -42
- package/cjs/components/eb-sortable/EbDroppable.js +20 -27
- package/cjs/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
- package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
- package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
- package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
- package/cjs/components/material-quiz/constants/color.js +5 -5
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
- package/cjs/components/material-quiz-edit/context.js +2 -8
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
- package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
- package/cjs/components/shared/QuestionBox.js +165 -198
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
- package/cjs/components/shared/QuizDraggbleOption.js +59 -65
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/cjs/components/shared/utils/mergeRefs.js +6 -15
- package/cjs/constant/element.js +3 -3
- package/cjs/helpers/index.js +10 -8
- package/cjs/hooks/useCaculatePassage.js +20 -21
- package/es/components/eb-sortable/EbDraggable.js +33 -37
- package/es/components/eb-sortable/EbDroppable.js +20 -22
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-quiz/MaterialQuiz.js +83 -109
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
- package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
- package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
- package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
- package/es/components/material-quiz/MaterialQuizText.js +115 -158
- package/es/components/material-quiz/QuizResultBadge.js +22 -27
- package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
- package/es/components/material-quiz/constants/color.js +5 -5
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
- package/es/components/material-quiz-edit/context.js +2 -4
- package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
- package/es/components/material-quiz-edit/options/OptionText.js +82 -86
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/es/components/material-quiz-edit/utils/editValue.js +12 -17
- package/es/components/shared/QuestionBox.js +165 -192
- package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
- package/es/components/shared/QuizDraggbleOption.js +59 -61
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
- package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/es/components/shared/utils/mergeRefs.js +6 -15
- package/es/constant/element.js +3 -3
- package/es/helpers/index.js +10 -8
- package/es/hooks/useCaculatePassage.js +20 -21
- package/package.json +15 -12
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
- package/cjs/components/material-quiz/index.js +0 -9
- package/cjs/components/material-quiz/locales/index.js +0 -13
- package/cjs/components/material-quiz-edit/index.js +0 -7
- package/cjs/components/material-quiz-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -19
- package/cjs/constant/index.js +0 -9
- package/cjs/hooks/index.js +0 -7
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
- package/es/components/material-quiz/index.js +0 -2
- package/es/components/material-quiz/locales/index.js +0 -4
- package/es/components/material-quiz-edit/index.js +0 -1
- package/es/components/material-quiz-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -7
- package/es/constant/index.js +0 -1
- package/es/hooks/index.js +0 -1
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
5
|
var React = require('react');
|
|
8
6
|
var reactHookForm = require('react-hook-form');
|
|
9
7
|
var reactTransitionGroup = require('react-transition-group');
|
|
@@ -22,38 +20,26 @@ var checkTwoDimensionArray = require('./utils/checkTwoDimensionArray.js');
|
|
|
22
20
|
var randomId = require('./utils/randomId.js');
|
|
23
21
|
var context = require('./context.js');
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
watch = _useFormContext.watch,
|
|
40
|
-
setValue = _useFormContext.setValue;
|
|
41
|
-
var _watch = watch(['optionType', 'optionsDefault', 'answerInfoDefault', 'answerHint', 'explanationInfo', 'isAutoGrade', 'groups', 'optionsSetEnabled']),
|
|
42
|
-
_watch2 = _rollupPluginBabelHelpers.slicedToArray(_watch, 8),
|
|
43
|
-
watchedOptionType = _watch2[0],
|
|
44
|
-
watchedOptionInfo = _watch2[1],
|
|
45
|
-
watchedAnswerInfo = _watch2[2],
|
|
46
|
-
watchedAnswerHint = _watch2[3],
|
|
47
|
-
watchedExplanationInfo = _watch2[4],
|
|
48
|
-
watchedIsAutoGrade = _watch2[5],
|
|
49
|
-
watchedGroups = _watch2[6],
|
|
50
|
-
optionsSetEnabled = _watch2[7];
|
|
23
|
+
const MIN_TEXT_LENGTH = 1;
|
|
24
|
+
const MAX_TEXT_LENGTH = 128;
|
|
25
|
+
const MaterialQuizEditContent = () => {
|
|
26
|
+
const intl$1 = intl.useRawEliceIntl();
|
|
27
|
+
const {
|
|
28
|
+
disabled,
|
|
29
|
+
onFileUploadRequest
|
|
30
|
+
} = context.useMaterialQuizEditContext();
|
|
31
|
+
const {
|
|
32
|
+
control,
|
|
33
|
+
watch,
|
|
34
|
+
setValue
|
|
35
|
+
} = reactHookForm.useFormContext();
|
|
36
|
+
const [watchedOptionType, watchedOptionInfo, watchedAnswerInfo, watchedAnswerHint, watchedExplanationInfo, watchedIsAutoGrade, watchedGroups, optionsSetEnabled] = watch(['optionType', 'optionsDefault', 'answerInfoDefault', 'answerHint', 'explanationInfo', 'isAutoGrade', 'groups', 'optionsSetEnabled']);
|
|
51
37
|
//
|
|
52
38
|
// Change `options` according to `optionType`.
|
|
53
39
|
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
const get = () => {
|
|
42
|
+
const filteredNotMarkdownOptions = watchedOptionInfo === null || watchedOptionInfo === void 0 ? void 0 : watchedOptionInfo.filter(option => {
|
|
57
43
|
var _a;
|
|
58
44
|
return !((_a = option.content) === null || _a === void 0 ? void 0 : _a.includes('![]'));
|
|
59
45
|
});
|
|
@@ -82,7 +68,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
82
68
|
}];
|
|
83
69
|
}
|
|
84
70
|
if (filteredNotMarkdownOptions.length) {
|
|
85
|
-
return watchedOptionInfo.map(
|
|
71
|
+
return watchedOptionInfo.map(e => {
|
|
86
72
|
var _a;
|
|
87
73
|
if ((_a = e.title) === null || _a === void 0 ? void 0 : _a.length) {
|
|
88
74
|
return Object.assign(Object.assign({}, e), {
|
|
@@ -116,7 +102,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
116
102
|
}];
|
|
117
103
|
}
|
|
118
104
|
if (filteredNotMarkdownOptions.length) {
|
|
119
|
-
return watchedOptionInfo.map(
|
|
105
|
+
return watchedOptionInfo.map(e => {
|
|
120
106
|
var _a, _b;
|
|
121
107
|
if (!((_a = e.content) === null || _a === void 0 ? void 0 : _a.includes('![]')) && !((_b = e.title) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
122
108
|
return Object.assign(Object.assign({}, e), {
|
|
@@ -141,16 +127,16 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
141
127
|
//
|
|
142
128
|
// Change `answerInfo` according to `optionType`.
|
|
143
129
|
//
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
React.useEffect(() => {
|
|
131
|
+
const get = () => {
|
|
146
132
|
switch (watchedOptionType) {
|
|
147
133
|
case types.enums.QuizOptionType.SelectOne:
|
|
148
134
|
if (!Array.isArray(watchedAnswerInfo)) {
|
|
149
135
|
return [0];
|
|
150
136
|
}
|
|
151
137
|
if (checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
152
|
-
|
|
153
|
-
return
|
|
138
|
+
const convertedAnswerInfo = watchedAnswerInfo;
|
|
139
|
+
return flattenDeep(convertedAnswerInfo).slice(0, 1);
|
|
154
140
|
}
|
|
155
141
|
return watchedAnswerInfo.slice(0, 1);
|
|
156
142
|
case types.enums.QuizOptionType.SelectMultiple:
|
|
@@ -159,7 +145,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
159
145
|
return [0];
|
|
160
146
|
}
|
|
161
147
|
if (checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
162
|
-
return
|
|
148
|
+
return flattenDeep(watchedAnswerInfo);
|
|
163
149
|
}
|
|
164
150
|
return watchedAnswerInfo;
|
|
165
151
|
case types.enums.QuizOptionType.Text:
|
|
@@ -177,8 +163,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
177
163
|
//
|
|
178
164
|
// Change `answerHint` according to `optionType`.
|
|
179
165
|
//
|
|
180
|
-
|
|
181
|
-
|
|
166
|
+
React.useEffect(() => {
|
|
167
|
+
const get = () => {
|
|
182
168
|
switch (watchedOptionType) {
|
|
183
169
|
case types.enums.QuizOptionType.SelectOne:
|
|
184
170
|
case types.enums.QuizOptionType.SelectMultiple:
|
|
@@ -198,8 +184,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
198
184
|
//
|
|
199
185
|
// Change `isAutoGrade` according to `optionType`.
|
|
200
186
|
//
|
|
201
|
-
|
|
202
|
-
|
|
187
|
+
React.useEffect(() => {
|
|
188
|
+
const get = () => {
|
|
203
189
|
switch (watchedOptionType) {
|
|
204
190
|
case types.enums.QuizOptionType.SelectOne:
|
|
205
191
|
case types.enums.QuizOptionType.SelectMultiple:
|
|
@@ -219,8 +205,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
219
205
|
//
|
|
220
206
|
// Change `groups` according to `optionType`.
|
|
221
207
|
//
|
|
222
|
-
|
|
223
|
-
|
|
208
|
+
React.useEffect(() => {
|
|
209
|
+
const get = () => {
|
|
224
210
|
switch (watchedOptionType) {
|
|
225
211
|
case types.enums.QuizOptionType.SelectOne:
|
|
226
212
|
case types.enums.QuizOptionType.SelectMultiple:
|
|
@@ -255,7 +241,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
255
241
|
* Input of option info and answer info,
|
|
256
242
|
* according to option type.
|
|
257
243
|
*/
|
|
258
|
-
|
|
244
|
+
const Option = React.useMemo(() => {
|
|
259
245
|
switch (watchedOptionType) {
|
|
260
246
|
case types.enums.QuizOptionType.SelectOne:
|
|
261
247
|
return OptionSelectOne.default;
|
|
@@ -268,22 +254,21 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
268
254
|
case types.enums.QuizOptionType.Text:
|
|
269
255
|
return OptionText.default;
|
|
270
256
|
default:
|
|
271
|
-
return
|
|
257
|
+
return React.Fragment;
|
|
272
258
|
}
|
|
273
259
|
}, [watchedOptionType]);
|
|
274
260
|
/**
|
|
275
261
|
* Render input for quiz title.
|
|
276
262
|
*/
|
|
277
|
-
|
|
278
|
-
return
|
|
279
|
-
label:
|
|
263
|
+
const renderQuestionTitleInput = () => {
|
|
264
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
265
|
+
label: React.createElement(blocks.Label, {
|
|
280
266
|
size: "small",
|
|
281
|
-
required: true
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
input: jsxRuntime.jsx(reactHookForm.Controller, {
|
|
267
|
+
required: true
|
|
268
|
+
}, intl$1.formatMessage({
|
|
269
|
+
id: 'content.title'
|
|
270
|
+
})),
|
|
271
|
+
input: React.createElement(reactHookForm.Controller, {
|
|
287
272
|
control: control,
|
|
288
273
|
name: "questionTitle",
|
|
289
274
|
rules: {
|
|
@@ -312,11 +297,12 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
312
297
|
})
|
|
313
298
|
}
|
|
314
299
|
},
|
|
315
|
-
render:
|
|
316
|
-
|
|
317
|
-
|
|
300
|
+
render: ({
|
|
301
|
+
field,
|
|
302
|
+
fieldState
|
|
303
|
+
}) => {
|
|
318
304
|
var _a;
|
|
319
|
-
return
|
|
305
|
+
return React.createElement(blocks.Input, Object.assign({
|
|
320
306
|
size: "small",
|
|
321
307
|
width: "full",
|
|
322
308
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -334,169 +320,149 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
334
320
|
/**
|
|
335
321
|
* Render input for quiz description.
|
|
336
322
|
*/
|
|
337
|
-
|
|
338
|
-
return
|
|
339
|
-
label:
|
|
340
|
-
size: "small"
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
input: jsxRuntime.jsx(reactHookForm.Controller, {
|
|
323
|
+
const renderQuestionDescriptionInput = () => {
|
|
324
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
325
|
+
label: React.createElement(blocks.Label, {
|
|
326
|
+
size: "small"
|
|
327
|
+
}, intl$1.formatMessage({
|
|
328
|
+
id: 'content.description.title'
|
|
329
|
+
})),
|
|
330
|
+
input: React.createElement(reactHookForm.Controller, {
|
|
346
331
|
control: control,
|
|
347
332
|
name: "questionDescription",
|
|
348
|
-
render:
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
333
|
+
render: ({
|
|
334
|
+
field
|
|
335
|
+
}) => React.createElement(index.MarkdownEditor, Object.assign({
|
|
336
|
+
placeholder: intl$1.formatMessage({
|
|
337
|
+
id: 'content.description.placeholder'
|
|
338
|
+
}),
|
|
339
|
+
onFileUploadRequest: onFileUploadRequest
|
|
340
|
+
}, field))
|
|
357
341
|
})
|
|
358
342
|
});
|
|
359
343
|
};
|
|
360
344
|
/**
|
|
361
345
|
* Render input of option type, option info and answer info.
|
|
362
346
|
*/
|
|
363
|
-
|
|
364
|
-
return
|
|
365
|
-
label:
|
|
347
|
+
const renderOptionInput = () => {
|
|
348
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
349
|
+
label: React.createElement(blocks.Label, {
|
|
366
350
|
size: "small",
|
|
367
|
-
required: true
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
field.onChange(event);
|
|
397
|
-
},
|
|
398
|
-
children: [jsxRuntime.jsx(material.MenuItem, {
|
|
399
|
-
value: types.enums.QuizOptionType.SelectOne,
|
|
400
|
-
children: intl$1.formatMessage({
|
|
401
|
-
id: 'content.option.select.items.selectOne'
|
|
402
|
-
})
|
|
403
|
-
}), jsxRuntime.jsx(material.MenuItem, {
|
|
404
|
-
value: types.enums.QuizOptionType.SelectMultiple,
|
|
405
|
-
children: intl$1.formatMessage({
|
|
406
|
-
id: 'content.option.select.items.selectMultiple'
|
|
407
|
-
})
|
|
408
|
-
}), jsxRuntime.jsx(material.MenuItem, {
|
|
409
|
-
value: types.enums.QuizOptionType.SelectMultipleOrder,
|
|
410
|
-
children: intl$1.formatMessage({
|
|
411
|
-
id: 'content.option.select.items.selectMultipleOrder'
|
|
412
|
-
})
|
|
413
|
-
}), jsxRuntime.jsx(material.MenuItem, {
|
|
414
|
-
value: types.enums.QuizOptionType.Group,
|
|
415
|
-
children: intl$1.formatMessage({
|
|
416
|
-
id: 'content.option.select.items.group'
|
|
417
|
-
})
|
|
418
|
-
}), jsxRuntime.jsx(material.MenuItem, {
|
|
419
|
-
value: types.enums.QuizOptionType.Text,
|
|
420
|
-
children: intl$1.formatMessage({
|
|
421
|
-
id: 'content.option.select.items.text'
|
|
422
|
-
})
|
|
423
|
-
})]
|
|
424
|
-
})), watchedOptionType !== types.enums.QuizOptionType.Text ? jsxRuntime.jsx(reactHookForm.Controller, {
|
|
425
|
-
name: "optionsSetEnabled",
|
|
426
|
-
control: control,
|
|
427
|
-
render: function render(_ref4) {
|
|
428
|
-
var field = _ref4.field;
|
|
429
|
-
return jsxRuntime.jsx(material.Tooltip, {
|
|
430
|
-
title: disabled ? '' : intl$1.formatMessage({
|
|
431
|
-
id: 'content.option.optionsSetEnabled.tooltip'
|
|
432
|
-
}),
|
|
433
|
-
placement: "top",
|
|
434
|
-
children: jsxRuntime.jsx(material.FormControlLabel, {
|
|
435
|
-
disabled: disabled,
|
|
436
|
-
label: intl$1.formatMessage({
|
|
437
|
-
id: 'content.option.optionsSetEnabled.label'
|
|
438
|
-
}),
|
|
439
|
-
control: jsxRuntime.jsx(material.Switch, Object.assign({}, field, {
|
|
440
|
-
checked: field.value
|
|
441
|
-
}))
|
|
442
|
-
})
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
}) : null]
|
|
446
|
-
})
|
|
447
|
-
});
|
|
351
|
+
required: true
|
|
352
|
+
}, intl$1.formatMessage({
|
|
353
|
+
id: 'content.option.title'
|
|
354
|
+
})),
|
|
355
|
+
input: React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
|
|
356
|
+
control: control,
|
|
357
|
+
name: "optionType",
|
|
358
|
+
render: ({
|
|
359
|
+
field
|
|
360
|
+
}) => React.createElement(material.Tooltip, {
|
|
361
|
+
title: disabled && intl$1.formatMessage({
|
|
362
|
+
id: 'content.option.tooltip.disabled'
|
|
363
|
+
}),
|
|
364
|
+
placement: "top-end"
|
|
365
|
+
}, React.createElement(material.Stack, {
|
|
366
|
+
direction: "row",
|
|
367
|
+
justifyContent: "space-between",
|
|
368
|
+
marginBottom: "0.5rem"
|
|
369
|
+
}, React.createElement(material.TextField, Object.assign({
|
|
370
|
+
select: true,
|
|
371
|
+
disabled: disabled
|
|
372
|
+
}, field, {
|
|
373
|
+
onChange: event => {
|
|
374
|
+
const isTextQuizOption = Number(event.target.value) === types.enums.QuizOptionType.Text;
|
|
375
|
+
if (isTextQuizOption) {
|
|
376
|
+
setValue('optionsSetEnabled', false);
|
|
377
|
+
}
|
|
378
|
+
field.onChange(event);
|
|
448
379
|
}
|
|
449
|
-
}),
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
},
|
|
454
|
-
children: [jsxRuntime.jsx(material.AlertTitle, {
|
|
455
|
-
children: intl$1.formatMessage({
|
|
456
|
-
id: 'content.option.alert.randomized.title'
|
|
457
|
-
})
|
|
458
|
-
}), intl$1.formatMessage({
|
|
459
|
-
id: 'content.option.alert.randomized.description'
|
|
460
|
-
})]
|
|
461
|
-
}) : null, jsxRuntime.jsx(reactTransitionGroup.Transition, {
|
|
462
|
-
in: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder || watchedOptionType === types.enums.QuizOptionType.Group,
|
|
463
|
-
timeout: 0,
|
|
464
|
-
mountOnEnter: true,
|
|
465
|
-
unmountOnExit: true,
|
|
466
|
-
children: jsxRuntime.jsx(material.Box, {
|
|
467
|
-
marginBottom: "0.5rem",
|
|
468
|
-
children: jsxRuntime.jsx(blocks.StatusText, {
|
|
469
|
-
role: "description",
|
|
470
|
-
preWrap: true,
|
|
471
|
-
children: intl$1.formatMessage({
|
|
472
|
-
id: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder ? 'content.option.statusText.dragNDrop' : 'content.option.statusText.dragNDropGroup'
|
|
473
|
-
})
|
|
474
|
-
})
|
|
380
|
+
}), React.createElement(material.MenuItem, {
|
|
381
|
+
value: types.enums.QuizOptionType.SelectOne,
|
|
382
|
+
children: intl$1.formatMessage({
|
|
383
|
+
id: 'content.option.select.items.selectOne'
|
|
475
384
|
})
|
|
476
|
-
}),
|
|
477
|
-
|
|
385
|
+
}), React.createElement(material.MenuItem, {
|
|
386
|
+
value: types.enums.QuizOptionType.SelectMultiple,
|
|
387
|
+
children: intl$1.formatMessage({
|
|
388
|
+
id: 'content.option.select.items.selectMultiple'
|
|
389
|
+
})
|
|
390
|
+
}), React.createElement(material.MenuItem, {
|
|
391
|
+
value: types.enums.QuizOptionType.SelectMultipleOrder,
|
|
392
|
+
children: intl$1.formatMessage({
|
|
393
|
+
id: 'content.option.select.items.selectMultipleOrder'
|
|
394
|
+
})
|
|
395
|
+
}), React.createElement(material.MenuItem, {
|
|
396
|
+
value: types.enums.QuizOptionType.Group,
|
|
397
|
+
children: intl$1.formatMessage({
|
|
398
|
+
id: 'content.option.select.items.group'
|
|
399
|
+
})
|
|
400
|
+
}), React.createElement(material.MenuItem, {
|
|
401
|
+
value: types.enums.QuizOptionType.Text,
|
|
402
|
+
children: intl$1.formatMessage({
|
|
403
|
+
id: 'content.option.select.items.text'
|
|
404
|
+
})
|
|
405
|
+
})), watchedOptionType !== types.enums.QuizOptionType.Text ? React.createElement(reactHookForm.Controller, {
|
|
406
|
+
name: "optionsSetEnabled",
|
|
407
|
+
control: control,
|
|
408
|
+
render: ({
|
|
409
|
+
field
|
|
410
|
+
}) => React.createElement(material.Tooltip, {
|
|
411
|
+
title: disabled ? '' : intl$1.formatMessage({
|
|
412
|
+
id: 'content.option.optionsSetEnabled.tooltip'
|
|
413
|
+
}),
|
|
414
|
+
placement: "top"
|
|
415
|
+
}, React.createElement(material.FormControlLabel, {
|
|
416
|
+
disabled: disabled,
|
|
417
|
+
label: intl$1.formatMessage({
|
|
418
|
+
id: 'content.option.optionsSetEnabled.label'
|
|
419
|
+
}),
|
|
420
|
+
control: React.createElement(material.Switch, Object.assign({}, field, {
|
|
421
|
+
checked: field.value
|
|
422
|
+
}))
|
|
423
|
+
}))
|
|
424
|
+
}) : null))
|
|
425
|
+
}), watchedOptionType !== types.enums.QuizOptionType.Text && optionsSetEnabled ? React.createElement(material.Alert, {
|
|
426
|
+
severity: "info",
|
|
427
|
+
sx: {
|
|
428
|
+
marginBottom: '1rem'
|
|
429
|
+
}
|
|
430
|
+
}, React.createElement(material.AlertTitle, null, intl$1.formatMessage({
|
|
431
|
+
id: 'content.option.alert.randomized.title'
|
|
432
|
+
})), intl$1.formatMessage({
|
|
433
|
+
id: 'content.option.alert.randomized.description'
|
|
434
|
+
})) : null, React.createElement(reactTransitionGroup.Transition, {
|
|
435
|
+
in: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder || watchedOptionType === types.enums.QuizOptionType.Group,
|
|
436
|
+
timeout: 0,
|
|
437
|
+
mountOnEnter: true,
|
|
438
|
+
unmountOnExit: true
|
|
439
|
+
}, React.createElement(material.Box, {
|
|
440
|
+
marginBottom: "0.5rem"
|
|
441
|
+
}, React.createElement(blocks.StatusText, {
|
|
442
|
+
role: "description",
|
|
443
|
+
preWrap: true
|
|
444
|
+
}, intl$1.formatMessage({
|
|
445
|
+
id: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder ? 'content.option.statusText.dragNDrop' : 'content.option.statusText.dragNDropGroup'
|
|
446
|
+
})))), React.createElement(Option, null))
|
|
478
447
|
});
|
|
479
448
|
};
|
|
480
449
|
/**
|
|
481
450
|
* Input of answer hint.
|
|
482
451
|
*/
|
|
483
|
-
|
|
452
|
+
const renderAnswerHintInput = () => {
|
|
484
453
|
if (watchedOptionType !== types.enums.QuizOptionType.Text) {
|
|
485
454
|
return null;
|
|
486
455
|
}
|
|
487
|
-
return
|
|
488
|
-
label:
|
|
489
|
-
size: "small"
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
})
|
|
498
|
-
}),
|
|
499
|
-
input: jsxRuntime.jsx(reactHookForm.Controller, {
|
|
456
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
457
|
+
label: React.createElement(blocks.Label, {
|
|
458
|
+
size: "small"
|
|
459
|
+
}, intl$1.formatMessage({
|
|
460
|
+
id: 'content.answerHint.title'
|
|
461
|
+
})),
|
|
462
|
+
description: React.createElement(blocks.Text, null, intl$1.formatMessage({
|
|
463
|
+
id: 'content.answerHint.description'
|
|
464
|
+
})),
|
|
465
|
+
input: React.createElement(reactHookForm.Controller, {
|
|
500
466
|
control: control,
|
|
501
467
|
name: "answerHint",
|
|
502
468
|
rules: {
|
|
@@ -519,11 +485,12 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
519
485
|
})
|
|
520
486
|
}
|
|
521
487
|
},
|
|
522
|
-
render:
|
|
523
|
-
|
|
524
|
-
|
|
488
|
+
render: ({
|
|
489
|
+
field,
|
|
490
|
+
fieldState
|
|
491
|
+
}) => {
|
|
525
492
|
var _a, _b;
|
|
526
|
-
return
|
|
493
|
+
return React.createElement(blocks.Input, Object.assign({
|
|
527
494
|
size: "small",
|
|
528
495
|
width: "full",
|
|
529
496
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -543,85 +510,70 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
543
510
|
/**
|
|
544
511
|
* Input of explanation info.
|
|
545
512
|
*/
|
|
546
|
-
|
|
547
|
-
return
|
|
548
|
-
label:
|
|
549
|
-
size: "small"
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
513
|
+
const renderExplanationInfoInput = () => {
|
|
514
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
515
|
+
label: React.createElement(blocks.Label, {
|
|
516
|
+
size: "small"
|
|
517
|
+
}, intl$1.formatMessage({
|
|
518
|
+
id: 'content.explanationInfo.title'
|
|
519
|
+
})),
|
|
520
|
+
description: React.createElement(blocks.Text, null, intl$1.formatMessage({
|
|
521
|
+
id: 'content.explanationInfo.description'
|
|
522
|
+
})),
|
|
523
|
+
input: React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
|
|
524
|
+
control: control,
|
|
525
|
+
name: "explanationInfo.isEnabled",
|
|
526
|
+
render: ({
|
|
527
|
+
field
|
|
528
|
+
}) => React.createElement(blocks.Checkbox, Object.assign({
|
|
529
|
+
size: "small"
|
|
530
|
+
}, field), intl$1.formatMessage({
|
|
531
|
+
id: 'content.explanationInfo.checkbox.label'
|
|
532
|
+
}))
|
|
533
|
+
}), React.createElement(reactTransitionGroup.Transition, {
|
|
534
|
+
in: watchedExplanationInfo.isEnabled,
|
|
535
|
+
timeout: 0,
|
|
536
|
+
mountOnEnter: true,
|
|
537
|
+
unmountOnExit: true
|
|
538
|
+
}, React.createElement(React.Fragment, null, React.createElement(blocks.Vspace, {
|
|
539
|
+
height: 1
|
|
540
|
+
}), React.createElement(reactHookForm.Controller, {
|
|
541
|
+
control: control,
|
|
542
|
+
name: "explanationInfo.value",
|
|
543
|
+
rules: {
|
|
544
|
+
required: {
|
|
545
|
+
value: true,
|
|
546
|
+
message: intl$1.formatMessage({
|
|
547
|
+
id: 'content.explanationInfo.textarea.placeholder'
|
|
548
|
+
})
|
|
572
549
|
}
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
fieldState = _ref7.fieldState;
|
|
595
|
-
var _a;
|
|
596
|
-
return jsxRuntime.jsxs(blocks.Flex, {
|
|
597
|
-
column: true,
|
|
598
|
-
children: [fieldState.invalid ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
599
|
-
children: [jsxRuntime.jsx(blocks.StatusText, {
|
|
600
|
-
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
601
|
-
role: "danger"
|
|
602
|
-
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
603
|
-
height: 0.5
|
|
604
|
-
})]
|
|
605
|
-
}) : null, jsxRuntime.jsx(index.MarkdownEditor, Object.assign({
|
|
606
|
-
placeholder: intl$1.formatMessage({
|
|
607
|
-
id: 'content.explanationInfo.textarea.errorMessage.required'
|
|
608
|
-
}),
|
|
609
|
-
onFileUploadRequest: onFileUploadRequest
|
|
610
|
-
}, field))]
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
})]
|
|
614
|
-
})
|
|
615
|
-
})]
|
|
616
|
-
})
|
|
550
|
+
},
|
|
551
|
+
render: ({
|
|
552
|
+
field,
|
|
553
|
+
fieldState
|
|
554
|
+
}) => {
|
|
555
|
+
var _a;
|
|
556
|
+
return React.createElement(blocks.Flex, {
|
|
557
|
+
column: true
|
|
558
|
+
}, fieldState.invalid ? React.createElement(React.Fragment, null, React.createElement(blocks.StatusText, {
|
|
559
|
+
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
560
|
+
role: "danger"
|
|
561
|
+
}), React.createElement(blocks.Vspace, {
|
|
562
|
+
height: 0.5
|
|
563
|
+
})) : null, React.createElement(index.MarkdownEditor, Object.assign({
|
|
564
|
+
placeholder: intl$1.formatMessage({
|
|
565
|
+
id: 'content.explanationInfo.textarea.errorMessage.required'
|
|
566
|
+
}),
|
|
567
|
+
onFileUploadRequest: onFileUploadRequest
|
|
568
|
+
}, field)));
|
|
569
|
+
}
|
|
570
|
+
}))))
|
|
617
571
|
});
|
|
618
572
|
};
|
|
619
573
|
//
|
|
620
574
|
//
|
|
621
575
|
//
|
|
622
|
-
return
|
|
623
|
-
children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput()]
|
|
624
|
-
});
|
|
576
|
+
return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput());
|
|
625
577
|
};
|
|
626
578
|
|
|
627
579
|
exports.default = MaterialQuizEditContent;
|