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 / question.js

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

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