PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9.4
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9.4
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 / question.js

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

536 lines 16.4 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/question.js":
5 /*!*************************************************************!*\
6 !*** ./assets/src/apps/js/admin/editor/actions/question.js ***!
7 \*************************************************************/
8 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 const Question = {
13 changeQuestionType(context, payload) {
14 const draftQuestion = undefined !== payload.question ? payload.question : '';
15 LP.Request({
16 type: 'change-question-type',
17 question_type: payload.type,
18 draft_question: context.getters.autoDraft ? draftQuestion : ''
19 }).then(function (response) {
20 const result = response.body;
21
22 if (result.success) {
23 context.commit('UPDATE_AUTO_DRAFT_STATUS', false);
24 context.commit('CHANGE_QUESTION_TYPE', result.data);
25 }
26 });
27 },
28
29 updateAnswersOrder(context, order) {
30 LP.Request({
31 type: 'sort-answer',
32 order
33 }).then(function (response) {
34 const result = response.body;
35
36 if (result.success) {// context.commit('SET_ANSWERS', result.data);
37 }
38 });
39 },
40
41 updateAnswerTitle(context, answer) {
42 if (typeof answer.question_answer_id == 'undefined') {
43 return;
44 }
45
46 answer = JSON.stringify(answer);
47 LP.Request({
48 type: 'update-answer-title',
49 answer
50 });
51 },
52
53 updateCorrectAnswer(context, correct) {
54 LP.Request({
55 type: 'change-correct',
56 correct: JSON.stringify(correct)
57 }).then(function (response) {
58 const result = response.body;
59
60 if (result.success) {
61 context.commit('UPDATE_ANSWERS', result.data);
62 context.commit('UPDATE_AUTO_DRAFT_STATUS', false);
63 }
64 });
65 },
66
67 deleteAnswer(context, payload) {
68 context.commit('DELETE_ANSWER', payload.id);
69 LP.Request({
70 type: 'delete-answer',
71 answer_id: payload.id
72 }).then(function (response) {
73 const result = response.body;
74
75 if (result.success) {
76 context.commit('SET_ANSWERS', result.data);
77 } else {// notice error
78 }
79 });
80 },
81
82 newAnswer(context, data) {
83 context.commit('ADD_NEW_ANSWER', data.answer);
84 LP.Request({
85 type: 'new-answer'
86 }).then(function (response) {
87 const result = response.body;
88
89 if (result.success) {
90 context.commit('UPDATE_ANSWERS', result.data);
91 } else {// notice error
92 }
93 });
94 },
95
96 newRequest(context) {
97 context.commit('INCREASE_NUMBER_REQUEST');
98 context.commit('UPDATE_STATUS', 'loading');
99
100 window.onbeforeunload = function () {
101 return '';
102 };
103 },
104
105 requestCompleted(context, status) {
106 context.commit('DECREASE_NUMBER_REQUEST');
107
108 if (context.getters.currentRequest === 0) {
109 context.commit('UPDATE_STATUS', status);
110 window.onbeforeunload = null;
111 }
112 }
113
114 };
115 /* harmony default export */ __webpack_exports__["default"] = (Question);
116
117 /***/ }),
118
119 /***/ "./assets/src/apps/js/admin/editor/fill-in-blanks.js":
120 /*!***********************************************************!*\
121 !*** ./assets/src/apps/js/admin/editor/fill-in-blanks.js ***!
122 \***********************************************************/
123 /***/ (function() {
124
125 (function ($) {
126 window.FIB = {
127 getSelectedText: function getSelectedText() {
128 let html = '';
129
130 if (typeof window.getSelection !== 'undefined') {
131 const sel = window.getSelection();
132
133 if (sel.rangeCount) {
134 const container = document.createElement('div');
135
136 for (let i = 0, len = sel.rangeCount; i < len; ++i) {
137 container.appendChild(sel.getRangeAt(i).cloneContents());
138 }
139
140 html = container.innerHTML;
141 }
142 } else if (typeof document.selection !== 'undefined') {
143 if (document.selection.type === 'Text') {
144 html = document.selection.createRange().htmlText;
145 }
146 }
147
148 return html;
149 },
150
151 createTextNode(content) {
152 return document.createTextNode(content);
153 },
154
155 isContainHtml: function isContainHtml(content) {
156 const $el = $(content),
157 sel = 'b.fib-blank';
158 return $el.is(sel) || $el.find(sel).length || $el.parent().is(sel);
159 },
160 getSelectionRange: function getSelectionRange() {
161 let t = '';
162
163 if (window.getSelection) {
164 t = window.getSelection();
165 } else if (document.getSelection) {
166 t = document.getSelection();
167 } else if (document.selection) {
168 t = document.selection.createRange().text;
169 }
170
171 return t;
172 },
173
174 outerHTML($dom) {
175 return $('<div>').append($($dom).clone()).html();
176 },
177
178 doUpgrade(callback) {
179 $.ajax({
180 url: '',
181 data: {
182 'lp-ajax': 'fib-upgrade'
183 },
184
185 success(res) {
186 console.log(res);
187 callback && callback.call(res);
188 }
189
190 });
191 }
192
193 };
194 $(document).ready(function () {
195 $('#do-upgrade-fib').on('click', function () {
196 const $button = $(this).prop('disabled', true).addClass('ajaxloading');
197 FIB.doUpgrade(function () {
198 $button.prop('disabled', false).removeClass('ajaxloading');
199 });
200 });
201 });
202 })(jQuery);
203
204 /***/ }),
205
206 /***/ "./assets/src/apps/js/admin/editor/getters/question.js":
207 /*!*************************************************************!*\
208 !*** ./assets/src/apps/js/admin/editor/getters/question.js ***!
209 \*************************************************************/
210 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
211
212 "use strict";
213 __webpack_require__.r(__webpack_exports__);
214 const Question = {
215 id: function (state) {
216 return state.id;
217 },
218 type: function (state) {
219 return state.type;
220 },
221 code: function (state) {
222 return Date.now();
223 },
224 autoDraft: function (state) {
225 return state.auto_draft;
226 },
227 answers: function (state) {
228 return Object.values(state.answers) || [];
229 },
230 settings: function (state) {
231 return state.setting;
232 },
233 types: function (state) {
234 return state.questionTypes || [];
235 },
236 numberCorrect: function (state) {
237 var correct = 0;
238 Object.keys(state.answers).forEach(function (key) {
239 if (state.answers[key].is_true === 'yes') {
240 correct += 1;
241 }
242 });
243 return correct;
244 },
245 status: function (state) {
246 return state.status;
247 },
248 currentRequest: function (state) {
249 return state.countCurrentRequest || 0;
250 },
251 action: function (state) {
252 return state.action;
253 },
254 nonce: function (state) {
255 return state.nonce;
256 },
257 externalComponent: function (state) {
258 return state.externalComponent || [];
259 },
260 supportAnswerOptions: function (state) {
261 return state.supportAnswerOptions || [];
262 },
263 state: function (state) {
264 return state;
265 },
266 i18n: function (state) {
267 return state.i18n;
268 }
269 };
270 /* harmony default export */ __webpack_exports__["default"] = (Question);
271
272 /***/ }),
273
274 /***/ "./assets/src/apps/js/admin/editor/http.js":
275 /*!*************************************************!*\
276 !*** ./assets/src/apps/js/admin/editor/http.js ***!
277 \*************************************************/
278 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
279
280 "use strict";
281 __webpack_require__.r(__webpack_exports__);
282 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
283 /* harmony export */ "default": function() { return /* binding */ HTTP; }
284 /* harmony export */ });
285 function HTTP(options) {
286 const $ = window.jQuery || jQuery;
287 const $VueHTTP = Vue.http;
288 options = $.extend({
289 ns: 'LPRequest',
290 store: false
291 }, options || {});
292 let $publishingAction = null;
293
294 LP.Request = function (payload) {
295 $publishingAction = $('#publishing-action');
296 payload.id = options.store.getters.id;
297 payload.nonce = options.store.getters.nonce;
298 payload['lp-ajax'] = options.store.getters.action;
299 payload.code = options.store.getters.code;
300 $publishingAction.find('#publish').addClass('disabled');
301 $publishingAction.find('.spinner').addClass('is-active');
302 $publishingAction.addClass('code-' + payload.code);
303 return $VueHTTP.post(options.store.getters.urlAjax, payload, {
304 emulateJSON: true,
305 params: {
306 namespace: options.ns,
307 code: payload.code
308 }
309 });
310 };
311
312 $VueHTTP.interceptors.push(function (request, next) {
313 if (request.params.namespace !== options.ns) {
314 next();
315 return;
316 }
317
318 options.store.dispatch('newRequest');
319 next(function (response) {
320 if (!jQuery.isPlainObject(response.body)) {
321 response.body = LP.parseJSON(response.body);
322 }
323
324 const body = response.body;
325 const result = body.success || false;
326
327 if (result) {
328 options.store.dispatch('requestCompleted', 'successful');
329 } else {
330 options.store.dispatch('requestCompleted', 'failed');
331 }
332
333 $publishingAction.removeClass('code-' + request.params.code);
334
335 if (!$publishingAction.attr('class')) {
336 $publishingAction.find('#publish').removeClass('disabled');
337 $publishingAction.find('.spinner').removeClass('is-active');
338 }
339 });
340 });
341 }
342
343 /***/ }),
344
345 /***/ "./assets/src/apps/js/admin/editor/mutations/question.js":
346 /*!***************************************************************!*\
347 !*** ./assets/src/apps/js/admin/editor/mutations/question.js ***!
348 \***************************************************************/
349 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
350
351 "use strict";
352 __webpack_require__.r(__webpack_exports__);
353 const Question = {
354 UPDATE_STATUS: function (state, status) {
355 state.status = status;
356 },
357 UPDATE_AUTO_DRAFT_STATUS: function (state, status) {
358 state.auto_draft = status;
359 },
360 CHANGE_QUESTION_TYPE: function (state, question) {
361 state.answers = question.answers;
362 state.type = question.type;
363 },
364 SET_ANSWERS: function (state, answers) {
365 state.answers = answers;
366 },
367 DELETE_ANSWER: function (state, id) {
368 for (var i = 0, n = state.answers.length; i < n; i++) {
369 if (state.answers[i].question_answer_id == id) {
370 state.answers[i].question_answer_id = LP.uniqueId();
371 break;
372 }
373 }
374 },
375 ADD_NEW_ANSWER: function (state, answer) {
376 state.answers.push(answer);
377 },
378 UPDATE_ANSWERS: function (state, answers) {
379 state.answers = answers;
380 },
381 INCREASE_NUMBER_REQUEST: function (state) {
382 state.countCurrentRequest++;
383 },
384 DECREASE_NUMBER_REQUEST: function (state) {
385 state.countCurrentRequest--;
386 }
387 };
388 /* harmony default export */ __webpack_exports__["default"] = (Question);
389
390 /***/ }),
391
392 /***/ "./assets/src/apps/js/admin/editor/store/question.js":
393 /*!***********************************************************!*\
394 !*** ./assets/src/apps/js/admin/editor/store/question.js ***!
395 \***********************************************************/
396 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
397
398 "use strict";
399 __webpack_require__.r(__webpack_exports__);
400 /* harmony import */ var _getters_question__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../getters/question */ "./assets/src/apps/js/admin/editor/getters/question.js");
401 /* harmony import */ var _mutations_question__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mutations/question */ "./assets/src/apps/js/admin/editor/mutations/question.js");
402 /* harmony import */ var _actions_question__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../actions/question */ "./assets/src/apps/js/admin/editor/actions/question.js");
403
404
405
406 const $ = window.jQuery || jQuery;
407
408 const Question = function Question(data) {
409 var state = $.extend({
410 status: 'successful',
411 countCurrentRequest: 0,
412 i18n: $.extend({}, data.i18n)
413 }, data.root);
414 return {
415 state: state,
416 getters: _getters_question__WEBPACK_IMPORTED_MODULE_0__["default"],
417 mutations: _mutations_question__WEBPACK_IMPORTED_MODULE_1__["default"],
418 actions: _actions_question__WEBPACK_IMPORTED_MODULE_2__["default"]
419 };
420 };
421
422 /* harmony default export */ __webpack_exports__["default"] = (Question);
423
424 /***/ })
425
426 /******/ });
427 /************************************************************************/
428 /******/ // The module cache
429 /******/ var __webpack_module_cache__ = {};
430 /******/
431 /******/ // The require function
432 /******/ function __webpack_require__(moduleId) {
433 /******/ // Check if module is in cache
434 /******/ var cachedModule = __webpack_module_cache__[moduleId];
435 /******/ if (cachedModule !== undefined) {
436 /******/ return cachedModule.exports;
437 /******/ }
438 /******/ // Create a new module (and put it into the cache)
439 /******/ var module = __webpack_module_cache__[moduleId] = {
440 /******/ // no module.id needed
441 /******/ // no module.loaded needed
442 /******/ exports: {}
443 /******/ };
444 /******/
445 /******/ // Execute the module function
446 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
447 /******/
448 /******/ // Return the exports of the module
449 /******/ return module.exports;
450 /******/ }
451 /******/
452 /************************************************************************/
453 /******/ /* webpack/runtime/compat get default export */
454 /******/ !function() {
455 /******/ // getDefaultExport function for compatibility with non-harmony modules
456 /******/ __webpack_require__.n = function(module) {
457 /******/ var getter = module && module.__esModule ?
458 /******/ function() { return module['default']; } :
459 /******/ function() { return module; };
460 /******/ __webpack_require__.d(getter, { a: getter });
461 /******/ return getter;
462 /******/ };
463 /******/ }();
464 /******/
465 /******/ /* webpack/runtime/define property getters */
466 /******/ !function() {
467 /******/ // define getter functions for harmony exports
468 /******/ __webpack_require__.d = function(exports, definition) {
469 /******/ for(var key in definition) {
470 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
471 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
472 /******/ }
473 /******/ }
474 /******/ };
475 /******/ }();
476 /******/
477 /******/ /* webpack/runtime/hasOwnProperty shorthand */
478 /******/ !function() {
479 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
480 /******/ }();
481 /******/
482 /******/ /* webpack/runtime/make namespace object */
483 /******/ !function() {
484 /******/ // define __esModule on exports
485 /******/ __webpack_require__.r = function(exports) {
486 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
487 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
488 /******/ }
489 /******/ Object.defineProperty(exports, '__esModule', { value: true });
490 /******/ };
491 /******/ }();
492 /******/
493 /************************************************************************/
494 var __webpack_exports__ = {};
495 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
496 !function() {
497 "use strict";
498 /*!*****************************************************!*\
499 !*** ./assets/src/apps/js/admin/editor/question.js ***!
500 \*****************************************************/
501 __webpack_require__.r(__webpack_exports__);
502 /* harmony import */ var _http__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http */ "./assets/src/apps/js/admin/editor/http.js");
503 /* harmony import */ var _store_question__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store/question */ "./assets/src/apps/js/admin/editor/store/question.js");
504 /* 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");
505 /* harmony import */ var _fill_in_blanks__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_fill_in_blanks__WEBPACK_IMPORTED_MODULE_2__);
506
507
508
509 window.$Vue = window.$Vue || Vue;
510 window.$Vuex = window.$Vuex || Vuex;
511 const $ = window.jQuery;
512 /**
513 * Init app.
514 *
515 * @since 3.0.0
516 */
517
518 $(document).ready(function () {
519 window.LP_Question_Store = new $Vuex.Store((0,_store_question__WEBPACK_IMPORTED_MODULE_1__["default"])(lp_question_editor));
520 (0,_http__WEBPACK_IMPORTED_MODULE_0__["default"])({
521 ns: 'LPQuestionEditorRequest',
522 store: LP_Question_Store
523 });
524 setTimeout(() => {
525 if ($('#admin-editor-lp_question').length) {
526 window.LP_Question_Editor = new $Vue({
527 el: '#admin-editor-lp_question',
528 template: '<lp-question-editor></lp-question-editor>'
529 });
530 }
531 }, 100);
532 });
533 }();
534 /******/ })()
535 ;
536 //# sourceMappingURL=question.js.map