@elice/material-quiz 1.240718.0-trasncript.0 → 1.240718.0-trasncript.2
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/_virtual/_rollupPluginBabelHelpers.js +423 -0
- package/cjs/components/eb-sortable/EbDraggable.js +42 -33
- package/cjs/components/eb-sortable/EbDroppable.js +27 -20
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
- package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
- package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
- package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
- 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 +156 -93
- package/cjs/components/material-quiz/index.js +9 -0
- package/cjs/components/material-quiz/locales/index.js +13 -0
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
- package/cjs/components/material-quiz-edit/context.js +8 -2
- package/cjs/components/material-quiz-edit/index.js +7 -0
- package/cjs/components/material-quiz-edit/locales/index.js +13 -0
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
- package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
- package/cjs/components/shared/QuestionBox.js +198 -165
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
- package/cjs/components/shared/QuizDraggbleOption.js +65 -59
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/index.js +19 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/cjs/components/shared/utils/mergeRefs.js +15 -6
- package/cjs/constant/element.js +3 -3
- package/cjs/constant/index.js +9 -0
- package/cjs/helpers/index.js +8 -10
- package/cjs/hooks/index.js +7 -0
- package/cjs/hooks/useCaculatePassage.js +21 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
- package/es/components/eb-sortable/EbDraggable.js +37 -33
- package/es/components/eb-sortable/EbDroppable.js +22 -20
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-quiz/MaterialQuiz.js +109 -83
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
- package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
- package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
- package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
- package/es/components/material-quiz/MaterialQuizText.js +158 -115
- package/es/components/material-quiz/QuizResultBadge.js +27 -22
- package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
- 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 +153 -94
- package/es/components/material-quiz/index.js +2 -0
- package/es/components/material-quiz/locales/index.js +4 -0
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
- package/es/components/material-quiz-edit/context.js +4 -2
- package/es/components/material-quiz-edit/index.js +1 -0
- package/es/components/material-quiz-edit/locales/index.js +4 -0
- package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
- package/es/components/material-quiz-edit/options/OptionText.js +86 -82
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/es/components/material-quiz-edit/utils/editValue.js +17 -12
- package/es/components/shared/QuestionBox.js +192 -165
- package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
- package/es/components/shared/QuizDraggbleOption.js +61 -59
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/index.js +7 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
- package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/es/components/shared/utils/mergeRefs.js +15 -6
- package/es/constant/element.js +3 -3
- package/es/constant/index.js +1 -0
- package/es/helpers/index.js +8 -10
- package/es/hooks/index.js +1 -0
- package/es/hooks/useCaculatePassage.js +21 -20
- package/package.json +12 -15
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { useFormContext, Controller } from 'react-hook-form';
|
|
3
5
|
import { Transition } from 'react-transition-group';
|
|
@@ -16,26 +18,33 @@ import { checkTwoDimensionArray } from './utils/checkTwoDimensionArray.js';
|
|
|
16
18
|
import { createRandomId } from './utils/randomId.js';
|
|
17
19
|
import { useMaterialQuizEditContext } from './context.js';
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
disabled,
|
|
25
|
-
onFileUploadRequest
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
var MIN_TEXT_LENGTH = 1;
|
|
22
|
+
var MAX_TEXT_LENGTH = 128;
|
|
23
|
+
var MaterialQuizEditContent = function MaterialQuizEditContent() {
|
|
24
|
+
var intl = useRawEliceIntl();
|
|
25
|
+
var _useMaterialQuizEditC = useMaterialQuizEditContext(),
|
|
26
|
+
disabled = _useMaterialQuizEditC.disabled,
|
|
27
|
+
onFileUploadRequest = _useMaterialQuizEditC.onFileUploadRequest;
|
|
28
|
+
var _useFormContext = useFormContext(),
|
|
29
|
+
control = _useFormContext.control,
|
|
30
|
+
watch = _useFormContext.watch,
|
|
31
|
+
setValue = _useFormContext.setValue;
|
|
32
|
+
var _watch = watch(['optionType', 'optionsDefault', 'answerInfoDefault', 'answerHint', 'explanationInfo', 'isAutoGrade', 'groups', 'optionsSetEnabled']),
|
|
33
|
+
_watch2 = _slicedToArray(_watch, 8),
|
|
34
|
+
watchedOptionType = _watch2[0],
|
|
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];
|
|
33
42
|
//
|
|
34
43
|
// Change `options` according to `optionType`.
|
|
35
44
|
//
|
|
36
|
-
React.useEffect(()
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
React.useEffect(function () {
|
|
46
|
+
var get = function get() {
|
|
47
|
+
var filteredNotMarkdownOptions = watchedOptionInfo === null || watchedOptionInfo === void 0 ? void 0 : watchedOptionInfo.filter(function (option) {
|
|
39
48
|
var _a;
|
|
40
49
|
return !((_a = option.content) === null || _a === void 0 ? void 0 : _a.includes('![]'));
|
|
41
50
|
});
|
|
@@ -64,7 +73,7 @@ const MaterialQuizEditContent = () => {
|
|
|
64
73
|
}];
|
|
65
74
|
}
|
|
66
75
|
if (filteredNotMarkdownOptions.length) {
|
|
67
|
-
return watchedOptionInfo.map(e
|
|
76
|
+
return watchedOptionInfo.map(function (e) {
|
|
68
77
|
var _a;
|
|
69
78
|
if ((_a = e.title) === null || _a === void 0 ? void 0 : _a.length) {
|
|
70
79
|
return Object.assign(Object.assign({}, e), {
|
|
@@ -98,7 +107,7 @@ const MaterialQuizEditContent = () => {
|
|
|
98
107
|
}];
|
|
99
108
|
}
|
|
100
109
|
if (filteredNotMarkdownOptions.length) {
|
|
101
|
-
return watchedOptionInfo.map(e
|
|
110
|
+
return watchedOptionInfo.map(function (e) {
|
|
102
111
|
var _a, _b;
|
|
103
112
|
if (!((_a = e.content) === null || _a === void 0 ? void 0 : _a.includes('![]')) && !((_b = e.title) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
104
113
|
return Object.assign(Object.assign({}, e), {
|
|
@@ -123,15 +132,15 @@ const MaterialQuizEditContent = () => {
|
|
|
123
132
|
//
|
|
124
133
|
// Change `answerInfo` according to `optionType`.
|
|
125
134
|
//
|
|
126
|
-
React.useEffect(()
|
|
127
|
-
|
|
135
|
+
React.useEffect(function () {
|
|
136
|
+
var get = function get() {
|
|
128
137
|
switch (watchedOptionType) {
|
|
129
138
|
case enums.QuizOptionType.SelectOne:
|
|
130
139
|
if (!Array.isArray(watchedAnswerInfo)) {
|
|
131
140
|
return [0];
|
|
132
141
|
}
|
|
133
142
|
if (checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
134
|
-
|
|
143
|
+
var convertedAnswerInfo = watchedAnswerInfo;
|
|
135
144
|
return flattenDeep(convertedAnswerInfo).slice(0, 1);
|
|
136
145
|
}
|
|
137
146
|
return watchedAnswerInfo.slice(0, 1);
|
|
@@ -159,8 +168,8 @@ const MaterialQuizEditContent = () => {
|
|
|
159
168
|
//
|
|
160
169
|
// Change `answerHint` according to `optionType`.
|
|
161
170
|
//
|
|
162
|
-
React.useEffect(()
|
|
163
|
-
|
|
171
|
+
React.useEffect(function () {
|
|
172
|
+
var get = function get() {
|
|
164
173
|
switch (watchedOptionType) {
|
|
165
174
|
case enums.QuizOptionType.SelectOne:
|
|
166
175
|
case enums.QuizOptionType.SelectMultiple:
|
|
@@ -180,8 +189,8 @@ const MaterialQuizEditContent = () => {
|
|
|
180
189
|
//
|
|
181
190
|
// Change `isAutoGrade` according to `optionType`.
|
|
182
191
|
//
|
|
183
|
-
React.useEffect(()
|
|
184
|
-
|
|
192
|
+
React.useEffect(function () {
|
|
193
|
+
var get = function get() {
|
|
185
194
|
switch (watchedOptionType) {
|
|
186
195
|
case enums.QuizOptionType.SelectOne:
|
|
187
196
|
case enums.QuizOptionType.SelectMultiple:
|
|
@@ -201,8 +210,8 @@ const MaterialQuizEditContent = () => {
|
|
|
201
210
|
//
|
|
202
211
|
// Change `groups` according to `optionType`.
|
|
203
212
|
//
|
|
204
|
-
React.useEffect(()
|
|
205
|
-
|
|
213
|
+
React.useEffect(function () {
|
|
214
|
+
var get = function get() {
|
|
206
215
|
switch (watchedOptionType) {
|
|
207
216
|
case enums.QuizOptionType.SelectOne:
|
|
208
217
|
case enums.QuizOptionType.SelectMultiple:
|
|
@@ -237,7 +246,7 @@ const MaterialQuizEditContent = () => {
|
|
|
237
246
|
* Input of option info and answer info,
|
|
238
247
|
* according to option type.
|
|
239
248
|
*/
|
|
240
|
-
|
|
249
|
+
var Option = React.useMemo(function () {
|
|
241
250
|
switch (watchedOptionType) {
|
|
242
251
|
case enums.QuizOptionType.SelectOne:
|
|
243
252
|
return OptionSelectOne;
|
|
@@ -256,15 +265,16 @@ const MaterialQuizEditContent = () => {
|
|
|
256
265
|
/**
|
|
257
266
|
* Render input for quiz title.
|
|
258
267
|
*/
|
|
259
|
-
|
|
260
|
-
return
|
|
261
|
-
label:
|
|
268
|
+
var renderQuestionTitleInput = function renderQuestionTitleInput() {
|
|
269
|
+
return jsx(FormInputVerticalLayout, {
|
|
270
|
+
label: jsx(Label, {
|
|
262
271
|
size: "small",
|
|
263
|
-
required: true
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
272
|
+
required: true,
|
|
273
|
+
children: intl.formatMessage({
|
|
274
|
+
id: 'content.title'
|
|
275
|
+
})
|
|
276
|
+
}),
|
|
277
|
+
input: jsx(Controller, {
|
|
268
278
|
control: control,
|
|
269
279
|
name: "questionTitle",
|
|
270
280
|
rules: {
|
|
@@ -293,12 +303,11 @@ const MaterialQuizEditContent = () => {
|
|
|
293
303
|
})
|
|
294
304
|
}
|
|
295
305
|
},
|
|
296
|
-
render: ({
|
|
297
|
-
field,
|
|
298
|
-
|
|
299
|
-
}) => {
|
|
306
|
+
render: function render(_ref) {
|
|
307
|
+
var field = _ref.field,
|
|
308
|
+
fieldState = _ref.fieldState;
|
|
300
309
|
var _a;
|
|
301
|
-
return
|
|
310
|
+
return jsx(Input, Object.assign({
|
|
302
311
|
size: "small",
|
|
303
312
|
width: "full",
|
|
304
313
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -316,149 +325,169 @@ const MaterialQuizEditContent = () => {
|
|
|
316
325
|
/**
|
|
317
326
|
* Render input for quiz description.
|
|
318
327
|
*/
|
|
319
|
-
|
|
320
|
-
return
|
|
321
|
-
label:
|
|
322
|
-
size: "small"
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
328
|
+
var renderQuestionDescriptionInput = function renderQuestionDescriptionInput() {
|
|
329
|
+
return jsx(FormInputVerticalLayout, {
|
|
330
|
+
label: jsx(Label, {
|
|
331
|
+
size: "small",
|
|
332
|
+
children: intl.formatMessage({
|
|
333
|
+
id: 'content.description.title'
|
|
334
|
+
})
|
|
335
|
+
}),
|
|
336
|
+
input: jsx(Controller, {
|
|
327
337
|
control: control,
|
|
328
338
|
name: "questionDescription",
|
|
329
|
-
render: ({
|
|
330
|
-
field
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
339
|
+
render: function render(_ref2) {
|
|
340
|
+
var field = _ref2.field;
|
|
341
|
+
return jsx(MarkdownEditor, Object.assign({
|
|
342
|
+
placeholder: intl.formatMessage({
|
|
343
|
+
id: 'content.description.placeholder'
|
|
344
|
+
}),
|
|
345
|
+
onFileUploadRequest: onFileUploadRequest
|
|
346
|
+
}, field));
|
|
347
|
+
}
|
|
337
348
|
})
|
|
338
349
|
});
|
|
339
350
|
};
|
|
340
351
|
/**
|
|
341
352
|
* Render input of option type, option info and answer info.
|
|
342
353
|
*/
|
|
343
|
-
|
|
344
|
-
return
|
|
345
|
-
label:
|
|
354
|
+
var renderOptionInput = function renderOptionInput() {
|
|
355
|
+
return jsx(FormInputVerticalLayout, {
|
|
356
|
+
label: jsx(Label, {
|
|
346
357
|
size: "small",
|
|
347
|
-
required: true
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
358
|
+
required: true,
|
|
359
|
+
children: intl.formatMessage({
|
|
360
|
+
id: 'content.option.title'
|
|
361
|
+
})
|
|
362
|
+
}),
|
|
363
|
+
input: jsxs(Fragment, {
|
|
364
|
+
children: [jsx(Controller, {
|
|
365
|
+
control: control,
|
|
366
|
+
name: "optionType",
|
|
367
|
+
render: function render(_ref3) {
|
|
368
|
+
var field = _ref3.field;
|
|
369
|
+
return jsx(Tooltip, {
|
|
370
|
+
title: disabled && intl.formatMessage({
|
|
371
|
+
id: 'content.option.tooltip.disabled'
|
|
372
|
+
}),
|
|
373
|
+
placement: "top-end",
|
|
374
|
+
children: jsxs(Stack, {
|
|
375
|
+
direction: "row",
|
|
376
|
+
justifyContent: "space-between",
|
|
377
|
+
marginBottom: "0.5rem",
|
|
378
|
+
children: [jsxs(TextField, Object.assign({
|
|
379
|
+
select: true,
|
|
380
|
+
disabled: disabled
|
|
381
|
+
}, field, {
|
|
382
|
+
onChange: function onChange(event) {
|
|
383
|
+
var isTextQuizOption = Number(event.target.value) === enums.QuizOptionType.Text;
|
|
384
|
+
if (isTextQuizOption) {
|
|
385
|
+
setValue('optionsSetEnabled', false);
|
|
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
|
+
});
|
|
375
439
|
}
|
|
376
|
-
}),
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
children:
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
440
|
+
}), watchedOptionType !== enums.QuizOptionType.Text && optionsSetEnabled ? jsxs(Alert, {
|
|
441
|
+
severity: "info",
|
|
442
|
+
sx: {
|
|
443
|
+
marginBottom: '1rem'
|
|
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
|
+
})
|
|
400
466
|
})
|
|
401
|
-
})
|
|
402
|
-
|
|
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))
|
|
467
|
+
}), jsx(Option, {})]
|
|
468
|
+
})
|
|
443
469
|
});
|
|
444
470
|
};
|
|
445
471
|
/**
|
|
446
472
|
* Input of answer hint.
|
|
447
473
|
*/
|
|
448
|
-
|
|
474
|
+
var renderAnswerHintInput = function renderAnswerHintInput() {
|
|
449
475
|
if (watchedOptionType !== enums.QuizOptionType.Text) {
|
|
450
476
|
return null;
|
|
451
477
|
}
|
|
452
|
-
return
|
|
453
|
-
label:
|
|
454
|
-
size: "small"
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
478
|
+
return jsx(FormInputVerticalLayout, {
|
|
479
|
+
label: jsx(Label, {
|
|
480
|
+
size: "small",
|
|
481
|
+
children: intl.formatMessage({
|
|
482
|
+
id: 'content.answerHint.title'
|
|
483
|
+
})
|
|
484
|
+
}),
|
|
485
|
+
description: jsx(Text, {
|
|
486
|
+
children: intl.formatMessage({
|
|
487
|
+
id: 'content.answerHint.description'
|
|
488
|
+
})
|
|
489
|
+
}),
|
|
490
|
+
input: jsx(Controller, {
|
|
462
491
|
control: control,
|
|
463
492
|
name: "answerHint",
|
|
464
493
|
rules: {
|
|
@@ -481,12 +510,11 @@ const MaterialQuizEditContent = () => {
|
|
|
481
510
|
})
|
|
482
511
|
}
|
|
483
512
|
},
|
|
484
|
-
render: ({
|
|
485
|
-
field,
|
|
486
|
-
|
|
487
|
-
}) => {
|
|
513
|
+
render: function render(_ref5) {
|
|
514
|
+
var field = _ref5.field,
|
|
515
|
+
fieldState = _ref5.fieldState;
|
|
488
516
|
var _a, _b;
|
|
489
|
-
return
|
|
517
|
+
return jsx(Input, Object.assign({
|
|
490
518
|
size: "small",
|
|
491
519
|
width: "full",
|
|
492
520
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -506,70 +534,85 @@ const MaterialQuizEditContent = () => {
|
|
|
506
534
|
/**
|
|
507
535
|
* Input of explanation info.
|
|
508
536
|
*/
|
|
509
|
-
|
|
510
|
-
return
|
|
511
|
-
label:
|
|
512
|
-
size: "small"
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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
|
-
})
|
|
537
|
+
var renderExplanationInfoInput = function renderExplanationInfoInput() {
|
|
538
|
+
return jsx(FormInputVerticalLayout, {
|
|
539
|
+
label: jsx(Label, {
|
|
540
|
+
size: "small",
|
|
541
|
+
children: intl.formatMessage({
|
|
542
|
+
id: 'content.explanationInfo.title'
|
|
543
|
+
})
|
|
544
|
+
}),
|
|
545
|
+
description: jsx(Text, {
|
|
546
|
+
children: intl.formatMessage({
|
|
547
|
+
id: 'content.explanationInfo.description'
|
|
548
|
+
})
|
|
549
|
+
}),
|
|
550
|
+
input: jsxs(Fragment, {
|
|
551
|
+
children: [jsx(Controller, {
|
|
552
|
+
control: control,
|
|
553
|
+
name: "explanationInfo.isEnabled",
|
|
554
|
+
render: function render(_ref6) {
|
|
555
|
+
var field = _ref6.field;
|
|
556
|
+
return jsx(Checkbox, Object.assign({
|
|
557
|
+
size: "small"
|
|
558
|
+
}, field, {
|
|
559
|
+
children: intl.formatMessage({
|
|
560
|
+
id: 'content.explanationInfo.checkbox.label'
|
|
561
|
+
})
|
|
562
|
+
}));
|
|
545
563
|
}
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
}), jsx(Transition, {
|
|
565
|
+
in: watchedExplanationInfo.isEnabled,
|
|
566
|
+
timeout: 0,
|
|
567
|
+
mountOnEnter: true,
|
|
568
|
+
unmountOnExit: true,
|
|
569
|
+
children: jsxs(Fragment, {
|
|
570
|
+
children: [jsx(Vspace, {
|
|
571
|
+
height: 1
|
|
572
|
+
}), jsx(Controller, {
|
|
573
|
+
control: control,
|
|
574
|
+
name: "explanationInfo.value",
|
|
575
|
+
rules: {
|
|
576
|
+
required: {
|
|
577
|
+
value: true,
|
|
578
|
+
message: intl.formatMessage({
|
|
579
|
+
id: 'content.explanationInfo.textarea.placeholder'
|
|
580
|
+
})
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
render: function render(_ref7) {
|
|
584
|
+
var field = _ref7.field,
|
|
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
|
+
})
|
|
567
608
|
});
|
|
568
609
|
};
|
|
569
610
|
//
|
|
570
611
|
//
|
|
571
612
|
//
|
|
572
|
-
return
|
|
613
|
+
return jsxs(Fragment, {
|
|
614
|
+
children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput()]
|
|
615
|
+
});
|
|
573
616
|
};
|
|
574
617
|
|
|
575
618
|
export { MaterialQuizEditContent as default };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var MaterialQuizEditContext = React.createContext(null);
|
|
4
|
+
var useMaterialQuizEditContext = function useMaterialQuizEditContext() {
|
|
5
|
+
return React.useContext(MaterialQuizEditContext);
|
|
6
|
+
};
|
|
5
7
|
|
|
6
8
|
export { MaterialQuizEditContext as default, useMaterialQuizEditContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MaterialQuizEdit } from './MaterialQuizEdit.js';
|