@elice/material-quiz 1.240719.1 → 1.240722.0-dev2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/cjs/components/eb-sortable/EbDraggable.d.ts +1 -12
  2. package/cjs/components/eb-sortable/EbDraggable.js +29 -99
  3. package/cjs/components/eb-sortable/EbDroppable.d.ts +3 -8
  4. package/cjs/components/eb-sortable/EbDroppable.js +17 -43
  5. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +2 -1
  6. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +246 -173
  7. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +2 -1
  8. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +41 -10
  9. package/cjs/components/shared/QuizDraggbleDroppedOption.d.ts +1 -1
  10. package/cjs/components/shared/QuizDraggbleDroppedOption.js +35 -10
  11. package/cjs/components/shared/QuizDraggbleDummyOption.d.ts +1 -3
  12. package/cjs/components/shared/QuizDraggbleDummyOption.js +8 -3
  13. package/cjs/components/shared/QuizDraggbleOption.d.ts +0 -1
  14. package/cjs/components/shared/QuizDraggbleOption.js +10 -4
  15. package/es/components/eb-sortable/EbDraggable.d.ts +1 -12
  16. package/es/components/eb-sortable/EbDraggable.js +29 -94
  17. package/es/components/eb-sortable/EbDroppable.d.ts +3 -8
  18. package/es/components/eb-sortable/EbDroppable.js +17 -38
  19. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +2 -1
  20. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +246 -173
  21. package/es/components/material-quiz/MaterialQuizSelectOne.js +2 -1
  22. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +42 -11
  23. package/es/components/shared/QuizDraggbleDroppedOption.d.ts +1 -1
  24. package/es/components/shared/QuizDraggbleDroppedOption.js +31 -10
  25. package/es/components/shared/QuizDraggbleDummyOption.d.ts +1 -3
  26. package/es/components/shared/QuizDraggbleDummyOption.js +8 -3
  27. package/es/components/shared/QuizDraggbleOption.d.ts +0 -1
  28. package/es/components/shared/QuizDraggbleOption.js +10 -4
  29. package/package.json +5 -3
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var React = require('react');
8
+ var core = require('@dnd-kit/core');
8
9
  var apiClient = require('@elice/api-client');
9
10
  var blocks = require('@elice/blocks');
10
11
  var designTokens = require('@elice/design-tokens');
@@ -31,6 +32,9 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
31
32
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
32
33
  var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
33
34
 
35
+ //
36
+ //
37
+ //
34
38
  var StyledVerticalDivider = styled__default.default.div.withConfig({
35
39
  componentId: "sc-10067nt-0"
36
40
  })(["display:flex;flex-direction:column;align-items:center;justify-content:center;flex:none !important;padding:1rem;", ""], function (_ref) {
@@ -55,6 +59,9 @@ var StyledOptionBox = styled__default.default.div.withConfig({
55
59
  var vertical = _ref3.vertical;
56
60
  return vertical ? "\n flex-direction: column;\n " : '';
57
61
  });
62
+ //
63
+ //
64
+ //
58
65
  var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_ref4) {
59
66
  var hasInlinePassage = _ref4.hasInlinePassage;
60
67
  // context
@@ -109,52 +116,16 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
109
116
  }).length || !!userId;
110
117
  // ref
111
118
  var optionBoxRef = React__default.default.useRef(null);
