@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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
5
3
|
import { Transition } from 'react-transition-group';
|
|
@@ -18,33 +16,26 @@ import { checkTwoDimensionArray } from './utils/checkTwoDimensionArray.js';
|
|
|
18
16
|
import { createRandomId } from './utils/randomId.js';
|
|
19
17
|
import { useMaterialQuizEditContext } from './context.js';
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
disabled
|
|
27
|
-
onFileUploadRequest
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
watchedOptionInfo = _watch2[1],
|
|
36
|
-
watchedAnswerInfo = _watch2[2],
|
|
37
|
-
watchedAnswerHint = _watch2[3],
|
|
38
|
-
watchedExplanationInfo = _watch2[4],
|
|
39
|
-
watchedIsAutoGrade = _watch2[5],
|
|
40
|
-
watchedGroups = _watch2[6],
|
|
41
|
-
optionsSetEnabled = _watch2[7];
|
|
19
|
+
const MIN_TEXT_LENGTH = 1;
|
|
20
|
+
const MAX_TEXT_LENGTH = 128;
|
|
21
|
+
const MaterialQuizEditContent = () => {
|
|
22
|
+
const intl = useRawEliceIntl();
|
|
23
|
+
const {
|
|
24
|
+
disabled,
|
|
25
|
+
onFileUploadRequest
|
|
26
|
+
} = useMaterialQuizEditContext();
|
|
27
|
+
const {
|
|
28
|
+
control,
|
|
29
|
+
watch,
|
|
30
|
+
setValue
|
|
31
|
+
} = useFormContext();
|
|
32
|
+
const [watchedOptionType, watchedOptionInfo, watchedAnswerInfo, watchedAnswerHint, watchedExplanationInfo, watchedIsAutoGrade, watchedGroups, optionsSetEnabled] = watch(['optionType', 'optionsDefault', 'answerInfoDefault', 'answerHint', 'explanationInfo', 'isAutoGrade', 'groups', 'optionsSetEnabled']);
|
|
42
33
|
//
|
|
43
34
|
// Change `options` according to `optionType`.
|
|
44
35
|
//
|
|
45
|
-
React.useEffect(
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
const get = () => {
|
|
38
|
+
const filteredNotMarkdownOptions = watchedOptionInfo === null || watchedOptionInfo === void 0 ? void 0 : watchedOptionInfo.filter(option => {
|
|
48
39
|
var _a;
|
|
49
40
|
return !((_a = option.content) === null || _a === void 0 ? void 0 : _a.includes('![]'));
|
|
50
41
|
});
|
|
@@ -73,7 +64,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
73
64
|
}];
|
|
74
65
|
}
|
|
75
66
|
if (filteredNotMarkdownOptions.length) {
|
|
76
|
-
return watchedOptionInfo.map(
|
|
67
|
+
return watchedOptionInfo.map(e => {
|
|
77
68
|
var _a;
|
|
78
69
|
if ((_a = e.title) === null || _a === void 0 ? void 0 : _a.length) {
|
|
79
70
|
return Object.assign(Object.assign({}, e), {
|
|
@@ -107,7 +98,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
107
98
|
}];
|
|
108
99
|
}
|
|
109
100
|
if (filteredNotMarkdownOptions.length) {
|
|
110
|
-
return watchedOptionInfo.map(
|
|
101
|
+
return watchedOptionInfo.map(e => {
|
|
111
102
|
var _a, _b;
|
|
112
103
|
if (!((_a = e.content) === null || _a === void 0 ? void 0 : _a.includes('![]')) && !((_b = e.title) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
113
104
|
return Object.assign(Object.assign({}, e), {
|
|
@@ -132,15 +123,15 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
132
123
|
//
|
|
133
124
|
// Change `answerInfo` according to `optionType`.
|
|
134
125
|
//
|
|
135
|
-
React.useEffect(
|
|
136
|
-
|
|
126
|
+
React.useEffect(() => {
|
|
127
|
+
const get = () => {
|
|
137
128
|
switch (watchedOptionType) {
|
|
138
129
|
case enums.QuizOptionType.SelectOne:
|
|
139
130
|
if (!Array.isArray(watchedAnswerInfo)) {
|
|
140
131
|
return [0];
|
|
141
132
|
}
|
|
142
133
|
if (checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
143
|
-
|
|
134
|
+
const convertedAnswerInfo = watchedAnswerInfo;
|
|
144
135
|
return flattenDeep(convertedAnswerInfo).slice(0, 1);
|
|
145
136
|
}
|
|
146
137
|
return watchedAnswerInfo.slice(0, 1);
|
|
@@ -168,8 +159,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
168
159
|
//
|
|
169
160
|
// Change `answerHint` according to `optionType`.
|
|
170
161
|
//
|
|
171
|
-
React.useEffect(
|
|
172
|
-
|
|
162
|
+
React.useEffect(() => {
|
|
163
|
+
const get = () => {
|
|
173
164
|
switch (watchedOptionType) {
|
|
174
165
|
case enums.QuizOptionType.SelectOne:
|
|
175
166
|
case enums.QuizOptionType.SelectMultiple:
|
|
@@ -189,8 +180,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
189
180
|
//
|
|
190
181
|
// Change `isAutoGrade` according to `optionType`.
|
|
191
182
|
//
|
|
192
|
-
React.useEffect(
|
|
193
|
-
|
|
183
|
+
React.useEffect(() => {
|
|
184
|
+
const get = () => {
|
|
194
185
|
switch (watchedOptionType) {
|
|
195
186
|
case enums.QuizOptionType.SelectOne:
|
|
196
187
|
case enums.QuizOptionType.SelectMultiple:
|
|
@@ -210,8 +201,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
210
201
|
//
|
|
211
202
|
// Change `groups` according to `optionType`.
|
|
212
203
|
//
|
|
213
|
-
React.useEffect(
|
|
214
|
-
|
|
204
|
+
React.useEffect(() => {
|
|
205
|
+
const get = () => {
|
|
215
206
|
switch (watchedOptionType) {
|
|
216
207
|
case enums.QuizOptionType.SelectOne:
|
|
217
208
|
case enums.QuizOptionType.SelectMultiple:
|
|
@@ -246,7 +237,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
246
237
|
* Input of option info and answer info,
|
|
247
238
|
* according to option type.
|
|
248
239
|
*/
|
|
249
|
-
|
|
240
|
+
const Option = React.useMemo(() => {
|
|
250
241
|
switch (watchedOptionType) {
|
|
251
242
|
case enums.QuizOptionType.SelectOne:
|
|
252
243
|
return OptionSelectOne;
|
|
@@ -265,16 +256,15 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
265
256
|
/**
|
|
266
257
|
* Render input for quiz title.
|
|
267
258
|
*/
|
|
268
|
-
|
|
269
|
-
return
|
|
270
|
-
label:
|
|
259
|
+
const renderQuestionTitleInput = () => {
|
|
260
|
+
return React.createElement(FormInputVerticalLayout, {
|
|
261
|
+
label: React.createElement(Label, {
|
|
271
262
|
size: "small",
|
|
272
|
-
required: true
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
input: jsx(Controller, {
|
|
263
|
+
required: true
|
|
264
|
+
}, intl.formatMessage({
|
|
265
|
+
id: 'content.title'
|
|
266
|
+
})),
|
|
267
|
+
input: React.createElement(Controller, {
|
|
278
268
|
control: control,
|
|
279
269
|
name: "questionTitle",
|
|
280
270
|
rules: {
|
|
@@ -303,11 +293,12 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
303
293
|
})
|
|
304
294
|
}
|
|
305
295
|
},
|
|
306
|
-
render:
|
|
307
|
-
|
|
308
|
-
|
|
296
|
+
render: ({
|
|
297
|
+
field,
|
|
298
|
+
fieldState
|
|
299
|
+
}) => {
|
|
309
300
|
var _a;
|
|
310
|
-
return
|
|
301
|
+
return React.createElement(Input, Object.assign({
|
|
311
302
|
size: "small",
|
|
312
303
|
width: "full",
|
|
313
304
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -325,169 +316,149 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
325
316
|
/**
|
|
326
317
|
* Render input for quiz description.
|
|
327
318
|
*/
|
|
328
|
-
|
|
329
|
-
return
|
|
330
|
-
label:
|
|
331
|
-
size: "small"
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
input: jsx(Controller, {
|
|
319
|
+
const renderQuestionDescriptionInput = () => {
|
|
320
|
+
return React.createElement(FormInputVerticalLayout, {
|
|
321
|
+
label: React.createElement(Label, {
|
|
322
|
+
size: "small"
|
|
323
|
+
}, intl.formatMessage({
|
|
324
|
+
id: 'content.description.title'
|
|
325
|
+
})),
|
|
326
|
+
input: React.createElement(Controller, {
|
|
337
327
|
control: control,
|
|
338
328
|
name: "questionDescription",
|
|
339
|
-
render:
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}
|
|
329
|
+
render: ({
|
|
330
|
+
field
|
|
331
|
+
}) => React.createElement(MarkdownEditor, Object.assign({
|
|
332
|
+
placeholder: intl.formatMessage({
|
|
333
|
+
id: 'content.description.placeholder'
|
|
334
|
+
}),
|
|
335
|
+
onFileUploadRequest: onFileUploadRequest
|
|
336
|
+
}, field))
|
|
348
337
|
})
|
|
349
338
|
});
|
|
350
339
|
};
|
|
351
340
|
/**
|
|
352
341
|
* Render input of option type, option info and answer info.
|
|
353
342
|
*/
|
|
354
|
-
|
|
355
|
-
return
|
|
356
|
-
label:
|
|
343
|
+
const renderOptionInput = () => {
|
|
344
|
+
return React.createElement(FormInputVerticalLayout, {
|
|
345
|
+
label: React.createElement(Label, {
|
|
357
346
|
size: "small",
|
|
358
|
-
required: true
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
387
|
-
field.onChange(event);
|
|
388
|
-
},
|
|
389
|
-
children: [jsx(MenuItem, {
|
|
390
|
-
value: enums.QuizOptionType.SelectOne,
|
|
391
|
-
children: intl.formatMessage({
|
|
392
|
-
id: 'content.option.select.items.selectOne'
|
|
393
|
-
})
|
|
394
|
-
}), jsx(MenuItem, {
|
|
395
|
-
value: enums.QuizOptionType.SelectMultiple,
|
|
396
|
-
children: intl.formatMessage({
|
|
397
|
-
id: 'content.option.select.items.selectMultiple'
|
|
398
|
-
})
|
|
399
|
-
}), jsx(MenuItem, {
|
|
400
|
-
value: enums.QuizOptionType.SelectMultipleOrder,
|
|
401
|
-
children: intl.formatMessage({
|
|
402
|
-
id: 'content.option.select.items.selectMultipleOrder'
|
|
403
|
-
})
|
|
404
|
-
}), jsx(MenuItem, {
|
|
405
|
-
value: enums.QuizOptionType.Group,
|
|
406
|
-
children: intl.formatMessage({
|
|
407
|
-
id: 'content.option.select.items.group'
|
|
408
|
-
})
|
|
409
|
-
}), jsx(MenuItem, {
|
|
410
|
-
value: enums.QuizOptionType.Text,
|
|
411
|
-
children: intl.formatMessage({
|
|
412
|
-
id: 'content.option.select.items.text'
|
|
413
|
-
})
|
|
414
|
-
})]
|
|
415
|
-
})), watchedOptionType !== enums.QuizOptionType.Text ? jsx(Controller, {
|
|
416
|
-
name: "optionsSetEnabled",
|
|
417
|
-
control: control,
|
|
418
|
-
render: function render(_ref4) {
|
|
419
|
-
var field = _ref4.field;
|
|
420
|
-
return jsx(Tooltip, {
|
|
421
|
-
title: disabled ? '' : intl.formatMessage({
|
|
422
|
-
id: 'content.option.optionsSetEnabled.tooltip'
|
|
423
|
-
}),
|
|
424
|
-
placement: "top",
|
|
425
|
-
children: jsx(FormControlLabel, {
|
|
426
|
-
disabled: disabled,
|
|
427
|
-
label: intl.formatMessage({
|
|
428
|
-
id: 'content.option.optionsSetEnabled.label'
|
|
429
|
-
}),
|
|
430
|
-
control: jsx(Switch, Object.assign({}, field, {
|
|
431
|
-
checked: field.value
|
|
432
|
-
}))
|
|
433
|
-
})
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
}) : null]
|
|
437
|
-
})
|
|
438
|
-
});
|
|
347
|
+
required: true
|
|
348
|
+
}, intl.formatMessage({
|
|
349
|
+
id: 'content.option.title'
|
|
350
|
+
})),
|
|
351
|
+
input: React.createElement(React.Fragment, null, React.createElement(Controller, {
|
|
352
|
+
control: control,
|
|
353
|
+
name: "optionType",
|
|
354
|
+
render: ({
|
|
355
|
+
field
|
|
356
|
+
}) => React.createElement(Tooltip, {
|
|
357
|
+
title: disabled && intl.formatMessage({
|
|
358
|
+
id: 'content.option.tooltip.disabled'
|
|
359
|
+
}),
|
|
360
|
+
placement: "top-end"
|
|
361
|
+
}, React.createElement(Stack, {
|
|
362
|
+
direction: "row",
|
|
363
|
+
justifyContent: "space-between",
|
|
364
|
+
marginBottom: "0.5rem"
|
|
365
|
+
}, React.createElement(TextField, Object.assign({
|
|
366
|
+
select: true,
|
|
367
|
+
disabled: disabled
|
|
368
|
+
}, field, {
|
|
369
|
+
onChange: event => {
|
|
370
|
+
const isTextQuizOption = Number(event.target.value) === enums.QuizOptionType.Text;
|
|
371
|
+
if (isTextQuizOption) {
|
|
372
|
+
setValue('optionsSetEnabled', false);
|
|
373
|
+
}
|
|
374
|
+
field.onChange(event);
|
|
439
375
|
}
|
|
440
|
-
}),
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
},
|
|
445
|
-
children: [jsx(AlertTitle, {
|
|
446
|
-
children: intl.formatMessage({
|
|
447
|
-
id: 'content.option.alert.randomized.title'
|
|
448
|
-
})
|
|
449
|
-
}), intl.formatMessage({
|
|
450
|
-
id: 'content.option.alert.randomized.description'
|
|
451
|
-
})]
|
|
452
|
-
}) : null, jsx(Transition, {
|
|
453
|
-
in: watchedOptionType === enums.QuizOptionType.SelectMultipleOrder || watchedOptionType === enums.QuizOptionType.Group,
|
|
454
|
-
timeout: 0,
|
|
455
|
-
mountOnEnter: true,
|
|
456
|
-
unmountOnExit: true,
|
|
457
|
-
children: jsx(Box, {
|
|
458
|
-
marginBottom: "0.5rem",
|
|
459
|
-
children: jsx(StatusText, {
|
|
460
|
-
role: "description",
|
|
461
|
-
preWrap: true,
|
|
462
|
-
children: intl.formatMessage({
|
|
463
|
-
id: watchedOptionType === enums.QuizOptionType.SelectMultipleOrder ? 'content.option.statusText.dragNDrop' : 'content.option.statusText.dragNDropGroup'
|
|
464
|
-
})
|
|
465
|
-
})
|
|
376
|
+
}), React.createElement(MenuItem, {
|
|
377
|
+
value: enums.QuizOptionType.SelectOne,
|
|
378
|
+
children: intl.formatMessage({
|
|
379
|
+
id: 'content.option.select.items.selectOne'
|
|
466
380
|
})
|
|
467
|
-
}),
|
|
468
|
-
|
|
381
|
+
}), React.createElement(MenuItem, {
|
|
382
|
+
value: enums.QuizOptionType.SelectMultiple,
|
|
383
|
+
children: intl.formatMessage({
|
|
384
|
+
id: 'content.option.select.items.selectMultiple'
|
|
385
|
+
})
|
|
386
|
+
}), React.createElement(MenuItem, {
|
|
387
|
+
value: enums.QuizOptionType.SelectMultipleOrder,
|
|
388
|
+
children: intl.formatMessage({
|
|
389
|
+
id: 'content.option.select.items.selectMultipleOrder'
|
|
390
|
+
})
|
|
391
|
+
}), React.createElement(MenuItem, {
|
|
392
|
+
value: enums.QuizOptionType.Group,
|
|
393
|
+
children: intl.formatMessage({
|
|
394
|
+
id: 'content.option.select.items.group'
|
|
395
|
+
})
|
|
396
|
+
}), React.createElement(MenuItem, {
|
|
397
|
+
value: enums.QuizOptionType.Text,
|
|
398
|
+
children: intl.formatMessage({
|
|
399
|
+
id: 'content.option.select.items.text'
|
|
400
|
+
})
|
|
401
|
+
})), watchedOptionType !== enums.QuizOptionType.Text ? React.createElement(Controller, {
|
|
402
|
+
name: "optionsSetEnabled",
|
|
403
|
+
control: control,
|
|
404
|
+
render: ({
|
|
405
|
+
field
|
|
406
|
+
}) => React.createElement(Tooltip, {
|
|
407
|
+
title: disabled ? '' : intl.formatMessage({
|
|
408
|
+
id: 'content.option.optionsSetEnabled.tooltip'
|
|
409
|
+
}),
|
|
410
|
+
placement: "top"
|
|
411
|
+
}, React.createElement(FormControlLabel, {
|
|
412
|
+
disabled: disabled,
|
|
413
|
+
label: intl.formatMessage({
|
|
414
|
+
id: 'content.option.optionsSetEnabled.label'
|
|
415
|
+
}),
|
|
416
|
+
control: React.createElement(Switch, Object.assign({}, field, {
|
|
417
|
+
checked: field.value
|
|
418
|
+
}))
|
|
419
|
+
}))
|
|
420
|
+
}) : null))
|
|
421
|
+
}), watchedOptionType !== enums.QuizOptionType.Text && optionsSetEnabled ? React.createElement(Alert, {
|
|
422
|
+
severity: "info",
|
|
423
|
+
sx: {
|
|
424
|
+
marginBottom: '1rem'
|
|
425
|
+
}
|
|
426
|
+
}, React.createElement(AlertTitle, null, intl.formatMessage({
|
|
427
|
+
id: 'content.option.alert.randomized.title'
|
|
428
|
+
})), intl.formatMessage({
|
|
429
|
+
id: 'content.option.alert.randomized.description'
|
|
430
|
+
})) : null, React.createElement(Transition, {
|
|
431
|
+
in: watchedOptionType === enums.QuizOptionType.SelectMultipleOrder || watchedOptionType === enums.QuizOptionType.Group,
|
|
432
|
+
timeout: 0,
|
|
433
|
+
mountOnEnter: true,
|
|
434
|
+
unmountOnExit: true
|
|
435
|
+
}, React.createElement(Box, {
|
|
436
|
+
marginBottom: "0.5rem"
|
|
437
|
+
}, React.createElement(StatusText, {
|
|
438
|
+
role: "description",
|
|
439
|
+
preWrap: true
|
|
440
|
+
}, intl.formatMessage({
|
|
441
|
+
id: watchedOptionType === enums.QuizOptionType.SelectMultipleOrder ? 'content.option.statusText.dragNDrop' : 'content.option.statusText.dragNDropGroup'
|
|
442
|
+
})))), React.createElement(Option, null))
|
|
469
443
|
});
|
|
470
444
|
};
|
|
471
445
|
/**
|
|
472
446
|
* Input of answer hint.
|
|
473
447
|
*/
|
|
474
|
-
|
|
448
|
+
const renderAnswerHintInput = () => {
|
|
475
449
|
if (watchedOptionType !== enums.QuizOptionType.Text) {
|
|
476
450
|
return null;
|
|
477
451
|
}
|
|
478
|
-
return
|
|
479
|
-
label:
|
|
480
|
-
size: "small"
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
})
|
|
489
|
-
}),
|
|
490
|
-
input: jsx(Controller, {
|
|
452
|
+
return React.createElement(FormInputVerticalLayout, {
|
|
453
|
+
label: React.createElement(Label, {
|
|
454
|
+
size: "small"
|
|
455
|
+
}, intl.formatMessage({
|
|
456
|
+
id: 'content.answerHint.title'
|
|
457
|
+
})),
|
|
458
|
+
description: React.createElement(Text, null, intl.formatMessage({
|
|
459
|
+
id: 'content.answerHint.description'
|
|
460
|
+
})),
|
|
461
|
+
input: React.createElement(Controller, {
|
|
491
462
|
control: control,
|
|
492
463
|
name: "answerHint",
|
|
493
464
|
rules: {
|
|
@@ -510,11 +481,12 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
510
481
|
})
|
|
511
482
|
}
|
|
512
483
|
},
|
|
513
|
-
render:
|
|
514
|
-
|
|
515
|
-
|
|
484
|
+
render: ({
|
|
485
|
+
field,
|
|
486
|
+
fieldState
|
|
487
|
+
}) => {
|
|
516
488
|
var _a, _b;
|
|
517
|
-
return
|
|
489
|
+
return React.createElement(Input, Object.assign({
|
|
518
490
|
size: "small",
|
|
519
491
|
width: "full",
|
|
520
492
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -534,85 +506,70 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
|
534
506
|
/**
|
|
535
507
|
* Input of explanation info.
|
|
536
508
|
*/
|
|
537
|
-
|
|
538
|
-
return
|
|
539
|
-
label:
|
|
540
|
-
size: "small"
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
509
|
+
const renderExplanationInfoInput = () => {
|
|
510
|
+
return React.createElement(FormInputVerticalLayout, {
|
|
511
|
+
label: React.createElement(Label, {
|
|
512
|
+
size: "small"
|
|
513
|
+
}, intl.formatMessage({
|
|
514
|
+
id: 'content.explanationInfo.title'
|
|
515
|
+
})),
|
|
516
|
+
description: React.createElement(Text, null, intl.formatMessage({
|
|
517
|
+
id: 'content.explanationInfo.description'
|
|
518
|
+
})),
|
|
519
|
+
input: React.createElement(React.Fragment, null, React.createElement(Controller, {
|
|
520
|
+
control: control,
|
|
521
|
+
name: "explanationInfo.isEnabled",
|
|
522
|
+
render: ({
|
|
523
|
+
field
|
|
524
|
+
}) => React.createElement(Checkbox, Object.assign({
|
|
525
|
+
size: "small"
|
|
526
|
+
}, field), intl.formatMessage({
|
|
527
|
+
id: 'content.explanationInfo.checkbox.label'
|
|
528
|
+
}))
|
|
529
|
+
}), React.createElement(Transition, {
|
|
530
|
+
in: watchedExplanationInfo.isEnabled,
|
|
531
|
+
timeout: 0,
|
|
532
|
+
mountOnEnter: true,
|
|
533
|
+
unmountOnExit: true
|
|
534
|
+
}, React.createElement(React.Fragment, null, React.createElement(Vspace, {
|
|
535
|
+
height: 1
|
|
536
|
+
}), React.createElement(Controller, {
|
|
537
|
+
control: control,
|
|
538
|
+
name: "explanationInfo.value",
|
|
539
|
+
rules: {
|
|
540
|
+
required: {
|
|
541
|
+
value: true,
|
|
542
|
+
message: intl.formatMessage({
|
|
543
|
+
id: 'content.explanationInfo.textarea.placeholder'
|
|
544
|
+
})
|
|
563
545
|
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
fieldState = _ref7.fieldState;
|
|
586
|
-
var _a;
|
|
587
|
-
return jsxs(Flex, {
|
|
588
|
-
column: true,
|
|
589
|
-
children: [fieldState.invalid ? jsxs(Fragment, {
|
|
590
|
-
children: [jsx(StatusText, {
|
|
591
|
-
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
592
|
-
role: "danger"
|
|
593
|
-
}), jsx(Vspace, {
|
|
594
|
-
height: 0.5
|
|
595
|
-
})]
|
|
596
|
-
}) : null, jsx(MarkdownEditor, Object.assign({
|
|
597
|
-
placeholder: intl.formatMessage({
|
|
598
|
-
id: 'content.explanationInfo.textarea.errorMessage.required'
|
|
599
|
-
}),
|
|
600
|
-
onFileUploadRequest: onFileUploadRequest
|
|
601
|
-
}, field))]
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
})]
|
|
605
|
-
})
|
|
606
|
-
})]
|
|
607
|
-
})
|
|
546
|
+
},
|
|
547
|
+
render: ({
|
|
548
|
+
field,
|
|
549
|
+
fieldState
|
|
550
|
+
}) => {
|
|
551
|
+
var _a;
|
|
552
|
+
return React.createElement(Flex, {
|
|
553
|
+
column: true
|
|
554
|
+
}, fieldState.invalid ? React.createElement(React.Fragment, null, React.createElement(StatusText, {
|
|
555
|
+
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
556
|
+
role: "danger"
|
|
557
|
+
}), React.createElement(Vspace, {
|
|
558
|
+
height: 0.5
|
|
559
|
+
})) : null, React.createElement(MarkdownEditor, Object.assign({
|
|
560
|
+
placeholder: intl.formatMessage({
|
|
561
|
+
id: 'content.explanationInfo.textarea.errorMessage.required'
|
|
562
|
+
}),
|
|
563
|
+
onFileUploadRequest: onFileUploadRequest
|
|
564
|
+
}, field)));
|
|
565
|
+
}
|
|
566
|
+
}))))
|
|
608
567
|
});
|
|
609
568
|
};
|
|
610
569
|
//
|
|
611
570
|
//
|
|
612
571
|
//
|
|
613
|
-
return
|
|
614
|
-
children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput()]
|
|
615
|
-
});
|
|
572
|
+
return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput());
|
|
616
573
|
};
|
|
617
574
|
|
|
618
575
|
export { MaterialQuizEditContent as default };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return React.useContext(MaterialQuizEditContext);
|
|
6
|
-
};
|
|
3
|
+
const MaterialQuizEditContext = React.createContext(null);
|
|
4
|
+
const useMaterialQuizEditContext = () => React.useContext(MaterialQuizEditContext);
|
|
7
5
|
|
|
8
6
|
export { MaterialQuizEditContext as default, useMaterialQuizEditContext };
|