PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 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 All 140 releases
learnpress / assets / js / dist / admin / editor / quiz.js

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

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