112
- // to make jquery touchable
113
- React__default.default.useEffect(function () {
114
- var optionBoxElement = optionBoxRef.current;
115
- if (!optionBoxElement) {
116
- return;
119
+ var sensors = core.useSensors(core.useSensor(core.MouseSensor, {
120
+ activationConstraint: {
121
+ distance: 10
117
122
  }
118
- /**
119
- * Lightweight script to convert touch handlers to mouse handlers
120
- * credit: http://stackoverflow.com/a/6141093
121
- */
122
- function touchHandler(event) {
123
- var touches = event.changedTouches;
124
- var first = touches[0];
125
- var type = '';
126
- switch (event.type) {
127
- case 'touchstart':
128
- type = 'mousedown';
129
- break;
130
- case 'touchmove':
131
- type = 'mousemove';
132
- break;
133
- case 'touchend':
134
- type = 'mouseup';
135
- break;
136
- default:
137
- return;
138
- }
139
- // initMouseEvent(type, canBubble, cancelable, view, clickCount,
140
- // screenX, screenY, clientX, clientY, ctrlKey,
141
- // altKey, shiftKey, metaKey, button, relatedTarget);
142
- var simulatedEvent = document.createEvent('MouseEvent');
143
- simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0 /*left*/, null);
144
- first.target.dispatchEvent(simulatedEvent);
145
- event.preventDefault();
123
+ }), core.useSensor(core.TouchSensor, {
124
+ activationConstraint: {
125
+ delay: 50,
126
+ tolerance: 5
146
127
  }
147
- optionBoxElement.addEventListener('touchstart', touchHandler, true);
148
- optionBoxElement.addEventListener('touchmove', touchHandler, true);
149
- optionBoxElement.addEventListener('touchend', touchHandler, true);
150
- optionBoxElement.addEventListener('touchcancel', touchHandler, true);
151
- return function () {
152
- optionBoxElement.removeEventListener('touchstart', touchHandler, true);
153
- optionBoxElement.removeEventListener('touchmove', touchHandler, true);
154
- optionBoxElement.removeEventListener('touchend', touchHandler, true);
155
- optionBoxElement.removeEventListener('touchcancel', touchHandler, true);
156
- };
157
- }, []);
128
+ }));
158
129
  // quiz response fetcher
159
130
  React__default.default.useEffect(function () {
160
131
  var _a, _b;
@@ -170,10 +141,11 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
170
141
  setMaterialQuizResponse(response.quizResponse);
171
142
  var answer = response.quizResponse.answer; // user submitted
172
143
  var options = (_a = materialQuiz.options) !== null && _a !== void 0 ? _a : []; // options
173
- var answerList = answer.map(function (answer) {
144
+ var answerList = answer.map(function (answer, index) {
174
145
  var _a, _b;
175
146
  return {
176
- order: answer,
147
+ initialOrder: answer,
148
+ order: index,
177
149
  value: (_b = (_a = options[answer]) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : ''
178
150
  };
179
151
  }, []);
@@ -182,6 +154,9 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
182
154
  }).map(function (option) {
183
155
  var _a;
184
156
  return {
157
+ initialOrder: options.findIndex(function (optionInfo) {
158
+ return optionInfo === option;
159
+ }),
185
160
  order: options.findIndex(function (optionInfo) {
186
161
  return optionInfo === option;
187
162
  }),
@@ -200,6 +175,7 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
200
175
  setOptionList(((_a = materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.options) === null || _a === void 0 ? void 0 : _a.map(function (option, index) {
201
176
  var _a;
202
177
  return {
178
+ initialOrder: index,
203
179
  order: index,
204
180
  value: (_a = option === null || option === void 0 ? void 0 : option.content) !== null && _a !== void 0 ? _a : ''
205
181
  };
@@ -208,6 +184,7 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
208
184
  length: (_b = materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.correctOptionCount) !== null && _b !== void 0 ? _b : 0
209
185
  }, function () {
210
186
  return {
187
+ initialOrder: null,
211
188
  order: null,
212
189
  value: null
213
190
  };
@@ -238,6 +215,7 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
238
215
  var correctAnswerList = Array.isArray(materialQuizAnswerInfo) ? (_c = materialQuizAnswerInfo === null || materialQuizAnswerInfo === void 0 ? void 0 : materialQuizAnswerInfo.map(function (answerInfo) {
239
216
  var _a, _b, _c;
240
217
  return {
218
+ initialOrder: answerInfo,
241
219
  order: answerInfo,
242
220
  value: (_c = (_b = (_a = materialQuiz.options) === null || _a === void 0 ? void 0 : _a[answerInfo]) === null || _b === void 0 ? void 0 : _b.content) !== null && _c !== void 0 ? _c : ''
243
221
  };
@@ -245,6 +223,7 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
245
223
  var answerList = answer.map(function (answer) {
246
224
  var _a, _b;
247
225
  return {
226
+ initialOrder: answer,
248
227
  order: answer,
249
228
  value: (_b = (_a = options[answer]) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : ''
250
229
  };
@@ -254,6 +233,9 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
254
233
  }).map(function (option) {
255
234
  var _a;
256
235
  return {
236
+ initialOrder: options.findIndex(function (optionInfo) {
237
+ return optionInfo === option;
238
+ }),
257
239
  order: options.findIndex(function (optionInfo) {
258
240
  return optionInfo === option;
259
241
  }),
@@ -271,7 +253,9 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
271
253
  };
272
254
  }
273
255
  }, [materialQuiz, userId]);
274
- // submit handler
256
+ /**
257
+ * submit handler
258
+ */
275
259
  var handleSubmit = /*#__PURE__*/function () {
276
260
  var _ref5 = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
277
261
  var _yield$postOrgMateria, quizResponseId, _yield$getOrgMaterial, quizResponse;
@@ -290,8 +274,8 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
290
274
  return apiClient.postOrgMaterialQuizResponseAdd({
291
275
  materialQuizId: materialQuiz.id,
292
276
  answer: answerList.map(function (answer) {
293
- return answer.order;
294
- }) // FIXME: Type mismatch
277
+ return answer.initialOrder;
278
+ })
295
279
  });
296
280
  case 6:
297
281
  _yield$postOrgMateria = _context.sent;
@@ -328,48 +312,175 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
328
312
  return _ref5.apply(this, arguments);
329
313
  };
330
314
  }();
315
+ /**
316
+ *
317
+ */
318
+ var handleDragEnd = function handleDragEnd(event) {
319
+ var _a;
320
+ if (index.checkUserLectureTestEnded(lecture)) {
321
+ return;
322
+ }
323
+ var targetId = Number(event.active.id.split('-').pop());
324
+ var dropzoneId = (_a = event.over) === null || _a === void 0 ? void 0 : _a.id.toString();
325
+ setIsActive(true);
326
+ setHasSubmitted(false);
327
+ dropzoneId === 'quiz-options-dropzone' && onDirty(true);
328
+ if (dropzoneId === 'quiz-options-dropzone') {
329
+ handleDropOptionZone(event, targetId);
330
+ } else if (dropzoneId === null || dropzoneId === void 0 ? void 0 : dropzoneId.includes('quiz-dummy-zone')) {
331
+ handleDropDummyZone(event, targetId);
332
+ } else if (dropzoneId === null || dropzoneId === void 0 ? void 0 : dropzoneId.includes('quiz-answer-zone')) {
333
+ handleDropAnswerZone(event, targetId);
334
+ }
335
+ };
336
+ /**
337
+ *
338
+ */
339
+ var handleDropOptionZone = function handleDropOptionZone(event, targetId) {
340
+ var _a;
341
+ var isAnswerTarget = event.active.id.toString().includes('answer');
342
+ // option to option
343
+ if (!isAnswerTarget) {
344
+ return;
345
+ }
346
+ // answer to option
347
+ else {
348
+ var from = targetId;
349
+ var to = ((_a = event.over) === null || _a === void 0 ? void 0 : _a.id) === 'quiz-options-dropzone' ? optionList.length : 0;
350
+ setOptionList(function (prevOptionList) {
351
+ var _a, _b, _c;
352
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevOptionList);
353
+ newState[to] = {
354
+ initialOrder: (_a = answerList[from]) === null || _a === void 0 ? void 0 : _a.initialOrder,
355
+ order: to,
356
+ value: (_c = (_b = answerList[from]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : ''
357
+ };
358
+ return newState;
359
+ });
360
+ setAnswerList(function (prevAnswerList) {
361
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevAnswerList);
362
+ newState[from] = {
363
+ initialOrder: null,
364
+ order: null,
365
+ value: null
366
+ };
367
+ return newState;
368
+ });
369
+ }
370
+ };
371
+ /**
372
+ *
373
+ */
374
+ var handleDropAnswerZone = function handleDropAnswerZone(event, targetId) {
375
+ var _a;
376
+ var isAnswerTarget = event.active.id.toString().includes('answer');
377
+ var dropzoneIndex = Number(((_a = event.over) === null || _a === void 0 ? void 0 : _a.id).split('-').pop());
378
+ var from = targetId;
379
+ var to = dropzoneIndex;
380
+ // answer to answer
381
+ if (isAnswerTarget) {
382
+ setAnswerList(function (prevAnswerList) {
383
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevAnswerList);
384
+ newState[from].order = to;
385
+ newState[to].order = from;
386
+ var temp = newState[from];
387
+ newState[from] = newState[to];
388
+ newState[to] = temp;
389
+ return newState;
390
+ });
391
+ }
392
+ // option to answer
393
+ else {
394
+ setOptionList(function (prevOptionList) {
395
+ var _a, _b;
396
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevOptionList);
397
+ newState[from] = {
398
+ initialOrder: (_a = answerList[to]) === null || _a === void 0 ? void 0 : _a.initialOrder,
399
+ order: from,
400
+ value: (_b = answerList[to]) === null || _b === void 0 ? void 0 : _b.value
401
+ };
402
+ return newState;
403
+ });
404
+ setAnswerList(function (prevAnswerList) {
405
+ var _a, _b, _c;
406
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevAnswerList);
407
+ newState[to] = {
408
+ initialOrder: (_a = optionList[from]) === null || _a === void 0 ? void 0 : _a.initialOrder,
409
+ order: to,
410
+ value: (_c = (_b = optionList[from]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null
411
+ };
412
+ return newState;
413
+ });
414
+ }
415
+ };
416
+ /**
417
+ *
418
+ */
419
+ var handleDropDummyZone = function handleDropDummyZone(event, targetId) {
420
+ var _a;
421
+ var isAnswerTarget = event.active.id.toString().includes('answer');
422
+ var dropzoneIndex = Number(((_a = event.over) === null || _a === void 0 ? void 0 : _a.id).split('-').pop());
423
+ var from = targetId;
424
+ var to = dropzoneIndex;
425
+ // option to dummy
426
+ if (!isAnswerTarget) {
427
+ setAnswerList(function (prevAnswerList) {
428
+ var _a, _b, _c;
429
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevAnswerList);
430
+ newState[dropzoneIndex] = {
431
+ initialOrder: (_a = optionList[from]) === null || _a === void 0 ? void 0 : _a.initialOrder,
432
+ order: to,
433
+ value: (_c = (_b = optionList[from]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null
434
+ };
435
+ return newState;
436
+ });
437
+ setOptionList(function (prevOptionList) {
438
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevOptionList);
439
+ // reorder
440
+ newState.splice(from, 1);
441
+ newState.forEach(function (option, index) {
442
+ if (option.order > targetId) {
443
+ newState[index].order -= 1;
444
+ }
445
+ });
446
+ return newState;
447
+ });
448
+ }
449
+ // answer to dummy
450
+ else {
451
+ setAnswerList(function (prevAnswerList) {
452
+ var _a, _b;
453
+ var newState = _rollupPluginBabelHelpers.toConsumableArray(prevAnswerList);
454
+ newState[to] = {
455
+ initialOrder: (_a = newState[from]) === null || _a === void 0 ? void 0 : _a.initialOrder,
456
+ order: to,
457
+ value: (_b = newState[from]) === null || _b === void 0 ? void 0 : _b.value
458
+ };
459
+ newState[from] = {
460
+ initialOrder: null,
461
+ order: null,
462
+ value: null
463
+ };
464
+ return newState;
465
+ });
466
+ }
467
+ };
468
+ /**
469
+ *
470
+ */
331
471
  var renderQuizDragOption = function renderQuizDragOption() {
332
472
  return jsxRuntime.jsxs(StyledQuizOptionsDropZone, {
473
+ id: "quiz-options-dropzone",
333
474
  disabled: !!userId,
334
475
  accept: ".quiz-answer",
335
- onDrop: function onDrop(event, ui) {
336
- if (index.checkUserLectureTestEnded(lecture)) {
337
- return;
338
- }
339
- setIsActive(true);
340
- setHasSubmitted(false);
341
- var targetId = Number(ui.draggable[0].id);
342
- setOptionList(function (prevOptionList) {
343
- return [].concat(_rollupPluginBabelHelpers.toConsumableArray(prevOptionList), [answerList.find(function (answer) {
344
- return answer.order === targetId;
345
- })]).sort(function (a, b) {
346
- return a.order - b.order;
347
- });
348
- });
349
- setAnswerList(function (prevAnswerList) {
350
- var removingIndex = prevAnswerList.findIndex(function (answer) {
351
- return answer.order === targetId;
352
- });
353
- return prevAnswerList.map(function (answer, answerIndex) {
354
- if (answerIndex === removingIndex) {
355
- return {
356
- order: null,
357
- value: null
358
- };
359
- } else {
360
- return answer;
361
- }
362
- });
363
- });
364
- },
365
476
  children: [optionList.map(function (option, index) {
366
477
  return jsxRuntime.jsx(QuizDraggbleOption.default, {
367
478
  disabled: !!userId,
368
- id: option.order.toString(),
479
+ id: "quiz-option-".concat(index),
369
480
  className: "quiz-option",
370
481
  content: option.value,
371
482
  isMarkdown: !!(course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInQuizOptions)
372
- }, option.order);
483
+ }, "quiz-option-".concat(index));
373
484
  }), optionList.length === 0 && !userId ? jsxRuntime.jsx(blocks.Flex, {
374
485
  align: "center",
375
486
  justify: "center",
@@ -387,6 +498,9 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
387
498
  }) : null]
388
499
  });
389
500
  };
501
+ /**
502
+ *
503
+ */
390
504
  var renderQuizDragAnswers = function renderQuizDragAnswers() {
391
505
  return jsxRuntime.jsx(StyledQuizAnswersDropZone, {
392
506
  children: answerList.map(function (option, index$1) {
@@ -409,70 +523,24 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
409
523
  children: intl$1.formatMessage({
410
524
  id: 'materialQuiz.selectMultipleOrder.answer.title'
411
525
  }),
412
- indexOrder: index$1 + 1,
413
- onDrop: function onDrop(event, ui) {
414
- if (index.checkUserLectureTestEnded(lecture)) {
415
- return;
416
- }
417
- setIsActive(true);
418
- setHasSubmitted(false);
419
- onDirty(true);
420
- // from answerList to answerList
421
- if (ui.draggable[0].classList.contains('quiz-answer')) {
422
- var targetOptionId = Number(ui.draggable[0].id);
423
- setAnswerList(function (prevAnswerList) {
424
- var newState = _rollupPluginBabelHelpers.toConsumableArray(prevAnswerList);
425
- var from = newState.find(function (prevAnswer) {
426
- return prevAnswer.order === targetOptionId;
427
- });
428
- var fromIndex = newState.findIndex(function (prevAnswer) {
429
- return prevAnswer.order === targetOptionId;
430
- });
431
- var to = newState[index$1];
432
- newState[index$1] = from;
433
- newState[fromIndex] = to;
434
- return newState;
435
- });
436
- }
437
- // from option-list to answerList-list
438
- else {
439
- var _targetOptionId = Number(ui.draggable[0].id);
440
- setOptionList(function (prevOptions) {
441
- return prevOptions.filter(function (prevOption) {
442
- return prevOption.order !== _targetOptionId;
443
- });
444
- });
445
- setAnswerList(function (prevAnswerList) {
446
- return prevAnswerList.map(function (prevAnswer, prevAnswerIndex) {
447
- var _a, _b;
448
- if (index$1 === prevAnswerIndex) {
449
- return {
450
- order: _targetOptionId,
451
- value: (_b = (_a = optionList.find(function (option) {
452
- return option.order === _targetOptionId;
453
- })) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : ''
454
- };
455
- } else {
456
- return prevAnswer;
457
- }
458
- });
459
- });
460
- }
461
- }
462
- }, index$1);
526
+ indexOrder: index$1 + 1
527
+ }, "quiz-dummy-".concat(index$1));
463
528
  } else {
464
529
  return jsxRuntime.jsx(QuizDraggbleDroppedOption.default, {
465
- id: option.order.toString(),
530
+ id: "option-answer-".concat(index$1),
466
531
  content: option.value,
467
532
  role: getRole(),
468
533
  disabled: !!userId,
469
534
  indexOrder: index$1 + 1,
470
535
  isMarkdown: !!(course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInQuizOptions)
471
- }, index$1);
536
+ }, "option-answer-".concat(index$1));
472
537
  }
473
538
  })
474
539
  });
475
540
  };
541
+ //
542
+ //
543
+ //
476
544
  return jsxRuntime.jsx(QuestionBox.default, {
477
545
  title: materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.questionTitle,
478
546
  titlePrefix: "Q.",
@@ -509,47 +577,52 @@ var MaterialQuizSelectMultipleOrder = function MaterialQuizSelectMultipleOrder(_
509
577
  children: jsxRuntime.jsx(MaterialQuizInfo.default, {
510
578
  renderWithBox: false
511
579
  })
512
- }), jsxRuntime.jsxs("div", {
513
- id: element.MATERIAL_QUIZ_ANSWER_ID,
514
- children: [jsxRuntime.jsxs(StyledOptionBox, {
515
- ref: optionBoxRef,
516
- vertical: vertical,
517
- children: [renderQuizDragOption(), jsxRuntime.jsx(StyledVerticalDivider, {
580
+ }), jsxRuntime.jsx(core.DndContext, {
581
+ sensors: sensors,
582
+ onDragEnd: handleDragEnd,
583
+ children: jsxRuntime.jsxs("div", {
584
+ id: element.MATERIAL_QUIZ_ANSWER_ID,
585
+ children: [jsxRuntime.jsxs(StyledOptionBox, {
586
+ ref: optionBoxRef,
518
587
  vertical: vertical,
519
- children: jsxRuntime.jsx(blocks.Icon, {
520
- size: "elephant",
521
- icon: icons.eilSortItem,
522
- rotate: 90,
523
- style: {
524
- color: designTokens.base.color.navy3
525
- }
526
- })
527
- }), jsxRuntime.jsx(StyledHorizontalDivider, {
528
- vertical: vertical
529
- }), renderQuizDragAnswers()]
530
- }), !!userId ? jsxRuntime.jsx(blocks.Flex, {
531
- margintop: "1rem",
532
- column: true,
533
- children: jsxRuntime.jsxs(StyledQuizOptionsDropZone, {
534
- children: [jsxRuntime.jsx(blocks.Text, {
535
- role: "white",
536
- size: "small",
537
- children: intl$1.formatMessage({
538
- id: 'materialQuiz.answer'
588
+ children: [renderQuizDragOption(), jsxRuntime.jsx(StyledVerticalDivider, {
589
+ vertical: vertical,
590
+ children: jsxRuntime.jsx(blocks.Icon, {
591
+ size: "elephant",
592
+ icon: icons.eilSortItem,
593
+ rotate: 90,
594
+ style: {
595
+ color: designTokens.base.color.navy3
596
+ }
539
597
  })
540
- }), correctAnswerList.map(function (correctAnswer, index) {
541
- var _a;
542
- return jsxRuntime.jsx(QuizDraggbleDroppedOption.default, {
543
- id: (_a = correctAnswer.order) === null || _a === void 0 ? void 0 : _a.toString(),
544
- content: correctAnswer.value,
545
- disabled: true,
546
- role: "correct",
547
- indexOrder: index + 1,
548
- isMarkdown: !!(course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInQuizOptions)
549
- }, correctAnswer.order);
550
- })]
551
- })
552
- }) : null, jsxRuntime.jsx(MaterialQuizAnswerExplanation.default, {})]
598
+ }), jsxRuntime.jsx(StyledHorizontalDivider, {
599
+ vertical: vertical
600
+ }), renderQuizDragAnswers()]
601
+ }), !!userId ? jsxRuntime.jsx(blocks.Flex, {
602
+ margintop: "1rem",
603
+ column: true,
604
+ children: jsxRuntime.jsxs(StyledQuizOptionsDropZone, {
605
+ id: "quiz-answers-dropzone",
606
+ disabled: true,
607
+ children: [jsxRuntime.jsx(blocks.Text, {
608
+ role: "white",
609
+ size: "small",
610
+ children: intl$1.formatMessage({
611
+ id: 'materialQuiz.answer'
612
+ })
613
+ }), correctAnswerList.map(function (correctAnswer, index) {
614
+ return jsxRuntime.jsx(QuizDraggbleDroppedOption.default, {
615
+ id: "option-answer-".concat(index),
616
+ content: correctAnswer.value,
617
+ disabled: true,
618
+ role: "correct",
619
+ indexOrder: index + 1,
620
+ isMarkdown: !!(course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInQuizOptions)
621
+ }, "dropped-option-answer-".concat(index));
622
+ })]
623
+ })
624
+ }) : null, jsxRuntime.jsx(MaterialQuizAnswerExplanation.default, {})]
625
+ })
553
626
  })]
554
627
  })
555
628
  });
