PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.2
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / js / dist / admin / editor / quiz.js

quiz.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7.2, at assets/js/dist/admin/editor/quiz.js

1,231 lines 40.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/apps/js/admin/editor/actions/modal-quiz-items.js":
5 /*!*********************************************************************!*\
6 !*** ./assets/src/apps/js/admin/editor/actions/modal-quiz-items.js ***!
7 \*********************************************************************/
8 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 const ModalQuizItems = {
13 toggle: function (context) {
14 context.commit('TOGGLE');
15 },
16 // open modal
17 open: function (context, quizId) {
18 context.commit('SET_QUIZ', quizId);
19 context.commit('RESET');
20 context.commit('TOGGLE');
21 },
22 // query available question
23 searchItems: function (context, payload) {
24 context.commit('SEARCH_ITEM_REQUEST');
25 LP.Request({
26 type: 'search-items',
27 query: payload.query,
28 page: payload.page,
29 exclude: JSON.stringify([])
30 }).then(function (response) {
31 var result = response.body;
32
33 if (!result.success) {
34 return;
35 }
36
37 var data = result.data;
38 context.commit('SET_LIST_ITEMS', data.items);
39 context.commit('UPDATE_PAGINATION', data.pagination);
40 context.commit('SEARCH_ITEM_SUCCESS');
41 }, function (error) {
42 context.commit('SEARCH_ITEMS_FAIL');
43 console.log(error);
44 });
45 },
46 // add question
47 addItem: function (context, item) {
48 context.commit('ADD_ITEM', item);
49 },
50 // remove question
51 removeItem: function (context, index) {
52 context.commit('REMOVE_ADDED_ITEM', index);
53 },
54 addQuestionsToQuiz: function (context, quiz) {
55 var items = context.getters.addedItems;
56
57 if (items.length > 0) {
58 LP.Request({
59 type: 'add-questions-to-quiz',
60 items: JSON.stringify(items),
61 draft_quiz: JSON.stringify(quiz)
62 }).then(function (response) {
63 var result = response.body;
64
65 if (result.success) {
66 var questions = result.data; // update quiz list questions
67
68 context.commit('lqs/SET_QUESTIONS', questions, {
69 root: true
70 });
71 context.commit('TOGGLE');
72 }
73 }, function (error) {
74 console.log(error);
75 });
76 }
77 }
78 };
79 /* harmony default export */ __webpack_exports__["default"] = (ModalQuizItems);
80
81 /***/ }),
82
83 /***/ "./assets/src/apps/js/admin/editor/actions/question-list.js":
84 /*!******************************************************************!*\
85 !*** ./assets/src/apps/js/admin/editor/actions/question-list.js ***!
86 \******************************************************************/
87 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
88
89 "use strict";
90 __webpack_require__.r(__webpack_exports__);
91 const $ = window.jQuery;
92 const QuestionList = {
93 toggleAll: function (context) {
94 var hidden = context.getters.isHiddenListQuestions;
95
96 if (hidden) {
97 context.commit('OPEN_LIST_QUESTIONS');
98 } else {
99 context.commit('CLOSE_LIST_QUESTIONS');
100 }
101
102 LP.Request({
103 type: 'hidden-questions',
104 hidden: context.getters.hiddenQuestions
105 });
106 },
107 updateQuizQuestionsHidden: function (context, data) {
108 LP.Request($.extend({}, data, {
109 type: 'update-quiz-questions-hidden'
110 }));
111 },
112 newQuestion: function (context, payload) {
113 var newQuestion = JSON.parse(JSON.stringify(payload.question));
114 newQuestion.settings = {};
115 context.commit('ADD_NEW_QUESTION', newQuestion);
116 LP.Request({
117 type: 'new-question',
118 question: JSON.stringify(payload.question),
119 draft_quiz: JSON.stringify(payload.quiz)
120 }).then(function (response) {
121 var result = response.body;
122
123 if (result.success) {
124 context.commit('UPDATE_NEW_QUESTION_TYPE', payload.question.type, {
125 root: true
126 });
127 context.commit('ADD_NEW_QUESTION', result.data);
128 context.commit('CLOSE_LIST_QUESTIONS');
129 context.commit('OPEN_QUESTION', result.data);
130 }
131 }, function (error) {
132 console.log(error);
133 });
134 },
135 updateQuestionsOrder: function (context, order) {
136 LP.Request({
137 type: 'sort-questions',
138 order: JSON.stringify(order)
139 }).then(function (response) {
140 context.commit('SORT_QUESTIONS', order);
141 }, function (error) {
142 console.log(error);
143 });
144 },
145 updateQuestionTitle: function (context, question) {
146 context.commit('UPDATE_QUESTION_REQUEST', question.id);
147 LP.Request({
148 type: 'update-question-title',
149 question: JSON.stringify(question)
150 }).then(function () {
151 context.commit('UPDATE_QUESTION_SUCCESS', question.id);
152 }).catch(function () {
153 context.commit('UPDATE_QUESTION_FAILURE', question.id);
154 });
155 },
156 changeQuestionType: function (context, payload) {
157 context.commit('UPDATE_QUESTION_REQUEST', payload.question_id);
158 LP.Request({
159 type: 'change-question-type',
160 question_id: payload.question_id,
161 question_type: payload.type
162 }).then(function (response) {
163 var result = response.body;
164
165 if (result.success) {
166 var question = result.data;
167 context.commit('CHANGE_QUESTION_TYPE', question);
168 context.commit('UPDATE_NEW_QUESTION_TYPE', question.type.key, {
169 root: true
170 });
171 context.commit('UPDATE_QUESTION_SUCCESS', payload.question_id);
172 }
173 }).catch(function () {
174 context.commit('UPDATE_QUESTION_FAILURE', payload.question_id);
175 });
176 },
177 isHiddenQuestionsSettings: function (context, id) {},
178 cloneQuestion: function (context, question) {
179 LP.Request({
180 type: 'clone-question',
181 question: JSON.stringify(question)
182 }).then(function (response) {
183 var result = response.body;
184
185 if (result.success) {
186 var question = result.data;
187 context.commit('ADD_NEW_QUESTION', result.data);
188 context.commit('UPDATE_NEW_QUESTION_TYPE', question.type.key, {
189 root: true
190 });
191 }
192 }, function (error) {
193 console.log(error);
194 });
195 },
196 removeQuestion: function (context, question) {
197 var question_id = question.id;
198 question.temp_id = LP.uniqueId();
199 context.commit('REMOVE_QUESTION', question);
200 LP.Request({
201 type: 'remove-question',
202 question_id: question_id
203 }).then(function (response) {
204 var result = response.body;
205
206 if (result.success) {
207 question.id = question.temp_id;
208 question.temp_id = 0;
209 context.commit('REMOVE_QUESTION', question);
210 }
211 }, function (error) {
212 console.error(error);
213 });
214 },
215 deleteQuestion: function (context, question) {
216 var question_id = question.id;
217 question.temp_id = LP.uniqueId();
218 context.commit('REMOVE_QUESTION', question);
219 LP.Request({
220 type: 'delete-question',
221 question_id: question_id
222 }).then(function () {
223 question.id = question.temp_id;
224 question.temp_id = 0;
225 context.commit('REMOVE_QUESTION', question);
226 context.commit('UPDATE_QUESTION_SUCCESS', question.id);
227 }).catch(function () {
228 context.commit('UPDATE_QUESTION_FAILURE', question.id);
229 });
230 },
231 toggleQuestion: function (context, question) {
232 if (question.open) {
233 context.commit('CLOSE_QUESTION', question);
234 } else {
235 context.commit('OPEN_QUESTION', question);
236 }
237
238 LP.Request({
239 type: 'hidden-questions',
240 hidden: context.getters.hiddenQuestions
241 });
242 },
243 updateQuestionAnswersOrder: function (context, payload) {
244 context.commit('UPDATE_QUESTION_REQUEST', payload.question_id);
245 LP.Request({
246 type: 'sort-question-answers',
247 question_id: payload.question_id,
248 order: JSON.stringify(payload.order)
249 }).then(function (response) {
250 var result = response.body,
251 order = result.data;
252 context.commit('SORT_QUESTION_ANSWERS', order);
253 context.commit('UPDATE_QUESTION_SUCCESS', payload.question_id);
254 }, function (error) {
255 context.commit('UPDATE_QUESTION_FAILURE', payload.question_id);
256 console.log(error);
257 });
258 },
259 updateQuestionAnswerTitle: function (context, payload) {
260 context.commit('UPDATE_QUESTION_REQUEST', payload.question_id);
261 LP.Request({
262 type: 'update-question-answer-title',
263 question_id: parseInt(payload.question_id),
264 answer: JSON.stringify(payload.answer)
265 }).then(function () {
266 context.commit('UPDATE_QUESTION_ANSWER_SUCCESS', parseInt(payload.question_id));
267 context.commit('UPDATE_QUESTION_SUCCESS', payload.question_id);
268 }).catch(function () {
269 context.commit('UPDATE_QUESTION_ANSWER_FAILURE', parseInt(payload.question_id));
270 context.commit('UPDATE_QUESTION_FAILURE', payload.question_id);
271 });
272 },
273 updateQuestionCorrectAnswer: function (context, payload) {
274 context.commit('UPDATE_QUESTION_REQUEST', payload.question_id);
275 LP.Request({
276 type: 'change-question-correct-answer',
277 question_id: payload.question_id,
278 correct: JSON.stringify(payload.correct)
279 }).then(function (response) {
280 var result = response.body;
281
282 if (result.success) {
283 context.commit('CHANGE_QUESTION_CORRECT_ANSWERS', result.data);
284 context.commit('UPDATE_QUESTION_SUCCESS', payload.question_id);
285 }
286 }, function (error) {
287 context.commit('UPDATE_QUESTION_FAILURE', payload.question_id);
288 console.log(error);
289 });
290 },
291 deleteQuestionAnswer: function (context, payload) {
292 payload.temp_id = LP.uniqueId();
293 context.commit('DELETE_ANSWER', payload);
294 context.commit('UPDATE_QUESTION_REQUEST', payload.question_id);
295 LP.Request({
296 type: 'delete-question-answer',
297 question_id: payload.question_id,
298 answer_id: payload.answer_id
299 }).then(function (response) {
300 var result = response.body;
301
302 if (result.success) {
303 context.commit('DELETE_QUESTION_ANSWER', {
304 question_id: payload.question_id,
305 answer_id: payload.temp_id //answer_id: payload.answer_id
306
307 });
308 context.commit('UPDATE_QUESTION_SUCCESS', payload.question_id);
309 }
310 }, function (error) {
311 context.commit('UPDATE_QUESTION_FAILURE', payload.question_id);
312 console.log(error);
313 });
314 },
315 newQuestionAnswer: function (context, data) {
316 var temp_id = LP.uniqueId(),
317 question_id = data.question_id;
318 context.commit('UPDATE_QUESTION_REQUEST', question_id);
319 context.commit('ADD_QUESTION_ANSWER', {
320 question_id: question_id,
321 answer: {
322 text: LP_Quiz_Store.getters['i18n/all'].new_option,
323 question_answer_id: temp_id
324 }
325 });
326 LP.Request({
327 type: 'new-question-answer',
328 question_id: question_id,
329 question_answer_id: temp_id
330 }).then(function (response) {
331 var result = response.body;
332
333 if (result.success) {
334 var answer = result.data;
335 context.commit('ADD_QUESTION_ANSWER', {
336 question_id: question_id,
337 answer: answer
338 });
339 context.commit('UPDATE_QUESTION_SUCCESS', question_id);
340 data.success && setTimeout(function () {
341 data.success.apply(data.context, [answer]);
342 }, 300);
343 }
344 }, function (error) {
345 context.commit('UPDATE_QUESTION_FAILURE', question_id);
346 console.error(error);
347 });
348 },
349 updateQuestionContent: function (context, question) {
350 context.commit('UPDATE_QUESTION_REQUEST', question.id);
351 LP.Request({
352 type: 'update-question-content',
353 question: JSON.stringify(question)
354 }).then(function () {
355 context.commit('UPDATE_QUESTION_SUCCESS', question.id);
356 }).catch(function () {
357 context.commit('UPDATE_QUESTION_FAILURE', question.id);
358 });
359 },
360 updateQuestionMeta: function (context, payload) {
361 context.commit('UPDATE_QUESTION_REQUEST', payload.question.id);
362 LP.Request({
363 type: 'update-question-meta',
364 question: JSON.stringify(payload.question),
365 meta_key: payload.meta_key
366 }).then(function () {
367 context.commit('UPDATE_QUESTION_SUCCESS', payload.question.id);
368 }).catch(function () {
369 context.commit('UPDATE_QUESTION_FAILURE', payload.question.id);
370 });
371 }
372 };
373 /* harmony default export */ __webpack_exports__["default"] = (QuestionList);
374
375 /***/ }),
376
377 /***/ "./assets/src/apps/js/admin/editor/actions/quiz.js":
378 /*!*********************************************************!*\
379 !*** ./assets/src/apps/js/admin/editor/actions/quiz.js ***!
380 \*********************************************************/
381 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
382
383 "use strict";
384 __webpack_require__.r(__webpack_exports__);
385 const Quiz = {
386 heartbeat: function (context) {
387 LP.Request({
388 type: 'heartbeat'
389 }).then(function (response) {
390 var result = response.body;
391 context.commit('UPDATE_HEART_BEAT', !!result.success);
392 }, function (error) {
393 context.commit('UPDATE_HEART_BEAT', false);
394 });
395 },
396 newRequest: function (context) {
397 context.commit('INCREASE_NUMBER_REQUEST');
398 context.commit('UPDATE_STATUS', 'loading');
399
400 window.onbeforeunload = function () {
401 return '';
402 };
403 },
404 requestCompleted: function (context, status) {
405 context.commit('DECREASE_NUMBER_REQUEST');
406
407 if (context.getters.currentRequest === 0) {
408 context.commit('UPDATE_STATUS', status);
409 window.onbeforeunload = null;
410 }
411 }
412 };
413 /* harmony default export */ __webpack_exports__["default"] = (Quiz);
414
415 /***/ }),
416
417 /***/ "./assets/src/apps/js/admin/editor/fill-in-blanks.js":
418 /*!***********************************************************!*\
419 !*** ./assets/src/apps/js/admin/editor/fill-in-blanks.js ***!
420 \***********************************************************/
421 /***/ (function() {
422
423 (function ($) {
424 window.FIB = {
425 getSelectedText: function getSelectedText() {
426 let html = '';
427
428 if (typeof window.getSelection !== 'undefined') {
429 const sel = window.getSelection();
430
431 if (sel.rangeCount) {
432 const container = document.createElement('div');
433
434 for (let i = 0, len = sel.rangeCount; i < len; ++i) {
435 container.appendChild(sel.getRangeAt(i).cloneContents());
436 }
437
438 html = container.innerHTML;
439 }
440 } else if (typeof document.selection !== 'undefined') {
441 if (document.selection.type === 'Text') {
442 html = document.selection.createRange().htmlText;
443 }
444 }
445
446 return html;
447 },
448
449 createTextNode(content) {
450 return document.createTextNode(content);
451 },
452
453 isContainHtml: function isContainHtml(content) {
454 const $el = $(content),
455 sel = 'b.fib-blank';
456 return $el.is(sel) || $el.find(sel).length || $el.parent().is(sel);
457 },
458 getSelectionRange: function getSelectionRange() {
459 let t = '';
460
461 if (window.getSelection) {
462 t = window.getSelection();
463 } else if (document.getSelection) {
464 t = document.getSelection();
465 } else if (document.selection) {
466 t = document.selection.createRange().text;
467 }
468
469 return t;
470 },
471
472 outerHTML($dom) {
473 return $('<div>').append($($dom).clone()).html();
474 },
475
476 doUpgrade(callback) {
477 $.ajax({
478 url: '',
479 data: {
480 'lp-ajax': 'fib-upgrade'
481 },
482
483 success(res) {
484 console.log(res);
485 callback && callback.call(res);
486 }
487
488 });
489 }
490
491 };
492 $(document).ready(function () {
493 $('#do-upgrade-fib').on('click', function () {
494 const $button = $(this).prop('disabled', true).addClass('ajaxloading');
495 FIB.doUpgrade(function () {
496 $button.prop('disabled', false).removeClass('ajaxloading');
497 });
498 });
499 });
500 })(jQuery);
501
502 /***/ }),
503
504 /***/ "./assets/src/apps/js/admin/editor/getters/modal-quiz-items.js":
505 /*!*********************************************************************!*\
506 !*** ./assets/src/apps/js/admin/editor/getters/modal-quiz-items.js ***!
507 \*********************************************************************/
508 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
509
510 "use strict";
511 __webpack_require__.r(__webpack_exports__);
512 const ModalQuizItems = {
513 status: function (state) {
514 return state.status;
515 },
516 pagination: function (state) {
517 return state.pagination;
518 },
519 items: function (state, _getters) {
520 return state.items.map(function (item) {
521 var find = _getters.addedItems.find(function (_item) {
522 return item.id === _item.id;
523 });
524
525 item.added = !!find;
526 return item;
527 });
528 },
529 code: function (state) {
530 return Date.now();
531 },
532 addedItems: function (state) {
533 return state.addedItems;
534 },
535 isOpen: function (state) {
536 return state.open;
537 },
538 quiz: function (state) {
539 return state.quizId;
540 }
541 };
542 /* harmony default export */ __webpack_exports__["default"] = (ModalQuizItems);
543
544 /***/ }),
545
546 /***/ "./assets/src/apps/js/admin/editor/getters/question-list.js":
547 /*!******************************************************************!*\
548 !*** ./assets/src/apps/js/admin/editor/getters/question-list.js ***!
549 \******************************************************************/
550 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
551
552 "use strict";
553 __webpack_require__.r(__webpack_exports__);
554 const QuestionList = {
555 listQuestions: function (state) {
556 return state.questions || [];
557 },
558 questionsOrder: function (state) {
559 return state.order || [];
560 },
561 externalComponent: function (state) {
562 return state.externalComponent || [];
563 },
564 supportAnswerOptions: function (state) {
565 return state.supportAnswerOptions || [];
566 },
567 hiddenQuestionsSettings: function (state) {
568 return state.hidden_questions_settings || [];
569 },
570 hiddenQuestions: function (state) {
571 return state.questions.filter(function (question) {
572 return !question.open;
573 }).map(function (question) {
574 return parseInt(question.id);
575 });
576 },
577 isHiddenListQuestions: function (state, getters) {
578 var questions = getters.listQuestions;
579 var hiddenQuestions = getters.hiddenQuestions;
580 return questions.length === hiddenQuestions.length;
581 },
582 disableUpdateList: function (state) {
583 return state.disableUpdateList;
584 },
585 statusUpdateQuestions: function (state) {
586 return state.statusUpdateQuestions;
587 },
588 statusUpdateQuestionItem: function (state) {
589 return state.statusUpdateQuestionItem;
590 },
591 statusUpdateQuestionAnswer: function (state) {
592 return state.statusUpdateQuestionAnswer;
593 }
594 };
595 /* harmony default export */ __webpack_exports__["default"] = (QuestionList);
596
597 /***/ }),
598
599 /***/ "./assets/src/apps/js/admin/editor/getters/quiz.js":
600 /*!*********************************************************!*\
601 !*** ./assets/src/apps/js/admin/editor/getters/quiz.js ***!
602 \*********************************************************/
603 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
604
605 "use strict";
606 __webpack_require__.r(__webpack_exports__);
607 const Quiz = {
608 heartbeat: function (state) {
609 return state.heartbeat;
610 },
611 questionTypes: function (state) {
612 return state.types;
613 },
614 defaultNewQuestionType: function (state) {
615 return state.default_new;
616 },
617 action: function (state) {
618 return state.action;
619 },
620 id: function (state) {
621 return state.quiz_id;
622 },
623 status: function (state) {
624 return state.status || 'error';
625 },
626 currentRequest: function (state) {
627 return state.countCurrentRequest || 0;
628 },
629 nonce: function (state) {
630 return state.nonce;
631 }
632 };
633 /* harmony default export */ __webpack_exports__["default"] = (Quiz);
634
635 /***/ }),
636
637 /***/ "./assets/src/apps/js/admin/editor/http.js":
638 /*!*************************************************!*\
639 !*** ./assets/src/apps/js/admin/editor/http.js ***!
640 \*************************************************/
641 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
642
643 "use strict";
644 __webpack_require__.r(__webpack_exports__);
645 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
646 /* harmony export */ "default": function() { return /* binding */ HTTP; }
647 /* harmony export */ });
648 function HTTP(options) {
649 const $ = window.jQuery || jQuery;
650 const $VueHTTP = Vue.http;
651 options = $.extend({
652 ns: 'LPRequest',
653 store: false
654 }, options || {});
655 let $publishingAction = null;
656
657 LP.Request = function (payload) {
658 $publishingAction = $('#publishing-action');
659 payload.id = options.store.getters.id;
660 payload.nonce = options.store.getters.nonce;
661 payload['lp-ajax'] = options.store.getters.action;
662 payload.code = options.store.getters.code;
663 $publishingAction.find('#publish').addClass('disabled');
664 $publishingAction.find('.spinner').addClass('is-active');
665 $publishingAction.addClass('code-' + payload.code);
666 return $VueHTTP.post(options.store.getters.urlAjax, payload, {
667 emulateJSON: true,
668 params: {
669 namespace: options.ns,
670 code: payload.code
671 }
672 });
673 };
674
675 $VueHTTP.interceptors.push(function (request, next) {
676 if (request.params.namespace !== options.ns) {
677 next();
678 return;
679 }
680
681 options.store.dispatch('newRequest');
682 next(function (response) {
683 if (!jQuery.isPlainObject(response.body)) {
684 response.body = LP.parseJSON(response.body);
685 }
686
687 const body = response.body;
688 const result = body.success || false;
689
690 if (result) {
691 options.store.dispatch('requestCompleted', 'successful');
692 } else {
693 options.store.dispatch('requestCompleted', 'failed');
694 }
695
696 $publishingAction.removeClass('code-' + request.params.code);
697
698 if (!$publishingAction.attr('class')) {
699 $publishingAction.find('#publish').removeClass('disabled');
700 $publishingAction.find('.spinner').removeClass('is-active');
701 }
702 });
703 });
704 }
705
706 /***/ }),
707
708 /***/ "./assets/src/apps/js/admin/editor/mutations/modal-quiz-items.js":
709 /*!***********************************************************************!*\
710 !*** ./assets/src/apps/js/admin/editor/mutations/modal-quiz-items.js ***!
711 \***********************************************************************/
712 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
713
714 "use strict";
715 __webpack_require__.r(__webpack_exports__);
716 const ModalQuizItems = {
717 TOGGLE: function (state) {
718 state.open = !state.open;
719 },
720 SET_QUIZ: function (state, quizId) {
721 state.quizId = quizId;
722 },
723 SET_LIST_ITEMS: function (state, items) {
724 state.items = items;
725 },
726 ADD_ITEM: function (state, item) {
727 state.addedItems.push(item);
728 },
729 REMOVE_ADDED_ITEM: function (state, item) {
730 state.addedItems.forEach(function (_item, index) {
731 if (_item.id === item.id) {
732 state.addedItems.splice(index, 1);
733 }
734 });
735 },
736 RESET: function (state) {
737 state.addedItems = [];
738 state.items = [];
739 },
740 UPDATE_PAGINATION: function (state, pagination) {
741 state.pagination = pagination;
742 },
743 SEARCH_ITEM_REQUEST: function (state) {
744 state.status = 'loading';
745 },
746 SEARCH_ITEM_SUCCESS: function (state) {
747 state.status = 'successful';
748 },
749 SEARCH_ITEM_FAIL: function (state) {
750 state.status = 'fail';
751 }
752 };
753 /* harmony default export */ __webpack_exports__["default"] = (ModalQuizItems);
754
755 /***/ }),
756
757 /***/ "./assets/src/apps/js/admin/editor/mutations/question-list.js":
758 /*!********************************************************************!*\
759 !*** ./assets/src/apps/js/admin/editor/mutations/question-list.js ***!
760 \********************************************************************/
761 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
762
763 "use strict";
764 __webpack_require__.r(__webpack_exports__);
765 var $ = window.jQuery;
766 const QuestionList = {
767 SORT_QUESTIONS: function (state, orders) {
768 state.questions = state.questions.map(function (question) {
769 question.order = orders[question.id];
770 return question;
771 });
772 },
773 SORT_QUESTION_ANSWERS: function (state, orders) {
774 state.questions = state.questions.map(function (question) {
775 question.answers.answer_order = orders[question.answers.question_answer_id];
776 return question;
777 });
778 },
779 ADD_QUESTION_ANSWER: function (state, payload) {
780 state.questions = state.questions.map(function (question) {
781 if (question.id === payload.question_id) {
782 var found = false;
783
784 if (payload.answer.temp_id) {
785 for (var i = 0, n = question.answers.length; i < n; i++) {
786 if (question.answers[i].question_answer_id == payload.answer.temp_id) {
787 found = true;
788 $Vue.set(question.answers, i, payload.answer);
789 }
790 }
791 }
792
793 !found && question.answers.push(payload.answer);
794 return question;
795 }
796
797 return question;
798 });
799 },
800 CHANGE_QUESTION_CORRECT_ANSWERS: function (state, data) {
801 state.questions = state.questions.map(function (question) {
802 if (parseInt(question.id) === data.id) {
803 question.answers = data.answers;
804 }
805
806 return question;
807 });
808 },
809 SET_QUESTIONS: function (state, questions) {
810 state.questions = questions;
811 },
812 ADD_NEW_QUESTION: function (state, question) {
813 var found = false;
814
815 if (question.temp_id) {
816 for (var i = 0, n = state.questions.length; i < n; i++) {
817 if (state.questions[i].id === question.temp_id) {
818 $Vue.set(state.questions, i, question);
819 found = true;
820 break;
821 }
822 }
823 }
824
825 if (!found) {
826 var _last_child = $('.lp-list-questions .main > div:last-child');
827
828 if (_last_child.length) {
829 var _offset = _last_child.offset().top;
830
831 $('html,body').animate({
832 scrollTop: _offset
833 });
834 }
835
836 state.questions.push(question);
837 }
838 },
839 CHANGE_QUESTION_TYPE: function (state, data) {
840 state.questions = state.questions.map(function (question) {
841 if (parseInt(question.id) === data.id) {
842 question.answers = data.answers;
843 question.type = data.type;
844 question.open = true;
845 }
846
847 return question;
848 });
849 },
850 REMOVE_QUESTION: function (state, item) {
851 var questions = state.questions,
852 index = questions.indexOf(item);
853
854 if (item.temp_id) {
855 state.questions[index].id = item.temp_id;
856 } else {
857 state.questions.splice(index, 1);
858 }
859 },
860 DELETE_QUESTION_ANSWER: function (state, payload) {
861 var question_id = payload.question_id,
862 answer_id = payload.answer_id;
863 state.questions = state.questions.map(function (question) {
864 if (question.id === question_id) {
865 var answers = question.answers;
866 answers.forEach(function (answer) {
867 if (answer.question_answer_id === answer_id) {
868 var index = answers.indexOf(answer);
869 answers.splice(index, 1);
870 }
871 });
872 }
873
874 return question;
875 });
876 },
877 REMOVE_QUESTIONS: function () {// code
878 },
879 CLOSE_QUESTION: function (state, question) {
880 state.questions.forEach(function (_question, index) {
881 if (question.id === _question.id) {
882 state.questions[index].open = false;
883 }
884 });
885 },
886 OPEN_QUESTION: function (state, question) {
887 state.questions.forEach(function (_question, index) {
888 if (question.id === _question.id) {
889 state.questions[index].open = true;
890 }
891 });
892 },
893 CLOSE_LIST_QUESTIONS: function (state) {
894 state.questions = state.questions.map(function (_question) {
895 _question.open = false;
896 return _question;
897 });
898 },
899 OPEN_LIST_QUESTIONS: function (state) {
900 state.questions = state.questions.map(function (_question) {
901 _question.open = true;
902 return _question;
903 });
904 },
905 UPDATE_QUESTION_REQUEST: function (state, questionId) {
906 $Vue.set(state.statusUpdateQuestionItem, questionId, 'updating');
907 },
908 UPDATE_QUESTION_SUCCESS: function (state, questionID) {
909 $Vue.set(state.statusUpdateQuestionItem, questionID, 'successful');
910 },
911 UPDATE_QUESTION_FAILURE: function (state, questionID) {
912 $Vue.set(state.statusUpdateQuestionItem, questionID, 'failed');
913 },
914 UPDATE_QUESTION_ANSWER_REQUEST: function (state, question_id) {
915 $Vue.set(state.statusUpdateQuestionAnswer, question_id, 'updating');
916 },
917 UPDATE_QUESTION_ANSWER_SUCCESS: function (state, question_id) {
918 $Vue.set(state.statusUpdateQuestionAnswer, question_id, 'successful');
919 },
920 UPDATE_QUESTION_ANSWER_FAIL: function (state, question_id) {
921 $Vue.set(state.statusUpdateQuestionAnswer, question_id, 'failed');
922 },
923 DELETE_ANSWER: function (state, data) {
924 state.questions.map(function (question, index) {
925 if (question.id == data.question_id) {
926 for (var i = 0, n = question.answers.length; i < n; i++) {
927 if (question.answers[i].question_answer_id == data.answer_id) {
928 question.answers[i].question_answer_id = data.temp_id; //state.questions[index].answers.splice(i, 1);
929
930 break;
931 }
932 }
933
934 return false;
935 }
936 });
937 }
938 };
939 /* harmony default export */ __webpack_exports__["default"] = (QuestionList);
940
941 /***/ }),
942
943 /***/ "./assets/src/apps/js/admin/editor/mutations/quiz.js":
944 /*!***********************************************************!*\
945 !*** ./assets/src/apps/js/admin/editor/mutations/quiz.js ***!
946 \***********************************************************/
947 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
948
949 "use strict";
950 __webpack_require__.r(__webpack_exports__);
951 const Quiz = {
952 UPDATE_HEART_BEAT: function (state, status) {
953 state.heartbeat = !!status;
954 },
955 UPDATE_STATUS: function (state, status) {
956 state.status = status;
957 },
958 UPDATE_NEW_QUESTION_TYPE: function (state, type) {
959 state.default_new = type;
960 },
961 INCREASE_NUMBER_REQUEST: function (state) {
962 state.countCurrentRequest++;
963 },
964 DECREASE_NUMBER_REQUEST: function (state) {
965 state.countCurrentRequest--;
966 }
967 };
968 /* harmony default export */ __webpack_exports__["default"] = (Quiz);
969
970 /***/ }),
971
972 /***/ "./assets/src/apps/js/admin/editor/store/i18n.js":
973 /*!*******************************************************!*\
974 !*** ./assets/src/apps/js/admin/editor/store/i18n.js ***!
975 \*******************************************************/
976 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
977
978 "use strict";
979 __webpack_require__.r(__webpack_exports__);
980 const $ = window.jQuery || jQuery;
981
982 const i18n = function i18n(i18n) {
983 const state = $.extend({}, i18n);
984 const getters = {
985 all: function (state) {
986 return state;
987 }
988 };
989 return {
990 namespaced: true,
991 state: state,
992 getters: getters
993 };
994 };
995
996 /* harmony default export */ __webpack_exports__["default"] = (i18n);
997
998 /***/ }),
999
1000 /***/ "./assets/src/apps/js/admin/editor/store/modal-quiz-items.js":
1001 /*!*******************************************************************!*\
1002 !*** ./assets/src/apps/js/admin/editor/store/modal-quiz-items.js ***!
1003 \*******************************************************************/
1004 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1005
1006 "use strict";
1007 __webpack_require__.r(__webpack_exports__);
1008 /* harmony import */ var _getters_modal_quiz_items__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../getters/modal-quiz-items */ "./assets/src/apps/js/admin/editor/getters/modal-quiz-items.js");
1009 /* harmony import */ var _mutations_modal_quiz_items__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mutations/modal-quiz-items */ "./assets/src/apps/js/admin/editor/mutations/modal-quiz-items.js");
1010 /* harmony import */ var _actions_modal_quiz_items__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions/modal-quiz-items */ "./assets/src/apps/js/admin/editor/actions/modal-quiz-items.js");
1011
1012
1013
1014 const $ = window.jQuery || jQuery;
1015
1016 const Quiz = function (data) {
1017 var state = $.extend({
1018 quizId: false,
1019 pagination: '',
1020 status: ''
1021 }, data.chooseItems);
1022 return {
1023 namespaced: true,
1024 state: state,
1025 getters: _getters_modal_quiz_items__WEBPACK_IMPORTED_MODULE_0__["default"],
1026 mutations: _mutations_modal_quiz_items__WEBPACK_IMPORTED_MODULE_1__["default"],
1027 actions: _actions_modal_quiz_items__WEBPACK_IMPORTED_MODULE_2__["default"]
1028 };
1029 };
1030
1031 /* harmony default export */ __webpack_exports__["default"] = (Quiz);
1032
1033 /***/ }),
1034
1035 /***/ "./assets/src/apps/js/admin/editor/store/question-list.js":
1036 /*!****************************************************************!*\
1037 !*** ./assets/src/apps/js/admin/editor/store/question-list.js ***!
1038 \****************************************************************/
1039 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1040
1041 "use strict";
1042 __webpack_require__.r(__webpack_exports__);
1043 /* harmony import */ var _getters_question_list__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../getters/question-list */ "./assets/src/apps/js/admin/editor/getters/question-list.js");
1044 /* harmony import */ var _mutations_question_list__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mutations/question-list */ "./assets/src/apps/js/admin/editor/mutations/question-list.js");
1045 /* harmony import */ var _actions_question_list__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions/question-list */ "./assets/src/apps/js/admin/editor/actions/question-list.js");
1046
1047
1048
1049 const $ = window.jQuery || jQuery;
1050
1051 const QuestionList = function QuestionList(data) {
1052 const listQuestions = data.listQuestions;
1053 var state = $.extend({
1054 statusUpdateQuestions: {},
1055 statusUpdateQuestionItem: {},
1056 statusUpdateQuestionAnswer: {},
1057 questions: listQuestions.questions.map(function (question) {
1058 var hiddenQuestions = listQuestions.hidden_questions;
1059 var find = hiddenQuestions.find(function (questionId) {
1060 return parseInt(question.id) === parseInt(questionId);
1061 });
1062 question.open = !find;
1063 return question;
1064 })
1065 }, listQuestions);
1066 return {
1067 namespaced: true,
1068 state: state,
1069 getters: _getters_question_list__WEBPACK_IMPORTED_MODULE_0__["default"],
1070 mutations: _mutations_question_list__WEBPACK_IMPORTED_MODULE_1__["default"],
1071 actions: _actions_question_list__WEBPACK_IMPORTED_MODULE_2__["default"]
1072 };
1073 };
1074
1075 /* harmony default export */ __webpack_exports__["default"] = (QuestionList);
1076
1077 /***/ }),
1078
1079 /***/ "./assets/src/apps/js/admin/editor/store/quiz.js":
1080 /*!*******************************************************!*\
1081 !*** ./assets/src/apps/js/admin/editor/store/quiz.js ***!
1082 \*******************************************************/
1083 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1084
1085 "use strict";
1086 __webpack_require__.r(__webpack_exports__);
1087 /* harmony import */ var _getters_quiz__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../getters/quiz */ "./assets/src/apps/js/admin/editor/getters/quiz.js");
1088 /* harmony import */ var _mutations_quiz__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mutations/quiz */ "./assets/src/apps/js/admin/editor/mutations/quiz.js");
1089 /* harmony import */ var _actions_quiz__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions/quiz */ "./assets/src/apps/js/admin/editor/actions/quiz.js");
1090 /* harmony import */ var _store_modal_quiz_items__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../store/modal-quiz-items */ "./assets/src/apps/js/admin/editor/store/modal-quiz-items.js");
1091 /* harmony import */ var _store_i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../store/i18n */ "./assets/src/apps/js/admin/editor/store/i18n.js");
1092 /* harmony import */ var _store_question_list__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../store/question-list */ "./assets/src/apps/js/admin/editor/store/question-list.js");
1093
1094
1095
1096
1097
1098
1099 const $ = window.jQuery || jQuery;
1100
1101 const Quiz = function Quiz(data) {
1102 const state = $.extend({
1103 status: 'success',
1104 heartbeat: true,
1105 countCurrentRequest: 0
1106 }, data.root);
1107 return {
1108 state: state,
1109 getters: _getters_quiz__WEBPACK_IMPORTED_MODULE_0__["default"],
1110 mutations: _mutations_quiz__WEBPACK_IMPORTED_MODULE_1__["default"],
1111 actions: _actions_quiz__WEBPACK_IMPORTED_MODULE_2__["default"],
1112 modules: {
1113 cqi: (0,_store_modal_quiz_items__WEBPACK_IMPORTED_MODULE_3__["default"])(data),
1114 i18n: (0,_store_i18n__WEBPACK_IMPORTED_MODULE_4__["default"])(data.i18n),
1115 lqs: (0,_store_question_list__WEBPACK_IMPORTED_MODULE_5__["default"])(data)
1116 }
1117 };
1118 };
1119
1120 /* harmony default export */ __webpack_exports__["default"] = (Quiz);
1121
1122 /***/ })
1123
1124 /******/ });
1125 /************************************************************************/
1126 /******/ // The module cache
1127 /******/ var __webpack_module_cache__ = {};
1128 /******/
1129 /******/ // The require function
1130 /******/ function __webpack_require__(moduleId) {
1131 /******/ // Check if module is in cache
1132 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1133 /******/ if (cachedModule !== undefined) {
1134 /******/ return cachedModule.exports;
1135 /******/ }
1136 /******/ // Create a new module (and put it into the cache)
1137 /******/ var module = __webpack_module_cache__[moduleId] = {
1138 /******/ // no module.id needed
1139 /******/ // no module.loaded needed
1140 /******/ exports: {}
1141 /******/ };
1142 /******/
1143 /******/ // Execute the module function
1144 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1145 /******/
1146 /******/ // Return the exports of the module
1147 /******/ return module.exports;
1148 /******/ }
1149 /******/
1150 /************************************************************************/
1151 /******/ /* webpack/runtime/compat get default export */
1152 /******/ !function() {
1153 /******/ // getDefaultExport function for compatibility with non-harmony modules
1154 /******/ __webpack_require__.n = function(module) {
1155 /******/ var getter = module && module.__esModule ?
1156 /******/ function() { return module['default']; } :
1157 /******/ function() { return module; };
1158 /******/ __webpack_require__.d(getter, { a: getter });
1159 /******/ return getter;
1160 /******/ };
1161 /******/ }();
1162 /******/
1163 /******/ /* webpack/runtime/define property getters */
1164 /******/ !function() {
1165 /******/ // define getter functions for harmony exports
1166 /******/ __webpack_require__.d = function(exports, definition) {
1167 /******/ for(var key in definition) {
1168 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1169 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1170 /******/ }
1171 /******/ }
1172 /******/ };
1173 /******/ }();
1174 /******/
1175 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1176 /******/ !function() {
1177 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
1178 /******/ }();
1179 /******/
1180 /******/ /* webpack/runtime/make namespace object */
1181 /******/ !function() {
1182 /******/ // define __esModule on exports
1183 /******/ __webpack_require__.r = function(exports) {
1184 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1185 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1186 /******/ }
1187 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1188 /******/ };
1189 /******/ }();
1190 /******/
1191 /************************************************************************/
1192 var __webpack_exports__ = {};
1193 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1194 !function() {
1195 "use strict";
1196 /*!*************************************************!*\
1197 !*** ./assets/src/apps/js/admin/editor/quiz.js ***!
1198 \*************************************************/
1199 __webpack_require__.r(__webpack_exports__);
1200 /* harmony import */ var _store_quiz__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./store/quiz */ "./assets/src/apps/js/admin/editor/store/quiz.js");
1201 /* harmony import */ var _http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./http */ "./assets/src/apps/js/admin/editor/http.js");
1202 /* harmony import */ var _fill_in_blanks__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fill-in-blanks */ "./assets/src/apps/js/admin/editor/fill-in-blanks.js");
1203 /* harmony import */ var _fill_in_blanks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_fill_in_blanks__WEBPACK_IMPORTED_MODULE_2__);
1204
1205
1206
1207 window.$Vue = window.$Vue || Vue;
1208 window.$Vuex = window.$Vuex || Vuex;
1209 /**
1210 * Init app.
1211 *
1212 * @since 3.0.0
1213 */
1214
1215 window.jQuery(document).ready(function () {
1216 window.LP_Quiz_Store = new $Vuex.Store((0,_store_quiz__WEBPACK_IMPORTED_MODULE_0__["default"])(lp_quiz_editor));
1217 (0,_http__WEBPACK_IMPORTED_MODULE_1__["default"])({
1218 ns: 'LPListQuizQuestionsRequest',
1219 store: LP_Quiz_Store
1220 });
1221 setTimeout(() => {
1222 window.LP_Quiz_Editor = new $Vue({
1223 el: '#admin-editor-lp_quiz',
1224 template: '<lp-quiz-editor></lp-quiz-editor>'
1225 });
1226 }, 100);
1227 });
1228 }();
1229 /******/ })()
1230 ;
1231 //# sourceMappingURL=quiz.js.map