LearnPress – WordPress LMS Plugin - Version 4.0.3

Version Description

~ Fixed: tool "Reset course progress" ~ Added: tool "Create Database Indexes" ~ Fixed js button "Retake course" if have more than one. ~ Added: tool "Re upgrade Database" ~ If DB upgrade not success

Download this release

Release Info

Developer ThimPress
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 4.0.3
Comparing to
See all releases

Code changes from version 4.0.2 to 4.0.3

Files changed (65) hide show
  1. assets/js/dist/admin/editor/question.min.js +1 -1
  2. assets/js/dist/admin/pages/statistic.js +5 -1
  3. assets/js/dist/admin/pages/statistic.min.js +1 -1
  4. assets/js/dist/admin/pages/tools.js +228 -1
  5. assets/js/dist/admin/pages/tools.min.js +1 -1
  6. assets/js/dist/frontend/config.min.js +1 -1
  7. assets/js/dist/frontend/custom.min.js +1 -1
  8. assets/js/dist/frontend/lesson.min.js +1 -1
  9. assets/js/dist/frontend/modal.min.js +1 -1
  10. assets/js/dist/frontend/question-types.min.js +1 -1
  11. assets/js/dist/frontend/quiz.js +252 -0
  12. assets/js/dist/frontend/quiz.min.js +2 -2
  13. assets/js/dist/frontend/single-course.js +20 -9
  14. assets/js/dist/frontend/single-course.min.js +1 -1
  15. assets/js/dist/frontend/single-curriculum.js +124 -4
  16. assets/js/dist/frontend/single-curriculum.min.js +1 -1
  17. assets/js/dist/js/data-controls.min.js +1 -1
  18. assets/src/apps/js/admin/pages/statistic.js +5 -1
  19. assets/src/apps/js/admin/pages/tools.js +4 -0
  20. assets/src/apps/js/admin/pages/tools/database/create_indexs.js +135 -0
  21. assets/src/apps/js/admin/pages/tools/database/re-upgrade-db.js +53 -0
  22. assets/src/apps/js/admin/pages/tools/database/upgrade.js +6 -0
  23. assets/src/apps/js/frontend/quiz/components/result/index.js +12 -0
  24. assets/src/apps/js/frontend/single-course.js +12 -9
  25. assets/src/apps/js/frontend/single-curriculum/components/items-progress.js +47 -0
  26. assets/src/apps/js/frontend/single-curriculum/index.js +3 -0
  27. assets/src/apps/js/utils/lp-modal-overlay.js +11 -1
  28. inc/abstracts/abstract-api_bk_to_remove.php +0 -79
  29. inc/abstracts/abstract-rest-api.php +1 -1
  30. inc/admin/class-lp-admin-assets.php +2 -0
  31. inc/admin/class-lp-reset-data.php +48 -16
  32. inc/admin/meta-box/class-lp-meta-box-v3.php +0 -316
  33. inc/admin/views/tools/course/html-course.php +0 -87
  34. inc/admin/views/tools/course/html-user.php +6 -2
  35. inc/admin/views/tools/database/html-create-indexs-tables.php +26 -0
  36. inc/admin/views/tools/database/html-reupgrade-db.php +25 -0
  37. inc/admin/views/tools/html-database.php +3 -0
  38. inc/databases/class-lp-db.php +63 -6
  39. inc/lp-template-functions.php +1 -1
  40. inc/rest-api/admin/class-lp-admin-core-api.php +0 -33
  41. inc/rest-api/class-lp-admin-core-api.php +47 -0
  42. inc/rest-api/class-lp-core-api.php +15 -4
  43. inc/rest-api/class-lp-rest-authentication.php +1 -1
  44. inc/rest-api/{admin → v1/admin}/class-lp-admin-rest-course-controller.php +0 -0
  45. inc/rest-api/{admin → v1/admin}/class-lp-admin-rest-database-controller.php +90 -3
  46. inc/rest-api/{admin → v1/admin}/class-lp-admin-rest-question-controller.php +0 -0
  47. inc/rest-api/v1/admin/class-lp-admin-rest-tools-controller.php +136 -0
  48. inc/rest-api/{class-lp-rest-courses-controller.php → v1/frontend/class-lp-rest-courses-controller.php} +5 -0
  49. inc/rest-api/{class-lp-rest-lazy-load-controller.php → v1/frontend/class-lp-rest-lazy-load-controller.php} +51 -0
  50. inc/rest-api/{class-lp-rest-settings-controller.php → v1/frontend/class-lp-rest-settings-controller.php} +0 -0
  51. inc/rest-api/{class-lp-rest-users-controller.php → v1/frontend/class-lp-rest-users-controller.php} +0 -0
  52. inc/shortcodes/class-lp-shortcode-profile.php +5 -5
  53. inc/templates/abstract-template.php +2 -0
  54. inc/templates/class-lp-template-course.php +49 -28
  55. inc/updates/learnpress-upgrade-4.php +43 -0
  56. inc/user/abstract-lp-user.php +13 -3
  57. inc/user/class-lp-user-factory.php +2 -0
  58. languages/learnpress.pot +1 -1
  59. learnpress.php +2 -2
  60. readme.txt +7 -1
  61. templates/global/lp-group-step.php +37 -0
  62. templates/pages/profile.php +0 -2
  63. templates/profile/tabs.php +1 -2
  64. templates/single-course/buttons/finish.php +1 -6
  65. templates/single-course/content-item/popup-header.php +0 -6
assets/js/dist/admin/editor/question.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}({0:function(e,t,n){"use strict";function o(e){var t=window.jQuery||jQuery,n=Vue.http;e=t.extend({ns:"LPRequest",store:!1},e||{});var o=null;LP.Request=function(r){return o=t("#publishing-action"),r.id=e.store.getters.id,r.nonce=e.store.getters.nonce,r["lp-ajax"]=e.store.getters.action,r.code=e.store.getters.code,o.find("#publish").addClass("disabled"),o.find(".spinner").addClass("is-active"),o.addClass("code-"+r.code),n.post(e.store.getters.urlAjax,r,{emulateJSON:!0,params:{namespace:e.ns,code:r.code}})},n.interceptors.push((function(t,n){t.params.namespace===e.ns?(e.store.dispatch("newRequest"),n((function(n){jQuery.isPlainObject(n.body)||(n.body=LP.parseJSON(n.body)),n.body.success||!1?e.store.dispatch("requestCompleted","successful"):e.store.dispatch("requestCompleted","failed"),o.removeClass("code-"+t.params.code),o.attr("class")||(o.find("#publish").removeClass("disabled"),o.find(".spinner").removeClass("is-active"))}))):n()}))}n.d(t,"a",(function(){return o}))},14:function(e,t,n){"use strict";n.r(t);var o=n(0),r={id:function(e){return e.id},type:function(e){return e.type},code:function(e){return Date.now()},autoDraft:function(e){return e.auto_draft},answers:function(e){return Object.values(e.answers)||[]},settings:function(e){return e.setting},types:function(e){return e.questionTypes||[]},numberCorrect:function(e){var t=0;return Object.keys(e.answers).forEach((function(n){"yes"===e.answers[n].is_true&&(t+=1)})),t},status:function(e){return e.status},currentRequest:function(e){return e.countCurrentRequest||0},action:function(e){return e.action},nonce:function(e){return e.nonce},externalComponent:function(e){return e.externalComponent||[]},supportAnswerOptions:function(e){return e.supportAnswerOptions||[]},state:function(e){return e},i18n:function(e){return e.i18n}},u={UPDATE_STATUS:function(e,t){e.status=t},UPDATE_AUTO_DRAFT_STATUS:function(e,t){e.auto_draft=t},CHANGE_QUESTION_TYPE:function(e,t){e.answers=t.answers,e.type=t.type},SET_ANSWERS:function(e,t){e.answers=t},DELETE_ANSWER:function(e,t){for(var n=0,o=e.answers.length;n<o;n++)if(e.answers[n].question_answer_id==t){e.answers[n].question_answer_id=LP.uniqueId();break}},ADD_NEW_ANSWER:function(e,t){e.answers.push(t)},UPDATE_ANSWERS:function(e,t){e.answers=t},INCREASE_NUMBER_REQUEST:function(e){e.countCurrentRequest++},DECREASE_NUMBER_REQUEST:function(e){e.countCurrentRequest--}},i={changeQuestionType:function(e,t){LP.Request({type:"change-question-type",question_type:t.type,draft_question:e.getters.autoDraft?JSON.stringify(t.question):""}).then((function(t){var n=t.body;n.success&&(e.commit("UPDATE_AUTO_DRAFT_STATUS",!1),e.commit("CHANGE_QUESTION_TYPE",n.data))}))},updateAnswersOrder:function(e,t){LP.Request({type:"sort-answer",order:t}).then((function(e){e.body.success}))},updateAnswerTitle:function(e,t){void 0!==t.question_answer_id&&(t=JSON.stringify(t),LP.Request({type:"update-answer-title",answer:t}))},updateCorrectAnswer:function(e,t){LP.Request({type:"change-correct",correct:JSON.stringify(t)}).then((function(t){var n=t.body;n.success&&(e.commit("UPDATE_ANSWERS",n.data),e.commit("UPDATE_AUTO_DRAFT_STATUS",!1))}))},deleteAnswer:function(e,t){e.commit("DELETE_ANSWER",t.id),LP.Request({type:"delete-answer",answer_id:t.id}).then((function(t){var n=t.body;n.success&&e.commit("SET_ANSWERS",n.data)}))},newAnswer:function(e,t){e.commit("ADD_NEW_ANSWER",t.answer),LP.Request({type:"new-answer"}).then((function(t){var n=t.body;n.success&&e.commit("UPDATE_ANSWERS",n.data)}))},newRequest:function(e){e.commit("INCREASE_NUMBER_REQUEST"),e.commit("UPDATE_STATUS","loading"),window.onbeforeunload=function(){return""}},requestCompleted:function(e,t){e.commit("DECREASE_NUMBER_REQUEST"),0===e.getters.currentRequest&&(e.commit("UPDATE_STATUS",t),window.onbeforeunload=null)}},s=window.jQuery||jQuery,c=function(e){return{state:s.extend({status:"successful",countCurrentRequest:0,i18n:s.extend({},e.i18n)},e.root),getters:r,mutations:u,actions:i}};n(2);window.$Vue=window.$Vue||Vue,window.$Vuex=window.$Vuex||Vuex;var a=window.jQuery;a(document).ready((function(){window.LP_Question_Store=new $Vuex.Store(c(lp_question_editor)),Object(o.a)({ns:"LPQuestionEditorRequest",store:LP_Question_Store}),setTimeout((function(){a("#admin-editor-lp_question").length&&(window.LP_Question_Editor=new $Vue({el:"#admin-editor-lp_question",template:"<lp-question-editor></lp-question-editor>"}))}),100)}))},2:function(e,t){var n;n=jQuery,window.FIB={getSelectedText:function(){var e="";if(void 0!==window.getSelection){var t=window.getSelection();if(t.rangeCount){for(var n=document.createElement("div"),o=0,r=t.rangeCount;o<r;++o)n.appendChild(t.getRangeAt(o).cloneContents());e=n.innerHTML}}else void 0!==document.selection&&"Text"===document.selection.type&&(e=document.selection.createRange().htmlText);return e},createTextNode:function(e){return document.createTextNode(e)},isContainHtml:function(e){var t=n(e),o="b.fib-blank";return t.is(o)||t.find(o).length||t.parent().is(o)},getSelectionRange:function(){var e="";return window.getSelection?e=window.getSelection():document.getSelection?e=document.getSelection():document.selection&&(e=document.selection.createRange().text),e},outerHTML:function(e){return n("<div>").append(n(e).clone()).html()},doUpgrade:function(e){n.ajax({url:"",data:{"lp-ajax":"fib-upgrade"},success:function(t){console.log(t),e&&e.call(t)}})}},n(document).ready((function(){n("#do-upgrade-fib").on("click",(function(){var e=n(this).prop("disabled",!0).addClass("ajaxloading");FIB.doUpgrade((function(){e.prop("disabled",!1).removeClass("ajaxloading")}))}))}))}});
1
+ !function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}({0:function(e,t,n){"use strict";function o(e){var t=window.jQuery||jQuery,n=Vue.http;e=t.extend({ns:"LPRequest",store:!1},e||{});var o=null;LP.Request=function(r){return o=t("#publishing-action"),r.id=e.store.getters.id,r.nonce=e.store.getters.nonce,r["lp-ajax"]=e.store.getters.action,r.code=e.store.getters.code,o.find("#publish").addClass("disabled"),o.find(".spinner").addClass("is-active"),o.addClass("code-"+r.code),n.post(e.store.getters.urlAjax,r,{emulateJSON:!0,params:{namespace:e.ns,code:r.code}})},n.interceptors.push((function(t,n){t.params.namespace===e.ns?(e.store.dispatch("newRequest"),n((function(n){jQuery.isPlainObject(n.body)||(n.body=LP.parseJSON(n.body)),n.body.success||!1?e.store.dispatch("requestCompleted","successful"):e.store.dispatch("requestCompleted","failed"),o.removeClass("code-"+t.params.code),o.attr("class")||(o.find("#publish").removeClass("disabled"),o.find(".spinner").removeClass("is-active"))}))):n()}))}n.d(t,"a",(function(){return o}))},15:function(e,t,n){"use strict";n.r(t);var o=n(0),r={id:function(e){return e.id},type:function(e){return e.type},code:function(e){return Date.now()},autoDraft:function(e){return e.auto_draft},answers:function(e){return Object.values(e.answers)||[]},settings:function(e){return e.setting},types:function(e){return e.questionTypes||[]},numberCorrect:function(e){var t=0;return Object.keys(e.answers).forEach((function(n){"yes"===e.answers[n].is_true&&(t+=1)})),t},status:function(e){return e.status},currentRequest:function(e){return e.countCurrentRequest||0},action:function(e){return e.action},nonce:function(e){return e.nonce},externalComponent:function(e){return e.externalComponent||[]},supportAnswerOptions:function(e){return e.supportAnswerOptions||[]},state:function(e){return e},i18n:function(e){return e.i18n}},u={UPDATE_STATUS:function(e,t){e.status=t},UPDATE_AUTO_DRAFT_STATUS:function(e,t){e.auto_draft=t},CHANGE_QUESTION_TYPE:function(e,t){e.answers=t.answers,e.type=t.type},SET_ANSWERS:function(e,t){e.answers=t},DELETE_ANSWER:function(e,t){for(var n=0,o=e.answers.length;n<o;n++)if(e.answers[n].question_answer_id==t){e.answers[n].question_answer_id=LP.uniqueId();break}},ADD_NEW_ANSWER:function(e,t){e.answers.push(t)},UPDATE_ANSWERS:function(e,t){e.answers=t},INCREASE_NUMBER_REQUEST:function(e){e.countCurrentRequest++},DECREASE_NUMBER_REQUEST:function(e){e.countCurrentRequest--}},i={changeQuestionType:function(e,t){LP.Request({type:"change-question-type",question_type:t.type,draft_question:e.getters.autoDraft?JSON.stringify(t.question):""}).then((function(t){var n=t.body;n.success&&(e.commit("UPDATE_AUTO_DRAFT_STATUS",!1),e.commit("CHANGE_QUESTION_TYPE",n.data))}))},updateAnswersOrder:function(e,t){LP.Request({type:"sort-answer",order:t}).then((function(e){e.body.success}))},updateAnswerTitle:function(e,t){void 0!==t.question_answer_id&&(t=JSON.stringify(t),LP.Request({type:"update-answer-title",answer:t}))},updateCorrectAnswer:function(e,t){LP.Request({type:"change-correct",correct:JSON.stringify(t)}).then((function(t){var n=t.body;n.success&&(e.commit("UPDATE_ANSWERS",n.data),e.commit("UPDATE_AUTO_DRAFT_STATUS",!1))}))},deleteAnswer:function(e,t){e.commit("DELETE_ANSWER",t.id),LP.Request({type:"delete-answer",answer_id:t.id}).then((function(t){var n=t.body;n.success&&e.commit("SET_ANSWERS",n.data)}))},newAnswer:function(e,t){e.commit("ADD_NEW_ANSWER",t.answer),LP.Request({type:"new-answer"}).then((function(t){var n=t.body;n.success&&e.commit("UPDATE_ANSWERS",n.data)}))},newRequest:function(e){e.commit("INCREASE_NUMBER_REQUEST"),e.commit("UPDATE_STATUS","loading"),window.onbeforeunload=function(){return""}},requestCompleted:function(e,t){e.commit("DECREASE_NUMBER_REQUEST"),0===e.getters.currentRequest&&(e.commit("UPDATE_STATUS",t),window.onbeforeunload=null)}},s=window.jQuery||jQuery,c=function(e){return{state:s.extend({status:"successful",countCurrentRequest:0,i18n:s.extend({},e.i18n)},e.root),getters:r,mutations:u,actions:i}};n(2);window.$Vue=window.$Vue||Vue,window.$Vuex=window.$Vuex||Vuex;var a=window.jQuery;a(document).ready((function(){window.LP_Question_Store=new $Vuex.Store(c(lp_question_editor)),Object(o.a)({ns:"LPQuestionEditorRequest",store:LP_Question_Store}),setTimeout((function(){a("#admin-editor-lp_question").length&&(window.LP_Question_Editor=new $Vue({el:"#admin-editor-lp_question",template:"<lp-question-editor></lp-question-editor>"}))}),100)}))},2:function(e,t){var n;n=jQuery,window.FIB={getSelectedText:function(){var e="";if(void 0!==window.getSelection){var t=window.getSelection();if(t.rangeCount){for(var n=document.createElement("div"),o=0,r=t.rangeCount;o<r;++o)n.appendChild(t.getRangeAt(o).cloneContents());e=n.innerHTML}}else void 0!==document.selection&&"Text"===document.selection.type&&(e=document.selection.createRange().htmlText);return e},createTextNode:function(e){return document.createTextNode(e)},isContainHtml:function(e){var t=n(e),o="b.fib-blank";return t.is(o)||t.find(o).length||t.parent().is(o)},getSelectionRange:function(){var e="";return window.getSelection?e=window.getSelection():document.getSelection?e=document.getSelection():document.selection&&(e=document.selection.createRange().text),e},outerHTML:function(e){return n("<div>").append(n(e).clone()).html()},doUpgrade:function(e){n.ajax({url:"",data:{"lp-ajax":"fib-upgrade"},success:function(t){console.log(t),e&&e.call(t)}})}},n(document).ready((function(){n("#do-upgrade-fib").on("click",(function(){var e=n(this).prop("disabled",!0).addClass("ajaxloading");FIB.doUpgrade((function(){e.prop("disabled",!1).removeClass("ajaxloading")}))}))}))}});
assets/js/dist/admin/pages/statistic.js CHANGED
@@ -100,7 +100,11 @@
100
  $canvas = $('<canvas />');
101
  $elem.html('');
102
  $canvas.appendTo($elem);
103
- new Chart($canvas.get(0).getContext('2d')).Line(data, config);
 
 
 
 
104
  }); //
105
  };
106
 
100
  $canvas = $('<canvas />');
101
  $elem.html('');
102
  $canvas.appendTo($elem);
103
+ var lineChart = new Chart($canvas, {
104
+ type: 'line',
105
+ data: data,
106
+ options: config
107
+ });
108
  }); //
109
  };
110
 
assets/js/dist/admin/pages/statistic.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function r(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(n,a,function(e){return t[e]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}({7:function(t,e){var r;(r=jQuery).fn.LP_Chart_Line=function(t,e){return r.each(this,(function(){var n=r(this),a=r("<canvas />");n.html(""),a.appendTo(n),new Chart(a.get(0).getContext("2d")).Line(t,e)}))},r.fn.LP_Statistic_Users=function(){if(0!==parseInt(r(this).length))return r.each(this,(function(){var t=r(".chart-buttons button").on("click",(function(){var e=r(this),n=e.data("type"),a="",o="";if(t.not(this).not('[data-type="user-custom-time"]').prop("disabled",!1),"user-custom-time"==n){if(a=r('#user-custom-time input[name="from"]').val(),o=r('#user-custom-time input[name="to"]').val(),""==a||""==o)return!1}else e.prop("disabled",!0);var i=r("#learn-press-chart");return i.addClass("loading"),r.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:n,range:[a,o]},dataType:"text",success:function(t){t=LP.parseJSON(t),i.LP_Chart_Line(t,LP_Chart_Config),i.removeClass("loading")}}),!1})),e=r('.chart-buttons #user-custom-time input[type="text"]').on("change",(function(){t.filter('[data-type="user-custom-time"]').prop("disabled",e.filter((function(){return""==this.value})).get().length||!function(){if(new Date(e[0].value)<new Date(e[1].value))return!0}())}))}))},r.fn.LP_Statistic_Courses=function(){if(0!==parseInt(r(this).length))return r.each(this,(function(){var t=r(".chart-buttons button").on("click",(function(){var e=r(this),n=e.data("type"),a="",o="",i=r("#learn-press-chart");if(t.not(this).not('[data-type="course-custom-time"]').prop("disabled",!1),"course-custom-time"==n){if(a=r('#course-custom-time input[name="from"]').val(),o=r('#course-custom-time input[name="to"]').val(),""==a||""==o)return!1}else e.prop("disabled",!0);return i.addClass("loading"),r.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:n,range:[a,o]},dataType:"text",success:function(t){t=LP.parseJSON(t),i.LP_Chart_Line(t,LP_Chart_Config),i.removeClass("loading")}}),!1})),e=r('.chart-buttons #course-custom-time input[type="text"]').on("change",(function(){t.filter('[data-type="course-custom-time"]').prop("disabled",e.filter((function(){return""==this.value})).get().length||!function(){if(new Date(e[0].value)<new Date(e[1].value))return!0}())}))}))},r.fn.LP_Statistic_Orders=function(){if(0!==parseInt(r(this).length)){r(".panel_report_option").hide(),r("#panel_report_sales_by_"+r("#report_sales_by").val()).show(),r("#report_sales_by").on("change",(function(){r(".panel_report_option").hide(),r("#panel_report_sales_by_"+r(this).val()).show(),"date"==r(this).val()&&t()}));var t=function(){var t,e="",n="",a="",o=0,i=0;t=r("#report_sales_by").val(),$container=r("#learn-press-chart"),$container.addClass("loading");var s=r(".chart-buttons button:disabled").not('[data-type="order-custom-time"]');if(parseInt(s.length)>0)e=r(s[0]).data("type");else if(e="order-custom-time",n=r('#order-custom-time input[name="from"]').val(),a=r('#order-custom-time input[name="to"]').val(),""==n||""==a)return!1;"course"===t?i=r("#report-by-course-id").val():"category"===t&&(o=r("#report-by-course-category-id").val()),r.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:e,range:[n,a],report_sales_by:t,course_id:i,cat_id:o},dataType:"text",success:function(t){t=LP.parseJSON(t),$container.LP_Chart_Line(t,LP_Chart_Config),$container.removeClass("loading")}})};r("#report-by-course-id").select2({placeholder:"Select a course",minimumInputLength:1,ajax:{url:ajaxurl+"?action=learnpress_search_course",dataType:"json",quietMillis:250,data:function(t,e){return{q:t}},results:function(t,e){return{results:t.items}},cache:!0}}),r("#report-by-course-id").on("change",(function(){t()})),r("#report-by-course-category-id").select2({placeholder:"Select a course",minimumInputLength:1,ajax:{url:ajaxurl+"?action=learnpress_search_course_category",dataType:"json",quietMillis:250,data:function(t,e){return{q:t}},results:function(t,e){return{results:t.items}},cache:!0}}),r("#report-by-course-category-id").on("change",(function(){t()}));var e=r(".chart-buttons button").on("click",(function(){var n=r(this),a=n.data("type");return r("#learn-press-chart"),e.not(this).not('[data-type="order-custom-time"]').prop("disabled",!1),"order-custom-time"!==a&&(n.prop("disabled",!0),r('#order-custom-time input[name="from"]').val(""),r('#order-custom-time input[name="to"]').val("")),t(),!1})),n=r('.chart-buttons #order-custom-time input[type="text"]').on("change",(function(){e.filter('[data-type="order-custom-time"]').prop("disabled",n.filter((function(){return""==this.value})).get().length||!function(){if(new Date(n[0].value)<new Date(n[1].value))return!0}())}))}},r((function(){void 0!==r.fn.datepicker&&r(".date-picker").datepicker({dateFormat:"yy/mm/dd"}),r(".learn-press-statistic-users").LP_Statistic_Users(),r(".learn-press-statistic-courses").LP_Statistic_Courses(),r(".learn-press-statistic-orders").LP_Statistic_Orders()}))}});
1
+ !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}({7:function(t,e){var r;(r=jQuery).fn.LP_Chart_Line=function(t,e){return r.each(this,(function(){var a=r(this),n=r("<canvas />");a.html(""),n.appendTo(a),new Chart(n,{type:"line",data:t,options:e})}))},r.fn.LP_Statistic_Users=function(){if(0!==parseInt(r(this).length))return r.each(this,(function(){var t=r(".chart-buttons button").on("click",(function(){var e=r(this),a=e.data("type"),n="",o="";if(t.not(this).not('[data-type="user-custom-time"]').prop("disabled",!1),"user-custom-time"==a){if(n=r('#user-custom-time input[name="from"]').val(),o=r('#user-custom-time input[name="to"]').val(),""==n||""==o)return!1}else e.prop("disabled",!0);var i=r("#learn-press-chart");return i.addClass("loading"),r.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:a,range:[n,o]},dataType:"text",success:function(t){t=LP.parseJSON(t),i.LP_Chart_Line(t,LP_Chart_Config),i.removeClass("loading")}}),!1})),e=r('.chart-buttons #user-custom-time input[type="text"]').on("change",(function(){t.filter('[data-type="user-custom-time"]').prop("disabled",e.filter((function(){return""==this.value})).get().length||!function(){if(new Date(e[0].value)<new Date(e[1].value))return!0}())}))}))},r.fn.LP_Statistic_Courses=function(){if(0!==parseInt(r(this).length))return r.each(this,(function(){var t=r(".chart-buttons button").on("click",(function(){var e=r(this),a=e.data("type"),n="",o="",i=r("#learn-press-chart");if(t.not(this).not('[data-type="course-custom-time"]').prop("disabled",!1),"course-custom-time"==a){if(n=r('#course-custom-time input[name="from"]').val(),o=r('#course-custom-time input[name="to"]').val(),""==n||""==o)return!1}else e.prop("disabled",!0);return i.addClass("loading"),r.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:a,range:[n,o]},dataType:"text",success:function(t){t=LP.parseJSON(t),i.LP_Chart_Line(t,LP_Chart_Config),i.removeClass("loading")}}),!1})),e=r('.chart-buttons #course-custom-time input[type="text"]').on("change",(function(){t.filter('[data-type="course-custom-time"]').prop("disabled",e.filter((function(){return""==this.value})).get().length||!function(){if(new Date(e[0].value)<new Date(e[1].value))return!0}())}))}))},r.fn.LP_Statistic_Orders=function(){if(0!==parseInt(r(this).length)){r(".panel_report_option").hide(),r("#panel_report_sales_by_"+r("#report_sales_by").val()).show(),r("#report_sales_by").on("change",(function(){r(".panel_report_option").hide(),r("#panel_report_sales_by_"+r(this).val()).show(),"date"==r(this).val()&&t()}));var t=function(){var t,e="",a="",n="",o=0,i=0;t=r("#report_sales_by").val(),$container=r("#learn-press-chart"),$container.addClass("loading");var s=r(".chart-buttons button:disabled").not('[data-type="order-custom-time"]');if(parseInt(s.length)>0)e=r(s[0]).data("type");else if(e="order-custom-time",a=r('#order-custom-time input[name="from"]').val(),n=r('#order-custom-time input[name="to"]').val(),""==a||""==n)return!1;"course"===t?i=r("#report-by-course-id").val():"category"===t&&(o=r("#report-by-course-category-id").val()),r.ajax({url:"admin-ajax.php",data:{action:"learnpress_load_chart",type:e,range:[a,n],report_sales_by:t,course_id:i,cat_id:o},dataType:"text",success:function(t){t=LP.parseJSON(t),$container.LP_Chart_Line(t,LP_Chart_Config),$container.removeClass("loading")}})};r("#report-by-course-id").select2({placeholder:"Select a course",minimumInputLength:1,ajax:{url:ajaxurl+"?action=learnpress_search_course",dataType:"json",quietMillis:250,data:function(t,e){return{q:t}},results:function(t,e){return{results:t.items}},cache:!0}}),r("#report-by-course-id").on("change",(function(){t()})),r("#report-by-course-category-id").select2({placeholder:"Select a course",minimumInputLength:1,ajax:{url:ajaxurl+"?action=learnpress_search_course_category",dataType:"json",quietMillis:250,data:function(t,e){return{q:t}},results:function(t,e){return{results:t.items}},cache:!0}}),r("#report-by-course-category-id").on("change",(function(){t()}));var e=r(".chart-buttons button").on("click",(function(){var a=r(this),n=a.data("type");return r("#learn-press-chart"),e.not(this).not('[data-type="order-custom-time"]').prop("disabled",!1),"order-custom-time"!==n&&(a.prop("disabled",!0),r('#order-custom-time input[name="from"]').val(""),r('#order-custom-time input[name="to"]').val("")),t(),!1})),a=r('.chart-buttons #order-custom-time input[type="text"]').on("change",(function(){e.filter('[data-type="order-custom-time"]').prop("disabled",a.filter((function(){return""==this.value})).get().length||!function(){if(new Date(a[0].value)<new Date(a[1].value))return!0}())}))}},r((function(){void 0!==r.fn.datepicker&&r(".date-picker").datepicker({dateFormat:"yy/mm/dd"}),r(".learn-press-statistic-users").LP_Statistic_Users(),r(".learn-press-statistic-courses").LP_Statistic_Courses(),r(".learn-press-statistic-orders").LP_Statistic_Orders()}))}});
assets/js/dist/admin/pages/tools.js CHANGED
@@ -96,6 +96,10 @@
96
  "use strict";
97
  __webpack_require__.r(__webpack_exports__);
98
  /* harmony import */ var _tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/database/upgrade */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/upgrade.js");
 
 
 
 
99
 
100
 
101
  (function ($) {
@@ -201,12 +205,216 @@ __webpack_require__.r(__webpack_exports__);
201
 
202
  $(function () {
203
  Object(_tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__["default"])();
 
 
204
  $doc.on('click', '.lp-install-sample__install', installSampleCourse).on('click', '.lp-install-sample__uninstall', uninstallSampleCourse).on('click', '#learn-press-clear-cache', clearHardCache).on('click', 'input[name="enable_hard_cache"]', toggleHardCache).on('click', '.lp-install-sample__toggle-options', toggleOptions);
205
  });
206
  })(jQuery);
207
 
208
  /***/ }),
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/upgrade.js":
211
  /*!*********************************************************************************************************************************************************************************!*\
212
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/upgrade.js ***!
@@ -355,6 +563,11 @@ var upgradeDB = function upgradeDB() {
355
  elItemStepCurrent.removeClass('running').addClass('error');
356
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal(elWrapperUpgradeMessage.html(), function () {
357
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes.text('Retry').show();
 
 
 
 
 
358
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo.show();
359
 
360
  if (!res.message) {
@@ -369,6 +582,11 @@ var upgradeDB = function upgradeDB() {
369
  isUpgrading = 0;
370
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal(elWrapperUpgradeMessage.html(), function () {
371
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes.text('Retry').show();
 
 
 
 
 
372
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo.show();
373
 
374
  if (!err.message) {
@@ -536,7 +754,12 @@ var lpModalOverlay = {
536
  elFooter: null,
537
  elCalledModal: null,
538
  callBackYes: null,
 
539
  init: function init() {
 
 
 
 
540
  this.elLPOverlay = $('.lp-overlay');
541
 
542
  if (!this.elLPOverlay.length) {
@@ -552,11 +775,15 @@ var lpModalOverlay = {
552
  $(document).on('click', '.close, .btn-no', function () {
553
  elLPOverlay.hide();
554
  });
555
- $(document).on('click', '.btn-yes', function () {
 
 
 
556
  if ('function' === typeof lpModalOverlay.callBackYes) {
557
  lpModalOverlay.callBackYes();
558
  }
559
  });
 
560
  return true;
561
  },
562
  setElCalledModal: function setElCalledModal(elCalledModal) {
96
  "use strict";
97
  __webpack_require__.r(__webpack_exports__);
98
  /* harmony import */ var _tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/database/upgrade */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/upgrade.js");
99
+ /* harmony import */ var _tools_database_create_indexs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools/database/create_indexs */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/create_indexs.js");
100
+ /* harmony import */ var _tools_database_re_upgrade_db__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools/database/re-upgrade-db */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/re-upgrade-db.js");
101
+
102
+
103
 
104
 
105
  (function ($) {
205
 
206
  $(function () {
207
  Object(_tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__["default"])();
208
+ Object(_tools_database_create_indexs__WEBPACK_IMPORTED_MODULE_1__["default"])();
209
+ Object(_tools_database_re_upgrade_db__WEBPACK_IMPORTED_MODULE_2__["default"])();
210
  $doc.on('click', '.lp-install-sample__install', installSampleCourse).on('click', '.lp-install-sample__uninstall', uninstallSampleCourse).on('click', '#learn-press-clear-cache', clearHardCache).on('click', 'input[name="enable_hard_cache"]', toggleHardCache).on('click', '.lp-install-sample__toggle-options', toggleOptions);
211
  });
212
  })(jQuery);
213
 
214
  /***/ }),
215
 
216
+ /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/create_indexs.js":
217
+ /*!***************************************************************************************************************************************************************************************!*\
218
+ !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/create_indexs.js ***!
219
+ \***************************************************************************************************************************************************************************************/
220
+ /*! exports provided: default */
221
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
222
+
223
+ "use strict";
224
+ __webpack_require__.r(__webpack_exports__);
225
+ /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../utils/lp-modal-overlay */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/lp-modal-overlay.js");
226
+ /* harmony import */ var _utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/handle-ajax-api */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/handle-ajax-api.js");
227
+
228
+
229
+
230
+ var createIndexes = function createIndexes() {
231
+ var elCreateIndexTables = document.querySelector('#lp-tool-create-indexes-tables');
232
+
233
+ if (!elCreateIndexTables) {
234
+ return;
235
+ }
236
+
237
+ var elBtnCreateIndexes = elCreateIndexTables.querySelector('.lp-btn-create-indexes');
238
+ elBtnCreateIndexes.addEventListener('click', function (e) {
239
+ e.preventDefault();
240
+ var elLoading = elCreateIndexTables.querySelector('.wrapper-lp-loading');
241
+
242
+ if (!_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].init()) {
243
+ return;
244
+ }
245
+
246
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show();
247
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal(elLoading.innerHTML);
248
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(elCreateIndexTables.querySelector('h2').textContent);
249
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes[0].style.display = 'inline-block';
250
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes[0].textContent = 'Run';
251
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo[0].textContent = 'Close';
252
+ var url = '/lp/v1/tools/list-tables-indexs';
253
+ var params = {};
254
+ var functions = {
255
+ success: function success(res) {
256
+ var status = res.status,
257
+ message = res.message,
258
+ _res$data = res.data,
259
+ tables = _res$data.tables,
260
+ table = _res$data.table;
261
+ var elSteps = document.querySelector('.example-lp-group-step');
262
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal(elSteps.innerHTML);
263
+ var elGroupStep = _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay[0].querySelector('.lp-group-step '); // Show progress when upgrading.
264
+
265
+ var showProgress = function showProgress(stepCurrent, percent) {
266
+ var elItemStepCurrent = elGroupStep.querySelector('input[value=' + stepCurrent + ']').closest('.lp-item-step');
267
+ elItemStepCurrent.classList.add('running');
268
+
269
+ if (100 === percent) {
270
+ elItemStepCurrent.classList.remove('running');
271
+ elItemStepCurrent.classList.add('completed');
272
+ }
273
+
274
+ var progressBar = elItemStepCurrent.querySelector('.progress-bar');
275
+ progressBar.style.width = percent;
276
+ }; // Scroll to step current.
277
+
278
+
279
+ var scrollToStepCurrent = function scrollToStepCurrent(stepCurrent) {
280
+ var elItemStepCurrent = elGroupStep.querySelector('input[value=' + stepCurrent + ']').closest('.lp-item-step');
281
+ console.log(elItemStepCurrent.offsetTop, _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elMainContent[0].offsetTop);
282
+ var offset = elItemStepCurrent.offsetTop - _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elMainContent[0].offsetTop + _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elMainContent[0].scrollTop;
283
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elMainContent.stop().animate({
284
+ scrollTop: offset
285
+ }, 600);
286
+ };
287
+
288
+ for (var _table in tables) {
289
+ var elItemStep = _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay[0].querySelector('.lp-item-step').cloneNode(true);
290
+ var input = elItemStep.querySelector('input');
291
+ var label = elItemStep.querySelector('label');
292
+ label.textContent = "Table: ".concat(_table);
293
+ input.value = _table;
294
+ elGroupStep.append(elItemStep);
295
+ }
296
+
297
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = function () {
298
+ var url = '/lp/v1/tools/create-indexs';
299
+ var params = {
300
+ tables: tables,
301
+ table: table
302
+ };
303
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo[0].style.display = 'none';
304
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes[0].style.display = 'none';
305
+ showProgress(table, 0.1);
306
+ var functions = {
307
+ success: function success(res) {
308
+ var status = res.status,
309
+ message = res.message,
310
+ _res$data2 = res.data,
311
+ table = _res$data2.table,
312
+ percent = _res$data2.percent;
313
+ showProgress(params.table, percent);
314
+
315
+ if (undefined !== table) {
316
+ if (params.table !== table) {
317
+ showProgress(table, 0.1);
318
+ scrollToStepCurrent(table);
319
+ }
320
+
321
+ params.table = table;
322
+ }
323
+
324
+ if ('success' === status) {
325
+ Object(_utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__["default"])(url, params, functions);
326
+ } else if ('finished' === status) {
327
+ console.log('finished');
328
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo[0].style.display = 'inline-block';
329
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo[0].textContent = 'Finish';
330
+ } else {
331
+ console.log(message);
332
+ }
333
+ },
334
+ error: function error(err) {
335
+ console.log(err);
336
+ },
337
+ completed: function completed() {}
338
+ };
339
+ Object(_utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__["default"])(url, params, functions);
340
+ };
341
+ },
342
+ error: function error(err) {},
343
+ completed: function completed() {}
344
+ };
345
+ Object(_utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__["default"])(url, params, functions);
346
+ });
347
+ };
348
+
349
+ /* harmony default export */ __webpack_exports__["default"] = (createIndexes);
350
+
351
+ /***/ }),
352
+
353
+ /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/re-upgrade-db.js":
354
+ /*!***************************************************************************************************************************************************************************************!*\
355
+ !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/re-upgrade-db.js ***!
356
+ \***************************************************************************************************************************************************************************************/
357
+ /*! exports provided: default */
358
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
359
+
360
+ "use strict";
361
+ __webpack_require__.r(__webpack_exports__);
362
+ /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../../utils/lp-modal-overlay */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/lp-modal-overlay.js");
363
+ /* harmony import */ var _utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../../utils/handle-ajax-api */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/handle-ajax-api.js");
364
+
365
+
366
+
367
+ var reUpgradeDB = function reUpgradeDB() {
368
+ var elToolReUpgradeDB = document.querySelector('#lp-tool-re-upgrade-db');
369
+
370
+ if (!elToolReUpgradeDB) {
371
+ return;
372
+ } // Check valid to show popup re-upgrade
373
+
374
+
375
+ var url = 'lp/v1/database/check-db-valid-re-upgrade';
376
+ Object(_utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__["default"])(url, {}, {
377
+ success: function success(res) {
378
+ var can_re_upgrade = res.data.can_re_upgrade;
379
+
380
+ if (!can_re_upgrade) {
381
+ return;
382
+ }
383
+
384
+ elToolReUpgradeDB.style.display = 'block';
385
+ var elBtnReUpradeDB = elToolReUpgradeDB.querySelector('.lp-btn-re-upgrade-db');
386
+ var elMessage = elToolReUpgradeDB.querySelector('.learn-press-message');
387
+ elBtnReUpradeDB.addEventListener('click', function () {
388
+ // eslint-disable-next-line no-alert
389
+ if (confirm('Are want Re Upgrade!')) {
390
+ url = 'lp/v1/database/del-tb-lp-upgrade-db';
391
+ Object(_utils_handle_ajax_api__WEBPACK_IMPORTED_MODULE_1__["default"])(url, {}, {
392
+ success: function success(res) {
393
+ var status = res.status,
394
+ message = res.message,
395
+ url = res.data.url;
396
+
397
+ if ('success' === status && undefined !== url) {
398
+ window.location.href = url;
399
+ }
400
+ },
401
+ error: function error(err) {
402
+ elMessage.classList.add('error');
403
+ elMessage.textContent = err.message;
404
+ elMessage.style.display = 'block';
405
+ }
406
+ });
407
+ }
408
+ });
409
+ },
410
+ error: function error(err) {}
411
+ });
412
+ };
413
+
414
+ /* harmony default export */ __webpack_exports__["default"] = (reUpgradeDB);
415
+
416
+ /***/ }),
417
+
418
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/upgrade.js":
419
  /*!*********************************************************************************************************************************************************************************!*\
420
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/admin/pages/tools/database/upgrade.js ***!
563
  elItemStepCurrent.removeClass('running').addClass('error');
564
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal(elWrapperUpgradeMessage.html(), function () {
565
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes.text('Retry').show();
566
+
567
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = function () {
568
+ window.location.href = 'wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db';
569
+ };
570
+
571
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo.show();
572
 
573
  if (!res.message) {
582
  isUpgrading = 0;
583
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal(elWrapperUpgradeMessage.html(), function () {
584
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnYes.text('Retry').show();
585
+
586
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = function () {
587
+ window.location.location = 'wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db';
588
+ };
589
+
590
  _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elBtnNo.show();
591
 
592
  if (!err.message) {
754
  elFooter: null,
755
  elCalledModal: null,
756
  callBackYes: null,
757
+ instance: null,
758
  init: function init() {
759
+ if (this.instance) {
760
+ return true;
761
+ }
762
+
763
  this.elLPOverlay = $('.lp-overlay');
764
 
765
  if (!this.elLPOverlay.length) {
775
  $(document).on('click', '.close, .btn-no', function () {
776
  elLPOverlay.hide();
777
  });
778
+ $(document).on('click', '.btn-yes', function (e) {
779
+ e.preventDefault();
780
+ e.stopPropagation();
781
+
782
  if ('function' === typeof lpModalOverlay.callBackYes) {
783
  lpModalOverlay.callBackYes();
784
  }
785
  });
786
+ this.instance = this;
787
  return true;
788
  },
789
  setElCalledModal: function setElCalledModal(elCalledModal) {
assets/js/dist/admin/pages/tools.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(l,a,function(t){return e[t]}.bind(null,a));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=15)}({15:function(e,t,n){"use strict";n.r(t);var l,a,s,o,r,i,d,c,p=jQuery,u=null,f={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,init:function(){return this.elLPOverlay=p(".lp-overlay"),!!this.elLPOverlay.length&&(u=this.elLPOverlay,this.elMainContent=u.find(".main-content"),this.elTitle=u.find(".modal-title"),this.elBtnYes=u.find(".btn-yes"),this.elBtnNo=u.find(".btn-no"),this.elFooter=u.find(".lp-modal-footer"),p(document).on("click",".close, .btn-no",(function(){u.hide()})),p(document).on("click",".btn-yes",(function(){"function"==typeof f.callBackYes&&f.callBackYes()})),!0)},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},m=f,h=function(e,t,n){wp.apiFetch({path:e,method:"POST",data:t}).then((function(e){"function"==typeof n.success&&n.success(e)})).catch((function(e){"function"==typeof n.error&&n.error(e)})).then((function(){"function"==typeof n.completed&&n.completed()}))},v=jQuery,g=v("#lp-tool-upgrade-db"),b=function(){var e=0,t=g.find(".wrapper-terms-upgrade"),n=g.find(".wrapper-lp-status-upgrade"),l=g.find(".wrapper-lp-upgrade-message"),a=null;if(t.length){m.setContentModal(t.html());var s=m.elLPOverlay.find(".terms-upgrade"),o=s.find("input[name=lp-agree-term]"),r=s.find(".error"),i=v("input[name=message-when-upgrading]").val();a=function(){return r.hide(),r.removeClass("learn-press-message"),o.is(":checked")?(h("/lp/v1/database/agree_terms",{agree_terms:1},{}),m.elFooter.find(".learn-press-notice").remove(),m.elFooter.prepend('<span class="learn-press-notice">'+i+"</span>"),m.setContentModal(n.html()),!0):(r.show(),r.addClass("learn-press-message"),m.elMainContent.animate({scrollTop:r.offset().top}),!1)}}else m.setContentModal(n.html()),a=function(){return!0};m.setTitleModal(g.find("h2").html()),m.elBtnYes.text("Upgrade"),m.elBtnYes.show(),m.elBtnNo.text("close"),m.callBackYes=function(){if(a()){e=1,m.elBtnYes.hide(),m.elBtnNo.hide();var t=m.elLPOverlay.find(".lp-group-step"),n=g.find(".lp-item-step"),s=[];v.each(n,(function(e,t){var n=v(t);if(!n.hasClass("completed")){var l=n.find("input").val();s.push(l)}}));var o={steps:s,step:s[0]},r=null,i=function(e,n){(r=t.find("input[value="+e+"]").closest(".lp-item-step")).addClass("running"),100===n&&r.removeClass("running").addClass("completed"),r.find(".progress-bar").css("width",n+"%"),r.find(".percent").text(n+"%")};i(s[0],.1);var d={success:function(n){var a,s;i(o.step,n.percent),o.step!==n.name&&i(n.name,.1),a=o.step,s=(r=t.find("input[value="+a+"]").closest(".lp-item-step")).offset().top-m.elMainContent.offset().top+m.elMainContent.scrollTop(),m.elMainContent.stop().animate({scrollTop:s},600),"success"===n.status?(o.step=n.name,o.data=n.data,setTimeout((function(){h("/lp/v1/database/upgrade",o,d)}),800)):"finished"===n.status?(e=0,r.removeClass("running").addClass("completed"),setTimeout((function(){m.setContentModal(l.html())}),1e3),m.elFooter.find(".learn-press-notice").remove(),m.elBtnNo.show(),m.elBtnNo.on("click",(function(){window.location.reload()}))):(e=0,m.elFooter.find(".learn-press-notice").remove(),r.removeClass("running").addClass("error"),m.setContentModal(l.html(),(function(){m.elBtnYes.text("Retry").show(),m.elBtnNo.show(),n.message||(n.message="Upgrade not success! Please clear cache, restart sever then retry or contact to LP to help"),m.elMainContent.find(".learn-press-message").addClass("error").html(n.message)})))},error:function(t){e=0,m.setContentModal(l.html(),(function(){m.elBtnYes.text("Retry").show(),m.elBtnNo.show(),t.message||(t.message="Upgrade not success! Something wrong. Please clear cache, restart sever then retry or contact to LP to help"),m.elMainContent.find(".learn-press-message").addClass("error").html(t.message)}))},completed:function(){}};h("/lp/v1/database/upgrade",o,d)}},window.onbeforeunload=function(){if(e)return"LP is upgrading Database. Are you want to reload page?"},window.onclose=function(){if(e)return"LP is upgrading Database. Are you want to close page?"}},C=function(){if(g.length&&m.init()){var e=v(".wrapper-lp-status-upgrade"),t=window.location.search,n=new URLSearchParams(t).get("action");"upgrade-db"===n&&(m.elLPOverlay.show(),m.setTitleModal(g.find("h2").html()),m.setContentModal(v(".wrapper-lp-loading").html())),h("/lp/v1/database/get_steps",{},{success:function(t){var l=t.steps_completed,a=t.steps_default;if(void 0===l||void 0===a)return console.log("invalid steps_completed and steps_default"),!1;var s="";for(var o in a){var r=a[o],i=r.steps;for(var d in s='<div class="lp-group-step">',s+="<h3>"+r.label+"</h3>",i){var c=i[d],p="";void 0!==l[d]&&(p="completed"),s+='<div class="lp-item-step '+p+'">',s+='<div class="lp-item-step-left"><input type="hidden" name="lp_steps_upgrade_db[]" value="'+c.name+'" /></div>',s+='<div class="lp-item-step-right">',s+='<label for=""><strong></strong>'+c.label+"</label>",s+='<div class="description">'+c.description+"</div>",s+='<div class="percent"></div>',s+='<span class="progress-bar"></span>',s+="</div>",s+="</div>"}s+="</div>",e.append(s);var u=v(".lp-btn-upgrade-db");"upgrade-db"===n&&b(),u.on("click",(function(){m.elLPOverlay.show(),b()}))}},error:function(e){},completed:function(){}})}};l=jQuery,a=l(document),s=!1,o=function(e){e.preventDefault();var t=l(this);s||confirm(lpGlobalSettings.i18n.confirm_install_sample_data)&&(t.addClass("disabled").html(t.data("installing-text")),l(".lp-install-sample__response").remove(),s=!0,l.ajax({url:t.attr("href"),data:l(".lp-install-sample__options").serializeJSON(),success:function(e){t.removeClass("disabled").html(t.data("text")),s=!1,l(e).insertBefore(t.parent())},error:function(){t.removeClass("disabled").html(t.data("text")),s=!1,l(response).insertBefore(t.parent())}}))},r=function(e){e.preventDefault();var t=l(this);s||confirm(lpGlobalSettings.i18n.confirm_uninstall_sample_data)&&(t.addClass("disabled").html(t.data("uninstalling-text")),s=!0,l.ajax({url:t.attr("href"),success:function(e){t.removeClass("disabled").html(t.data("text")),s=!1,l(e).insertBefore(t.parent())},error:function(){t.removeClass("disabled").html(t.data("text")),s=!1,l(response).insertBefore(t.parent())}}))},i=function(e){e.preventDefault();var t=l(this);t.hasClass("disabled")||(t.addClass("disabled").html(t.data("cleaning-text")),l.ajax({url:t.attr("href"),data:{},success:function(e){t.removeClass("disabled").html(t.data("text"))},error:function(){t.removeClass("disabled").html(t.data("text"))}}))},d=function(){l.ajax({url:"admin.php?page=lp-toggle-hard-cache-option",data:{v:this.checked?"yes":"no"},success:function(e){},error:function(){}})},c=function(e){e.preventDefault(),l(".lp-install-sample__options").toggleClass("hide-if-js")},l((function(){C(),a.on("click",".lp-install-sample__install",o).on("click",".lp-install-sample__uninstall",r).on("click","#learn-press-clear-cache",i).on("click",'input[name="enable_hard_cache"]',d).on("click",".lp-install-sample__toggle-options",c)}))}});
1
+ !function(e){var t={};function n(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(l,a,function(t){return e[t]}.bind(null,a));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=14)}({14:function(e,t,n){"use strict";n.r(t);var l,a,s,o,r,i,c,d,p=jQuery,u=null,f={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=p(".lp-overlay"),!!this.elLPOverlay.length&&(u=this.elLPOverlay,this.elMainContent=u.find(".main-content"),this.elTitle=u.find(".modal-title"),this.elBtnYes=u.find(".btn-yes"),this.elBtnNo=u.find(".btn-no"),this.elFooter=u.find(".lp-modal-footer"),p(document).on("click",".close, .btn-no",(function(){u.hide()})),p(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof f.callBackYes&&f.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},m=f,v=function(e,t,n){wp.apiFetch({path:e,method:"POST",data:t}).then((function(e){"function"==typeof n.success&&n.success(e)})).catch((function(e){"function"==typeof n.error&&n.error(e)})).then((function(){"function"==typeof n.completed&&n.completed()}))},h=jQuery,g=h("#lp-tool-upgrade-db"),b=function(){var e=0,t=g.find(".wrapper-terms-upgrade"),n=g.find(".wrapper-lp-status-upgrade"),l=g.find(".wrapper-lp-upgrade-message"),a=null;if(t.length){m.setContentModal(t.html());var s=m.elLPOverlay.find(".terms-upgrade"),o=s.find("input[name=lp-agree-term]"),r=s.find(".error"),i=h("input[name=message-when-upgrading]").val();a=function(){return r.hide(),r.removeClass("learn-press-message"),o.is(":checked")?(v("/lp/v1/database/agree_terms",{agree_terms:1},{}),m.elFooter.find(".learn-press-notice").remove(),m.elFooter.prepend('<span class="learn-press-notice">'+i+"</span>"),m.setContentModal(n.html()),!0):(r.show(),r.addClass("learn-press-message"),m.elMainContent.animate({scrollTop:r.offset().top}),!1)}}else m.setContentModal(n.html()),a=function(){return!0};m.setTitleModal(g.find("h2").html()),m.elBtnYes.text("Upgrade"),m.elBtnYes.show(),m.elBtnNo.text("close"),m.callBackYes=function(){if(a()){e=1,m.elBtnYes.hide(),m.elBtnNo.hide();var t=m.elLPOverlay.find(".lp-group-step"),n=g.find(".lp-item-step"),s=[];h.each(n,(function(e,t){var n=h(t);if(!n.hasClass("completed")){var l=n.find("input").val();s.push(l)}}));var o={steps:s,step:s[0]},r=null,i=function(e,n){(r=t.find("input[value="+e+"]").closest(".lp-item-step")).addClass("running"),100===n&&r.removeClass("running").addClass("completed"),r.find(".progress-bar").css("width",n+"%"),r.find(".percent").text(n+"%")};i(s[0],.1);var c={success:function(n){var a,s;i(o.step,n.percent),o.step!==n.name&&i(n.name,.1),a=o.step,s=(r=t.find("input[value="+a+"]").closest(".lp-item-step")).offset().top-m.elMainContent.offset().top+m.elMainContent.scrollTop(),m.elMainContent.stop().animate({scrollTop:s},600),"success"===n.status?(o.step=n.name,o.data=n.data,setTimeout((function(){v("/lp/v1/database/upgrade",o,c)}),800)):"finished"===n.status?(e=0,r.removeClass("running").addClass("completed"),setTimeout((function(){m.setContentModal(l.html())}),1e3),m.elFooter.find(".learn-press-notice").remove(),m.elBtnNo.show(),m.elBtnNo.on("click",(function(){window.location.reload()}))):(e=0,m.elFooter.find(".learn-press-notice").remove(),r.removeClass("running").addClass("error"),m.setContentModal(l.html(),(function(){m.elBtnYes.text("Retry").show(),m.callBackYes=function(){window.location.href="wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db"},m.elBtnNo.show(),n.message||(n.message="Upgrade not success! Please clear cache, restart sever then retry or contact to LP to help"),m.elMainContent.find(".learn-press-message").addClass("error").html(n.message)})))},error:function(t){e=0,m.setContentModal(l.html(),(function(){m.elBtnYes.text("Retry").show(),m.callBackYes=function(){window.location.location="wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db"},m.elBtnNo.show(),t.message||(t.message="Upgrade not success! Something wrong. Please clear cache, restart sever then retry or contact to LP to help"),m.elMainContent.find(".learn-press-message").addClass("error").html(t.message)}))},completed:function(){}};v("/lp/v1/database/upgrade",o,c)}},window.onbeforeunload=function(){if(e)return"LP is upgrading Database. Are you want to reload page?"},window.onclose=function(){if(e)return"LP is upgrading Database. Are you want to close page?"}},y=function(){if(g.length&&m.init()){var e=h(".wrapper-lp-status-upgrade"),t=window.location.search,n=new URLSearchParams(t).get("action");"upgrade-db"===n&&(m.elLPOverlay.show(),m.setTitleModal(g.find("h2").html()),m.setContentModal(h(".wrapper-lp-loading").html())),v("/lp/v1/database/get_steps",{},{success:function(t){var l=t.steps_completed,a=t.steps_default;if(void 0===l||void 0===a)return console.log("invalid steps_completed and steps_default"),!1;var s="";for(var o in a){var r=a[o],i=r.steps;for(var c in s='<div class="lp-group-step">',s+="<h3>"+r.label+"</h3>",i){var d=i[c],p="";void 0!==l[c]&&(p="completed"),s+='<div class="lp-item-step '+p+'">',s+='<div class="lp-item-step-left"><input type="hidden" name="lp_steps_upgrade_db[]" value="'+d.name+'" /></div>',s+='<div class="lp-item-step-right">',s+='<label for=""><strong></strong>'+d.label+"</label>",s+='<div class="description">'+d.description+"</div>",s+='<div class="percent"></div>',s+='<span class="progress-bar"></span>',s+="</div>",s+="</div>"}s+="</div>",e.append(s);var u=h(".lp-btn-upgrade-db");"upgrade-db"===n&&b(),u.on("click",(function(){m.elLPOverlay.show(),b()}))}},error:function(e){},completed:function(){}})}},C=function(){var e=document.querySelector("#lp-tool-create-indexes-tables");e&&e.querySelector(".lp-btn-create-indexes").addEventListener("click",(function(t){t.preventDefault();var n=e.querySelector(".wrapper-lp-loading");if(m.init()){m.elLPOverlay.show(),m.setContentModal(n.innerHTML),m.setTitleModal(e.querySelector("h2").textContent),m.elBtnYes[0].style.display="inline-block",m.elBtnYes[0].textContent="Run",m.elBtnNo[0].textContent="Close";var l={success:function(e){e.status,e.message;var t=e.data,n=t.tables,l=t.table,a=document.querySelector(".example-lp-group-step");m.setContentModal(a.innerHTML);var s=m.elLPOverlay[0].querySelector(".lp-group-step "),o=function(e,t){var n=s.querySelector("input[value="+e+"]").closest(".lp-item-step");n.classList.add("running"),100===t&&(n.classList.remove("running"),n.classList.add("completed")),n.querySelector(".progress-bar").style.width=t};for(var r in n){var i=m.elLPOverlay[0].querySelector(".lp-item-step").cloneNode(!0),c=i.querySelector("input");i.querySelector("label").textContent="Table: ".concat(r),c.value=r,s.append(i)}m.callBackYes=function(){var e="/lp/v1/tools/create-indexs",t={tables:n,table:l};m.elBtnNo[0].style.display="none",m.elBtnYes[0].style.display="none",o(l,.1);var a={success:function(n){var l=n.status,r=n.message,i=n.data,c=i.table,d=i.percent;o(t.table,d),void 0!==c&&(t.table!==c&&(o(c,.1),function(e){var t=s.querySelector("input[value="+e+"]").closest(".lp-item-step");console.log(t.offsetTop,m.elMainContent[0].offsetTop);var n=t.offsetTop-m.elMainContent[0].offsetTop+m.elMainContent[0].scrollTop;m.elMainContent.stop().animate({scrollTop:n},600)}(c)),t.table=c),"success"===l?v(e,t,a):"finished"===l?(console.log("finished"),m.elBtnNo[0].style.display="inline-block",m.elBtnNo[0].textContent="Finish"):console.log(r)},error:function(e){console.log(e)},completed:function(){}};v(e,t,a)}},error:function(e){},completed:function(){}};v("/lp/v1/tools/list-tables-indexs",{},l)}}))},w=function(){var e=document.querySelector("#lp-tool-re-upgrade-db");if(e){var t="lp/v1/database/check-db-valid-re-upgrade";v(t,{},{success:function(n){if(n.data.can_re_upgrade){e.style.display="block";var l=e.querySelector(".lp-btn-re-upgrade-db"),a=e.querySelector(".learn-press-message");l.addEventListener("click",(function(){confirm("Are want Re Upgrade!")&&v(t="lp/v1/database/del-tb-lp-upgrade-db",{},{success:function(e){var t=e.status,n=(e.message,e.data.url);"success"===t&&void 0!==n&&(window.location.href=n)},error:function(e){a.classList.add("error"),a.textContent=e.message,a.style.display="block"}})}))}},error:function(e){}})}};l=jQuery,a=l(document),s=!1,o=function(e){e.preventDefault();var t=l(this);s||confirm(lpGlobalSettings.i18n.confirm_install_sample_data)&&(t.addClass("disabled").html(t.data("installing-text")),l(".lp-install-sample__response").remove(),s=!0,l.ajax({url:t.attr("href"),data:l(".lp-install-sample__options").serializeJSON(),success:function(e){t.removeClass("disabled").html(t.data("text")),s=!1,l(e).insertBefore(t.parent())},error:function(){t.removeClass("disabled").html(t.data("text")),s=!1,l(response).insertBefore(t.parent())}}))},r=function(e){e.preventDefault();var t=l(this);s||confirm(lpGlobalSettings.i18n.confirm_uninstall_sample_data)&&(t.addClass("disabled").html(t.data("uninstalling-text")),s=!0,l.ajax({url:t.attr("href"),success:function(e){t.removeClass("disabled").html(t.data("text")),s=!1,l(e).insertBefore(t.parent())},error:function(){t.removeClass("disabled").html(t.data("text")),s=!1,l(response).insertBefore(t.parent())}}))},i=function(e){e.preventDefault();var t=l(this);t.hasClass("disabled")||(t.addClass("disabled").html(t.data("cleaning-text")),l.ajax({url:t.attr("href"),data:{},success:function(e){t.removeClass("disabled").html(t.data("text"))},error:function(){t.removeClass("disabled").html(t.data("text"))}}))},c=function(){l.ajax({url:"admin.php?page=lp-toggle-hard-cache-option",data:{v:this.checked?"yes":"no"},success:function(e){},error:function(){}})},d=function(e){e.preventDefault(),l(".lp-install-sample__options").toggleClass("hide-if-js")},l((function(){y(),C(),w(),a.on("click",".lp-install-sample__install",o).on("click",".lp-install-sample__uninstall",r).on("click","#learn-press-clear-cache",i).on("click",'input[name="enable_hard_cache"]',c).on("click",".lp-install-sample__toggle-options",d)}))}});
assets/js/dist/frontend/config.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.config=function(t){var n={};function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(n){return t[n]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=16)}({16:function(t,n,e){"use strict";e.r(n),e.d(n,"classNames",(function(){return r})),e.d(n,"isQuestionCorrect",(function(){return i})),e.d(n,"questionBlocks",(function(){return s})),e.d(n,"questionFooterButtons",(function(){return c})),e.d(n,"questionTitleParts",(function(){return l})),e.d(n,"questionChecker",(function(){return f})),e.d(n,"quizStartBlocks",(function(){return a}));var o=LP.Hook,r={Quiz:{Result:["quiz-result"],Content:["quiz-content"],Questions:["quiz-questions"],Buttons:["quiz-buttons"],Attempts:["quiz-attempts"]}},u={single_choice:function(){},multi_choice:function(){},true_or_false:function(){}},i={fill_in_blank:function(){return!0}},s=function(){return LP.Hook.applyFilters("question-blocks",["title","content","answer-options","explanation","hint","buttons"])},c=function(){return LP.Hook.applyFilters("question-footer-buttons",["instant-check"])},l=function(){return LP.Hook.applyFilters("question-title-parts",["index","title","hint","edit-permalink"])},f=function(t){var n=LP.Hook.applyFilters("question-checkers",u);return t&&n[t]?n[t]:function(){return{}}},a=function(){o.applyFilters("quiz-start-blocks",{meta:!0,description:!0,custom:"Hello"})}}});
1
+ this.LP=this.LP||{},this.LP.config=function(t){var n={};function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(n){return t[n]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=17)}({17:function(t,n,e){"use strict";e.r(n),e.d(n,"classNames",(function(){return r})),e.d(n,"isQuestionCorrect",(function(){return i})),e.d(n,"questionBlocks",(function(){return s})),e.d(n,"questionFooterButtons",(function(){return c})),e.d(n,"questionTitleParts",(function(){return l})),e.d(n,"questionChecker",(function(){return f})),e.d(n,"quizStartBlocks",(function(){return a}));var o=LP.Hook,r={Quiz:{Result:["quiz-result"],Content:["quiz-content"],Questions:["quiz-questions"],Buttons:["quiz-buttons"],Attempts:["quiz-attempts"]}},u={single_choice:function(){},multi_choice:function(){},true_or_false:function(){}},i={fill_in_blank:function(){return!0}},s=function(){return LP.Hook.applyFilters("question-blocks",["title","content","answer-options","explanation","hint","buttons"])},c=function(){return LP.Hook.applyFilters("question-footer-buttons",["instant-check"])},l=function(){return LP.Hook.applyFilters("question-title-parts",["index","title","hint","edit-permalink"])},f=function(t){var n=LP.Hook.applyFilters("question-checkers",u);return t&&n[t]?n[t]:function(){return{}}},a=function(){o.applyFilters("quiz-start-blocks",{meta:!0,description:!0,custom:"Hello"})}}});
assets/js/dist/frontend/custom.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.custom=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=17)}({17:function(t,e){var n=LP.Hook,r=window.jQuery||jQuery;n.addFilter("question-blocks",(function(t){return t})),n.addAction("before-start-quiz",(function(){})),n.addAction("quiz-started",(function(t,e){r(".course-item-".concat(e)).removeClass("status-completed failed passed").addClass("has-status status-started"),window.onbeforeunload=function(){return"Warning!"}})),n.addAction("quiz-submitted",(function(t,e){r(".course-item-".concat(e)).removeClass("status-started passed failed").addClass("has-status status-completed ".concat(t.results.graduation)),window.onbeforeunload=null}))}});
1
+ this.LP=this.LP||{},this.LP.custom=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=18)}({18:function(t,e){var n=LP.Hook,r=window.jQuery||jQuery;n.addFilter("question-blocks",(function(t){return t})),n.addAction("before-start-quiz",(function(){})),n.addAction("quiz-started",(function(t,e){r(".course-item-".concat(e)).removeClass("status-completed failed passed").addClass("has-status status-started"),window.onbeforeunload=function(){return"Warning!"}})),n.addAction("quiz-submitted",(function(t,e){r(".course-item-".concat(e)).removeClass("status-started passed failed").addClass("has-status status-completed ".concat(t.results.graduation)),window.onbeforeunload=null}))}});
assets/js/dist/frontend/lesson.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.lesson=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=15)}({15:function(e,t){}});
1
+ this.LP=this.LP||{},this.LP.lesson=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}({16:function(e,t){}});
assets/js/dist/frontend/modal.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.modal=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}({0:function(e,t){e.exports=window.wp.i18n},1:function(e,t){e.exports=window.wp.data},20:function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"show",(function(){return f})),n.d(r,"hide",(function(){return p})),n.d(r,"confirm",(function(){return d}));var o={};n.r(o),n.d(o,"isOpen",(function(){return b})),n.d(o,"getMessage",(function(){return O})),n.d(o,"confirm",(function(){return m}));var c=n(1);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l={},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SHOW_MODAL":return u(u({},e),{},{isOpen:!0,message:t.message,cb:t.cb});case"HIDE_MODAL":return u(u({},e),{},{isOpen:!1,message:!1,cb:null});case"CONFIRM":return e.cb&&setTimeout((function(){e.cb()}),10),u(u({},e),{},{confirm:t.value})}return e};function f(e,t){return{type:"SHOW_MODAL",message:e,cb:t}}function p(){return{type:"HIDE_MODAL"}}function d(e){return{type:"CONFIRM",value:e}}function b(e){return e.isOpen}function O(e){return e.message}function m(e,t,n){var r=Object(c.dispatch)("learnpress/modal"),o=r.show,i=r.hide;return e.message?(i(),e.confirm):(o(t,n),"no")}var y=n(4),v=n.n(y),g={ENROLL_COURSE_X:function(e,t){}};var j=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=v()(g)(n)(e.dispatch),e.dispatch=t,e};function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P=LP.dataControls.controls,E=Object(c.registerStore)("learnpress/modal",{reducer:s,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){w(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},P)});j(E);var S=n(0),_=function(e){var t=e.children,n=Object(c.dispatch)("learnpress/modal"),r=(n.show,n.hide,n.confirm),o=Object(c.useSelect)((function(e){return e("learnpress/modal").isOpen()})),i=Object(c.useSelect)((function(e){return e("learnpress/modal").getMessage()})),u=function(e){return function(t){r(e)}},a={display:o?"block":"none"};return React.createElement(React.Fragment,null,React.createElement("div",null,React.createElement("div",{id:"lp-modal-overlay",style:a}),React.createElement("div",{id:"lp-modal-window",style:a},React.createElement("div",{id:"lp-modal-content",dangerouslySetInnerHTML:{__html:i}}),React.createElement("div",{id:"lp-modal-buttons"},React.createElement("button",{className:"lp-button modal-button-ok",onClick:u("yes")},React.createElement("span",null,Object(S._x)("OK","button confirm ok","learnpress"))),React.createElement("button",{className:"lp-button modal-button-cancel",onClick:u("no")},React.createElement("span",null,Object(S._x)("Cancel","button confirm cancel","learnpress")))))),t)};t.default=_},4:function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,c,i=n[r.type],u=t(r);if(i)for(o=0;o<i.length;o++)(c=i[o](r,e))&&e.dispatch(c);return u}}}).effects=n,t}}});
1
+ this.LP=this.LP||{},this.LP.modal=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=21)}({0:function(e,t){e.exports=window.wp.i18n},1:function(e,t){e.exports=window.wp.data},21:function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"show",(function(){return f})),n.d(r,"hide",(function(){return p})),n.d(r,"confirm",(function(){return d}));var o={};n.r(o),n.d(o,"isOpen",(function(){return b})),n.d(o,"getMessage",(function(){return O})),n.d(o,"confirm",(function(){return m}));var c=n(1);function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l={},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SHOW_MODAL":return u(u({},e),{},{isOpen:!0,message:t.message,cb:t.cb});case"HIDE_MODAL":return u(u({},e),{},{isOpen:!1,message:!1,cb:null});case"CONFIRM":return e.cb&&setTimeout((function(){e.cb()}),10),u(u({},e),{},{confirm:t.value})}return e};function f(e,t){return{type:"SHOW_MODAL",message:e,cb:t}}function p(){return{type:"HIDE_MODAL"}}function d(e){return{type:"CONFIRM",value:e}}function b(e){return e.isOpen}function O(e){return e.message}function m(e,t,n){var r=Object(c.dispatch)("learnpress/modal"),o=r.show,i=r.hide;return e.message?(i(),e.confirm):(o(t,n),"no")}var y=n(6),v=n.n(y),g={ENROLL_COURSE_X:function(e,t){}};var j=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=v()(g)(n)(e.dispatch),e.dispatch=t,e};function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var P=LP.dataControls.controls,E=Object(c.registerStore)("learnpress/modal",{reducer:s,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){w(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},P)});j(E);var S=n(0),_=function(e){var t=e.children,n=Object(c.dispatch)("learnpress/modal"),r=(n.show,n.hide,n.confirm),o=Object(c.useSelect)((function(e){return e("learnpress/modal").isOpen()})),i=Object(c.useSelect)((function(e){return e("learnpress/modal").getMessage()})),u=function(e){return function(t){r(e)}},a={display:o?"block":"none"};return React.createElement(React.Fragment,null,React.createElement("div",null,React.createElement("div",{id:"lp-modal-overlay",style:a}),React.createElement("div",{id:"lp-modal-window",style:a},React.createElement("div",{id:"lp-modal-content",dangerouslySetInnerHTML:{__html:i}}),React.createElement("div",{id:"lp-modal-buttons"},React.createElement("button",{className:"lp-button modal-button-ok",onClick:u("yes")},React.createElement("span",null,Object(S._x)("OK","button confirm ok","learnpress"))),React.createElement("button",{className:"lp-button modal-button-cancel",onClick:u("no")},React.createElement("span",null,Object(S._x)("Cancel","button confirm cancel","learnpress")))))),t)};t.default=_},6:function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,c,i=n[r.type],u=t(r);if(i)for(o=0;o<i.length;o++)(c=i[o](r,e))&&e.dispatch(c);return u}}}).effects=n,t}}});
assets/js/dist/frontend/question-types.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.questionTypes=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}({0:function(e,t){e.exports=window.wp.i18n},1:function(e,t){e.exports=window.wp.data},19:function(e,t,n){"use strict";n.r(t),n.d(t,"QuestionBase",(function(){return v})),n.d(t,"SingleChoice",(function(){return E})),n.d(t,"MultipleChoices",(function(){return U})),n.d(t,"TrueOrFalse",(function(){return Y})),n.d(t,"FillInBlanks",(function(){return le})),n.d(t,"SortingChoice",(function(){return je}));var r=n(2),o=n(3),i=n(1),c=n(0);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return p(this,n)}}function p(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?y(e):t}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=lodash,d=h.isArray,v=(h.get,h.set,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(u,e);var t,n,r,o=f(u);function u(e){var t;a(this,u),m(y(t=o.apply(this,arguments)),"prepare",(function(e,t){var n=e.question;return n&&n.id!==t.questionId?{options:t.self.parseOptions(n.options)}:null})),m(y(t),"setInputRef",(function(e,n){t.inputs||(t.inputs={}),t.inputs[n]=e})),m(y(t),"maybeShowCorrectAnswer",(function(){var e=t.props,n=e.status,r=e.isCheckedAnswer,o=e.showCorrectReview,i=e.isReviewing;return"completed"===n&&o||r&&!i})),m(y(t),"maybeDisabledOption",(function(e){var n=t.props,r=(n.answered,n.status);return n.isCheckedAnswer||"started"!==r})),m(y(t),"setAnswerChecked",(function(){return function(e){var n=t.props,r=n.updateUserQuestionAnswers,o=n.question;if("started"!==n.status)return"LP Error: can not set answers";var i=t.$wrap.find(".option-check"),c=[],u="multi_choice"!==o.type;i.each((function(e,t){if(t.checked&&(c.push(t.value),u))return!1})),r(o.id,u?c[0]:c)}})),m(y(t),"maybeCheckedAnswer",(function(e){var n=t.props.answered;return d(n)?!!n.find((function(t){return t==e})):e==n})),m(y(t),"getOptionType",(function(e,t){var n="radio";switch(e){case"multi_choice":n="checkbox"}return n})),m(y(t),"isDefaultType",(function(){return t.props.supportOptions})),m(y(t),"getWarningMessage",(function(){return React.createElement(React.Fragment,null,Object(c.__)("Render function should be overwritten from base.","learnpress"))})),m(y(t),"getOptionClass",(function(e){t.props.answered;return["answer-option"]})),m(y(t),"parseOptions",(function(e){return e&&(e=d(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=d(e)?e:JSON.parse(e)),e||[]})),m(y(t),"getOptions",(function(){return t.state.options||[]})),m(y(t),"isCorrect",(function(){var e,n,r,o=t.props.answered;if(!o)return!1;for(e=0,r=t.getOptions();e<r.length;e++)if("yes"===(n=r[e]).isTrue&&o==n.value)return!0;return!1})),m(y(t),"isChecked",(function(){var e=t.props.question;return Object(i.select)("learnpress/quiz").isCheckedAnswer(e.id)})),m(y(t),"getCorrectLabel",(function(){var e=t.props,n=(e.status,e.answered,e.question),r=(LP.config.isQuestionCorrect[n.type]||t.isCorrect).call(y(t));return t.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response"+(r?" correct":" incorrect")},React.createElement("span",{className:"label"},r?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),r?n.point:0,n.point)))}));var n=e.question;return t.state={optionClass:["answer-option"],questionId:0,options:n?t.parseOptions(n.options):[],self:y(t)},e.$wrap&&(t.$wrap=e.$wrap),t}return t=u,r=[{key:"getDerivedStateFromProps",value:function(e,t){return t.self.prepare(e,t)}}],(n=[{key:"componentDidMount",value:function(){var e=this.prepare(this.props,this.state);e&&this.setState(e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.status;return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(n.id),className:"answer-options"},this.getOptions().map((function(t){var o="learn-press-answer-option-".concat(t.uid);return React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.uid)},React.createElement("input",{type:e.getOptionType(n.type,t),className:"option-check",name:"started"===r?"learn-press-question-".concat(n.id):"",id:o,ref:function(n){e.setInputRef(n,t.value)},onChange:e.setAnswerChecked(),disabled:e.maybeDisabledOption(t),checked:e.maybeCheckedAnswer(t.value),value:"started"===r?t.value:""}),React.createElement("label",{htmlFor:o,className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}}))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&s(t.prototype,n),r&&s(t,r),u}(r.Component));function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A(e);if(t){var o=A(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return R(this,n)}}function R(e,t){return!t||"object"!==w(t)&&"function"!=typeof t?P(e):t}function P(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var E=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(n,e);var t=_(n);function n(){var e;j(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return C(P(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var n=e.props.answered,r=O(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&r.push("answer-correct"),n&&("yes"===t.isTrue?n===t.value&&r.push("answered-correct"):n===t.value&&r.push("answered-wrong"))),r})),e}return n}(v);function T(e){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return q(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=B(e);if(t){var o=B(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return L(this,n)}}function L(e,t){return!t||"object"!==T(t)&&"function"!=typeof t?M(e):t}function M(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=lodash.isBoolean,U=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&I(e,t)}(n,e);var t=N(n);function n(){var e;x(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return D(M(e=t.call.apply(t,[this].concat(o))),"isCorrect",(function(){var t,n,r,o=e.props.answered;if(F(o)||!o)return!1;for(t=0,r=e.getOptions();t<r.length;t++)if("yes"===(n=r[t]).isTrue){if(-1===o.indexOf(n.value))return!1}else if(-1!==o.indexOf(n.value))return!1;return!0})),D(M(e),"getOptionClass",(function(t){var n=e.props.answered,r=k(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&r.push("answer-correct"),n&&("yes"===t.isTrue?-1!==n.indexOf(t.value)&&r.push("answered-correct"):-1!==n.indexOf(t.value)&&r.push("answered-wrong"))),r})),e}return n}(v);function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Q(e){return function(e){if(Array.isArray(e))return $(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=K(e);if(t){var o=K(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return V(this,n)}}function V(e,t){return!t||"object"!==H(t)&&"function"!=typeof t?G(e):t}function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&J(e,t)}(n,e);var t=W(n);function n(){var e;z(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return X(G(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var n=e.props.answered,r=Q(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&r.push("answer-correct"),n&&("yes"===t.isTrue?n===t.value&&r.push("answered-correct"):n===t.value&&r.push("answered-wrong"))),r})),e}return n}(v);function Z(e){return(Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e){return function(e){if(Array.isArray(e))return te(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return te(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return te(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ae(e);if(t){var o=ae(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ce(this,n)}}function ce(e,t){return!t||"object"!==Z(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ae(e){return(ae=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(i,e);var t,n,r,o=ie(i);function i(){var e;ne(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return se(ue(e=o.call.apply(o,[this].concat(n))),"updateFibAnswer",(function(){var t=document.querySelectorAll(".lp-fib-input > input"),n={};ee(t).map((function(t){t.addEventListener("input",(function(r){e.setAnswered(n,t.dataset.id,r.target.value)})),t.addEventListener("paste",(function(r){e.setAnswered(n,t.dataset.id,r.target.value)}))}))})),se(ue(e),"setAnswered",(function(t,n,r){var o=e.props,i=o.updateUserQuestionAnswers,c=o.question;if("started"!==o.status)return"LP Error: can not set answers";var u=Object.assign(t,se({},n,r));i(c.id,u)})),se(ue(e),"getCorrectLabel",(function(){var t=e.props,n=t.question,r=t.mark,o=r||0;return r&&(Number.isInteger(r)||(o=r.toFixed(2))),e.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response correct"},React.createElement("span",{className:"label"},Object(c.__)("Points","learnpress")),React.createElement("span",{className:"point"},"".concat(o,"/").concat(n.point," ").concat(Object(c.__)("point","learnpress"))),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#00adff"}}),Object(c.__)("Correct","learnpress")),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#d85554"}}),Object(c.__)("Incorrect","learnpress")))})),e}return t=i,(n=[{key:"componentDidMount",value:function(){this.updateFibAnswer()}},{key:"componentDidUpdate",value:function(e){e.answered||this.updateFibAnswer()}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{className:"lp-fib-content"},this.getOptions().map((function(e){return React.createElement("div",{key:"blank-".concat(e.uid),dangerouslySetInnerHTML:{__html:e.title||e.value}})}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&re(t.prototype,n),r&&re(t,r),i}(v);function fe(e){return(fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pe(e){return function(e){if(Array.isArray(e))return ye(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ye(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ye(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function me(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Oe(e);if(t){var o=Oe(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ve(this,n)}}function ve(e,t){return!t||"object"!==fe(t)&&"function"!=typeof t?we(e):t}function we(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Oe(e){return(Oe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ge(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&he(e,t)}(i,e);var t,n,r,o=de(i);function i(){var e;be(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ge(we(e=o.call.apply(o,[this].concat(n))),"isCorrect",(function(){var t,n,r,o=e.props.answered;if(!o)return!1;for(t=0,r=e.getOptions();t<r.length;t++)if(o[(n=r[t]).sorting]!==n.value)return!1;return!0})),ge(we(e),"getCorrectLabel",(function(){var t=e.props.question,n=e.isCorrect.call(we(e));return e.maybeShowCorrectAnswer()&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-response"+(n?" correct":" incorrect")},React.createElement("span",{className:"label"},n?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),n?t.point:0,t.point))))})),ge(we(e),"getAnswerSortingChoice",(function(){var t=e.props.question.options||[],n=e.isCorrect.call(we(e)),r=[];return!n&&t.length>0&&t.map((function(e){var t=e.sorting;if(void 0!==t)return r[t]=e.title})),r})),e}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.updateUserQuestionAnswers,n=e.question,r=document.querySelector("#answer-options-".concat(n.id));return jQuery(r).sortable({items:".answer-option",cursor:"move",axis:"y",handle:".option-drag",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,update:function(e,o){var i=r.querySelectorAll(".answer-option"),c=[];pe(i).map((function(e){return c.push(e.dataset.value)})),c.length>0&&t(n.id,c)}})}},{key:"render",value:function(){var e=this,t=this.props.question,n=this.getAnswerSortingChoice();return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(t.id),className:"answer-options lp-sorting-choice-ul"},this.getOptions().map((function(t,r){return React.createElement(React.Fragment,null,React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.value),"data-value":t.value},React.createElement("span",{className:"option-drag",style:{display:"flex",alignItems:"center",position:"absolute",height:"100%",left:14}},React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24"},React.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),React.createElement("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"}))),React.createElement("label",{htmlFor:"learn-press-answer-option-".concat(t.value),className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}})),n.length>0&&void 0!==n[r]&&React.createElement("div",{className:"lp-sorting-choice__check-answer",key:"lp-checked-answer-".concat(r),style:{marginBottom:10}},n[r]))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&me(t.prototype,n),r&&me(t,r),i}(v);function Se(e){return(Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ae(e,t){return(Ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ce(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ke(e);if(t){var o=ke(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Ee(this,n)}}function Ee(e,t){return!t||"object"!==Se(t)&&"function"!=typeof t?Te(e):t}function Te(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ke(e){return(ke=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function qe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var xe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ae(e,t)}(i,e);var t,n,r,o=Ce(i);function i(){var e;Re(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return qe(Te(e=o.call.apply(o,[this].concat(n))),"getQuestion",(function(){var t=e.props.question;return LP.Hook.applyFilters("question-types",{single_choice:LP.questionTypes.SingleChoice,multi_choice:LP.questionTypes.MultipleChoices,true_or_false:LP.questionTypes.TrueOrFalse,fill_in_blanks:LP.questionTypes.FillInBlanks,sorting_choice:LP.questionTypes.SortingChoice})[t.type]})),e}return t=i,(n=[{key:"render",value:function(){var e=this.props,t=e.question,n=e.supportOptions,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_e(Object(n),!0).forEach((function(t){qe(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},this.props);r.supportOptions=-1!==n.indexOf(t.type);var o=this.getQuestion()||function(){return React.createElement("div",{className:"question-types",dangerouslySetInnerHTML:{__html:Object(c.sprintf)(Object(c.__)("Question <code>%s</code> invalid!","learnpress"),t.type)}})};return React.createElement(React.Fragment,null,React.createElement(o,r))}}])&&Pe(t.prototype,n),r&&Pe(t,r),i}(r.Component),Ie=Object(o.compose)(Object(i.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.isCheckedAnswer;return{supportOptions:o("supportOptions"),isCheckedAnswer:i(n),keyPressed:o("keyPressed"),showCorrectReview:o("showCorrectReview"),isReviewing:"reviewing"===o("mode")}})),Object(i.withDispatch)((function(){return{}})))(xe);t.default=Ie},2:function(e,t){e.exports=window.wp.element},3:function(e,t){e.exports=window.wp.compose}});
1
+ this.LP=this.LP||{},this.LP.questionTypes=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}({0:function(e,t){e.exports=window.wp.i18n},1:function(e,t){e.exports=window.wp.data},2:function(e,t){e.exports=window.wp.element},20:function(e,t,n){"use strict";n.r(t),n.d(t,"QuestionBase",(function(){return v})),n.d(t,"SingleChoice",(function(){return E})),n.d(t,"MultipleChoices",(function(){return U})),n.d(t,"TrueOrFalse",(function(){return Y})),n.d(t,"FillInBlanks",(function(){return le})),n.d(t,"SortingChoice",(function(){return je}));var r=n(2),o=n(3),i=n(1),c=n(0);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=b(e);if(t){var o=b(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return p(this,n)}}function p(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?y(e):t}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=lodash,d=h.isArray,v=(h.get,h.set,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(u,e);var t,n,r,o=f(u);function u(e){var t;a(this,u),m(y(t=o.apply(this,arguments)),"prepare",(function(e,t){var n=e.question;return n&&n.id!==t.questionId?{options:t.self.parseOptions(n.options)}:null})),m(y(t),"setInputRef",(function(e,n){t.inputs||(t.inputs={}),t.inputs[n]=e})),m(y(t),"maybeShowCorrectAnswer",(function(){var e=t.props,n=e.status,r=e.isCheckedAnswer,o=e.showCorrectReview,i=e.isReviewing;return"completed"===n&&o||r&&!i})),m(y(t),"maybeDisabledOption",(function(e){var n=t.props,r=(n.answered,n.status);return n.isCheckedAnswer||"started"!==r})),m(y(t),"setAnswerChecked",(function(){return function(e){var n=t.props,r=n.updateUserQuestionAnswers,o=n.question;if("started"!==n.status)return"LP Error: can not set answers";var i=t.$wrap.find(".option-check"),c=[],u="multi_choice"!==o.type;i.each((function(e,t){if(t.checked&&(c.push(t.value),u))return!1})),r(o.id,u?c[0]:c)}})),m(y(t),"maybeCheckedAnswer",(function(e){var n=t.props.answered;return d(n)?!!n.find((function(t){return t==e})):e==n})),m(y(t),"getOptionType",(function(e,t){var n="radio";switch(e){case"multi_choice":n="checkbox"}return n})),m(y(t),"isDefaultType",(function(){return t.props.supportOptions})),m(y(t),"getWarningMessage",(function(){return React.createElement(React.Fragment,null,Object(c.__)("Render function should be overwritten from base.","learnpress"))})),m(y(t),"getOptionClass",(function(e){t.props.answered;return["answer-option"]})),m(y(t),"parseOptions",(function(e){return e&&(e=d(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=d(e)?e:JSON.parse(e)),e||[]})),m(y(t),"getOptions",(function(){return t.state.options||[]})),m(y(t),"isCorrect",(function(){var e,n,r,o=t.props.answered;if(!o)return!1;for(e=0,r=t.getOptions();e<r.length;e++)if("yes"===(n=r[e]).isTrue&&o==n.value)return!0;return!1})),m(y(t),"isChecked",(function(){var e=t.props.question;return Object(i.select)("learnpress/quiz").isCheckedAnswer(e.id)})),m(y(t),"getCorrectLabel",(function(){var e=t.props,n=(e.status,e.answered,e.question),r=(LP.config.isQuestionCorrect[n.type]||t.isCorrect).call(y(t));return t.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response"+(r?" correct":" incorrect")},React.createElement("span",{className:"label"},r?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),r?n.point:0,n.point)))}));var n=e.question;return t.state={optionClass:["answer-option"],questionId:0,options:n?t.parseOptions(n.options):[],self:y(t)},e.$wrap&&(t.$wrap=e.$wrap),t}return t=u,r=[{key:"getDerivedStateFromProps",value:function(e,t){return t.self.prepare(e,t)}}],(n=[{key:"componentDidMount",value:function(){var e=this.prepare(this.props,this.state);e&&this.setState(e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.status;return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(n.id),className:"answer-options"},this.getOptions().map((function(t){var o="learn-press-answer-option-".concat(t.uid);return React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.uid)},React.createElement("input",{type:e.getOptionType(n.type,t),className:"option-check",name:"started"===r?"learn-press-question-".concat(n.id):"",id:o,ref:function(n){e.setInputRef(n,t.value)},onChange:e.setAnswerChecked(),disabled:e.maybeDisabledOption(t),checked:e.maybeCheckedAnswer(t.value),value:"started"===r?t.value:""}),React.createElement("label",{htmlFor:o,className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}}))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&s(t.prototype,n),r&&s(t,r),u}(r.Component));function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function O(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return g(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return g(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=A(e);if(t){var o=A(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return R(this,n)}}function R(e,t){return!t||"object"!==w(t)&&"function"!=typeof t?P(e):t}function P(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var E=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(n,e);var t=_(n);function n(){var e;j(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return C(P(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var n=e.props.answered,r=O(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&r.push("answer-correct"),n&&("yes"===t.isTrue?n===t.value&&r.push("answered-correct"):n===t.value&&r.push("answered-wrong"))),r})),e}return n}(v);function T(e){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return q(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=B(e);if(t){var o=B(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return L(this,n)}}function L(e,t){return!t||"object"!==T(t)&&"function"!=typeof t?M(e):t}function M(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var F=lodash.isBoolean,U=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&I(e,t)}(n,e);var t=N(n);function n(){var e;x(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return D(M(e=t.call.apply(t,[this].concat(o))),"isCorrect",(function(){var t,n,r,o=e.props.answered;if(F(o)||!o)return!1;for(t=0,r=e.getOptions();t<r.length;t++)if("yes"===(n=r[t]).isTrue){if(-1===o.indexOf(n.value))return!1}else if(-1!==o.indexOf(n.value))return!1;return!0})),D(M(e),"getOptionClass",(function(t){var n=e.props.answered,r=k(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&r.push("answer-correct"),n&&("yes"===t.isTrue?-1!==n.indexOf(t.value)&&r.push("answered-correct"):-1!==n.indexOf(t.value)&&r.push("answered-wrong"))),r})),e}return n}(v);function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Q(e){return function(e){if(Array.isArray(e))return $(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return $(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=K(e);if(t){var o=K(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return V(this,n)}}function V(e,t){return!t||"object"!==H(t)&&"function"!=typeof t?G(e):t}function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&J(e,t)}(n,e);var t=W(n);function n(){var e;z(this,n);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return X(G(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var n=e.props.answered,r=Q(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&r.push("answer-correct"),n&&("yes"===t.isTrue?n===t.value&&r.push("answered-correct"):n===t.value&&r.push("answered-wrong"))),r})),e}return n}(v);function Z(e){return(Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e){return function(e){if(Array.isArray(e))return te(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return te(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return te(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ae(e);if(t){var o=ae(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ce(this,n)}}function ce(e,t){return!t||"object"!==Z(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ae(e){return(ae=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(i,e);var t,n,r,o=ie(i);function i(){var e;ne(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return se(ue(e=o.call.apply(o,[this].concat(n))),"updateFibAnswer",(function(){var t=document.querySelectorAll(".lp-fib-input > input"),n={};ee(t).map((function(t){t.addEventListener("input",(function(r){e.setAnswered(n,t.dataset.id,r.target.value)})),t.addEventListener("paste",(function(r){e.setAnswered(n,t.dataset.id,r.target.value)}))}))})),se(ue(e),"setAnswered",(function(t,n,r){var o=e.props,i=o.updateUserQuestionAnswers,c=o.question;if("started"!==o.status)return"LP Error: can not set answers";var u=Object.assign(t,se({},n,r));i(c.id,u)})),se(ue(e),"getCorrectLabel",(function(){var t=e.props,n=t.question,r=t.mark,o=r||0;return r&&(Number.isInteger(r)||(o=r.toFixed(2))),e.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response correct"},React.createElement("span",{className:"label"},Object(c.__)("Points","learnpress")),React.createElement("span",{className:"point"},"".concat(o,"/").concat(n.point," ").concat(Object(c.__)("point","learnpress"))),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#00adff"}}),Object(c.__)("Correct","learnpress")),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#d85554"}}),Object(c.__)("Incorrect","learnpress")))})),e}return t=i,(n=[{key:"componentDidMount",value:function(){this.updateFibAnswer()}},{key:"componentDidUpdate",value:function(e){e.answered||this.updateFibAnswer()}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{className:"lp-fib-content"},this.getOptions().map((function(e){return React.createElement("div",{key:"blank-".concat(e.uid),dangerouslySetInnerHTML:{__html:e.title||e.value}})}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&re(t.prototype,n),r&&re(t,r),i}(v);function fe(e){return(fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pe(e){return function(e){if(Array.isArray(e))return ye(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ye(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ye(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function me(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Oe(e);if(t){var o=Oe(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ve(this,n)}}function ve(e,t){return!t||"object"!==fe(t)&&"function"!=typeof t?we(e):t}function we(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Oe(e){return(Oe=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ge(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&he(e,t)}(i,e);var t,n,r,o=de(i);function i(){var e;be(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ge(we(e=o.call.apply(o,[this].concat(n))),"isCorrect",(function(){var t,n,r,o=e.props.answered;if(!o)return!1;for(t=0,r=e.getOptions();t<r.length;t++)if(o[(n=r[t]).sorting]!==n.value)return!1;return!0})),ge(we(e),"getCorrectLabel",(function(){var t=e.props.question,n=e.isCorrect.call(we(e));return e.maybeShowCorrectAnswer()&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-response"+(n?" correct":" incorrect")},React.createElement("span",{className:"label"},n?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),n?t.point:0,t.point))))})),ge(we(e),"getAnswerSortingChoice",(function(){var t=e.props.question.options||[],n=e.isCorrect.call(we(e)),r=[];return!n&&t.length>0&&t.map((function(e){var t=e.sorting;if(void 0!==t)return r[t]=e.title})),r})),e}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.updateUserQuestionAnswers,n=e.question,r=document.querySelector("#answer-options-".concat(n.id));return jQuery(r).sortable({items:".answer-option",cursor:"move",axis:"y",handle:".option-drag",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,update:function(e,o){var i=r.querySelectorAll(".answer-option"),c=[];pe(i).map((function(e){return c.push(e.dataset.value)})),c.length>0&&t(n.id,c)}})}},{key:"render",value:function(){var e=this,t=this.props.question,n=this.getAnswerSortingChoice();return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(t.id),className:"answer-options lp-sorting-choice-ul"},this.getOptions().map((function(t,r){return React.createElement(React.Fragment,null,React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.value),"data-value":t.value},React.createElement("span",{className:"option-drag",style:{display:"flex",alignItems:"center",position:"absolute",height:"100%",left:14}},React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24"},React.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),React.createElement("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"}))),React.createElement("label",{htmlFor:"learn-press-answer-option-".concat(t.value),className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}})),n.length>0&&void 0!==n[r]&&React.createElement("div",{className:"lp-sorting-choice__check-answer",key:"lp-checked-answer-".concat(r),style:{marginBottom:10}},n[r]))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&me(t.prototype,n),r&&me(t,r),i}(v);function Se(e){return(Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Ae(e,t){return(Ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ce(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=ke(e);if(t){var o=ke(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Ee(this,n)}}function Ee(e,t){return!t||"object"!==Se(t)&&"function"!=typeof t?Te(e):t}function Te(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ke(e){return(ke=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function qe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var xe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ae(e,t)}(i,e);var t,n,r,o=Ce(i);function i(){var e;Re(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return qe(Te(e=o.call.apply(o,[this].concat(n))),"getQuestion",(function(){var t=e.props.question;return LP.Hook.applyFilters("question-types",{single_choice:LP.questionTypes.SingleChoice,multi_choice:LP.questionTypes.MultipleChoices,true_or_false:LP.questionTypes.TrueOrFalse,fill_in_blanks:LP.questionTypes.FillInBlanks,sorting_choice:LP.questionTypes.SortingChoice})[t.type]})),e}return t=i,(n=[{key:"render",value:function(){var e=this.props,t=e.question,n=e.supportOptions,r=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_e(Object(n),!0).forEach((function(t){qe(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_e(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},this.props);r.supportOptions=-1!==n.indexOf(t.type);var o=this.getQuestion()||function(){return React.createElement("div",{className:"question-types",dangerouslySetInnerHTML:{__html:Object(c.sprintf)(Object(c.__)("Question <code>%s</code> invalid!","learnpress"),t.type)}})};return React.createElement(React.Fragment,null,React.createElement(o,r))}}])&&Pe(t.prototype,n),r&&Pe(t,r),i}(r.Component),Ie=Object(o.compose)(Object(i.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.isCheckedAnswer;return{supportOptions:o("supportOptions"),isCheckedAnswer:i(n),keyPressed:o("keyPressed"),showCorrectReview:o("showCorrectReview"),isReviewing:"reviewing"===o("mode")}})),Object(i.withDispatch)((function(){return{}})))(xe);t.default=Ie},3:function(e,t){e.exports=window.wp.compose}});
assets/js/dist/frontend/quiz.js CHANGED
@@ -1639,6 +1639,7 @@ __webpack_require__.r(__webpack_exports__);
1639
  /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__);
1640
  /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
1641
  /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__);
 
1642
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1643
 
1644
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -1668,6 +1669,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1668
 
1669
 
1670
 
 
1671
  var _lodash = lodash,
1672
  debounce = _lodash.debounce;
1673
 
@@ -1723,8 +1725,18 @@ var Result = function Result() {
1723
  itemCompleted.textContent = parseInt(allItemCompleted.length);
1724
  }
1725
  }
 
 
1726
  }, [results]);
1727
 
 
 
 
 
 
 
 
 
1728
  var animate = function animate() {
1729
  setPercentage(0);
1730
  setDone(false);
@@ -3204,6 +3216,68 @@ function getUserMark(state) {
3204
 
3205
  /***/ }),
3206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3207
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/compatible.js":
3208
  /*!***********************************************************************************************************************************************************************************************!*\
3209
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/compatible.js ***!
@@ -3296,6 +3370,173 @@ LP.Hook.addAction('lp-question-compatible-builder', function () {
3296
 
3297
  /***/ }),
3298
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3299
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/node_modules/classnames/index.js":
3300
  /*!*********************************************************************************************************************************************************!*\
3301
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/node_modules/classnames/index.js ***!
@@ -3477,6 +3718,17 @@ module.exports = refx;
3477
 
3478
  (function() { module.exports = window["wp"]["i18n"]; }());
3479
 
 
 
 
 
 
 
 
 
 
 
 
3480
  /***/ })
3481
 
3482
  /******/ });
1639
  /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__);
1640
  /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
1641
  /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__);
1642
+ /* harmony import */ var _single_curriculum_components_items_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../single-curriculum/components/items-progress */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/items-progress.js");
1643
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1644
 
1645
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1669
 
1670
 
1671
 
1672
+
1673
  var _lodash = lodash,
1674
  debounce = _lodash.debounce;
1675
 
1725
  itemCompleted.textContent = parseInt(allItemCompleted.length);
1726
  }
1727
  }
1728
+
1729
+ updateItemsProgress();
1730
  }, [results]);
1731
 
1732
+ var updateItemsProgress = function updateItemsProgress() {
1733
+ var elements = document.querySelectorAll('.popup-header__inner');
1734
+
1735
+ if (elements[0].querySelectorAll('form.form-button-finish-course').length === 0) {
1736
+ Object(_single_curriculum_components_items_progress__WEBPACK_IMPORTED_MODULE_3__["getResponse"])(elements[0]);
1737
+ }
1738
+ };
1739
+
1740
  var animate = function animate() {
1741
  setPercentage(0);
1742
  setDone(false);
3216
 
3217
  /***/ }),
3218
 
3219
+ /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/show-lp-overlay-complete-item.js":
3220
+ /*!*************************************************************************************************************************************************************************************!*\
3221
+ !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/show-lp-overlay-complete-item.js ***!
3222
+ \*************************************************************************************************************************************************************************************/
3223
+ /*! exports provided: default */
3224
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3225
+
3226
+ "use strict";
3227
+ __webpack_require__.r(__webpack_exports__);
3228
+ /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/lp-modal-overlay */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/lp-modal-overlay.js");
3229
+ var $ = jQuery;
3230
+
3231
+ var lpModalOverlayCompleteItem = {
3232
+ elBtnFinishCourse: null,
3233
+ elBtnCompleteItem: null,
3234
+ init: function init() {
3235
+ if (!_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].init()) {
3236
+ return;
3237
+ }
3238
+
3239
+ if (undefined === lpGlobalSettings || 'yes' !== lpGlobalSettings.option_enable_popup_confirm_finish) {
3240
+ return;
3241
+ }
3242
+
3243
+ this.elBtnFinishCourse = document.querySelectorAll('.lp-btn-finish-course');
3244
+ this.elBtnCompleteItem = document.querySelector('.lp-btn-complete-item');
3245
+
3246
+ if (this.elBtnCompleteItem) {
3247
+ this.elBtnCompleteItem.addEventListener('click', function (e) {
3248
+ e.preventDefault();
3249
+ var form = e.target.closest('form');
3250
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show();
3251
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title);
3252
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>');
3253
+
3254
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = function () {
3255
+ form.submit();
3256
+ };
3257
+ });
3258
+ }
3259
+
3260
+ if (this.elBtnFinishCourse) {
3261
+ this.elBtnFinishCourse.forEach(function (element) {
3262
+ return element.addEventListener('click', function (e) {
3263
+ e.preventDefault();
3264
+ var form = e.target.closest('form');
3265
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show();
3266
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title);
3267
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>');
3268
+
3269
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = function () {
3270
+ form.submit();
3271
+ };
3272
+ });
3273
+ });
3274
+ }
3275
+ }
3276
+ };
3277
+ /* harmony default export */ __webpack_exports__["default"] = (lpModalOverlayCompleteItem);
3278
+
3279
+ /***/ }),
3280
+
3281
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/compatible.js":
3282
  /*!***********************************************************************************************************************************************************************************************!*\
3283
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/compatible.js ***!
3370
 
3371
  /***/ }),
3372
 
3373
+ /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/items-progress.js":
3374
+ /*!***************************************************************************************************************************************************************************************************!*\
3375
+ !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/items-progress.js ***!
3376
+ \***************************************************************************************************************************************************************************************************/
3377
+ /*! exports provided: itemsProgress, getResponse */
3378
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3379
+
3380
+ "use strict";
3381
+ __webpack_require__.r(__webpack_exports__);
3382
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "itemsProgress", function() { return itemsProgress; });
3383
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getResponse", function() { return getResponse; });
3384
+ /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
3385
+ /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
3386
+ /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../show-lp-overlay-complete-item */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
3387
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3388
+
3389
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3390
+
3391
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3392
+
3393
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3394
+
3395
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3396
+
3397
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
3398
+
3399
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
3400
+
3401
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
3402
+
3403
+ // Rest API load content course progress - Nhamdv.
3404
+
3405
+
3406
+ var itemsProgress = function itemsProgress() {
3407
+ var elements = document.querySelectorAll('.popup-header__inner');
3408
+
3409
+ if (!elements.length) {
3410
+ return;
3411
+ }
3412
+
3413
+ if (document.querySelector('#learn-press-quiz-app div.quiz-result') !== null) {
3414
+ return;
3415
+ }
3416
+
3417
+ if ('IntersectionObserver' in window) {
3418
+ var eleObserver = new IntersectionObserver(function (entries, observer) {
3419
+ entries.forEach(function (entry) {
3420
+ if (entry.isIntersecting) {
3421
+ var ele = entry.target;
3422
+ getResponse(ele);
3423
+ eleObserver.unobserve(ele);
3424
+ }
3425
+ });
3426
+ });
3427
+
3428
+ _toConsumableArray(elements).map(function (ele) {
3429
+ return eleObserver.observe(ele);
3430
+ });
3431
+ }
3432
+ };
3433
+ var getResponse = /*#__PURE__*/function () {
3434
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ele) {
3435
+ var response, data;
3436
+ return regeneratorRuntime.wrap(function _callee$(_context) {
3437
+ while (1) {
3438
+ switch (_context.prev = _context.next) {
3439
+ case 0:
3440
+ _context.next = 2;
3441
+ return wp.apiFetch({
3442
+ path: Object(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__["addQueryArgs"])('lp/v1/lazy-load/items-progress', {
3443
+ courseId: lpGlobalSettings.post_id || '',
3444
+ userId: lpGlobalSettings.user_id || ''
3445
+ }),
3446
+ method: 'GET'
3447
+ });
3448
+
3449
+ case 2:
3450
+ response = _context.sent;
3451
+ data = response.data;
3452
+ ele.innerHTML += data;
3453
+ _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init();
3454
+
3455
+ case 6:
3456
+ case "end":
3457
+ return _context.stop();
3458
+ }
3459
+ }
3460
+ }, _callee);
3461
+ }));
3462
+
3463
+ return function getResponse(_x) {
3464
+ return _ref.apply(this, arguments);
3465
+ };
3466
+ }();
3467
+
3468
+ /***/ }),
3469
+
3470
+ /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/lp-modal-overlay.js":
3471
+ /*!*********************************************************************************************************************************************************************!*\
3472
+ !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/lp-modal-overlay.js ***!
3473
+ \*********************************************************************************************************************************************************************/
3474
+ /*! exports provided: default */
3475
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
3476
+
3477
+ "use strict";
3478
+ __webpack_require__.r(__webpack_exports__);
3479
+ var $ = jQuery;
3480
+ var elLPOverlay = null;
3481
+ var lpModalOverlay = {
3482
+ elLPOverlay: null,
3483
+ elMainContent: null,
3484
+ elTitle: null,
3485
+ elBtnYes: null,
3486
+ elBtnNo: null,
3487
+ elFooter: null,
3488
+ elCalledModal: null,
3489
+ callBackYes: null,
3490
+ instance: null,
3491
+ init: function init() {
3492
+ if (this.instance) {
3493
+ return true;
3494
+ }
3495
+
3496
+ this.elLPOverlay = $('.lp-overlay');
3497
+
3498
+ if (!this.elLPOverlay.length) {
3499
+ return false;
3500
+ }
3501
+
3502
+ elLPOverlay = this.elLPOverlay;
3503
+ this.elMainContent = elLPOverlay.find('.main-content');
3504
+ this.elTitle = elLPOverlay.find('.modal-title');
3505
+ this.elBtnYes = elLPOverlay.find('.btn-yes');
3506
+ this.elBtnNo = elLPOverlay.find('.btn-no');
3507
+ this.elFooter = elLPOverlay.find('.lp-modal-footer');
3508
+ $(document).on('click', '.close, .btn-no', function () {
3509
+ elLPOverlay.hide();
3510
+ });
3511
+ $(document).on('click', '.btn-yes', function (e) {
3512
+ e.preventDefault();
3513
+ e.stopPropagation();
3514
+
3515
+ if ('function' === typeof lpModalOverlay.callBackYes) {
3516
+ lpModalOverlay.callBackYes();
3517
+ }
3518
+ });
3519
+ this.instance = this;
3520
+ return true;
3521
+ },
3522
+ setElCalledModal: function setElCalledModal(elCalledModal) {
3523
+ this.elCalledModal = elCalledModal;
3524
+ },
3525
+ setContentModal: function setContentModal(content, event) {
3526
+ this.elMainContent.html(content);
3527
+
3528
+ if ('function' === typeof event) {
3529
+ event();
3530
+ }
3531
+ },
3532
+ setTitleModal: function setTitleModal(content) {
3533
+ this.elTitle.html(content);
3534
+ }
3535
+ };
3536
+ /* harmony default export */ __webpack_exports__["default"] = (lpModalOverlay);
3537
+
3538
+ /***/ }),
3539
+
3540
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/node_modules/classnames/index.js":
3541
  /*!*********************************************************************************************************************************************************!*\
3542
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/node_modules/classnames/index.js ***!
3718
 
3719
  (function() { module.exports = window["wp"]["i18n"]; }());
3720
 
3721
+ /***/ }),
3722
+
3723
+ /***/ "@wordpress/url":
3724
+ /*!*****************************!*\
3725
+ !*** external ["wp","url"] ***!
3726
+ \*****************************/
3727
+ /*! no static exports found */
3728
+ /***/ (function(module, exports) {
3729
+
3730
+ (function() { module.exports = window["wp"]["url"]; }());
3731
+
3732
  /***/ })
3733
 
3734
  /******/ });
assets/js/dist/frontend/quiz.min.js CHANGED
@@ -1,6 +1,6 @@
1
- this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=18)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.compose},function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,i,a=n[r.type],u=t(r);if(a)for(o=0;o<a.length;o++)(i=a[o](r,e))&&e.dispatch(i);return u}}}).effects=n,t}},,,function(e,t){!function(){e.exports=this.LP.dataControls}()},function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,,function(e,t,n){var r;
2
  /*!
3
  Copyright (c) 2018 Jed Watson.
4
  Licensed under the MIT License (MIT), see
5
  http://jedwatson.github.io/classnames
6
- */!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return qn}));var r={};n.r(r),n.d(r,"setQuizData",(function(){return vt})),n.d(r,"setCurrentQuestion",(function(){return Ot})),n.d(r,"setCurrentPage",(function(){return wt})),n.d(r,"__requestBeforeStartQuiz",(function(){return _t})),n.d(r,"__requestStartQuizSuccess",(function(){return jt})),n.d(r,"startQuiz",(function(){return Rt})),n.d(r,"__requestSubmitQuiz",(function(){return qt})),n.d(r,"__requestSubmitQuizSuccess",(function(){return St})),n.d(r,"submitQuiz",(function(){return Et})),n.d(r,"updateUserQuestionAnswers",(function(){return Pt})),n.d(r,"__requestShowHintSuccess",(function(){return kt})),n.d(r,"showHint",(function(){return zt})),n.d(r,"__requestCheckAnswerSuccess",(function(){return Qt})),n.d(r,"checkAnswer",(function(){return At})),n.d(r,"markQuestionRendered",(function(){return It})),n.d(r,"setQuizMode",(function(){return Nt})),n.d(r,"sendKey",(function(){return Ct}));var o={};n.r(o),n.d(o,"getQuestionOptions",(function(){return Ut})),n.d(o,"getItemStatus",(function(){return Mt})),n.d(o,"getProp",(function(){return Lt})),n.d(o,"getQuizAttempts",(function(){return Ht})),n.d(o,"getQuizAnswered",(function(){return Ft})),n.d(o,"getQuestions",(function(){return Bt})),n.d(o,"getData",(function(){return Kt})),n.d(o,"getDefaultRestArgs",(function(){return Wt})),n.d(o,"getQuestionAnswered",(function(){return Jt})),n.d(o,"getQuestionMark",(function(){return Zt})),n.d(o,"getCurrentQuestion",(function(){return $t})),n.d(o,"getQuestion",(function(){return Gt})),n.d(o,"isCheckedAnswer",(function(){return Vt})),n.d(o,"isCorrect",(function(){return Yt})),n.d(o,"getQuestionsSelectedAnswers",(function(){return Xt})),n.d(o,"getUserMark",(function(){return en}));var i=n(2),a=n(3),u=n(1),s=function(){var e=Object(u.select)("learnpress/quiz").getData("content");return React.createElement("div",{className:"quiz-content",dangerouslySetInnerHTML:{__html:e}})},c=n(0),l=function(e){var t;if(e>86400)t=(e-e%86400)/86400,e%=86400;else if(86400==e)return"24:00";var n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")},f=LP.Hook,p=function(){var e=function(e){return Object(u.select)("learnpress/quiz").getData(e)},t=f.applyFilters("quiz-meta-fields",{duration:{title:Object(c.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:Object(c.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:Object(c.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&React.createElement(React.Fragment,null,React.createElement("ul",{className:"quiz-intro"},Object.values(t).map((function(e,t){var n=e.name||t;return React.createElement("li",{key:"quiz-intro-field-".concat(t),className:"quiz-intro-item quiz-intro-item--".concat(n)},React.createElement("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),React.createElement("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j(e);if(t){var o=j(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return w(this,n)}}function w(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(i,e);var t,n,r,o=O(i);function i(){var e;h(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return R(_(e=o.call.apply(o,[this].concat(n))),"startQuiz",(function(t){t&&t.preventDefault();var n=document.querySelector(".lp-button.start");n&&n.setAttribute("disabled","disabled");var r=e.props,o=r.startQuiz;if("completed"===r.status){var i=Object(u.select)("learnpress/modal"),a=i.confirm,s=i.isOpen;if("no"===a("Are you sure you want to retry quiz?",e.startQuiz))return void(!s()&&n&&n.removeAttribute("disabled"))}o()})),R(_(e),"nav",(function(t){return function(n){var r=e.props,o=r.questionNav,i=r.currentPage,a=r.numPages,u=r.setCurrentPage;switch(t){case"prev":i>1?i-=1:i="infinity"===o?a:1;break;default:i<a?i+=1:i="infinity"===o?1:a}u(i)}})),R(_(e),"moveTo",(function(t){return function(n){n.preventDefault();var r=e.props,o=r.numPages,i=r.setCurrentPage;t<1||t>o||i(t)}})),R(_(e),"isLast",(function(){var t=e.props;return t.currentPage===t.numPages})),R(_(e),"isFirst",(function(){return 1===e.props.currentPage})),R(_(e),"submit",(function(){var t=e.props.submitQuiz;"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),e.submit)&&t()})),R(_(e),"setQuizMode",(function(t){return function(){(0,e.props.setQuizMode)(t)}})),R(_(e),"isReviewing",(function(){return e.props.isReviewing})),e}return t=i,(n=[{key:"pageNumbers",value:function(e){var t=this,n=this.props,r=n.numPages,o=n.currentPage;if(r<2)return"";(e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({numPages:r,currentPage:o,midSize:1,endSize:1,prevNext:!0},e||{})).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);var i=m(Array(r).keys()),a=!1;return React.createElement("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&React.createElement("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},Object(c.__)("Prev","learnpress")),i.map((function(n){return(n+=1)===e.currentPage?(a=!0,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers current"},n)):n<=e.endSize||e.currentPage&&n>=e.currentPage-e.midSize&&n<=e.currentPage+e.midSize||n>e.numPages-e.endSize?(a=!0,React.createElement("button",{key:"page-number-".concat(n),className:"page-numbers",onClick:t.moveTo(n)},n)):a?(a=!1,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers dots"},"…")):""})),e.prevNext&&!this.isLast()&&React.createElement("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},Object(c.__)("Next","learnpress")))}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.questionNav,r=e.isReviewing,o=e.showReview,i=e.numPages,a=(e.question,e.questionsPerPage,e.canRetry),u=e.retakeNumber,s=["quiz-buttons"];("started"===t||r)&&s.push("align-center"),"questionNav"===n&&s.push("infinity"),this.isFirst()&&s.push("is-first"),this.isLast()&&s.push("is-last");var l=document.querySelector("#popup-sidebar"),f=document.querySelector("#learn-press-quiz-app"),p="";return p="started"===t||r?{marginLeft:l&&l.offsetWidth/2,width:f&&f.offsetWidth}:null,React.createElement(React.Fragment,null,React.createElement("div",{className:s.join(" ")},React.createElement("div",{className:"button-left"+("started"===t||r?" fixed":""),style:p},("completed"===t&&a||-1!==["","viewed"].indexOf(t))&&!r&&React.createElement("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===t?"".concat(Object(c._x)("Retake","label button retry quiz","learnpress")).concat(u?" (".concat(u,")"):""):Object(c._x)("Start","label button start quiz","learnpress")),("started"===t||r)&&i>1&&React.createElement(React.Fragment,null,React.createElement("div",{className:"questions-pagination"},this.pageNumbers()))),React.createElement("div",{className:"button-right"},"started"===t&&React.createElement(React.Fragment,null,("infinity"===n||this.isLast())&&!r&&React.createElement("button",{className:"lp-button submit-quiz",onClick:this.submit},Object(c.__)("Finish Quiz","learnpress"))),r&&o&&React.createElement("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},Object(c.__)("Result","learnpress")),"completed"===t&&o&&!r&&React.createElement("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},Object(c.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&React.createElement("div",{className:"learn-press-message error"},this.props.message))}}])&&g(t.prototype,n),r&&g(t,r),i}(i.Component),S=Object(a.compose)(Object(u.withSelect)((function(e){var t=e("learnpress/quiz").getData;return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((function(e){var t=e.showCheck,n=e.checkedQuestions,r=e.hintedQuestions,o=e.question,i=e.status,a=e.type,u=e.Button;if("started"!==i)return!1;var s=React.createElement(u,{question:o});switch(a){case"hint":return r?!!o.hasHint&&(-1===r.indexOf(o.id)&&s):s;case"check":return!!t&&(n?-1===n.indexOf(o.id)&&s:s)}})),E=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getData,r=t.getCurrentQuestion,o={id:n("id"),status:n("status"),questionIds:n("questionIds"),questionNav:n("questionNav"),isReviewing:n("reviewQuestions")&&"reviewing"===n("mode"),showReview:n("reviewQuestions"),showCheck:n("instantCheck"),checkedQuestions:n("checkedQuestions"),hintedQuestions:n("hintedQuestions"),numPages:n("numPages"),pages:n("pages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage"),pageNumbers:n("pageNumbers"),keyPressed:n("keyPressed"),canRetry:n("retakeCount")>0&&n("retaken")<n("retakeCount"),retakeNumber:n("retakeCount")>0&&n("retaken")<n("retakeCount")?n("retakeCount")-n("retaken"):null,message:n("messageResponse")||!1,success:void 0===n("successResponse")||n("successResponse")};return 1===o.questionsPerPage&&(o.question=r("object")),o})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz"),r=n.startQuiz,o=n.setCurrentQuestion,i=n.submitQuiz,a=n.setQuizMode,u=n.showHint,s=n.checkAnswer;return{startQuiz:r,setCurrentQuestion:o,setQuizMode:a,setCurrentPage:n.setCurrentPage,submitQuiz:function(e){i(e)},showHint:function(e){u(e)},checkAnswer:function(e){s(e)}}}))])(q);function P(e){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=C(e);if(t){var o=C(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return I(this,n)}}function I(e,t){return!t||"object"!==P(t)&&"function"!=typeof t?N(e):t}function N(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(i,e);var t,n,r,o=A(i);function i(){var e;k(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return T(N(e=o.call.apply(o,[this].concat(n))),"showHint",(function(){var t=e.props,n=t.showHint,r=t.question;n(r.id,!r.showHint)})),e}return t=i,(n=[{key:"render",value:function(){return this.props.question.hint?React.createElement("button",{className:"btn-show-hint",onClick:this.showHint},React.createElement("span",null,Object(c.__)("Hint","learnpress"))):""}}])&&z(t.prototype,n),r&&z(t,r),i}(i.Component),D=Object(a.compose)(Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").showHint;return{showHint:function(e,t){n(e,t)}}})))(x),U=n(11),M=n.n(U);function L(e){return(L="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function H(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function K(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Z(e);if(t){var o=Z(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return W(this,n)}}function W(e,t){return!t||"object"!==L(t)&&"function"!=typeof t?J(e):t}function J(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Z(e){return(Z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var G=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&B(e,t)}(i,e);var t,n,r,o=K(i);function i(){var e;return H(this,i),$(J(e=o.apply(this,arguments)),"checkAnswer",(function(){var t=e.props,n=t.checkAnswer,r=t.question;t.answered&&(n(r.id),e.setState({loading:!0}))})),e.state={loading:!1},e}return t=i,(n=[{key:"render",value:function(){var e=this.props.answered;return React.createElement(React.Fragment,null,React.createElement("button",{className:M()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},React.createElement("span",{className:"instant-check__icon"}),Object(c._x)("Check answer","label of button check answer","learnpress"),!e&&React.createElement("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:Object(c.__)("You need to answer the question before check answer.","learnpress")}})))}}])&&F(t.prototype,n),r&&F(t,r),i}(i.Component),V=Object(a.compose)(Object(u.withSelect)((function(e,t){var n=t.question.id;return{answered:(0,e("learnpress/quiz").getQuestionAnswered)(n)}})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").checkAnswer;return{checkAnswer:function(e){n(e)}}})))(G),Y=function(e){var t=e.question,n={"instant-check":function(){return React.createElement(S,{type:"check",Button:V,question:t})},hint:function(){return React.createElement(S,{type:"hint",Button:D,question:t})}};return React.createElement(React.Fragment,null,LP.config.questionFooterButtons().map((function(e){return React.createElement(i.Fragment,{key:"button-".concat(e)},n[e]&&n[e]())})))};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=se(e);if(t){var o=se(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ae(this,n)}}function ae(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=window.jQuery,fe=lodash,pe=(fe.uniqueId,fe.isArray),de=(fe.isNumber,fe.bind,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(a,e);var t,n,r,o=ie(a);function a(){var e;return ne(this,a),ce(ue(e=o.apply(this,arguments)),"setRef",(function(t){e.$wrap=le(t)})),ce(ue(e),"parseOptions",(function(e){return e&&(e=pe(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=pe(e)?e:JSON.parse(e)),e||[]})),ce(ue(e),"getWrapperClass",(function(){var t=e.props,n=t.question,r=(t.answered,["question","question-"+n.type]),o=e.parseOptions(n.options);return o.length&&void 0!==o[0].isTrue&&r.push("question-answered"),r})),ce(ue(e),"getEditLink",(function(){var t=e.props,n=t.question,r=t.editPermalink;return r?r.replace(/post=([0-9]{3,4})/,"post=".concat(n.id)):""})),ce(ue(e),"editPermalink",(function(e){return Object(c.sprintf)('<a href="%s">%s</a>',e,Object(c.__)("Edit","learnpress"))})),e.state={time:null,showHint:!1},e.$wrap=null,e}return t=a,(n=[{key:"componentDidMount",value:function(e){var t=this.props,n=t.question,r=t.isCurrent,o=t.markQuestionRendered;return r&&o(n.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),e}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.isShow,o=t.isShowIndex,a=(t.isShowHint,t.status),u=LP.questionTypes.default,s=this.getEditLink();s&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",s);var l={index:function(){return o?React.createElement("span",{className:"question-index"},o,"."):""},title:function(){return n.title},hint:function(){return React.createElement(D,{question:n})},"edit-permalink":function(){return s&&React.createElement("span",{dangerouslySetInnerHTML:{__html:e.editPermalink(s)},className:"edit-link"})}},f={title:function(){return React.createElement("h4",{className:"question-title"},LP.config.questionTitleParts().map((function(e){return React.createElement(i.Fragment,{key:"title-part-".concat(e)},l[e]&&l[e]())})))},content:function(){return React.createElement("div",{className:"question-content",dangerouslySetInnerHTML:{__html:n.content}})},"answer-options":function(){return e.$wrap&&React.createElement(u,te(te({},e.props),{},{$wrap:e.$wrap}))},explanation:function(){return n.explanation&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-explanation-content"},React.createElement("strong",{className:"explanation-title"},Object(c.__)("Explanation:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.explanation}})))},hint:function(){return n.hint&&!n.explanation&&n.showHint&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-hint-content"},React.createElement("strong",{className:"hint-title"},Object(c.__)("Hint:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.hint}})))},buttons:function(){return"started"===a&&React.createElement(Y,{question:n})}},p=LP.config.questionBlocks();return React.createElement(React.Fragment,null,React.createElement("div",{className:this.getWrapperClass().join(" "),style:{display:r?"":"none"},"data-id":n.id,ref:this.setRef},p.map((function(e){return React.createElement(i.Fragment,{key:"block-".concat(e)},f[e]?f[e]():"")}))))}}])&&re(t.prototype,n),r&&re(t,r),a}(i.Component)),me=Object(a.compose)([Object(u.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.getQuestionAnswered,a=r.getQuestionMark;return{status:o("status"),questions:o("question"),answered:i(n),questionsRendered:o("questionsRendered"),editPermalink:o("editPermalink"),numPages:o("numPages"),mark:a(n)||""}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz"),n=t.updateUserQuestionAnswers;return{markQuestionRendered:t.markQuestionRendered,updateUserQuestionAnswers:n}}))])(de);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Oe(this,n)}}function Oe(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?we(e):t}function we(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function je(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Re=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ge(e,t)}(i,e);var t,n,r,o=ve(i);function i(e){var t;return ye(this,i),je(we(t=o.apply(this,arguments)),"startQuiz",(function(e){e.preventDefault(),(0,t.props.startQuiz)()})),je(we(t),"isInVisibleRange",(function(e,n){var r=t.props,o=r.currentPage,i=r.questionsPerPage;return o===Math.ceil(n/i)})),je(we(t),"nav",(function(e){var n=t.props.sendKey;switch(e.keyCode){case 37:return n("left");case 38:return;case 39:return n("right");case 40:return;default:e.keyCode>=49&&e.keyCode<=57&&n(e.keyCode-48)}})),t.needToTop=!1,t.state={isReviewing:null,currentPage:0,self:we(t)},t}return t=i,r=[{key:"getDerivedStateFromProps",value:function(e,t){for(var n=["isReviewing","currentPage"],r={},o=0;o<n.length;o++)e[n[o]]!==t[n[o]]&&(r[n[o]]=e[n[o]]);return Object.values(r).length?(t.self.needToTop=!0,r):null}}],(n=[{key:"componentDidUpdate",value:function(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}},{key:"render",value:function(){var e=this,t=this.props,n=t.status,r=t.currentQuestion,o=t.questions,i=t.questionsRendered,a=t.isReviewing,u=t.questionsPerPage,s=!0;return"completed"!==n||a||(s=!1),React.createElement(React.Fragment,null,React.createElement("div",{tabIndex:100,onKeyUp:this.nav},React.createElement("div",{className:"quiz-questions",style:{display:s?"":"none"}},o.map((function(t,n){var o=!u&&r===t.id,a=i&&-1!==i.indexOf(t.id),s=e.isInVisibleRange(t.id,n+1);return a||!a||s?React.createElement(me,{key:"loop-question-".concat(t.id),isCurrent:o,isShow:s,isShowIndex:!!u&&n+1,questionsPerPage:u,question:t}):""})))))}}])&&he(t.prototype,n),r&&he(t,r),i}(i.Component),qe=Object(a.compose)(Object(u.withSelect)((function(e,t,n){var r=e("learnpress/quiz"),o=r.getData,i=r.getQuestions;return{status:o("status"),currentQuestion:o("currentQuestion"),questions:i(),questionsRendered:o("questionsRendered"),isReviewing:"reviewing"===o("mode"),numPages:o("numPages"),currentPage:o("currentPage"),questionsPerPage:o("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{startQuiz:t.startQuiz,sendKey:t.sendKey}})))(Re),Se=function(){var e=Object(u.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&React.createElement(React.Fragment,null,React.createElement("div",{className:"quiz-attempts"},React.createElement("h4",{className:"attempts-heading"},Object(c.__)("Last Attempted","learnpress")),t&&React.createElement("table",null,React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",{className:"quiz-attempts__questions"},Object(c.__)("Questions","learnpress")),React.createElement("th",{className:"quiz-attempts__spend"},Object(c.__)("Time spend","learnpress")),React.createElement("th",{className:"quiz-attempts__marks"},Object(c.__)("Marks","learnpress")),React.createElement("th",{className:"quiz-attempts__grade"},Object(c.__)("Passing grade","learnpress")),React.createElement("th",{className:"quiz-attempts__result"},Object(c.__)("Result","learnpress")))),React.createElement("tbody",null,e.map((function(e,t){return React.createElement("tr",{key:"attempt-".concat(t)},React.createElement("td",{className:"quiz-attempts__questions"},"".concat(e.questionCorrect," / ").concat(e.questionCount)),React.createElement("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),React.createElement("td",{className:"quiz-attempts__marks"},"".concat(e.userMark," / ").concat(e.mark)),React.createElement("td",{className:"quiz-attempts__grade"},e.passingGrade||Object(c._x)("-","unknown passing grade value","learnpress")),React.createElement("td",{className:"quiz-attempts__result"},"".concat(parseFloat(e.result).toFixed(2),"%")," ",React.createElement("span",null,e.graduationText)))}))))))};function Ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Pe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Pe(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ke=function(){var e=Object(u.select)("learnpress/quiz").getData,t=Object(u.dispatch)("learnpress/quiz").submitQuiz,n=e("totalTime")?e("totalTime"):e("duration"),r=e("endTime"),o=new Date(r.replace(/-/g,"/")),a=new Date,s=(new Date).getTimezoneOffset(),c=parseInt(o.getTime()/1e3-(a.getTime()/1e3+60*s)),l=Ee(Object(i.useState)(c>0?c:0),2),f=l[0],p=l[1];Object(i.useEffect)((function(){var e=setInterval((function(){var n=f;(n-=1)>0?p(n):(clearInterval(e),t())}),1e3);return function(){return clearInterval(e)}}),[f]);return React.createElement("div",{className:"countdown"},React.createElement("i",{className:"fas fa-stopwatch"}),React.createElement("span",null,function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":",r=[];return n<3600?(r.push((f-f%60)/60),r.push(f%60)):n&&(r.push((f-f%3600)/3600),e=f%3600,r.push((e-e%60)/60),r.push(e%60)),r.map((function(e){return e<10?"0".concat(e):e})).join(t)}()))};function ze(e){return function(e){if(Array.isArray(e))return Ie(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||Ae(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Qe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||Ae(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ae(e,t){if(e){if("string"==typeof e)return Ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ie(e,t):void 0}}function Ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=lodash.debounce,Ce=function(){var e=Qe(Object(i.useState)(0),2),t=e[0],n=e[1],r=Qe(Object(i.useState)(!1),2),o=r[0],a=r[1],s=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("results")}),[]),l=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("passingGrade")}),[]),f=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("id")}),[]);Object(i.useEffect)((function(){p();var e="";if(e=s.graduation?s.graduation:s.result>=h.replace(/[^0-9\.]+/g,"")?"passed":"failed"){var t=document.querySelector(".course-curriculum .course-item.course-item-".concat(f));t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}var n=ze(document.querySelectorAll("#popup-header .items-progress"))[0];if(n){var r=n.querySelector(".items-completed");if(r){parseInt(r.textContent);var o=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");r.textContent=parseInt(o.length)}}}),[s]);var p=function(){n(0),a(!1),jQuery.easing._customEasing=function(e,t,n,r,o){return r*Math.sqrt(1-(t=t/o-1)*t)+n},Ne((function(){var e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:s.result},{duration:1500,step:function(e,t){n(e)},done:function(){a(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),Ne((function(){jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),s.result>0?1e3:10)()},d=t;Number.isInteger(t)||(d=parseFloat(t).toFixed(2));var m=190*Math.PI,b=m-d/100*m,y={strokeDasharray:"".concat(m," ").concat(m),strokeDashoffset:b},h=s.passingGrade||l,g="";g=s.graduation?s.graduation:d>=h.replace(/[^0-9\.]+/g,"")?"passed":"failed";var v="";v=s.graduationText?s.graduationText:"passed"===g?Object(c.__)("Passed","learnpress"):Object(c.__)("Failed","learnpress");var O=["quiz-result",g];return React.createElement("div",{className:O.join(" ")},React.createElement("h3",{className:"result-heading"},Object(c.__)("Your Result","learnpress")),React.createElement("div",{id:"quizResultGrade",className:"result-grade"},React.createElement("svg",{className:"circle-progress-bar",width:200,height:200},React.createElement("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:y,fill:"transparent",r:95,cx:100,cy:100})),React.createElement("span",{className:"result-achieved"},"".concat(d,"%")),React.createElement("span",{className:"result-require"},h||Object(c._x)("-","unknown passing grade value","learnpress"))),o&&React.createElement("p",{className:"result-message"},v),React.createElement("ul",{className:"result-statistic"},React.createElement("li",{className:"result-statistic-field result-time-spend"},React.createElement("span",null,Object(c.__)("Time spend","learnpress")),React.createElement("p",null,s.timeSpend)),React.createElement("li",{className:"result-statistic-field result-point"},React.createElement("span",null,Object(c.__)("Point","learnpress")),React.createElement("p",null,s.userMark," / ",s.mark)),React.createElement("li",{className:"result-statistic-field result-questions"},React.createElement("span",null,Object(c.__)("Questions","learnpress")),React.createElement("p",null,s.questionCount)),React.createElement("li",{className:"result-statistic-field result-questions-correct"},React.createElement("span",null,Object(c.__)("Correct","learnpress")),React.createElement("p",null,s.questionCorrect)),React.createElement("li",{className:"result-statistic-field result-questions-wrong"},React.createElement("span",null,Object(c.__)("Wrong","learnpress")),React.createElement("p",null,s.questionWrong)),React.createElement("li",{className:"result-statistic-field result-questions-skipped"},React.createElement("span",null,Object(c.__)("Skipped","learnpress")),React.createElement("p",null,s.questionEmpty))))},Te=jQuery,xe=lodash.debounce,De=function(){var e=Object(u.dispatch)("learnpress/quiz").submitQuiz;Object(i.useEffect)((function(){var e=Te("#popup-content");if(e.length){var t=e.find(".content-item-scrollable:eq(1)"),n=e.find(".content-item-wrap"),r=e.find(".quiz-status"),o=r.offset().top-92,i=!1,a="-"+n.css("margin-left");Te(window).on("resize.refresh-quiz-stauts-bar",xe((function(){a="-"+n.css("margin-left"),r.css({"margin-left":a,"margin-right":a})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(function(){if(t.scrollTop()>=o){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}}),[]);var t=Object(u.select)("learnpress/quiz"),n=t.getData,r=t.getUserMark,o=n("currentPage"),a=n("questionsPerPage"),s=n("questionIds").length,l=n("submitting"),f=n("totalTime"),p=n("duration"),d=r(),m=["quiz-status"],b=(o-1)*a+1,y=b+a-1,h="";return y=Math.min(y,s),l&&m.push("submitting"),h=y<s?a>1?Object(c.sprintf)(Object(c.__)("Question <span>%d to %d of %d</span>","learnpress"),b,y,s):Object(c.sprintf)(Object(c.__)("Question <span>%d of %d</span>","learnpress"),b,s):Object(c.sprintf)(Object(c.__)("Question <span>%d to %d</span>","learnpress"),b,y),React.createElement("div",{className:m.join(" ")},React.createElement("div",null,React.createElement("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:h}}),React.createElement("div",{className:"current-point"},Object(c.sprintf)(Object(c.__)("Earned Point: %s","learnpress"),d)),React.createElement("div",null,React.createElement("div",{className:"submit-quiz"},React.createElement("button",{className:"lp-button",id:"button-submit-quiz",onClick:function t(){"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),t)&&e()}},l?Object(c.__)("Submitting...","learnpress"):Object(c.__)("Finish Quiz","learnpress"))),f&&p&&React.createElement(ke,null))))};function Ue(e){return function(e){if(Array.isArray(e))return Me(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Me(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Me(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Me(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach((function(t){Fe(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Fe(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Be=lodash,Ke=(Be.omit,Be.flow),We=Be.isArray,Je=Be.chunk,Ze=(LP.camelCaseDashObjectKeys,LP.localStorage),$e=Ze.get,Ge=Ze.set,Ve={},Ye=function(e,t){var n=He(He({},e.answered[t.questionId]||{}),{},{answered:t.answers,temp:!0});return He(He({},e),{},{answered:He(He({},e.answered),{},Fe({},t.questionId,n))})},Xe=function(e,t){var n=e.questionsRendered;return We(n)?(n.push(t.questionId),He(He({},e),{},{questionsRendered:Ue(n)})):He(He({},e),{},{questionsRendered:[t.questionId]})},et=function(e,t){return t.currentPage&&Ge("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),t)},tt=function(e,t){var n=e.questions.map((function(e){return e.id==t.questionId?He(He({},e),{},{showHint:t.showHint}):e}));return He(He({},e),{},{questions:Ue(n)})},nt=function(e,t){var n=e.questions.map((function(e){if(e.id!==t.questionId)return e;var n={explanation:t.explanation};return t.options&&(n.options=t.options),He(He({},e),n)}));return He(He({},e),{},{questions:Ue(n),answered:He(He({},e.answered),{},Fe({},t.questionId,t.result)),checkedQuestions:[].concat(Ue(e.checkedQuestions),[t.questionId])})},rt=function(e,t){var n=e.questions.map((function(n){var r={};return e.reviewQuestions&&(t.results.questions[n.id].explanation&&(r.explanation=t.results.questions[n.id].explanation),t.results.questions[n.id].options&&(r.options=t.results.questions[n.id].options)),He(He({},n),r)}));return et(e,He(He({submitting:!1,currentPage:1},t.results),{},{questions:Ue(n)}))},ot=function(e,t){var n=void 0!==t.results.success&&t.results.success,r=t.results.message||!1;return et(e,He(He({checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1},t.results.results),{},{successResponse:n,messageResponse:r}))},it=Ke(u.combineReducers,(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}))({a:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1};return e},b:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2};return e}}),at=Object(u.combineReducers)({blocks:it,userQuiz:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);var n=Je(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=n.length,t.data.pages=n,He(He(He({},e),t.data),{},{currentPage:$e("Q".concat(t.data.id,".currentPage"))||t.data.currentPage});case"SUBMIT_QUIZ":return He(He({},e),{},{submitting:!0});case"START_QUIZ":case"START_QUIZ_SUCCESS":return ot(e,t);case"SET_CURRENT_QUESTION":return Ge("Q".concat(e.id,".currentQuestion"),t.questionId),He(He({},e),{},{currentQuestion:t.questionId});case"SET_CURRENT_PAGE":return Ge("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),{},{currentPage:t.currentPage});case"SUBMIT_QUIZ_SUCCESS":return rt(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?Ye(e,t):e;case"MARK_QUESTION_RENDERED":return Xe(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?et(e,{mode:t.mode}):He(He({},e),{},{mode:t.mode});case"SET_QUESTION_HINT":return tt(e,t);case"CHECK_ANSWER":return nt(e,t);case"SEND_KEY":return He(He({},e),{},{keyPressed:t.keyPressed})}return e}}),ut=n(7);function st(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var ct=regeneratorRuntime.mark(Et),lt=regeneratorRuntime.mark(zt),ft=regeneratorRuntime.mark(At);function pt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function dt(e){return function(e){if(Array.isArray(e))return mt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return mt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return mt(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function bt(){var e=[].slice.call(arguments,2),t=Object(u.dispatch)(arguments[0]),n=arguments[1];t[n].apply(t,dt(e))}var yt=LP,ht=yt.camelCaseDashObjectKeys,gt=yt.Hook;function vt(e,t){return t="string"==typeof e?pt({},e,t):e,{type:"SET_QUIZ_DATA",data:ht(t)}}function Ot(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function wt(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function _t(e,t,n){return{type:"BEFORE_START_QUIZ"}}function jt(e,t,n,r){return gt.doAction("quiz-started",e,t,n,r),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:n,userId:r,results:e}}var Rt=regeneratorRuntime.mark((function e(){var t,n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Object(u.select)("learnpress/quiz").getDefaultRestArgs(),n=t.itemId,r=t.courseId,!0===gt.applyFilters("before-start-quiz",!0,n,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,Object(ut.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:n,course_id:r}});case 6:return o=e.sent,o=gt.applyFilters("request-start-quiz-response",o,n,r),e.next=10,bt("learnpress/quiz","__requestStartQuizSuccess",ht(o),n,r);case 10:case"end":return e.stop()}}),e)}));function qt(){return{type:"SUBMIT_QUIZ"}}function St(e,t,n){return gt.doAction("quiz-submitted",e,t,n),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function Et(){var e,t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(e=Object(u.select)("learnpress/quiz"),t=e.getDefaultRestArgs,n=e.getQuestionsSelectedAnswers,r=t(),o=r.itemId,i=r.courseId,!0===gt.applyFilters("before-submit-quiz",!0)){c.next=5;break}return c.abrupt("return");case 5:return a=n(),c.next=8,Object(ut.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:o,course_id:i,answered:a}});case 8:if(s=c.sent,!(s=gt.applyFilters("request-submit-quiz-response",s,o,i)).success){c.next=13;break}return c.next=13,bt("learnpress/quiz","__requestSubmitQuizSuccess",ht(s.results),o,i);case 13:case"end":return c.stop()}}),ct)}function Pt(e,t,n){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function kt(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function zt(e,t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,bt("learnpress/quiz","__requestShowHintSuccess",e,t);case 2:case"end":return n.stop()}}),lt)}function Qt(e,t){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?st(Object(n),!0).forEach((function(t){pt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):st(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({type:"CHECK_ANSWER",questionId:e},t)}function At(e){var t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return t=Object(u.select)("learnpress/quiz"),n=t.getDefaultRestArgs,r=t.getQuestionAnswered,o=n(),i=o.itemId,a=o.courseId,c.next=4,Object(ut.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:i,course_id:a,question_id:e,answered:r(e)||""}});case 4:return s=c.sent,c.next=7,bt("learnpress/quiz","__requestCheckAnswerSuccess",e,ht(s));case 7:case"end":return c.stop()}}),ft)}function It(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Nt(e){return{type:"SET_QUIZ_MODE",mode:e}}function Ct(e){return setTimeout((function(){bt("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}var Tt=lodash,xt=Tt.get,Dt=Tt.isArray,Ut=function(e,t){console.time("parseOptions");var n=Gt(e,t).options;return n=Dt(n)?n:JSON.parse(CryptoJS.AES.decrypt(n.data,n.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),n=Dt(n)?n:JSON.parse(n),console.timeEnd("parseOptions"),n};function Mt(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?xt(n,"userSettings.status"):""}function Lt(e,t,n){return e[t]||n}function Ht(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?xt(n,"userSettings.attempts"):[]}function Ft(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?xt(n,"userSettings.answered",{}):{}}function Bt(e){var t=e.userQuiz,n=xt(t,"questions");return n?Object.values(n):[]}function Kt(e,t){var n=e.userQuiz;return t?xt(n,t):n}function Wt(e){var t=e.userQuiz;return{itemId:t.id,courseId:t.courseId}}function Jt(e,t){var n=e.userQuiz;return xt(n,"answered.".concat(t,".answered"))||void 0}function Zt(e,t){var n=e.userQuiz;return xt(n,"answered.".concat(t,".mark"))||void 0}function $t(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=xt(e,"userQuiz.questionsPerPage")||1;if(n>1)return!1;var r=xt(e,"userQuiz.currentPage")||1;return xt(e,"object"===t?"userQuiz.questions[".concat(r-1,"]"):"userQuiz.questionIds[".concat(r-1,"]"))}var Gt=function(e,t){e.userQuiz;return Object(u.select)("learnpress/quiz").getQuestions().find((function(e){return e.id==t}))};function Vt(e,t){return-1!==(xt(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function Yt(e,t){}var Xt=function(e,t){var n=xt(e,"userQuiz.answered"),r={};for(var o in n)if(n.hasOwnProperty(o)&&(n[o].temp||n[o].blanks)){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}return r};function en(e){var t=e.userQuiz||{},n=t.answered,r=t.negativeMarking,o=t.questions,i=t.checkedQuestions,a=0,u=function(e){if(!n.hasOwnProperty(e))return s=e,"continue";e=parseInt(e);var t,u=n[e],c=u.questionMark?u.questionMark:(t=o.find((function(t){return s=e,t.id===e})),s=e,t?t.point:0);i.indexOf(e);if(u.temp)return s=e,"continue";r?u.answered&&(a=u.correct?a+u.mark:a-c):u.answered&&u.correct&&(a+=u.mark),s=e};for(var s in n)u(s);return a>0?a:0}var tn=n(4),nn=n.n(tn),rn={ENROLL_COURSE_X:function(e,t){}};var on=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=nn()(rn)(n)(e.dispatch),e.dispatch=t,e};function an(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function un(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var sn=LP.dataControls.controls,cn=Object(u.registerStore)("learnpress/quiz",{reducer:at,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?an(Object(n),!0).forEach((function(t){un(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):an(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},sn)});on(cn);function ln(e){return(ln="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function fn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function dn(e,t){return(dn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function mn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=hn(e);if(t){var o=hn(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return bn(this,n)}}function bn(e,t){return!t||"object"!==ln(t)&&"function"!=typeof t?yn(e):t}function yn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function hn(e){return(hn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function gn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var vn=lodash.chunk,On=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&dn(e,t)}(i,e);var t,n,r,o=mn(i);function i(e){var t;return fn(this,i),gn(yn(t=o.apply(this,arguments)),"startQuiz",(function(e){t.props.startQuiz()})),t.state={currentPage:1,numPages:0,pages:[]},t}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.settings,n=e.setQuizData,r=t.question_ids,o=t.questions_per_page,i=vn(r,o);t.currentPage=1,t.numPages=i.length,t.pages=i,n(t)}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.isReviewing,r=-1!==["","completed","viewed"].indexOf(t)||!t,o=-1!==["","viewed",void 0].indexOf(t)||!t;return void 0!==t&&React.createElement(React.Fragment,null,React.createElement("div",null,!n&&"completed"===t&&React.createElement(Ce,null),!n&&o&&React.createElement(p,null),!n&&o&&React.createElement(s,null),"started"===t&&React.createElement(De,null),(-1!==["completed","started"].indexOf(t)||n)&&React.createElement(qe,null),React.createElement(E,null),r&&!n&&React.createElement(Se,null)))}}])&&pn(t.prototype,n),r&&pn(t,r),i}(i.Component),wn=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getQuestions,r=t.getData;return{questions:n(),status:r("status"),store:r(),answered:r("answered"),isReviewing:"reviewing"===r("mode"),questionIds:r("questionIds"),checkCount:r("instantCheck"),questionsPerPage:r("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{setQuizData:t.setQuizData,startQuiz:t.startQuiz}}))])(On);n(8);function _n(e){return function(e){if(Array.isArray(e))return jn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return jn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return jn(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Rn=LP.modal.default,qn=(t.default=wn,function(e,t){wp.element.render(React.createElement(Rn,null,React.createElement(wn,{settings:t})),_n(document.querySelectorAll(e))[0]),LP.Hook.doAction("lp-quiz-compatible-builder")})}]);
1
+ this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.compose},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},a=i,u=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");a.elLPOverlay.show(),a.setTitleModal(t.dataset.title),a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");a.elLPOverlay.show(),a.setTitleModal(t.dataset.title),a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),a.callBackYes=function(){t.submit()}}))})))}});t.a=u},function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,i,a=n[r.type],u=t(r);if(a)for(o=0;o<a.length;o++)(i=a[o](r,e))&&e.dispatch(i);return u}}}).effects=n,t}},,function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n(5),o=n(4);function i(e,t,n,r,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,o)}function a(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;c(n),t.unobserve(n)}}))}));a(e).map((function(e){return t.observe(e)}))}},c=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,s,"next",e)}function s(e){i(a,r,o,u,s,"throw",e)}u(void 0)}))});return function(e){return t.apply(this,arguments)}}()},function(e,t){!function(){e.exports=this.LP.dataControls}()},function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,function(e,t,n){var r;
2
  /*!
3
  Copyright (c) 2018 Jed Watson.
4
  Licensed under the MIT License (MIT), see
5
  http://jedwatson.github.io/classnames
6
+ */!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return Sn}));var r={};n.r(r),n.d(r,"setQuizData",(function(){return Ot})),n.d(r,"setCurrentQuestion",(function(){return wt})),n.d(r,"setCurrentPage",(function(){return _t})),n.d(r,"__requestBeforeStartQuiz",(function(){return jt})),n.d(r,"__requestStartQuizSuccess",(function(){return Rt})),n.d(r,"startQuiz",(function(){return qt})),n.d(r,"__requestSubmitQuiz",(function(){return St})),n.d(r,"__requestSubmitQuizSuccess",(function(){return Pt})),n.d(r,"submitQuiz",(function(){return Et})),n.d(r,"updateUserQuestionAnswers",(function(){return kt})),n.d(r,"__requestShowHintSuccess",(function(){return zt})),n.d(r,"showHint",(function(){return Qt})),n.d(r,"__requestCheckAnswerSuccess",(function(){return At})),n.d(r,"checkAnswer",(function(){return It})),n.d(r,"markQuestionRendered",(function(){return Ct})),n.d(r,"setQuizMode",(function(){return Nt})),n.d(r,"sendKey",(function(){return Tt}));var o={};n.r(o),n.d(o,"getQuestionOptions",(function(){return Lt})),n.d(o,"getItemStatus",(function(){return Ut})),n.d(o,"getProp",(function(){return Ft})),n.d(o,"getQuizAttempts",(function(){return Ht})),n.d(o,"getQuizAnswered",(function(){return Bt})),n.d(o,"getQuestions",(function(){return Gt})),n.d(o,"getData",(function(){return Kt})),n.d(o,"getDefaultRestArgs",(function(){return Wt})),n.d(o,"getQuestionAnswered",(function(){return $t})),n.d(o,"getQuestionMark",(function(){return Jt})),n.d(o,"getCurrentQuestion",(function(){return Zt})),n.d(o,"getQuestion",(function(){return Yt})),n.d(o,"isCheckedAnswer",(function(){return Vt})),n.d(o,"isCorrect",(function(){return Xt})),n.d(o,"getQuestionsSelectedAnswers",(function(){return en})),n.d(o,"getUserMark",(function(){return tn}));var i=n(2),a=n(3),u=n(1),s=function(){var e=Object(u.select)("learnpress/quiz").getData("content");return React.createElement("div",{className:"quiz-content",dangerouslySetInnerHTML:{__html:e}})},c=n(0),l=function(e){var t;if(e>86400)t=(e-e%86400)/86400,e%=86400;else if(86400==e)return"24:00";var n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")},f=LP.Hook,p=function(){var e=function(e){return Object(u.select)("learnpress/quiz").getData(e)},t=f.applyFilters("quiz-meta-fields",{duration:{title:Object(c.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:Object(c.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:Object(c.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&React.createElement(React.Fragment,null,React.createElement("ul",{className:"quiz-intro"},Object.values(t).map((function(e,t){var n=e.name||t;return React.createElement("li",{key:"quiz-intro-field-".concat(t),className:"quiz-intro-item quiz-intro-item--".concat(n)},React.createElement("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),React.createElement("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,t){return(g=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function O(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=j(e);if(t){var o=j(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return w(this,n)}}function w(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function j(e){return(j=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var q=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&g(e,t)}(i,e);var t,n,r,o=O(i);function i(){var e;h(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return R(_(e=o.call.apply(o,[this].concat(n))),"startQuiz",(function(t){t&&t.preventDefault();var n=document.querySelector(".lp-button.start");n&&n.setAttribute("disabled","disabled");var r=e.props,o=r.startQuiz;if("completed"===r.status){var i=Object(u.select)("learnpress/modal"),a=i.confirm,s=i.isOpen;if("no"===a("Are you sure you want to retry quiz?",e.startQuiz))return void(!s()&&n&&n.removeAttribute("disabled"))}o()})),R(_(e),"nav",(function(t){return function(n){var r=e.props,o=r.questionNav,i=r.currentPage,a=r.numPages,u=r.setCurrentPage;switch(t){case"prev":i>1?i-=1:i="infinity"===o?a:1;break;default:i<a?i+=1:i="infinity"===o?1:a}u(i)}})),R(_(e),"moveTo",(function(t){return function(n){n.preventDefault();var r=e.props,o=r.numPages,i=r.setCurrentPage;t<1||t>o||i(t)}})),R(_(e),"isLast",(function(){var t=e.props;return t.currentPage===t.numPages})),R(_(e),"isFirst",(function(){return 1===e.props.currentPage})),R(_(e),"submit",(function(){var t=e.props.submitQuiz;"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),e.submit)&&t()})),R(_(e),"setQuizMode",(function(t){return function(){(0,e.props.setQuizMode)(t)}})),R(_(e),"isReviewing",(function(){return e.props.isReviewing})),e}return t=i,(n=[{key:"pageNumbers",value:function(e){var t=this,n=this.props,r=n.numPages,o=n.currentPage;if(r<2)return"";(e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({numPages:r,currentPage:o,midSize:1,endSize:1,prevNext:!0},e||{})).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);var i=m(Array(r).keys()),a=!1;return React.createElement("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&React.createElement("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},Object(c.__)("Prev","learnpress")),i.map((function(n){return(n+=1)===e.currentPage?(a=!0,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers current"},n)):n<=e.endSize||e.currentPage&&n>=e.currentPage-e.midSize&&n<=e.currentPage+e.midSize||n>e.numPages-e.endSize?(a=!0,React.createElement("button",{key:"page-number-".concat(n),className:"page-numbers",onClick:t.moveTo(n)},n)):a?(a=!1,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers dots"},"…")):""})),e.prevNext&&!this.isLast()&&React.createElement("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},Object(c.__)("Next","learnpress")))}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.questionNav,r=e.isReviewing,o=e.showReview,i=e.numPages,a=(e.question,e.questionsPerPage,e.canRetry),u=e.retakeNumber,s=["quiz-buttons"];("started"===t||r)&&s.push("align-center"),"questionNav"===n&&s.push("infinity"),this.isFirst()&&s.push("is-first"),this.isLast()&&s.push("is-last");var l=document.querySelector("#popup-sidebar"),f=document.querySelector("#learn-press-quiz-app"),p="";return p="started"===t||r?{marginLeft:l&&l.offsetWidth/2,width:f&&f.offsetWidth}:null,React.createElement(React.Fragment,null,React.createElement("div",{className:s.join(" ")},React.createElement("div",{className:"button-left"+("started"===t||r?" fixed":""),style:p},("completed"===t&&a||-1!==["","viewed"].indexOf(t))&&!r&&React.createElement("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===t?"".concat(Object(c._x)("Retake","label button retry quiz","learnpress")).concat(u?" (".concat(u,")"):""):Object(c._x)("Start","label button start quiz","learnpress")),("started"===t||r)&&i>1&&React.createElement(React.Fragment,null,React.createElement("div",{className:"questions-pagination"},this.pageNumbers()))),React.createElement("div",{className:"button-right"},"started"===t&&React.createElement(React.Fragment,null,("infinity"===n||this.isLast())&&!r&&React.createElement("button",{className:"lp-button submit-quiz",onClick:this.submit},Object(c.__)("Finish Quiz","learnpress"))),r&&o&&React.createElement("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},Object(c.__)("Result","learnpress")),"completed"===t&&o&&!r&&React.createElement("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},Object(c.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&React.createElement("div",{className:"learn-press-message error"},this.props.message))}}])&&v(t.prototype,n),r&&v(t,r),i}(i.Component),S=Object(a.compose)(Object(u.withSelect)((function(e){var t=e("learnpress/quiz").getData;return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((function(e){var t=e.showCheck,n=e.checkedQuestions,r=e.hintedQuestions,o=e.question,i=e.status,a=e.type,u=e.Button;if("started"!==i)return!1;var s=React.createElement(u,{question:o});switch(a){case"hint":return r?!!o.hasHint&&(-1===r.indexOf(o.id)&&s):s;case"check":return!!t&&(n?-1===n.indexOf(o.id)&&s:s)}})),P=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getData,r=t.getCurrentQuestion,o={id:n("id"),status:n("status"),questionIds:n("questionIds"),questionNav:n("questionNav"),isReviewing:n("reviewQuestions")&&"reviewing"===n("mode"),showReview:n("reviewQuestions"),showCheck:n("instantCheck"),checkedQuestions:n("checkedQuestions"),hintedQuestions:n("hintedQuestions"),numPages:n("numPages"),pages:n("pages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage"),pageNumbers:n("pageNumbers"),keyPressed:n("keyPressed"),canRetry:n("retakeCount")>0&&n("retaken")<n("retakeCount"),retakeNumber:n("retakeCount")>0&&n("retaken")<n("retakeCount")?n("retakeCount")-n("retaken"):null,message:n("messageResponse")||!1,success:void 0===n("successResponse")||n("successResponse")};return 1===o.questionsPerPage&&(o.question=r("object")),o})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz"),r=n.startQuiz,o=n.setCurrentQuestion,i=n.submitQuiz,a=n.setQuizMode,u=n.showHint,s=n.checkAnswer;return{startQuiz:r,setCurrentQuestion:o,setQuizMode:a,setCurrentPage:n.setCurrentPage,submitQuiz:function(e){i(e)},showHint:function(e){u(e)},checkAnswer:function(e){s(e)}}}))])(q);function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function z(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=N(e);if(t){var o=N(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return I(this,n)}}function I(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(i,e);var t,n,r,o=A(i);function i(){var e;k(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return T(C(e=o.call.apply(o,[this].concat(n))),"showHint",(function(){var t=e.props,n=t.showHint,r=t.question;n(r.id,!r.showHint)})),e}return t=i,(n=[{key:"render",value:function(){return this.props.question.hint?React.createElement("button",{className:"btn-show-hint",onClick:this.showHint},React.createElement("span",null,Object(c.__)("Hint","learnpress"))):""}}])&&z(t.prototype,n),r&&z(t,r),i}(i.Component),D=Object(a.compose)(Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").showHint;return{showHint:function(e,t){n(e,t)}}})))(x),M=n(12),L=n.n(M);function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function F(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=$(e);if(t){var o=$(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return K(this,n)}}function K(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?W(e):t}function W(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $(e){return($=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&B(e,t)}(i,e);var t,n,r,o=G(i);function i(){var e;return F(this,i),J(W(e=o.apply(this,arguments)),"checkAnswer",(function(){var t=e.props,n=t.checkAnswer,r=t.question;t.answered&&(n(r.id),e.setState({loading:!0}))})),e.state={loading:!1},e}return t=i,(n=[{key:"render",value:function(){var e=this.props.answered;return React.createElement(React.Fragment,null,React.createElement("button",{className:L()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},React.createElement("span",{className:"instant-check__icon"}),Object(c._x)("Check answer","label of button check answer","learnpress"),!e&&React.createElement("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:Object(c.__)("You need to answer the question before check answer.","learnpress")}})))}}])&&H(t.prototype,n),r&&H(t,r),i}(i.Component),Y=Object(a.compose)(Object(u.withSelect)((function(e,t){var n=t.question.id;return{answered:(0,e("learnpress/quiz").getQuestionAnswered)(n)}})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").checkAnswer;return{checkAnswer:function(e){n(e)}}})))(Z),V=function(e){var t=e.question,n={"instant-check":function(){return React.createElement(S,{type:"check",Button:Y,question:t})},hint:function(){return React.createElement(S,{type:"hint",Button:D,question:t})}};return React.createElement(React.Fragment,null,LP.config.questionFooterButtons().map((function(e){return React.createElement(i.Fragment,{key:"button-".concat(e)},n[e]&&n[e]())})))};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=se(e);if(t){var o=se(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ae(this,n)}}function ae(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=window.jQuery,fe=lodash,pe=(fe.uniqueId,fe.isArray),de=(fe.isNumber,fe.bind,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(a,e);var t,n,r,o=ie(a);function a(){var e;return ne(this,a),ce(ue(e=o.apply(this,arguments)),"setRef",(function(t){e.$wrap=le(t)})),ce(ue(e),"parseOptions",(function(e){return e&&(e=pe(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=pe(e)?e:JSON.parse(e)),e||[]})),ce(ue(e),"getWrapperClass",(function(){var t=e.props,n=t.question,r=(t.answered,["question","question-"+n.type]),o=e.parseOptions(n.options);return o.length&&void 0!==o[0].isTrue&&r.push("question-answered"),r})),ce(ue(e),"getEditLink",(function(){var t=e.props,n=t.question,r=t.editPermalink;return r?r.replace(/post=([0-9]{3,4})/,"post=".concat(n.id)):""})),ce(ue(e),"editPermalink",(function(e){return Object(c.sprintf)('<a href="%s">%s</a>',e,Object(c.__)("Edit","learnpress"))})),e.state={time:null,showHint:!1},e.$wrap=null,e}return t=a,(n=[{key:"componentDidMount",value:function(e){var t=this.props,n=t.question,r=t.isCurrent,o=t.markQuestionRendered;return r&&o(n.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),e}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.isShow,o=t.isShowIndex,a=(t.isShowHint,t.status),u=LP.questionTypes.default,s=this.getEditLink();s&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",s);var l={index:function(){return o?React.createElement("span",{className:"question-index"},o,"."):""},title:function(){return n.title},hint:function(){return React.createElement(D,{question:n})},"edit-permalink":function(){return s&&React.createElement("span",{dangerouslySetInnerHTML:{__html:e.editPermalink(s)},className:"edit-link"})}},f={title:function(){return React.createElement("h4",{className:"question-title"},LP.config.questionTitleParts().map((function(e){return React.createElement(i.Fragment,{key:"title-part-".concat(e)},l[e]&&l[e]())})))},content:function(){return React.createElement("div",{className:"question-content",dangerouslySetInnerHTML:{__html:n.content}})},"answer-options":function(){return e.$wrap&&React.createElement(u,te(te({},e.props),{},{$wrap:e.$wrap}))},explanation:function(){return n.explanation&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-explanation-content"},React.createElement("strong",{className:"explanation-title"},Object(c.__)("Explanation:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.explanation}})))},hint:function(){return n.hint&&!n.explanation&&n.showHint&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-hint-content"},React.createElement("strong",{className:"hint-title"},Object(c.__)("Hint:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.hint}})))},buttons:function(){return"started"===a&&React.createElement(V,{question:n})}},p=LP.config.questionBlocks();return React.createElement(React.Fragment,null,React.createElement("div",{className:this.getWrapperClass().join(" "),style:{display:r?"":"none"},"data-id":n.id,ref:this.setRef},p.map((function(e){return React.createElement(i.Fragment,{key:"block-".concat(e)},f[e]?f[e]():"")}))))}}])&&re(t.prototype,n),r&&re(t,r),a}(i.Component)),me=Object(a.compose)([Object(u.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.getQuestionAnswered,a=r.getQuestionMark;return{status:o("status"),questions:o("question"),answered:i(n),questionsRendered:o("questionsRendered"),editPermalink:o("editPermalink"),numPages:o("numPages"),mark:a(n)||""}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz"),n=t.updateUserQuestionAnswers;return{markQuestionRendered:t.markQuestionRendered,updateUserQuestionAnswers:n}}))])(de);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ve(e,t){return(ve=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ge(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return Oe(this,n)}}function Oe(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?we(e):t}function we(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function je(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Re=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ve(e,t)}(i,e);var t,n,r,o=ge(i);function i(e){var t;return ye(this,i),je(we(t=o.apply(this,arguments)),"startQuiz",(function(e){e.preventDefault(),(0,t.props.startQuiz)()})),je(we(t),"isInVisibleRange",(function(e,n){var r=t.props,o=r.currentPage,i=r.questionsPerPage;return o===Math.ceil(n/i)})),je(we(t),"nav",(function(e){var n=t.props.sendKey;switch(e.keyCode){case 37:return n("left");case 38:return;case 39:return n("right");case 40:return;default:e.keyCode>=49&&e.keyCode<=57&&n(e.keyCode-48)}})),t.needToTop=!1,t.state={isReviewing:null,currentPage:0,self:we(t)},t}return t=i,r=[{key:"getDerivedStateFromProps",value:function(e,t){for(var n=["isReviewing","currentPage"],r={},o=0;o<n.length;o++)e[n[o]]!==t[n[o]]&&(r[n[o]]=e[n[o]]);return Object.values(r).length?(t.self.needToTop=!0,r):null}}],(n=[{key:"componentDidUpdate",value:function(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}},{key:"render",value:function(){var e=this,t=this.props,n=t.status,r=t.currentQuestion,o=t.questions,i=t.questionsRendered,a=t.isReviewing,u=t.questionsPerPage,s=!0;return"completed"!==n||a||(s=!1),React.createElement(React.Fragment,null,React.createElement("div",{tabIndex:100,onKeyUp:this.nav},React.createElement("div",{className:"quiz-questions",style:{display:s?"":"none"}},o.map((function(t,n){var o=!u&&r===t.id,a=i&&-1!==i.indexOf(t.id),s=e.isInVisibleRange(t.id,n+1);return a||!a||s?React.createElement(me,{key:"loop-question-".concat(t.id),isCurrent:o,isShow:s,isShowIndex:!!u&&n+1,questionsPerPage:u,question:t}):""})))))}}])&&he(t.prototype,n),r&&he(t,r),i}(i.Component),qe=Object(a.compose)(Object(u.withSelect)((function(e,t,n){var r=e("learnpress/quiz"),o=r.getData,i=r.getQuestions;return{status:o("status"),currentQuestion:o("currentQuestion"),questions:i(),questionsRendered:o("questionsRendered"),isReviewing:"reviewing"===o("mode"),numPages:o("numPages"),currentPage:o("currentPage"),questionsPerPage:o("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{startQuiz:t.startQuiz,sendKey:t.sendKey}})))(Re),Se=function(){var e=Object(u.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&React.createElement(React.Fragment,null,React.createElement("div",{className:"quiz-attempts"},React.createElement("h4",{className:"attempts-heading"},Object(c.__)("Last Attempted","learnpress")),t&&React.createElement("table",null,React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",{className:"quiz-attempts__questions"},Object(c.__)("Questions","learnpress")),React.createElement("th",{className:"quiz-attempts__spend"},Object(c.__)("Time spend","learnpress")),React.createElement("th",{className:"quiz-attempts__marks"},Object(c.__)("Marks","learnpress")),React.createElement("th",{className:"quiz-attempts__grade"},Object(c.__)("Passing grade","learnpress")),React.createElement("th",{className:"quiz-attempts__result"},Object(c.__)("Result","learnpress")))),React.createElement("tbody",null,e.map((function(e,t){return React.createElement("tr",{key:"attempt-".concat(t)},React.createElement("td",{className:"quiz-attempts__questions"},"".concat(e.questionCorrect," / ").concat(e.questionCount)),React.createElement("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),React.createElement("td",{className:"quiz-attempts__marks"},"".concat(e.userMark," / ").concat(e.mark)),React.createElement("td",{className:"quiz-attempts__grade"},e.passingGrade||Object(c._x)("-","unknown passing grade value","learnpress")),React.createElement("td",{className:"quiz-attempts__result"},"".concat(parseFloat(e.result).toFixed(2),"%")," ",React.createElement("span",null,e.graduationText)))}))))))};function Pe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ee(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ke=function(){var e=Object(u.select)("learnpress/quiz").getData,t=Object(u.dispatch)("learnpress/quiz").submitQuiz,n=e("totalTime")?e("totalTime"):e("duration"),r=e("endTime"),o=new Date(r.replace(/-/g,"/")),a=new Date,s=(new Date).getTimezoneOffset(),c=parseInt(o.getTime()/1e3-(a.getTime()/1e3+60*s)),l=Pe(Object(i.useState)(c>0?c:0),2),f=l[0],p=l[1];Object(i.useEffect)((function(){var e=setInterval((function(){var n=f;(n-=1)>0?p(n):(clearInterval(e),t())}),1e3);return function(){return clearInterval(e)}}),[f]);return React.createElement("div",{className:"countdown"},React.createElement("i",{className:"fas fa-stopwatch"}),React.createElement("span",null,function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":",r=[];return n<3600?(r.push((f-f%60)/60),r.push(f%60)):n&&(r.push((f-f%3600)/3600),e=f%3600,r.push((e-e%60)/60),r.push(e%60)),r.map((function(e){return e<10?"0".concat(e):e})).join(t)}()))},ze=n(8);function Qe(e){return function(e){if(Array.isArray(e))return Ce(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||Ie(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ae(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=e[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||Ie(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,t){if(e){if("string"==typeof e)return Ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ce(e,t):void 0}}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=lodash.debounce,Te=function(){var e=Ae(Object(i.useState)(0),2),t=e[0],n=e[1],r=Ae(Object(i.useState)(!1),2),o=r[0],a=r[1],s=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("results")}),[]),l=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("passingGrade")}),[]),f=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("id")}),[]);Object(i.useEffect)((function(){d();var e="";if(e=s.graduation?s.graduation:s.result>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed"){var t=document.querySelector(".course-curriculum .course-item.course-item-".concat(f));t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}var n=Qe(document.querySelectorAll("#popup-header .items-progress"))[0];if(n){var r=n.querySelector(".items-completed");if(r){parseInt(r.textContent);var o=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");r.textContent=parseInt(o.length)}}p()}),[s]);var p=function(){var e=document.querySelectorAll(".popup-header__inner");0===e[0].querySelectorAll("form.form-button-finish-course").length&&Object(ze.a)(e[0])},d=function(){n(0),a(!1),jQuery.easing._customEasing=function(e,t,n,r,o){return r*Math.sqrt(1-(t=t/o-1)*t)+n},Ne((function(){var e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:s.result},{duration:1500,step:function(e,t){n(e)},done:function(){a(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),Ne((function(){jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),s.result>0?1e3:10)()},m=t;Number.isInteger(t)||(m=parseFloat(t).toFixed(2));var b=190*Math.PI,y=b-m/100*b,h={strokeDasharray:"".concat(b," ").concat(b),strokeDashoffset:y},v=s.passingGrade||l,g="";g=s.graduation?s.graduation:m>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed";var O="";O=s.graduationText?s.graduationText:"passed"===g?Object(c.__)("Passed","learnpress"):Object(c.__)("Failed","learnpress");var w=["quiz-result",g];return React.createElement("div",{className:w.join(" ")},React.createElement("h3",{className:"result-heading"},Object(c.__)("Your Result","learnpress")),React.createElement("div",{id:"quizResultGrade",className:"result-grade"},React.createElement("svg",{className:"circle-progress-bar",width:200,height:200},React.createElement("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:h,fill:"transparent",r:95,cx:100,cy:100})),React.createElement("span",{className:"result-achieved"},"".concat(m,"%")),React.createElement("span",{className:"result-require"},v||Object(c._x)("-","unknown passing grade value","learnpress"))),o&&React.createElement("p",{className:"result-message"},O),React.createElement("ul",{className:"result-statistic"},React.createElement("li",{className:"result-statistic-field result-time-spend"},React.createElement("span",null,Object(c.__)("Time spend","learnpress")),React.createElement("p",null,s.timeSpend)),React.createElement("li",{className:"result-statistic-field result-point"},React.createElement("span",null,Object(c.__)("Point","learnpress")),React.createElement("p",null,s.userMark," / ",s.mark)),React.createElement("li",{className:"result-statistic-field result-questions"},React.createElement("span",null,Object(c.__)("Questions","learnpress")),React.createElement("p",null,s.questionCount)),React.createElement("li",{className:"result-statistic-field result-questions-correct"},React.createElement("span",null,Object(c.__)("Correct","learnpress")),React.createElement("p",null,s.questionCorrect)),React.createElement("li",{className:"result-statistic-field result-questions-wrong"},React.createElement("span",null,Object(c.__)("Wrong","learnpress")),React.createElement("p",null,s.questionWrong)),React.createElement("li",{className:"result-statistic-field result-questions-skipped"},React.createElement("span",null,Object(c.__)("Skipped","learnpress")),React.createElement("p",null,s.questionEmpty))))},xe=jQuery,De=lodash.debounce,Me=function(){var e=Object(u.dispatch)("learnpress/quiz").submitQuiz;Object(i.useEffect)((function(){var e=xe("#popup-content");if(e.length){var t=e.find(".content-item-scrollable:eq(1)"),n=e.find(".content-item-wrap"),r=e.find(".quiz-status"),o=r.offset().top-92,i=!1,a="-"+n.css("margin-left");xe(window).on("resize.refresh-quiz-stauts-bar",De((function(){a="-"+n.css("margin-left"),r.css({"margin-left":a,"margin-right":a})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(function(){if(t.scrollTop()>=o){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}}),[]);var t=Object(u.select)("learnpress/quiz"),n=t.getData,r=t.getUserMark,o=n("currentPage"),a=n("questionsPerPage"),s=n("questionIds").length,l=n("submitting"),f=n("totalTime"),p=n("duration"),d=r(),m=["quiz-status"],b=(o-1)*a+1,y=b+a-1,h="";return y=Math.min(y,s),l&&m.push("submitting"),h=y<s?a>1?Object(c.sprintf)(Object(c.__)("Question <span>%d to %d of %d</span>","learnpress"),b,y,s):Object(c.sprintf)(Object(c.__)("Question <span>%d of %d</span>","learnpress"),b,s):Object(c.sprintf)(Object(c.__)("Question <span>%d to %d</span>","learnpress"),b,y),React.createElement("div",{className:m.join(" ")},React.createElement("div",null,React.createElement("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:h}}),React.createElement("div",{className:"current-point"},Object(c.sprintf)(Object(c.__)("Earned Point: %s","learnpress"),d)),React.createElement("div",null,React.createElement("div",{className:"submit-quiz"},React.createElement("button",{className:"lp-button",id:"button-submit-quiz",onClick:function t(){"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),t)&&e()}},l?Object(c.__)("Submitting...","learnpress"):Object(c.__)("Finish Quiz","learnpress"))),f&&p&&React.createElement(ke,null))))};function Le(e){return function(e){if(Array.isArray(e))return Ue(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ue(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(n),!0).forEach((function(t){Be(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ge=lodash,Ke=(Ge.omit,Ge.flow),We=Ge.isArray,$e=Ge.chunk,Je=(LP.camelCaseDashObjectKeys,LP.localStorage),Ze=Je.get,Ye=Je.set,Ve={},Xe=function(e,t){var n=He(He({},e.answered[t.questionId]||{}),{},{answered:t.answers,temp:!0});return He(He({},e),{},{answered:He(He({},e.answered),{},Be({},t.questionId,n))})},et=function(e,t){var n=e.questionsRendered;return We(n)?(n.push(t.questionId),He(He({},e),{},{questionsRendered:Le(n)})):He(He({},e),{},{questionsRendered:[t.questionId]})},tt=function(e,t){return t.currentPage&&Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),t)},nt=function(e,t){var n=e.questions.map((function(e){return e.id==t.questionId?He(He({},e),{},{showHint:t.showHint}):e}));return He(He({},e),{},{questions:Le(n)})},rt=function(e,t){var n=e.questions.map((function(e){if(e.id!==t.questionId)return e;var n={explanation:t.explanation};return t.options&&(n.options=t.options),He(He({},e),n)}));return He(He({},e),{},{questions:Le(n),answered:He(He({},e.answered),{},Be({},t.questionId,t.result)),checkedQuestions:[].concat(Le(e.checkedQuestions),[t.questionId])})},ot=function(e,t){var n=e.questions.map((function(n){var r={};return e.reviewQuestions&&(t.results.questions[n.id].explanation&&(r.explanation=t.results.questions[n.id].explanation),t.results.questions[n.id].options&&(r.options=t.results.questions[n.id].options)),He(He({},n),r)}));return tt(e,He(He({submitting:!1,currentPage:1},t.results),{},{questions:Le(n)}))},it=function(e,t){var n=void 0!==t.results.success&&t.results.success,r=t.results.message||!1;return tt(e,He(He({checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1},t.results.results),{},{successResponse:n,messageResponse:r}))},at=Ke(u.combineReducers,(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}))({a:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1};return e},b:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2};return e}}),ut=Object(u.combineReducers)({blocks:at,userQuiz:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);var n=$e(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=n.length,t.data.pages=n,He(He(He({},e),t.data),{},{currentPage:Ze("Q".concat(t.data.id,".currentPage"))||t.data.currentPage});case"SUBMIT_QUIZ":return He(He({},e),{},{submitting:!0});case"START_QUIZ":case"START_QUIZ_SUCCESS":return it(e,t);case"SET_CURRENT_QUESTION":return Ye("Q".concat(e.id,".currentQuestion"),t.questionId),He(He({},e),{},{currentQuestion:t.questionId});case"SET_CURRENT_PAGE":return Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),{},{currentPage:t.currentPage});case"SUBMIT_QUIZ_SUCCESS":return ot(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?Xe(e,t):e;case"MARK_QUESTION_RENDERED":return et(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?tt(e,{mode:t.mode}):He(He({},e),{},{mode:t.mode});case"SET_QUESTION_HINT":return nt(e,t);case"CHECK_ANSWER":return rt(e,t);case"SEND_KEY":return He(He({},e),{},{keyPressed:t.keyPressed})}return e}}),st=n(9);function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var lt=regeneratorRuntime.mark(Et),ft=regeneratorRuntime.mark(Qt),pt=regeneratorRuntime.mark(It);function dt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(e){return function(e){if(Array.isArray(e))return bt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return bt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return bt(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yt(){var e=[].slice.call(arguments,2),t=Object(u.dispatch)(arguments[0]),n=arguments[1];t[n].apply(t,mt(e))}var ht=LP,vt=ht.camelCaseDashObjectKeys,gt=ht.Hook;function Ot(e,t){return t="string"==typeof e?dt({},e,t):e,{type:"SET_QUIZ_DATA",data:vt(t)}}function wt(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function _t(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function jt(e,t,n){return{type:"BEFORE_START_QUIZ"}}function Rt(e,t,n,r){return gt.doAction("quiz-started",e,t,n,r),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:n,userId:r,results:e}}var qt=regeneratorRuntime.mark((function e(){var t,n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Object(u.select)("learnpress/quiz").getDefaultRestArgs(),n=t.itemId,r=t.courseId,!0===gt.applyFilters("before-start-quiz",!0,n,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,Object(st.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:n,course_id:r}});case 6:return o=e.sent,o=gt.applyFilters("request-start-quiz-response",o,n,r),e.next=10,yt("learnpress/quiz","__requestStartQuizSuccess",vt(o),n,r);case 10:case"end":return e.stop()}}),e)}));function St(){return{type:"SUBMIT_QUIZ"}}function Pt(e,t,n){return gt.doAction("quiz-submitted",e,t,n),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function Et(){var e,t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(e=Object(u.select)("learnpress/quiz"),t=e.getDefaultRestArgs,n=e.getQuestionsSelectedAnswers,r=t(),o=r.itemId,i=r.courseId,!0===gt.applyFilters("before-submit-quiz",!0)){c.next=5;break}return c.abrupt("return");case 5:return a=n(),c.next=8,Object(st.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:o,course_id:i,answered:a}});case 8:if(s=c.sent,!(s=gt.applyFilters("request-submit-quiz-response",s,o,i)).success){c.next=13;break}return c.next=13,yt("learnpress/quiz","__requestSubmitQuizSuccess",vt(s.results),o,i);case 13:case"end":return c.stop()}}),lt)}function kt(e,t,n){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function zt(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function Qt(e,t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yt("learnpress/quiz","__requestShowHintSuccess",e,t);case 2:case"end":return n.stop()}}),ft)}function At(e,t){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach((function(t){dt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({type:"CHECK_ANSWER",questionId:e},t)}function It(e){var t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return t=Object(u.select)("learnpress/quiz"),n=t.getDefaultRestArgs,r=t.getQuestionAnswered,o=n(),i=o.itemId,a=o.courseId,c.next=4,Object(st.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:i,course_id:a,question_id:e,answered:r(e)||""}});case 4:return s=c.sent,c.next=7,yt("learnpress/quiz","__requestCheckAnswerSuccess",e,vt(s));case 7:case"end":return c.stop()}}),pt)}function Ct(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Nt(e){return{type:"SET_QUIZ_MODE",mode:e}}function Tt(e){return setTimeout((function(){yt("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}var xt=lodash,Dt=xt.get,Mt=xt.isArray,Lt=function(e,t){console.time("parseOptions");var n=Yt(e,t).options;return n=Mt(n)?n:JSON.parse(CryptoJS.AES.decrypt(n.data,n.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),n=Mt(n)?n:JSON.parse(n),console.timeEnd("parseOptions"),n};function Ut(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.status"):""}function Ft(e,t,n){return e[t]||n}function Ht(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.attempts"):[]}function Bt(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.answered",{}):{}}function Gt(e){var t=e.userQuiz,n=Dt(t,"questions");return n?Object.values(n):[]}function Kt(e,t){var n=e.userQuiz;return t?Dt(n,t):n}function Wt(e){var t=e.userQuiz;return{itemId:t.id,courseId:t.courseId}}function $t(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".answered"))||void 0}function Jt(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".mark"))||void 0}function Zt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=Dt(e,"userQuiz.questionsPerPage")||1;if(n>1)return!1;var r=Dt(e,"userQuiz.currentPage")||1;return Dt(e,"object"===t?"userQuiz.questions[".concat(r-1,"]"):"userQuiz.questionIds[".concat(r-1,"]"))}var Yt=function(e,t){e.userQuiz;return Object(u.select)("learnpress/quiz").getQuestions().find((function(e){return e.id==t}))};function Vt(e,t){return-1!==(Dt(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function Xt(e,t){}var en=function(e,t){var n=Dt(e,"userQuiz.answered"),r={};for(var o in n)if(n.hasOwnProperty(o)&&(n[o].temp||n[o].blanks)){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}return r};function tn(e){var t=e.userQuiz||{},n=t.answered,r=t.negativeMarking,o=t.questions,i=t.checkedQuestions,a=0,u=function(e){if(!n.hasOwnProperty(e))return s=e,"continue";e=parseInt(e);var t,u=n[e],c=u.questionMark?u.questionMark:(t=o.find((function(t){return s=e,t.id===e})),s=e,t?t.point:0);i.indexOf(e);if(u.temp)return s=e,"continue";r?u.answered&&(a=u.correct?a+u.mark:a-c):u.answered&&u.correct&&(a+=u.mark),s=e};for(var s in n)u(s);return a>0?a:0}var nn=n(6),rn=n.n(nn),on={ENROLL_COURSE_X:function(e,t){}};var an=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=rn()(on)(n)(e.dispatch),e.dispatch=t,e};function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var cn=LP.dataControls.controls,ln=Object(u.registerStore)("learnpress/quiz",{reducer:ut,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach((function(t){sn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},cn)});an(ln);function fn(e){return(fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function mn(e,t){return(mn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function bn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=vn(e);if(t){var o=vn(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return yn(this,n)}}function yn(e,t){return!t||"object"!==fn(t)&&"function"!=typeof t?hn(e):t}function hn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vn(e){return(vn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function gn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var On=lodash.chunk,wn=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mn(e,t)}(i,e);var t,n,r,o=bn(i);function i(e){var t;return pn(this,i),gn(hn(t=o.apply(this,arguments)),"startQuiz",(function(e){t.props.startQuiz()})),t.state={currentPage:1,numPages:0,pages:[]},t}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.settings,n=e.setQuizData,r=t.question_ids,o=t.questions_per_page,i=On(r,o);t.currentPage=1,t.numPages=i.length,t.pages=i,n(t)}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.isReviewing,r=-1!==["","completed","viewed"].indexOf(t)||!t,o=-1!==["","viewed",void 0].indexOf(t)||!t;return void 0!==t&&React.createElement(React.Fragment,null,React.createElement("div",null,!n&&"completed"===t&&React.createElement(Te,null),!n&&o&&React.createElement(p,null),!n&&o&&React.createElement(s,null),"started"===t&&React.createElement(Me,null),(-1!==["completed","started"].indexOf(t)||n)&&React.createElement(qe,null),React.createElement(P,null),r&&!n&&React.createElement(Se,null)))}}])&&dn(t.prototype,n),r&&dn(t,r),i}(i.Component),_n=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getQuestions,r=t.getData;return{questions:n(),status:r("status"),store:r(),answered:r("answered"),isReviewing:"reviewing"===r("mode"),questionIds:r("questionIds"),checkCount:r("instantCheck"),questionsPerPage:r("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{setQuizData:t.setQuizData,startQuiz:t.startQuiz}}))])(wn);n(10);function jn(e){return function(e){if(Array.isArray(e))return Rn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Rn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Rn(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var qn=LP.modal.default,Sn=(t.default=_n,function(e,t){wp.element.render(React.createElement(qn,null,React.createElement(_n,{settings:t})),jn(document.querySelectorAll(e))[0]),LP.Hook.doAction("lp-quiz-compatible-builder")})}]);
assets/js/dist/frontend/single-course.js CHANGED
@@ -397,11 +397,11 @@ var retakeCourse = function retakeCourse() {
397
  return;
398
  }
399
 
400
- var elButtonRetakeCourse = elFormRetakeCourse.querySelector('.button-retake-course');
401
  var elCourseId = elFormRetakeCourse.querySelector('[name=retake-course]').value;
402
  var elAjaxMessage = elFormRetakeCourse.querySelector('.lp-ajax-message');
403
 
404
- var submit = function submit() {
405
  wp.apiFetch({
406
  path: '/lp/v1/courses/retake-course',
407
  method: 'POST',
@@ -424,7 +424,7 @@ var retakeCourse = function retakeCourse() {
424
  }
425
  })["catch"](function (err) {
426
  elAjaxMessage.classList.add('error');
427
- elAjaxMessage.innerHTML = 'error: ' + err.data.status + ' ' + err.message;
428
  }).then(function () {
429
  elButtonRetakeCourse.classList.remove('loading');
430
  elButtonRetakeCourse.disabled = false;
@@ -435,11 +435,13 @@ var retakeCourse = function retakeCourse() {
435
  elFormRetakeCourse.addEventListener('submit', function (e) {
436
  e.preventDefault();
437
  });
438
- elButtonRetakeCourse.addEventListener('click', function (e) {
439
- e.preventDefault();
440
- elButtonRetakeCourse.classList.add('loading');
441
- elButtonRetakeCourse.disabled = true;
442
- submit();
 
 
443
  });
444
  }; // Rest API load content course progress - Nhamdv.
445
 
@@ -810,7 +812,12 @@ var lpModalOverlay = {
810
  elFooter: null,
811
  elCalledModal: null,
812
  callBackYes: null,
 
813
  init: function init() {
 
 
 
 
814
  this.elLPOverlay = $('.lp-overlay');
815
 
816
  if (!this.elLPOverlay.length) {
@@ -826,11 +833,15 @@ var lpModalOverlay = {
826
  $(document).on('click', '.close, .btn-no', function () {
827
  elLPOverlay.hide();
828
  });
829
- $(document).on('click', '.btn-yes', function () {
 
 
 
830
  if ('function' === typeof lpModalOverlay.callBackYes) {
831
  lpModalOverlay.callBackYes();
832
  }
833
  });
 
834
  return true;
835
  },
836
  setElCalledModal: function setElCalledModal(elCalledModal) {
397
  return;
398
  }
399
 
400
+ var elButtonRetakeCourses = elFormRetakeCourse.querySelectorAll('.button-retake-course');
401
  var elCourseId = elFormRetakeCourse.querySelector('[name=retake-course]').value;
402
  var elAjaxMessage = elFormRetakeCourse.querySelector('.lp-ajax-message');
403
 
404
+ var submit = function submit(elButtonRetakeCourse) {
405
  wp.apiFetch({
406
  path: '/lp/v1/courses/retake-course',
407
  method: 'POST',
424
  }
425
  })["catch"](function (err) {
426
  elAjaxMessage.classList.add('error');
427
+ elAjaxMessage.innerHTML = 'error: ' + err.message;
428
  }).then(function () {
429
  elButtonRetakeCourse.classList.remove('loading');
430
  elButtonRetakeCourse.disabled = false;
435
  elFormRetakeCourse.addEventListener('submit', function (e) {
436
  e.preventDefault();
437
  });
438
+ elButtonRetakeCourses.forEach(function (element) {
439
+ return element.addEventListener('click', function (e) {
440
+ e.preventDefault();
441
+ element.classList.add('loading');
442
+ element.disabled = true;
443
+ submit(element);
444
+ });
445
  });
446
  }; // Rest API load content course progress - Nhamdv.
447
 
812
  elFooter: null,
813
  elCalledModal: null,
814
  callBackYes: null,
815
+ instance: null,
816
  init: function init() {
817
+ if (this.instance) {
818
+ return true;
819
+ }
820
+
821
  this.elLPOverlay = $('.lp-overlay');
822
 
823
  if (!this.elLPOverlay.length) {
833
  $(document).on('click', '.close, .btn-no', function () {
834
  elLPOverlay.hide();
835
  });
836
+ $(document).on('click', '.btn-yes', function (e) {
837
+ e.preventDefault();
838
+ e.stopPropagation();
839
+
840
  if ('function' === typeof lpModalOverlay.callBackYes) {
841
  lpModalOverlay.callBackYes();
842
  }
843
  });
844
+ this.instance = this;
845
  return true;
846
  },
847
  setElCalledModal: function setElCalledModal(elCalledModal) {
assets/js/dist/frontend/single-course.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.singleCourse=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=22)}([,,function(e,t){e.exports=window.wp.element},,,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return s}));var i=jQuery,a=lodash.throttle,s=function(){var e,t=i("#popup-course"),n=i("#learn-press-course-curriculum");i("#sidebar-toggle").on("change",(function(e){LP.Cookies.set("sidebar-toggle",e.target.checked),o(e.target.checked)}));var o=function(e){i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),e?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open")};o(LP.Cookies.get("sidebar-toggle")),n.find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))})),t.length&&(n.on("scroll",a((function(){var t=i(this);t.addClass("scrolling"),e&&clearTimeout(e),e=setTimeout((function(){t.removeClass("scrolling")}),1e3)}),500)),LP.toElement(".course-item.current",{container:".curriculum-scrollable:eq(1)",offset:100,duration:1}))}},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,init:function(){return this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(){"function"==typeof i.callBackYes&&i.callBackYes()})),!0)},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},a=i,s=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");a.elLPOverlay.show(),a.setTitleModal(t.dataset.title),a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");a.elLPOverlay.show(),a.setTitleModal(t.dataset.title),a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),a.callBackYes=function(){t.submit()}}))})))}});t.a=s},,,,function(e,t){e.exports=window.wp.url},,,function(e,t){!function(){e.exports=this.LP.quiz}()},function(e,t){},,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return h})),n.d(t,"initCourseTabs",(function(){return w})),n.d(t,"initCourseSidebar",(function(){return S})),n.d(t,"enrollCourse",(function(){return C}));var r=n(2),o=(n(13),n(14),n(5));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(i,e);var t,n,r,o=c(i);function i(){return a(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"render",value:function(){return React.createElement(React.Fragment,null)}}])&&s(t.prototype,n),r&&s(t,r),i}(r.Component);window.addEventListener("DOMContentLoaded",(function(){Object(o.a)()}));n(10);var p=n(6);function v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function b(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){y(i,r,o,a,s,"next",e)}function s(e){y(i,r,o,a,s,"throw",e)}a(void 0)}))}}t.default=f;var h=function(){wp.element.render(React.createElement(f,null))},g=jQuery,w=function(){g("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){var t=g('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),g('label[for="'+g(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")}))},S=function(){var e=g(".course-summary-sidebar");if(e.length){var t=g(window),n=e.children(),r=e.offset(),o=e.height(),i=n.height(),a=32;t.on("scroll.fixed-course-sidebar",(function(){var s=t.scrollTop()-r.top+a;if(s<0)return e.removeClass("slide-top slide-down"),void n.css("top","");s>o-i?(e.removeClass("slide-down").addClass("slide-top"),n.css("top",o-i)):(e.removeClass("slide-top").addClass("slide-down"),n.css("top",a))})).trigger("scroll.fixed-course-sidebar")}},C=function(){var e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((function(e){var t=function(){var t=b(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(r.style.display="none",e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),form.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(function(e){(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))},L=function(){var e=document.querySelector(".lp-form-retake-course");if(e){var t=e.querySelector(".button-retake-course"),n=e.querySelector("[name=retake-course]").value,r=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(function(e){e.preventDefault()})),t.addEventListener("click",(function(e){e.preventDefault(),t.classList.add("loading"),t.disabled=!0,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:n}}).then((function(e){var n=e.status,o=e.message,i=e.data;r.innerHTML=o,null!=n&&"success"===n?(t.style.display="none",setTimeout((function(){window.location.replace(i.url_redirect)}),1e3)):r.classList.add("error")})).catch((function(e){r.classList.add("error"),r.innerHTML="error: "+e.data.status+" "+e.message})).then((function(){t.classList.remove("loading"),t.disabled=!1,r.style.display="block"}))}))}};g(window).on("load",(function(){var e;g("#popup-course"),g("#learn-press-course-curriculum");v(document.querySelectorAll(".course-extra-box")).map((function(e){var t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(function(){var n=t.nextElementSibling,r=document.querySelector(".course-extra-box.active");r&&!e.classList.contains("active")&&(r.classList.remove("active"),r.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),n.style.display="none"):(e.classList.add("active"),n.style.display="block")}))})),w(),S(),C(),(e=document.querySelectorAll("form.purchase-course")).length>0&&e.forEach((function(e){var t=function(){var t=b(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),"success"===i&&a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),e.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=purchase-course]").value,o=e.querySelector("button.button-purchase-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),L(),function(){var e=document.querySelectorAll(".lp-course-progress-wrapper");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,r){e.forEach((function(e){if(e.isIntersecting){var r=e.target;setTimeout((function(){n(r)}),600),t.unobserve(r)}}))}));v(e).map((function(e){return t.observe(e)}))}var n=function(){var e=b(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}});case 2:n=e.sent,r=n.data,t.innerHTML=r;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}(),p.a.init()}))}]);
1
+ this.LP=this.LP||{},this.LP.singleCourse=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=23)}({14:function(e,t){!function(){e.exports=this.LP.quiz}()},15:function(e,t){},2:function(e,t){e.exports=window.wp.element},23:function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return b})),n.d(t,"initCourseTabs",(function(){return w})),n.d(t,"initCourseSidebar",(function(){return S})),n.d(t,"enrollCourse",(function(){return C}));var r=n(2),o=(n(14),n(15),n(7));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(i,e);var t,n,r,o=c(i);function i(){return a(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"render",value:function(){return React.createElement(React.Fragment,null)}}])&&s(t.prototype,n),r&&s(t,r),i}(r.Component);window.addEventListener("DOMContentLoaded",(function(){Object(o.a)()}));n(5);var p=n(4);function v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){y(i,r,o,a,s,"next",e)}function s(e){y(i,r,o,a,s,"throw",e)}a(void 0)}))}}t.default=f;var b=function(){wp.element.render(React.createElement(f,null))},g=jQuery,w=function(){g("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){var t=g('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),g('label[for="'+g(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")}))},S=function(){var e=g(".course-summary-sidebar");if(e.length){var t=g(window),n=e.children(),r=e.offset(),o=e.height(),i=n.height(),a=32;t.on("scroll.fixed-course-sidebar",(function(){var s=t.scrollTop()-r.top+a;if(s<0)return e.removeClass("slide-top slide-down"),void n.css("top","");s>o-i?(e.removeClass("slide-down").addClass("slide-top"),n.css("top",o-i)):(e.removeClass("slide-top").addClass("slide-down"),n.css("top",a))})).trigger("scroll.fixed-course-sidebar")}},C=function(){var e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(r.style.display="none",e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),form.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(function(e){(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))},L=function(){var e=document.querySelector(".lp-form-retake-course");if(e){var t=e.querySelectorAll(".button-retake-course"),n=e.querySelector("[name=retake-course]").value,r=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(function(e){e.preventDefault()})),t.forEach((function(e){return e.addEventListener("click",(function(t){var o;t.preventDefault(),e.classList.add("loading"),e.disabled=!0,o=e,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:n}}).then((function(e){var t=e.status,n=e.message,i=e.data;r.innerHTML=n,null!=t&&"success"===t?(o.style.display="none",setTimeout((function(){window.location.replace(i.url_redirect)}),1e3)):r.classList.add("error")})).catch((function(e){r.classList.add("error"),r.innerHTML="error: "+e.message})).then((function(){o.classList.remove("loading"),o.disabled=!1,r.style.display="block"}))}))}))}};g(window).on("load",(function(){var e;g("#popup-course"),g("#learn-press-course-curriculum");v(document.querySelectorAll(".course-extra-box")).map((function(e){var t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(function(){var n=t.nextElementSibling,r=document.querySelector(".course-extra-box.active");r&&!e.classList.contains("active")&&(r.classList.remove("active"),r.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),n.style.display="none"):(e.classList.add("active"),n.style.display="block")}))})),w(),S(),C(),(e=document.querySelectorAll("form.purchase-course")).length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),"success"===i&&a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),e.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=purchase-course]").value,o=e.querySelector("button.button-purchase-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),L(),function(){var e=document.querySelectorAll(".lp-course-progress-wrapper");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,r){e.forEach((function(e){if(e.isIntersecting){var r=e.target;setTimeout((function(){n(r)}),600),t.unobserve(r)}}))}));v(e).map((function(e){return t.observe(e)}))}var n=function(){var e=h(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}});case 2:n=e.sent,r=n.data,t.innerHTML=r;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}(),p.a.init()}))},4:function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},a=i,s=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");a.elLPOverlay.show(),a.setTitleModal(t.dataset.title),a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");a.elLPOverlay.show(),a.setTitleModal(t.dataset.title),a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),a.callBackYes=function(){t.submit()}}))})))}});t.a=s},5:function(e,t){e.exports=window.wp.url},7:function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return s}));var i=jQuery,a=lodash.throttle,s=function(){var e,t=i("#popup-course"),n=i("#learn-press-course-curriculum");i("#sidebar-toggle").on("change",(function(e){LP.Cookies.set("sidebar-toggle",e.target.checked),o(e.target.checked)}));var o=function(e){i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),e?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open")};o(LP.Cookies.get("sidebar-toggle")),n.find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))})),t.length&&(n.on("scroll",a((function(){var t=i(this);t.addClass("scrolling"),e&&clearTimeout(e),e=setTimeout((function(){t.removeClass("scrolling")}),1e3)}),500)),LP.toElement(".course-item.current",{container:".curriculum-scrollable:eq(1)",offset:100,duration:1}))}}});
assets/js/dist/frontend/single-curriculum.js CHANGED
@@ -328,6 +328,103 @@ LP.Hook.addAction('lp-question-compatible-builder', function () {
328
 
329
  /***/ }),
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/progress.js":
332
  /*!*********************************************************************************************************************************************************************************************!*\
333
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/progress.js ***!
@@ -554,8 +651,9 @@ __webpack_require__.r(__webpack_exports__);
554
  /* harmony import */ var _components_sidebar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/sidebar */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/sidebar.js");
555
  /* harmony import */ var _components_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/progress */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/progress.js");
556
  /* harmony import */ var _components_comment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/comment */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/comment.js");
557
- /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/compatible */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/compatible.js");
558
- /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_components_compatible__WEBPACK_IMPORTED_MODULE_5__);
 
559
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
560
 
561
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -586,6 +684,7 @@ var $ = jQuery;
586
 
587
 
588
 
 
589
  var SingleCurriculums = /*#__PURE__*/function (_Component) {
590
  _inherits(SingleCurriculums, _Component);
591
 
@@ -630,7 +729,8 @@ window.addEventListener('DOMContentLoaded', function () {
630
  Object(_components_search__WEBPACK_IMPORTED_MODULE_1__["searchCourseContent"])();
631
  Object(_components_sidebar__WEBPACK_IMPORTED_MODULE_2__["Sidebar"])();
632
  Object(_components_progress__WEBPACK_IMPORTED_MODULE_3__["progressBar"])();
633
- Object(_components_comment__WEBPACK_IMPORTED_MODULE_4__["commentForm"])(); // Check duration expire of course
 
634
 
635
  var singleCurriculums = new SingleCurriculums();
636
  singleCurriculums.checkCourseDurationExpire();
@@ -717,7 +817,12 @@ var lpModalOverlay = {
717
  elFooter: null,
718
  elCalledModal: null,
719
  callBackYes: null,
 
720
  init: function init() {
 
 
 
 
721
  this.elLPOverlay = $('.lp-overlay');
722
 
723
  if (!this.elLPOverlay.length) {
@@ -733,11 +838,15 @@ var lpModalOverlay = {
733
  $(document).on('click', '.close, .btn-no', function () {
734
  elLPOverlay.hide();
735
  });
736
- $(document).on('click', '.btn-yes', function () {
 
 
 
737
  if ('function' === typeof lpModalOverlay.callBackYes) {
738
  lpModalOverlay.callBackYes();
739
  }
740
  });
 
741
  return true;
742
  },
743
  setElCalledModal: function setElCalledModal(elCalledModal) {
@@ -767,6 +876,17 @@ var lpModalOverlay = {
767
 
768
  (function() { module.exports = window["wp"]["element"]; }());
769
 
 
 
 
 
 
 
 
 
 
 
 
770
  /***/ })
771
 
772
  /******/ });
328
 
329
  /***/ }),
330
 
331
+ /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/items-progress.js":
332
+ /*!***************************************************************************************************************************************************************************************************!*\
333
+ !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/items-progress.js ***!
334
+ \***************************************************************************************************************************************************************************************************/
335
+ /*! exports provided: itemsProgress, getResponse */
336
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
337
+
338
+ "use strict";
339
+ __webpack_require__.r(__webpack_exports__);
340
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "itemsProgress", function() { return itemsProgress; });
341
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getResponse", function() { return getResponse; });
342
+ /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
343
+ /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
344
+ /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../show-lp-overlay-complete-item */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
345
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
346
+
347
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
348
+
349
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
350
+
351
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
352
+
353
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
354
+
355
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
356
+
357
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
358
+
359
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
360
+
361
+ // Rest API load content course progress - Nhamdv.
362
+
363
+
364
+ var itemsProgress = function itemsProgress() {
365
+ var elements = document.querySelectorAll('.popup-header__inner');
366
+
367
+ if (!elements.length) {
368
+ return;
369
+ }
370
+
371
+ if (document.querySelector('#learn-press-quiz-app div.quiz-result') !== null) {
372
+ return;
373
+ }
374
+
375
+ if ('IntersectionObserver' in window) {
376
+ var eleObserver = new IntersectionObserver(function (entries, observer) {
377
+ entries.forEach(function (entry) {
378
+ if (entry.isIntersecting) {
379
+ var ele = entry.target;
380
+ getResponse(ele);
381
+ eleObserver.unobserve(ele);
382
+ }
383
+ });
384
+ });
385
+
386
+ _toConsumableArray(elements).map(function (ele) {
387
+ return eleObserver.observe(ele);
388
+ });
389
+ }
390
+ };
391
+ var getResponse = /*#__PURE__*/function () {
392
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ele) {
393
+ var response, data;
394
+ return regeneratorRuntime.wrap(function _callee$(_context) {
395
+ while (1) {
396
+ switch (_context.prev = _context.next) {
397
+ case 0:
398
+ _context.next = 2;
399
+ return wp.apiFetch({
400
+ path: Object(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__["addQueryArgs"])('lp/v1/lazy-load/items-progress', {
401
+ courseId: lpGlobalSettings.post_id || '',
402
+ userId: lpGlobalSettings.user_id || ''
403
+ }),
404
+ method: 'GET'
405
+ });
406
+
407
+ case 2:
408
+ response = _context.sent;
409
+ data = response.data;
410
+ ele.innerHTML += data;
411
+ _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init();
412
+
413
+ case 6:
414
+ case "end":
415
+ return _context.stop();
416
+ }
417
+ }
418
+ }, _callee);
419
+ }));
420
+
421
+ return function getResponse(_x) {
422
+ return _ref.apply(this, arguments);
423
+ };
424
+ }();
425
+
426
+ /***/ }),
427
+
428
  /***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/progress.js":
429
  /*!*********************************************************************************************************************************************************************************************!*\
430
  !*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/progress.js ***!
651
  /* harmony import */ var _components_sidebar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/sidebar */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/sidebar.js");
652
  /* harmony import */ var _components_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/progress */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/progress.js");
653
  /* harmony import */ var _components_comment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/comment */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/comment.js");
654
+ /* harmony import */ var _components_items_progress__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/items-progress */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/items-progress.js");
655
+ /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./components/compatible */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/single-curriculum/components/compatible.js");
656
+ /* harmony import */ var _components_compatible__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_components_compatible__WEBPACK_IMPORTED_MODULE_6__);
657
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
658
 
659
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
684
 
685
 
686
 
687
+
688
  var SingleCurriculums = /*#__PURE__*/function (_Component) {
689
  _inherits(SingleCurriculums, _Component);
690
 
729
  Object(_components_search__WEBPACK_IMPORTED_MODULE_1__["searchCourseContent"])();
730
  Object(_components_sidebar__WEBPACK_IMPORTED_MODULE_2__["Sidebar"])();
731
  Object(_components_progress__WEBPACK_IMPORTED_MODULE_3__["progressBar"])();
732
+ Object(_components_comment__WEBPACK_IMPORTED_MODULE_4__["commentForm"])();
733
+ Object(_components_items_progress__WEBPACK_IMPORTED_MODULE_5__["itemsProgress"])(); // Check duration expire of course
734
 
735
  var singleCurriculums = new SingleCurriculums();
736
  singleCurriculums.checkCourseDurationExpire();
817
  elFooter: null,
818
  elCalledModal: null,
819
  callBackYes: null,
820
+ instance: null,
821
  init: function init() {
822
+ if (this.instance) {
823
+ return true;
824
+ }
825
+
826
  this.elLPOverlay = $('.lp-overlay');
827
 
828
  if (!this.elLPOverlay.length) {
838
  $(document).on('click', '.close, .btn-no', function () {
839
  elLPOverlay.hide();
840
  });
841
+ $(document).on('click', '.btn-yes', function (e) {
842
+ e.preventDefault();
843
+ e.stopPropagation();
844
+
845
  if ('function' === typeof lpModalOverlay.callBackYes) {
846
  lpModalOverlay.callBackYes();
847
  }
848
  });
849
+ this.instance = this;
850
  return true;
851
  },
852
  setElCalledModal: function setElCalledModal(elCalledModal) {
876
 
877
  (function() { module.exports = window["wp"]["element"]; }());
878
 
879
+ /***/ }),
880
+
881
+ /***/ "@wordpress/url":
882
+ /*!*****************************!*\
883
+ !*** external ["wp","url"] ***!
884
+ \*****************************/
885
+ /*! no static exports found */
886
+ /***/ (function(module, exports) {
887
+
888
+ (function() { module.exports = window["wp"]["url"]; }());
889
+
890
  /***/ })
891
 
892
  /******/ });
assets/js/dist/frontend/single-curriculum.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.singleCurriculum=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=21)}({2:function(e,t){e.exports=window.wp.element},21:function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return b}));var o=n(2),r=n(5),i=jQuery;n(8);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,o=f(e);if(t){var r=f(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}jQuery;var p=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&a(e,t)}(i,e);var t,n,o,r=s(i);function i(){return c(this,i),r.apply(this,arguments)}return t=i,(n=[{key:"checkCourseDurationExpire",value:function(){var e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){var t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}},{key:"render",value:function(){return React.createElement("div",null)}}])&&u(t.prototype,n),o&&u(t,o),i}(o.Component),m=p;window.addEventListener("DOMContentLoaded",(function(){LP.Hook.doAction("lp-compatible-builder"),function(){var e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){var n=t.querySelector(".curriculum-sections"),o=e.querySelector(".search-course"),r=e.querySelector('.search-course input[type="text"]');if(!r||!n||!o)return;var i=n.querySelectorAll("li.section"),l=n.querySelectorAll("li.course-item"),c=[];l.forEach((function(e){var t=e.dataset.id,n=e.querySelector(".item-name");c.push({id:t,name:n?n.textContent.toLowerCase():""})}));var u=function(e){e.preventDefault();var t=r.value;o.classList.add("searching"),t||o.classList.remove("searching");var n=[];c.forEach((function(e){t&&!e.name.match(t.toLowerCase())||(n.push(e.id),l.forEach((function(e){-1!==n.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),i.forEach((function(e){var t=e.querySelectorAll(".course-item"),o=[];t.forEach((function(e){n.includes(e.dataset.id)&&o.push(e.dataset.id)})),0===o.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},a=o.querySelector(".clear");a&&a.addEventListener("click",(function(e){e.preventDefault(),r.value="",u(e)})),o.addEventListener("submit",u),r.addEventListener("keyup",u)}}(),Object(r.a)(),i(".learn-press-progress").each((function(){var e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")})),function(){var e=document.querySelector(".lp-lesson-comment-btn");if(e){var t=e.textContent,n=e.dataset.close;window.location.hash.includes("comment")&&e.parentNode.classList.add("open-comments");var o=function(e,o){o.classList.contains("open-comments")?e.textContent=n:e.textContent=t};o(e,e.parentNode),e.addEventListener("click",(function(t){t.preventDefault(),e.parentNode.classList.toggle("open-comments"),o(e,e.parentNode)}))}}(),(new p).checkCourseDurationExpire()}));var y=n(6),v=jQuery,h={init:function(){this.scrollToItemViewing=function(){var e=v(".viewing-course-item");if(e.length){var t=v("#popup-sidebar").outerHeight(),n=v(".section-title").outerHeight(),o=v(".section-header").outerHeight(),r=new RegExp("^viewing-course-item-([0-9].*)"),i=e.attr("class").split(/\s+/),l=0;if(v.each(i,(function(e,t){var n=r.exec(t);if(n)return l=n[1],!1})),0===l)return;var c=v(".course-item-"+l).offset().top-t;void 0===n?c=c-o+20:c-=n,v("#learn-press-course-curriculum").animate({scrollTop:c+7},800)}},this.scrollToItemViewing()}},b=(jQuery,t.default=m,function(){wp.element.render(React.createElement(m,null),document.getElementById("learn-press-course-curriculum"))});document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),y.a.init(),h.init()}))},5:function(e,t,n){"use strict";function o(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}n.d(t,"a",(function(){return c}));var i=jQuery,l=lodash.throttle,c=function(){var e,t=i("#popup-course"),n=i("#learn-press-course-curriculum");i("#sidebar-toggle").on("change",(function(e){LP.Cookies.set("sidebar-toggle",e.target.checked),r(e.target.checked)}));var r=function(e){i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),e?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open")};r(LP.Cookies.get("sidebar-toggle")),n.find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){o.toggleClass("c")})),o=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],r=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==r}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,o(new Set(n)))}))})),t.length&&(n.on("scroll",l((function(){var t=i(this);t.addClass("scrolling"),e&&clearTimeout(e),e=setTimeout((function(){t.removeClass("scrolling")}),1e3)}),500)),LP.toElement(".course-item.current",{container:".curriculum-scrollable:eq(1)",offset:100,duration:1}))}},6:function(e,t,n){"use strict";var o=jQuery,r=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,init:function(){return this.elLPOverlay=o(".lp-overlay"),!!this.elLPOverlay.length&&(r=this.elLPOverlay,this.elMainContent=r.find(".main-content"),this.elTitle=r.find(".modal-title"),this.elBtnYes=r.find(".btn-yes"),this.elBtnNo=r.find(".btn-no"),this.elFooter=r.find(".lp-modal-footer"),o(document).on("click",".close, .btn-no",(function(){r.hide()})),o(document).on("click",".btn-yes",(function(){"function"==typeof i.callBackYes&&i.callBackYes()})),!0)},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},l=i,c=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){l.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");l.elLPOverlay.show(),l.setTitleModal(t.dataset.title),l.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),l.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");l.elLPOverlay.show(),l.setTitleModal(t.dataset.title),l.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),l.callBackYes=function(){t.submit()}}))})))}});t.a=c},8:function(e,t){function n(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))}});
1
+ this.LP=this.LP||{},this.LP.singleCurriculum=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=22)}({10:function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},2:function(e,t){e.exports=window.wp.element},22:function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return g}));var r=n(2),o=n(7),i=jQuery,c=n(8);n(10);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==l(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}jQuery;var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r,o=f(i);function i(){return u(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"checkCourseDurationExpire",value:function(){var e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){var t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}},{key:"render",value:function(){return React.createElement("div",null)}}])&&a(t.prototype,n),r&&a(t,r),i}(r.Component),y=m;window.addEventListener("DOMContentLoaded",(function(){LP.Hook.doAction("lp-compatible-builder"),function(){var e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){var n=t.querySelector(".curriculum-sections"),r=e.querySelector(".search-course"),o=e.querySelector('.search-course input[type="text"]');if(!o||!n||!r)return;var i=n.querySelectorAll("li.section"),c=n.querySelectorAll("li.course-item"),l=[];c.forEach((function(e){var t=e.dataset.id,n=e.querySelector(".item-name");l.push({id:t,name:n?n.textContent.toLowerCase():""})}));var u=function(e){e.preventDefault();var t=o.value;r.classList.add("searching"),t||r.classList.remove("searching");var n=[];l.forEach((function(e){t&&!e.name.match(t.toLowerCase())||(n.push(e.id),c.forEach((function(e){-1!==n.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),i.forEach((function(e){var t=e.querySelectorAll(".course-item"),r=[];t.forEach((function(e){n.includes(e.dataset.id)&&r.push(e.dataset.id)})),0===r.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},a=r.querySelector(".clear");a&&a.addEventListener("click",(function(e){e.preventDefault(),o.value="",u(e)})),r.addEventListener("submit",u),o.addEventListener("keyup",u)}}(),Object(o.a)(),i(".learn-press-progress").each((function(){var e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")})),function(){var e=document.querySelector(".lp-lesson-comment-btn");if(e){var t=e.textContent,n=e.dataset.close;window.location.hash.includes("comment")&&e.parentNode.classList.add("open-comments");var r=function(e,r){r.classList.contains("open-comments")?e.textContent=n:e.textContent=t};r(e,e.parentNode),e.addEventListener("click",(function(t){t.preventDefault(),e.parentNode.classList.toggle("open-comments"),r(e,e.parentNode)}))}}(),Object(c.b)(),(new m).checkCourseDurationExpire()}));var v=n(4),h=jQuery,b={init:function(){this.scrollToItemViewing=function(){var e=h(".viewing-course-item");if(e.length){var t=h("#popup-sidebar").outerHeight(),n=h(".section-title").outerHeight(),r=h(".section-header").outerHeight(),o=new RegExp("^viewing-course-item-([0-9].*)"),i=e.attr("class").split(/\s+/),c=0;if(h.each(i,(function(e,t){var n=o.exec(t);if(n)return c=n[1],!1})),0===c)return;var l=h(".course-item-"+c).offset().top-t;void 0===n?l=l-r+20:l-=n,h("#learn-press-course-curriculum").animate({scrollTop:l+300},800)}},this.scrollToItemViewing()}},g=(jQuery,t.default=y,function(){wp.element.render(React.createElement(y,null),document.getElementById("learn-press-course-curriculum"))});document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),v.a.init(),b.init()}))},4:function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}},c=i,l=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){c.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");c.elLPOverlay.show(),c.setTitleModal(t.dataset.title),c.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),c.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");c.elLPOverlay.show(),c.setTitleModal(t.dataset.title),c.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),c.callBackYes=function(){t.submit()}}))})))}});t.a=l},5:function(e,t){e.exports=window.wp.url},7:function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return l}));var i=jQuery,c=lodash.throttle,l=function(){var e,t=i("#popup-course"),n=i("#learn-press-course-curriculum");i("#sidebar-toggle").on("change",(function(e){LP.Cookies.set("sidebar-toggle",e.target.checked),o(e.target.checked)}));var o=function(e){i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),e?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open")};o(LP.Cookies.get("sidebar-toggle")),n.find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))})),t.length&&(n.on("scroll",c((function(){var t=i(this);t.addClass("scrolling"),e&&clearTimeout(e),e=setTimeout((function(){t.removeClass("scrolling")}),1e3)}),500)),LP.toElement(".course-item.current",{container:".curriculum-scrollable:eq(1)",offset:100,duration:1}))}},8:function(e,t,n){"use strict";n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return a}));var r=n(5),o=n(4);function i(e,t,n,r,o,i,c){try{var l=e[i](c),u=l.value}catch(e){return void n(e)}l.done?t(u):Promise.resolve(u).then(r,o)}function c(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var u=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;a(n),t.unobserve(n)}}))}));c(e).map((function(e){return t.observe(e)}))}},a=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var c=e.apply(t,n);function l(e){i(c,r,o,l,u,"next",e)}function u(e){i(c,r,o,l,u,"throw",e)}l(void 0)}))});return function(e){return t.apply(this,arguments)}}()}});
assets/js/dist/js/data-controls.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.dataControls=function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=12)}({12:function(r,t,e){"use strict";e.r(t),e.d(t,"apiFetch",(function(){return c})),e.d(t,"select",(function(){return f})),e.d(t,"dispatch",(function(){return s})),e.d(t,"controls",(function(){return l}));var n=e(9),o=e.n(n);function u(r){return function(r){if(Array.isArray(r))return i(r)}(r)||function(r){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(r))return Array.from(r)}(r)||function(r,t){if(!r)return;if("string"==typeof r)return i(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(r,t)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}var a=function(r){return r.isRegistryControl=!0,r},c=function(r){return{type:"API_FETCH",request:r}};function f(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return{type:"SELECT",storeKey:r,selectorName:t,args:n}}function s(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return{type:"DISPATCH",storeKey:r,actionName:t,args:n}}var l={API_FETCH:function(r){var t=r.request;return o()(t)},SELECT:a((function(r){return function(t){var e,n=t.storeKey,o=t.selectorName,i=t.args;return r.select(n)[o].hasResolver?function(r,t){var e=t.storeKey,n=t.selectorName,o=t.args;return new Promise((function(t){var u=function(){return r.select("").hasFinishedResolution(e,n,o)},i=function(){return r.select(e)[n].apply(null,o)},a=i();if(u())return t(a);var c=r.subscribe((function(){u()&&(c(),t(i()))}))}))}(r,{storeKey:n,selectorName:o,args:i}):(e=r.select(n))[o].apply(e,u(i))}})),DISPATCH:a((function(r){return function(t){var e,n=t.storeKey,o=t.actionName,i=t.args;return(e=r.dispatch(n))[o].apply(e,u(i))}}))}},9:function(r,t){r.exports=window.wp.apiFetch}});
1
+ this.LP=this.LP||{},this.LP.dataControls=function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=13)}({11:function(r,t){r.exports=window.wp.apiFetch},13:function(r,t,e){"use strict";e.r(t),e.d(t,"apiFetch",(function(){return c})),e.d(t,"select",(function(){return f})),e.d(t,"dispatch",(function(){return s})),e.d(t,"controls",(function(){return l}));var n=e(11),o=e.n(n);function u(r){return function(r){if(Array.isArray(r))return i(r)}(r)||function(r){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(r))return Array.from(r)}(r)||function(r,t){if(!r)return;if("string"==typeof r)return i(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return i(r,t)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}var a=function(r){return r.isRegistryControl=!0,r},c=function(r){return{type:"API_FETCH",request:r}};function f(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return{type:"SELECT",storeKey:r,selectorName:t,args:n}}function s(r,t){for(var e=arguments.length,n=new Array(e>2?e-2:0),o=2;o<e;o++)n[o-2]=arguments[o];return{type:"DISPATCH",storeKey:r,actionName:t,args:n}}var l={API_FETCH:function(r){var t=r.request;return o()(t)},SELECT:a((function(r){return function(t){var e,n=t.storeKey,o=t.selectorName,i=t.args;return r.select(n)[o].hasResolver?function(r,t){var e=t.storeKey,n=t.selectorName,o=t.args;return new Promise((function(t){var u=function(){return r.select("").hasFinishedResolution(e,n,o)},i=function(){return r.select(e)[n].apply(null,o)},a=i();if(u())return t(a);var c=r.subscribe((function(){u()&&(c(),t(i()))}))}))}(r,{storeKey:n,selectorName:o,args:i}):(e=r.select(n))[o].apply(e,u(i))}})),DISPATCH:a((function(r){return function(t){var e,n=t.storeKey,o=t.actionName,i=t.args;return(e=r.dispatch(n))[o].apply(e,u(i))}}))}}});
assets/src/apps/js/admin/pages/statistic.js CHANGED
@@ -5,7 +5,11 @@
5
  $canvas = $( '<canvas />' );
6
  $elem.html( '' );
7
  $canvas.appendTo( $elem );
8
- new Chart( $canvas.get( 0 ).getContext( '2d' ) ).Line( data, config );
 
 
 
 
9
  } );
10
  //
11
  };
5
  $canvas = $( '<canvas />' );
6
  $elem.html( '' );
7
  $canvas.appendTo( $elem );
8
+ var lineChart = new Chart($canvas,{
9
+ type: 'line',
10
+ data: data,
11
+ options: config
12
+ })
13
  } );
14
  //
15
  };
assets/src/apps/js/admin/pages/tools.js CHANGED
@@ -1,4 +1,6 @@
1
  import getStepsUpgradeStatus from './tools/database/upgrade';
 
 
2
 
3
  ( function( $ ) {
4
  const $doc = $( document );
@@ -107,6 +109,8 @@ import getStepsUpgradeStatus from './tools/database/upgrade';
107
 
108
  $( function() {
109
  getStepsUpgradeStatus();
 
 
110
 
111
  $doc.on( 'click', '.lp-install-sample__install', installSampleCourse )
112
  .on( 'click', '.lp-install-sample__uninstall', uninstallSampleCourse )
1
  import getStepsUpgradeStatus from './tools/database/upgrade';
2
+ import createIndexes from './tools/database/create_indexs';
3
+ import reUpgradeDB from './tools/database/re-upgrade-db';
4
 
5
  ( function( $ ) {
6
  const $doc = $( document );
109
 
110
  $( function() {
111
  getStepsUpgradeStatus();
112
+ createIndexes();
113
+ reUpgradeDB();
114
 
115
  $doc.on( 'click', '.lp-install-sample__install', installSampleCourse )
116
  .on( 'click', '.lp-install-sample__uninstall', uninstallSampleCourse )
assets/src/apps/js/admin/pages/tools/database/create_indexs.js ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import lpModalOverlay from '../../../../utils/lp-modal-overlay';
2
+ import handleAjax from '../../../../utils/handle-ajax-api';
3
+
4
+ const createIndexes = () => {
5
+ const elCreateIndexTables = document.querySelector( '#lp-tool-create-indexes-tables' );
6
+
7
+ if ( ! elCreateIndexTables ) {
8
+ return;
9
+ }
10
+
11
+ const elBtnCreateIndexes = elCreateIndexTables.querySelector( '.lp-btn-create-indexes' );
12
+
13
+ elBtnCreateIndexes.addEventListener( 'click', ( e ) => {
14
+ e.preventDefault();
15
+ const elLoading = elCreateIndexTables.querySelector( '.wrapper-lp-loading' );
16
+
17
+ if ( ! lpModalOverlay.init() ) {
18
+ return;
19
+ }
20
+
21
+ lpModalOverlay.elLPOverlay.show();
22
+ lpModalOverlay.setContentModal( elLoading.innerHTML );
23
+ lpModalOverlay.setTitleModal( elCreateIndexTables.querySelector( 'h2' ).textContent );
24
+ lpModalOverlay.elBtnYes[ 0 ].style.display = 'inline-block';
25
+ lpModalOverlay.elBtnYes[ 0 ].textContent = 'Run';
26
+ lpModalOverlay.elBtnNo[ 0 ].textContent = 'Close';
27
+
28
+ const url = '/lp/v1/tools/list-tables-indexs';
29
+ const params = {};
30
+ const functions = {
31
+ success: ( res ) => {
32
+ const { status, message, data: { tables, table } } = res;
33
+
34
+ const elSteps = document.querySelector( '.example-lp-group-step' );
35
+
36
+ lpModalOverlay.setContentModal( elSteps.innerHTML );
37
+
38
+ const elGroupStep = lpModalOverlay.elLPOverlay[ 0 ].querySelector( '.lp-group-step ' );
39
+
40
+ // Show progress when upgrading.
41
+ const showProgress = ( stepCurrent, percent ) => {
42
+ const elItemStepCurrent = elGroupStep.querySelector( 'input[value=' + stepCurrent + ']' ).closest( '.lp-item-step' );
43
+ elItemStepCurrent.classList.add( 'running' );
44
+
45
+ if ( 100 === percent ) {
46
+ elItemStepCurrent.classList.remove( 'running' );
47
+ elItemStepCurrent.classList.add( 'completed' );
48
+ }
49
+
50
+ const progressBar = elItemStepCurrent.querySelector( '.progress-bar' );
51
+ progressBar.style.width = percent;
52
+ };
53
+
54
+ // Scroll to step current.
55
+ const scrollToStepCurrent = ( stepCurrent ) => {
56
+ const elItemStepCurrent = elGroupStep.querySelector( 'input[value=' + stepCurrent + ']' ).closest( '.lp-item-step' );
57
+
58
+ console.log( elItemStepCurrent.offsetTop, lpModalOverlay.elMainContent[ 0 ].offsetTop );
59
+
60
+ const offset = elItemStepCurrent.offsetTop - lpModalOverlay.elMainContent[ 0 ].offsetTop +
61
+ lpModalOverlay.elMainContent[ 0 ].scrollTop;
62
+
63
+ lpModalOverlay.elMainContent.stop().animate( {
64
+ scrollTop: offset,
65
+ }, 600 );
66
+ };
67
+
68
+ for ( const table in tables ) {
69
+ const elItemStep = lpModalOverlay.elLPOverlay[ 0 ].querySelector( '.lp-item-step' ).cloneNode( true );
70
+ const input = elItemStep.querySelector( 'input' );
71
+ const label = elItemStep.querySelector( 'label' );
72
+
73
+ label.textContent = `Table: ${ table }`;
74
+ input.value = table;
75
+
76
+ elGroupStep.append( elItemStep );
77
+ }
78
+
79
+ lpModalOverlay.callBackYes = () => {
80
+ const url = '/lp/v1/tools/create-indexs';
81
+ const params = { tables, table };
82
+
83
+ lpModalOverlay.elBtnNo[ 0 ].style.display = 'none';
84
+ lpModalOverlay.elBtnYes[ 0 ].style.display = 'none';
85
+
86
+ showProgress( table, 0.1 );
87
+
88
+ const functions = {
89
+ success: ( res ) => {
90
+ const { status, message, data: { table, percent } } = res;
91
+
92
+ showProgress( params.table, percent );
93
+
94
+ if ( undefined !== table ) {
95
+ if ( params.table !== table ) {
96
+ showProgress( table, 0.1 );
97
+ scrollToStepCurrent( table );
98
+ }
99
+
100
+ params.table = table;
101
+ }
102
+
103
+ if ( 'success' === status ) {
104
+ handleAjax( url, params, functions );
105
+ } else if ( 'finished' === status ) {
106
+ console.log( 'finished' );
107
+ lpModalOverlay.elBtnNo[ 0 ].style.display = 'inline-block';
108
+ lpModalOverlay.elBtnNo[ 0 ].textContent = 'Finish';
109
+ } else {
110
+ console.log( message );
111
+ }
112
+ },
113
+ error: ( err ) => {
114
+ console.log( err );
115
+ },
116
+ completed: () => {
117
+
118
+ },
119
+ };
120
+ handleAjax( url, params, functions );
121
+ };
122
+ },
123
+ error: ( err ) => {
124
+
125
+ },
126
+ completed: () => {
127
+
128
+ },
129
+ };
130
+
131
+ handleAjax( url, params, functions );
132
+ } );
133
+ };
134
+
135
+ export default createIndexes;
assets/src/apps/js/admin/pages/tools/database/re-upgrade-db.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import lpModalOverlay from '../../../../utils/lp-modal-overlay';
2
+ import handleAjax from '../../../../utils/handle-ajax-api';
3
+
4
+ const reUpgradeDB = () => {
5
+ const elToolReUpgradeDB = document.querySelector( '#lp-tool-re-upgrade-db' );
6
+
7
+ if ( ! elToolReUpgradeDB ) {
8
+ return;
9
+ }
10
+
11
+ // Check valid to show popup re-upgrade
12
+ let url = 'lp/v1/database/check-db-valid-re-upgrade';
13
+ handleAjax( url, {}, {
14
+ success( res ) {
15
+ const { data: { can_re_upgrade } } = res;
16
+
17
+ if ( ! can_re_upgrade ) {
18
+ return;
19
+ }
20
+
21
+ elToolReUpgradeDB.style.display = 'block';
22
+
23
+ const elBtnReUpradeDB = elToolReUpgradeDB.querySelector( '.lp-btn-re-upgrade-db' );
24
+ const elMessage = elToolReUpgradeDB.querySelector( '.learn-press-message' );
25
+
26
+ elBtnReUpradeDB.addEventListener( 'click', () => {
27
+ // eslint-disable-next-line no-alert
28
+ if ( confirm( 'Are want Re Upgrade!' ) ) {
29
+ url = 'lp/v1/database/del-tb-lp-upgrade-db';
30
+ handleAjax( url, {}, {
31
+ success( res ) {
32
+ const { status, message, data: { url } } = res;
33
+
34
+ if ( 'success' === status && undefined !== url ) {
35
+ window.location.href = url;
36
+ }
37
+ },
38
+ error( err ) {
39
+ elMessage.classList.add( 'error' );
40
+ elMessage.textContent = err.message;
41
+ elMessage.style.display = 'block';
42
+ },
43
+ } );
44
+ }
45
+ } );
46
+ },
47
+ error( err ) {
48
+
49
+ },
50
+ } );
51
+ };
52
+
53
+ export default reUpgradeDB;
assets/src/apps/js/admin/pages/tools/database/upgrade.js CHANGED
@@ -147,6 +147,9 @@ const upgradeDB = () => {
147
  elItemStepCurrent.removeClass( 'running' ).addClass( 'error' );
148
  lpModalOverlay.setContentModal( elWrapperUpgradeMessage.html(), function() {
149
  lpModalOverlay.elBtnYes.text( 'Retry' ).show();
 
 
 
150
  lpModalOverlay.elBtnNo.show();
151
 
152
  if ( ! res.message ) {
@@ -161,6 +164,9 @@ const upgradeDB = () => {
161
  isUpgrading = 0;
162
  lpModalOverlay.setContentModal( elWrapperUpgradeMessage.html(), function() {
163
  lpModalOverlay.elBtnYes.text( 'Retry' ).show();
 
 
 
164
  lpModalOverlay.elBtnNo.show();
165
 
166
  if ( ! err.message ) {
147
  elItemStepCurrent.removeClass( 'running' ).addClass( 'error' );
148
  lpModalOverlay.setContentModal( elWrapperUpgradeMessage.html(), function() {
149
  lpModalOverlay.elBtnYes.text( 'Retry' ).show();
150
+ lpModalOverlay.callBackYes = () => {
151
+ window.location.href = 'wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db';
152
+ };
153
  lpModalOverlay.elBtnNo.show();
154
 
155
  if ( ! res.message ) {
164
  isUpgrading = 0;
165
  lpModalOverlay.setContentModal( elWrapperUpgradeMessage.html(), function() {
166
  lpModalOverlay.elBtnYes.text( 'Retry' ).show();
167
+ lpModalOverlay.callBackYes = () => {
168
+ window.location.location = 'wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db';
169
+ };
170
  lpModalOverlay.elBtnNo.show();
171
 
172
  if ( ! err.message ) {
assets/src/apps/js/frontend/quiz/components/result/index.js CHANGED
@@ -8,6 +8,8 @@ import { useState, useEffect } from '@wordpress/element';
8
  import { useSelect } from '@wordpress/data';
9
  import { __, _x } from '@wordpress/i18n';
10
 
 
 
11
  const { debounce } = lodash;
12
 
13
  const Result = () => {
@@ -60,8 +62,18 @@ const Result = () => {
60
  itemCompleted.textContent = parseInt( allItemCompleted.length );
61
  }
62
  }
 
 
63
  }, [ results ] );
64
 
 
 
 
 
 
 
 
 
65
  const animate = () => {
66
  setPercentage( 0 );
67
  setDone( false );
8
  import { useSelect } from '@wordpress/data';
9
  import { __, _x } from '@wordpress/i18n';
10
 
11
+ import { getResponse } from '../../../single-curriculum/components/items-progress';
12
+
13
  const { debounce } = lodash;
14
 
15
  const Result = () => {
62
  itemCompleted.textContent = parseInt( allItemCompleted.length );
63
  }
64
  }
65
+
66
+ updateItemsProgress();
67
  }, [ results ] );
68
 
69
+ const updateItemsProgress = () => {
70
+ const elements = document.querySelectorAll( '.popup-header__inner' );
71
+
72
+ if ( elements[ 0 ].querySelectorAll( 'form.form-button-finish-course' ).length === 0 ) {
73
+ getResponse( elements[ 0 ] );
74
+ }
75
+ };
76
+
77
  const animate = () => {
78
  setPercentage( 0 );
79
  setDone( false );
assets/src/apps/js/frontend/single-course.js CHANGED
@@ -171,10 +171,10 @@ const retakeCourse = () => {
171
  return;
172
  }
173
 
174
- const elButtonRetakeCourse = elFormRetakeCourse.querySelector( '.button-retake-course' );
175
  const elCourseId = elFormRetakeCourse.querySelector( '[name=retake-course]' ).value;
176
  const elAjaxMessage = elFormRetakeCourse.querySelector( '.lp-ajax-message' );
177
- const submit = () => {
178
  wp.apiFetch( {
179
  path: '/lp/v1/courses/retake-course',
180
  method: 'POST',
@@ -193,7 +193,7 @@ const retakeCourse = () => {
193
  }
194
  } ).catch( ( err ) => {
195
  elAjaxMessage.classList.add( 'error' );
196
- elAjaxMessage.innerHTML = 'error: ' + err.data.status + ' ' + err.message;
197
  } ).then( ( ) => {
198
  elButtonRetakeCourse.classList.remove( 'loading' );
199
  elButtonRetakeCourse.disabled = false;
@@ -205,12 +205,15 @@ const retakeCourse = () => {
205
  e.preventDefault();
206
  } );
207
 
208
- elButtonRetakeCourse.addEventListener( 'click', ( e ) => {
209
- e.preventDefault();
210
- elButtonRetakeCourse.classList.add( 'loading' );
211
- elButtonRetakeCourse.disabled = true;
212
- submit();
213
- } );
 
 
 
214
  };
215
 
216
  // Rest API load content course progress - Nhamdv.
171
  return;
172
  }
173
 
174
+ const elButtonRetakeCourses = elFormRetakeCourse.querySelectorAll( '.button-retake-course' );
175
  const elCourseId = elFormRetakeCourse.querySelector( '[name=retake-course]' ).value;
176
  const elAjaxMessage = elFormRetakeCourse.querySelector( '.lp-ajax-message' );
177
+ const submit = ( elButtonRetakeCourse ) => {
178
  wp.apiFetch( {
179
  path: '/lp/v1/courses/retake-course',
180
  method: 'POST',
193
  }
194
  } ).catch( ( err ) => {
195
  elAjaxMessage.classList.add( 'error' );
196
+ elAjaxMessage.innerHTML = 'error: ' + err.message;
197
  } ).then( ( ) => {
198
  elButtonRetakeCourse.classList.remove( 'loading' );
199
  elButtonRetakeCourse.disabled = false;
205
  e.preventDefault();
206
  } );
207
 
208
+ elButtonRetakeCourses.forEach( ( element ) => element.addEventListener(
209
+ 'click',
210
+ ( e ) => {
211
+ e.preventDefault();
212
+ element.classList.add( 'loading' );
213
+ element.disabled = true;
214
+ submit( element );
215
+ } )
216
+ );
217
  };
218
 
219
  // Rest API load content course progress - Nhamdv.
assets/src/apps/js/frontend/single-curriculum/components/items-progress.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Rest API load content course progress - Nhamdv.
2
+ import { addQueryArgs } from '@wordpress/url';
3
+ import lpModalOverlayCompleteItem from '../../show-lp-overlay-complete-item';
4
+
5
+ export const itemsProgress = () => {
6
+ const elements = document.querySelectorAll( '.popup-header__inner' );
7
+
8
+ if ( ! elements.length ) {
9
+ return;
10
+ }
11
+
12
+ if ( document.querySelector( '#learn-press-quiz-app div.quiz-result' ) !== null ) {
13
+ return;
14
+ }
15
+
16
+ if ( 'IntersectionObserver' in window ) {
17
+ const eleObserver = new IntersectionObserver( ( entries, observer ) => {
18
+ entries.forEach( ( entry ) => {
19
+ if ( entry.isIntersecting ) {
20
+ const ele = entry.target;
21
+
22
+ getResponse( ele );
23
+
24
+ eleObserver.unobserve( ele );
25
+ }
26
+ } );
27
+ } );
28
+
29
+ [ ...elements ].map( ( ele ) => eleObserver.observe( ele ) );
30
+ }
31
+ };
32
+
33
+ export const getResponse = async ( ele ) => {
34
+ const response = await wp.apiFetch( {
35
+ path: addQueryArgs( 'lp/v1/lazy-load/items-progress', {
36
+ courseId: lpGlobalSettings.post_id || '',
37
+ userId: lpGlobalSettings.user_id || '',
38
+ } ),
39
+ method: 'GET',
40
+ } );
41
+
42
+ const { data } = response;
43
+
44
+ ele.innerHTML += data;
45
+
46
+ lpModalOverlayCompleteItem.init();
47
+ };
assets/src/apps/js/frontend/single-curriculum/index.js CHANGED
@@ -4,6 +4,8 @@ import { searchCourseContent } from './components/search';
4
  import { Sidebar } from './components/sidebar';
5
  import { progressBar } from './components/progress';
6
  import { commentForm } from './components/comment';
 
 
7
  import './components/compatible';
8
 
9
  class SingleCurriculums extends Component {
@@ -40,6 +42,7 @@ window.addEventListener( 'DOMContentLoaded', () => {
40
  Sidebar();
41
  progressBar();
42
  commentForm();
 
43
 
44
  // Check duration expire of course
45
  const singleCurriculums = new SingleCurriculums();
4
  import { Sidebar } from './components/sidebar';
5
  import { progressBar } from './components/progress';
6
  import { commentForm } from './components/comment';
7
+ import { itemsProgress } from './components/items-progress';
8
+
9
  import './components/compatible';
10
 
11
  class SingleCurriculums extends Component {
42
  Sidebar();
43
  progressBar();
44
  commentForm();
45
+ itemsProgress();
46
 
47
  // Check duration expire of course
48
  const singleCurriculums = new SingleCurriculums();
assets/src/apps/js/utils/lp-modal-overlay.js CHANGED
@@ -9,7 +9,12 @@ const lpModalOverlay = {
9
  elFooter: null,
10
  elCalledModal: null,
11
  callBackYes: null,
 
12
  init() {
 
 
 
 
13
  this.elLPOverlay = $( '.lp-overlay' );
14
 
15
  if ( ! this.elLPOverlay.length ) {
@@ -27,12 +32,17 @@ const lpModalOverlay = {
27
  elLPOverlay.hide();
28
  } );
29
 
30
- $( document ).on( 'click', '.btn-yes', function() {
 
 
 
31
  if ( 'function' === typeof lpModalOverlay.callBackYes ) {
32
  lpModalOverlay.callBackYes();
33
  }
34
  } );
35
 
 
 
36
  return true;
37
  },
38
  setElCalledModal( elCalledModal ) {
9
  elFooter: null,
10
  elCalledModal: null,
11
  callBackYes: null,
12
+ instance: null,
13
  init() {
14
+ if ( this.instance ) {
15
+ return true;
16
+ }
17
+
18
  this.elLPOverlay = $( '.lp-overlay' );
19
 
20
  if ( ! this.elLPOverlay.length ) {
32
  elLPOverlay.hide();
33
  } );
34
 
35
+ $( document ).on( 'click', '.btn-yes', function( e ) {
36
+ e.preventDefault();
37
+ e.stopPropagation();
38
+
39
  if ( 'function' === typeof lpModalOverlay.callBackYes ) {
40
  lpModalOverlay.callBackYes();
41
  }
42
  } );
43
 
44
+ this.instance = this;
45
+
46
  return true;
47
  },
48
  setElCalledModal( elCalledModal ) {
inc/abstracts/abstract-api_bk_to_remove.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Class LP_API_Base
5
- *
6
- * Base class for api
7
- *
8
- * @since 3.3.0
9
- */
10
- abstract class LP_Abstract_API {
11
- /**
12
- * @var string
13
- */
14
- public $version = '';
15
-
16
- /**
17
- * @var string
18
- */
19
- public $endpoint = '';
20
-
21
- /**
22
- * @var WC_REST_Controller[]|string[]
23
- */
24
- public $controllers = array();
25
-
26
- /**
27
- * LP_API_Base constructor.
28
- */
29
- public function __construct() {
30
- $this->rest_api_init();
31
- }
32
-
33
- /**
34
- * Init REST.
35
- *
36
- * @since 3.3.0
37
- */
38
- public function rest_api_init() {
39
- if ( ! class_exists( 'WP_REST_Server' ) ) {
40
- return;
41
- }
42
-
43
- $this->rest_api_includes();
44
-
45
- add_action( 'rest_api_init', array( $this, 'rest_api_register_routes' ), 10 );
46
-
47
- }
48
-
49
- public function rest_api_includes() {
50
- include_once LP_PLUGIN_PATH . 'inc/rest-api/class-lp-rest-authentication.php';
51
- }
52
-
53
- /**
54
- * Register routes
55
- *
56
- * @since 3.3.0
57
- */
58
- public function rest_api_register_routes() {
59
- if ( ! $this->controllers ) {
60
- return;
61
- }
62
-
63
- $controllers = array();
64
-
65
- foreach ( $this->controllers as $name => $controller ) {
66
-
67
- if ( is_string( $controller ) ) {
68
- $name = $controller;
69
- $controllers[ $name ] = new $controller();
70
- } else {
71
- $controllers[ $name ] = $controller;
72
- }
73
-
74
- $controllers[ $name ]->register_routes();
75
- }
76
-
77
- $this->controllers = $controllers;
78
- }
79
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/abstracts/abstract-rest-api.php CHANGED
@@ -11,7 +11,7 @@ abstract class LP_Abstract_API {
11
  /**
12
  * @var string
13
  */
14
- public $version = '';
15
 
16
  /**
17
  * @var string
11
  /**
12
  * @var string
13
  */
14
+ public $version = 'v1';
15
 
16
  /**
17
  * @var string
inc/admin/class-lp-admin-assets.php CHANGED
@@ -392,6 +392,8 @@ class LP_Admin_Assets extends LP_Abstract_Assets {
392
  echo '<div class="lp-overlay">';
393
  apply_filters( 'learnpress/admin/modal-dialog', learn_press_get_template( 'global/lp-modal-overlay' ) );
394
  echo '</div>';
 
 
395
  }
396
 
397
  public static function instance() {
392
  echo '<div class="lp-overlay">';
393
  apply_filters( 'learnpress/admin/modal-dialog', learn_press_get_template( 'global/lp-modal-overlay' ) );
394
  echo '</div>';
395
+
396
+ apply_filters( 'learnpress/admin/steps', learn_press_get_template( 'global/lp-group-step' ) );
397
  }
398
 
399
  public static function instance() {
inc/admin/class-lp-reset-data.php CHANGED
@@ -242,23 +242,55 @@ class LP_Reset_Data {
242
  public static function ajax_reset_user_courses() {
243
  $user_id = LP_Request::get_int( 'user_id' );
244
  $course_id = LP_Request::get_int( 'course_id' );
245
-
246
  $user = learn_press_get_user($user_id);
247
- $user_course_data = $user->get_course_data( $course_id );
248
-
249
- // Set status, start_time, end_time of course to enrolled.
250
- $user_course_data->set_status( LP_COURSE_ENROLLED )
251
- ->set_start_time( current_time( 'mysql', true ) )
252
- ->set_end_time( '' )
253
- ->set_graduation( 'in-progress' )
254
- ->update();
255
-
256
- // Remove items' course user learned.
257
- $filter_remove = new LP_User_Items_Filter();
258
- $filter_remove->parent_id = $user_course_data->get_user_item_id();
259
- $filter_remove->user_id = $user_course_data->get_user_id();
260
- $filter_remove->limit = - 1;
261
- LP_User_Items_DB::getInstance()->remove_items_of_user_course( $filter_remove );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
 
263
  die();
264
  }
242
  public static function ajax_reset_user_courses() {
243
  $user_id = LP_Request::get_int( 'user_id' );
244
  $course_id = LP_Request::get_int( 'course_id' );
245
+ $object_reset = LP_Request::get_string( 'object_reset' );
246
  $user = learn_press_get_user($user_id);
247
+ if ( ! current_user_can( 'administrator' ) ) {
248
+ return;
249
+ }
250
+ if ( $course_id && $object_reset == 'single' ) {
251
+ $user_course_data = $user->get_course_data( $course_id );
252
+
253
+ // Set status, start_time, end_time of course to enrolled.
254
+ $user_course_data->set_status( LP_COURSE_ENROLLED )
255
+ ->set_start_time( current_time( 'mysql', true ) )
256
+ ->set_end_time( '' )
257
+ ->set_graduation( 'in-progress' )
258
+ ->update();
259
+ // Remove items' course user learned.
260
+ $filter_remove = new LP_User_Items_Filter();
261
+ $filter_remove->parent_id = $user_course_data->get_user_item_id();
262
+ $filter_remove->user_id = $user_course_data->get_user_id();
263
+ $filter_remove->limit = - 1;
264
+ LP_User_Items_DB::getInstance()->remove_items_of_user_course( $filter_remove );
265
+ }
266
+ if ( $object_reset == 'all' && $user_id ) {
267
+ global $wpdb;
268
+ $query = $wpdb->prepare( "
269
+ SELECT item_id
270
+ FROM {$wpdb->learnpress_user_items}
271
+ WHERE user_id = %d AND item_type='lp_course'
272
+ ", $user_id );
273
+ $user_item_ids = $wpdb->get_col( $query );
274
+ if ( $user_item_ids ) {
275
+ foreach ( $user_item_ids as $user_item_id ) {
276
+ $course_id = $user_item_id;
277
+ $user_course_data = $user->get_course_data( $course_id );
278
+
279
+ // Set status, start_time, end_time of course to enrolled.
280
+ $user_course_data->set_status( LP_COURSE_ENROLLED )
281
+ ->set_start_time( current_time( 'mysql', true ) )
282
+ ->set_end_time( '' )
283
+ ->set_graduation( 'in-progress' )
284
+ ->update();
285
+ // Remove items' course user learned.
286
+ $filter_remove = new LP_User_Items_Filter();
287
+ $filter_remove->parent_id = $user_course_data->get_user_item_id();
288
+ $filter_remove->user_id = $user_course_data->get_user_id();
289
+ $filter_remove->limit = - 1;
290
+ LP_User_Items_DB::getInstance()->remove_items_of_user_course( $filter_remove );
291
+ }
292
+ }
293
+ }
294
 
295
  die();
296
  }
inc/admin/meta-box/class-lp-meta-box-v3.php DELETED
@@ -1,316 +0,0 @@
1
- <?php
2
- /**
3
- * Use for Add-on old version.
4
- * support for Add-on in LP3
5
- *
6
- * @author Nhamdv <email@email.com>
7
- * @since 4.0.0
8
- */
9
-
10
- $all_plugins = get_plugins();
11
- if ( ! class_exists( 'RW_Meta_Box' ) && ( ! isset( $all_plugins['thim-core/thim-core.php'] ) || ( isset( $all_plugins['thim-core/thim-core.php'] ) && version_compare( $all_plugins['thim-core/thim-core.php']['Version'], '1.10.2', '>=' ) ) ) ) {
12
- class RW_Meta_Box {
13
-
14
- public $meta_box;
15
-
16
- public function __construct( $meta_box ) {
17
- $meta_box = self::normalize( $meta_box );
18
-
19
- $this->meta_box = $meta_box;
20
-
21
- add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
22
- add_action( 'save_post', array( $this, 'save_meta_box' ), 100, 2 );
23
- }
24
-
25
- public function add_meta_boxes() {
26
- $meta_box = $this->meta_box;
27
-
28
- if ( isset( $meta_box['pages'] ) ) {
29
- $meta_box['post_types'] = $meta_box['pages'];
30
- }
31
-
32
- if ( is_array( $meta_box['post_types'] ) ) {
33
- foreach ( $meta_box['post_types'] as $post_type ) {
34
- add_meta_box( $meta_box['id'], $meta_box['title'], array( $this, 'display' ), $post_type, $meta_box['context'], $meta_box['priority'] );
35
- }
36
- } else {
37
- add_meta_box( $meta_box['id'], $meta_box['title'], array( $this, 'display' ), $meta_box['post_types'], $meta_box['context'], $meta_box['priority'] );
38
- }
39
- }
40
-
41
- public static function normalize( $meta_box ) {
42
- $meta_box = wp_parse_args(
43
- $meta_box,
44
- array(
45
- 'id' => sanitize_title( $meta_box['title'] ),
46
- 'context' => 'normal',
47
- 'priority' => 'high',
48
- 'post_types' => 'post',
49
- 'autosave' => false,
50
- 'default_hidden' => false,
51
- 'style' => 'default',
52
- 'icon' => '',
53
- )
54
- );
55
-
56
- return $meta_box;
57
- }
58
-
59
- public function normalize_setting( $setting ) {
60
- $setting = wp_parse_args(
61
- $setting,
62
- array(
63
- 'id' => '',
64
- 'name' => '',
65
- 'desc' => '',
66
- 'std' => '',
67
- )
68
- );
69
-
70
- return $setting;
71
- }
72
-
73
- public function save_meta_box( $post_id, $post ) {
74
- $post_id = absint( $post_id );
75
-
76
- if ( empty( $_POST['learnpress_meta_box_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['learnpress_meta_box_nonce'] ), 'learnpress_save_meta_box' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
77
- return;
78
- }
79
-
80
- if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) {
81
- return;
82
- }
83
-
84
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
85
- return;
86
- }
87
-
88
- $meta_boxes = $this->meta_box;
89
-
90
- if ( ! empty( $meta_boxes['fields'] ) ) {
91
- foreach ( $meta_boxes['fields'] as $setting ) {
92
- $field = $this->normalize_setting( $setting );
93
-
94
- switch ( $field['type'] ) {
95
- case 'text':
96
- case 'number':
97
- case 'textarea':
98
- case 'select':
99
- $text = isset( $_POST[ $field['id'] ] ) ? wp_unslash( $_POST[ $field['id'] ] ) : '';
100
- update_post_meta( $post_id, $field['id'], $text );
101
- break;
102
-
103
- case 'checkbox':
104
- $checkbox = isset( $_POST[ $field['id'] ] ) ? 'yes' : 'no';
105
- update_post_meta( $post_id, $field['id'], $checkbox );
106
- break;
107
-
108
- case 'duration':
109
- $duration = isset( $_POST[ $field['id'] ][0] ) && $_POST[ $field['id'] ][0] !== '' ? implode( ' ', wp_unslash( $_POST[ $field['id'] ] ) ) : '0 minute';
110
- update_post_meta( $post_id, $field['id'], $duration );
111
- }
112
- }
113
- }
114
-
115
- }
116
-
117
- public function display() {
118
- $meta_boxes = $this->meta_box;
119
-
120
- if ( ! empty( $meta_boxes['fields'] ) ) {
121
- wp_nonce_field( 'learnpress_save_meta_box', 'learnpress_meta_box_nonce' );
122
- ?>
123
-
124
- <div class="lp-meta-box">
125
- <div class="lp-meta-box__inner">
126
- <?php
127
- foreach ( $meta_boxes['fields'] as $setting ) {
128
- $field = $this->normalize_setting( $setting );
129
-
130
- switch ( $field['type'] ) {
131
- case 'text':
132
- case 'number':
133
- lp_meta_box_text_input_field(
134
- array(
135
- 'id' => $field['id'],
136
- 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
137
- 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
138
- 'type' => $field['type'],
139
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
140
- 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
141
- )
142
- );
143
- break;
144
-
145
- case 'textarea':
146
- lp_meta_box_textarea_field(
147
- array(
148
- 'id' => $field['id'],
149
- 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
150
- 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
151
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
152
- 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
153
- )
154
- );
155
- break;
156
-
157
- case 'checkbox':
158
- lp_meta_box_checkbox_field(
159
- array(
160
- 'id' => $field['id'],
161
- 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
162
- 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
163
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
164
- )
165
- );
166
- break;
167
-
168
- case 'duration':
169
- lp_meta_box_duration_field(
170
- array(
171
- 'id' => $field['id'],
172
- 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
173
- 'default_time' => $field['default_time'],
174
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
175
- 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
176
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
177
- 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
178
- )
179
- );
180
- break;
181
-
182
- case 'select':
183
- lp_meta_box_select_field(
184
- array(
185
- 'id' => $field['id'],
186
- 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
187
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
188
- 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
189
- 'options' => $field['options'],
190
- 'style' => 'min-width: 200px',
191
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
192
- 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
193
- )
194
- );
195
- break;
196
-
197
- case 'select_advanced':
198
- lp_meta_box_select_field(
199
- array(
200
- 'id' => $field['id'],
201
- 'label' => isset( $field['label'] ) ? $field['label'] : $field['name'],
202
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
203
- 'description' => isset( $field['description'] ) ? $field['description'] : $field['desc'],
204
- 'options' => $field['options'],
205
- 'multiple' => true,
206
- 'default' => isset( $field['default'] ) ? $field['default'] : $field['std'],
207
- 'wrapper_class' => 'lp-select-2',
208
- 'style' => 'min-width: 200px',
209
- 'custom_attributes' => isset( $field['custom_attributes'] ) ? $field['custom_attributes'] : '',
210
- )
211
- );
212
- break;
213
- }
214
- }
215
- ?>
216
- </div>
217
- </div>
218
- <?php
219
- }
220
- }
221
- }
222
- }
223
-
224
- class LP_Course_MetaBox_Tab_V3 {
225
- public function __construct() {
226
- add_action( 'lp_course_data_settings_tabs', array( $this, 'get_tab_title' ) );
227
- add_action( 'lp_course_data_setting_tab_content', array( $this, 'get_tab_content' ) );
228
- add_action( 'learnpress/course-settings/after-author', array( $this, 'co_instructor_author' ) );
229
- add_action( 'admin_init', array( $this, 'add_course_tab' ) );
230
- }
231
-
232
- public function add_course_tab() {
233
- $tabs = apply_filters( 'learn-press/admin-course-tabs', array() );
234
-
235
- if ( ! empty( $tabs ) ) {
236
- foreach ( $tabs as $key => $tab ) {
237
- return $tab;
238
- }
239
- }
240
- }
241
-
242
- public function get_tab_title( $tabs ) {
243
- $tab = apply_filters( 'learn-press/' . LP_COURSE_CPT . '/tabs', false );
244
-
245
- $priority = 60;
246
- if ( ! empty( $tab ) && is_array( $tab ) ) {
247
- foreach ( $tab as $key => $field ) {
248
- $tabs[ $key ] = array(
249
- 'label' => $field['title'],
250
- 'target' => $field['id'],
251
- 'icon' => $field['icon'],
252
- 'priority' => $priority + 10,
253
- );
254
- }
255
- }
256
-
257
- return $tabs;
258
- }
259
-
260
- public function get_tab_content() {
261
- $tab = apply_filters( 'learn-press/' . LP_COURSE_CPT . '/tabs', false );
262
-
263
- if ( ! $tab ) {
264
- return;
265
- }
266
-
267
- foreach ( $tab as $field ) {
268
- if ( isset( $field['callback'] ) ) {
269
- ?>
270
- <div id="<?php echo $field['id']; ?>" class="lp-meta-box-course-panels">
271
- <?php call_user_func( $field['callback'] ); ?>
272
- </div>
273
- <?php
274
- }
275
- }
276
- }
277
-
278
- /**
279
- * Support for Co Instructor plugin.
280
- *
281
- * @return void
282
- */
283
- public function co_instructor_author() {
284
- $fields = apply_filters( 'learn_press_course_author_meta_box', array() );
285
-
286
- if ( ! empty( $fields ) ) {
287
- LP_Meta_Box_Course::eduma_child_metabox_v3( $fields );
288
- }
289
- }
290
- }
291
-
292
- new LP_Course_MetaBox_Tab_V3();
293
-
294
- if ( ! class_exists( 'LP_Meta_Box_Tabs' ) ) {
295
- /**
296
- * Not use, but need to fix error.
297
- * use in learnpress-coupon plugin.
298
- *
299
- * @author nhamdv <email@email.com>
300
- */
301
- class LP_Meta_Box_Tabs {
302
- public function __construct() {
303
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
304
-
305
- return true;
306
- }
307
-
308
- public function admin_notices() {
309
- ?>
310
- <div class="error">
311
- <p><?php esc_html_e( 'LearnPress 4 don\'t use LP_Meta_Box_Tabs, please update your code.', 'learnpress' ); ?></p>
312
- </div>
313
- <?php
314
- }
315
- }
316
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/views/tools/course/html-course.php CHANGED
@@ -41,8 +41,6 @@ defined( 'ABSPATH' ) or die();
41
  href=""
42
  @click="reset($event, course);"
43
  :class="resetActionClass(course)"></a>
44
- <!-- <span v-else-if="course.status=='done'">--><?php //_e( 'Done', 'learnpress' ); ?><!--</span>-->
45
- <!-- <span v-else-if="course.status=='resetting'">--><?php //_e( 'Resetting...', 'learnpress' ); ?><!--</span>-->
46
  </td>
47
  </tr>
48
  </tbody>
@@ -62,88 +60,3 @@ $localize = array(
62
  'reset_course_users' => __( 'Are you sure to reset course progress of all users enrolled this course?', 'learnpress' )
63
  );
64
  ?>
65
- <script>
66
- window.$Vue = window.$Vue || Vue;
67
-
68
- jQuery(function ($) {
69
-
70
- var js_localize = <?php echo wp_json_encode( $localize );?>
71
-
72
- new $Vue({
73
- el: '#learn-press-reset-course-users',
74
- data: {
75
- s: '',
76
- status: false,
77
- courses: []
78
- },
79
- methods: {
80
- resetActionClass: function (course) {
81
- return {
82
- 'dashicons-trash': !course.status,
83
- 'dashicons-yes': course.status === 'done',
84
- 'dashicons-update': course.status === 'resetting'
85
- }
86
- },
87
- updateSearch: function (e) {
88
- this.s = e.target.value;
89
- this.status = false;
90
- e.preventDefault();
91
- },
92
- search: function (e) {
93
- e.preventDefault();
94
-
95
- var that = this;
96
- this.s = $(this.$el).find('input[name="s"]').val();
97
-
98
- if (this.s.length < 3) {
99
- return;
100
- }
101
-
102
- this.status = 'searching';
103
- this.courses = [];
104
-
105
- $.ajax({
106
- url: '',
107
- data: {
108
- 'lp-ajax': 'rs-search-courses',
109
- s: this.s
110
- },
111
- success: function (response) {
112
- that.courses = LP.parseJSON(response);
113
- that.status = 'result';
114
- }
115
- })
116
- },
117
-
118
- reset: function (e, course) {
119
- e.preventDefault();
120
-
121
- if (!confirm(js_localize.reset_course_users)) {
122
- return;
123
- }
124
- var that = this;
125
- course.status = 'resetting';
126
- $.ajax({
127
- url: '',
128
- data: {
129
- 'lp-ajax': 'rs-reset-course-users',
130
- id: course.id
131
- },
132
- success: function (response) {
133
- response = LP.parseJSON(response);
134
- if (response.id == course.id) {
135
- for (var i = 0, n = that.courses.length; i < n; i++) {
136
- if (that.courses[i].id === course.id) {
137
- that.courses[i].status = 'done';
138
- break;
139
- }
140
- }
141
- }
142
- }
143
- })
144
- }
145
- }
146
- });
147
- });
148
-
149
- </script>
41
  href=""
42
  @click="reset($event, course);"
43
  :class="resetActionClass(course)"></a>
 
 
44
  </td>
45
  </tr>
46
  </tbody>
60
  'reset_course_users' => __( 'Are you sure to reset course progress of all users enrolled this course?', 'learnpress' )
61
  );
62
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/views/tools/course/html-user.php CHANGED
@@ -41,6 +41,7 @@ defined( 'ABSPATH' ) or die();
41
  <a :href="course.url" target="_blank">{{course.title}} (#{{course.id}})</a>
42
  <a href=""
43
  class="action-reset dashicons"
 
44
  @click="reset($event, user, course.id);"
45
  :class="resetActionClass(user, course)"></a>
46
  </li>
@@ -49,8 +50,10 @@ defined( 'ABSPATH' ) or die();
49
  <td>
50
  <a href=""
51
  class="action-reset dashicons"
 
52
  :class="resetActionClass(user)"
53
  @click="reset($event, user);"></a>
 
54
  </td>
55
  </tr>
56
  </tbody>
@@ -145,14 +148,15 @@ $localize = array(
145
  user.status = 'resetting';
146
  }
147
 
148
- console.log(user.courses);
149
 
150
  $.ajax({
151
  url: '',
152
  data: {
153
  'lp-ajax': 'rs-reset-user-courses',
154
  user_id: user.id,
155
- course_id: course_id
 
156
  },
157
  success: function (response) {
158
  response = LP.parseJSON(response);
41
  <a :href="course.url" target="_blank">{{course.title}} (#{{course.id}})</a>
42
  <a href=""
43
  class="action-reset dashicons"
44
+ data-reset="single"
45
  @click="reset($event, user, course.id);"
46
  :class="resetActionClass(user, course)"></a>
47
  </li>
50
  <td>
51
  <a href=""
52
  class="action-reset dashicons"
53
+ data-reset="all"
54
  :class="resetActionClass(user)"
55
  @click="reset($event, user);"></a>
56
+ <span style="font-size: 12px"><?php echo esc_html__('Delete All','learnpress'); ?></span>
57
  </td>
58
  </tr>
59
  </tbody>
148
  user.status = 'resetting';
149
  }
150
 
151
+ var object_reset = $(e.target).data('reset');
152
 
153
  $.ajax({
154
  url: '',
155
  data: {
156
  'lp-ajax': 'rs-reset-user-courses',
157
  user_id: user.id,
158
+ course_id: course_id,
159
+ object_reset: object_reset
160
  },
161
  success: function (response) {
162
  response = LP.parseJSON(response);
inc/admin/views/tools/database/html-create-indexs-tables.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template tool create indexs fo tables database.
4
+ *
5
+ * @template html-create-indexs-tables
6
+ * @author tungnx
7
+ * @package learnpress/admin/views/tools/database
8
+ * @version 1.0.0
9
+ * @since 4.0.3
10
+ */
11
+
12
+ defined( 'ABSPATH' ) or die();
13
+ ?>
14
+
15
+ <div class="card" id="lp-tool-create-indexes-tables">
16
+ <h2><?php echo sprintf( '%s', __( 'Create Database Indexes', 'learnpress' ) ); ?></h2>
17
+ <p><?php _e( 'Re-create or create new indexes for tables.', 'learnpress' ); ?></p>
18
+ <p class="tools-button">
19
+ <button type="button" class="button lp-btn lp-btn-create-indexes"><?php esc_html_e( 'Create now', 'learnpress' ); ?></button>
20
+ </p>
21
+
22
+ <div class="wrapper-lp-loading" style="display: none">
23
+ <?php lp_skeleton_animation_html( 7 ); ?>
24
+ </div>
25
+ </div>
26
+
inc/admin/views/tools/database/html-reupgrade-db.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template tool Reupgrade database.
4
+ *
5
+ * @template html-reupgrade-db
6
+ * @author tungnx
7
+ * @package learnpress/admin/views/tools/database
8
+ * @version 1.0.0
9
+ * @since 4.0.2
10
+ */
11
+
12
+ defined( 'ABSPATH' ) or die();
13
+ ?>
14
+
15
+ <div class="card" id="lp-tool-re-upgrade-db" style="display: none">
16
+ <h2><?php echo sprintf( '%s', __( 'Reupgrade Database.', 'learnpress' ) ); ?></h2>
17
+ <p><?php _e( '1. Tool only one apply for case Update from LP3 to LP4 didn\'t success', 'learnpress' ); ?></p>
18
+ <p><?php _e( '2. Please sure what you doing', 'learnpress' ); ?></p>
19
+ <p class="tools-button">
20
+ <button type="button" class="button lp-btn lp-btn-re-upgrade-db">
21
+ <?php esc_html_e( 'Run now', 'learnpress' ); ?>
22
+ </button>
23
+ </p>
24
+ <div class="learn-press-message" style="display: none"></div>
25
+ </div>
inc/admin/views/tools/html-database.php CHANGED
@@ -13,4 +13,7 @@ require_once 'database/html-upgrade-database.php';
13
  //require_once 'database/html-repair-database.php';
14
  //require_once 'database/html-remove-database.php';
15
  //require_once 'database/html-remove-outdated-data.php';
 
 
16
  require_once 'database/html-rollback-db.php';
 
13
  //require_once 'database/html-repair-database.php';
14
  //require_once 'database/html-remove-database.php';
15
  //require_once 'database/html-remove-outdated-data.php';
16
+ require_once 'database/html-create-indexs-tables.php';
17
+ //require_once 'database/html-reupgrade-db.php';
18
  require_once 'database/html-rollback-db.php';
19
+ require_once 'database/html-reupgrade-db.php';
inc/databases/class-lp-db.php CHANGED
@@ -189,8 +189,8 @@ class LP_Database {
189
  * @throws Exception
190
  */
191
  public function clone_table( string $name_table ):bool {
192
- if ( ! current_user_can( 'administrator' ) ) {
193
- return false;
194
  }
195
 
196
  $table_bk = $name_table . '_bk';
@@ -261,8 +261,8 @@ class LP_Database {
261
  * @throws Exception
262
  */
263
  public function add_col_table( string $name_table, string $name_col, string $type, string $after_col = '' ) {
264
- if ( ! current_user_can( 'administrator' ) ) {
265
- return false;
266
  }
267
 
268
  $query_add = '';
@@ -290,6 +290,7 @@ class LP_Database {
290
  * @param string $name_table .
291
  *
292
  * @return bool|int
 
293
  */
294
  public function drop_indexs_table( string $name_table ) {
295
  $show_index = "SHOW INDEX FROM $name_table";
@@ -303,6 +304,7 @@ class LP_Database {
303
  $query = $this->wpdb->prepare( "ALTER TABLE $name_table DROP INDEX $index->Key_name", 1 );
304
 
305
  $this->wpdb->query( $query );
 
306
  }
307
  }
308
 
@@ -351,8 +353,8 @@ class LP_Database {
351
  * @throws Exception
352
  */
353
  public function drop_table( string $name_table = '' ) {
354
- if ( ! current_user_can( 'administrator' ) ) {
355
- return false;
356
  }
357
 
358
  // Check table exists.
@@ -460,4 +462,59 @@ class LP_Database {
460
  throw new Exception( $this->wpdb->last_error );
461
  }
462
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463
  }
189
  * @throws Exception
190
  */
191
  public function clone_table( string $name_table ):bool {
192
+ if ( ! current_user_can( ADMIN_ROLE ) ) {
193
+ throw new Exception( 'You don\'t have permission' );
194
  }
195
 
196
  $table_bk = $name_table . '_bk';
261
  * @throws Exception
262
  */
263
  public function add_col_table( string $name_table, string $name_col, string $type, string $after_col = '' ) {
264
+ if ( ! current_user_can( ADMIN_ROLE ) ) {
265
+ throw new Exception( 'You don\'t have permission' );
266
  }
267
 
268
  $query_add = '';
290
  * @param string $name_table .
291
  *
292
  * @return bool|int
293
+ * @throws Exception
294
  */
295
  public function drop_indexs_table( string $name_table ) {
296
  $show_index = "SHOW INDEX FROM $name_table";
304
  $query = $this->wpdb->prepare( "ALTER TABLE $name_table DROP INDEX $index->Key_name", 1 );
305
 
306
  $this->wpdb->query( $query );
307
+ $this->check_execute_has_error();
308
  }
309
  }
310
 
353
  * @throws Exception
354
  */
355
  public function drop_table( string $name_table = '' ) {
356
+ if ( ! current_user_can( ADMIN_ROLE ) ) {
357
+ throw new Exception( 'You don\'t have permission' );
358
  }
359
 
360
  // Check table exists.
462
  throw new Exception( $this->wpdb->last_error );
463
  }
464
  }
465
+
466
+ /**
467
+ * Important: Reason need set again indexes for table options of WP
468
+ * because if want change value of "option_name" will error "database error Duplicate entry"
469
+ * So before set must drop and add when done all
470
+ *
471
+ * @author tungnx
472
+ * @version 1.0.0
473
+ * @since 4.0.3
474
+ * @throws Exception
475
+ */
476
+ public function create_indexes_tb_options() {
477
+ $this->drop_indexs_table( $this->tb_options );
478
+ $result = $this->wpdb->query(
479
+ "
480
+ ALTER TABLE $this->tb_options
481
+ ADD UNIQUE option_name (option_name),
482
+ ADD INDEX autoload (autoload)
483
+ "
484
+ );
485
+
486
+ $this->check_execute_has_error();
487
+
488
+ return $result;
489
+ }
490
+
491
+ /**
492
+ * Rename table
493
+ *
494
+ * @author tungnx
495
+ * @version 1.0.0
496
+ * @since 4.0.3
497
+ * @throws Exception
498
+ */
499
+ public function rename_table( string $name_table = '', string $new_name = '' ) {
500
+ if ( ! current_user_can( ADMIN_ROLE ) ) {
501
+ throw new Exception( 'You don\'t have permission' );
502
+ }
503
+
504
+ $tb_exists = $this->check_table_exists( $name_table );
505
+
506
+ if ( ! $tb_exists ) {
507
+ throw new Exception( 'Table not exists' );
508
+ }
509
+
510
+ $result = $this->wpdb->query(
511
+ "
512
+ ALTER TABLE $name_table
513
+ RENAME $new_name
514
+ "
515
+ );
516
+ $this->check_execute_has_error();
517
+
518
+ return $result;
519
+ }
520
  }
inc/lp-template-functions.php CHANGED
@@ -1829,7 +1829,7 @@ if ( ! function_exists( 'lp_profile_page_content' ) ) {
1829
  if ( $profile_id ) {
1830
  $profile_page = get_post( $profile_id );
1831
 
1832
- remove_shortcode( 'learn_press_profile' );
1833
  $description = lp_format_page_content( wp_kses_post( $profile_page->post_content ) );
1834
 
1835
  if ( $description ) {
1829
  if ( $profile_id ) {
1830
  $profile_page = get_post( $profile_id );
1831
 
1832
+ //remove_shortcode( 'learn_press_profile' );
1833
  $description = lp_format_page_content( wp_kses_post( $profile_page->post_content ) );
1834
 
1835
  if ( $description ) {
inc/rest-api/admin/class-lp-admin-core-api.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- class LP_Admin_Core_API extends LP_Abstract_API {
4
- public function __construct() {
5
-
6
- parent::__construct();
7
- }
8
-
9
- /**
10
- * Includes files
11
- */
12
- public function rest_api_includes() {
13
- parent::rest_api_includes();
14
-
15
- include_once dirname( __FILE__ ) . '/class-lp-admin-rest-question-controller.php';
16
- include_once dirname( __FILE__ ) . '/class-lp-admin-rest-database-controller.php';
17
- include_once dirname( __FILE__ ) . '/class-lp-admin-rest-course-controller.php';
18
-
19
- do_action( 'learn-press/admin/core-api/includes' );
20
- }
21
-
22
- public function rest_api_register_routes() {
23
- $controllers = array(
24
- 'LP_REST_Admin_Question_Controller',
25
- 'LP_REST_Admin_Database_Controller',
26
- 'LP_REST_Admin_Course_Controller',
27
- );
28
-
29
- $this->controllers = apply_filters( 'learn-press/core-api/controllers', $controllers );
30
-
31
- parent::rest_api_register_routes();
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/rest-api/class-lp-admin-core-api.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class LP_Admin_Core_API
4
+ *
5
+ * @author Thimpress
6
+ * @editor tungnx, nhamdv
7
+ * @version 1.0.1
8
+ * @since 4.0.0
9
+ */
10
+ class LP_Admin_Core_API extends LP_Abstract_API {
11
+ public function __construct() {
12
+ if ( ! current_user_can( 'administrator' ) ) {
13
+ return;
14
+ }
15
+
16
+ parent::__construct();
17
+ }
18
+
19
+ /**
20
+ * Includes files
21
+ */
22
+ public function rest_api_includes() {
23
+ parent::rest_api_includes();
24
+
25
+ $path_version = DIRECTORY_SEPARATOR . $this->version . DIRECTORY_SEPARATOR . 'admin';
26
+
27
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-admin-rest-question-controller.php';
28
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-admin-rest-database-controller.php';
29
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-admin-rest-course-controller.php';
30
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-admin-rest-tools-controller.php';
31
+
32
+ do_action( 'learn-press/admin/core-api/includes' );
33
+ }
34
+
35
+ public function rest_api_register_routes() {
36
+ $controllers = array(
37
+ 'LP_REST_Admin_Question_Controller',
38
+ 'LP_REST_Admin_Database_Controller',
39
+ 'LP_REST_Admin_Course_Controller',
40
+ 'LP_REST_Admin_Tools_Controller',
41
+ );
42
+
43
+ $this->controllers = apply_filters( 'learn-press/core-api/controllers', $controllers );
44
+
45
+ parent::rest_api_register_routes();
46
+ }
47
+ }
inc/rest-api/class-lp-core-api.php CHANGED
@@ -1,4 +1,13 @@
1
  <?php
 
 
 
 
 
 
 
 
 
2
 
3
  class LP_Core_API extends LP_Abstract_API {
4
  public function __construct() {
@@ -12,10 +21,12 @@ class LP_Core_API extends LP_Abstract_API {
12
  public function rest_api_includes() {
13
  parent::rest_api_includes();
14
 
15
- include_once dirname( __FILE__ ) . '/class-lp-rest-settings-controller.php';
16
- include_once dirname( __FILE__ ) . '/class-lp-rest-users-controller.php';
17
- include_once dirname( __FILE__ ) . '/class-lp-rest-courses-controller.php';
18
- include_once dirname( __FILE__ ) . '/class-lp-rest-lazy-load-controller.php';
 
 
19
 
20
  do_action( 'learn-press/core-api/includes' );
21
  }
1
  <?php
2
+ /**
3
+ * Class LP_Core_API
4
+ *
5
+ * @author Thimpress
6
+ * @editor tungnx, nhamdv
7
+ * @version 1.0.1
8
+ * @since 4.0.0
9
+ */
10
+ defined( 'ABSPATH' ) || exit;
11
 
12
  class LP_Core_API extends LP_Abstract_API {
13
  public function __construct() {
21
  public function rest_api_includes() {
22
  parent::rest_api_includes();
23
 
24
+ $path_version = DIRECTORY_SEPARATOR . $this->version . DIRECTORY_SEPARATOR . 'frontend';
25
+
26
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-settings-controller.php';
27
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-users-controller.php';
28
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-courses-controller.php';
29
+ include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-lazy-load-controller.php';
30
 
31
  do_action( 'learn-press/core-api/includes' );
32
  }
inc/rest-api/class-lp-rest-authentication.php CHANGED
@@ -186,7 +186,7 @@ class LP_REST_Authentication {
186
  * @return bool
187
  */
188
  public static function check_admin_permission() {
189
- return current_user_can(ADMIN_ROLE);
190
  }
191
  }
192
 
186
  * @return bool
187
  */
188
  public static function check_admin_permission() {
189
+ return current_user_can( ADMIN_ROLE );
190
  }
191
  }
192
 
inc/rest-api/{admin → v1/admin}/class-lp-admin-rest-course-controller.php RENAMED
File without changes
inc/rest-api/{admin → v1/admin}/class-lp-admin-rest-database-controller.php RENAMED
@@ -38,27 +38,41 @@ class LP_REST_Admin_Database_Controller extends LP_Abstract_REST_Controller {
38
  */
39
  public function register_routes() {
40
  $this->routes = array(
41
- 'upgrade' => array(
42
  array(
43
  'methods' => WP_REST_Server::CREATABLE,
44
  'callback' => array( $this, 'upgrade' ),
45
  'permission_callback' => array( $this, 'check_admin_permission' ),
46
  ),
47
  ),
48
- 'get_steps' => array(
49
  array(
50
  'methods' => WP_REST_Server::CREATABLE,
51
  'callback' => array( $this, 'get_steps' ),
52
  'permission_callback' => array( $this, 'check_admin_permission' ),
53
  ),
54
  ),
55
- 'agree_terms' => array(
56
  array(
57
  'methods' => WP_REST_Server::CREATABLE,
58
  'callback' => array( $this, 'agree_terms_upgrade' ),
59
  'permission_callback' => array( $this, 'check_admin_permission' ),
60
  ),
61
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  );
63
 
64
  parent::register_routes();
@@ -140,4 +154,77 @@ class LP_REST_Admin_Database_Controller extends LP_Abstract_REST_Controller {
140
 
141
  wp_send_json( $steps );
142
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
38
  */
39
  public function register_routes() {
40
  $this->routes = array(
41
+ 'upgrade' => array(
42
  array(
43
  'methods' => WP_REST_Server::CREATABLE,
44
  'callback' => array( $this, 'upgrade' ),
45
  'permission_callback' => array( $this, 'check_admin_permission' ),
46
  ),
47
  ),
48
+ 'get_steps' => array(
49
  array(
50
  'methods' => WP_REST_Server::CREATABLE,
51
  'callback' => array( $this, 'get_steps' ),
52
  'permission_callback' => array( $this, 'check_admin_permission' ),
53
  ),
54
  ),
55
+ 'agree_terms' => array(
56
  array(
57
  'methods' => WP_REST_Server::CREATABLE,
58
  'callback' => array( $this, 'agree_terms_upgrade' ),
59
  'permission_callback' => array( $this, 'check_admin_permission' ),
60
  ),
61
  ),
62
+ 'check-db-valid-re-upgrade' => array(
63
+ array(
64
+ 'methods' => WP_REST_Server::CREATABLE,
65
+ 'callback' => array( $this, 'check_DB_valid_to_re_upgrade' ),
66
+ 'permission_callback' => array( $this, 'check_admin_permission' ),
67
+ ),
68
+ ),
69
+ 'del-tb-lp-upgrade-db' => array(
70
+ array(
71
+ 'methods' => WP_REST_Server::CREATABLE,
72
+ 'callback' => array( $this, 'delete_tb_lp_upgrade_db' ),
73
+ 'permission_callback' => array( $this, 'check_admin_permission' ),
74
+ ),
75
+ ),
76
  );
77
 
78
  parent::register_routes();
154
 
155
  wp_send_json( $steps );
156
  }
157
+
158
+ /**
159
+ * Check DB valid to re upgrade
160
+ *
161
+ * can_re_upgrade | 1: can, 0: can't
162
+ */
163
+ public function check_DB_valid_to_re_upgrade() {
164
+ $response = new LP_REST_Response();
165
+ $lp_db = LP_Database::getInstance();
166
+ $response->data->can_re_upgrade = 0;
167
+
168
+ $col_start_time_gmt_exist = $lp_db->check_col_table( $lp_db->tb_lp_user_items, 'start_time_gmt' );
169
+ $col_graduation_exist = $lp_db->check_col_table( $lp_db->tb_lp_user_items, 'graduation' );
170
+ $col_item_id_exist = $lp_db->check_col_table( $lp_db->tb_lp_order_items, 'item_id' );
171
+
172
+ if ( $col_start_time_gmt_exist || ! $col_graduation_exist || ! $col_item_id_exist ) {
173
+ $response->data->can_re_upgrade = 1;
174
+ }
175
+
176
+ $response->status = 'success';
177
+
178
+ wp_send_json( $response );
179
+ }
180
+
181
+ /**
182
+ * Remove table lp_upgrade_db
183
+ *
184
+ * can_re_upgrade | 1: can, 0: can't
185
+ */
186
+ public function delete_tb_lp_upgrade_db() {
187
+ $response = new LP_REST_Response();
188
+ $lp_db = LP_Database::getInstance();
189
+ $response->data->can_re_upgrade = 0;
190
+
191
+ try {
192
+ $result = $lp_db->drop_table( $lp_db->tb_lp_upgrade_db );
193
+ update_option( 'learnpress_db_version', 3 );
194
+
195
+ // Drop tables.
196
+ $lp_db->drop_table( $lp_db->tb_lp_user_items );
197
+ $lp_db->drop_table( $lp_db->tb_lp_user_itemmeta );
198
+ $lp_db->drop_table( $lp_db->tb_lp_question_answers );
199
+ $lp_db->drop_table( $lp_db->tb_postmeta );
200
+ $lp_db->drop_table( $lp_db->tb_options );
201
+ // End.
202
+
203
+ // Rename tables bk.
204
+ $tb_lp_user_items_bk = $lp_db->tb_lp_user_items . '_bk';
205
+ $lp_db->rename_table( $tb_lp_user_items_bk, $lp_db->tb_lp_user_items );
206
+
207
+ $tb_lp_user_itemmeta_bk = $lp_db->tb_lp_user_itemmeta . '_bk';
208
+ $lp_db->rename_table( $tb_lp_user_itemmeta_bk, $lp_db->tb_lp_user_itemmeta );
209
+
210
+ $tb_lp_question_answers_bk = $lp_db->tb_lp_question_answers . '_bk';
211
+ $lp_db->rename_table( $tb_lp_question_answers_bk, $lp_db->tb_lp_question_answers );
212
+
213
+ $tb_postmeta_bk = $lp_db->tb_postmeta . '_bk';
214
+ $lp_db->rename_table( $tb_postmeta_bk, $lp_db->tb_postmeta );
215
+
216
+ $tb_options_bk = $lp_db->tb_options . '_bk';
217
+ $lp_db->rename_table( $tb_options_bk, $lp_db->tb_options );
218
+ // End.
219
+
220
+ if ( $result ) {
221
+ $response->status = 'success';
222
+ $response->data->url = admin_url( 'admin.php?page=learn-press-tools&tab=database&action=upgrade-db' );
223
+ }
224
+ } catch ( Exception $e ) {
225
+ $response->message = $e->getMessage();
226
+ }
227
+
228
+ wp_send_json( $response );
229
+ }
230
  }
inc/rest-api/{admin → v1/admin}/class-lp-admin-rest-question-controller.php RENAMED
File without changes
inc/rest-api/v1/admin/class-lp-admin-rest-tools-controller.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class LP_REST_Admin_Tools_Controller
5
+ *
6
+ * @since 4.0.3
7
+ * @author tungnx
8
+ * @version 1.0.0
9
+ */
10
+ class LP_REST_Admin_Tools_Controller extends LP_Abstract_REST_Controller {
11
+ public function __construct() {
12
+ $this->namespace = 'lp/v1';
13
+ $this->rest_base = 'tools';
14
+ parent::__construct();
15
+ }
16
+
17
+ /**
18
+ * Register rest routes.
19
+ */
20
+ public function register_routes() {
21
+ $this->routes = array(
22
+ 'create-indexs' => array(
23
+ array(
24
+ 'methods' => WP_REST_Server::CREATABLE,
25
+ 'callback' => array( $this, 'create_indexs' ),
26
+ 'permission_callback' => '__return_true',
27
+ ),
28
+ ),
29
+ 'list-tables-indexs' => array(
30
+ array(
31
+ 'methods' => WP_REST_Server::CREATABLE,
32
+ 'callback' => array( $this, 'get_list_tables_indexs' ),
33
+ 'permission_callback' => '__return_true',
34
+ ),
35
+ ),
36
+ );
37
+
38
+ parent::register_routes();
39
+ }
40
+
41
+ /**
42
+ * Create indexs.
43
+ *
44
+ * @param WP_REST_Request $request .
45
+ *
46
+ * @return void
47
+ */
48
+ public function create_indexs( WP_REST_Request $request ) {
49
+ $response = new LP_REST_Response();
50
+ $lp_db = LP_Database::getInstance();
51
+
52
+ try {
53
+ $tables = $request->get_param( 'tables' );
54
+ $table = $request->get_param( 'table' );
55
+ $table_keys = array();
56
+
57
+ $lp_db->wpdb->query( 'SET autocommit = 0' );
58
+
59
+ if ( empty( $tables ) ) {
60
+ throw new Exception( 'Param invalid!' );
61
+ } else {
62
+ $table_keys = array_keys( $tables );
63
+ }
64
+
65
+ if ( empty( $table ) ) {
66
+ $table = $lp_db->tb_lp_user_items;
67
+ } elseif ( array_key_exists( $table, $table_keys ) ) {
68
+ throw new Exception( 'Table invalid!' );
69
+ }
70
+
71
+ // Create Indexs for a table.
72
+ if ( $table === $lp_db->tb_lp_question_answermeta ) {
73
+ $lp_db->drop_indexs_table( $lp_db->tb_lp_question_answermeta );
74
+ $lp_db->wpdb->query(
75
+ "
76
+ ALTER TABLE {$lp_db->tb_lp_question_answermeta}
77
+ ADD INDEX question_answer_meta (`learnpress_question_answer_id`, `meta_key`(150))
78
+ "
79
+ );
80
+ $lp_db->check_execute_has_error();
81
+ } elseif ( $table === $lp_db->tb_lp_section_items ) {
82
+ $lp_db->drop_indexs_table( $lp_db->tb_lp_section_items );
83
+
84
+ $lp_db->wpdb->query(
85
+ "
86
+ ALTER TABLE {$lp_db->tb_lp_section_items}
87
+ ADD INDEX section_item (`section_id`, `item_id`)
88
+ "
89
+ );
90
+ $lp_db->check_execute_has_error();
91
+ } else {
92
+ $lp_db->add_indexs_table( $table, $tables[ $table ] );
93
+ }
94
+
95
+ // Set next table key.
96
+ $index_key = array_search( $table, $table_keys );
97
+ ++ $index_key;
98
+
99
+ if ( ! array_key_exists( $index_key, $table_keys ) ) {
100
+ $response->status = 'finished';
101
+ $response->data->percent = 100;
102
+ } else {
103
+ $response->data->table = $table_keys[ $index_key ];
104
+ $response->data->percent = 100;
105
+ $response->status = 'success';
106
+ }
107
+ } catch ( Exception $e ) {
108
+ $response->message = $e->getMessage();
109
+ }
110
+
111
+ wp_send_json( $response );
112
+ }
113
+
114
+ public function get_list_tables_indexs( WP_REST_Request $request ) {
115
+ $response = new LP_REST_Response();
116
+ $lp_db = LP_Database::getInstance();
117
+
118
+ $tables_indexs = array(
119
+ $lp_db->tb_lp_user_items => array( 'user_id', 'item_id', 'item_type', 'status', 'ref_type', 'ref_id', 'parent_id' ),
120
+ $lp_db->tb_lp_user_itemmeta => array( 'learnpress_user_item_id', 'meta_key', 'meta_value' ),
121
+ $lp_db->tb_lp_quiz_questions => array( 'quiz_id', 'question_id' ),
122
+ $lp_db->tb_lp_question_answers => array( 'question_id' ),
123
+ $lp_db->tb_lp_question_answermeta => '',
124
+ $lp_db->tb_lp_order_items => array( 'order_id', 'item_id', 'item_type' ),
125
+ $lp_db->tb_lp_order_itemmeta => array( 'learnpress_order_item_id', 'meta_key', 'meta_value' ),
126
+ $lp_db->tb_lp_sections => array( 'section_course_id' ),
127
+ $lp_db->tb_lp_section_items => '',
128
+ );
129
+
130
+ $response->data->tables = $tables_indexs;
131
+ $response->data->table = $lp_db->tb_lp_user_items;
132
+ $response->status = 'success';
133
+
134
+ wp_send_json( $response );
135
+ }
136
+ }
inc/rest-api/{class-lp-rest-courses-controller.php → v1/frontend/class-lp-rest-courses-controller.php} RENAMED
@@ -271,12 +271,17 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
271
  }
272
  }
273
 
 
 
274
  if ( is_user_logged_in() ) {
275
  $response->status = 'success';
276
  $response->message = esc_html__(
277
  'Congrats! You enroll course successfully. Redirecting...',
278
  'learnpress'
279
  );
 
 
 
280
  $response->data->redirect = $course->get_redirect_url_after_enroll();
281
  } else {
282
  $response->message = esc_html__( 'Redirecting...', 'learnpress' );
271
  }
272
  }
273
 
274
+
275
+
276
  if ( is_user_logged_in() ) {
277
  $response->status = 'success';
278
  $response->message = esc_html__(
279
  'Congrats! You enroll course successfully. Redirecting...',
280
  'learnpress'
281
  );
282
+ // Send mail when course enrolled
283
+ $user = learn_press_get_current_user();
284
+ $user->enrolled_sendmail( get_current_user_id(), $course_id );
285
  $response->data->redirect = $course->get_redirect_url_after_enroll();
286
  } else {
287
  $response->message = esc_html__( 'Redirecting...', 'learnpress' );
inc/rest-api/{class-lp-rest-lazy-load-controller.php → v1/frontend/class-lp-rest-lazy-load-controller.php} RENAMED
@@ -25,11 +25,62 @@ class LP_REST_Lazy_Load_Controller extends LP_Abstract_REST_Controller {
25
  'permission_callback' => '__return_true',
26
  ),
27
  ),
 
 
 
 
 
 
 
28
  );
29
 
30
  parent::register_routes();
31
  }
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  /**
34
  * Load user_progress in single course.
35
  *
25
  'permission_callback' => '__return_true',
26
  ),
27
  ),
28
+ 'items-progress' => array(
29
+ array(
30
+ 'methods' => WP_REST_Server::READABLE,
31
+ 'callback' => array( $this, 'items_progress' ),
32
+ 'permission_callback' => '__return_true',
33
+ ),
34
+ ),
35
  );
36
 
37
  parent::register_routes();
38
  }
39
 
40
+ /**
41
+ * Load items progress in single curriculum items.
42
+ *
43
+ * @param [type] $request
44
+ * @return
45
+ *
46
+ * @author Nhamdv <daonham95>
47
+ */
48
+ public function items_progress( $request ) {
49
+ $params = $request->get_params();
50
+ $course_id = isset( $params['courseId'] ) ? $params['courseId'] : false;
51
+ $user_id = isset( $params['userId'] ) ? $params['userId'] : false;
52
+ $response = new LP_REST_Response();
53
+ $response->data = '';
54
+
55
+ try {
56
+ if ( $course_id && $user_id ) {
57
+ $course = learn_press_get_course( $course_id );
58
+ $user = learn_press_get_user( $user_id );
59
+
60
+ $check = LP()->template( 'course' )->can_show_finish_course_btn( $course, $user );
61
+
62
+ if ( $check['status'] !== 'success' ) {
63
+ throw new Exception( $check['message'] );
64
+ }
65
+
66
+ $response->status = 'success';
67
+ $response->data = learn_press_get_template_content(
68
+ 'single-course/buttons/finish.php',
69
+ array(
70
+ 'course' => $course,
71
+ 'user' => $user,
72
+ )
73
+ );
74
+ } else {
75
+ throw new Exception( esc_html__( 'Error: Cannot get course ID or user ID', 'learnpress' ) );
76
+ }
77
+ } catch ( Exception $e ) {
78
+ $response->message = $e->getMessage();
79
+ }
80
+
81
+ return rest_ensure_response( $response );
82
+ }
83
+
84
  /**
85
  * Load user_progress in single course.
86
  *
inc/rest-api/{class-lp-rest-settings-controller.php → v1/frontend/class-lp-rest-settings-controller.php} RENAMED
File without changes
inc/rest-api/{class-lp-rest-users-controller.php → v1/frontend/class-lp-rest-users-controller.php} RENAMED
File without changes
inc/shortcodes/class-lp-shortcode-profile.php CHANGED
@@ -36,12 +36,12 @@ if ( ! class_exists( 'LP_Shortcode_Profile' ) ) {
36
  */
37
  public function output() {
38
 
39
- ob_start();
40
- learn_press_print_messages();
41
- learn_press_get_template( 'pages/profile.php' );
42
- $output = ob_get_clean();
43
 
44
- return $output;
45
  }
46
  }
47
  }
36
  */
37
  public function output() {
38
 
39
+ //ob_start();
40
+ //learn_press_print_messages();
41
+ //learn_press_get_template( 'pages/profile.php' );
42
+ //$output = ob_get_clean();
43
 
44
+ return '';
45
  }
46
  }
47
  }
inc/templates/abstract-template.php CHANGED
@@ -70,6 +70,8 @@ class LP_Abstract_Template {
70
  * @param string $tag
71
  * @param string $function_to_remove - '*' will remove all methods.
72
  * @param int $priority
 
 
73
  */
74
  public function remove( $tag, $function_to_remove, $priority = 10 ) {
75
  global $wp_filter;
70
  * @param string $tag
71
  * @param string $function_to_remove - '*' will remove all methods.
72
  * @param int $priority
73
+ *
74
+ * Ex: Remove for text: LP()->template( 'course' )->remove( 'learn-press/course-content-summary', array( '<div class="course-detail-info"> <div class="lp-content-area"> <div class="course-info-left">', 'course-info-left-open' ), 10 );
75
  */
76
  public function remove( $tag, $function_to_remove, $priority = 10 ) {
77
  global $wp_filter;
inc/templates/class-lp-template-course.php CHANGED
@@ -426,45 +426,66 @@ class LP_Template_Course extends LP_Abstract_Template {
426
  learn_press_get_template( 'single-course/buttons/continue.php' );
427
  }
428
 
429
- public function course_finish_button() {
430
- $user = LP_Global::user();
431
- $course = LP_Global::course();
 
 
432
 
433
- if ( ! $user || ! $course ) {
434
- return;
435
- }
 
436
 
437
- if ( $course->get_external_link() ) {
438
- return;
439
- }
440
 
441
- if ( ! $user->is_course_in_progress( $course->get_id() ) ) {
442
- return;
443
- }
444
 
445
- $has_finish = get_post_meta( $course->get_id(), '_lp_has_finish', true ) ? get_post_meta( $course->get_id(), '_lp_has_finish', true ) : 'yes';
446
- $is_passed = $user->has_reached_passing_condition( $course->get_id() );
447
 
448
- if ( ! $is_passed && $has_finish === 'no' ) {
449
- return;
450
- }
451
 
452
- $is_all_completed = $user->is_completed_all_items( $course->get_id() );
 
453
 
454
- if ( ! $user->is_course_in_progress( $course->get_id() ) ) {
455
- return;
456
- }
457
 
458
- // All items completed and not passed.
459
- if ( ! $is_all_completed && $has_finish === 'yes' && ! $is_passed ) {
460
- return;
461
- }
462
 
463
- if ( ! apply_filters( 'lp_can_finish_course', true ) ) {
464
- return;
 
 
 
 
 
465
  }
466
 
467
- learn_press_get_template( 'single-course/buttons/finish.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  }
469
 
470
  public function course_external_button() {
426
  learn_press_get_template( 'single-course/buttons/continue.php' );
427
  }
428
 
429
+ public function can_show_finish_course_btn( $course, $user ) {
430
+ $return = array(
431
+ 'status' => 'fail',
432
+ 'message' => '',
433
+ );
434
 
435
+ try {
436
+ if ( ! $course || ! $user ) {
437
+ throw new Exception( esc_html__( 'Error: No Course or User avaliable.', 'learnpress' ) );
438
+ }
439
 
440
+ $course_id = $course->get_id();
 
 
441
 
442
+ $course_data = $user->get_course_data( $course_id );
443
+ $course_results = $course_data->calculate_course_results();
 
444
 
445
+ $is_all_completed = $user->is_completed_all_items( $course_id );
 
446
 
447
+ if ( ! $user->is_course_in_progress( $course_id ) ) {
448
+ throw new Exception( esc_html__( 'Error: Course is not in-progress.', 'learnpress' ) );
449
+ }
450
 
451
+ $has_finish = get_post_meta( $course_id, '_lp_has_finish', true ) ? get_post_meta( $course_id, '_lp_has_finish', true ) : 'yes';
452
+ $is_passed = $user->has_reached_passing_condition( $course_id );
453
 
454
+ if ( ! $is_passed && $has_finish === 'no' ) {
455
+ throw new Exception( esc_html__( 'Error: Course is not has finish.', 'learnpress' ) );
456
+ }
457
 
458
+ if ( ! $is_all_completed && $has_finish === 'yes' && ! $is_passed ) {
459
+ throw new Exception( esc_html__( 'Error: Cannot finish course.', 'learnpress' ) );
460
+ }
 
461
 
462
+ if ( ! apply_filters( 'lp_can_finish_course', true ) ) {
463
+ throw new Exception( esc_html__( 'Error: Filter disable finish course.', 'learnpress' ) );
464
+ }
465
+
466
+ $return['status'] = 'success';
467
+ } catch ( Exception $e ) {
468
+ $return['message'] = $e->getMessage();
469
  }
470
 
471
+ return $return;
472
+ }
473
+
474
+ public function course_finish_button() {
475
+ $user = LP_Global::user();
476
+ $course = LP_Global::course();
477
+
478
+ $check = $this->can_show_finish_course_btn( $course, $user );
479
+
480
+ if ( $check['status'] === 'success' ) {
481
+ learn_press_get_template(
482
+ 'single-course/buttons/finish.php',
483
+ array(
484
+ 'course' => $course,
485
+ 'user' => $user,
486
+ )
487
+ );
488
+ }
489
  }
490
 
491
  public function course_external_button() {
inc/updates/learnpress-upgrade-4.php CHANGED
@@ -413,6 +413,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
413
  $lp_db->add_indexs_table( $lp_db->tb_lp_user_items, $indexs );
414
  } catch ( Exception $e ) {
415
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
416
  }
417
 
418
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -440,6 +441,10 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
440
  )
441
  );
442
 
 
 
 
 
443
  $user_course_ids_str = implode( ',', $user_course_ids );
444
 
445
  $user_item_ids = $lp_db->wpdb->get_col(
@@ -471,6 +476,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
471
  $lp_db->check_execute_has_error();
472
  } catch ( Exception $e ) {
473
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
474
  }
475
 
476
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -788,6 +794,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
788
  $lp_db->add_col_table( $lp_db->tb_lp_user_itemmeta, 'extra_value', 'longtext', 'meta_value' );
789
  } catch ( Exception $e ) {
790
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
791
  }
792
 
793
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -824,6 +831,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
824
  $lp_db->check_execute_has_error();
825
  } catch ( Exception $e ) {
826
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
827
  }
828
 
829
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -855,6 +863,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
855
  $lp_db->add_indexs_table( $lp_db->tb_lp_user_itemmeta, $indexs );
856
  } catch ( Exception $e ) {
857
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
858
  }
859
 
860
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -894,6 +903,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
894
  $lp_db->check_execute_has_error();
895
  } catch ( Exception $e ) {
896
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
897
  }
898
 
899
  return $this->finish_step(
@@ -914,6 +924,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
914
  $lp_db->add_indexs_table( $lp_db->tb_lp_quiz_questions, $indexs );
915
  } catch ( Exception $e ) {
916
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
917
  }
918
 
919
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -982,6 +993,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
982
  }
983
  } catch ( Exception $e ) {
984
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
985
  }
986
 
987
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
@@ -1109,8 +1121,10 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1109
  ADD INDEX question_answer_meta (`learnpress_question_answer_id`, `meta_key`(150))
1110
  "
1111
  );
 
1112
  } catch ( Exception $e ) {
1113
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1114
  }
1115
 
1116
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
@@ -1216,6 +1230,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1216
  $lp_db->drop_col_table( $lp_db->tb_lp_question_answers, 'answer_order' );
1217
  } catch ( Exception $e ) {
1218
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1219
  }
1220
 
1221
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
@@ -1236,6 +1251,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1236
  $lp_db->add_indexs_table( $lp_db->tb_lp_order_items, $indexs );
1237
  } catch ( Exception $e ) {
1238
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1239
  }
1240
 
1241
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
@@ -1266,6 +1282,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1266
  $lp_db->add_indexs_table( $lp_db->tb_lp_order_itemmeta, $indexs );
1267
  } catch ( Exception $e ) {
1268
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1269
  }
1270
 
1271
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
@@ -1284,6 +1301,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1284
  $lp_db->add_indexs_table( $lp_db->tb_lp_sections, $indexs );
1285
  } catch ( Exception $e ) {
1286
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1287
  }
1288
 
1289
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
@@ -1308,6 +1326,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1308
  $lp_db->check_execute_has_error();
1309
  } catch ( Exception $e ) {
1310
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1311
  }
1312
 
1313
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
@@ -1329,6 +1348,14 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1329
  $lp_db = LP_Database::getInstance();
1330
 
1331
  try {
 
 
 
 
 
 
 
 
1332
  // Courses thumbnail dimensions convert.
1333
  $lp_db->wpdb->query(
1334
  "UPDATE $lp_db->tb_options
@@ -1336,6 +1363,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1336
  WHERE option_name = 'learn_press_course_thumbnail_image_size'
1337
  "
1338
  );
 
1339
 
1340
  // Profile thumbnail dimensions convert.
1341
  $lp_db->wpdb->query(
@@ -1344,6 +1372,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1344
  WHERE option_name = 'learn_press_profile_picture_thumbnail_size'
1345
  "
1346
  );
 
1347
 
1348
  // Profile rename dashboard to overview.
1349
  $learn_press_profile_endpoints = $lp_db->wpdb->get_var(
@@ -1352,6 +1381,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1352
  WHERE option_name = 'learn_press_profile_endpoints'
1353
  "
1354
  );
 
1355
 
1356
  $learn_press_profile_endpoints = maybe_unserialize( $learn_press_profile_endpoints );
1357
 
@@ -1375,6 +1405,11 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1375
  maybe_serialize( $learn_press_profile_endpoints_tmp )
1376
  )
1377
  );
 
 
 
 
 
1378
 
1379
  // Course settings.
1380
  // Block course by duration.
@@ -1384,6 +1419,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1384
  WHERE meta_key = '_lp_block_course_item_duration_content'
1385
  "
1386
  );
 
1387
 
1388
  // Block course when finished.
1389
  $lp_db->wpdb->query(
@@ -1392,6 +1428,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1392
  WHERE meta_key = '_lp_block_lesson_content'
1393
  "
1394
  );
 
1395
 
1396
  // Assessment course by quizzes - Evaluate.
1397
  $lp_db->wpdb->query(
@@ -1401,6 +1438,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1401
  AND meta_value = 'evaluate_quizzes'
1402
  "
1403
  );
 
1404
 
1405
  // End course settings.
1406
 
@@ -1412,6 +1450,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1412
  WHERE meta_key = '_lp_review_questions'
1413
  "
1414
  );
 
1415
 
1416
  $lp_db->wpdb->query(
1417
  "
@@ -1420,6 +1459,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1420
  WHERE meta_key = '_lp_minus_points'
1421
  "
1422
  );
 
1423
 
1424
  $lp_db->wpdb->query(
1425
  "
@@ -1429,6 +1469,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1429
  AND meta_value > 0
1430
  "
1431
  );
 
1432
 
1433
  $lp_db->wpdb->query(
1434
  "
@@ -1438,6 +1479,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1438
  AND meta_value != 'yes'
1439
  "
1440
  );
 
1441
 
1442
  // Delete some fields not use.
1443
 
@@ -1447,6 +1489,7 @@ class LP_Upgrade_4 extends LP_Handle_Upgrade_Steps {
1447
  delete_option( 'lp_db_need_upgrade' );
1448
  } catch ( Exception $e ) {
1449
  $response->message = $this->error_step( $response->name, $e->getMessage() );
 
1450
  }
1451
 
1452
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
413
  $lp_db->add_indexs_table( $lp_db->tb_lp_user_items, $indexs );
414
  } catch ( Exception $e ) {
415
  $response->message = $this->error_step( $response->name, $e->getMessage() );
416
+ return $response;
417
  }
418
 
419
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
441
  )
442
  );
443
 
444
+ if ( empty( $user_course_ids ) ) {
445
+ return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
446
+ }
447
+
448
  $user_course_ids_str = implode( ',', $user_course_ids );
449
 
450
  $user_item_ids = $lp_db->wpdb->get_col(
476
  $lp_db->check_execute_has_error();
477
  } catch ( Exception $e ) {
478
  $response->message = $this->error_step( $response->name, $e->getMessage() );
479
+ return $response;
480
  }
481
 
482
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
794
  $lp_db->add_col_table( $lp_db->tb_lp_user_itemmeta, 'extra_value', 'longtext', 'meta_value' );
795
  } catch ( Exception $e ) {
796
  $response->message = $this->error_step( $response->name, $e->getMessage() );
797
+ return $response;
798
  }
799
 
800
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
831
  $lp_db->check_execute_has_error();
832
  } catch ( Exception $e ) {
833
  $response->message = $this->error_step( $response->name, $e->getMessage() );
834
+ return $response;
835
  }
836
 
837
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
863
  $lp_db->add_indexs_table( $lp_db->tb_lp_user_itemmeta, $indexs );
864
  } catch ( Exception $e ) {
865
  $response->message = $this->error_step( $response->name, $e->getMessage() );
866
+ return $response;
867
  }
868
 
869
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
903
  $lp_db->check_execute_has_error();
904
  } catch ( Exception $e ) {
905
  $response->message = $this->error_step( $response->name, $e->getMessage() );
906
+ return $response;
907
  }
908
 
909
  return $this->finish_step(
924
  $lp_db->add_indexs_table( $lp_db->tb_lp_quiz_questions, $indexs );
925
  } catch ( Exception $e ) {
926
  $response->message = $this->error_step( $response->name, $e->getMessage() );
927
+ return $response;
928
  }
929
 
930
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
993
  }
994
  } catch ( Exception $e ) {
995
  $response->message = $this->error_step( $response->name, $e->getMessage() );
996
+ return $response;
997
  }
998
 
999
  return $this->finish_step( $response, 'Step ' . __FUNCTION__ . ' finished' );
1121
  ADD INDEX question_answer_meta (`learnpress_question_answer_id`, `meta_key`(150))
1122
  "
1123
  );
1124
+ $lp_db->check_execute_has_error();
1125
  } catch ( Exception $e ) {
1126
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1127
+ return $response;
1128
  }
1129
 
1130
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
1230
  $lp_db->drop_col_table( $lp_db->tb_lp_question_answers, 'answer_order' );
1231
  } catch ( Exception $e ) {
1232
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1233
+ return $response;
1234
  }
1235
 
1236
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
1251
  $lp_db->add_indexs_table( $lp_db->tb_lp_order_items, $indexs );
1252
  } catch ( Exception $e ) {
1253
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1254
+ return $response;
1255
  }
1256
 
1257
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
1282
  $lp_db->add_indexs_table( $lp_db->tb_lp_order_itemmeta, $indexs );
1283
  } catch ( Exception $e ) {
1284
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1285
+ return $response;
1286
  }
1287
 
1288
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
1301
  $lp_db->add_indexs_table( $lp_db->tb_lp_sections, $indexs );
1302
  } catch ( Exception $e ) {
1303
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1304
+ return $response;
1305
  }
1306
 
1307
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
1326
  $lp_db->check_execute_has_error();
1327
  } catch ( Exception $e ) {
1328
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1329
+ return $response;
1330
  }
1331
 
1332
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
1348
  $lp_db = LP_Database::getInstance();
1349
 
1350
  try {
1351
+
1352
+ /**
1353
+ * Update value on column option_name.
1354
+ * Code update value option_name must write before re create indexes if not error "Duplicate entry".
1355
+ */
1356
+ // Drop table options.
1357
+ $lp_db->drop_indexs_table( $lp_db->tb_options );
1358
+
1359
  // Courses thumbnail dimensions convert.
1360
  $lp_db->wpdb->query(
1361
  "UPDATE $lp_db->tb_options
1363
  WHERE option_name = 'learn_press_course_thumbnail_image_size'
1364
  "
1365
  );
1366
+ $lp_db->check_execute_has_error();
1367
 
1368
  // Profile thumbnail dimensions convert.
1369
  $lp_db->wpdb->query(
1372
  WHERE option_name = 'learn_press_profile_picture_thumbnail_size'
1373
  "
1374
  );
1375
+ $lp_db->check_execute_has_error();
1376
 
1377
  // Profile rename dashboard to overview.
1378
  $learn_press_profile_endpoints = $lp_db->wpdb->get_var(
1381
  WHERE option_name = 'learn_press_profile_endpoints'
1382
  "
1383
  );
1384
+ $lp_db->check_execute_has_error();
1385
 
1386
  $learn_press_profile_endpoints = maybe_unserialize( $learn_press_profile_endpoints );
1387
 
1405
  maybe_serialize( $learn_press_profile_endpoints_tmp )
1406
  )
1407
  );
1408
+ $lp_db->check_execute_has_error();
1409
+
1410
+ // Create indexes for table options.
1411
+ $lp_db->create_indexes_tb_options();
1412
+ // End.
1413
 
1414
  // Course settings.
1415
  // Block course by duration.
1419
  WHERE meta_key = '_lp_block_course_item_duration_content'
1420
  "
1421
  );
1422
+ $lp_db->check_execute_has_error();
1423
 
1424
  // Block course when finished.
1425
  $lp_db->wpdb->query(
1428
  WHERE meta_key = '_lp_block_lesson_content'
1429
  "
1430
  );
1431
+ $lp_db->check_execute_has_error();
1432
 
1433
  // Assessment course by quizzes - Evaluate.
1434
  $lp_db->wpdb->query(
1438
  AND meta_value = 'evaluate_quizzes'
1439
  "
1440
  );
1441
+ $lp_db->check_execute_has_error();
1442
 
1443
  // End course settings.
1444
 
1450
  WHERE meta_key = '_lp_review_questions'
1451
  "
1452
  );
1453
+ $lp_db->check_execute_has_error();
1454
 
1455
  $lp_db->wpdb->query(
1456
  "
1459
  WHERE meta_key = '_lp_minus_points'
1460
  "
1461
  );
1462
+ $lp_db->check_execute_has_error();
1463
 
1464
  $lp_db->wpdb->query(
1465
  "
1469
  AND meta_value > 0
1470
  "
1471
  );
1472
+ $lp_db->check_execute_has_error();
1473
 
1474
  $lp_db->wpdb->query(
1475
  "
1479
  AND meta_value != 'yes'
1480
  "
1481
  );
1482
+ $lp_db->check_execute_has_error();
1483
 
1484
  // Delete some fields not use.
1485
 
1489
  delete_option( 'lp_db_need_upgrade' );
1490
  } catch ( Exception $e ) {
1491
  $response->message = $this->error_step( $response->name, $e->getMessage() );
1492
+ return $response;
1493
  }
1494
 
1495
  return $this->finish_step( $response, __FUNCTION__ . ' finished' );
inc/user/abstract-lp-user.php CHANGED
@@ -2357,9 +2357,6 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
2357
  );
2358
  $wpdb->query( $query );
2359
 
2360
- // Trigger action
2361
- do_action( 'learn-press/user-enrolled-course', $course_id, $user_id, $user_course );
2362
-
2363
  $return = $user_course->get_user_item_id();
2364
  } catch ( Exception $ex ) {
2365
  if ( $wp_error ) {
@@ -2372,6 +2369,19 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
2372
  return $return;
2373
  }
2374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2375
  /**
2376
  * Enroll this user to a course.
2377
  *
2357
  );
2358
  $wpdb->query( $query );
2359
 
 
 
 
2360
  $return = $user_course->get_user_item_id();
2361
  } catch ( Exception $ex ) {
2362
  if ( $wp_error ) {
2369
  return $return;
2370
  }
2371
 
2372
+ /**
2373
+ * Send mail when user enrolled course
2374
+ * @param $user_id
2375
+ * @param $course_id
2376
+ */
2377
+ public function enrolled_sendmail( $user_id, $course_id ) {
2378
+ $user_course = $this->get_course_data( $this->get_id() );
2379
+ if ( $this->has_enrolled_course($course_id) ) {
2380
+ // Trigger action
2381
+ do_action( 'learn-press/user-enrolled-course', $course_id, $user_id, $user_course );
2382
+ }
2383
+ }
2384
+
2385
  /**
2386
  * Enroll this user to a course.
2387
  *
inc/user/class-lp-user-factory.php CHANGED
@@ -176,6 +176,8 @@ class LP_User_Factory {
176
 
177
  if ( $new_status == 'completed' && $can_enroll && $auto_enroll ) {
178
  $args['status'] = LP_COURSE_ENROLLED;
 
 
179
  }
180
 
181
  if ( $course->is_free() && $can_enroll ) {
176
 
177
  if ( $new_status == 'completed' && $can_enroll && $auto_enroll ) {
178
  $args['status'] = LP_COURSE_ENROLLED;
179
+ // Send mail when course enrolled
180
+ $user->enrolled_sendmail( $user_id, $course_id );
181
  }
182
 
183
  if ( $course->is_free() && $can_enroll ) {
languages/learnpress.pot CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the same license as the LearnPress plugin.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: LearnPress 4.0.0\n"
6
  "Report-Msgid-Bugs-To: https://github.com/LearnPress/learnpress/issues\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
2
  # This file is distributed under the same license as the LearnPress plugin.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: LearnPress 4.0.0n"
6
  "Report-Msgid-Bugs-To: https://github.com/LearnPress/learnpress/issues\n"
7
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
8
  "Language-Team: LANGUAGE <LL@li.org>\n"
learnpress.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
- * Version: 4.0.2
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 3.8
10
  * Tested up to: 5.7
@@ -446,7 +446,7 @@ if ( ! class_exists( 'LearnPress' ) ) {
446
  require_once 'inc/abstracts/abstract-rest-api.php';
447
  require_once 'inc/abstracts/abstract-rest-controller.php';
448
  require_once 'inc/rest-api/class-lp-core-api.php';
449
- require_once 'inc/rest-api/admin/class-lp-admin-core-api.php';
450
 
451
  include_once 'inc/theme-support/class-theme-support-base.php';
452
  include_once 'inc/class-lp-theme-support.php';
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
+ * Version: 4.0.3
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 3.8
10
  * Tested up to: 5.7
446
  require_once 'inc/abstracts/abstract-rest-api.php';
447
  require_once 'inc/abstracts/abstract-rest-controller.php';
448
  require_once 'inc/rest-api/class-lp-core-api.php';
449
+ require_once 'inc/rest-api/class-lp-admin-core-api.php';
450
 
451
  include_once 'inc/theme-support/class-theme-support-base.php';
452
  include_once 'inc/class-lp-theme-support.php';
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: elearning, education, course, lms, learning management system
5
  Requires at least: 5.6
6
  Tested up to: 5.7
7
  Requires PHP: 7.0
8
- Stable tag: 4.0.2
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -197,6 +197,12 @@ https://www.transifex.com/projects/p/learnpress/
197
 
198
  == Changelog ==
199
 
 
 
 
 
 
 
200
  = 4.0.2 =
201
  ~ Upgrade library chart.js to v3.2.1
202
  ~ Optimize query with cache get list questions on a quiz
5
  Requires at least: 5.6
6
  Tested up to: 5.7
7
  Requires PHP: 7.0
8
+ Stable tag: 4.0.3
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
197
 
198
  == Changelog ==
199
 
200
+ = 4.0.3 =
201
+ ~ Fixed: tool "Reset course progress"
202
+ ~ Added: tool "Create Database Indexes"
203
+ ~ Fixed js button "Retake course" if have more than one.
204
+ ~ Added: tool "Re upgrade Database" ~ If DB upgrade not success
205
+
206
  = 4.0.2 =
207
  ~ Upgrade library chart.js to v3.2.1
208
  ~ Optimize query with cache get list questions on a quiz
templates/global/lp-group-step.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for Step item.
4
+ *
5
+ * This template for js read and render each item.
6
+ * Purpose:
7
+ * 1. Define struct template group step
8
+ * 2. On js will read ".example-lp-item-step" and clone content ".lp-item-step"
9
+ * 3. Js will render data to template have just clone, and append to ".lp-group-step"
10
+ *
11
+ * @author tungnx
12
+ * @package Learnpress/Templates
13
+ * @version 1.0.0
14
+ * @since 4.0.3
15
+ */
16
+
17
+ ?>
18
+
19
+ <div class="example-lp-group-step">
20
+ <div class="lp-group-step">
21
+ </div>
22
+ <div class="example-lp-item-step">
23
+ <h3></h3>
24
+ <div class="lp-item-step">
25
+ <div class="lp-item-step-left">
26
+ <input type="hidden" name="" value="" />
27
+ </div>
28
+ <div class="lp-item-step-right">
29
+ <label for=""><strong></strong></label>
30
+ <div class="description"></div>
31
+ <div class="percent"></div>
32
+ <span class="progress-bar"></span>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
templates/pages/profile.php CHANGED
@@ -16,8 +16,6 @@ $profile = LP_Global::profile();
16
  do_action( 'learnpress/template/pages/profile/before-content' );
17
  ?>
18
 
19
- <?php echo lp_profile_page_content(); ?>
20
-
21
  <div id="learn-press-profile" <?php $profile->main_class(); ?>>
22
  <?php if ( $profile->is_public() || $profile->get_user()->is_guest() ) : ?>
23
 
16
  do_action( 'learnpress/template/pages/profile/before-content' );
17
  ?>
18
 
 
 
19
  <div id="learn-press-profile" <?php $profile->main_class(); ?>>
20
  <?php if ( $profile->is_public() || $profile->get_user()->is_guest() ) : ?>
21
 
templates/profile/tabs.php CHANGED
@@ -25,8 +25,7 @@ $profile = LP_Profile::instance();
25
  * @var LP_Profile_Tab $profile_tab
26
  */
27
  foreach ( $profile->get_tabs()->tabs() as $tab_key => $profile_tab ) {
28
-
29
- if ( $profile_tab->is_hidden() || ! $profile_tab->user_can_view() ) {
30
  continue;
31
  }
32
 
25
  * @var LP_Profile_Tab $profile_tab
26
  */
27
  foreach ( $profile->get_tabs()->tabs() as $tab_key => $profile_tab ) {
28
+ if ( ! is_object( $profile_tab ) || ! $profile_tab || $profile_tab->is_hidden() || ! $profile_tab->user_can_view() ) {
 
29
  continue;
30
  }
31
 
templates/single-course/buttons/finish.php CHANGED
@@ -10,14 +10,9 @@
10
  */
11
 
12
  defined( 'ABSPATH' ) || exit();
13
-
14
- $course = LP_Global::course();
15
- $user = LP_Global::user();
16
  ?>
17
 
18
- <form class="lp-form form-button form-button-finish-course" method="post"
19
- data-confirm="<?php LP_Strings::esc_attr_e( 'confirm-finish-course', '', array( $course->get_title() ) ); ?>"
20
- data-title="<?php echo esc_attr__( 'Finish course', 'learnpress' ) ?>">
21
  <button class="lp-button lp-btn-finish-course"><?php esc_html_e( 'Finish course', 'learnpress' ); ?></button>
22
  <input type="hidden" name="course-id" value="<?php echo esc_attr( $course->get_id() ); ?>"/>
23
  <input type="hidden" name="finish-course-nonce" value="<?php echo esc_attr( wp_create_nonce( sprintf( 'finish-course-%d-%d', $course->get_id(), $user->get_id() ) ) ); ?>"/>
10
  */
11
 
12
  defined( 'ABSPATH' ) || exit();
 
 
 
13
  ?>
14
 
15
+ <form class="lp-form form-button form-button-finish-course" method="post" data-confirm="<?php echo LP_Strings::esc_attr( 'confirm-finish-course', '', array( $course->get_title() ) ); ?>" data-title="<?php echo esc_attr__( 'Finish course', 'learnpress' ); ?>">
 
 
16
  <button class="lp-button lp-btn-finish-course"><?php esc_html_e( 'Finish course', 'learnpress' ); ?></button>
17
  <input type="hidden" name="course-id" value="<?php echo esc_attr( $course->get_id() ); ?>"/>
18
  <input type="hidden" name="finish-course-nonce" value="<?php echo esc_attr( wp_create_nonce( sprintf( 'finish-course-%d-%d', $course->get_id(), $user->get_id() ) ) ); ?>"/>
templates/single-course/content-item/popup-header.php CHANGED
@@ -38,11 +38,5 @@ $percentage = $course_results['count_items'] ? absint( $course_results['comp
38
  </div>
39
  </div>
40
  <?php endif; ?>
41
-
42
- <?php
43
- if ( $user->can_finish_course( $course->get_id() ) ) {
44
- LP()->template( 'course' )->course_finish_button();
45
- }
46
- ?>
47
  </div>
48
  </div>
38
  </div>
39
  </div>
40
  <?php endif; ?>
 
 
 
 
 
 
41
  </div>
42
  </div>