PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | assets/js/dist/admin/pages/tools.js +12 -368 4.4.4 → 4.4.9 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 -/******/ const __webpack_module_cache__ = {};
705 +/******/ var __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 -/******/ const cachedModule = __webpack_module_cache__[moduleId];
710 +/******/ var 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 -/******/ const module = __webpack_module_cache__[moduleId] = {
715 +/******/ var 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 -/******/ const e = new Error("Cannot find module '" + moduleId + "'");
724 +/******/ var 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,43 +731,16 @@
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 -/******/ const 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/value functions for harmony exports
737 +/******/ // define getter functions for harmony exports
1006 738 /******/ __webpack_require__.d = (exports, definition) => {
1007 -/******/ if(Array.isArray(definition)) {
1008 -/******/ var i = 0;
1009 -/******/ while(i < definition.length) {
1010 -/******/ var key = definition[i++];
1011 -/******/ var binding = definition[i++];
1012 -/******/ if(!__webpack_require__.o(exports, key)) {
1013 -/******/ if(binding === 0) {
1014 -/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
1015 -/******/ } else {
1016 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
1017 -/******/ }
1018 -/******/ } else if(binding === 0) { i++; }
739 +/******/ for(var key in definition) {
740 +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
741 +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1019 742 /******/ }
1020 -/******/ } else {
1021 -/******/ for(var key in definition) {
1022 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1023 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1024 -/******/ }
1025 -/******/ }
1026 743 /******/ }
1027 744 /******/ };
1028 745 /******/ })();
1029 746 /******/
@@ -1028,9 +745,9 @@
1028 745 /******/ })();
1029 746 /******/
1030 747 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1031 748 /******/ (() => {
1032 -/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
749 +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1033 750 /******/ })();
1034 751 /******/
1035 752 /******/ /* webpack/runtime/make namespace object */
1036 753 /******/ (() => {
@@ -1035,9 +752,9 @@
1035 752 /******/ /* webpack/runtime/make namespace object */
1036 753 /******/ (() => {
1037 754 /******/ // define __esModule on exports
1038 755 /******/ __webpack_require__.r = (exports) => {
1039 -/******/ if(Symbol.toStringTag) {
756 +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1040 757 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1041 758 /******/ }
1042 759 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1043 760 /******/ };
@@ -1043,9 +760,9 @@
1043 760 /******/ };
1044 761 /******/ })();
1045 762 /******/
1046 763 /************************************************************************/
1047 -let __webpack_exports__ = {};
764 +var __webpack_exports__ = {};
1048 765 // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
1049 766 (() => {
1050 767 /*!*************************************************!*\
1051 768 !*** ./assets/src/apps/js/admin/pages/tools.js ***!
@@ -1054,70 +771,14 @@
1054 771 /* 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");
1055 772 /* 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");
1056 773 /* 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");
1057 774 /* 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");
1058 -/* 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");
1059 775
1060 776
1061 777
1062 778
1063 -
1064 779 (function ($) {
1065 780 const $doc = $(document);
1066 - let isRunning = false;
1067 - const installSampleCourse = function installSampleCourse(e) {
1068 - e.preventDefault();
1069 - const $button = $(this);
1070 - if (isRunning) {
1071 - return;
1072 - }
1073 - if (!confirm(lpGlobalSettings.i18n.confirm_install_sample_data)) {
1074 - return;
1075 - }
1076 - $button.addClass('disabled').html($button.data('installing-text'));
1077 - $('.lp-install-sample__response').remove();
1078 - isRunning = true;
1079 - $.ajax({
1080 - method: 'POST',
1081 - url: $button.attr('href'),
1082 - data: $('.lp-install-sample__options').serializeJSON(),
1083 - success(response) {
1084 - $button.removeClass('disabled').html($button.data('text'));
1085 - isRunning = false;
1086 - $(response).insertBefore($button.parent());
1087 - },
1088 - error() {
1089 - $button.removeClass('disabled').html($button.data('text'));
1090 - isRunning = false;
1091 - $(response).insertBefore($button.parent());
1092 - }
1093 - });
1094 - };
1095 - const uninstallSampleCourse = function uninstallSampleCourse(e) {
1096 - e.preventDefault();
1097 - const $button = $(this);
1098 - if (isRunning) {
1099 - return;
1100 - }
1101 - if (!confirm(lpGlobalSettings.i18n.confirm_uninstall_sample_data)) {
1102 - return;
1103 - }
1104 - $button.addClass('disabled').html($button.data('uninstalling-text'));
1105 - isRunning = true;
1106 - $.ajax({
1107 - url: $button.attr('href'),
1108 - success(response) {
1109 - $button.removeClass('disabled').html($button.data('text'));
1110 - isRunning = false;
1111 - $(response).insertBefore($button.parent());
1112 - },
1113 - error() {
1114 - $button.removeClass('disabled').html($button.data('text'));
1115 - isRunning = false;
1116 - $(response).insertBefore($button.parent());
1117 - }
1118 - });
1119 - };
1120 781 const clearHardCache = function clearHardCache(e) {
1121 782 e.preventDefault();
1122 783 const $button = $(this);
1123 784 if ($button.hasClass('disabled')) {
@@ -1144,31 +805,14 @@
1144 805 success(response) {},
1145 806 error() {}
1146 807 });
1147 808 };
1148 - const toggleOptions = function toggleOptions(e) {
1149 - e.preventDefault();
1150 - $('.lp-install-sample__options').toggleClass('hide-if-js');
1151 - };
1152 - const formatValueInput = e => {
1153 - const input = $(e.target);
1154 - let value = input.val();
1155 - value = value.replace(/[^0-9]/g, '');
1156 - input.val(value);
1157 - if (parseInt(value, 10) < input.attr('min')) {
1158 - input.val(input.attr('min'));
1159 - }
1160 - if (parseInt(value, 10) > input.attr('max')) {
1161 - input.val(input.attr('max'));
1162 - }
1163 - };
1164 809 $(function () {
1165 810 (0,_tools_database_upgrade__WEBPACK_IMPORTED_MODULE_0__["default"])();
1166 811 (0,_tools_database_create_indexs__WEBPACK_IMPORTED_MODULE_1__["default"])();
1167 812 (0,_tools_database_re_upgrade_db__WEBPACK_IMPORTED_MODULE_2__["default"])();
1168 - (0,_tools_reset_data__WEBPACK_IMPORTED_MODULE_4__["default"])();
1169 813 (0,_tools_database_clean_database__WEBPACK_IMPORTED_MODULE_3__["default"])();
1170 - $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);
814 + $doc.on('click', '#learn-press-clear-cache', clearHardCache).on('click', 'input[name="enable_hard_cache"]', toggleHardCache);
1171 815 });
1172 816 })(jQuery);
1173 817 })();
1174 818