@@ -12,8 +12,9 @@ var material = require('@mui/material');
12
12
  var element = require('../../constant/element.js');
13
13
  var index = require('../../helpers/index.js');
14
14
  var useCaculatePassage = require('../../hooks/useCaculatePassage.js');
15
- require('../shared/QuizDraggbleOption.js');
15
+ require('../shared/QuizDraggbleDroppedOption.js');
16
16
  require('../shared/QuizDraggbleDummyOption.js');
17
+ require('../shared/QuizDraggbleOption.js');
17
18
  var QuestionRadio = require('../shared/question-radio/QuestionRadio.js');
18
19
  var QuestionRadioOption = require('../shared/question-radio/QuestionRadioOption.js');
19
20
  require('../shared/question-checkbox/QuestionCheckbox.js');
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var React = require('react');
7
+ var core = require('@dnd-kit/core');
7
8
  var blocks = require('@elice/blocks');
8
9
  var designTokens = require('@elice/design-tokens');
9
10
  var icons = require('@elice/icons');
@@ -19,7 +20,13 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
19
20
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
20
21
  var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
21
22
 
23
+ //
24
+ //
25
+ //
22
26
  var QUIZ_OPTIONS_CONTENT_WIDTH = 534;
27
+ //
28
+ //
29
+ //
23
30
  var StyledQuizAnswerWrapper = styled__default.default.div.withConfig({
24
31
  componentId: "sc-18trt81-0"
25
32
  })(["display:flex;flex-direction:column;flex:0 0 calc((100% - ", "px) / 2);"], QUIZ_OPTIONS_CONTENT_WIDTH);
