PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9.1
4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 All 141 releases
← All changes | assets/js/dist/admin/pages/tools.js +27 -353 4.4.2 → 4.4.9.1 View file →
@@ -599,254 +599,8 @@
599 599 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getStepsUpgradeStatus);
600 600
601 601 /***/ },
602 602
603 -/***/ "./assets/src/apps/js/admin/pages/tools/reset-data/course.js"
604 -/*!*******************************************************************!*\
605 - !*** ./assets/src/apps/js/admin/pages/tools/reset-data/course.js ***!
606 - \*******************************************************************/
607 -(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
608 -
609 -__webpack_require__.r(__webpack_exports__);
610 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
611 -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
612 -/* harmony export */ });
613 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
614 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
615 -
616 -/**
617 - * Reset course progress.
618 - *
619 - * @since 4.0.5.
620 - * @author Nhamdv - Code choi choi in Physcode.
621 - */
622 -const {
623 - __
624 -} = wp.i18n;
625 -const {
626 - TextControl,
627 - Button,
628 - Spinner,
629 - CheckboxControl,
630 - Notice
631 -} = wp.components;
632 -const {
633 - useState,
634 - useEffect
635 -} = wp.element;
636 -const {
637 - addQueryArgs
638 -} = wp.url;
639 -const ResetCourse = () => {
640 - const [loading, setLoading] = useState(false);
641 - const [search, setSearch] = useState('');
642 - const [data, setData] = useState([]);
643 - const [checkData, setCheckData] = useState([]);
644 - const [message, setMessage] = useState([]);
645 - const [loadingReset, setLoadingReset] = useState(false);
646 - useEffect(() => {
647 - responsiveData(search);
648 - }, [search]);
649 - const responsiveData = async s => {
650 - try {
651 - if (!s || loading) {
652 - setMessage([]);
653 - setData([]);
654 - return;
655 - }
656 - if (s.length < 3) {
657 - setMessage([{
658 - status: 'error',
659 - message: 'Please enter at least 3 characters to searching course.'
660 - }]);
661 - setData([]);
662 - return;
663 - }
664 - setLoading(true);
665 - const response = await wp.apiFetch({
666 - path: addQueryArgs('lp/v1/admin/tools/reset-data/search-courses', {
667 - s
668 - }),
669 - method: 'GET'
670 - });
671 - const {
672 - status,
673 - data
674 - } = response;
675 - setLoading(false);
676 - if (status === 'success') {
677 - setData(data);
678 - setMessage([]);
679 - } else {
680 - setMessage([{
681 - status: 'error',
682 - message: response.message || 'LearnPress: Search Course Fail!'
683 - }]);
684 - setData([]);
685 - }
686 - } catch (error) {
687 - console.log(error.message);
688 - }
689 - };
690 - function checkItems(id) {
691 - const datas = [...checkData];
692 - if (datas.includes(id)) {
693 - const index = datas.indexOf(id);
694 - if (index > -1) {
695 - datas.splice(index, 1);
696 - }
697 - } else {
698 - datas.push(id);
699 - }
700 - setCheckData(datas);
701 - }
702 - const resetCourse = async () => {
703 - if (checkData.length === 0) {
704 - setMessage([{
705 - status: 'error',
706 - message: 'Please chooce Course for reset data!'
707 - }]);
708 - return;
709 - }
710 -
711 - // eslint-disable-next-line no-alert
712 - if (!confirm('Are you sure to reset course progress of all users enrolled this course?')) {
713 - return;
714 - }
715 - const notice = [];
716 - try {
717 - setLoadingReset(true);
718 - for (const courseId of checkData) {
719 - const response = await wp.apiFetch({
720 - path: addQueryArgs('lp/v1/admin/tools/reset-data/reset-courses', {
721 - courseId
722 - }),
723 - method: 'GET'
724 - });
725 - const {
726 - status,
727 - data,
728 - message
729 - } = response;
730 - notice.push({
731 - status,
732 - message: message || `Course #${courseId} reset successfully!`
733 - });
734 - }
735 - setLoadingReset(false);
736 - } catch (error) {
737 - notice.push({
738 - status: 'error',
739 - message: error.message || `LearnPress Error: Reset Course Data.`
740 - });
741 - }
742 - setMessage(notice);
743 - };
744 - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h2", null, __('Reset Course Progress', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
745 - className: "description"
746 - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, __('This action will reset course progress of all users who have enrolled.', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, __('Search results only show if courses have user data.', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(TextControl, {
747 - placeholder: __('Search course by name', 'learnpress'),
748 - value: search,
749 - onChange: value => setSearch(value),
750 - style: {
751 - width: 300
752 - }
753 - }))), loading && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(Spinner, null), data.length > 0 && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
754 - className: "lp-reset-course_progress",
755 - style: {
756 - border: '1px solid #eee'
757 - }
758 - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
759 - style: {
760 - background: '#eee'
761 - }
762 - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(CheckboxControl, {
763 - checked: checkData.length === data.length,
764 - onChange: () => {
765 - if (checkData.length === data.length) {
766 - setCheckData([]);
767 - } else {
768 - setCheckData(data.map(dt => dt.id));
769 - }
770 - },
771 - style: {
772 - margin: 0
773 - }
774 - })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, __('ID', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, __('Name', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, __('Students', 'learnpress')))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
775 - style: {
776 - height: '100%',
777 - maxHeight: 200,
778 - overflow: 'auto'
779 - }
780 - }, data.map(dt => {
781 - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
782 - style: {
783 - borderTop: '1px solid #eee'
784 - },
785 - key: dt.id
786 - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(CheckboxControl, {
787 - checked: checkData.includes(dt.id),
788 - onChange: () => checkItems(dt.id)
789 - })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, "#", dt.id), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, dt.title), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, dt.students));
790 - }))), loadingReset ? (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(Spinner, null) : (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(Button, {
791 - isPrimary: true,
792 - onClick: () => resetCourse(),
793 - style: {
794 - marginTop: 10,
795 - height: 30
796 - }
797 - }, __('Reset now', 'learnpress'))), message.length > 0 && message.map((mess, index) => {
798 - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(Notice, {
799 - status: mess.status,
800 - key: index,
801 - isDismissible: false
802 - }, mess.message);
803 - }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("style", null, '\
804 - .lp-reset-course_progress .components-base-control__field {\
805 - margin: 0;\
806 - }\
807 - .components-notice{\
808 - margin-left: 0;\
809 - }\
810 - .lp-reset-course_progress > div > div{\
811 - display: grid;\
812 - grid-template-columns: 80px 50px 1fr 80px;\
813 - align-items: center;\
814 - }\
815 - .lp-reset-course_progress > div > div > div{\
816 - maegin: 0;\
817 - padding: 8px 10px;\
818 - }\
819 - '));
820 -};
821 -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ResetCourse);
822 -
823 -/***/ },
824 -
825 -/***/ "./assets/src/apps/js/admin/pages/tools/reset-data/index.js"
826 -/*!******************************************************************!*\
827 - !*** ./assets/src/apps/js/admin/pages/tools/reset-data/index.js ***!
828 - \******************************************************************/
829 -(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
830 -
831 -__webpack_require__.r(__webpack_exports__);
832 -/* harmony export */ __webpack_require__.d(__webpack_exports__, {
833 -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
834 -/* harmony export */ });
835 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
836 -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
837 -/* harmony import */ var _course__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./course */ "./assets/src/apps/js/admin/pages/tools/reset-data/course.js");
838 -
839 -
840 -const resetData = () => {
841 - if (document.querySelectorAll('#learn-press-reset-course-users').length > 0) {
842 - wp.element.render((0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_course__WEBPACK_IMPORTED_MODULE_1__["default"], null), [...document.querySelectorAll('#learn-press-reset-course-users')][0]);
843 - }
844 -};
845 -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (resetData);
846 -
847 -/***/ },
848 -
849 603 /***/ "./assets/src/apps/js/utils/handle-ajax-api.js"
850 604 /*!*****************************************************!*\
851 605 !*** ./assets/src/apps/js/utils/handle-ajax-api.js ***!
852 606 \*****************************************************/
@@ -942,34 +696,24 @@
942 696 }
943 697 };
944 698 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlay);
945 699
946 -/***/ },
947 -
948 -/***/ "react"
949 -/*!************************!*\
950 - !*** external "React" ***!
951 - \************************/
952 -(module) {
953 -
954 -module.exports = window["React"];
955 -
956 700 /***/ }
957 701
958 702 /******/ });
959 703 /************************************************************************/
960 704 /******/ // The module cache
961 -/******/ var __webpack_module_cache__ = {};
705 +/******/ const __webpack_module_cache__ = {};
962 706 /******/
963 707 /******/ // The require function
964 708 /******/ function __webpack_require__(moduleId) {
965 709 /******/ // Check if module is in cache
966 -/******/ var cachedModule = __webpack_module_cache__[moduleId];
710 +/******/ const cachedModule = __webpack_module_cache__[moduleId];
967 711 /******/ if (cachedModule !== undefined) {
968 712 /******/ return cachedModule.exports;
969 713 /******/ }
970 714 /******/ // Create a new module (and put it into the cache)
971 -/******/ var module = __webpack_module_cache__[moduleId] = {
715 +/******/ const module = __webpack_module_cache__[moduleId] = {
972 716 /******/ // no module.id needed
973 717 /******/ // no module.loaded needed
974 718 /******/ exports: {}
975 719 /******/ };
@@ -976,9 +720,9 @@
976 720 /******/
977 721 /******/ // Execute the module function
978 722 /******/ if (!(moduleId in __webpack_modules__)) {
979 723 /******/ delete __webpack_module_cache__[moduleId];
980 -/******/ var e = new Error("Cannot find module '" + moduleId + "'");
724 +/******/ const e = new Error("Cannot find module '" + moduleId + "'");
981 725 /******/ e.code = 'MODULE_NOT_FOUND';
982 726 /******/ throw e;
983 727 /******/ }
984 728 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
@@ -987,28 +731,31 @@
987 731 /******/ return module.exports;
988 732 /******/ }
989 733 /******/
990 734 /************************************************************************/
991 -/******/ /* webpack/runtime/compat get default export */
992 -/******/ (() => {
993 -/******/ // getDefaultExport function for compatibility with non-harmony modules
994 -/******/ __webpack_require__.n = (module) => {
995 -/******/ var getter = module && module.__esModule ?
996 -/******/ () => (module['default']) :
997 -/******/ () => (module);
998 -/******/ __webpack_require__.d(getter, { a: getter });
999 -/******/ return getter;
1000 -/******/ };
1001 -/******/ })();
1002 -/******/
1003 735 /******/ /* webpack/runtime/define property getters */
1004 736 /******/ (() => {
1005 -/******/ // define getter functions for harmony exports
737 +/******/ // define getter/value functions for harmony exports
1006 738 /******/ __webpack_require__.d = (exports, definition) => {
1007 -/******/ for(var key in definition) {
1008 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1009 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
739 +/******/ if(Array.isArray(definition)) {
740 +/******/ var i = 0;
741 +/******/ while(i < definition.length) {
742 +/******/ var key = definition[i++];
743 +/******/ var binding = definition[i++];
744 +/******/ if(!__webpack_require__.o(exports, key)) {
745 +/******/ if(binding === 0) {
746 +/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
747 +/******/ } else {
748 +/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
749 +/******/ }
750 +/******/ } else if(binding === 0) { i++; }
1010 751 /******/ }
752 +/******/ } else {
753 +/******/ for(var key in definition) {
754 +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
755 +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
756 +/******/ }
757 +/******/ }
1011 758 /******/ }
1012 759 /******/ };
1013 760 /******/ })();
1014 761 /******/
@@ -1013,9 +760,9 @@
1013 760 /******/ })();
1014 761 /******/
1015 762 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1016 763 /******/ (() => {
1017 -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
764 +/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
1018 765 /******/ })();
1019 766 /******/
1020 767 /******/ /* webpack/runtime/make namespace object */
1021 768 /******/ (() => {
@@ -1020,9 +767,9 @@
1020 767 /******/ /* webpack/runtime/make namespace object */
1021 768 /******/ (() => {
1022 769 /******/ // define __esModule on exports
1023 770 /******/ __webpack_require__.r = (exports) => {
1024 -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
771 +/******/ if(Symbol.toStringTag) {
1025 772 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1026 773 /******/ }
1027 774 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1028 775 /******/ };
@@ -1028,9 +775,9 @@
1028 775 /******/ };
1029 776 /******/ })();
1030 777 /******/
1031 778 /************************************************************************/
1032 -var __webpack_exports__ = {};
779 +let __webpack_exports__ = {};
1033 780 // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
1034 781 (() => {
1035 782 /*!*************************************************!*\
1036 783 !*** ./assets/src/apps/js/admin/pages/tools.js ***!
@@ -1039,70 +786,14 @@
1039 786 /* harmony import */ var _tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/database/upgrade */ "./assets/src/apps/js/admin/pages/tools/database/upgrade.js");
1040 787 /* harmony import */ var _tools_database_create_indexs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools/database/create_indexs */ "./assets/src/apps/js/admin/pages/tools/database/create_indexs.js");
1041 788 /* harmony import */ var _tools_database_re_upgrade_db__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools/database/re-upgrade-db */ "./assets/src/apps/js/admin/pages/tools/database/re-upgrade-db.js");
1042 789 /* harmony import */ var _tools_database_clean_database__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/database/clean_database */ "./assets/src/apps/js/admin/pages/tools/database/clean_database.js");
1043 -/* harmony import */ var _tools_reset_data__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tools/reset-data */ "./assets/src/apps/js/admin/pages/tools/reset-data/index.js");
1044 790
1045 791
1046 792
1047 793
1048 -
1049 794 (function ($) {
1050 795 const $doc = $(document);
1051 - let isRunning = false;
1052 - const installSampleCourse = function installSampleCourse(e) {
1053 - e.preventDefault();
1054 - const $button = $(this);
1055 - if (isRunning) {
1056 - return;
1057 - }
1058 - if (!confirm(lpGlobalSettings.i18n.confirm_install_sample_data)) {
1059 - return;
1060 - }
1061 - $button.addClass('disabled').html($button.data('installing-text'));
1062 - $('.lp-install-sample__response').remove();
1063 - isRunning = true;
1064 - $.ajax({
1065 - method: 'POST',
1066 - url: $button.attr('href'),
1067 - data: $('.lp-install-sample__options').serializeJSON(),
1068 - success(response) {
1069 - $button.removeClass('disabled').html($button.data('text'));
1070 - isRunning = false;
1071 - $(response).insertBefore($button.parent());
1072 - },
1073 - error() {
1074 - $button.removeClass('disabled').html($button.data('text'));
1075 - isRunning = false;
1076 - $(response).insertBefore($button.parent());
1077 - }
1078 - });
1079 - };
1080 - const uninstallSampleCourse = function uninstallSampleCourse(e) {
1081 - e.preventDefault();
1082 - const $button = $(this);
1083 - if (isRunning) {
1084 - return;
1085 - }
1086 - if (!confirm(lpGlobalSettings.i18n.confirm_uninstall_sample_data)) {
1087 - return;
1088 - }
1089 - $button.addClass('disabled').html($button.data('uninstalling-text'));
1090 - isRunning = true;
1091 - $.ajax({
1092 - url: $button.attr('href'),
1093 - success(response) {
1094 - $button.removeClass('disabled').html($button.data('text'));
1095 - isRunning = false;
1096 - $(response).insertBefore($button.parent());
1097 - },
1098 - error() {
1099 - $button.removeClass('disabled').html($button.data('text'));
1100 - isRunning = false;
1101 - $(response).insertBefore($button.parent());
1102 - }
1103 - });
1104 - };
1105 796 const clearHardCache = function clearHardCache(e) {
1106 797 e.preventDefault();
1107 798 const $button = $(this);
1108 799 if ($button.hasClass('disabled')) {
@@ -1129,31 +820,14 @@
1129 820 success(response) {},
1130 821 error() {}
1131 822 });
1132 823 };
1133 - const toggleOptions = function toggleOptions(e) {
1134 - e.preventDefault();
1135 - $('.lp-install-sample__options').toggleClass('hide-if-js');
1136 - };
1137 - const formatValueInput = e => {
1138 - const input = $(e.target);
1139 - let value = input.val();
1140 - value = value.replace(/[^0-9]/g, '');
1141 - input.val(value);
1142 - if (parseInt(value, 10) < input.attr('min')) {
1143 - input.val(input.attr('min'));
1144 - }
1145 - if (parseInt(value, 10) > input.attr('max')) {
1146 - input.val(input.attr('max'));
1147 - }
1148 - };
1149 824 $(function () {
1150 825 (0,_tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__["default"])();
1151 826 (0,_tools_database_create_indexs__WEBPACK_IMPORTED_MODULE_1__["default"])();
1152 827 (0,_tools_database_re_upgrade_db__WEBPACK_IMPORTED_MODULE_2__["default"])();
1153 - (0,_tools_reset_data__WEBPACK_IMPORTED_MODULE_4__["default"])();
1154 828 (0,_tools_database_clean_database__WEBPACK_IMPORTED_MODULE_3__["default"])();
1155 - $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).on('change', 'input[name="section-range[]"]', formatValueInput).on('change', 'input[name="item-range[]"]', formatValueInput).on('change', 'input[name="question-range[]"]', formatValueInput).on('change', 'input[name="answer-range[]"]', formatValueInput).on('change', 'input[name="course-price"]', formatValueInput);
829 + $doc.on('click', '#learn-press-clear-cache', clearHardCache).on('click', 'input[name="enable_hard_cache"]', toggleHardCache);
1156 830 });
1157 831 })(jQuery);
1158 832 })();
1159 833