@@ -41,6 +48,9 @@ var StyledQuizOptions = styled__default.default.div.withConfig({
41
48
  var StyledQuizOptionsDropzone = styled__default.default(EbDroppable.default).withConfig({
42
49
  componentId: "sc-18trt81-4"
43
50
  })(["display:flex;flex-wrap:wrap;gap:1rem;min-height:10.25rem;border-radius:0.5rem;outline:1px dashed ", ";&.ui-droppable-hover{outline:1px dashed ", ";}"], designTokens.base.color.navy4, designTokens.base.color.gray4);
51
+ //
52
+ //
53
+ //
44
54
  var MaterialQuizGroupDesktop = function MaterialQuizGroupDesktop() {
45
55
  var intl$1 = intl.useRawEliceIntl();
46
56
  var _useMaterialQuizState = MaterialQuizContext.useMaterialQuizState(),
@@ -52,6 +62,29 @@ var MaterialQuizGroupDesktop = function MaterialQuizGroupDesktop() {
52
62
  updateCurrentAnswer = _React$useContext.updateCurrentAnswer,
53
63
  updateCurrentOption = _React$useContext.updateCurrentOption,
54
64
  handleAnswerReset = _React$useContext.handleAnswerReset;
65
+ var sensors = core.useSensors(core.useSensor(core.MouseSensor, {
66
+ activationConstraint: {
67
+ distance: 10
68
+ }
69
+ }), core.useSensor(core.TouchSensor, {
70
+ activationConstraint: {
71
+ delay: 50,
72
+ tolerance: 5
73
+ }
74
+ }));
75
+ /**
76
+ *
77
+ */
78
+ var handleDragEnd = function handleDragEnd(e) {
79
+ var _a, _b, _c;
80
+ if (!e.over) {
81
+ return;
82
+ }
83
+ var targetId = Number(e.active.id);
84
+ var isOverOptionZone = ((_a = e.over) === null || _a === void 0 ? void 0 : _a.id) === 'quiz-options-dropzone';
85
+ var dropzoneIndex = Number((_c = (_b = e.over) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.split('-').pop());
86
+ isOverOptionZone ? updateCurrentOption(targetId) : updateCurrentAnswer(targetId, dropzoneIndex);
87
+ };
55
88
  /**
56
89
  *
57
90
  */
@@ -81,13 +114,10 @@ var MaterialQuizGroupDesktop = function MaterialQuizGroupDesktop() {
81
114
  }), jsxRuntime.jsx(blocks.Vspace, {
82
115
  height: 1
83
116
  }), jsxRuntime.jsx(StyledQuizAnswerDropzone, {
117
+ id: "quiz-answer-dropzone-".concat(dropzoneIndex),
84
118
  accept: ".quiz-answer",
85
119
  disabled: !!userId,
86
120
  isGroupAnswer: isGroupAnswer,
87
- onDrop: function onDrop(event, ui) {
88
- var targetId = Number(ui.draggable[0].id);
89
- updateCurrentAnswer(targetId, dropzoneIndex);
90
- },
91
121
  children: isGroupAnswer ? (_b = currentAnswerList[dropzoneIndex]) === null || _b === void 0 ? void 0 : _b.map(function (answer, index) {
92
122
  return jsxRuntime.jsx(MaterialQuizGroupOptionItem.default, {
93
123
  option: answer
@@ -148,11 +178,8 @@ var MaterialQuizGroupDesktop = function MaterialQuizGroupDesktop() {
148
178
  }), jsxRuntime.jsx(blocks.Vspace, {
149
179
  height: 1
150
180
  }), jsxRuntime.jsx(StyledQuizOptionsDropzone, {
181
+ id: "quiz-options-dropzone",
151
182
  accept: ".quiz-answer",
152
- onDrop: function onDrop(event, ui) {
153
- var targetId = Number(ui.draggable[0].id);
154
- updateCurrentOption(targetId);
155
- },
156
183
  children: currentOptionList.length ? currentOptionList.map(function (option, index) {
157
184
  return jsxRuntime.jsx(MaterialQuizGroupOptionItem.default, {
158
185
  option: option
@@ -177,10 +204,14 @@ var MaterialQuizGroupDesktop = function MaterialQuizGroupDesktop() {
177
204
  //
178
205
  //
179
206
  //
180
- return jsxRuntime.jsxs(blocks.Flex, {
207
+ return jsxRuntime.jsx(blocks.Flex, {
181
208
  width: "100%",
182
209
  height: "100%",
183
- children: [renderQuizContentLeft(), renderQuizContentOption(), renderQuizContentRight()]
210
+ children: jsxRuntime.jsxs(core.DndContext, {
211
+ sensors: sensors,
212
+ onDragEnd: handleDragEnd,
213
+ children: [renderQuizContentLeft(), renderQuizContentOption(), renderQuizContentRight()]
214
+ })
184
215
  });
185
216
  };
186
217