LearnPress – WordPress LMS Plugin - Version 4.1.7.3

Version Description

(2022-11-02) = ~ Updated: text grammar. ~ Modified: LP_DateTime class. ~ Added: Course category and tag to menu. ~ Changed: input type regular price, sale price to text. ~ Call quiz get_questions function to get_question_ids. ~ Fixed: upgrade LP3 to LP4 missing result of lesson. ~ Remove file class-lp-backward-plugins.php, class-lp-factory.php, class-lp-query-search.php, class-lp-course-utils.php, class-lp-rest-authentication.php ~ Remove code deprecated before.

Download this release

Release Info

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

Code changes from version 4.1.7.2 to 4.1.7.3

Files changed (222) hide show
  1. assets/css/admin/admin-rtl.css +3 -0
  2. assets/css/admin/admin.css +3 -0
  3. assets/css/learnpress-rtl.css +2 -0
  4. assets/css/learnpress.css +2 -0
  5. assets/js/dist/admin/pages/tools.min.js +1 -1
  6. assets/js/dist/blocks/index.min.js +2 -2
  7. assets/js/dist/frontend/courses.js +5 -5
  8. assets/js/dist/frontend/profile.js +15 -35
  9. assets/js/dist/frontend/profile.min.js +1 -1
  10. assets/js/dist/frontend/question-types.min.js +1 -1
  11. assets/js/dist/frontend/quiz.js +9 -3
  12. assets/js/dist/frontend/quiz.min.js +1 -1
  13. assets/js/dist/frontend/single-course.js +2 -8
  14. assets/js/dist/frontend/single-curriculum.js +2 -8
  15. assets/src/apps/js/admin/pages/tools/database/upgrade.js +4 -0
  16. assets/src/apps/js/blocks/template/edit.js +1 -1
  17. assets/src/apps/js/frontend/profile/avatar.js +2 -2
  18. assets/src/apps/js/frontend/question-types/components/question-base/index.js +1 -1
  19. assets/src/apps/js/frontend/quiz/components/attempts/index.js +1 -1
  20. assets/src/apps/js/frontend/quiz/components/buttons/button-check.js +2 -2
  21. assets/src/apps/js/frontend/quiz/components/buttons/index.js +2 -2
  22. assets/src/apps/js/frontend/quiz/components/status/index.js +1 -1
  23. assets/src/apps/js/frontend/quiz/store/reducer.js +2 -3
  24. assets/src/apps/js/frontend/single-course/student-list.js +0 -96
  25. config/settings/course.php +14 -14
  26. config/settings/general.php +7 -7
  27. inc/abstract-settings.php +1 -1
  28. inc/abstracts/abstract-addon.php +4 -0
  29. inc/abstracts/abstract-object-data.php +38 -31
  30. inc/abstracts/abstract-rest-api.php +1 -1
  31. inc/admin/class-lp-admin-ajax.php +5 -5
  32. inc/admin/class-lp-admin-assets.php +2 -2
  33. inc/admin/class-lp-admin-menu.php +49 -37
  34. inc/admin/class-lp-admin.php +56 -89
  35. inc/admin/class-lp-install-sample-data.php +4 -4
  36. inc/admin/class-lp-reset-data.php +16 -10
  37. inc/admin/class-lp-setup-wizard.php +1 -1
  38. inc/admin/class-lp-updater.php +5 -5
  39. inc/admin/editor/class-lp-admin-editor-quiz.php +6 -4
  40. inc/admin/lp-admin-actions.php +2 -8
  41. inc/admin/lp-admin-functions.php +14 -32
  42. inc/admin/meta-box/fields/email-content.php +2 -2
  43. inc/admin/meta-box/fields/image-advanced.php +1 -1
  44. inc/admin/settings/class-lp-settings-advanced.php +2 -2
  45. inc/admin/settings/class-lp-settings-payments.php +3 -3
  46. inc/admin/settings/class-lp-settings-profile.php +3 -3
  47. inc/admin/sub-menus/abstract-submenu.php +9 -0
  48. inc/admin/sub-menus/class-lp-submenu-addons.php +3 -2
  49. inc/admin/sub-menus/class-lp-submenu-categories.php +17 -0
  50. inc/admin/sub-menus/class-lp-submenu-settings.php +1 -0
  51. inc/admin/sub-menus/class-lp-submenu-statistics.php +1 -1
  52. inc/admin/sub-menus/class-lp-submenu-tags.php +17 -0
  53. inc/admin/sub-menus/class-lp-submenu-tools.php +8 -18
  54. inc/admin/views/addons/html-plugins-more.php +1 -1
  55. inc/admin/views/course/editor.php +1 -1
  56. inc/admin/views/course/modal-choose-items.php +1 -1
  57. inc/admin/views/course/section-item.php +2 -2
  58. inc/admin/views/dashboard/plugin-status/html-results.php +1 -1
  59. inc/admin/views/html-admin-notice-templates.php +3 -3
  60. inc/admin/views/meta-boxes/course/settings.php +17 -17
  61. inc/admin/views/meta-boxes/fields/autocomplete.php +3 -0
  62. inc/admin/views/meta-boxes/order/actions.php +1 -1
  63. inc/admin/views/meta-boxes/order/details.php +6 -6
  64. inc/admin/views/meta-boxes/question/settings.php +2 -2
  65. inc/admin/views/meta-boxes/quiz/settings.php +8 -8
  66. inc/admin/views/question/answer.php +1 -1
  67. inc/admin/views/question/fib-answer-editor.php +5 -5
  68. inc/admin/views/quiz/modal-choose-items.php +1 -1
  69. inc/admin/views/quiz/question-actions.php +2 -2
  70. inc/admin/views/quiz/question-meta.php +2 -2
  71. inc/admin/views/setup/setup-paypal.php +1 -1
  72. inc/admin/views/setup/steps/currency.php +2 -2
  73. inc/admin/views/setup/steps/emails.php +3 -3
  74. inc/admin/views/setup/steps/pages.php +2 -2
  75. inc/admin/views/statistics/general.php +1 -1
  76. inc/admin/views/tools/database/html-upgrade-database.php +1 -1
  77. inc/admin/views/tools/html-cron.php +0 -34
  78. inc/admin/views/updates/html-updated-latest-message.php +1 -1
  79. inc/admin/views/updates/html-updating-message.php +1 -1
  80. inc/admin/views/user/courses.php +1 -1
  81. inc/background-process/class-lp-background-query-items.php +3 -3
  82. inc/background-process/class-lp-background-single-course.php +1 -1
  83. inc/cart/class-lp-cart.php +2 -56
  84. inc/class-lp-ajax.php +2 -2
  85. inc/class-lp-backward-plugins.php +0 -117
  86. inc/class-lp-checkout.php +2 -2
  87. inc/class-lp-datetime.php +55 -45
  88. inc/class-lp-factory.php +0 -20
  89. inc/class-lp-forms-handler.php +51 -17
  90. inc/class-lp-global.php +9 -50
  91. inc/class-lp-helper.php +5 -4
  92. inc/class-lp-install.php +1 -55
  93. inc/class-lp-nonce-helper.php +2 -2
  94. inc/class-lp-page-controller.php +4 -4
  95. inc/class-lp-query-search.php +0 -107
  96. inc/class-lp-request-handler.php +2 -0
  97. inc/class-lp-shortcodes.php +1 -1
  98. inc/class-lp-strings.php +6 -6
  99. inc/class-lp-template.php +18 -5
  100. inc/class-lp-widget.php +1 -1
  101. inc/course/abstract-course.php +8 -19
  102. inc/course/class-lp-course-item.php +2 -2
  103. inc/course/class-lp-course-no-required-enroll.php +2 -2
  104. inc/course/class-lp-course-section.php +1 -1
  105. inc/course/class-lp-course-utils.php +0 -107
  106. inc/course/class-lp-course.php +1 -1
  107. inc/course/lp-course-functions.php +9 -37
  108. inc/curds/class-lp-course-curd.php +5 -5
  109. inc/curds/class-lp-lesson-curd.php +1 -1
  110. inc/curds/class-lp-order-curd.php +3 -3
  111. inc/curds/class-lp-question-curd.php +5 -5
  112. inc/curds/class-lp-quiz-curd.php +25 -68
  113. inc/curds/class-lp-section-curd.php +2 -2
  114. inc/curds/class-lp-user-curd.php +10 -10
  115. inc/curds/class-lp-user-item-curd.php +3 -3
  116. inc/custom-post-types/abstract.php +4 -4
  117. inc/custom-post-types/course.php +9 -9
  118. inc/custom-post-types/lesson.php +2 -2
  119. inc/custom-post-types/order.php +4 -4
  120. inc/custom-post-types/question.php +4 -4
  121. inc/custom-post-types/quiz.php +4 -4
  122. inc/databases/class-lp-course-db.php +0 -35
  123. inc/databases/class-lp-order-db.php +2 -2
  124. inc/databases/class-lp-section-db.php +2 -2
  125. inc/databases/class-lp-user-items-db.php +3 -3
  126. inc/emails/admin/class-lp-email-cancelled-order-admin.php +3 -3
  127. inc/emails/admin/class-lp-email-completed-order-admin.php +3 -3
  128. inc/emails/admin/class-lp-email-enrolled-course-admin.php +3 -3
  129. inc/emails/admin/class-lp-email-finished-course-admin.php +3 -3
  130. inc/emails/class-lp-email.php +1 -1
  131. inc/emails/guest/class-lp-email-cancelled-order-guest.php +1 -1
  132. inc/emails/guest/class-lp-email-completed-order-guest.php +1 -1
  133. inc/emails/guest/class-lp-email-new-order-guest.php +1 -1
  134. inc/emails/guest/class-lp-email-processing-order-guest.php +1 -1
  135. inc/emails/instructor/class-lp-email-cancelled-order-instructor.php +3 -3
  136. inc/emails/instructor/class-lp-email-enrolled-course-instructor.php +3 -3
  137. inc/emails/instructor/class-lp-email-finished-course-instructor.php +3 -3
  138. inc/emails/instructor/class-lp-email-instructor-accepted.php +3 -3
  139. inc/emails/instructor/class-lp-email-instructor-denied.php +3 -3
  140. inc/emails/instructor/class-lp-email-new-order-instructor.php +1 -1
  141. inc/emails/student/class-lp-email-cancelled-order-user.php +1 -1
  142. inc/emails/student/class-lp-email-completed-order-user.php +1 -1
  143. inc/emails/student/class-lp-email-enrolled-course-user.php +3 -3
  144. inc/emails/student/class-lp-email-finished-course-user.php +3 -3
  145. inc/emails/student/class-lp-email-new-order-user.php +1 -1
  146. inc/emails/student/class-lp-email-processing-order-user.php +1 -1
  147. inc/emails/types/class-lp-email-reset-password.php +1 -1
  148. inc/emails/types/class-lp-email-type-finished-course.php +3 -1
  149. inc/external-plugin/elementor/widgets/become-a-teacher.php +1 -1
  150. inc/external-plugin/elementor/widgets/login-form.php +1 -1
  151. inc/external-plugin/elementor/widgets/register-form.php +1 -1
  152. inc/gateways/offline-payment/class-lp-gateway-offline-payment.php +1 -1
  153. inc/gateways/paypal/class-lp-gateway-paypal.php +1 -1
  154. inc/handle-steps/class-lp-handle-steps.php +3 -3
  155. inc/jwt/includes/class-jwt-public.php +2 -2
  156. inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php +24 -23
  157. inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php +8 -8
  158. inc/jwt/rest-api/version1/class-lp-rest-posts-controller.php +13 -13
  159. inc/jwt/rest-api/version1/class-lp-rest-questions-v1-controller.php +3 -3
  160. inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php +10 -10
  161. inc/jwt/rest-api/version1/class-lp-rest-section-items-v1-controller.php +8 -8
  162. inc/jwt/rest-api/version1/class-lp-rest-sections-v1-controller.php +7 -7
  163. inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php +7 -7
  164. inc/lp-core-functions.php +60 -72
  165. inc/lp-deprecated.php +28 -28
  166. inc/lp-template-functions.php +4 -21
  167. inc/lp-webhooks.php +1 -1
  168. inc/order/class-lp-order.php +4 -6
  169. inc/order/lp-order-functions.php +4 -4
  170. inc/question/class-lp-question.php +4 -4
  171. inc/quiz/class-lp-quiz.php +42 -47
  172. inc/quiz/lp-quiz-functions.php +3 -1
  173. inc/rest-api/class-lp-rest-authentication.php +0 -185
  174. inc/rest-api/v1/admin/class-lp-admin-rest-reset-data-controller.php +1 -1
  175. inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php +18 -15
  176. inc/rest-api/v1/frontend/class-lp-rest-lazy-load-controller.php +7 -7
  177. inc/rest-api/v1/frontend/class-lp-rest-profile-controller.php +7 -7
  178. inc/rest-api/v1/frontend/class-lp-rest-settings-controller.php +1 -1
  179. inc/rest-api/v1/frontend/class-lp-rest-users-controller.php +25 -21
  180. inc/settings/abstract-settings-page.php +1 -1
  181. inc/shortcodes/class-lp-shortcode-become-a-teacher.php +2 -2
  182. inc/shortcodes/class-lp-shortcode-button-enroll.php +0 -96
  183. inc/shortcodes/class-lp-shortcode-button-purchase.php +0 -1
  184. inc/shortcodes/class-lp-shortcode-profile.php +1 -1
  185. inc/templates/class-lp-template-course.php +19 -13
  186. inc/updates/learnpress-upgrade-4.php +131 -15
  187. inc/user-item/class-lp-user-item-course.php +9 -9
  188. inc/user-item/class-lp-user-item-quiz.php +5 -5
  189. inc/user-item/class-lp-user-item.php +37 -97
  190. inc/user/abstract-lp-user.php +18 -21
  191. inc/user/class-lp-profile-tabs.php +0 -1
  192. inc/user/class-lp-profile.php +15 -37
  193. inc/user/class-lp-user-factory.php +17 -18
  194. inc/user/class-lp-user.php +24 -25
  195. inc/user/lp-user-functions.php +55 -65
  196. inc/widgets/course-progress.php +2 -2
  197. languages/learnpress.pot +743 -782
  198. learnpress.php +5 -15
  199. mu-plugin/class-lp-mu-plugin.php +0 -149
  200. readme.txt +11 -1
  201. templates/checkout/form.php +1 -1
  202. templates/checkout/guest-checkout.php +1 -1
  203. templates/checkout/order-received.php +1 -1
  204. templates/content-lesson/button-complete.php +1 -1
  205. templates/content-lesson/content.php +1 -1
  206. templates/global/before-main-content.php +2 -2
  207. templates/global/block-content.php +1 -1
  208. templates/global/no-courses-found.php +1 -1
  209. templates/pages/profile.php +1 -1
  210. templates/profile/content.php +1 -1
  211. templates/profile/tabs/courses/course-list.php +4 -2
  212. templates/profile/tabs/courses/general-statistic.php +5 -5
  213. templates/profile/tabs/orders/recover-order.php +2 -2
  214. templates/profile/tabs/settings/change-password.php +1 -1
  215. templates/single-course/buttons/retry.php +1 -1
  216. templates/single-course/content-item/popup-sidebar.php +1 -1
  217. templates/single-course/content-protected.php +1 -1
  218. templates/single-course/sidebar/user-progress.php +4 -8
  219. templates/single-course/sidebar/user-time.php +9 -9
  220. templates/single-course/tabs/curriculum-v2.php +1 -1
  221. templates/single-course/tabs/curriculum.php +1 -1
  222. templates/single-course/tabs/tabs.php +1 -1
assets/css/admin/admin-rtl.css CHANGED
@@ -1172,6 +1172,7 @@ ul .clearfix {
1172
  .learn-press-advertisement-slider .slide-item .slide-detail .slide-controls .button {
1173
  margin-bottom: 0;
1174
  }
 
1175
  .wp-responsive-open .learn-press-advertisement-slider {
1176
  margin-right: 56px;
1177
  }
@@ -2566,6 +2567,7 @@ input[name=_lp_course_result]:checked ~ #passing-condition-quiz-result {
2566
  .plugin-card:not(.hide-if-js):nth-child(even) {
2567
  margin-left: 8px;
2568
  }
 
2569
  .plugin-card:not(.hide-if-js):nth-child(3n) {
2570
  margin-left: 0;
2571
  }
@@ -6069,6 +6071,7 @@ body.lp-item-moving {
6069
  .learn-press-dropdown-pages .select2-selection__rendered {
6070
  line-height: 31px !important;
6071
  }
 
6072
  #learn-press-advertisement {
6073
  margin: 0 12px;
6074
  padding-bottom: 0;
1172
  .learn-press-advertisement-slider .slide-item .slide-detail .slide-controls .button {
1173
  margin-bottom: 0;
1174
  }
1175
+
1176
  .wp-responsive-open .learn-press-advertisement-slider {
1177
  margin-right: 56px;
1178
  }
2567
  .plugin-card:not(.hide-if-js):nth-child(even) {
2568
  margin-left: 8px;
2569
  }
2570
+
2571
  .plugin-card:not(.hide-if-js):nth-child(3n) {
2572
  margin-left: 0;
2573
  }
6071
  .learn-press-dropdown-pages .select2-selection__rendered {
6072
  line-height: 31px !important;
6073
  }
6074
+
6075
  #learn-press-advertisement {
6076
  margin: 0 12px;
6077
  padding-bottom: 0;
assets/css/admin/admin.css CHANGED
@@ -1172,6 +1172,7 @@ ul .clearfix {
1172
  .learn-press-advertisement-slider .slide-item .slide-detail .slide-controls .button {
1173
  margin-bottom: 0;
1174
  }
 
1175
  .wp-responsive-open .learn-press-advertisement-slider {
1176
  margin-left: 56px;
1177
  }
@@ -2566,6 +2567,7 @@ input[name=_lp_course_result]:checked ~ #passing-condition-quiz-result {
2566
  .plugin-card:not(.hide-if-js):nth-child(even) {
2567
  margin-right: 8px;
2568
  }
 
2569
  .plugin-card:not(.hide-if-js):nth-child(3n) {
2570
  margin-right: 0;
2571
  }
@@ -6069,6 +6071,7 @@ body.lp-item-moving {
6069
  .learn-press-dropdown-pages .select2-selection__rendered {
6070
  line-height: 31px !important;
6071
  }
 
6072
  #learn-press-advertisement {
6073
  margin: 0 12px;
6074
  padding-bottom: 0;
1172
  .learn-press-advertisement-slider .slide-item .slide-detail .slide-controls .button {
1173
  margin-bottom: 0;
1174
  }
1175
+
1176
  .wp-responsive-open .learn-press-advertisement-slider {
1177
  margin-left: 56px;
1178
  }
2567
  .plugin-card:not(.hide-if-js):nth-child(even) {
2568
  margin-right: 8px;
2569
  }
2570
+
2571
  .plugin-card:not(.hide-if-js):nth-child(3n) {
2572
  margin-right: 0;
2573
  }
6071
  .learn-press-dropdown-pages .select2-selection__rendered {
6072
  line-height: 31px !important;
6073
  }
6074
+
6075
  #learn-press-advertisement {
6076
  margin: 0 12px;
6077
  padding-bottom: 0;
assets/css/learnpress-rtl.css CHANGED
@@ -3519,6 +3519,7 @@ input[name=course-faqs-box-ratio]:checked + .course-faqs-box .course-faqs-box__t
3519
  body.course-item-popup.wpadminbar #learn-press-course-curriculum {
3520
  top: 106px;
3521
  }
 
3522
  .learn-press-course-results-progress {
3523
  margin-left: 0%;
3524
  }
@@ -6912,6 +6913,7 @@ body.lp-sidebar-toggle__close #popup-course #popup-header, body.lp-sidebar-toggl
6912
  body.admin-bar #popup-course {
6913
  top: 46px;
6914
  }
 
6915
  #popup-course #popup-sidebar {
6916
  flex-basis: 250px;
6917
  }
3519
  body.course-item-popup.wpadminbar #learn-press-course-curriculum {
3520
  top: 106px;
3521
  }
3522
+
3523
  .learn-press-course-results-progress {
3524
  margin-left: 0%;
3525
  }
6913
  body.admin-bar #popup-course {
6914
  top: 46px;
6915
  }
6916
+
6917
  #popup-course #popup-sidebar {
6918
  flex-basis: 250px;
6919
  }
assets/css/learnpress.css CHANGED
@@ -3519,6 +3519,7 @@ input[name=course-faqs-box-ratio]:checked + .course-faqs-box .course-faqs-box__t
3519
  body.course-item-popup.wpadminbar #learn-press-course-curriculum {
3520
  top: 106px;
3521
  }
 
3522
  .learn-press-course-results-progress {
3523
  margin-right: 0%;
3524
  }
@@ -6912,6 +6913,7 @@ body.lp-sidebar-toggle__close #popup-course #popup-header, body.lp-sidebar-toggl
6912
  body.admin-bar #popup-course {
6913
  top: 46px;
6914
  }
 
6915
  #popup-course #popup-sidebar {
6916
  flex-basis: 250px;
6917
  }
3519
  body.course-item-popup.wpadminbar #learn-press-course-curriculum {
3520
  top: 106px;
3521
  }
3522
+
3523
  .learn-press-course-results-progress {
3524
  margin-right: 0%;
3525
  }
6913
  body.admin-bar #popup-course {
6914
  top: 46px;
6915
  }
6916
+
6917
  #popup-course #popup-sidebar {
6918
  flex-basis: 250px;
6919
  }
assets/js/dist/admin/pages/tools.min.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";const e=jQuery;let t=null;const s={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=e(".lp-overlay"),!!this.elLPOverlay.length&&(t=this.elLPOverlay,this.elMainContent=t.find(".main-content"),this.elTitle=t.find(".modal-title"),this.elBtnYes=t.find(".btn-yes"),this.elBtnNo=t.find(".btn-no"),this.elFooter=t.find(".lp-modal-footer"),e(document).on("click",".close, .btn-no",(function(){t.hide()})),e(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof s.callBackYes&&s.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var l=s,n=function(e,t,s){wp.apiFetch({path:e,method:"POST",data:t}).then((e=>{"function"==typeof s.success&&s.success(e)})).catch((e=>{"function"==typeof s.error&&s.error(e)})).then((()=>{"function"==typeof s.completed&&s.completed()}))};const o=jQuery,a=o("#lp-tool-upgrade-db"),r=()=>{let e=0;const t=a.find(".wrapper-terms-upgrade"),s=a.find(".wrapper-lp-status-upgrade"),r=a.find(".wrapper-lp-upgrade-message");let i=null;if(t.length){l.setContentModal(t.html());const e=l.elLPOverlay.find(".terms-upgrade"),a=e.find("input[name=lp-agree-term]"),r=e.find(".error"),c=o("input[name=message-when-upgrading]").val();i=function(){return r.hide(),r.removeClass("learn-press-message"),a.is(":checked")?(n("/lp/v1/database/agree_terms",{agree_terms:1},{}),l.elFooter.find(".learn-press-notice").remove(),l.elFooter.prepend('<span class="learn-press-notice">'+c+"</span>"),l.setContentModal(s.html()),!0):(r.show(),r.addClass("learn-press-message"),l.elMainContent.animate({scrollTop:r.offset().top}),!1)}}else l.setContentModal(s.html()),i=function(){return!0};l.setTitleModal(a.find("h2").html()),l.elBtnYes.text("Upgrade"),l.elBtnYes.show(),l.elBtnNo.text("close"),l.callBackYes=function(){if(!i())return;e=1,l.elBtnYes.hide(),l.elBtnNo.hide();const t="/lp/v1/database/upgrade",s=l.elLPOverlay.find(".lp-group-step"),c=a.find(".lp-item-step"),d=[];o.each(c,(function(e,t){const s=o(t);if(!s.hasClass("completed")){const e=s.find("input").val();d.push(e)}}));const p={steps:d,step:d[0]};let u=null;const m=(e,t)=>{u=s.find("input[value="+e+"]").closest(".lp-item-step"),u.addClass("running"),100===t&&u.removeClass("running").addClass("completed"),u.find(".progress-bar").css("width",t+"%"),u.find(".percent").text(t+"%")};m(d[0],.1);const h={success:o=>{m(p.step,o.percent),p.step!==o.name&&m(o.name,.1),(e=>{u=s.find("input[value="+e+"]").closest(".lp-item-step");const t=u.offset().top-l.elMainContent.offset().top+l.elMainContent.scrollTop();l.elMainContent.stop().animate({scrollTop:t},600)})(p.step),"success"===o.status?(p.step=o.name,p.data=o.data,setTimeout((()=>{n(t,p,h)}),800)):"finished"===o.status?(e=0,u.removeClass("running").addClass("completed"),setTimeout((()=>{l.setContentModal(r.html())}),1e3),l.elFooter.find(".learn-press-notice").remove(),l.elBtnNo.show(),l.elBtnNo.on("click",(()=>{window.location.reload()}))):(e=0,l.elFooter.find(".learn-press-notice").remove(),u.removeClass("running").addClass("error"),l.setContentModal(r.html(),(function(){l.elBtnYes.text("Retry").show(),l.callBackYes=()=>{window.location.href=lpGlobalSettings.siteurl+"/wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db"},l.elBtnNo.show(),o.message||(o.message="Upgrade not success! Please clear cache, restart sever then retry or contact to LP to help"),l.elMainContent.find(".learn-press-message").addClass("error").html(o.message)})))},error:t=>{e=0,l.setContentModal(r.html(),(function(){l.elBtnYes.text("Retry").show(),l.callBackYes=()=>{window.location.location="wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db"},l.elBtnNo.show(),t.message||(t.message="Upgrade not success! Something wrong. Please clear cache, restart sever then retry or contact to LP to help"),l.elMainContent.find(".learn-press-message").addClass("error").html(t.message)}))},completed:()=>{}};n(t,p,h)},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?"}};var i=window.wp.element;const{__:__}=wp.i18n,{TextControl:c,Button:d,Spinner:p,CheckboxControl:u,Notice:m}=wp.components,{useState:h,useEffect:g}=wp.element,{addQueryArgs:f}=wp.url;var y=()=>{const[e,t]=h(!1),[s,l]=h(""),[n,o]=h([]),[a,r]=h([]),[y,v]=h([]),[b,C]=h(!1);g((()=>{w(s)}),[s]);const w=async s=>{try{if(!s||e)return v([]),void o([]);if(s.length<3)return v([{status:"error",message:"Please enter at least 3 characters to searching course."}]),void o([]);t(!0);const l=await wp.apiFetch({path:f("lp/v1/admin/tools/reset-data/search-courses",{s:s}),method:"GET"}),{status:n,data:a}=l;t(!1),"success"===n?(o(a),v([])):(v([{status:"error",message:l.message||"LearnPress: Search Course Fail!"}]),o([]))}catch(e){console.log(e.message)}};return(0,i.createElement)(i.Fragment,null,(0,i.createElement)("h2",null,__("Reset course progress","learnpress")),(0,i.createElement)("div",{className:"description"},(0,i.createElement)("p",null,__("This action will reset progress of a course for all users have enrolled.","learnpress")),(0,i.createElement)("p",null,__("Search results only show course have user data.","learnpress")),(0,i.createElement)("div",null,(0,i.createElement)(c,{placeholder:__("Search course by name","learnpress"),value:s,onChange:e=>l(e),style:{width:300}}))),e&&(0,i.createElement)(p,null),n.length>0&&(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:"lp-reset-course_progress",style:{border:"1px solid #eee"}},(0,i.createElement)("div",null,(0,i.createElement)("div",{style:{background:"#eee"}},(0,i.createElement)("div",null,(0,i.createElement)(u,{checked:a.length===n.length,onChange:()=>{a.length===n.length?r([]):r(n.map((e=>e.id)))},style:{margin:0}})),(0,i.createElement)("div",null,__("ID","learnpress")),(0,i.createElement)("div",null,__("Name","learnpress")),(0,i.createElement)("div",null,__("Students","learnpress")))),(0,i.createElement)("div",{style:{height:"100%",maxHeight:200,overflow:"auto"}},n.map((e=>(0,i.createElement)("div",{style:{borderTop:"1px solid #eee"},key:e.id},(0,i.createElement)("div",null,(0,i.createElement)(u,{checked:a.includes(e.id),onChange:()=>function(e){const t=[...a];if(t.includes(e)){const s=t.indexOf(e);s>-1&&t.splice(s,1)}else t.push(e);r(t)}(e.id)})),(0,i.createElement)("div",null,"#",e.id),(0,i.createElement)("div",null,e.title),(0,i.createElement)("div",null,e.students)))))),b?(0,i.createElement)(p,null):(0,i.createElement)(d,{isPrimary:!0,onClick:()=>(async()=>{if(0===a.length)return void v([{status:"error",message:"Please chooce Course for reset data!"}]);if(!confirm("Are you sure to reset course progress of all users enrolled this course?"))return;const e=[];try{C(!0);for(const t of a){const s=await wp.apiFetch({path:f("lp/v1/admin/tools/reset-data/reset-courses",{courseId:t}),method:"GET"}),{status:l,data:n,message:o}=s;e.push({status:l,message:o||`Course #${t} reset successfully!`})}C(!1)}catch(t){e.push({status:"error",message:t.message||"LearnPress Error: Reset Course Data."})}v(e)})(),style:{marginTop:10,height:30}},__("Reset now","learnpress"))),y.length>0&&y.map(((e,t)=>(0,i.createElement)(m,{status:e.status,key:t,isDismissible:!1},e.message))),(0,i.createElement)("style",null,"\t\t\t\t.lp-reset-course_progress .components-base-control__field {\t\t\t\t\tmargin: 0;\t\t\t\t}\t\t\t\t.components-notice{\t\t\t\t\tmargin-left: 0;\t\t\t\t}\t\t\t\t.lp-reset-course_progress > div > div{\t\t\t\t\tdisplay: grid;\t\t\t\t\tgrid-template-columns: 80px 50px 1fr 80px;\t\t\t\t\talign-items: center;\t\t\t\t}\t\t\t\t.lp-reset-course_progress > div > div > div{\t\t\t\t\tmaegin: 0;\t\t\t\t\tpadding: 8px 10px;\t\t\t\t}\t\t\t\t"))};!function(e){const t=e(document);let s=!1;const c=function(t){t.preventDefault();const l=e(this);s||confirm(lpGlobalSettings.i18n.confirm_install_sample_data)&&(l.addClass("disabled").html(l.data("installing-text")),e(".lp-install-sample__response").remove(),s=!0,e.ajax({url:l.attr("href"),data:e(".lp-install-sample__options").serializeJSON(),success(t){l.removeClass("disabled").html(l.data("text")),s=!1,e(t).insertBefore(l.parent())},error(){l.removeClass("disabled").html(l.data("text")),s=!1,e(response).insertBefore(l.parent())}}))},d=function(t){t.preventDefault();const l=e(this);s||confirm(lpGlobalSettings.i18n.confirm_uninstall_sample_data)&&(l.addClass("disabled").html(l.data("uninstalling-text")),s=!0,e.ajax({url:l.attr("href"),success(t){l.removeClass("disabled").html(l.data("text")),s=!1,e(t).insertBefore(l.parent())},error(){l.removeClass("disabled").html(l.data("text")),s=!1,e(response).insertBefore(l.parent())}}))},p=function(t){t.preventDefault();const s=e(this);s.hasClass("disabled")||(s.addClass("disabled").html(s.data("cleaning-text")),e.ajax({url:s.attr("href"),data:{},success(e){s.removeClass("disabled").html(s.data("text"))},error(){s.removeClass("disabled").html(s.data("text"))}}))},u=function(){e.ajax({url:"admin.php?page=lp-toggle-hard-cache-option",data:{v:this.checked?"yes":"no"},success(e){},error(){}})},m=function(t){t.preventDefault(),e(".lp-install-sample__options").toggleClass("hide-if-js")};e((function(){(()=>{if(!a.length)return;if(!l.init())return;const e=o(".wrapper-lp-status-upgrade"),t=window.location.search,s=new URLSearchParams(t).get("action");"upgrade-db"===s&&(l.elLPOverlay.show(),l.setTitleModal(a.find("h2").html()),l.setContentModal(o(".wrapper-lp-loading").html())),n("/lp/v1/database/get_steps",{},{success:t=>{const{steps_completed:n,steps_default:a}=t;if(void 0===n||void 0===a)return console.log("invalid steps_completed and steps_default"),!1;let i="";for(const t in a){const c=a[t],d=c.steps;i='<div class="lp-group-step">',i+="<h3>"+c.label+"</h3>";for(const e in d){const t=d[e];let s="";void 0!==n[e]&&(s="completed"),i+='<div class="lp-item-step '+s+'">',i+='<div class="lp-item-step-left"><input type="hidden" name="lp_steps_upgrade_db[]" value="'+t.name+'" /></div>',i+='<div class="lp-item-step-right">',i+='<label for=""><strong></strong>'+t.label+"</label>",i+='<div class="description">'+t.description+"</div>",i+='<div class="percent"></div>',i+='<span class="progress-bar"></span>',i+="</div>",i+="</div>"}i+="</div>",e.append(i);const p=o(".lp-btn-upgrade-db");"upgrade-db"===s&&r(),p.on("click",(function(){l.elLPOverlay.show(),r()}))}},error:e=>{},completed:()=>{}})})(),(()=>{const e=document.querySelector("#lp-tool-create-indexes-tables");e&&e.querySelector(".lp-btn-create-indexes").addEventListener("click",(t=>{t.preventDefault();const s=e.querySelector(".wrapper-lp-loading");if(!l.init())return;l.elLPOverlay.show(),l.setContentModal(s.innerHTML),l.setTitleModal(e.querySelector("h2").textContent),l.elBtnYes[0].style.display="inline-block",l.elBtnYes[0].textContent="Run",l.elBtnNo[0].textContent="Close";const o={success:e=>{const{status:t,message:s,data:{tables:o,table:a}}=e,r=document.querySelector(".example-lp-group-step");l.setContentModal(r.innerHTML);const i=l.elLPOverlay[0].querySelector(".lp-group-step "),c=(e,t)=>{const s=i.querySelector("input[value="+e+"]").closest(".lp-item-step");s.classList.add("running"),100===t&&(s.classList.remove("running"),s.classList.add("completed")),s.querySelector(".progress-bar").style.width=t};for(const e in o){const t=l.elLPOverlay[0].querySelector(".lp-item-step").cloneNode(!0),s=t.querySelector("input");t.querySelector("label").textContent=`Table: ${e}`,s.value=e,i.append(t)}l.callBackYes=()=>{const e="/lp/v1/admin/tools/create-indexs",t={tables:o,table:a};l.elBtnNo[0].style.display="none",l.elBtnYes[0].style.display="none",c(a,.1);const s={success:o=>{const{status:a,message:r,data:{table:d,percent:p}}=o;c(t.table,p),void 0!==d&&(t.table!==d&&(c(d,.1),(e=>{const t=i.querySelector("input[value="+e+"]").closest(".lp-item-step").offsetTop-l.elMainContent[0].offsetTop+l.elMainContent[0].scrollTop;l.elMainContent.stop().animate({scrollTop:t},600)})(d)),t.table=d),"success"===a?setTimeout((()=>{n(e,t,s)}),2e3):"finished"===a?(console.log("finished"),l.elBtnNo[0].style.display="inline-block",l.elBtnNo[0].textContent="Finish"):console.log(r)},error:e=>{console.log(e)},completed:()=>{}};n(e,t,s)}},error:e=>{},completed:()=>{}};n("/lp/v1/admin/tools/list-tables-indexs",{},o)}))})(),(()=>{const e=document.querySelector("#lp-tool-re-upgrade-db");if(!e)return;let t="lp/v1/database/check-db-valid-re-upgrade";n(t,{},{success(s){const{data:{can_re_upgrade:l}}=s;if(!l)return;e.style.display="block";const o=e.querySelector(".lp-btn-re-upgrade-db"),a=e.querySelector(".learn-press-message");o.addEventListener("click",(()=>{confirm("Are you want to Re Upgrade!")&&(t="lp/v1/database/del-tb-lp-upgrade-db",n(t,{},{success(e){const{status:t,message:s,data:{url:l}}=e;"success"===t&&void 0!==l&&(window.location.href=l)},error(e){a.classList.add("error"),a.textContent=e.message,a.style.display="block"}}))}))},error(e){}})})(),document.querySelectorAll("#learn-press-reset-course-users").length>0&&wp.element.render((0,i.createElement)(y,null),[...document.querySelectorAll("#learn-press-reset-course-users")][0]),(()=>{const e=document.querySelector("#lp-tool-clean-database");e&&e.querySelector(".lp-btn-clean-db").addEventListener("click",(function(t){t.preventDefault();const s=document.querySelector("#tools-select__id"),o=s.querySelectorAll("ul li input"),a=Array.prototype.slice.call(o).some((e=>e.checked)),r=e.querySelector(".tools-prepare__message");if(0==a)return r.style.display="block",void(r.textContent="You must choose at least one table to take this action");r.style.display="none";const i=e.querySelector(".wrapper-lp-loading");if(!l.init())return;l.elLPOverlay.show(),l.setContentModal(i.innerHTML),l.setTitleModal(e.querySelector("h2").textContent),l.elBtnYes[0].style.display="inline-block",l.elBtnYes[0].textContent="Run",l.elBtnNo[0].textContent="Close";const c=new Array;s.querySelectorAll("ul li input:checked").forEach((e=>{c.push(e.value)}));const d=c[0],p=i.querySelector(".progressbar__item").getAttribute("data-total"),u=document.querySelector(".lp-modal-body .main-content").querySelector(".lp-tool__message");if(p<=0)return l.elBtnYes[0].style.display="none",u.textContent="There is no data that need to be repaired in the chosen tables",void(u.style.display="block");l.callBackYes=()=>{if(0==confirm("The modified data is impossible to be restored. Please backup your website before doing this."))return;const e=document.querySelector(".lp-modal-body .main-content"),t=e.querySelector(".lp-tool__message");t.textContent="This action is in processing. Don't close this page",t.style.display="block";const s="/lp/v1/admin/tools/clean-tables",o={tables:d,itemtotal:p};l.elBtnNo[0].style.display="none",l.elBtnYes[0].style.display="none";const a={success:t=>{const{status:r,message:i,data:{processed:c,percent:d}}=t,u=e.querySelector(".progressbar__item"),m=u.querySelector(".progressbar__rows"),h=u.querySelector(".progressbar__percent"),g=u.querySelector(".progressbar__value");if(console.log(r),"success"===r)setTimeout((()=>{n(s,o,a)}),2e3),m.textContent=c+" / "+p,h.textContent="( "+d+"% )",g.style.width=d+"%";else if("finished"===r){m.textContent=p+" / "+p,h.textContent="( 100% )";const e=document.querySelector(".lp-modal-body .main-content").querySelector(".lp-tool__message");e.textContent="Process has been completed. Press click the finish button to close this popup",e.style.color="white",e.style.background="green",g.style.width="100%",l.elBtnNo[0].style.display="inline-block",l.elBtnNo[0].textContent="Finish",l.elBtnNo[0].addEventListener("click",(function(){location.reload()}))}else console.log(i)},error:e=>{console.log(e)},completed:()=>{}};n(s,o,a)}}))})(),t.on("click",".lp-install-sample__install",c).on("click",".lp-install-sample__uninstall",d).on("click","#learn-press-clear-cache",p).on("click",'input[name="enable_hard_cache"]',u).on("click",".lp-install-sample__toggle-options",m)}))}(jQuery)}();
1
+ !function(){"use strict";const e=jQuery;let t=null;const s={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=e(".lp-overlay"),!!this.elLPOverlay.length&&(t=this.elLPOverlay,this.elMainContent=t.find(".main-content"),this.elTitle=t.find(".modal-title"),this.elBtnYes=t.find(".btn-yes"),this.elBtnNo=t.find(".btn-no"),this.elFooter=t.find(".lp-modal-footer"),e(document).on("click",".close, .btn-no",(function(){t.hide()})),e(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof s.callBackYes&&s.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var l=s,n=function(e,t,s){wp.apiFetch({path:e,method:"POST",data:t}).then((e=>{"function"==typeof s.success&&s.success(e)})).catch((e=>{"function"==typeof s.error&&s.error(e)})).then((()=>{"function"==typeof s.completed&&s.completed()}))};const o=jQuery,a=o("#lp-tool-upgrade-db"),r=()=>{let e=0;const t=a.find(".wrapper-terms-upgrade"),s=a.find(".wrapper-lp-status-upgrade"),r=a.find(".wrapper-lp-upgrade-message");let i=null;if(t.length){l.setContentModal(t.html());const e=l.elLPOverlay.find(".terms-upgrade"),a=e.find("input[name=lp-agree-term]"),r=e.find(".error"),c=o("input[name=message-when-upgrading]").val();i=function(){return r.hide(),r.removeClass("learn-press-message"),a.is(":checked")?(n("/lp/v1/database/agree_terms",{agree_terms:1},{}),l.elFooter.find(".learn-press-notice").remove(),l.elFooter.prepend('<span class="learn-press-notice">'+c+"</span>"),l.setContentModal(s.html()),!0):(r.show(),r.addClass("learn-press-message"),l.elMainContent.animate({scrollTop:r.offset().top}),!1)}}else l.setContentModal(s.html()),i=function(){return!0};l.setTitleModal(a.find("h2").html()),l.elBtnYes.text("Upgrade"),l.elBtnYes.show(),l.elBtnNo.text("close"),l.callBackYes=function(){if(!i())return;e=1,l.elBtnYes.hide(),l.elBtnNo.hide();const t="/lp/v1/database/upgrade",s=l.elLPOverlay.find(".lp-group-step"),c=a.find(".lp-item-step"),d=[];o.each(c,(function(e,t){const s=o(t);if(!s.hasClass("completed")){const e=s.find("input").val();d.push(e)}}));const p={steps:d,step:d[0]};let u=null;const m=(e,t)=>{u=s.find("input[value="+e+"]").closest(".lp-item-step"),u.addClass("running"),100===t&&u.removeClass("running").addClass("completed"),u.find(".progress-bar").css("width",t+"%"),u.find(".percent").text(t+"%")};m(d[0],.1);const h={success:o=>{m(p.step,o.percent),p.step!==o.name&&m(o.name,.1),(e=>{if(u=s.find("input[value="+e+"]").closest(".lp-item-step"),!u.length)return;const t=u.offset().top-l.elMainContent.offset().top+l.elMainContent.scrollTop();l.elMainContent.stop().animate({scrollTop:t},600)})(p.step),"success"===o.status?(p.step=o.name,p.data=o.data,setTimeout((()=>{n(t,p,h)}),800)):"finished"===o.status?(e=0,u.removeClass("running").addClass("completed"),setTimeout((()=>{l.setContentModal(r.html())}),1e3),l.elFooter.find(".learn-press-notice").remove(),l.elBtnNo.show(),l.elBtnNo.on("click",(()=>{window.location.reload()}))):(e=0,l.elFooter.find(".learn-press-notice").remove(),u.removeClass("running").addClass("error"),l.setContentModal(r.html(),(function(){l.elBtnYes.text("Retry").show(),l.callBackYes=()=>{window.location.href=lpGlobalSettings.siteurl+"/wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db"},l.elBtnNo.show(),o.message||(o.message="Upgrade not success! Please clear cache, restart sever then retry or contact to LP to help"),l.elMainContent.find(".learn-press-message").addClass("error").html(o.message)})))},error:t=>{e=0,l.setContentModal(r.html(),(function(){l.elBtnYes.text("Retry").show(),l.callBackYes=()=>{window.location.location="wp-admin/admin.php?page=learn-press-tools&tab=database&action=upgrade-db"},l.elBtnNo.show(),t.message||(t.message="Upgrade not success! Something wrong. Please clear cache, restart sever then retry or contact to LP to help"),l.elMainContent.find(".learn-press-message").addClass("error").html(t.message)}))},completed:()=>{}};n(t,p,h)},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?"}};var i=window.wp.element;const{__:__}=wp.i18n,{TextControl:c,Button:d,Spinner:p,CheckboxControl:u,Notice:m}=wp.components,{useState:h,useEffect:g}=wp.element,{addQueryArgs:f}=wp.url;var y=()=>{const[e,t]=h(!1),[s,l]=h(""),[n,o]=h([]),[a,r]=h([]),[y,v]=h([]),[b,C]=h(!1);g((()=>{w(s)}),[s]);const w=async s=>{try{if(!s||e)return v([]),void o([]);if(s.length<3)return v([{status:"error",message:"Please enter at least 3 characters to searching course."}]),void o([]);t(!0);const l=await wp.apiFetch({path:f("lp/v1/admin/tools/reset-data/search-courses",{s:s}),method:"GET"}),{status:n,data:a}=l;t(!1),"success"===n?(o(a),v([])):(v([{status:"error",message:l.message||"LearnPress: Search Course Fail!"}]),o([]))}catch(e){console.log(e.message)}};return(0,i.createElement)(i.Fragment,null,(0,i.createElement)("h2",null,__("Reset course progress","learnpress")),(0,i.createElement)("div",{className:"description"},(0,i.createElement)("p",null,__("This action will reset progress of a course for all users have enrolled.","learnpress")),(0,i.createElement)("p",null,__("Search results only show course have user data.","learnpress")),(0,i.createElement)("div",null,(0,i.createElement)(c,{placeholder:__("Search course by name","learnpress"),value:s,onChange:e=>l(e),style:{width:300}}))),e&&(0,i.createElement)(p,null),n.length>0&&(0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",{className:"lp-reset-course_progress",style:{border:"1px solid #eee"}},(0,i.createElement)("div",null,(0,i.createElement)("div",{style:{background:"#eee"}},(0,i.createElement)("div",null,(0,i.createElement)(u,{checked:a.length===n.length,onChange:()=>{a.length===n.length?r([]):r(n.map((e=>e.id)))},style:{margin:0}})),(0,i.createElement)("div",null,__("ID","learnpress")),(0,i.createElement)("div",null,__("Name","learnpress")),(0,i.createElement)("div",null,__("Students","learnpress")))),(0,i.createElement)("div",{style:{height:"100%",maxHeight:200,overflow:"auto"}},n.map((e=>(0,i.createElement)("div",{style:{borderTop:"1px solid #eee"},key:e.id},(0,i.createElement)("div",null,(0,i.createElement)(u,{checked:a.includes(e.id),onChange:()=>function(e){const t=[...a];if(t.includes(e)){const s=t.indexOf(e);s>-1&&t.splice(s,1)}else t.push(e);r(t)}(e.id)})),(0,i.createElement)("div",null,"#",e.id),(0,i.createElement)("div",null,e.title),(0,i.createElement)("div",null,e.students)))))),b?(0,i.createElement)(p,null):(0,i.createElement)(d,{isPrimary:!0,onClick:()=>(async()=>{if(0===a.length)return void v([{status:"error",message:"Please chooce Course for reset data!"}]);if(!confirm("Are you sure to reset course progress of all users enrolled this course?"))return;const e=[];try{C(!0);for(const t of a){const s=await wp.apiFetch({path:f("lp/v1/admin/tools/reset-data/reset-courses",{courseId:t}),method:"GET"}),{status:l,data:n,message:o}=s;e.push({status:l,message:o||`Course #${t} reset successfully!`})}C(!1)}catch(t){e.push({status:"error",message:t.message||"LearnPress Error: Reset Course Data."})}v(e)})(),style:{marginTop:10,height:30}},__("Reset now","learnpress"))),y.length>0&&y.map(((e,t)=>(0,i.createElement)(m,{status:e.status,key:t,isDismissible:!1},e.message))),(0,i.createElement)("style",null,"\t\t\t\t.lp-reset-course_progress .components-base-control__field {\t\t\t\t\tmargin: 0;\t\t\t\t}\t\t\t\t.components-notice{\t\t\t\t\tmargin-left: 0;\t\t\t\t}\t\t\t\t.lp-reset-course_progress > div > div{\t\t\t\t\tdisplay: grid;\t\t\t\t\tgrid-template-columns: 80px 50px 1fr 80px;\t\t\t\t\talign-items: center;\t\t\t\t}\t\t\t\t.lp-reset-course_progress > div > div > div{\t\t\t\t\tmaegin: 0;\t\t\t\t\tpadding: 8px 10px;\t\t\t\t}\t\t\t\t"))};!function(e){const t=e(document);let s=!1;const c=function(t){t.preventDefault();const l=e(this);s||confirm(lpGlobalSettings.i18n.confirm_install_sample_data)&&(l.addClass("disabled").html(l.data("installing-text")),e(".lp-install-sample__response").remove(),s=!0,e.ajax({url:l.attr("href"),data:e(".lp-install-sample__options").serializeJSON(),success(t){l.removeClass("disabled").html(l.data("text")),s=!1,e(t).insertBefore(l.parent())},error(){l.removeClass("disabled").html(l.data("text")),s=!1,e(response).insertBefore(l.parent())}}))},d=function(t){t.preventDefault();const l=e(this);s||confirm(lpGlobalSettings.i18n.confirm_uninstall_sample_data)&&(l.addClass("disabled").html(l.data("uninstalling-text")),s=!0,e.ajax({url:l.attr("href"),success(t){l.removeClass("disabled").html(l.data("text")),s=!1,e(t).insertBefore(l.parent())},error(){l.removeClass("disabled").html(l.data("text")),s=!1,e(response).insertBefore(l.parent())}}))},p=function(t){t.preventDefault();const s=e(this);s.hasClass("disabled")||(s.addClass("disabled").html(s.data("cleaning-text")),e.ajax({url:s.attr("href"),data:{},success(e){s.removeClass("disabled").html(s.data("text"))},error(){s.removeClass("disabled").html(s.data("text"))}}))},u=function(){e.ajax({url:"admin.php?page=lp-toggle-hard-cache-option",data:{v:this.checked?"yes":"no"},success(e){},error(){}})},m=function(t){t.preventDefault(),e(".lp-install-sample__options").toggleClass("hide-if-js")};e((function(){(()=>{if(!a.length)return;if(!l.init())return;const e=o(".wrapper-lp-status-upgrade"),t=window.location.search,s=new URLSearchParams(t).get("action");"upgrade-db"===s&&(l.elLPOverlay.show(),l.setTitleModal(a.find("h2").html()),l.setContentModal(o(".wrapper-lp-loading").html())),n("/lp/v1/database/get_steps",{},{success:t=>{const{steps_completed:n,steps_default:a}=t;if(void 0===n||void 0===a)return console.log("invalid steps_completed and steps_default"),!1;let i="";for(const t in a){const c=a[t],d=c.steps;i='<div class="lp-group-step">',i+="<h3>"+c.label+"</h3>";for(const e in d){const t=d[e];let s="";void 0!==n[e]&&(s="completed"),i+='<div class="lp-item-step '+s+'">',i+='<div class="lp-item-step-left"><input type="hidden" name="lp_steps_upgrade_db[]" value="'+t.name+'" /></div>',i+='<div class="lp-item-step-right">',i+='<label for=""><strong></strong>'+t.label+"</label>",i+='<div class="description">'+t.description+"</div>",i+='<div class="percent"></div>',i+='<span class="progress-bar"></span>',i+="</div>",i+="</div>"}i+="</div>",e.append(i);const p=o(".lp-btn-upgrade-db");"upgrade-db"===s&&r(),p.on("click",(function(){l.elLPOverlay.show(),r()}))}},error:e=>{},completed:()=>{}})})(),(()=>{const e=document.querySelector("#lp-tool-create-indexes-tables");e&&e.querySelector(".lp-btn-create-indexes").addEventListener("click",(t=>{t.preventDefault();const s=e.querySelector(".wrapper-lp-loading");if(!l.init())return;l.elLPOverlay.show(),l.setContentModal(s.innerHTML),l.setTitleModal(e.querySelector("h2").textContent),l.elBtnYes[0].style.display="inline-block",l.elBtnYes[0].textContent="Run",l.elBtnNo[0].textContent="Close";const o={success:e=>{const{status:t,message:s,data:{tables:o,table:a}}=e,r=document.querySelector(".example-lp-group-step");l.setContentModal(r.innerHTML);const i=l.elLPOverlay[0].querySelector(".lp-group-step "),c=(e,t)=>{const s=i.querySelector("input[value="+e+"]").closest(".lp-item-step");s.classList.add("running"),100===t&&(s.classList.remove("running"),s.classList.add("completed")),s.querySelector(".progress-bar").style.width=t};for(const e in o){const t=l.elLPOverlay[0].querySelector(".lp-item-step").cloneNode(!0),s=t.querySelector("input");t.querySelector("label").textContent=`Table: ${e}`,s.value=e,i.append(t)}l.callBackYes=()=>{const e="/lp/v1/admin/tools/create-indexs",t={tables:o,table:a};l.elBtnNo[0].style.display="none",l.elBtnYes[0].style.display="none",c(a,.1);const s={success:o=>{const{status:a,message:r,data:{table:d,percent:p}}=o;c(t.table,p),void 0!==d&&(t.table!==d&&(c(d,.1),(e=>{const t=i.querySelector("input[value="+e+"]").closest(".lp-item-step").offsetTop-l.elMainContent[0].offsetTop+l.elMainContent[0].scrollTop;l.elMainContent.stop().animate({scrollTop:t},600)})(d)),t.table=d),"success"===a?setTimeout((()=>{n(e,t,s)}),2e3):"finished"===a?(console.log("finished"),l.elBtnNo[0].style.display="inline-block",l.elBtnNo[0].textContent="Finish"):console.log(r)},error:e=>{console.log(e)},completed:()=>{}};n(e,t,s)}},error:e=>{},completed:()=>{}};n("/lp/v1/admin/tools/list-tables-indexs",{},o)}))})(),(()=>{const e=document.querySelector("#lp-tool-re-upgrade-db");if(!e)return;let t="lp/v1/database/check-db-valid-re-upgrade";n(t,{},{success(s){const{data:{can_re_upgrade:l}}=s;if(!l)return;e.style.display="block";const o=e.querySelector(".lp-btn-re-upgrade-db"),a=e.querySelector(".learn-press-message");o.addEventListener("click",(()=>{confirm("Are you want to Re Upgrade!")&&(t="lp/v1/database/del-tb-lp-upgrade-db",n(t,{},{success(e){const{status:t,message:s,data:{url:l}}=e;"success"===t&&void 0!==l&&(window.location.href=l)},error(e){a.classList.add("error"),a.textContent=e.message,a.style.display="block"}}))}))},error(e){}})})(),document.querySelectorAll("#learn-press-reset-course-users").length>0&&wp.element.render((0,i.createElement)(y,null),[...document.querySelectorAll("#learn-press-reset-course-users")][0]),(()=>{const e=document.querySelector("#lp-tool-clean-database");e&&e.querySelector(".lp-btn-clean-db").addEventListener("click",(function(t){t.preventDefault();const s=document.querySelector("#tools-select__id"),o=s.querySelectorAll("ul li input"),a=Array.prototype.slice.call(o).some((e=>e.checked)),r=e.querySelector(".tools-prepare__message");if(0==a)return r.style.display="block",void(r.textContent="You must choose at least one table to take this action");r.style.display="none";const i=e.querySelector(".wrapper-lp-loading");if(!l.init())return;l.elLPOverlay.show(),l.setContentModal(i.innerHTML),l.setTitleModal(e.querySelector("h2").textContent),l.elBtnYes[0].style.display="inline-block",l.elBtnYes[0].textContent="Run",l.elBtnNo[0].textContent="Close";const c=new Array;s.querySelectorAll("ul li input:checked").forEach((e=>{c.push(e.value)}));const d=c[0],p=i.querySelector(".progressbar__item").getAttribute("data-total"),u=document.querySelector(".lp-modal-body .main-content").querySelector(".lp-tool__message");if(p<=0)return l.elBtnYes[0].style.display="none",u.textContent="There is no data that need to be repaired in the chosen tables",void(u.style.display="block");l.callBackYes=()=>{if(0==confirm("The modified data is impossible to be restored. Please backup your website before doing this."))return;const e=document.querySelector(".lp-modal-body .main-content"),t=e.querySelector(".lp-tool__message");t.textContent="This action is in processing. Don't close this page",t.style.display="block";const s="/lp/v1/admin/tools/clean-tables",o={tables:d,itemtotal:p};l.elBtnNo[0].style.display="none",l.elBtnYes[0].style.display="none";const a={success:t=>{const{status:r,message:i,data:{processed:c,percent:d}}=t,u=e.querySelector(".progressbar__item"),m=u.querySelector(".progressbar__rows"),h=u.querySelector(".progressbar__percent"),g=u.querySelector(".progressbar__value");if(console.log(r),"success"===r)setTimeout((()=>{n(s,o,a)}),2e3),m.textContent=c+" / "+p,h.textContent="( "+d+"% )",g.style.width=d+"%";else if("finished"===r){m.textContent=p+" / "+p,h.textContent="( 100% )";const e=document.querySelector(".lp-modal-body .main-content").querySelector(".lp-tool__message");e.textContent="Process has been completed. Press click the finish button to close this popup",e.style.color="white",e.style.background="green",g.style.width="100%",l.elBtnNo[0].style.display="inline-block",l.elBtnNo[0].textContent="Finish",l.elBtnNo[0].addEventListener("click",(function(){location.reload()}))}else console.log(i)},error:e=>{console.log(e)},completed:()=>{}};n(s,o,a)}}))})(),t.on("click",".lp-install-sample__install",c).on("click",".lp-install-sample__uninstall",d).on("click","#learn-press-clear-cache",p).on("click",'input[name="enable_hard_cache"]',u).on("click",".lp-install-sample__toggle-options",m)}))}(jQuery)}();
assets/js/dist/blocks/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
- !function(){"use strict";var e={d:function(t,r){for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{metadata:function(){return c},name:function(){return d},settings:function(){return u}});var r=window.wp.blocks,a=window.wp.i18n;(0,r.setCategories)([...(0,r.getCategories)().filter((e=>{let{slug:t}=e;return"learnpress"!==t})),{slug:"learnpress",title:(0,a.__)("LearnPress","learnpress")}]);var n=window.wp.element,l=window.wp.blockEditor,s=window.wp.components,o=window.wp.primitives,i=(0,n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(o.Path,{d:"M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"}));const p={"single-course":{title:(0,a.__)("LearnPress Single Course Template","learnpress"),placeholder:"single-course"},"archive-course":{title:(0,a.__)("LearnPress Course Archive Template","learnpress"),placeholder:"archive-course"}};var c=JSON.parse('{"apiVersion":2,"name":"learnpress/template","category":"learnpress","attributes":{"template":{"type":"string","default":""}}}');const{name:d}=c,u={title:"LearnPress Template",keywords:["learnpress","template"],description:(0,a.__)("Renders LearnPress PHP templates.","learnpress"),icon:"archive",edit:function(e){var t,r;let{attributes:o}=e;const c=(0,l.useBlockProps)(),d=null!==(t=null===(r=p[o.template])||void 0===r?void 0:r.title)&&void 0!==t?t:o.template;return(0,n.createElement)("div",c,(0,n.createElement)(s.Placeholder,{icon:i,label:d,className:"wp-block-learnpress-template__placeholder"},(0,n.createElement)("div",{className:"wp-block-learnpress-template__placeholder-inner"},(0,a.sprintf)(
2
  /* translators: %s is the template title */
3
- (0,a.__)("This is an editor placeholder for the %s. On your store this will be replaced by the template and display with your course image(s), title, price, etc. You can move this placeholder around and add further blocks around it to extend the template.","learnpress"),d))))},save:()=>null};[t].forEach((e=>{if(!e)return;const{metadata:t,settings:a,name:n}=e;(0,r.registerBlockType)(n,{...t,...a})}))}();
1
+ !function(){"use strict";var e={d:function(t,r){for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{metadata:function(){return c},name:function(){return d},settings:function(){return u}});var r=window.wp.blocks,a=window.wp.i18n;(0,r.setCategories)([...(0,r.getCategories)().filter((e=>{let{slug:t}=e;return"learnpress"!==t})),{slug:"learnpress",title:(0,a.__)("LearnPress","learnpress")}]);var n=window.wp.element,s=window.wp.blockEditor,l=window.wp.components,o=window.wp.primitives,i=(0,n.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,n.createElement)(o.Path,{d:"M7 5.5h10a.5.5 0 01.5.5v12a.5.5 0 01-.5.5H7a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM17 4H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V6a2 2 0 00-2-2zm-1 3.75H8v1.5h8v-1.5zM8 11h8v1.5H8V11zm6 3.25H8v1.5h6v-1.5z"}));const p={"single-course":{title:(0,a.__)("LearnPress Single Course Template","learnpress"),placeholder:"single-course"},"archive-course":{title:(0,a.__)("LearnPress Course Archive Template","learnpress"),placeholder:"archive-course"}};var c=JSON.parse('{"apiVersion":2,"name":"learnpress/template","category":"learnpress","attributes":{"template":{"type":"string","default":""}}}');const{name:d}=c,u={title:"LearnPress Template",keywords:["learnpress","template"],description:(0,a.__)("Renders LearnPress PHP templates.","learnpress"),icon:"archive",edit:function(e){var t,r;let{attributes:o}=e;const c=(0,s.useBlockProps)(),d=null!==(t=null===(r=p[o.template])||void 0===r?void 0:r.title)&&void 0!==t?t:o.template;return(0,n.createElement)("div",c,(0,n.createElement)(l.Placeholder,{icon:i,label:d,className:"wp-block-learnpress-template__placeholder"},(0,n.createElement)("div",{className:"wp-block-learnpress-template__placeholder-inner"},(0,a.sprintf)(
2
  /* translators: %s is the template title */
3
+ (0,a.__)("This is an editor placeholder for the %s. This will be replaced by the template in your store and displayed with your course image(s), title, price, and so on. You can move this placeholder around and add further blocks around it to extend the template.","learnpress"),d))))},save:()=>null};[t].forEach((e=>{if(!e)return;const{metadata:t,settings:a,name:n}=e;(0,r.registerBlockType)(n,{...t,...a})}))}();
assets/js/dist/frontend/courses.js CHANGED
@@ -10,8 +10,8 @@ let skeleton;
10
  let skeletonClone;
11
  let isLoading = false;
12
  let firstLoad = 1;
13
- let elNoLoadAjaxFirst;
14
- let elArchive;
15
 
16
  if (lpGlobalSettings.is_course_archive) {
17
  const queryString = window.location.search;
@@ -39,10 +39,10 @@ const lpArchiveCourse = () => {
39
 
40
  if (!elNoLoadAjaxFirst) {
41
  lpArchiveRequestCourse(filterCourses);
 
 
 
42
  }
43
-
44
- lpArchivePaginationCourse();
45
- lpArchiveSearchCourse();
46
  };
47
 
48
  window.lpArchiveRequestCourse = (args, callBackSuccess) => {
10
  let skeletonClone;
11
  let isLoading = false;
12
  let firstLoad = 1;
13
+ let elNoLoadAjaxFirst = null;
14
+ let elArchive = null;
15
 
16
  if (lpGlobalSettings.is_course_archive) {
17
  const queryString = window.location.search;
39
 
40
  if (!elNoLoadAjaxFirst) {
41
  lpArchiveRequestCourse(filterCourses);
42
+ } else {
43
+ lpArchivePaginationCourse();
44
+ lpArchiveSearchCourse();
45
  }
 
 
 
46
  };
47
 
48
  window.lpArchiveRequestCourse = (args, callBackSuccess) => {
assets/js/dist/frontend/profile.js CHANGED
@@ -1549,8 +1549,8 @@ function (_super) {
1549
  function Cropper() {
1550
  var _this = _super !== null && _super.apply(this, arguments) || this;
1551
 
1552
- _this.imageRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createRef();
1553
- _this.videoRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createRef();
1554
  _this.containerRef = null;
1555
  _this.styleRef = null;
1556
  _this.containerRect = null;
@@ -1634,13 +1634,13 @@ function (_super) {
1634
  _this.computeSizes = function () {
1635
  var _a, _b, _c, _d, _e, _f;
1636
 
1637
- var mediaRef = _this.imageRef.current || _this.videoRef.current;
1638
 
1639
  if (mediaRef && _this.containerRef) {
1640
  _this.containerRect = _this.containerRef.getBoundingClientRect();
1641
  var containerAspect = _this.containerRect.width / _this.containerRect.height;
1642
- var naturalWidth = ((_a = _this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0;
1643
- var naturalHeight = ((_c = _this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0;
1644
  var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight;
1645
  var mediaAspect = naturalWidth / naturalHeight; // We do not rely on the offsetWidth/offsetHeight if the media is scaled down
1646
  // as the values they report are rounded. That will result in precision losses
@@ -1677,16 +1677,6 @@ function (_super) {
1677
  height: _this.containerRect.height
1678
  };
1679
  break;
1680
-
1681
- case 'auto-cover':
1682
- renderedMediaSize = naturalWidth > naturalHeight ? {
1683
- width: _this.containerRect.width,
1684
- height: _this.containerRect.width / mediaAspect
1685
- } : {
1686
- width: _this.containerRect.height * mediaAspect,
1687
- height: _this.containerRect.height
1688
- };
1689
- break;
1690
  }
1691
  } else {
1692
  renderedMediaSize = {
@@ -1942,27 +1932,13 @@ function (_super) {
1942
  if (!this.props.disableAutomaticStylesInjection) {
1943
  this.styleRef = document.createElement('style');
1944
  this.styleRef.setAttribute('type', 'text/css');
1945
-
1946
- if (this.props.nonce) {
1947
- this.styleRef.setAttribute('nonce', this.props.nonce);
1948
- }
1949
-
1950
  this.styleRef.innerHTML = css_248z;
1951
  document.head.appendChild(this.styleRef);
1952
  } // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called
1953
 
1954
 
1955
- if (this.imageRef.current && this.imageRef.current.complete) {
1956
  this.onMediaLoad();
1957
- } // set image and video refs in the parent if the callbacks exist
1958
-
1959
-
1960
- if (this.props.setImageRef) {
1961
- this.props.setImageRef(this.imageRef);
1962
- }
1963
-
1964
- if (this.props.setVideoRef) {
1965
- this.props.setVideoRef(this.videoRef);
1966
  }
1967
  };
1968
 
@@ -2007,7 +1983,7 @@ function (_super) {
2007
  }
2008
 
2009
  if (prevProps.video !== this.props.video) {
2010
- (_j = this.videoRef.current) === null || _j === void 0 ? void 0 : _j.load();
2011
  }
2012
  };
2013
 
@@ -2088,10 +2064,12 @@ function (_super) {
2088
  className: classNames('reactEasyCrop_Container', containerClassName)
2089
  }, image ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("img", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({
2090
  alt: "",
2091
- className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', objectFit === 'auto-cover' && (this.mediaSize.naturalWidth > this.mediaSize.naturalHeight ? 'reactEasyCrop_Cover_Horizontal' : 'reactEasyCrop_Cover_Vertical'), mediaClassName)
2092
  }, mediaProps, {
2093
  src: image,
2094
- ref: this.imageRef,
 
 
2095
  style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), {
2096
  transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
2097
  }),
@@ -2100,9 +2078,11 @@ function (_super) {
2100
  autoPlay: true,
2101
  loop: true,
2102
  muted: true,
2103
- className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', objectFit === 'auto-cover' && (this.mediaSize.naturalWidth > this.mediaSize.naturalHeight ? 'reactEasyCrop_Cover_Horizontal' : 'reactEasyCrop_Cover_Vertical'), mediaClassName)
2104
  }, mediaProps, {
2105
- ref: this.videoRef,
 
 
2106
  onLoadedMetadata: this.onMediaLoad,
2107
  style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), {
2108
  transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
1549
  function Cropper() {
1550
  var _this = _super !== null && _super.apply(this, arguments) || this;
1551
 
1552
+ _this.imageRef = null;
1553
+ _this.videoRef = null;
1554
  _this.containerRef = null;
1555
  _this.styleRef = null;
1556
  _this.containerRect = null;
1634
  _this.computeSizes = function () {
1635
  var _a, _b, _c, _d, _e, _f;
1636
 
1637
+ var mediaRef = _this.imageRef || _this.videoRef;
1638
 
1639
  if (mediaRef && _this.containerRef) {
1640
  _this.containerRect = _this.containerRef.getBoundingClientRect();
1641
  var containerAspect = _this.containerRect.width / _this.containerRect.height;
1642
+ var naturalWidth = ((_a = _this.imageRef) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0;
1643
+ var naturalHeight = ((_c = _this.imageRef) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0;
1644
  var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight;
1645
  var mediaAspect = naturalWidth / naturalHeight; // We do not rely on the offsetWidth/offsetHeight if the media is scaled down
1646
  // as the values they report are rounded. That will result in precision losses
1677
  height: _this.containerRect.height
1678
  };
1679
  break;
 
 
 
 
 
 
 
 
 
 
1680
  }
1681
  } else {
1682
  renderedMediaSize = {
1932
  if (!this.props.disableAutomaticStylesInjection) {
1933
  this.styleRef = document.createElement('style');
1934
  this.styleRef.setAttribute('type', 'text/css');
 
 
 
 
 
1935
  this.styleRef.innerHTML = css_248z;
1936
  document.head.appendChild(this.styleRef);
1937
  } // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called
1938
 
1939
 
1940
+ if (this.imageRef && this.imageRef.complete) {
1941
  this.onMediaLoad();
 
 
 
 
 
 
 
 
 
1942
  }
1943
  };
1944
 
1983
  }
1984
 
1985
  if (prevProps.video !== this.props.video) {
1986
+ (_j = this.videoRef) === null || _j === void 0 ? void 0 : _j.load();
1987
  }
1988
  };
1989
 
2064
  className: classNames('reactEasyCrop_Container', containerClassName)
2065
  }, image ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("img", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({
2066
  alt: "",
2067
+ className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName)
2068
  }, mediaProps, {
2069
  src: image,
2070
+ ref: function ref(el) {
2071
+ return _this.imageRef = el;
2072
+ },
2073
  style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), {
2074
  transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
2075
  }),
2078
  autoPlay: true,
2079
  loop: true,
2080
  muted: true,
2081
+ className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName)
2082
  }, mediaProps, {
2083
+ ref: function ref(el) {
2084
+ return _this.videoRef = el;
2085
+ },
2086
  onLoadedMetadata: this.onMediaLoad,
2087
  style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), {
2088
  transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
assets/js/dist/frontend/profile.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var e={796:function(e,t,o){e.exports=o(643)},264:function(e){"use strict";var t=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:t,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:t&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:t&&!!window.screen,isInWorker:!t};e.exports=o},518:function(e){var t,o,r,n,a,i,s,c,l,p,d,h,u,m,v,g=!1;function f(){if(!g){g=!0;var e=navigator.userAgent,f=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),w=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(h=/\b(iPhone|iP[ao]d)/.exec(e),u=/\b(iP[ao]d)/.exec(e),p=/Android/i.exec(e),m=/FBAN\/\w+;/i.exec(e),v=/Mobile/i.exec(e),d=!!/Win64/.exec(e),f){(t=f[1]?parseFloat(f[1]):f[5]?parseFloat(f[5]):NaN)&&document&&document.documentMode&&(t=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);i=y?parseFloat(y[1])+4:t,o=f[2]?parseFloat(f[2]):NaN,r=f[3]?parseFloat(f[3]):NaN,(n=f[4]?parseFloat(f[4]):NaN)?(f=/(?:Chrome\/(\d+\.\d+))/.exec(e),a=f&&f[1]?parseFloat(f[1]):NaN):a=NaN}else t=o=r=a=n=NaN;if(w){if(w[1]){var S=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);s=!S||parseFloat(S[1].replace("_","."))}else s=!1;c=!!w[2],l=!!w[3]}else s=c=l=!1}}var w={ie:function(){return f()||t},ieCompatibilityMode:function(){return f()||i>t},ie64:function(){return w.ie()&&d},firefox:function(){return f()||o},opera:function(){return f()||r},webkit:function(){return f()||n},safari:function(){return w.webkit()},chrome:function(){return f()||a},windows:function(){return f()||c},osx:function(){return f()||s},linux:function(){return f()||l},iphone:function(){return f()||h},mobile:function(){return f()||h||u||p||v},nativeApp:function(){return f()||m},android:function(){return f()||p},ipad:function(){return f()||u}};e.exports=w},534:function(e,t,o){"use strict";var r,n=o(264);n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),e.exports=function(e,t){if(!n.canUseDOM||t&&!("addEventListener"in document))return!1;var o="on"+e,a=o in document;if(!a){var i=document.createElement("div");i.setAttribute(o,"return;"),a="function"==typeof i[o]}return!a&&r&&"wheel"===e&&(a=document.implementation.hasFeature("Events.wheel","3.0")),a}},643:function(e,t,o){"use strict";var r=o(518),n=o(534);function a(e){var t=0,o=0,r=0,n=0;return"detail"in e&&(o=e.detail),"wheelDelta"in e&&(o=-e.wheelDelta/120),"wheelDeltaY"in e&&(o=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=o,o=0),r=10*t,n=10*o,"deltaY"in e&&(n=e.deltaY),"deltaX"in e&&(r=e.deltaX),(r||n)&&e.deltaMode&&(1==e.deltaMode?(r*=40,n*=40):(r*=800,n*=800)),r&&!t&&(t=r<1?-1:1),n&&!o&&(o=n<1?-1:1),{spinX:t,spinY:o,pixelX:r,pixelY:n}}a.getEventType=function(){return r.firefox()?"DOMMouseScroll":n("wheel")?"wheel":"mousewheel"},e.exports=a}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.url;const r=window.jQuery;var n=window.wp.apiFetch,a=o.n(n),i=window.wp.i18n,s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},s(e,t)},c=function(){return c=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},c.apply(this,arguments)};Object.create,Object.create;var l=window.React,p=o.n(l),d=o(796),h=o.n(d);function u(e,t,o,r,n,a){void 0===a&&(a=0);var i=E(e,t,a),s=i.width,c=i.height,l=Math.min(s,o),p=Math.min(c,r);return l>p*n?{width:p*n,height:p}:{width:l,height:l/n}}function m(e,t,o,r,n){void 0===n&&(n=0);var a=E(t.width,t.height,n),i=a.width,s=a.height;return{x:v(e.x,i,o.width,r),y:v(e.y,s,o.height,r)}}function v(e,t,o,r){var n=t*r/2-o/2;return x(e,-n,n)}function g(e,t){return Math.sqrt(Math.pow(e.y-t.y,2)+Math.pow(e.x-t.x,2))}function f(e,t){return 180*Math.atan2(t.y-e.y,t.x-e.x)/Math.PI}function w(e,t,o,r,n,a,i){void 0===a&&(a=0),void 0===i&&(i=!0);var s=i?y:S,l=E(t.width,t.height,a),p=E(t.naturalWidth,t.naturalHeight,a),d={x:s(100,((l.width-o.width/n)/2-e.x/n)/l.width*100),y:s(100,((l.height-o.height/n)/2-e.y/n)/l.height*100),width:s(100,o.width/l.width*100/n),height:s(100,o.height/l.height*100/n)},h=Math.round(s(p.width,d.width*p.width/100)),u=Math.round(s(p.height,d.height*p.height/100)),m=p.width>=p.height*r?{width:Math.round(u*r),height:u}:{width:h,height:Math.round(h/r)};return{croppedAreaPercentages:d,croppedAreaPixels:c(c({},m),{x:Math.round(s(p.width-m.width,d.x*p.width/100)),y:Math.round(s(p.height-m.height,d.y*p.height/100))})}}function y(e,t){return Math.min(e,Math.max(0,t))}function S(e,t){return t}function C(e,t,o,r,n,a){var i=E(t.width,t.height,o),s=x(r.width/i.width*(100/e.width),n,a);return{crop:{x:s*i.width/2-r.width/2-i.width*s*(e.x/100),y:s*i.height/2-r.height/2-i.height*s*(e.y/100)},zoom:s}}function _(e,t,o,r,n,a){void 0===o&&(o=0);var i=E(t.naturalWidth,t.naturalHeight,o),s=x(function(e,t,o){var r=function(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}(t);return o.height>o.width?o.height/(e.height*r):o.width/(e.width*r)}(e,t,r),n,a),c=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((i.width-e.width)/2-e.x)*c,y:((i.height-e.height)/2-e.y)*c},zoom:s}}function b(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function E(e,t,o){var r=o*Math.PI/180;return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function x(e,t,o){return Math.min(Math.max(e,t),o)}function z(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter((function(e){return"string"==typeof e&&e.length>0})).join(" ").trim()}var M=function(e){function t(){var o=null!==e&&e.apply(this,arguments)||this;return o.imageRef=p().createRef(),o.videoRef=p().createRef(),o.containerRef=null,o.styleRef=null,o.containerRect=null,o.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},o.dragStartPosition={x:0,y:0},o.dragStartCrop={x:0,y:0},o.lastPinchDistance=0,o.lastPinchRotation=0,o.rafDragTimeout=null,o.rafPinchTimeout=null,o.wheelTimer=null,o.state={cropSize:null,hasWheelJustStarted:!1},o.preventZoomSafari=function(e){return e.preventDefault()},o.cleanEvents=function(){document.removeEventListener("mousemove",o.onMouseMove),document.removeEventListener("mouseup",o.onDragStopped),document.removeEventListener("touchmove",o.onTouchMove),document.removeEventListener("touchend",o.onDragStopped)},o.clearScrollEvent=function(){o.containerRef&&o.containerRef.removeEventListener("wheel",o.onWheel),o.wheelTimer&&clearTimeout(o.wheelTimer)},o.onMediaLoad=function(){var e=o.computeSizes();e&&(o.emitCropData(),o.setInitialCrop(e)),o.props.onMediaLoaded&&o.props.onMediaLoaded(o.mediaSize)},o.setInitialCrop=function(e){if(o.props.initialCroppedAreaPercentages){var t=C(o.props.initialCroppedAreaPercentages,o.mediaSize,o.props.rotation,e,o.props.minZoom,o.props.maxZoom),r=t.crop,n=t.zoom;o.props.onCropChange(r),o.props.onZoomChange&&o.props.onZoomChange(n)}else if(o.props.initialCroppedAreaPixels){var a=_(o.props.initialCroppedAreaPixels,o.mediaSize,o.props.rotation,e,o.props.minZoom,o.props.maxZoom);r=a.crop,n=a.zoom,o.props.onCropChange(r),o.props.onZoomChange&&o.props.onZoomChange(n)}},o.computeSizes=function(){var e,t,r,n,a,i,s=o.imageRef.current||o.videoRef.current;if(s&&o.containerRef){o.containerRect=o.containerRef.getBoundingClientRect();var l=o.containerRect.width/o.containerRect.height,p=(null===(e=o.imageRef.current)||void 0===e?void 0:e.naturalWidth)||(null===(t=o.videoRef.current)||void 0===t?void 0:t.videoWidth)||0,d=(null===(r=o.imageRef.current)||void 0===r?void 0:r.naturalHeight)||(null===(n=o.videoRef.current)||void 0===n?void 0:n.videoHeight)||0,h=p/d,m=void 0;if(s.offsetWidth<p||s.offsetHeight<d)switch(o.props.objectFit){default:case"contain":m=l>h?{width:o.containerRect.height*h,height:o.containerRect.height}:{width:o.containerRect.width,height:o.containerRect.width/h};break;case"horizontal-cover":m={width:o.containerRect.width,height:o.containerRect.width/h};break;case"vertical-cover":m={width:o.containerRect.height*h,height:o.containerRect.height};break;case"auto-cover":m=p>d?{width:o.containerRect.width,height:o.containerRect.width/h}:{width:o.containerRect.height*h,height:o.containerRect.height}}else m={width:s.offsetWidth,height:s.offsetHeight};o.mediaSize=c(c({},m),{naturalWidth:p,naturalHeight:d});var v=o.props.cropSize?o.props.cropSize:u(o.mediaSize.width,o.mediaSize.height,o.containerRect.width,o.containerRect.height,o.props.aspect,o.props.rotation);return(null===(a=o.state.cropSize)||void 0===a?void 0:a.height)===v.height&&(null===(i=o.state.cropSize)||void 0===i?void 0:i.width)===v.width||o.props.onCropSizeChange&&o.props.onCropSizeChange(v),o.setState({cropSize:v},o.recomputeCropPosition),v}},o.onMouseDown=function(e){e.preventDefault(),document.addEventListener("mousemove",o.onMouseMove),document.addEventListener("mouseup",o.onDragStopped),o.onDragStart(t.getMousePoint(e))},o.onMouseMove=function(e){return o.onDrag(t.getMousePoint(e))},o.onTouchStart=function(e){o.props.onTouchRequest&&!o.props.onTouchRequest(e)||(document.addEventListener("touchmove",o.onTouchMove,{passive:!1}),document.addEventListener("touchend",o.onDragStopped),2===e.touches.length?o.onPinchStart(e):1===e.touches.length&&o.onDragStart(t.getTouchPoint(e.touches[0])))},o.onTouchMove=function(e){e.preventDefault(),2===e.touches.length?o.onPinchMove(e):1===e.touches.length&&o.onDrag(t.getTouchPoint(e.touches[0]))},o.onDragStart=function(e){var t,r,n=e.x,a=e.y;o.dragStartPosition={x:n,y:a},o.dragStartCrop=c({},o.props.crop),null===(r=(t=o.props).onInteractionStart)||void 0===r||r.call(t)},o.onDrag=function(e){var t=e.x,r=e.y;o.rafDragTimeout&&window.cancelAnimationFrame(o.rafDragTimeout),o.rafDragTimeout=window.requestAnimationFrame((function(){if(o.state.cropSize&&void 0!==t&&void 0!==r){var e=t-o.dragStartPosition.x,n=r-o.dragStartPosition.y,a={x:o.dragStartCrop.x+e,y:o.dragStartCrop.y+n},i=o.props.restrictPosition?m(a,o.mediaSize,o.state.cropSize,o.props.zoom,o.props.rotation):a;o.props.onCropChange(i)}}))},o.onDragStopped=function(){var e,t;o.cleanEvents(),o.emitCropData(),null===(t=(e=o.props).onInteractionEnd)||void 0===t||t.call(e)},o.onWheel=function(e){if(!o.props.onWheelRequest||o.props.onWheelRequest(e)){e.preventDefault();var r=t.getMousePoint(e),n=h()(e).pixelY,a=o.props.zoom-n*o.props.zoomSpeed/200;o.setNewZoom(a,r),o.state.hasWheelJustStarted||o.setState({hasWheelJustStarted:!0},(function(){var e,t;return null===(t=(e=o.props).onInteractionStart)||void 0===t?void 0:t.call(e)})),o.wheelTimer&&clearTimeout(o.wheelTimer),o.wheelTimer=window.setTimeout((function(){return o.setState({hasWheelJustStarted:!1},(function(){var e,t;return null===(t=(e=o.props).onInteractionEnd)||void 0===t?void 0:t.call(e)}))}),250)}},o.getPointOnContainer=function(e){var t=e.x,r=e.y;if(!o.containerRect)throw new Error("The Cropper is not mounted");return{x:o.containerRect.width/2-(t-o.containerRect.left),y:o.containerRect.height/2-(r-o.containerRect.top)}},o.getPointOnMedia=function(e){var t=e.x,r=e.y,n=o.props,a=n.crop,i=n.zoom;return{x:(t+a.x)/i,y:(r+a.y)/i}},o.setNewZoom=function(e,t){if(o.state.cropSize&&o.props.onZoomChange){var r=o.getPointOnContainer(t),n=o.getPointOnMedia(r),a=x(e,o.props.minZoom,o.props.maxZoom),i={x:n.x*a-r.x,y:n.y*a-r.y},s=o.props.restrictPosition?m(i,o.mediaSize,o.state.cropSize,a,o.props.rotation):i;o.props.onCropChange(s),o.props.onZoomChange(a)}},o.getCropData=function(){return o.state.cropSize?w(o.props.restrictPosition?m(o.props.crop,o.mediaSize,o.state.cropSize,o.props.zoom,o.props.rotation):o.props.crop,o.mediaSize,o.state.cropSize,o.getAspect(),o.props.zoom,o.props.rotation,o.props.restrictPosition):null},o.emitCropData=function(){var e=o.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;o.props.onCropComplete&&o.props.onCropComplete(t,r),o.props.onCropAreaChange&&o.props.onCropAreaChange(t,r)}},o.emitCropAreaChange=function(){var e=o.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;o.props.onCropAreaChange&&o.props.onCropAreaChange(t,r)}},o.recomputeCropPosition=function(){if(o.state.cropSize){var e=o.props.restrictPosition?m(o.props.crop,o.mediaSize,o.state.cropSize,o.props.zoom,o.props.rotation):o.props.crop;o.props.onCropChange(e),o.emitCropData()}},o}return function(e,t){function __(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}(t,e),t.prototype.componentDidMount=function(){window.addEventListener("resize",this.computeSizes),this.containerRef&&(this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.preventZoomSafari),this.containerRef.addEventListener("gesturechange",this.preventZoomSafari)),this.props.disableAutomaticStylesInjection||(this.styleRef=document.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.props.nonce&&this.styleRef.setAttribute("nonce",this.props.nonce),this.styleRef.innerHTML=".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n",document.head.appendChild(this.styleRef)),this.imageRef.current&&this.imageRef.current.complete&&this.onMediaLoad(),this.props.setImageRef&&this.props.setImageRef(this.imageRef),this.props.setVideoRef&&this.props.setVideoRef(this.videoRef)},t.prototype.componentWillUnmount=function(){var e;window.removeEventListener("resize",this.computeSizes),this.containerRef&&(this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.containerRef.removeEventListener("gesturechange",this.preventZoomSafari)),this.styleRef&&(null===(e=this.styleRef.parentNode)||void 0===e||e.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent()},t.prototype.componentDidUpdate=function(e){var t,o,r,n,a,i,s,c,l;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():(null===(t=e.cropSize)||void 0===t?void 0:t.height)!==(null===(o=this.props.cropSize)||void 0===o?void 0:o.height)||(null===(r=e.cropSize)||void 0===r?void 0:r.width)!==(null===(n=this.props.cropSize)||void 0===n?void 0:n.width)?this.computeSizes():(null===(a=e.crop)||void 0===a?void 0:a.x)===(null===(i=this.props.crop)||void 0===i?void 0:i.x)&&(null===(s=e.crop)||void 0===s?void 0:s.y)===(null===(c=this.props.crop)||void 0===c?void 0:c.y)||this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&(null===(l=this.videoRef.current)||void 0===l||l.load())},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,o=e.aspect;return t?t.width/t.height:o},t.prototype.onPinchStart=function(e){var o=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=g(o,r),this.lastPinchRotation=f(o,r),this.onDragStart(b(o,r))},t.prototype.onPinchMove=function(e){var o=this,r=t.getTouchPoint(e.touches[0]),n=t.getTouchPoint(e.touches[1]),a=b(r,n);this.onDrag(a),this.rafPinchTimeout&&window.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=window.requestAnimationFrame((function(){var e=g(r,n),t=o.props.zoom*(e/o.lastPinchDistance);o.setNewZoom(t,a),o.lastPinchDistance=e;var i=f(r,n),s=o.props.rotation+(i-o.lastPinchRotation);o.props.onRotationChange&&o.props.onRotationChange(s),o.lastPinchRotation=i}))},t.prototype.render=function(){var e=this,t=this.props,o=t.image,r=t.video,n=t.mediaProps,a=t.transform,i=t.crop,s=i.x,l=i.y,d=t.rotation,h=t.zoom,u=t.cropShape,m=t.showGrid,v=t.style,g=v.containerStyle,f=v.cropAreaStyle,w=v.mediaStyle,y=t.classes,S=y.containerClassName,C=y.cropAreaClassName,_=y.mediaClassName,b=t.objectFit;return p().createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":"container",style:g,className:z("reactEasyCrop_Container",S)},o?p().createElement("img",c({alt:"",className:z("reactEasyCrop_Image","contain"===b&&"reactEasyCrop_Contain","horizontal-cover"===b&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===b&&"reactEasyCrop_Cover_Vertical","auto-cover"===b&&(this.mediaSize.naturalWidth>this.mediaSize.naturalHeight?"reactEasyCrop_Cover_Horizontal":"reactEasyCrop_Cover_Vertical"),_)},n,{src:o,ref:this.imageRef,style:c(c({},w),{transform:a||"translate("+s+"px, "+l+"px) rotate("+d+"deg) scale("+h+")"}),onLoad:this.onMediaLoad})):r&&p().createElement("video",c({autoPlay:!0,loop:!0,muted:!0,className:z("reactEasyCrop_Video","contain"===b&&"reactEasyCrop_Contain","horizontal-cover"===b&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===b&&"reactEasyCrop_Cover_Vertical","auto-cover"===b&&(this.mediaSize.naturalWidth>this.mediaSize.naturalHeight?"reactEasyCrop_Cover_Horizontal":"reactEasyCrop_Cover_Vertical"),_)},n,{ref:this.videoRef,onLoadedMetadata:this.onMediaLoad,style:c(c({},w),{transform:a||"translate("+s+"px, "+l+"px) rotate("+d+"deg) scale("+h+")"}),controls:!1}),(Array.isArray(r)?r:[{src:r}]).map((function(e){return p().createElement("source",c({key:e.src},e))}))),this.state.cropSize&&p().createElement("div",{style:c(c({},f),{width:this.state.cropSize.width,height:this.state.cropSize.height}),"data-testid":"cropper",className:z("reactEasyCrop_CropArea","round"===u&&"reactEasyCrop_CropAreaRound",m&&"reactEasyCrop_CropAreaGrid",C)}))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:3,minZoom:1,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(p().Component),R=M;const P=e=>new Promise(((t,o)=>{const r=new Image;r.addEventListener("load",(()=>t(r))),r.addEventListener("error",(e=>o(e))),r.setAttribute("crossOrigin","anonymous"),r.src=e}));function A(e){return e*Math.PI/180}function L(e,t,o){const r=A(o);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}document.addEventListener("DOMContentLoaded",(function(e){(()=>{const e=document.querySelectorAll(".learn-press-course-tab__filter__content"),o=function(e,o){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];wp.apiFetch({path:(0,t.addQueryArgs)("lp/v1/profile/course-tab",o),method:"GET"}).then((t=>{const i=e.querySelector(".lp-skeleton-animation");if(i&&i.remove(),"success"===t.status&&t.data?n?e.innerHTML+=t.data:e.innerHTML=t.data:n?e.innerHTML+=`<div class="lp-ajax-message" style="display:block">${t.message&&t.message}</div>`:e.innerHTML=`<div class="lp-ajax-message" style="display:block">${t.message&&t.message}</div>`,a){a.classList.remove("loading");const e=a.dataset.paged;a.dataset.number<=e&&a.remove(),a.dataset.paged=parseInt(e)+1}r(e,o)})).catch((t=>{if(n?e.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${t.message&&t.message}</div>`:e.innerHTML=`<div class="lp-ajax-message error" style="display:block">${t.message&&t.message}</div>`,a){a.classList.remove("loading");const e=a.dataset.paged;a.dataset.number<=e&&a.remove(),a.dataset.paged=parseInt(e)+1}}))};if("IntersectionObserver"in window){const t=new IntersectionObserver(((e,r)=>{e.forEach((e=>{if(e.isIntersecting){const r=e.target,n=r.parentNode.querySelector(".lp_profile_tab_input_param"),a={...JSON.parse(n.value),status:r.dataset.tab||""};o(r,a),t.unobserve(r)}}))}));[...e].map((e=>{if("all"!==e.dataset.tab)t.observe(e);else{const t=e.parentNode.querySelector(".lp_profile_tab_input_param"),r={...JSON.parse(t.value),status:"all"===e.dataset.tab?"":e.dataset.tab||""};o(e,r)}}))}document.querySelectorAll(".learn-press-course-tab-filters").forEach((e=>{const t=e.querySelectorAll(".learn-press-filters a");t.forEach((o=>{o.addEventListener("click",(r=>{r.preventDefault();const n=o.dataset.tab;[...t].map((e=>{e.classList.remove("active")})),o.classList.add("active"),[...e.querySelectorAll(".learn-press-course-tab__filter__content")].map((e=>{e.style.display="none",e.dataset.tab===n&&(e.style.display="")}))}))}))})),document.querySelectorAll(".learn-press-profile-course__tab__inner").forEach((e=>{const t=e.querySelectorAll("li> a");t.forEach((e=>{e.addEventListener("click",(o=>{o.preventDefault();const r=e.dataset.tab;[...t].map((e=>{e.classList.remove("active")})),e.classList.add("active"),[...document.querySelectorAll(".learn-press-course-tab-filters")].map((e=>{e.style.display="none",e.dataset.tab===r&&(e.style.display="")}))}))}))}));const r=(e,t)=>{const r=e.querySelector("button[data-paged]");r&&r.addEventListener("click",(n=>{n.preventDefault();const a=r&&r.dataset.paged;r.classList.add("loading");const i="list"===t.layout?".lp_profile_course_progress":".learn-press-courses";o(e.querySelector(i),{...t,paged:a},!0,r)}))}})(),(()=>{const e=document.querySelector(".learn-press-profile-course__statistic");if(!e)return;const o=document.querySelector('[name="args_query_user_courses_statistic"]');if(!o)return;const r=JSON.parse(o.value);var n,a;n=e,a=r,wp.apiFetch({path:(0,t.addQueryArgs)("lp/v1/profile/statistic",a),method:"GET"}).then((e=>{"success"===e.status&&e.data?n.innerHTML=e.data:n.innerHTML=`<div class="lp-ajax-message error" style="display:block">${e.message&&e.message}</div>`})).catch((e=>{console.log(e)}))})(),function(){const e=r(".order-recover"),t=e.find(".button-recover-order");t.on("click",(()=>{e.find(".learn-press-message").remove(),r(".profile-recover-order").find(".learn-press-message").remove(),r.post({url:"",data:e.serializeJSON(),beforeSend(){t.addClass("loading").attr("disabled","disabled")},success(o){if((o=LP.parseJSON(o)).message){const t=r('<div class="learn-press-message icon"><i class="fa"></i> '+o.message+"</div>");"error"==o.result&&t.addClass("error"),e.before(t)}o.redirect&&(window.location.href=o.redirect),t.removeClass("loading").removeAttr("disabled","")},error(){t.removeClass("loading").removeAttr("disabled","")}})}))}()})),document.getElementById("learnpress-avatar-upload")&&wp.element.render((0,e.createElement)((function(){const[t,o]=(0,e.useState)(),[r,n]=(0,e.useState)(0),[s,c]=(0,e.useState)(0),[l,p]=(0,e.useState)({x:0,y:0}),[d,h]=(0,e.useState)(0),[u,m]=(0,e.useState)(null),[v,g]=(0,e.useState)(0),[f,w]=(0,e.useState)(0),[y,S]=(0,e.useState)(!1),[C,_]=(0,e.useState)(!0),[b,E]=(0,e.useState)(""),[x,z]=(0,e.useState)({type:"",message:""}),M=(0,e.useRef)();(0,e.useEffect)((()=>{!async function(){_(!0);try{var e,t,r;const i=await a()({method:"GET",path:"lp/v1/profile/get-avatar"});n(null!=i&&null!==(e=i.data)&&void 0!==e&&e.width?parseInt(i.data.width):0),c(null!=i&&null!==(t=i.data)&&void 0!==t&&t.height?parseInt(i.data.height):0),o(null!=i&&null!==(r=i.data)&&void 0!==r&&r.url?i.data.url:"")}catch(e){z({type:"error",message:e.message})}_(!1)}()}),[]);const D=(0,e.useCallback)(((e,t)=>{m(t)}),[]),T=(0,e.useCallback)((async()=>{S({save:!0});try{const e=await async function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{horizontal:!1,vertical:!1};const n=await P(e),a=document.createElement("canvas"),i=a.getContext("2d");if(!i)return null;const s=A(o),{width:c,height:l}=L(n.width,n.height,o);a.width=c,a.height=l,i.translate(c/2,l/2),i.rotate(s),i.scale(r.horizontal?-1:1,r.vertical?-1:1),i.translate(-n.width/2,-n.height/2),i.drawImage(n,0,0);const p=i.getImageData(t.x,t.y,t.width,t.height);return a.width=t.width,a.height=t.height,i.putImageData(p,0,0),a.toDataURL("image/jpeg")}(t,u,d),o=await((e,t,o)=>new Promise(((r,n)=>{const a=document.createElement("canvas"),i=document.createElement("img");i.src=e,i.setAttribute("crossOrigin","anonymous"),i.onload=()=>{(i.naturalWidth>t||i.naturalHeight>o)&&(a.width=t,a.height=o,a.getContext("2d").drawImage(i,0,0,t,o),r(a.toDataURL("image/jpeg"))),r(e)},i.onerror=e=>n(e)})))(e,r,s),n=await a()({path:"lp/v1/profile/upload-avatar",method:"POST",data:{file:o||""}}),{data:i,status:c,message:l}=await n;"success"===c&&window.location.reload(),z({type:c,message:l})}catch(e){z({type:"error",message:e.message||""})}S({save:!1})}),[u,d]);return(0,e.createElement)("div",{className:"learnpress_avatar"},C?(0,e.createElement)("ul",{className:"lp-skeleton-animation"},(0,e.createElement)("li",{style:{width:200,height:200}}),(0,e.createElement)("li",{style:{width:200,height:20}}),(0,e.createElement)("li",{style:{width:200,height:20}})):(0,e.createElement)(e.Fragment,null,t&&!b&&(0,e.createElement)(e.Fragment,null,f&&v?(0,e.createElement)("div",{className:"learnpress_avatar__cropper"},(0,e.createElement)("div",{style:{position:"relative",width:v,height:f,zIndex:9999,maxWidth:"100%",maxHeight:"800px"}},(0,e.createElement)(R,{image:t,crop:l,zoom:"1",cropSize:{width:r,height:s},onCropChange:p,onCropComplete:D})),(0,e.createElement)("div",null,(0,e.createElement)("button",{className:"learnpress_avatar__button learnpress_avatar__button--save "+(null!=y&&y.save?"learnpress_avatar__button--loading":""),onClick:T},(0,i.__)("Save","learnpress")))):(0,e.createElement)("div",{className:"learnpress_avatar__cropper"},(0,e.createElement)("img",{src:t,alt:""}),(0,e.createElement)("div",null,(0,e.createElement)("button",{className:"learnpress_avatar__button learnpress_avatar__button--replace",onClick:()=>M.current&&M.current.click()},(0,i.__)("Replace","learnpress")),(0,e.createElement)("button",{className:"learnpress_avatar__button learnpress_avatar__button--remove "+(null!=y&&y.remove?"learnpress_avatar__button--loading":""),onClick:async function(){if(confirm((0,i.__)("Are you sure you want to remove your avatar?","learnpress"))){S({remove:!0});try{const e=await a()({path:"lp/v1/profile/remove-avatar",method:"POST"}),{data:t,status:r,message:n}=await e;z({type:r,message:n}),o("")}catch(e){z({type:"error",message:e.message||""})}S({remove:!1})}}},(0,i.__)("Remove","learnpress"))))),(0,e.createElement)("form",{style:{display:t?"none":""}},(0,e.createElement)("div",{className:"learnpress_avatar__form"},(0,e.createElement)("div",{className:"learnpress_avatar__form-group"},(0,e.createElement)("label",{htmlFor:"avatar-file"},(0,e.createElement)("div",{className:"learnpress_avatar__form__upload"},(0,e.createElement)("div",null,(0,e.createElement)("span",null,(0,e.createElement)("svg",{viewBox:"64 64 896 896",focusable:"false","data-icon":"plus",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"},(0,e.createElement)("defs",null,(0,e.createElement)("style",null)),(0,e.createElement)("path",{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}),(0,e.createElement)("path",{d:"M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z"}))),(0,e.createElement)("div",null,(0,i.__)("Upload","learnpress")))),(0,e.createElement)("input",{ref:M,type:"file",id:"avatar-file",accept:"image/*",onChange:e=>(async e=>{const t=await function(e){return new Promise((t=>{const o=new FileReader;o.addEventListener("load",(()=>t(o.result)),!1),o.readAsDataURL(e)}))}(e),n=new Image;n.src=await t,n.onload=await(function(){g(n.naturalWidth),w(n.naturalHeight);let a="";parseInt(e.size)>2097152?a=(0,i.__)("File size too large. You need to upload a file < 2MB","learnpress"):(n.naturalWidth<r||n.naturalHeight<s)&&(a=(0,i.sprintf)((0,i.__)("Image size must be greater than or equal to %1$sx%2$spx","learnpress"),r,s)),a?E(a):(E(""),o(t))})})(e.target.files&&e.target.files.length>0?e.target.files[0]:"")}))))),b&&(0,e.createElement)("div",{className:"lp-ajax-message error",style:{display:"block"}},b),!b&&x&&x.type&&x.message&&(0,e.createElement)("div",{className:`lp-ajax-message ${x.type}`,style:{display:"block"}},x.message)))}),null),document.getElementById("learnpress-avatar-upload"))}()}();
1
+ !function(){var e={796:function(e,t,o){e.exports=o(643)},264:function(e){"use strict";var t=!("undefined"==typeof window||!window.document||!window.document.createElement),o={canUseDOM:t,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:t&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:t&&!!window.screen,isInWorker:!t};e.exports=o},518:function(e){var t,o,r,n,a,i,s,c,l,p,d,h,u,m,v,g=!1;function f(){if(!g){g=!0;var e=navigator.userAgent,f=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e),w=/(Mac OS X)|(Windows)|(Linux)/.exec(e);if(h=/\b(iPhone|iP[ao]d)/.exec(e),u=/\b(iP[ao]d)/.exec(e),p=/Android/i.exec(e),m=/FBAN\/\w+;/i.exec(e),v=/Mobile/i.exec(e),d=!!/Win64/.exec(e),f){(t=f[1]?parseFloat(f[1]):f[5]?parseFloat(f[5]):NaN)&&document&&document.documentMode&&(t=document.documentMode);var y=/(?:Trident\/(\d+.\d+))/.exec(e);i=y?parseFloat(y[1])+4:t,o=f[2]?parseFloat(f[2]):NaN,r=f[3]?parseFloat(f[3]):NaN,(n=f[4]?parseFloat(f[4]):NaN)?(f=/(?:Chrome\/(\d+\.\d+))/.exec(e),a=f&&f[1]?parseFloat(f[1]):NaN):a=NaN}else t=o=r=a=n=NaN;if(w){if(w[1]){var S=/(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e);s=!S||parseFloat(S[1].replace("_","."))}else s=!1;c=!!w[2],l=!!w[3]}else s=c=l=!1}}var w={ie:function(){return f()||t},ieCompatibilityMode:function(){return f()||i>t},ie64:function(){return w.ie()&&d},firefox:function(){return f()||o},opera:function(){return f()||r},webkit:function(){return f()||n},safari:function(){return w.webkit()},chrome:function(){return f()||a},windows:function(){return f()||c},osx:function(){return f()||s},linux:function(){return f()||l},iphone:function(){return f()||h},mobile:function(){return f()||h||u||p||v},nativeApp:function(){return f()||m},android:function(){return f()||p},ipad:function(){return f()||u}};e.exports=w},534:function(e,t,o){"use strict";var r,n=o(264);n.canUseDOM&&(r=document.implementation&&document.implementation.hasFeature&&!0!==document.implementation.hasFeature("","")),e.exports=function(e,t){if(!n.canUseDOM||t&&!("addEventListener"in document))return!1;var o="on"+e,a=o in document;if(!a){var i=document.createElement("div");i.setAttribute(o,"return;"),a="function"==typeof i[o]}return!a&&r&&"wheel"===e&&(a=document.implementation.hasFeature("Events.wheel","3.0")),a}},643:function(e,t,o){"use strict";var r=o(518),n=o(534);function a(e){var t=0,o=0,r=0,n=0;return"detail"in e&&(o=e.detail),"wheelDelta"in e&&(o=-e.wheelDelta/120),"wheelDeltaY"in e&&(o=-e.wheelDeltaY/120),"wheelDeltaX"in e&&(t=-e.wheelDeltaX/120),"axis"in e&&e.axis===e.HORIZONTAL_AXIS&&(t=o,o=0),r=10*t,n=10*o,"deltaY"in e&&(n=e.deltaY),"deltaX"in e&&(r=e.deltaX),(r||n)&&e.deltaMode&&(1==e.deltaMode?(r*=40,n*=40):(r*=800,n*=800)),r&&!t&&(t=r<1?-1:1),n&&!o&&(o=n<1?-1:1),{spinX:t,spinY:o,pixelX:r,pixelY:n}}a.getEventType=function(){return r.firefox()?"DOMMouseScroll":n("wheel")?"wheel":"mousewheel"},e.exports=a}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,o),a.exports}o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,{a:t}),t},o.d=function(e,t){for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.url;const r=window.jQuery;var n=window.wp.apiFetch,a=o.n(n),i=window.wp.i18n,s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},s(e,t)},c=function(){return c=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},c.apply(this,arguments)};Object.create,Object.create;var l=window.React,p=o.n(l),d=o(796),h=o.n(d);function u(e,t,o,r,n,a){void 0===a&&(a=0);var i=E(e,t,a),s=i.width,c=i.height,l=Math.min(s,o),p=Math.min(c,r);return l>p*n?{width:p*n,height:p}:{width:l,height:l/n}}function m(e,t,o,r,n){void 0===n&&(n=0);var a=E(t.width,t.height,n),i=a.width,s=a.height;return{x:v(e.x,i,o.width,r),y:v(e.y,s,o.height,r)}}function v(e,t,o,r){var n=t*r/2-o/2;return x(e,-n,n)}function g(e,t){return Math.sqrt(Math.pow(e.y-t.y,2)+Math.pow(e.x-t.x,2))}function f(e,t){return 180*Math.atan2(t.y-e.y,t.x-e.x)/Math.PI}function w(e,t,o,r,n,a,i){void 0===a&&(a=0),void 0===i&&(i=!0);var s=i?y:S,l=E(t.width,t.height,a),p=E(t.naturalWidth,t.naturalHeight,a),d={x:s(100,((l.width-o.width/n)/2-e.x/n)/l.width*100),y:s(100,((l.height-o.height/n)/2-e.y/n)/l.height*100),width:s(100,o.width/l.width*100/n),height:s(100,o.height/l.height*100/n)},h=Math.round(s(p.width,d.width*p.width/100)),u=Math.round(s(p.height,d.height*p.height/100)),m=p.width>=p.height*r?{width:Math.round(u*r),height:u}:{width:h,height:Math.round(h/r)};return{croppedAreaPercentages:d,croppedAreaPixels:c(c({},m),{x:Math.round(s(p.width-m.width,d.x*p.width/100)),y:Math.round(s(p.height-m.height,d.y*p.height/100))})}}function y(e,t){return Math.min(e,Math.max(0,t))}function S(e,t){return t}function C(e,t,o,r,n,a){var i=E(t.width,t.height,o),s=x(r.width/i.width*(100/e.width),n,a);return{crop:{x:s*i.width/2-r.width/2-i.width*s*(e.x/100),y:s*i.height/2-r.height/2-i.height*s*(e.y/100)},zoom:s}}function b(e,t,o,r,n,a){void 0===o&&(o=0);var i=E(t.naturalWidth,t.naturalHeight,o),s=x(function(e,t,o){var r=function(e){return e.width>e.height?e.width/e.naturalWidth:e.height/e.naturalHeight}(t);return o.height>o.width?o.height/(e.height*r):o.width/(e.width*r)}(e,t,r),n,a),c=r.height>r.width?r.height/e.height:r.width/e.width;return{crop:{x:((i.width-e.width)/2-e.x)*c,y:((i.height-e.height)/2-e.y)*c},zoom:s}}function _(e,t){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function E(e,t,o){var r=o*Math.PI/180;return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}function x(e,t,o){return Math.min(Math.max(e,t),o)}function M(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.filter((function(e){return"string"==typeof e&&e.length>0})).join(" ").trim()}var z=function(e){function t(){var o=null!==e&&e.apply(this,arguments)||this;return o.imageRef=null,o.videoRef=null,o.containerRef=null,o.styleRef=null,o.containerRect=null,o.mediaSize={width:0,height:0,naturalWidth:0,naturalHeight:0},o.dragStartPosition={x:0,y:0},o.dragStartCrop={x:0,y:0},o.lastPinchDistance=0,o.lastPinchRotation=0,o.rafDragTimeout=null,o.rafPinchTimeout=null,o.wheelTimer=null,o.state={cropSize:null,hasWheelJustStarted:!1},o.preventZoomSafari=function(e){return e.preventDefault()},o.cleanEvents=function(){document.removeEventListener("mousemove",o.onMouseMove),document.removeEventListener("mouseup",o.onDragStopped),document.removeEventListener("touchmove",o.onTouchMove),document.removeEventListener("touchend",o.onDragStopped)},o.clearScrollEvent=function(){o.containerRef&&o.containerRef.removeEventListener("wheel",o.onWheel),o.wheelTimer&&clearTimeout(o.wheelTimer)},o.onMediaLoad=function(){var e=o.computeSizes();e&&(o.emitCropData(),o.setInitialCrop(e)),o.props.onMediaLoaded&&o.props.onMediaLoaded(o.mediaSize)},o.setInitialCrop=function(e){if(o.props.initialCroppedAreaPercentages){var t=C(o.props.initialCroppedAreaPercentages,o.mediaSize,o.props.rotation,e,o.props.minZoom,o.props.maxZoom),r=t.crop,n=t.zoom;o.props.onCropChange(r),o.props.onZoomChange&&o.props.onZoomChange(n)}else if(o.props.initialCroppedAreaPixels){var a=b(o.props.initialCroppedAreaPixels,o.mediaSize,o.props.rotation,e,o.props.minZoom,o.props.maxZoom);r=a.crop,n=a.zoom,o.props.onCropChange(r),o.props.onZoomChange&&o.props.onZoomChange(n)}},o.computeSizes=function(){var e,t,r,n,a,i,s=o.imageRef||o.videoRef;if(s&&o.containerRef){o.containerRect=o.containerRef.getBoundingClientRect();var l=o.containerRect.width/o.containerRect.height,p=(null===(e=o.imageRef)||void 0===e?void 0:e.naturalWidth)||(null===(t=o.videoRef)||void 0===t?void 0:t.videoWidth)||0,d=(null===(r=o.imageRef)||void 0===r?void 0:r.naturalHeight)||(null===(n=o.videoRef)||void 0===n?void 0:n.videoHeight)||0,h=p/d,m=void 0;if(s.offsetWidth<p||s.offsetHeight<d)switch(o.props.objectFit){default:case"contain":m=l>h?{width:o.containerRect.height*h,height:o.containerRect.height}:{width:o.containerRect.width,height:o.containerRect.width/h};break;case"horizontal-cover":m={width:o.containerRect.width,height:o.containerRect.width/h};break;case"vertical-cover":m={width:o.containerRect.height*h,height:o.containerRect.height}}else m={width:s.offsetWidth,height:s.offsetHeight};o.mediaSize=c(c({},m),{naturalWidth:p,naturalHeight:d});var v=o.props.cropSize?o.props.cropSize:u(o.mediaSize.width,o.mediaSize.height,o.containerRect.width,o.containerRect.height,o.props.aspect,o.props.rotation);return(null===(a=o.state.cropSize)||void 0===a?void 0:a.height)===v.height&&(null===(i=o.state.cropSize)||void 0===i?void 0:i.width)===v.width||o.props.onCropSizeChange&&o.props.onCropSizeChange(v),o.setState({cropSize:v},o.recomputeCropPosition),v}},o.onMouseDown=function(e){e.preventDefault(),document.addEventListener("mousemove",o.onMouseMove),document.addEventListener("mouseup",o.onDragStopped),o.onDragStart(t.getMousePoint(e))},o.onMouseMove=function(e){return o.onDrag(t.getMousePoint(e))},o.onTouchStart=function(e){o.props.onTouchRequest&&!o.props.onTouchRequest(e)||(document.addEventListener("touchmove",o.onTouchMove,{passive:!1}),document.addEventListener("touchend",o.onDragStopped),2===e.touches.length?o.onPinchStart(e):1===e.touches.length&&o.onDragStart(t.getTouchPoint(e.touches[0])))},o.onTouchMove=function(e){e.preventDefault(),2===e.touches.length?o.onPinchMove(e):1===e.touches.length&&o.onDrag(t.getTouchPoint(e.touches[0]))},o.onDragStart=function(e){var t,r,n=e.x,a=e.y;o.dragStartPosition={x:n,y:a},o.dragStartCrop=c({},o.props.crop),null===(r=(t=o.props).onInteractionStart)||void 0===r||r.call(t)},o.onDrag=function(e){var t=e.x,r=e.y;o.rafDragTimeout&&window.cancelAnimationFrame(o.rafDragTimeout),o.rafDragTimeout=window.requestAnimationFrame((function(){if(o.state.cropSize&&void 0!==t&&void 0!==r){var e=t-o.dragStartPosition.x,n=r-o.dragStartPosition.y,a={x:o.dragStartCrop.x+e,y:o.dragStartCrop.y+n},i=o.props.restrictPosition?m(a,o.mediaSize,o.state.cropSize,o.props.zoom,o.props.rotation):a;o.props.onCropChange(i)}}))},o.onDragStopped=function(){var e,t;o.cleanEvents(),o.emitCropData(),null===(t=(e=o.props).onInteractionEnd)||void 0===t||t.call(e)},o.onWheel=function(e){if(!o.props.onWheelRequest||o.props.onWheelRequest(e)){e.preventDefault();var r=t.getMousePoint(e),n=h()(e).pixelY,a=o.props.zoom-n*o.props.zoomSpeed/200;o.setNewZoom(a,r),o.state.hasWheelJustStarted||o.setState({hasWheelJustStarted:!0},(function(){var e,t;return null===(t=(e=o.props).onInteractionStart)||void 0===t?void 0:t.call(e)})),o.wheelTimer&&clearTimeout(o.wheelTimer),o.wheelTimer=window.setTimeout((function(){return o.setState({hasWheelJustStarted:!1},(function(){var e,t;return null===(t=(e=o.props).onInteractionEnd)||void 0===t?void 0:t.call(e)}))}),250)}},o.getPointOnContainer=function(e){var t=e.x,r=e.y;if(!o.containerRect)throw new Error("The Cropper is not mounted");return{x:o.containerRect.width/2-(t-o.containerRect.left),y:o.containerRect.height/2-(r-o.containerRect.top)}},o.getPointOnMedia=function(e){var t=e.x,r=e.y,n=o.props,a=n.crop,i=n.zoom;return{x:(t+a.x)/i,y:(r+a.y)/i}},o.setNewZoom=function(e,t){if(o.state.cropSize&&o.props.onZoomChange){var r=o.getPointOnContainer(t),n=o.getPointOnMedia(r),a=x(e,o.props.minZoom,o.props.maxZoom),i={x:n.x*a-r.x,y:n.y*a-r.y},s=o.props.restrictPosition?m(i,o.mediaSize,o.state.cropSize,a,o.props.rotation):i;o.props.onCropChange(s),o.props.onZoomChange(a)}},o.getCropData=function(){return o.state.cropSize?w(o.props.restrictPosition?m(o.props.crop,o.mediaSize,o.state.cropSize,o.props.zoom,o.props.rotation):o.props.crop,o.mediaSize,o.state.cropSize,o.getAspect(),o.props.zoom,o.props.rotation,o.props.restrictPosition):null},o.emitCropData=function(){var e=o.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;o.props.onCropComplete&&o.props.onCropComplete(t,r),o.props.onCropAreaChange&&o.props.onCropAreaChange(t,r)}},o.emitCropAreaChange=function(){var e=o.getCropData();if(e){var t=e.croppedAreaPercentages,r=e.croppedAreaPixels;o.props.onCropAreaChange&&o.props.onCropAreaChange(t,r)}},o.recomputeCropPosition=function(){if(o.state.cropSize){var e=o.props.restrictPosition?m(o.props.crop,o.mediaSize,o.state.cropSize,o.props.zoom,o.props.rotation):o.props.crop;o.props.onCropChange(e),o.emitCropData()}},o}return function(e,t){function __(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}(t,e),t.prototype.componentDidMount=function(){window.addEventListener("resize",this.computeSizes),this.containerRef&&(this.props.zoomWithScroll&&this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}),this.containerRef.addEventListener("gesturestart",this.preventZoomSafari),this.containerRef.addEventListener("gesturechange",this.preventZoomSafari)),this.props.disableAutomaticStylesInjection||(this.styleRef=document.createElement("style"),this.styleRef.setAttribute("type","text/css"),this.styleRef.innerHTML=".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n",document.head.appendChild(this.styleRef)),this.imageRef&&this.imageRef.complete&&this.onMediaLoad()},t.prototype.componentWillUnmount=function(){var e;window.removeEventListener("resize",this.computeSizes),this.containerRef&&(this.containerRef.removeEventListener("gesturestart",this.preventZoomSafari),this.containerRef.removeEventListener("gesturechange",this.preventZoomSafari)),this.styleRef&&(null===(e=this.styleRef.parentNode)||void 0===e||e.removeChild(this.styleRef)),this.cleanEvents(),this.props.zoomWithScroll&&this.clearScrollEvent()},t.prototype.componentDidUpdate=function(e){var t,o,r,n,a,i,s,c,l;e.rotation!==this.props.rotation?(this.computeSizes(),this.recomputeCropPosition()):e.aspect!==this.props.aspect?this.computeSizes():e.zoom!==this.props.zoom?this.recomputeCropPosition():(null===(t=e.cropSize)||void 0===t?void 0:t.height)!==(null===(o=this.props.cropSize)||void 0===o?void 0:o.height)||(null===(r=e.cropSize)||void 0===r?void 0:r.width)!==(null===(n=this.props.cropSize)||void 0===n?void 0:n.width)?this.computeSizes():(null===(a=e.crop)||void 0===a?void 0:a.x)===(null===(i=this.props.crop)||void 0===i?void 0:i.x)&&(null===(s=e.crop)||void 0===s?void 0:s.y)===(null===(c=this.props.crop)||void 0===c?void 0:c.y)||this.emitCropAreaChange(),e.zoomWithScroll!==this.props.zoomWithScroll&&this.containerRef&&(this.props.zoomWithScroll?this.containerRef.addEventListener("wheel",this.onWheel,{passive:!1}):this.clearScrollEvent()),e.video!==this.props.video&&(null===(l=this.videoRef)||void 0===l||l.load())},t.prototype.getAspect=function(){var e=this.props,t=e.cropSize,o=e.aspect;return t?t.width/t.height:o},t.prototype.onPinchStart=function(e){var o=t.getTouchPoint(e.touches[0]),r=t.getTouchPoint(e.touches[1]);this.lastPinchDistance=g(o,r),this.lastPinchRotation=f(o,r),this.onDragStart(_(o,r))},t.prototype.onPinchMove=function(e){var o=this,r=t.getTouchPoint(e.touches[0]),n=t.getTouchPoint(e.touches[1]),a=_(r,n);this.onDrag(a),this.rafPinchTimeout&&window.cancelAnimationFrame(this.rafPinchTimeout),this.rafPinchTimeout=window.requestAnimationFrame((function(){var e=g(r,n),t=o.props.zoom*(e/o.lastPinchDistance);o.setNewZoom(t,a),o.lastPinchDistance=e;var i=f(r,n),s=o.props.rotation+(i-o.lastPinchRotation);o.props.onRotationChange&&o.props.onRotationChange(s),o.lastPinchRotation=i}))},t.prototype.render=function(){var e=this,t=this.props,o=t.image,r=t.video,n=t.mediaProps,a=t.transform,i=t.crop,s=i.x,l=i.y,d=t.rotation,h=t.zoom,u=t.cropShape,m=t.showGrid,v=t.style,g=v.containerStyle,f=v.cropAreaStyle,w=v.mediaStyle,y=t.classes,S=y.containerClassName,C=y.cropAreaClassName,b=y.mediaClassName,_=t.objectFit;return p().createElement("div",{onMouseDown:this.onMouseDown,onTouchStart:this.onTouchStart,ref:function(t){return e.containerRef=t},"data-testid":"container",style:g,className:M("reactEasyCrop_Container",S)},o?p().createElement("img",c({alt:"",className:M("reactEasyCrop_Image","contain"===_&&"reactEasyCrop_Contain","horizontal-cover"===_&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===_&&"reactEasyCrop_Cover_Vertical",b)},n,{src:o,ref:function(t){return e.imageRef=t},style:c(c({},w),{transform:a||"translate("+s+"px, "+l+"px) rotate("+d+"deg) scale("+h+")"}),onLoad:this.onMediaLoad})):r&&p().createElement("video",c({autoPlay:!0,loop:!0,muted:!0,className:M("reactEasyCrop_Video","contain"===_&&"reactEasyCrop_Contain","horizontal-cover"===_&&"reactEasyCrop_Cover_Horizontal","vertical-cover"===_&&"reactEasyCrop_Cover_Vertical",b)},n,{ref:function(t){return e.videoRef=t},onLoadedMetadata:this.onMediaLoad,style:c(c({},w),{transform:a||"translate("+s+"px, "+l+"px) rotate("+d+"deg) scale("+h+")"}),controls:!1}),(Array.isArray(r)?r:[{src:r}]).map((function(e){return p().createElement("source",c({key:e.src},e))}))),this.state.cropSize&&p().createElement("div",{style:c(c({},f),{width:this.state.cropSize.width,height:this.state.cropSize.height}),"data-testid":"cropper",className:M("reactEasyCrop_CropArea","round"===u&&"reactEasyCrop_CropAreaRound",m&&"reactEasyCrop_CropAreaGrid",C)}))},t.defaultProps={zoom:1,rotation:0,aspect:4/3,maxZoom:3,minZoom:1,cropShape:"rect",objectFit:"contain",showGrid:!0,style:{},classes:{},mediaProps:{},zoomSpeed:1,restrictPosition:!0,zoomWithScroll:!0},t.getMousePoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t.getTouchPoint=function(e){return{x:Number(e.clientX),y:Number(e.clientY)}},t}(p().Component),P=z;const R=e=>new Promise(((t,o)=>{const r=new Image;r.addEventListener("load",(()=>t(r))),r.addEventListener("error",(e=>o(e))),r.setAttribute("crossOrigin","anonymous"),r.src=e}));function A(e){return e*Math.PI/180}function L(e,t,o){const r=A(o);return{width:Math.abs(Math.cos(r)*e)+Math.abs(Math.sin(r)*t),height:Math.abs(Math.sin(r)*e)+Math.abs(Math.cos(r)*t)}}document.addEventListener("DOMContentLoaded",(function(e){(()=>{const e=document.querySelectorAll(".learn-press-course-tab__filter__content"),o=function(e,o){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];wp.apiFetch({path:(0,t.addQueryArgs)("lp/v1/profile/course-tab",o),method:"GET"}).then((t=>{const i=e.querySelector(".lp-skeleton-animation");if(i&&i.remove(),"success"===t.status&&t.data?n?e.innerHTML+=t.data:e.innerHTML=t.data:n?e.innerHTML+=`<div class="lp-ajax-message" style="display:block">${t.message&&t.message}</div>`:e.innerHTML=`<div class="lp-ajax-message" style="display:block">${t.message&&t.message}</div>`,a){a.classList.remove("loading");const e=a.dataset.paged;a.dataset.number<=e&&a.remove(),a.dataset.paged=parseInt(e)+1}r(e,o)})).catch((t=>{if(n?e.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${t.message&&t.message}</div>`:e.innerHTML=`<div class="lp-ajax-message error" style="display:block">${t.message&&t.message}</div>`,a){a.classList.remove("loading");const e=a.dataset.paged;a.dataset.number<=e&&a.remove(),a.dataset.paged=parseInt(e)+1}}))};if("IntersectionObserver"in window){const t=new IntersectionObserver(((e,r)=>{e.forEach((e=>{if(e.isIntersecting){const r=e.target,n=r.parentNode.querySelector(".lp_profile_tab_input_param"),a={...JSON.parse(n.value),status:r.dataset.tab||""};o(r,a),t.unobserve(r)}}))}));[...e].map((e=>{if("all"!==e.dataset.tab)t.observe(e);else{const t=e.parentNode.querySelector(".lp_profile_tab_input_param"),r={...JSON.parse(t.value),status:"all"===e.dataset.tab?"":e.dataset.tab||""};o(e,r)}}))}document.querySelectorAll(".learn-press-course-tab-filters").forEach((e=>{const t=e.querySelectorAll(".learn-press-filters a");t.forEach((o=>{o.addEventListener("click",(r=>{r.preventDefault();const n=o.dataset.tab;[...t].map((e=>{e.classList.remove("active")})),o.classList.add("active"),[...e.querySelectorAll(".learn-press-course-tab__filter__content")].map((e=>{e.style.display="none",e.dataset.tab===n&&(e.style.display="")}))}))}))})),document.querySelectorAll(".learn-press-profile-course__tab__inner").forEach((e=>{const t=e.querySelectorAll("li> a");t.forEach((e=>{e.addEventListener("click",(o=>{o.preventDefault();const r=e.dataset.tab;[...t].map((e=>{e.classList.remove("active")})),e.classList.add("active"),[...document.querySelectorAll(".learn-press-course-tab-filters")].map((e=>{e.style.display="none",e.dataset.tab===r&&(e.style.display="")}))}))}))}));const r=(e,t)=>{const r=e.querySelector("button[data-paged]");r&&r.addEventListener("click",(n=>{n.preventDefault();const a=r&&r.dataset.paged;r.classList.add("loading");const i="list"===t.layout?".lp_profile_course_progress":".learn-press-courses";o(e.querySelector(i),{...t,paged:a},!0,r)}))}})(),(()=>{const e=document.querySelector(".learn-press-profile-course__statistic");if(!e)return;const o=document.querySelector('[name="args_query_user_courses_statistic"]');if(!o)return;const r=JSON.parse(o.value);var n,a;n=e,a=r,wp.apiFetch({path:(0,t.addQueryArgs)("lp/v1/profile/statistic",a),method:"GET"}).then((e=>{"success"===e.status&&e.data?n.innerHTML=e.data:n.innerHTML=`<div class="lp-ajax-message error" style="display:block">${e.message&&e.message}</div>`})).catch((e=>{console.log(e)}))})(),function(){const e=r(".order-recover"),t=e.find(".button-recover-order");t.on("click",(()=>{e.find(".learn-press-message").remove(),r(".profile-recover-order").find(".learn-press-message").remove(),r.post({url:"",data:e.serializeJSON(),beforeSend(){t.addClass("loading").attr("disabled","disabled")},success(o){if((o=LP.parseJSON(o)).message){const t=r('<div class="learn-press-message icon"><i class="fa"></i> '+o.message+"</div>");"error"==o.result&&t.addClass("error"),e.before(t)}o.redirect&&(window.location.href=o.redirect),t.removeClass("loading").removeAttr("disabled","")},error(){t.removeClass("loading").removeAttr("disabled","")}})}))}()})),document.getElementById("learnpress-avatar-upload")&&wp.element.render((0,e.createElement)((function(){const[t,o]=(0,e.useState)(),[r,n]=(0,e.useState)(0),[s,c]=(0,e.useState)(0),[l,p]=(0,e.useState)({x:0,y:0}),[d,h]=(0,e.useState)(0),[u,m]=(0,e.useState)(null),[v,g]=(0,e.useState)(0),[f,w]=(0,e.useState)(0),[y,S]=(0,e.useState)(!1),[C,b]=(0,e.useState)(!0),[_,E]=(0,e.useState)(""),[x,M]=(0,e.useState)({type:"",message:""}),z=(0,e.useRef)();(0,e.useEffect)((()=>{!async function(){b(!0);try{var e,t,r;const i=await a()({method:"GET",path:"lp/v1/profile/get-avatar"});n(null!=i&&null!==(e=i.data)&&void 0!==e&&e.width?parseInt(i.data.width):0),c(null!=i&&null!==(t=i.data)&&void 0!==t&&t.height?parseInt(i.data.height):0),o(null!=i&&null!==(r=i.data)&&void 0!==r&&r.url?i.data.url:"")}catch(e){M({type:"error",message:e.message})}b(!1)}()}),[]);const D=(0,e.useCallback)(((e,t)=>{m(t)}),[]),T=(0,e.useCallback)((async()=>{S({save:!0});try{const e=await async function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{horizontal:!1,vertical:!1};const n=await R(e),a=document.createElement("canvas"),i=a.getContext("2d");if(!i)return null;const s=A(o),{width:c,height:l}=L(n.width,n.height,o);a.width=c,a.height=l,i.translate(c/2,l/2),i.rotate(s),i.scale(r.horizontal?-1:1,r.vertical?-1:1),i.translate(-n.width/2,-n.height/2),i.drawImage(n,0,0);const p=i.getImageData(t.x,t.y,t.width,t.height);return a.width=t.width,a.height=t.height,i.putImageData(p,0,0),a.toDataURL("image/jpeg")}(t,u,d),o=await((e,t,o)=>new Promise(((r,n)=>{const a=document.createElement("canvas"),i=document.createElement("img");i.src=e,i.setAttribute("crossOrigin","anonymous"),i.onload=()=>{(i.naturalWidth>t||i.naturalHeight>o)&&(a.width=t,a.height=o,a.getContext("2d").drawImage(i,0,0,t,o),r(a.toDataURL("image/jpeg"))),r(e)},i.onerror=e=>n(e)})))(e,r,s),n=await a()({path:"lp/v1/profile/upload-avatar",method:"POST",data:{file:o||""}}),{data:i,status:c,message:l}=await n;"success"===c&&window.location.reload(),M({type:c,message:l})}catch(e){M({type:"error",message:e.message||""})}S({save:!1})}),[u,d]);return(0,e.createElement)("div",{className:"learnpress_avatar"},C?(0,e.createElement)("ul",{className:"lp-skeleton-animation"},(0,e.createElement)("li",{style:{width:200,height:200}}),(0,e.createElement)("li",{style:{width:200,height:20}}),(0,e.createElement)("li",{style:{width:200,height:20}})):(0,e.createElement)(e.Fragment,null,t&&!_&&(0,e.createElement)(e.Fragment,null,f&&v?(0,e.createElement)("div",{className:"learnpress_avatar__cropper"},(0,e.createElement)("div",{style:{position:"relative",width:v,height:f,zIndex:9999,maxWidth:"100%",maxHeight:"800px"}},(0,e.createElement)(P,{image:t,crop:l,zoom:"1",cropSize:{width:r,height:s},onCropChange:p,onCropComplete:D})),(0,e.createElement)("div",null,(0,e.createElement)("button",{className:"learnpress_avatar__button learnpress_avatar__button--save "+(null!=y&&y.save?"learnpress_avatar__button--loading":""),onClick:T},(0,i.__)("Save","learnpress")))):(0,e.createElement)("div",{className:"learnpress_avatar__cropper"},(0,e.createElement)("img",{src:t,alt:""}),(0,e.createElement)("div",null,(0,e.createElement)("button",{className:"learnpress_avatar__button learnpress_avatar__button--replace",onClick:()=>z.current&&z.current.click()},(0,i.__)("Replace","learnpress")),(0,e.createElement)("button",{className:"learnpress_avatar__button learnpress_avatar__button--remove "+(null!=y&&y.remove?"learnpress_avatar__button--loading":""),onClick:async function(){if(confirm((0,i.__)("Are you sure you want to remove your avatar?","learnpress"))){S({remove:!0});try{const e=await a()({path:"lp/v1/profile/remove-avatar",method:"POST"}),{data:t,status:r,message:n}=await e;M({type:r,message:n}),o("")}catch(e){M({type:"error",message:e.message||""})}S({remove:!1})}}},(0,i.__)("Remove","learnpress"))))),(0,e.createElement)("form",{style:{display:t?"none":""}},(0,e.createElement)("div",{className:"learnpress_avatar__form"},(0,e.createElement)("div",{className:"learnpress_avatar__form-group"},(0,e.createElement)("label",{htmlFor:"avatar-file"},(0,e.createElement)("div",{className:"learnpress_avatar__form__upload"},(0,e.createElement)("div",null,(0,e.createElement)("span",null,(0,e.createElement)("svg",{viewBox:"64 64 896 896",focusable:"false","data-icon":"plus",width:"1em",height:"1em",fill:"currentColor","aria-hidden":"true"},(0,e.createElement)("defs",null,(0,e.createElement)("style",null)),(0,e.createElement)("path",{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"}),(0,e.createElement)("path",{d:"M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z"}))),(0,e.createElement)("div",null,(0,i.__)("Upload","learnpress")))),(0,e.createElement)("input",{ref:z,type:"file",id:"avatar-file",accept:"image/*",onChange:e=>(async e=>{const t=await function(e){return new Promise((t=>{const o=new FileReader;o.addEventListener("load",(()=>t(o.result)),!1),o.readAsDataURL(e)}))}(e),n=new Image;n.src=await t,n.onload=await(function(){g(n.naturalWidth),w(n.naturalHeight);let a="";parseInt(e.size)>2097152?a=(0,i.__)("The file size is too large. You need to upload a file < 2MB.","learnpress"):(n.naturalWidth<r||n.naturalHeight<s)&&(a=(0,i.sprintf)((0,i.__)("The image size must be greater than or equal to %1$sx%2$spx","learnpress"),r,s)),a?E(a):(E(""),o(t))})})(e.target.files&&e.target.files.length>0?e.target.files[0]:"")}))))),_&&(0,e.createElement)("div",{className:"lp-ajax-message error",style:{display:"block"}},_),!_&&x&&x.type&&x.message&&(0,e.createElement)("div",{className:`lp-ajax-message ${x.type}`,style:{display:"block"}},x.message)))}),null),document.getElementById("learnpress-avatar-upload"))}()}();
assets/js/dist/frontend/question-types.min.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e={d:function(t,s){for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function s(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}e.r(t),e.d(t,{FillInBlanks:function(){return f},MultipleChoices:function(){return w},QuestionBase:function(){return u},SingleChoice:function(){return d},TrueOrFalse:function(){return m},default:function(){return g}});var n=window.wp.element,r=window.wp.compose,i=window.wp.data,o=window.wp.i18n;const{isArray:a,get:p,set:l}=lodash;class c extends n.Component{constructor(e){super(...arguments),s(this,"prepare",((e,t)=>{const{question:s}=e;return s&&s.id!==t.questionId?{options:t.self.parseOptions(s.options)}:null})),s(this,"setInputRef",((e,t)=>{this.inputs||(this.inputs={}),this.inputs[t]=e})),s(this,"maybeShowCorrectAnswer",(()=>{const{status:e,isCheckedAnswer:t,showCorrectReview:s,isReviewing:n}=this.props;return"completed"===e&&s||t&&!n})),s(this,"maybeDisabledOption",(e=>{const{answered:t,status:s,isCheckedAnswer:n}=this.props;return n||"started"!==s})),s(this,"setAnswerChecked",(()=>e=>{const{updateUserQuestionAnswers:t,question:s,status:n}=this.props;if("started"!==n)return(0,o.__)("LP Error: can not set answers","learnpress");const r=this.$wrap.find(".option-check"),i=[],a="multi_choice"!==s.type;r.each(((e,t)=>{if(t.checked&&(i.push(t.value),a))return!1})),t(s.id,a?i[0]:i)})),s(this,"maybeCheckedAnswer",(e=>{const{answered:t}=this.props;return a(t)?!!t.find((t=>t==e)):e==t})),s(this,"getOptionType",((e,t)=>{let s="radio";return"multi_choice"===e&&(s="checkbox"),s})),s(this,"isDefaultType",(()=>this.props.supportOptions)),s(this,"getWarningMessage",(()=>(0,n.createElement)(n.Fragment,null,(0,o.__)("Render function should be overwritten from base.","learnpress")))),s(this,"getOptionClass",(e=>{const{answered:t}=this.props;return["answer-option"]})),s(this,"parseOptions",(e=>(e&&(e=a(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=a(e)?e:JSON.parse(e)),e||[]))),s(this,"getOptions",(()=>this.state.options||[])),s(this,"isCorrect",(()=>{const{answered:e}=this.props;if(!e)return!1;let t,s,n;for(t=0,n=this.getOptions();t<n.length;t++)if(s=n[t],"yes"===s.isTrue&&e==s.value)return!0;return!1})),s(this,"isChecked",(()=>{const{question:e}=this.props;return(0,i.select)("learnpress/quiz").isCheckedAnswer(e.id)})),s(this,"getCorrectLabel",(()=>{const{status:e,answered:t,question:s}=this.props,r=(LP.config.isQuestionCorrect[s.type]||this.isCorrect).call(this);return this.maybeShowCorrectAnswer()&&(0,n.createElement)("div",{className:"question-response"+(r?" correct":" incorrect")},(0,n.createElement)("span",{className:"label"},r?(0,o.__)("Correct","learnpress"):(0,o.__)("Incorrect","learnpress")),(0,n.createElement)("span",{className:"point"},sprintf((0,o.__)("%d/%d point","learnpress"),r?s.point:0,s.point)))}));const{question:t}=e;this.state={optionClass:["answer-option"],questionId:0,options:t?this.parseOptions(t.options):[],self:this},e.$wrap&&(this.$wrap=e.$wrap)}static getDerivedStateFromProps(e,t){return t.self.prepare(e,t)}componentDidMount(){const e=this.prepare(this.props,this.state);e&&this.setState(e)}render(){const{question:e,status:t}=this.props;return(0,n.createElement)("div",{className:"question-answers"},this.isDefaultType()&&(0,n.createElement)("ul",{id:`answer-options-${e.id}`,className:"answer-options"},this.getOptions().map((s=>{const r=`learn-press-answer-option-${s.uid}`;return(0,n.createElement)("li",{className:this.getOptionClass(s).join(" "),key:`answer-option-${s.uid}`},(0,n.createElement)("input",{type:this.getOptionType(e.type,s),className:"option-check",name:"started"===t?`learn-press-question-${e.id}`:"",id:r,ref:e=>{this.setInputRef(e,s.value)},onChange:this.setAnswerChecked(),disabled:this.maybeDisabledOption(s),checked:this.maybeCheckedAnswer(s.value),value:"started"===t?s.value:""}),(0,n.createElement)("label",{htmlFor:r,className:"option-title",dangerouslySetInnerHTML:{__html:s.title||s.value}}))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}var u=c,d=class extends u{constructor(){super(...arguments),s(this,"getOptionClass",(e=>{const{answered:t}=this.props,s=[...this.state.optionClass];return this.maybeShowCorrectAnswer()&&("yes"===e.isTrue&&s.push("answer-correct"),t&&("yes"===e.isTrue?t===e.value&&s.push("answered-correct"):t===e.value&&s.push("answered-wrong"))),s}))}};const{isBoolean:h}=lodash;var w=class extends u{constructor(){super(...arguments),s(this,"isCorrect",(()=>{const{answered:e}=this.props;if(h(e)||!e)return!1;let t,s,n;for(t=0,n=this.getOptions();t<n.length;t++)if(s=n[t],"yes"===s.isTrue){if(-1===e.indexOf(s.value))return!1}else if(-1!==e.indexOf(s.value))return!1;return!0})),s(this,"getOptionClass",(e=>{const{answered:t}=this.props,s=[...this.state.optionClass];return this.maybeShowCorrectAnswer()&&("yes"===e.isTrue&&s.push("answer-correct"),t&&("yes"===e.isTrue?-1!==t.indexOf(e.value)&&s.push("answered-correct"):-1!==t.indexOf(e.value)&&s.push("answered-wrong"))),s}))}},m=class extends u{constructor(){super(...arguments),s(this,"getOptionClass",(e=>{const{answered:t}=this.props,s=[...this.state.optionClass];return this.maybeShowCorrectAnswer()&&("yes"===e.isTrue&&s.push("answer-correct"),t&&("yes"===e.isTrue?t===e.value&&s.push("answered-correct"):t===e.value&&s.push("answered-wrong"))),s}))}},f=class extends u{constructor(){super(...arguments),s(this,"updateFibAnswer",(()=>{const e=document.querySelectorAll(".lp-fib-input > input"),{answered:t}=this.props,s=t||{};[...e].map((e=>{void 0===t&&(e.value=""),e.addEventListener("input",(t=>{this.setAnswered(s,e.dataset.id,t.target.value)})),e.addEventListener("paste",(t=>{this.setAnswered(s,e.dataset.id,t.target.value)}))}))})),s(this,"setAnswered",((e,t,s)=>{const{updateUserQuestionAnswers:n,question:r,status:i}=this.props;if("started"!==i)return"LP Error: can not set answers";const o=Object.assign(e,{[t]:s});n(r.id,o)})),s(this,"getCorrectLabel",(()=>{const{question:e,mark:t}=this.props;let s=t||0;return t&&(Number.isInteger(t)||(s=t.toFixed(2))),this.maybeShowCorrectAnswer()&&(0,n.createElement)("div",{className:"question-response correct"},(0,n.createElement)("span",{className:"label"},(0,o.__)("Points","learnpress")),(0,n.createElement)("span",{className:"point"},`${s}/${e.point} ${(0,o.__)("point","learnpress")}`),(0,n.createElement)("span",{className:"lp-fib-note"},(0,n.createElement)("span",{style:{background:"#00adff"}}),(0,o.__)("Correct","learnpress")),(0,n.createElement)("span",{className:"lp-fib-note"},(0,n.createElement)("span",{style:{background:"#d85554"}}),(0,o.__)("Incorrect","learnpress")))})),s(this,"convertInputField",(e=>{const{answered:t,isReviewing:s,showCorrectReview:n,isCheckedAnswer:r}=this.props;let i=e.title;const o=null==e?void 0:e.answers;return e.ids.map(((e,a)=>{const p="{{FIB_"+e+"}}";let l="";const c=o?null==o?void 0:o[e]:void 0;var u,d;c||s?(l+=`<span class="lp-fib-answered ${(n||r)&&null!=c&&c.correct?null!=c&&c.isCorrect?"correct":"fail":""}">`,null!=c&&c.isCorrect||(l+=`<span class="lp-fib-answered__answer">${null!==(d=null==t?void 0:t[e])&&void 0!==d?d:""}</span>`),null!=c&&c.isCorrect||null==c||!c.correct||(l+=" → "),l+=`<span class="lp-fib-answered__fill">${null!==(u=null==c?void 0:c.correct)&&void 0!==u?u:""}</span>`,l+="</span>"):(l+='<div class="lp-fib-input" style="display: inline-block; width: auto;">',l+='<input type="text" data-id="'+e+'" value="" />',l+="</div>");i=i.replace(p,l)})),i}))}componentDidMount(){const{answered:e}=this.props;e&&[...document.querySelectorAll(".lp-fib-input > input")].map((t=>{e[t.dataset.id]&&(t.value=e[t.dataset.id])})),this.updateFibAnswer()}componentDidUpdate(e){e.answered||this.updateFibAnswer()}render(){return(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"lp-fib-content"},this.getOptions().map((e=>(0,n.createElement)("div",{key:`blank-${e.uid}`,dangerouslySetInnerHTML:{__html:this.convertInputField(e)||e.value}})))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}};class y extends n.Component{constructor(){super(...arguments),s(this,"getQuestion",(()=>{const{question:e}=this.props;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})[e.type]}))}render(){const{question:e,supportOptions:t}=this.props,s={...this.props};s.supportOptions=-1!==t.indexOf(e.type);const r=this.getQuestion()||function(){return(0,n.createElement)("div",{className:"question-types",dangerouslySetInnerHTML:{__html:(0,o.sprintf)((0,o.__)("Question <code>%s</code> invalid!","learnpress"),e.type)}})};return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(r,s))}}var g=(0,r.compose)((0,i.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getData:n,isCheckedAnswer:r}=e("learnpress/quiz");return{supportOptions:n("supportOptions"),isCheckedAnswer:r(s),keyPressed:n("keyPressed"),showCorrectReview:n("showCorrectReview"),isReviewing:"reviewing"===n("mode")}})),(0,i.withDispatch)((()=>({}))))(y);(window.LP=window.LP||{}).questionTypes=t}();
1
+ !function(){"use strict";var e={d:function(t,s){for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function s(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}e.r(t),e.d(t,{FillInBlanks:function(){return f},MultipleChoices:function(){return w},QuestionBase:function(){return u},SingleChoice:function(){return d},TrueOrFalse:function(){return m},default:function(){return g}});var n=window.wp.element,r=window.wp.compose,i=window.wp.data,o=window.wp.i18n;const{isArray:a,get:p,set:l}=lodash;class c extends n.Component{constructor(e){super(...arguments),s(this,"prepare",((e,t)=>{const{question:s}=e;return s&&s.id!==t.questionId?{options:t.self.parseOptions(s.options)}:null})),s(this,"setInputRef",((e,t)=>{this.inputs||(this.inputs={}),this.inputs[t]=e})),s(this,"maybeShowCorrectAnswer",(()=>{const{status:e,isCheckedAnswer:t,showCorrectReview:s,isReviewing:n}=this.props;return"completed"===e&&s||t&&!n})),s(this,"maybeDisabledOption",(e=>{const{answered:t,status:s,isCheckedAnswer:n}=this.props;return n||"started"!==s})),s(this,"setAnswerChecked",(()=>e=>{const{updateUserQuestionAnswers:t,question:s,status:n}=this.props;if("started"!==n)return(0,o.__)("LP Error: can not set answers","learnpress");const r=this.$wrap.find(".option-check"),i=[],a="multi_choice"!==s.type;r.each(((e,t)=>{if(t.checked&&(i.push(t.value),a))return!1})),t(s.id,a?i[0]:i)})),s(this,"maybeCheckedAnswer",(e=>{const{answered:t}=this.props;return a(t)?!!t.find((t=>t==e)):e==t})),s(this,"getOptionType",((e,t)=>{let s="radio";return"multi_choice"===e&&(s="checkbox"),s})),s(this,"isDefaultType",(()=>this.props.supportOptions)),s(this,"getWarningMessage",(()=>(0,n.createElement)(n.Fragment,null,(0,o.__)("The render function should be overwritten from the base.","learnpress")))),s(this,"getOptionClass",(e=>{const{answered:t}=this.props;return["answer-option"]})),s(this,"parseOptions",(e=>(e&&(e=a(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=a(e)?e:JSON.parse(e)),e||[]))),s(this,"getOptions",(()=>this.state.options||[])),s(this,"isCorrect",(()=>{const{answered:e}=this.props;if(!e)return!1;let t,s,n;for(t=0,n=this.getOptions();t<n.length;t++)if(s=n[t],"yes"===s.isTrue&&e==s.value)return!0;return!1})),s(this,"isChecked",(()=>{const{question:e}=this.props;return(0,i.select)("learnpress/quiz").isCheckedAnswer(e.id)})),s(this,"getCorrectLabel",(()=>{const{status:e,answered:t,question:s}=this.props,r=(LP.config.isQuestionCorrect[s.type]||this.isCorrect).call(this);return this.maybeShowCorrectAnswer()&&(0,n.createElement)("div",{className:"question-response"+(r?" correct":" incorrect")},(0,n.createElement)("span",{className:"label"},r?(0,o.__)("Correct","learnpress"):(0,o.__)("Incorrect","learnpress")),(0,n.createElement)("span",{className:"point"},sprintf((0,o.__)("%d/%d point","learnpress"),r?s.point:0,s.point)))}));const{question:t}=e;this.state={optionClass:["answer-option"],questionId:0,options:t?this.parseOptions(t.options):[],self:this},e.$wrap&&(this.$wrap=e.$wrap)}static getDerivedStateFromProps(e,t){return t.self.prepare(e,t)}componentDidMount(){const e=this.prepare(this.props,this.state);e&&this.setState(e)}render(){const{question:e,status:t}=this.props;return(0,n.createElement)("div",{className:"question-answers"},this.isDefaultType()&&(0,n.createElement)("ul",{id:`answer-options-${e.id}`,className:"answer-options"},this.getOptions().map((s=>{const r=`learn-press-answer-option-${s.uid}`;return(0,n.createElement)("li",{className:this.getOptionClass(s).join(" "),key:`answer-option-${s.uid}`},(0,n.createElement)("input",{type:this.getOptionType(e.type,s),className:"option-check",name:"started"===t?`learn-press-question-${e.id}`:"",id:r,ref:e=>{this.setInputRef(e,s.value)},onChange:this.setAnswerChecked(),disabled:this.maybeDisabledOption(s),checked:this.maybeCheckedAnswer(s.value),value:"started"===t?s.value:""}),(0,n.createElement)("label",{htmlFor:r,className:"option-title",dangerouslySetInnerHTML:{__html:s.title||s.value}}))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}var u=c,d=class extends u{constructor(){super(...arguments),s(this,"getOptionClass",(e=>{const{answered:t}=this.props,s=[...this.state.optionClass];return this.maybeShowCorrectAnswer()&&("yes"===e.isTrue&&s.push("answer-correct"),t&&("yes"===e.isTrue?t===e.value&&s.push("answered-correct"):t===e.value&&s.push("answered-wrong"))),s}))}};const{isBoolean:h}=lodash;var w=class extends u{constructor(){super(...arguments),s(this,"isCorrect",(()=>{const{answered:e}=this.props;if(h(e)||!e)return!1;let t,s,n;for(t=0,n=this.getOptions();t<n.length;t++)if(s=n[t],"yes"===s.isTrue){if(-1===e.indexOf(s.value))return!1}else if(-1!==e.indexOf(s.value))return!1;return!0})),s(this,"getOptionClass",(e=>{const{answered:t}=this.props,s=[...this.state.optionClass];return this.maybeShowCorrectAnswer()&&("yes"===e.isTrue&&s.push("answer-correct"),t&&("yes"===e.isTrue?-1!==t.indexOf(e.value)&&s.push("answered-correct"):-1!==t.indexOf(e.value)&&s.push("answered-wrong"))),s}))}},m=class extends u{constructor(){super(...arguments),s(this,"getOptionClass",(e=>{const{answered:t}=this.props,s=[...this.state.optionClass];return this.maybeShowCorrectAnswer()&&("yes"===e.isTrue&&s.push("answer-correct"),t&&("yes"===e.isTrue?t===e.value&&s.push("answered-correct"):t===e.value&&s.push("answered-wrong"))),s}))}},f=class extends u{constructor(){super(...arguments),s(this,"updateFibAnswer",(()=>{const e=document.querySelectorAll(".lp-fib-input > input"),{answered:t}=this.props,s=t||{};[...e].map((e=>{void 0===t&&(e.value=""),e.addEventListener("input",(t=>{this.setAnswered(s,e.dataset.id,t.target.value)})),e.addEventListener("paste",(t=>{this.setAnswered(s,e.dataset.id,t.target.value)}))}))})),s(this,"setAnswered",((e,t,s)=>{const{updateUserQuestionAnswers:n,question:r,status:i}=this.props;if("started"!==i)return"LP Error: can not set answers";const o=Object.assign(e,{[t]:s});n(r.id,o)})),s(this,"getCorrectLabel",(()=>{const{question:e,mark:t}=this.props;let s=t||0;return t&&(Number.isInteger(t)||(s=t.toFixed(2))),this.maybeShowCorrectAnswer()&&(0,n.createElement)("div",{className:"question-response correct"},(0,n.createElement)("span",{className:"label"},(0,o.__)("Points","learnpress")),(0,n.createElement)("span",{className:"point"},`${s}/${e.point} ${(0,o.__)("point","learnpress")}`),(0,n.createElement)("span",{className:"lp-fib-note"},(0,n.createElement)("span",{style:{background:"#00adff"}}),(0,o.__)("Correct","learnpress")),(0,n.createElement)("span",{className:"lp-fib-note"},(0,n.createElement)("span",{style:{background:"#d85554"}}),(0,o.__)("Incorrect","learnpress")))})),s(this,"convertInputField",(e=>{const{answered:t,isReviewing:s,showCorrectReview:n,isCheckedAnswer:r}=this.props;let i=e.title;const o=null==e?void 0:e.answers;return e.ids.map(((e,a)=>{const p="{{FIB_"+e+"}}";let l="";const c=o?null==o?void 0:o[e]:void 0;var u,d;c||s?(l+=`<span class="lp-fib-answered ${(n||r)&&null!=c&&c.correct?null!=c&&c.isCorrect?"correct":"fail":""}">`,null!=c&&c.isCorrect||(l+=`<span class="lp-fib-answered__answer">${null!==(d=null==t?void 0:t[e])&&void 0!==d?d:""}</span>`),null!=c&&c.isCorrect||null==c||!c.correct||(l+=" → "),l+=`<span class="lp-fib-answered__fill">${null!==(u=null==c?void 0:c.correct)&&void 0!==u?u:""}</span>`,l+="</span>"):(l+='<div class="lp-fib-input" style="display: inline-block; width: auto;">',l+='<input type="text" data-id="'+e+'" value="" />',l+="</div>");i=i.replace(p,l)})),i}))}componentDidMount(){const{answered:e}=this.props;e&&[...document.querySelectorAll(".lp-fib-input > input")].map((t=>{e[t.dataset.id]&&(t.value=e[t.dataset.id])})),this.updateFibAnswer()}componentDidUpdate(e){e.answered||this.updateFibAnswer()}render(){return(0,n.createElement)(n.Fragment,null,(0,n.createElement)("div",{className:"lp-fib-content"},this.getOptions().map((e=>(0,n.createElement)("div",{key:`blank-${e.uid}`,dangerouslySetInnerHTML:{__html:this.convertInputField(e)||e.value}})))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}};class y extends n.Component{constructor(){super(...arguments),s(this,"getQuestion",(()=>{const{question:e}=this.props;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})[e.type]}))}render(){const{question:e,supportOptions:t}=this.props,s={...this.props};s.supportOptions=-1!==t.indexOf(e.type);const r=this.getQuestion()||function(){return(0,n.createElement)("div",{className:"question-types",dangerouslySetInnerHTML:{__html:(0,o.sprintf)((0,o.__)("Question <code>%s</code> invalid!","learnpress"),e.type)}})};return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(r,s))}}var g=(0,r.compose)((0,i.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getData:n,isCheckedAnswer:r}=e("learnpress/quiz");return{supportOptions:n("supportOptions"),isCheckedAnswer:r(s),keyPressed:n("keyPressed"),showCorrectReview:n("showCorrectReview"),isReviewing:"reviewing"===n("mode")}})),(0,i.withDispatch)((()=>({}))))(y);(window.LP=window.LP||{}).questionTypes=t}();
assets/js/dist/frontend/quiz.js CHANGED
@@ -1907,12 +1907,18 @@ const Timer = () => {
1907
  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('learnpress/quiz');
1908
  const totalTime = getData('totalTime');
1909
  const durationTime = getData('duration');
1910
- const [seconds, setSeconds] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(totalTime);
1911
- let [timeSpend, setTimeSpend] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); //const limitTime = totalTime > 0;
 
 
 
1912
 
 
 
 
1913
  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1914
  const myInterval = setInterval(() => {
1915
- if (durationTime > 0) {
1916
  let remainSeconds = seconds;
1917
  remainSeconds -= 1;
1918
 
1907
  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('learnpress/quiz');
1908
  const totalTime = getData('totalTime');
1909
  const durationTime = getData('duration');
1910
+ /* const endTime = getData( 'endTime' );
1911
+ const d1 = new Date( endTime.replace( /-/g, '/' ) );
1912
+ const d2 = new Date();
1913
+ const tz = new Date().getTimezoneOffset();
1914
+ const t = parseInt( ( d1.getTime() / 1000 ) - ( ( d2.getTime() / 1000 ) + ( tz * 60 ) ) );*/
1915
 
1916
+ const [seconds, setSeconds] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(totalTime);
1917
+ let [timeSpend, setTimeSpend] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
1918
+ const limitTime = totalTime > 0;
1919
  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
1920
  const myInterval = setInterval(() => {
1921
+ if (limitTime) {
1922
  let remainSeconds = seconds;
1923
  remainSeconds -= 1;
1924
 
assets/js/dist/frontend/quiz.min.js CHANGED
@@ -1 +1 @@
1
- !function(){var e={605:function(){LP.Hook.addAction("lp-compatible-builder",(()=>{LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-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))),LP.Hook.addAction("lp-question-compatible-builder",(()=>(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)))},184:function(e,t){var s;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var i=typeof s;if("string"===i||"number"===i)e.push(s);else if(Array.isArray(s)){if(s.length){var o=r.apply(null,s);o&&e.push(o)}}else if("object"===i)if(s.toString===Object.prototype.toString)for(var a in s)n.call(s,a)&&s[a]&&e.push(a);else e.push(s.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(s=function(){return r}.apply(t,[]))||(e.exports=s)}()},965:function(e){"use strict";function t(e,s){var n;if(Array.isArray(s))for(n=0;n<s.length;n++)t(e,s[n]);else for(n in s)e[n]=(e[n]||[]).concat(s[n])}e.exports=function(e){var s,n={};return t(n,e),(s=function(e){return function(t){return function(s){var r,i,o=n[s.type],a=t(s);if(o)for(r=0;r<o.length;r++)(i=o[r](s,e))&&e.dispatch(i);return a}}}).effects=n,s}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,s),i.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){"use strict";s.r(n),s.d(n,{default:function(){return tt},init:function(){return st}});var e={};s.r(e),s.d(e,{__requestBeforeStartQuiz:function(){return ge},__requestCheckAnswerSuccess:function(){return ze},__requestShowHintSuccess:function(){return ye},__requestStartQuizSuccess:function(){return fe},__requestSubmitQuiz:function(){return qe},__requestSubmitQuizSuccess:function(){return we},checkAnswer:function(){return be},markQuestionRendered:function(){return ke},sendKey:function(){return Qe},setCurrentPage:function(){return he},setCurrentQuestion:function(){return me},setQuizData:function(){return pe},setQuizMode:function(){return Pe},showHint:function(){return Ee},startQuiz:function(){return _e},submitQuiz:function(){return ve},updateUserQuestionAnswers:function(){return Se}});var t={};s.r(t),s.d(t,{getCurrentQuestion:function(){return Fe},getData:function(){return xe},getDefaultRestArgs:function(){return De},getItemStatus:function(){return Ae},getProp:function(){return Te},getQuestion:function(){return Ue},getQuestionAnswered:function(){return Me},getQuestionMark:function(){return He},getQuestionOptions:function(){return Ce},getQuestions:function(){return Le},getQuestionsSelectedAnswers:function(){return Be},getQuizAnswered:function(){return Oe},getQuizAttempts:function(){return Re},getUserMark:function(){return Je},isCheckedAnswer:function(){return $e},isCorrect:function(){return je}});var r=window.wp.element;function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var o=window.wp.compose,a=window.wp.data,u=window.wp.i18n,l=e=>{let t;const s=86400;if(e>s)t=(e-e%s)/s,e%=s;else if(e==s)return"24:00";const 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(":")};const{Hook:c}=LP;var d=()=>{const e=e=>(0,a.select)("learnpress/quiz").getData(e),t=c.applyFilters("quiz-meta-fields",{duration:{title:(0,u.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:(0,u.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:(0,u.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("ul",{className:"quiz-intro"},Object.values(t).map(((e,t)=>{const s=e.name||t;return(0,r.createElement)("li",{key:`quiz-intro-field-${t}`,className:`quiz-intro-item quiz-intro-item--${s}`},(0,r.createElement)("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),(0,r.createElement)("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};class p extends r.Component{constructor(){super(...arguments),i(this,"startQuiz",(e=>{e&&e.preventDefault();const t=document.querySelector(".lp-button.start");t&&t.setAttribute("disabled","disabled"),t.classList.add("loading");const{startQuiz:s,status:n}=this.props;if("completed"===n){const{confirm:e,isOpen:s}=(0,a.select)("learnpress/modal");if("no"===e((0,u.__)("Are you sure you want to retake quiz?","learnpress"),this.startQuiz))return void(!s()&&t&&t.removeAttribute("disabled"))}s()})),i(this,"nav",(e=>t=>{let{questionNav:s,currentPage:n,numPages:r,setCurrentPage:i}=this.props;"prev"===e?n>1?n-=1:n="infinity"===s?r:1:n<r?n+=1:n="infinity"===s?1:r,i(n)})),i(this,"moveTo",(e=>t=>{t.preventDefault();const{numPages:s,setCurrentPage:n}=this.props;e<1||e>s||n(e)})),i(this,"isLast",(()=>{const{currentPage:e,numPages:t}=this.props;return e===t})),i(this,"isFirst",(()=>{const{currentPage:e}=this.props;return 1===e})),i(this,"submit",(()=>{const{submitQuiz:e}=this.props,{confirm:t}=(0,a.select)("learnpress/modal");"no"!==t((0,u.__)("Are you sure to submit quiz?","learnpress"),this.submit)&&e()})),i(this,"setQuizMode",(e=>()=>{const{setQuizMode:t}=this.props;t(e)})),i(this,"isReviewing",(()=>{const{isReviewing:e}=this.props;return e}))}pageNumbers(e){const{numPages:t,currentPage:s}=this.props;if(t<2)return"";(e={numPages:t,currentPage:s,midSize:1,endSize:1,prevNext:!0,...e||{}}).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);const n=[...Array(t).keys()];let i=!1;return(0,r.createElement)("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&(0,r.createElement)("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},(0,u.__)("Prev","learnpress")),n.map((t=>(t+=1)===e.currentPage?(i=!0,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers current"},t)):t<=e.endSize||e.currentPage&&t>=e.currentPage-e.midSize&&t<=e.currentPage+e.midSize||t>e.numPages-e.endSize?(i=!0,(0,r.createElement)("button",{key:`page-number-${t}`,className:"page-numbers",onClick:this.moveTo(t)},t)):i?(i=!1,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers dots"},"…")):"")),e.prevNext&&!this.isLast()&&(0,r.createElement)("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},(0,u.__)("Next","learnpress")))}render(){const{status:e,questionNav:t,isReviewing:s,showReview:n,numPages:i,question:o,questionsPerPage:a,canRetry:l,retakeNumber:c,requiredPassword:d,allowRetake:p}=this.props,m=["quiz-buttons"];("started"===e||s)&&m.push("align-center"),"questionNav"===t&&m.push("infinity"),this.isFirst()&&m.push("is-first"),this.isLast()&&m.push("is-last");const h=document.querySelector("#popup-sidebar"),g=document.querySelector("#learn-press-quiz-app");let f="";f="started"===e||s?{marginLeft:h&&h.offsetWidth/2,width:g&&g.offsetWidth}:null;let _=" fixed";return"no"==lpQuizSettings.navigationPosition&&(_=" nav-center"),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:m.join(" ")},(0,r.createElement)("div",{className:"button-left"+("started"===e||s?_:""),style:f},("completed"===e&&l||-1!==["","viewed"].indexOf(e))&&!s&&!d&&(0,r.createElement)("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===e?`${(0,u.__)("Retake","learnpress")} ${p?"":" "+(c?` (${c})`:"")} `:" "+(0,u.__)("Start","learnpress")),("started"===e||s)&&i>1&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"questions-pagination"},this.pageNumbers()))),(0,r.createElement)("div",{className:"button-right"},"started"===e&&(0,r.createElement)(r.Fragment,null,("infinity"===t||this.isLast())&&!s&&(0,r.createElement)("button",{className:"lp-button submit-quiz",onClick:this.submit},(0,u.__)("Finish Quiz","learnpress"))),s&&n&&(0,r.createElement)("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},(0,u.__)("Result","learnpress")),"completed"===e&&n&&!s&&(0,r.createElement)("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},(0,u.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&(0,r.createElement)("div",{className:"learn-press-message error"},this.props.message))}}const m=(0,o.compose)((0,a.withSelect)((e=>{const{getData:t}=e("learnpress/quiz");return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((e=>{const{showCheck:t,checkedQuestions:s,hintedQuestions:n,question:i,status:o,type:a,Button:u}=e;if("started"!==o)return!1;const l=(0,r.createElement)(u,{question:i});switch(a){case"hint":return n?!!i.hasHint&&-1===n.indexOf(i.id)&&l:l;case"check":return!!t&&(s?-1===s.indexOf(i.id)&&l:l)}}));var h=(0,o.compose)([(0,a.withSelect)((e=>{const{getData:t,getCurrentQuestion:s}=e("learnpress/quiz"),n={id:t("id"),status:t("status"),questionIds:t("questionIds"),questionNav:t("questionNav"),isReviewing:t("reviewQuestions")&&"reviewing"===t("mode"),showReview:t("reviewQuestions"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),numPages:t("numPages"),pages:t("pages"),currentPage:t("currentPage"),questionsPerPage:t("questionsPerPage"),pageNumbers:t("pageNumbers"),keyPressed:t("keyPressed"),canRetry:t("retakeCount")>0&&t("retaken")<t("retakeCount"),retakeNumber:t("retakeCount")>0&&t("retaken")<t("retakeCount")?t("retakeCount")-t("retaken"):null,message:t("messageResponse")||!1,success:void 0===t("successResponse")||t("successResponse"),requiredPassword:t("requiredPassword"),allowRetake:t("allowRetake")};if(1===n.questionsPerPage&&(n.question=s("object")),1===lpQuizSettings.checkNorequizenroll){const e=window.localStorage.getItem("quiz_off_retaken_"+lpQuizSettings.id);t("retakeCount")>e?(n.retakeNumber=t("retakeCount")-e,n.canRetry=!0):n.canRetry=!1}return n.allowRetake&&(n.canRetry=!0),n})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{startQuiz:n,setCurrentQuestion:r,submitQuiz:i,setQuizMode:o,showHint:a,checkAnswer:u,setCurrentPage:l}=e("learnpress/quiz");return{startQuiz:n,setCurrentQuestion:r,setQuizMode:o,setCurrentPage:l,submitQuiz(e){i(e)},showHint(e){a(e)},checkAnswer(e){u(e)}}}))])(p);function g(){return g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},g.apply(this,arguments)}class f extends r.Component{constructor(){super(...arguments),i(this,"showHint",(()=>{const{showHint:e,question:t}=this.props;e(t.id,!t.showHint)}))}render(){const{question:e}=this.props;return e.hint?(0,r.createElement)("button",{className:"btn-show-hint",onClick:this.showHint},(0,r.createElement)("span",null,(0,u.__)("Hint","learnpress"))):""}}var _=(0,o.compose)((0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{showHint:n}=e("learnpress/quiz");return{showHint(e,t){n(e,t)}}})))(f),q=s(184),w=s.n(q);class v extends r.Component{constructor(){super(...arguments),i(this,"checkAnswer",(()=>{const{checkAnswer:e,question:t,answered:s}=this.props;s&&(e(t.id),this.setState({loading:!0}))})),this.state={loading:!1}}render(){const{answered:e}=this.props;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("button",{className:w()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},(0,r.createElement)("span",{className:"instant-check__icon"}),(0,u.__)("Check answer","learnpress"),!e&&(0,r.createElement)("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:(0,u.__)("You need to answer the question before check answer.","learnpress")}})))}}var S=(0,o.compose)((0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getQuestionAnswered:n}=e("learnpress/quiz");return{answered:n(s)}})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{checkAnswer:n}=e("learnpress/quiz");return{checkAnswer(e){n(e)}}})))(v),y=function(e){const{question:t}=e,s={"instant-check":()=>(0,r.createElement)(m,{type:"check",Button:S,question:t}),hint:()=>(0,r.createElement)(m,{type:"hint",Button:_,question:t})};return(0,r.createElement)(r.Fragment,null,LP.config.questionFooterButtons().map((e=>(0,r.createElement)(r.Fragment,{key:`button-${e}`},s[e]&&s[e]()))))};const E=window.jQuery,{uniqueId:z,isArray:b,isNumber:k,bind:P}=lodash;class Q extends r.Component{constructor(){super(...arguments),i(this,"setRef",(e=>{this.$wrap=E(e)})),i(this,"parseOptions",(e=>(e&&(e=b(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=b(e)?e:JSON.parse(e)),e||[]))),i(this,"getWrapperClass",(()=>{const{question:e,answered:t}=this.props,s=["question","question-"+e.type],n=this.parseOptions(e.options);return n.length&&void 0!==n[0].isTrue&&s.push("question-answered"),s})),i(this,"getEditLink",(()=>{const{question:e,editPermalink:t}=this.props;return t?t.replace(/post=(.*[0-9])/,`post=${e.id}`):""})),i(this,"editPermalink",(e=>(0,u.sprintf)('<a href="%s">%s</a>',e,(0,u.__)("Edit","learnpress")))),this.state={time:null,showHint:!1},this.$wrap=null}componentDidMount(e){const{question:t,isCurrent:s,markQuestionRendered:n}=this.props;return s&&n(t.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]),e}render(){const{question:e,isShow:t,isShowIndex:s,isShowHint:n,status:i}=this.props,o=LP.questionTypes.default,a=this.getEditLink();a&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",a);const l={index:()=>s?(0,r.createElement)("span",{className:"question-index"},s,"."):"",title:()=>(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:e.title}}),hint:()=>(0,r.createElement)(_,{question:e}),"edit-permalink":()=>a&&(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:this.editPermalink(a)},className:"edit-link"})},c={title:()=>(0,r.createElement)("h4",{className:"question-title"},LP.config.questionTitleParts().map((e=>(0,r.createElement)(r.Fragment,{key:`title-part-${e}`},l[e]&&l[e]())))),content:()=>(0,r.createElement)("div",{className:"question-content",dangerouslySetInnerHTML:{__html:e.content}}),"answer-options":()=>this.$wrap&&(0,r.createElement)(o,g({},this.props,{$wrap:this.$wrap})),explanation:()=>e.explanation&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-explanation-content"},(0,r.createElement)("strong",{className:"explanation-title"},(0,u.__)("Explanation","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.explanation}}))),hint:()=>e.hint&&!e.explanation&&e.showHint&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-hint-content"},(0,r.createElement)("strong",{className:"hint-title"},(0,u.__)("Hint","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.hint}}))),buttons:()=>"started"===i&&(0,r.createElement)(y,{question:e})},d=LP.config.questionBlocks();return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:this.getWrapperClass().join(" "),style:{display:t?"":"none"},"data-id":e.id,ref:this.setRef},d.map((e=>(0,r.createElement)(r.Fragment,{key:`block-${e}`},c[e]?c[e]():"")))))}}var N=(0,o.compose)([(0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getData:n,getQuestionAnswered:r,getQuestionMark:i}=e("learnpress/quiz");return{status:n("status"),questions:n("question"),answered:r(s),questionsRendered:n("questionsRendered"),editPermalink:n("editPermalink"),numPages:n("numPages"),mark:i(s)||""}})),(0,a.withDispatch)((e=>{const{updateUserQuestionAnswers:t,markQuestionRendered:s}=e("learnpress/quiz");return{markQuestionRendered:s,updateUserQuestionAnswers:t}}))])(Q);class I extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{e.preventDefault();const{startQuiz:t}=this.props;t()})),i(this,"isInVisibleRange",((e,t)=>{const{currentPage:s,questionsPerPage:n}=this.props;return s===Math.ceil(t/n)})),i(this,"nav",(e=>{const{sendKey:t}=this.props;switch(e.keyCode){case 37:return t("left");case 38:case 40:return;case 39:return t("right");default:e.keyCode>=49&&e.keyCode<=57&&t(e.keyCode-48)}})),this.needToTop=!1,this.state={isReviewing:null,currentPage:0,self:this}}static getDerivedStateFromProps(e,t){const s=["isReviewing","currentPage"],n={};for(let r=0;r<s.length;r++)e[s[r]]!==t[s[r]]&&(n[s[r]]=e[s[r]]);return Object.values(n).length?(t.self.needToTop=!0,n):null}componentDidUpdate(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}render(){const{status:e,currentQuestion:t,questions:s,questionsRendered:n,isReviewing:i,questionsPerPage:o}=this.props;let a=!0;return"completed"!==e||i||(a=!1),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{tabIndex:100,onKeyUp:this.nav},(0,r.createElement)("div",{className:"quiz-questions",style:{display:a?"":"none"}},s.map(((e,s)=>{const i=!o&&t===e.id,a=n&&-1!==n.indexOf(e.id),u=this.isInVisibleRange(e.id,s+1);return a||!a||u?(0,r.createElement)(N,{key:`loop-question-${e.id}`,isCurrent:i,isShow:u,isShowIndex:!!o&&s+1,questionsPerPage:o,question:e}):""})))))}}var C=(0,o.compose)((0,a.withSelect)(((e,t,s)=>{const{getData:n,getQuestions:r}=e("learnpress/quiz");return{status:n("status"),currentQuestion:n("currentQuestion"),questions:r(),questionsRendered:n("questionsRendered"),isReviewing:"reviewing"===n("mode"),numPages:n("numPages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{startQuiz:t,sendKey:s}=e("learnpress/quiz");return{startQuiz:t,sendKey:s}})))(I),A=()=>{const e=(0,a.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"quiz-attempts"},(0,r.createElement)("h4",{className:"attempts-heading"},(0,u.__)("Last Attempted","learnpress")),t&&(0,r.createElement)("table",null,(0,r.createElement)("thead",null,(0,r.createElement)("tr",null,(0,r.createElement)("th",{className:"quiz-attempts__questions"},(0,u.__)("Questions","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__spend"},(0,u.__)("Time spent","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__marks"},(0,u.__)("Marks","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__grade"},(0,u.__)("Passing grade","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__result"},(0,u.__)("Result","learnpress")))),(0,r.createElement)("tbody",null,e.map(((e,t)=>(0,r.createElement)("tr",{key:`attempt-${t}`},(0,r.createElement)("td",{className:"quiz-attempts__questions"},`${e.questionCorrect} / ${e.questionCount}`),(0,r.createElement)("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),(0,r.createElement)("td",{className:"quiz-attempts__marks"},`${e.userMark} / ${e.mark}`),(0,r.createElement)("td",{className:"quiz-attempts__grade"},e.passingGrade||"-"),(0,r.createElement)("td",{className:"quiz-attempts__result"},`${parseFloat(e.result).toFixed(2)}%`," ",(0,r.createElement)("span",null,e.graduationText)))))))))},T=()=>{const{getData:e}=(0,a.select)("learnpress/quiz"),{submitQuiz:t}=(0,a.dispatch)("learnpress/quiz"),s=e("totalTime"),n=e("duration"),[i,o]=(0,r.useState)(s);let[u,l]=(0,r.useState)(0);return(0,r.useEffect)((()=>{const e=setInterval((()=>{if(n>0){let s=i;s-=1,s>0?(o(s),u++,l(n-s)):(clearInterval(e),t())}else u++,l(u),o(u)}),1e3);return()=>clearInterval(e)}),[i,u]),(0,r.createElement)("div",{className:"countdown"},(0,r.createElement)("i",{className:"fas fa-stopwatch"}),(0,r.createElement)("span",null,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";const t=[];let n;return s<3600?(t.push((i-i%60)/60),t.push(i%60)):s&&(t.push((i-i%3600)/3600),n=i%3600,t.push((n-n%60)/60),t.push(n%60)),t.map((e=>e<10?`0${e}`:e)).join(e)}()),(0,r.createElement)("input",{type:"hidden",name:"lp-quiz-time-spend",value:u}))},R=window.wp.url;const O=jQuery;let L=null;const x={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=O(".lp-overlay"),!!this.elLPOverlay.length&&(L=this.elLPOverlay,this.elMainContent=L.find(".main-content"),this.elTitle=L.find(".modal-title"),this.elBtnYes=L.find(".btn-yes"),this.elBtnNo=L.find(".btn-no"),this.elFooter=L.find(".lp-modal-footer"),O(document).on("click",".close, .btn-no",(function(){L.hide()})),O(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof x.callBackYes&&x.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var D=x,M={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){D.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",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})))))}};const{debounce:H}=lodash;var F=()=>{const[e,t]=(0,r.useState)(0),[s,n]=(0,r.useState)(!1),i=(0,a.useSelect)((e=>e("learnpress/quiz").getData("id")),[]),o=(0,a.useSelect)((e=>e("learnpress/quiz").getData("results")),[]),l=(0,a.useSelect)((e=>e("learnpress/quiz").getData("passingGrade")),[]),c=(0,a.useSelect)((e=>e("learnpress/quiz").getData("submitting")),[]);(0,r.useEffect)((()=>{p();let e="";if(e=o.graduation?o.graduation:o.result>=f?"passed":"failed",e){const t=document.querySelector(`.course-curriculum .course-item.course-item-${i}`);t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}const t=[...document.querySelectorAll("#popup-header .items-progress")][0],s=document.querySelector(".curriculum-sections");if(t&&s){const e=t.dataset.totalItems,s=t.querySelector(".items-completed"),n=t.querySelector(".learn-press-progress__active");if(s){const t=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");s.textContent=parseInt(t.length);const r=100-100*parseInt(t.length)/parseInt(e);n.style.left="-"+r+"%"}}}),[o]),(0,r.useEffect)((()=>{void 0!==c&&d()}),[c]);const d=()=>{const e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&(async e=>{const t=await wp.apiFetch({path:(0,R.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"}),{data:s}=t;e.innerHTML+=s,M.init()})(e[0])},p=()=>{t(0),n(!1),jQuery.easing._customEasing=function(e,t,s,n,r){return n*Math.sqrt(1-(t=t/r-1)*t)+s},H((()=>{const e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:o.result},{duration:1500,step:(e,s)=>{t(e)},done:()=>{n(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),H((()=>{jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),o.result>0?1e3:10)()};let m=e;Number.isInteger(e)||(m=parseFloat(e).toFixed(2));const h=190*Math.PI,g={strokeDasharray:`${h} ${h}`,strokeDashoffset:h-m/100*h},f=parseFloat(o.passingGrade||l);let _="";_=o.graduation?o.graduation:m>=f?"passed":"failed";let q="";q=o.graduationText?o.graduationText:"passed"===_?(0,u.__)("Passed","learnpress"):(0,u.__)("Failed","learnpress");const w=["quiz-result",_];return(0,r.createElement)("div",{className:w.join(" ")},(0,r.createElement)("h3",{className:"result-heading"},(0,u.__)("Your Result","learnpress")),(0,r.createElement)("div",{id:"quizResultGrade",className:"result-grade"},(0,r.createElement)("svg",{className:"circle-progress-bar",width:200,height:200},(0,r.createElement)("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),(0,r.createElement)("span",{className:"result-achieved"},`${m}%`),(0,r.createElement)("span",{className:"result-require"},f+"%"||0)),s&&(0,r.createElement)("p",{className:"result-message"},q),(0,r.createElement)("ul",{className:"result-statistic"},(0,r.createElement)("li",{className:"result-statistic-field result-time-spend"},(0,r.createElement)("span",null,(0,u.__)("Time spent","learnpress")),(0,r.createElement)("p",null,o.timeSpend)),(0,r.createElement)("li",{className:"result-statistic-field result-point"},(0,r.createElement)("span",null,(0,u.__)("Points","learnpress")),(0,r.createElement)("p",null,o.userMark," / ",o.mark)),(0,r.createElement)("li",{className:"result-statistic-field result-questions"},(0,r.createElement)("span",null,(0,u.__)("Questions","learnpress")),(0,r.createElement)("p",null,o.questionCount)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-correct"},(0,r.createElement)("span",null,(0,u.__)("Correct","learnpress")),(0,r.createElement)("p",null,o.questionCorrect)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-wrong"},(0,r.createElement)("span",null,(0,u.__)("Wrong","learnpress")),(0,r.createElement)("p",null,o.questionWrong)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-skipped"},(0,r.createElement)("span",null,(0,u.__)("Skipped","learnpress")),(0,r.createElement)("p",null,o.questionEmpty))))};const U=jQuery,{debounce:$}=lodash;var j=()=>{const{submitQuiz:e}=(0,a.dispatch)("learnpress/quiz");(0,r.useEffect)((()=>{const e=U("#popup-content");if(!e.length)return;const t=e.find(".content-item-scrollable:eq(1)"),s=e.find(".content-item-wrap"),n=e.find(".quiz-status"),r=n.offset().top-92;let i=!1,o="-"+s.css("margin-left");U(window).on("resize.refresh-quiz-stauts-bar",$((function(){o="-"+s.css("margin-left"),n.css({"margin-left":o,"margin-right":o})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(()=>{if(t.scrollTop()>=r){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}),[]);const t=()=>{const{confirm:s}=(0,a.select)("learnpress/modal");"no"!==s((0,u.__)("Are you sure to submit quiz?","learnpress"),t)&&e()},{getData:s,getUserMark:n}=(0,a.select)("learnpress/quiz"),i=s("currentPage"),o=s("questionsPerPage"),l=s("questionIds").length,c=s("submitting"),d=(s("duration"),n()),p=["quiz-status"],m=(i-1)*o+1;let h=m+o-1,g="";return h=Math.min(h,l),c&&p.push("submitting"),g=h<l?o>1?(0,u.sprintf)((0,u.__)("Question <span>%d to %d of %d</span>","learnpress"),m,h,l):(0,u.sprintf)((0,u.__)("Question <span>%d of %d</span>","learnpress"),m,l):(0,u.sprintf)((0,u.__)("Question <span>%d to %d</span>","learnpress"),m,h),(0,r.createElement)("div",{className:p.join(" ")},(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:g}}),(0,r.createElement)("div",{className:"current-point"},(0,u.sprintf)((0,u.__)("Earned Point: %s","learnpress"),d)),(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"submit-quiz"},(0,r.createElement)("button",{className:"lp-button",id:"button-submit-quiz",onClick:t},c?(0,u.__)("Submitting...","learnpress"):(0,u.__)("Finish Quiz","learnpress"))),(0,r.createElement)(T,null))))};const{omit:B,flow:J,isArray:G,chunk:K}=lodash,{camelCaseDashObjectKeys:W}=LP,{get:Z,set:Y}=LP.localStorage,V={},X=(e,t)=>{const{answered:s,id:n}=e,r={...s[t.questionId]||{},answered:t.answers,temp:!0};return n&&localStorage.setItem(`LP_Quiz_${n}_Answered`,JSON.stringify({...e.answered,[t.questionId]:r})),{...e,answered:{...e.answered,[t.questionId]:r}}},ee=(e,t)=>{const{questionsRendered:s}=e;return G(s)?(s.push(t.questionId),{...e,questionsRendered:[...s]}):{...e,questionsRendered:[t.questionId]}},te=(e,t)=>(t.currentPage&&Y(`Q${e.id}.currentPage`,t.currentPage),{...e,...t}),se=(e,t)=>{const s=e.questions.map((e=>e.id==t.questionId?{...e,showHint:t.showHint}:e));return{...e,questions:[...s]}},ne=(e,t)=>{const s=e.questions.map((e=>{if(e.id!==t.questionId)return e;const s={explanation:t.explanation};return t.options&&(s.options=t.options),{...e,...s}})),n={...e.answered,[t.questionId]:t.result};let r=localStorage.getItem(`LP_Quiz_${e.id}_Answered`);return r&&(r={...JSON.parse(r),...n},localStorage.setItem(`LP_Quiz_${e.id}_Answered`,JSON.stringify(r))),{...e,questions:[...s],answered:n,checkedQuestions:[...e.checkedQuestions,t.questionId]}},re=(e,t)=>{localStorage.removeItem(`LP_Quiz_${e.id}_Answered`);const s=e.questions.map((s=>{const n={};return e.reviewQuestions&&(t.results.questions[s.id].explanation&&(n.explanation=t.results.questions[s.id].explanation),t.results.questions[s.id].options&&(n.options=t.results.questions[s.id].options)),{...s,...n}}));return te(e,{submitting:!1,currentPage:1,...t.results,questions:[...s]})},ie=(e,t)=>{const s=void 0!==t.results.success&&t.results.success,n=t.results.message||!1;return te(e,{checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1,...t.results.results,successResponse:s,messageResponse:n})},oe=J(a.combineReducers,(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)))({a(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1}},b(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2}}});var ae=(0,a.combineReducers)({blocks:oe,userQuiz:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);const s=K(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=s.length,t.data.pages=s,{...e,...t.data,currentPage:Z(`Q${t.data.id}.currentPage`)||t.data.currentPage};case"SUBMIT_QUIZ":return{...e,submitting:!0};case"START_QUIZ":case"START_QUIZ_SUCCESS":return ie(e,t);case"SET_CURRENT_QUESTION":return Y(`Q${e.id}.currentQuestion`,t.questionId),{...e,currentQuestion:t.questionId};case"SET_CURRENT_PAGE":return Y(`Q${e.id}.currentPage`,t.currentPage),{...e,currentPage:t.currentPage};case"SUBMIT_QUIZ_SUCCESS":return re(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?X(e,t):e;case"MARK_QUESTION_RENDERED":return ee(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?te(e,{mode:t.mode}):{...e,mode:t.mode};case"SET_QUESTION_HINT":return se(e,t);case"CHECK_ANSWER":return ne(e,t);case"SEND_KEY":return{...e,keyPressed:t.keyPressed}}return e}}),ue=window.LP.dataControls;function le(){const e=[].slice.call(arguments,2),t=(0,a.dispatch)(arguments[0]),s=arguments[1];t[s](...e)}const{camelCaseDashObjectKeys:ce,Hook:de}=LP;function pe(e,t){return{type:"SET_QUIZ_DATA",data:ce(t="string"==typeof e?{[e]:t}:e)}}function me(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function he(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function ge(e,t,s){return{type:"BEFORE_START_QUIZ"}}function fe(e,t,s,n){return de.doAction("quiz-started",e,t,s,n),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:s,userId:n,results:e}}const _e=function*(){const{itemId:e,courseId:t}=(0,a.select)("learnpress/quiz").getDefaultRestArgs();if(!0!==de.applyFilters("before-start-quiz",!0,e,t))return;let s=yield(0,ue.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:e,course_id:t}});const n=document.querySelector(".lp-button.start");if("error"!==s.status){if(s=de.applyFilters("request-start-quiz-response",s,e,t),1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id;window.localStorage.removeItem(e);const t={endTime:Date.now()+1e3*s.results.duration,status:s.results.status};window.localStorage.setItem(e,JSON.stringify(t));const n="quiz_off_retaken_"+lpQuizSettings.id;let r=window.localStorage.getItem(n);null===r?r=0:r++,window.localStorage.setItem(n,r)}yield le("learnpress/quiz","__requestStartQuizSuccess",ce(s),e,t)}else{const e=document.querySelector(".quiz-buttons"),t=`<div class="learn-press-message error">${s.message}</div>`;e.insertAdjacentHTML("afterend",t),n.classList.remove("loading")}};function qe(){return{type:"SUBMIT_QUIZ"}}function we(e,t,s){return de.doAction("quiz-submitted",e,t,s),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function*ve(){const{getDefaultRestArgs:e,getQuestionsSelectedAnswers:t}=(0,a.select)("learnpress/quiz"),{itemId:s,courseId:n}=e();if(!0!==de.applyFilters("before-submit-quiz",!0))return;const r=t();if(1===lpQuizSettings.checkNorequizenroll){const e=`LP_Quiz_${s}_Answered`,t=localStorage.getItem(e);if(null!==t){const e=JSON.parse(t);for(const[t,s]of Object.entries(e))r[t]=s.answered}}let i=0;const o=document.querySelector("input[name=lp-quiz-time-spend]");o&&(i=o.value);let u=yield(0,ue.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:s,course_id:n,answered:r,time_spend:i}});if(u=de.applyFilters("request-submit-quiz-response",u,s,n),"success"===u.status){if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,t=window.localStorage.getItem(e);if(null!==t){const s=JSON.parse(t);s.status=u.results.status,s.results=u.results.results,window.localStorage.setItem(e,JSON.stringify(s)),window.localStorage.removeItem("LP_Quiz_"+lpQuizSettings.id+"_Answered")}}yield le("learnpress/quiz","__requestSubmitQuizSuccess",ce(u.results),s,n)}}function Se(e,t,s){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function ye(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function*Ee(e,t){yield le("learnpress/quiz","__requestShowHintSuccess",e,t)}function ze(e,t){return{type:"CHECK_ANSWER",questionId:e,...t}}function*be(e){const{getDefaultRestArgs:t,getQuestionAnswered:s}=(0,a.select)("learnpress/quiz"),{itemId:n,courseId:r}=t(),i=yield(0,ue.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:n,course_id:r,question_id:e,answered:s(e)||""}});if("success"===i.status){if(1===lpQuizSettings.checkNorequizenroll){const t="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(t);if(null!==s){const n=JSON.parse(s),r=i.options;void 0===n.checked_questions?(n.checked_questions=[],n.checked_questions.push(e)):-1===n.checked_questions.indexOf(e)&&n.checked_questions.push(e),void 0===n.question_options?(n.question_options={},n.question_options[e]=r):void 0===n.question_options[e]&&(n.question_options[e]=r),window.localStorage.setItem(t,JSON.stringify(n))}}yield le("learnpress/quiz","__requestCheckAnswerSuccess",e,ce(i))}}function ke(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Pe(e){return{type:"SET_QUIZ_MODE",mode:e}}function Qe(e){return setTimeout((()=>{le("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}const{get:Ne,isArray:Ie}=lodash,Ce=function(e,t){console.time("parseOptions");let s=Ue(e,t).options;return s=Ie(s)?s:JSON.parse(CryptoJS.AES.decrypt(s.data,s.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),s=Ie(s)?s:JSON.parse(s),console.timeEnd("parseOptions"),s};function Ae(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.status"):""}function Te(e,t,s){return e[t]||s}function Re(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.attempts"):[]}function Oe(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.answered",{}):{}}function Le(e){const{userQuiz:t}=e,s=Ne(t,"questions");return s?Object.values(s):[]}function xe(e,t){const{userQuiz:s}=e;return t?Ne(s,t):s}function De(e){const{userQuiz:t}=e;return{itemId:t.id,courseId:t.courseId}}function Me(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.answered`)||void 0}function He(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.mark`)||void 0}function Fe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=Ne(e,"userQuiz.questionsPerPage")||1;if(s>1)return!1;const n=Ne(e,"userQuiz.currentPage")||1;return Ne(e,"object"===t?`userQuiz.questions[${n-1}]`:`userQuiz.questionIds[${n-1}]`)}const Ue=function(e,t){const{userQuiz:s}=e;return(0,a.select)("learnpress/quiz").getQuestions().find((e=>e.id==t))};function $e(e,t){return-1!==(Ne(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function je(e,t){}const Be=function(e,t){const s=Ne(e,"userQuiz.answered"),n={};for(const e in s)if(s.hasOwnProperty(e)&&(s[e].temp||s[e].blanks)){if(t&&e===t)return s[e].answered;n[e]=s[e].answered}return n};function Je(e){const t=e.userQuiz||{},{answered:s,negativeMarking:n,questions:r,checkedQuestions:i}=t;let o=0;for(let e in s){if(!s.hasOwnProperty(e))continue;e=parseInt(e);const t=s[e],a=t.questionMark?t.questionMark:function(){const t=r.find((t=>t.id===e));return t?t.point:0}();i.indexOf(e),t.temp||(n?t.answered&&(o=t.correct?o+t.mark:o-a):t.answered&&t.correct&&(o+=t.mark))}return o>0?o:0}var Ge=s(965),Ke=s.n(Ge);const We={ENROLL_COURSE_X:(e,t)=>{}};const{controls:Ze}=LP.dataControls;!function(e){let t=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:e.getState,dispatch:function(){return t(...arguments)}};t=Ke()(We)(s)(e.dispatch),e.dispatch=t}((0,a.registerStore)("learnpress/quiz",{reducer:ae,selectors:t,actions:e,controls:{...Ze}}));const{chunk:Ye}=lodash;class Ve extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{this.props.startQuiz()})),this.state={currentPage:1,numPages:0,pages:[]}}componentDidMount(){const{settings:e,setQuizData:t}=this.props,{question_ids:s,questions_per_page:n}=e,r=Ye(s,n);e.currentPage=1,e.numPages=r.length,e.pages=r;const i=!!e.id&&localStorage.getItem(`LP_Quiz_${e.id}_Answered`);i&&(e.answered=JSON.parse(i)),t(e)}componentDidUpdate(e,t,s){const{status:n}=e,r=document.querySelector(".quiz-content");void 0!==n&&r&&(r.style.display="none")}render(){const{status:e,isReviewing:t}=this.props,s=-1!==["","completed","viewed"].indexOf(e)||!e,n=-1!==["","viewed",void 0].indexOf(e)||!e;return void 0!==e&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",null,!t&&"completed"===e&&(0,r.createElement)(F,null),!t&&n&&(0,r.createElement)(d,null),"started"===e&&(0,r.createElement)(j,null),(-1!==["completed","started"].indexOf(e)||t)&&(0,r.createElement)(C,null),(0,r.createElement)(h,null),s&&!t&&(0,r.createElement)(A,null)))}}var Xe=(0,o.compose)([(0,a.withSelect)((e=>{const{getQuestions:t,getData:s}=e("learnpress/quiz");return{questions:t(),status:s("status"),store:s(),answered:s("answered"),isReviewing:"reviewing"===s("mode"),questionIds:s("questionIds"),checkCount:s("instantCheck"),questionsPerPage:s("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{setQuizData:t,startQuiz:s}=e("learnpress/quiz");return{setQuizData:t,startQuiz:s}}))])(Ve);s(605);const{modal:{default:et}}=LP;var tt=Xe;const st=(e,t)=>{if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(e);if(null!==s){const e=JSON.parse(s);if(t.status=e.status,"started"===e.status){const s=Date.now();t.total_time=Math.floor((e.endTime-s)/1e3)}else"completed"===e.status&&(t.results=e.results,t.answered=e.results.answered,t.questions=e.results.questions);if(void 0!==e.checked_questions&&(t.checked_questions=e.checked_questions),void 0!==e.question_options)for(const s in t.questions){let n=t.questions[s];void 0!==e.question_options[n.id]&&(n.options=e.question_options[n.id]),t.questions[s]=n}}}wp.element.render((0,r.createElement)(et,null,(0,r.createElement)(Xe,{settings:t})),[...document.querySelectorAll(e)][0]),LP.Hook.doAction("lp-quiz-compatible-builder")}}(),(window.LP=window.LP||{}).quiz=n}();
1
+ !function(){var e={605:function(){LP.Hook.addAction("lp-compatible-builder",(()=>{LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&[...document.querySelectorAll("#popup-content")][0].addEventListener("scroll",(()=>{VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-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))),LP.Hook.addAction("lp-question-compatible-builder",(()=>(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)))},184:function(e,t){var s;!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var s=arguments[t];if(s){var i=typeof s;if("string"===i||"number"===i)e.push(s);else if(Array.isArray(s)){if(s.length){var o=r.apply(null,s);o&&e.push(o)}}else if("object"===i)if(s.toString===Object.prototype.toString)for(var a in s)n.call(s,a)&&s[a]&&e.push(a);else e.push(s.toString())}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(s=function(){return r}.apply(t,[]))||(e.exports=s)}()},965:function(e){"use strict";function t(e,s){var n;if(Array.isArray(s))for(n=0;n<s.length;n++)t(e,s[n]);else for(n in s)e[n]=(e[n]||[]).concat(s[n])}e.exports=function(e){var s,n={};return t(n,e),(s=function(e){return function(t){return function(s){var r,i,o=n[s.type],a=t(s);if(o)for(r=0;r<o.length;r++)(i=o[r](s,e))&&e.dispatch(i);return a}}}).effects=n,s}}},t={};function s(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,s),i.exports}s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,{a:t}),t},s.d=function(e,t){for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){"use strict";s.r(n),s.d(n,{default:function(){return tt},init:function(){return st}});var e={};s.r(e),s.d(e,{__requestBeforeStartQuiz:function(){return ge},__requestCheckAnswerSuccess:function(){return ze},__requestShowHintSuccess:function(){return ye},__requestStartQuizSuccess:function(){return fe},__requestSubmitQuiz:function(){return qe},__requestSubmitQuizSuccess:function(){return we},checkAnswer:function(){return ke},markQuestionRendered:function(){return be},sendKey:function(){return Qe},setCurrentPage:function(){return he},setCurrentQuestion:function(){return me},setQuizData:function(){return pe},setQuizMode:function(){return Pe},showHint:function(){return Ee},startQuiz:function(){return _e},submitQuiz:function(){return ve},updateUserQuestionAnswers:function(){return Se}});var t={};s.r(t),s.d(t,{getCurrentQuestion:function(){return Fe},getData:function(){return xe},getDefaultRestArgs:function(){return De},getItemStatus:function(){return Ae},getProp:function(){return Te},getQuestion:function(){return Ue},getQuestionAnswered:function(){return Me},getQuestionMark:function(){return He},getQuestionOptions:function(){return Ce},getQuestions:function(){return Le},getQuestionsSelectedAnswers:function(){return Be},getQuizAnswered:function(){return Oe},getQuizAttempts:function(){return Re},getUserMark:function(){return Je},isCheckedAnswer:function(){return $e},isCorrect:function(){return je}});var r=window.wp.element;function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var o=window.wp.compose,a=window.wp.data,u=window.wp.i18n,l=e=>{let t;const s=86400;if(e>s)t=(e-e%s)/s,e%=s;else if(e==s)return"24:00";const 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(":")};const{Hook:c}=LP;var d=()=>{const e=e=>(0,a.select)("learnpress/quiz").getData(e),t=c.applyFilters("quiz-meta-fields",{duration:{title:(0,u.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:(0,u.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:(0,u.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("ul",{className:"quiz-intro"},Object.values(t).map(((e,t)=>{const s=e.name||t;return(0,r.createElement)("li",{key:`quiz-intro-field-${t}`,className:`quiz-intro-item quiz-intro-item--${s}`},(0,r.createElement)("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),(0,r.createElement)("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};class p extends r.Component{constructor(){super(...arguments),i(this,"startQuiz",(e=>{e&&e.preventDefault();const t=document.querySelector(".lp-button.start");t&&t.setAttribute("disabled","disabled"),t.classList.add("loading");const{startQuiz:s,status:n}=this.props;if("completed"===n){const{confirm:e,isOpen:s}=(0,a.select)("learnpress/modal");if("no"===e((0,u.__)("Are you sure you want to retake the quiz?","learnpress"),this.startQuiz))return void(!s()&&t&&t.removeAttribute("disabled"))}s()})),i(this,"nav",(e=>t=>{let{questionNav:s,currentPage:n,numPages:r,setCurrentPage:i}=this.props;"prev"===e?n>1?n-=1:n="infinity"===s?r:1:n<r?n+=1:n="infinity"===s?1:r,i(n)})),i(this,"moveTo",(e=>t=>{t.preventDefault();const{numPages:s,setCurrentPage:n}=this.props;e<1||e>s||n(e)})),i(this,"isLast",(()=>{const{currentPage:e,numPages:t}=this.props;return e===t})),i(this,"isFirst",(()=>{const{currentPage:e}=this.props;return 1===e})),i(this,"submit",(()=>{const{submitQuiz:e}=this.props,{confirm:t}=(0,a.select)("learnpress/modal");"no"!==t((0,u.__)("Are you sure to submit the quiz?","learnpress"),this.submit)&&e()})),i(this,"setQuizMode",(e=>()=>{const{setQuizMode:t}=this.props;t(e)})),i(this,"isReviewing",(()=>{const{isReviewing:e}=this.props;return e}))}pageNumbers(e){const{numPages:t,currentPage:s}=this.props;if(t<2)return"";(e={numPages:t,currentPage:s,midSize:1,endSize:1,prevNext:!0,...e||{}}).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);const n=[...Array(t).keys()];let i=!1;return(0,r.createElement)("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&(0,r.createElement)("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},(0,u.__)("Prev","learnpress")),n.map((t=>(t+=1)===e.currentPage?(i=!0,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers current"},t)):t<=e.endSize||e.currentPage&&t>=e.currentPage-e.midSize&&t<=e.currentPage+e.midSize||t>e.numPages-e.endSize?(i=!0,(0,r.createElement)("button",{key:`page-number-${t}`,className:"page-numbers",onClick:this.moveTo(t)},t)):i?(i=!1,(0,r.createElement)("span",{key:`page-number-${t}`,className:"page-numbers dots"},"…")):"")),e.prevNext&&!this.isLast()&&(0,r.createElement)("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},(0,u.__)("Next","learnpress")))}render(){const{status:e,questionNav:t,isReviewing:s,showReview:n,numPages:i,question:o,questionsPerPage:a,canRetry:l,retakeNumber:c,requiredPassword:d,allowRetake:p}=this.props,m=["quiz-buttons"];("started"===e||s)&&m.push("align-center"),"questionNav"===t&&m.push("infinity"),this.isFirst()&&m.push("is-first"),this.isLast()&&m.push("is-last");const h=document.querySelector("#popup-sidebar"),g=document.querySelector("#learn-press-quiz-app");let f="";f="started"===e||s?{marginLeft:h&&h.offsetWidth/2,width:g&&g.offsetWidth}:null;let _=" fixed";return"no"==lpQuizSettings.navigationPosition&&(_=" nav-center"),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:m.join(" ")},(0,r.createElement)("div",{className:"button-left"+("started"===e||s?_:""),style:f},("completed"===e&&l||-1!==["","viewed"].indexOf(e))&&!s&&!d&&(0,r.createElement)("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===e?`${(0,u.__)("Retake","learnpress")} ${p?"":" "+(c?` (${c})`:"")} `:" "+(0,u.__)("Start","learnpress")),("started"===e||s)&&i>1&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"questions-pagination"},this.pageNumbers()))),(0,r.createElement)("div",{className:"button-right"},"started"===e&&(0,r.createElement)(r.Fragment,null,("infinity"===t||this.isLast())&&!s&&(0,r.createElement)("button",{className:"lp-button submit-quiz",onClick:this.submit},(0,u.__)("Finish Quiz","learnpress"))),s&&n&&(0,r.createElement)("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},(0,u.__)("Result","learnpress")),"completed"===e&&n&&!s&&(0,r.createElement)("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},(0,u.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&(0,r.createElement)("div",{className:"learn-press-message error"},this.props.message))}}const m=(0,o.compose)((0,a.withSelect)((e=>{const{getData:t}=e("learnpress/quiz");return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((e=>{const{showCheck:t,checkedQuestions:s,hintedQuestions:n,question:i,status:o,type:a,Button:u}=e;if("started"!==o)return!1;const l=(0,r.createElement)(u,{question:i});switch(a){case"hint":return n?!!i.hasHint&&-1===n.indexOf(i.id)&&l:l;case"check":return!!t&&(s?-1===s.indexOf(i.id)&&l:l)}}));var h=(0,o.compose)([(0,a.withSelect)((e=>{const{getData:t,getCurrentQuestion:s}=e("learnpress/quiz"),n={id:t("id"),status:t("status"),questionIds:t("questionIds"),questionNav:t("questionNav"),isReviewing:t("reviewQuestions")&&"reviewing"===t("mode"),showReview:t("reviewQuestions"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),numPages:t("numPages"),pages:t("pages"),currentPage:t("currentPage"),questionsPerPage:t("questionsPerPage"),pageNumbers:t("pageNumbers"),keyPressed:t("keyPressed"),canRetry:t("retakeCount")>0&&t("retaken")<t("retakeCount"),retakeNumber:t("retakeCount")>0&&t("retaken")<t("retakeCount")?t("retakeCount")-t("retaken"):null,message:t("messageResponse")||!1,success:void 0===t("successResponse")||t("successResponse"),requiredPassword:t("requiredPassword"),allowRetake:t("allowRetake")};if(1===n.questionsPerPage&&(n.question=s("object")),1===lpQuizSettings.checkNorequizenroll){const e=window.localStorage.getItem("quiz_off_retaken_"+lpQuizSettings.id);t("retakeCount")>e?(n.retakeNumber=t("retakeCount")-e,n.canRetry=!0):n.canRetry=!1}return n.allowRetake&&(n.canRetry=!0),n})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{startQuiz:n,setCurrentQuestion:r,submitQuiz:i,setQuizMode:o,showHint:a,checkAnswer:u,setCurrentPage:l}=e("learnpress/quiz");return{startQuiz:n,setCurrentQuestion:r,setQuizMode:o,setCurrentPage:l,submitQuiz(e){i(e)},showHint(e){a(e)},checkAnswer(e){u(e)}}}))])(p);function g(){return g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n])}return e},g.apply(this,arguments)}class f extends r.Component{constructor(){super(...arguments),i(this,"showHint",(()=>{const{showHint:e,question:t}=this.props;e(t.id,!t.showHint)}))}render(){const{question:e}=this.props;return e.hint?(0,r.createElement)("button",{className:"btn-show-hint",onClick:this.showHint},(0,r.createElement)("span",null,(0,u.__)("Hint","learnpress"))):""}}var _=(0,o.compose)((0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{showHint:n}=e("learnpress/quiz");return{showHint(e,t){n(e,t)}}})))(f),q=s(184),w=s.n(q);class v extends r.Component{constructor(){super(...arguments),i(this,"checkAnswer",(()=>{const{checkAnswer:e,question:t,answered:s}=this.props;s&&(e(t.id),this.setState({loading:!0}))})),this.state={loading:!1}}render(){const{answered:e}=this.props;return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("button",{className:w()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},(0,r.createElement)("span",{className:"instant-check__icon"}),(0,u.__)("Check answers","learnpress"),!e&&(0,r.createElement)("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:(0,u.__)("You need to answer the question before checking the answer key.","learnpress")}})))}}var S=(0,o.compose)((0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getQuestionAnswered:n}=e("learnpress/quiz");return{answered:n(s)}})),(0,a.withDispatch)(((e,t)=>{let{id:s}=t;const{checkAnswer:n}=e("learnpress/quiz");return{checkAnswer(e){n(e)}}})))(v),y=function(e){const{question:t}=e,s={"instant-check":()=>(0,r.createElement)(m,{type:"check",Button:S,question:t}),hint:()=>(0,r.createElement)(m,{type:"hint",Button:_,question:t})};return(0,r.createElement)(r.Fragment,null,LP.config.questionFooterButtons().map((e=>(0,r.createElement)(r.Fragment,{key:`button-${e}`},s[e]&&s[e]()))))};const E=window.jQuery,{uniqueId:z,isArray:k,isNumber:b,bind:P}=lodash;class Q extends r.Component{constructor(){super(...arguments),i(this,"setRef",(e=>{this.$wrap=E(e)})),i(this,"parseOptions",(e=>(e&&(e=k(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=k(e)?e:JSON.parse(e)),e||[]))),i(this,"getWrapperClass",(()=>{const{question:e,answered:t}=this.props,s=["question","question-"+e.type],n=this.parseOptions(e.options);return n.length&&void 0!==n[0].isTrue&&s.push("question-answered"),s})),i(this,"getEditLink",(()=>{const{question:e,editPermalink:t}=this.props;return t?t.replace(/post=(.*[0-9])/,`post=${e.id}`):""})),i(this,"editPermalink",(e=>(0,u.sprintf)('<a href="%s">%s</a>',e,(0,u.__)("Edit","learnpress")))),this.state={time:null,showHint:!1},this.$wrap=null}componentDidMount(e){const{question:t,isCurrent:s,markQuestionRendered:n}=this.props;return s&&n(t.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),"undefined"!=typeof MathJax&&MathJax.Hub.Queue(["Typeset",MathJax.Hub]),e}render(){const{question:e,isShow:t,isShowIndex:s,isShowHint:n,status:i}=this.props,o=LP.questionTypes.default,a=this.getEditLink();a&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",a);const l={index:()=>s?(0,r.createElement)("span",{className:"question-index"},s,"."):"",title:()=>(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:e.title}}),hint:()=>(0,r.createElement)(_,{question:e}),"edit-permalink":()=>a&&(0,r.createElement)("span",{dangerouslySetInnerHTML:{__html:this.editPermalink(a)},className:"edit-link"})},c={title:()=>(0,r.createElement)("h4",{className:"question-title"},LP.config.questionTitleParts().map((e=>(0,r.createElement)(r.Fragment,{key:`title-part-${e}`},l[e]&&l[e]())))),content:()=>(0,r.createElement)("div",{className:"question-content",dangerouslySetInnerHTML:{__html:e.content}}),"answer-options":()=>this.$wrap&&(0,r.createElement)(o,g({},this.props,{$wrap:this.$wrap})),explanation:()=>e.explanation&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-explanation-content"},(0,r.createElement)("strong",{className:"explanation-title"},(0,u.__)("Explanation","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.explanation}}))),hint:()=>e.hint&&!e.explanation&&e.showHint&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"question-hint-content"},(0,r.createElement)("strong",{className:"hint-title"},(0,u.__)("Hint","learnpress"),":"),(0,r.createElement)("div",{dangerouslySetInnerHTML:{__html:e.hint}}))),buttons:()=>"started"===i&&(0,r.createElement)(y,{question:e})},d=LP.config.questionBlocks();return(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:this.getWrapperClass().join(" "),style:{display:t?"":"none"},"data-id":e.id,ref:this.setRef},d.map((e=>(0,r.createElement)(r.Fragment,{key:`block-${e}`},c[e]?c[e]():"")))))}}var N=(0,o.compose)([(0,a.withSelect)(((e,t)=>{let{question:{id:s}}=t;const{getData:n,getQuestionAnswered:r,getQuestionMark:i}=e("learnpress/quiz");return{status:n("status"),questions:n("question"),answered:r(s),questionsRendered:n("questionsRendered"),editPermalink:n("editPermalink"),numPages:n("numPages"),mark:i(s)||""}})),(0,a.withDispatch)((e=>{const{updateUserQuestionAnswers:t,markQuestionRendered:s}=e("learnpress/quiz");return{markQuestionRendered:s,updateUserQuestionAnswers:t}}))])(Q);class I extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{e.preventDefault();const{startQuiz:t}=this.props;t()})),i(this,"isInVisibleRange",((e,t)=>{const{currentPage:s,questionsPerPage:n}=this.props;return s===Math.ceil(t/n)})),i(this,"nav",(e=>{const{sendKey:t}=this.props;switch(e.keyCode){case 37:return t("left");case 38:case 40:return;case 39:return t("right");default:e.keyCode>=49&&e.keyCode<=57&&t(e.keyCode-48)}})),this.needToTop=!1,this.state={isReviewing:null,currentPage:0,self:this}}static getDerivedStateFromProps(e,t){const s=["isReviewing","currentPage"],n={};for(let r=0;r<s.length;r++)e[s[r]]!==t[s[r]]&&(n[s[r]]=e[s[r]]);return Object.values(n).length?(t.self.needToTop=!0,n):null}componentDidUpdate(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}render(){const{status:e,currentQuestion:t,questions:s,questionsRendered:n,isReviewing:i,questionsPerPage:o}=this.props;let a=!0;return"completed"!==e||i||(a=!1),(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{tabIndex:100,onKeyUp:this.nav},(0,r.createElement)("div",{className:"quiz-questions",style:{display:a?"":"none"}},s.map(((e,s)=>{const i=!o&&t===e.id,a=n&&-1!==n.indexOf(e.id),u=this.isInVisibleRange(e.id,s+1);return a||!a||u?(0,r.createElement)(N,{key:`loop-question-${e.id}`,isCurrent:i,isShow:u,isShowIndex:!!o&&s+1,questionsPerPage:o,question:e}):""})))))}}var C=(0,o.compose)((0,a.withSelect)(((e,t,s)=>{const{getData:n,getQuestions:r}=e("learnpress/quiz");return{status:n("status"),currentQuestion:n("currentQuestion"),questions:r(),questionsRendered:n("questionsRendered"),isReviewing:"reviewing"===n("mode"),numPages:n("numPages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{startQuiz:t,sendKey:s}=e("learnpress/quiz");return{startQuiz:t,sendKey:s}})))(I),A=()=>{const e=(0,a.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",{className:"quiz-attempts"},(0,r.createElement)("h4",{className:"attempts-heading"},(0,u.__)("Last Attempt","learnpress")),t&&(0,r.createElement)("table",null,(0,r.createElement)("thead",null,(0,r.createElement)("tr",null,(0,r.createElement)("th",{className:"quiz-attempts__questions"},(0,u.__)("Questions","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__spend"},(0,u.__)("Time spent","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__marks"},(0,u.__)("Marks","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__grade"},(0,u.__)("Passing grade","learnpress")),(0,r.createElement)("th",{className:"quiz-attempts__result"},(0,u.__)("Result","learnpress")))),(0,r.createElement)("tbody",null,e.map(((e,t)=>(0,r.createElement)("tr",{key:`attempt-${t}`},(0,r.createElement)("td",{className:"quiz-attempts__questions"},`${e.questionCorrect} / ${e.questionCount}`),(0,r.createElement)("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),(0,r.createElement)("td",{className:"quiz-attempts__marks"},`${e.userMark} / ${e.mark}`),(0,r.createElement)("td",{className:"quiz-attempts__grade"},e.passingGrade||"-"),(0,r.createElement)("td",{className:"quiz-attempts__result"},`${parseFloat(e.result).toFixed(2)}%`," ",(0,r.createElement)("span",null,e.graduationText)))))))))},T=()=>{const{getData:e}=(0,a.select)("learnpress/quiz"),{submitQuiz:t}=(0,a.dispatch)("learnpress/quiz"),s=e("totalTime"),n=e("duration"),[i,o]=(0,r.useState)(s);let[u,l]=(0,r.useState)(0);return(0,r.useEffect)((()=>{const e=setInterval((()=>{if(n>0){let s=i;s-=1,s>0?(o(s),u++,l(n-s)):(clearInterval(e),t())}else u++,l(u),o(u)}),1e3);return()=>clearInterval(e)}),[i,u]),(0,r.createElement)("div",{className:"countdown"},(0,r.createElement)("i",{className:"fas fa-stopwatch"}),(0,r.createElement)("span",null,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":";const t=[];let n;return s<3600?(t.push((i-i%60)/60),t.push(i%60)):s&&(t.push((i-i%3600)/3600),n=i%3600,t.push((n-n%60)/60),t.push(n%60)),t.map((e=>e<10?`0${e}`:e)).join(e)}()),(0,r.createElement)("input",{type:"hidden",name:"lp-quiz-time-spend",value:u}))},R=window.wp.url;const O=jQuery;let L=null;const x={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init(){return!!this.instance||(this.elLPOverlay=O(".lp-overlay"),!!this.elLPOverlay.length&&(L=this.elLPOverlay,this.elMainContent=L.find(".main-content"),this.elTitle=L.find(".modal-title"),this.elBtnYes=L.find(".btn-yes"),this.elBtnNo=L.find(".btn-no"),this.elFooter=L.find(".lp-modal-footer"),O(document).on("click",".close, .btn-no",(function(){L.hide()})),O(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof x.callBackYes&&x.callBackYes()})),this.instance=this,!0))},setElCalledModal(e){this.elCalledModal=e},setContentModal(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal(e){this.elTitle.html(e)}};var D=x,M={elBtnFinishCourse:null,elBtnCompleteItem:null,init(){D.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",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((e=>e.addEventListener("click",(e=>{e.preventDefault();const t=e.target.closest("form");D.elLPOverlay.show(),D.setTitleModal(t.dataset.title),D.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),D.callBackYes=()=>{t.submit()}})))))}};const{debounce:H}=lodash;var F=()=>{const[e,t]=(0,r.useState)(0),[s,n]=(0,r.useState)(!1),i=(0,a.useSelect)((e=>e("learnpress/quiz").getData("id")),[]),o=(0,a.useSelect)((e=>e("learnpress/quiz").getData("results")),[]),l=(0,a.useSelect)((e=>e("learnpress/quiz").getData("passingGrade")),[]),c=(0,a.useSelect)((e=>e("learnpress/quiz").getData("submitting")),[]);(0,r.useEffect)((()=>{p();let e="";if(e=o.graduation?o.graduation:o.result>=f?"passed":"failed",e){const t=document.querySelector(`.course-curriculum .course-item.course-item-${i}`);t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}const t=[...document.querySelectorAll("#popup-header .items-progress")][0],s=document.querySelector(".curriculum-sections");if(t&&s){const e=t.dataset.totalItems,s=t.querySelector(".items-completed"),n=t.querySelector(".learn-press-progress__active");if(s){const t=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");s.textContent=parseInt(t.length);const r=100-100*parseInt(t.length)/parseInt(e);n.style.left="-"+r+"%"}}}),[o]),(0,r.useEffect)((()=>{void 0!==c&&d()}),[c]);const d=()=>{const e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&(async e=>{const t=await wp.apiFetch({path:(0,R.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"}),{data:s}=t;e.innerHTML+=s,M.init()})(e[0])},p=()=>{t(0),n(!1),jQuery.easing._customEasing=function(e,t,s,n,r){return n*Math.sqrt(1-(t=t/r-1)*t)+s},H((()=>{const e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:o.result},{duration:1500,step:(e,s)=>{t(e)},done:()=>{n(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),H((()=>{jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),o.result>0?1e3:10)()};let m=e;Number.isInteger(e)||(m=parseFloat(e).toFixed(2));const h=190*Math.PI,g={strokeDasharray:`${h} ${h}`,strokeDashoffset:h-m/100*h},f=parseFloat(o.passingGrade||l);let _="";_=o.graduation?o.graduation:m>=f?"passed":"failed";let q="";q=o.graduationText?o.graduationText:"passed"===_?(0,u.__)("Passed","learnpress"):(0,u.__)("Failed","learnpress");const w=["quiz-result",_];return(0,r.createElement)("div",{className:w.join(" ")},(0,r.createElement)("h3",{className:"result-heading"},(0,u.__)("Your Result","learnpress")),(0,r.createElement)("div",{id:"quizResultGrade",className:"result-grade"},(0,r.createElement)("svg",{className:"circle-progress-bar",width:200,height:200},(0,r.createElement)("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),(0,r.createElement)("span",{className:"result-achieved"},`${m}%`),(0,r.createElement)("span",{className:"result-require"},f+"%"||0)),s&&(0,r.createElement)("p",{className:"result-message"},q),(0,r.createElement)("ul",{className:"result-statistic"},(0,r.createElement)("li",{className:"result-statistic-field result-time-spend"},(0,r.createElement)("span",null,(0,u.__)("Time spent","learnpress")),(0,r.createElement)("p",null,o.timeSpend)),(0,r.createElement)("li",{className:"result-statistic-field result-point"},(0,r.createElement)("span",null,(0,u.__)("Points","learnpress")),(0,r.createElement)("p",null,o.userMark," / ",o.mark)),(0,r.createElement)("li",{className:"result-statistic-field result-questions"},(0,r.createElement)("span",null,(0,u.__)("Questions","learnpress")),(0,r.createElement)("p",null,o.questionCount)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-correct"},(0,r.createElement)("span",null,(0,u.__)("Correct","learnpress")),(0,r.createElement)("p",null,o.questionCorrect)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-wrong"},(0,r.createElement)("span",null,(0,u.__)("Wrong","learnpress")),(0,r.createElement)("p",null,o.questionWrong)),(0,r.createElement)("li",{className:"result-statistic-field result-questions-skipped"},(0,r.createElement)("span",null,(0,u.__)("Skipped","learnpress")),(0,r.createElement)("p",null,o.questionEmpty))))};const U=jQuery,{debounce:$}=lodash;var j=()=>{const{submitQuiz:e}=(0,a.dispatch)("learnpress/quiz");(0,r.useEffect)((()=>{const e=U("#popup-content");if(!e.length)return;const t=e.find(".content-item-scrollable:eq(1)"),s=e.find(".content-item-wrap"),n=e.find(".quiz-status"),r=n.offset().top-92;let i=!1,o="-"+s.css("margin-left");U(window).on("resize.refresh-quiz-stauts-bar",$((function(){o="-"+s.css("margin-left"),n.css({"margin-left":o,"margin-right":o})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(()=>{if(t.scrollTop()>=r){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}),[]);const t=()=>{const{confirm:s}=(0,a.select)("learnpress/modal");"no"!==s((0,u.__)("Are you sure to submit the quiz?","learnpress"),t)&&e()},{getData:s,getUserMark:n}=(0,a.select)("learnpress/quiz"),i=s("currentPage"),o=s("questionsPerPage"),l=s("questionIds").length,c=s("submitting"),d=(s("duration"),n()),p=["quiz-status"],m=(i-1)*o+1;let h=m+o-1,g="";return h=Math.min(h,l),c&&p.push("submitting"),g=h<l?o>1?(0,u.sprintf)((0,u.__)("Question <span>%d to %d of %d</span>","learnpress"),m,h,l):(0,u.sprintf)((0,u.__)("Question <span>%d of %d</span>","learnpress"),m,l):(0,u.sprintf)((0,u.__)("Question <span>%d to %d</span>","learnpress"),m,h),(0,r.createElement)("div",{className:p.join(" ")},(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:g}}),(0,r.createElement)("div",{className:"current-point"},(0,u.sprintf)((0,u.__)("Earned Point: %s","learnpress"),d)),(0,r.createElement)("div",null,(0,r.createElement)("div",{className:"submit-quiz"},(0,r.createElement)("button",{className:"lp-button",id:"button-submit-quiz",onClick:t},c?(0,u.__)("Submitting...","learnpress"):(0,u.__)("Finish Quiz","learnpress"))),(0,r.createElement)(T,null))))};const{omit:B,flow:J,isArray:G,chunk:K}=lodash,{camelCaseDashObjectKeys:W}=LP,{get:Z,set:Y}=LP.localStorage,V={},X=(e,t)=>{const{answered:s,id:n}=e,r={...s[t.questionId]||{},answered:t.answers,temp:!0};return n&&localStorage.setItem(`LP_Quiz_${n}_Answered`,JSON.stringify({...e.answered,[t.questionId]:r})),{...e,answered:{...e.answered,[t.questionId]:r}}},ee=(e,t)=>{const{questionsRendered:s}=e;return G(s)?(s.push(t.questionId),{...e,questionsRendered:[...s]}):{...e,questionsRendered:[t.questionId]}},te=(e,t)=>(t.currentPage&&Y(`Q${e.id}.currentPage`,t.currentPage),{...e,...t}),se=(e,t)=>{const s=e.questions.map((e=>e.id==t.questionId?{...e,showHint:t.showHint}:e));return{...e,questions:[...s]}},ne=(e,t)=>{const s=e.questions.map((e=>{if(e.id!==t.questionId)return e;const s={explanation:t.explanation};return t.options&&(s.options=t.options),{...e,...s}})),n={...e.answered,[t.questionId]:t.result};let r=localStorage.getItem(`LP_Quiz_${e.id}_Answered`);return r&&(r={...JSON.parse(r),...n},localStorage.setItem(`LP_Quiz_${e.id}_Answered`,JSON.stringify(r))),{...e,questions:[...s],answered:n,checkedQuestions:[...e.checkedQuestions,t.questionId]}},re=(e,t)=>{localStorage.removeItem(`LP_Quiz_${e.id}_Answered`);const s=e.questions.map((s=>{const n={};var r,i;return e.reviewQuestions&&(null!==(r=t.results.questions[s.id])&&void 0!==r&&r.explanation&&(n.explanation=t.results.questions[s.id].explanation),null!==(i=t.results.questions[s.id])&&void 0!==i&&i.options&&(n.options=t.results.questions[s.id].options)),{...s,...n}}));return te(e,{submitting:!1,currentPage:1,...t.results,questions:[...s]})},ie=(e,t)=>{const s=void 0!==t.results.success&&t.results.success,n=t.results.message||!1;return te(e,{checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1,...t.results.results,successResponse:s,messageResponse:n})},oe=J(a.combineReducers,(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)),(e=>(t,s)=>e(t,s)))({a(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1}},b(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2}}});var ae=(0,a.combineReducers)({blocks:oe,userQuiz:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);const s=K(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=s.length,t.data.pages=s,{...e,...t.data,currentPage:Z(`Q${t.data.id}.currentPage`)||t.data.currentPage};case"SUBMIT_QUIZ":return{...e,submitting:!0};case"START_QUIZ":case"START_QUIZ_SUCCESS":return ie(e,t);case"SET_CURRENT_QUESTION":return Y(`Q${e.id}.currentQuestion`,t.questionId),{...e,currentQuestion:t.questionId};case"SET_CURRENT_PAGE":return Y(`Q${e.id}.currentPage`,t.currentPage),{...e,currentPage:t.currentPage};case"SUBMIT_QUIZ_SUCCESS":return re(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?X(e,t):e;case"MARK_QUESTION_RENDERED":return ee(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?te(e,{mode:t.mode}):{...e,mode:t.mode};case"SET_QUESTION_HINT":return se(e,t);case"CHECK_ANSWER":return ne(e,t);case"SEND_KEY":return{...e,keyPressed:t.keyPressed}}return e}}),ue=window.LP.dataControls;function le(){const e=[].slice.call(arguments,2),t=(0,a.dispatch)(arguments[0]),s=arguments[1];t[s](...e)}const{camelCaseDashObjectKeys:ce,Hook:de}=LP;function pe(e,t){return{type:"SET_QUIZ_DATA",data:ce(t="string"==typeof e?{[e]:t}:e)}}function me(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function he(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function ge(e,t,s){return{type:"BEFORE_START_QUIZ"}}function fe(e,t,s,n){return de.doAction("quiz-started",e,t,s,n),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:s,userId:n,results:e}}const _e=function*(){const{itemId:e,courseId:t}=(0,a.select)("learnpress/quiz").getDefaultRestArgs();if(!0!==de.applyFilters("before-start-quiz",!0,e,t))return;let s=yield(0,ue.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:e,course_id:t}});const n=document.querySelector(".lp-button.start");if("error"!==s.status){if(s=de.applyFilters("request-start-quiz-response",s,e,t),1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id;window.localStorage.removeItem(e);const t={endTime:Date.now()+1e3*s.results.duration,status:s.results.status};window.localStorage.setItem(e,JSON.stringify(t));const n="quiz_off_retaken_"+lpQuizSettings.id;let r=window.localStorage.getItem(n);null===r?r=0:r++,window.localStorage.setItem(n,r)}yield le("learnpress/quiz","__requestStartQuizSuccess",ce(s),e,t)}else{const e=document.querySelector(".quiz-buttons"),t=`<div class="learn-press-message error">${s.message}</div>`;e.insertAdjacentHTML("afterend",t),n.classList.remove("loading")}};function qe(){return{type:"SUBMIT_QUIZ"}}function we(e,t,s){return de.doAction("quiz-submitted",e,t,s),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function*ve(){const{getDefaultRestArgs:e,getQuestionsSelectedAnswers:t}=(0,a.select)("learnpress/quiz"),{itemId:s,courseId:n}=e();if(!0!==de.applyFilters("before-submit-quiz",!0))return;const r=t();if(1===lpQuizSettings.checkNorequizenroll){const e=`LP_Quiz_${s}_Answered`,t=localStorage.getItem(e);if(null!==t){const e=JSON.parse(t);for(const[t,s]of Object.entries(e))r[t]=s.answered}}let i=0;const o=document.querySelector("input[name=lp-quiz-time-spend]");o&&(i=o.value);let u=yield(0,ue.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:s,course_id:n,answered:r,time_spend:i}});if(u=de.applyFilters("request-submit-quiz-response",u,s,n),"success"===u.status){if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,t=window.localStorage.getItem(e);if(null!==t){const s=JSON.parse(t);s.status=u.results.status,s.results=u.results.results,window.localStorage.setItem(e,JSON.stringify(s)),window.localStorage.removeItem("LP_Quiz_"+lpQuizSettings.id+"_Answered")}}yield le("learnpress/quiz","__requestSubmitQuizSuccess",ce(u.results),s,n)}}function Se(e,t,s){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function ye(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function*Ee(e,t){yield le("learnpress/quiz","__requestShowHintSuccess",e,t)}function ze(e,t){return{type:"CHECK_ANSWER",questionId:e,...t}}function*ke(e){const{getDefaultRestArgs:t,getQuestionAnswered:s}=(0,a.select)("learnpress/quiz"),{itemId:n,courseId:r}=t(),i=yield(0,ue.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:n,course_id:r,question_id:e,answered:s(e)||""}});if("success"===i.status){if(1===lpQuizSettings.checkNorequizenroll){const t="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(t);if(null!==s){const n=JSON.parse(s),r=i.options;void 0===n.checked_questions?(n.checked_questions=[],n.checked_questions.push(e)):-1===n.checked_questions.indexOf(e)&&n.checked_questions.push(e),void 0===n.question_options?(n.question_options={},n.question_options[e]=r):void 0===n.question_options[e]&&(n.question_options[e]=r),window.localStorage.setItem(t,JSON.stringify(n))}}yield le("learnpress/quiz","__requestCheckAnswerSuccess",e,ce(i))}}function be(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Pe(e){return{type:"SET_QUIZ_MODE",mode:e}}function Qe(e){return setTimeout((()=>{le("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}const{get:Ne,isArray:Ie}=lodash,Ce=function(e,t){console.time("parseOptions");let s=Ue(e,t).options;return s=Ie(s)?s:JSON.parse(CryptoJS.AES.decrypt(s.data,s.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),s=Ie(s)?s:JSON.parse(s),console.timeEnd("parseOptions"),s};function Ae(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.status"):""}function Te(e,t,s){return e[t]||s}function Re(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.attempts"):[]}function Oe(e,t){const s=(0,a.select)("course-learner/user").getItemById(t);return s?Ne(s,"userSettings.answered",{}):{}}function Le(e){const{userQuiz:t}=e,s=Ne(t,"questions");return s?Object.values(s):[]}function xe(e,t){const{userQuiz:s}=e;return t?Ne(s,t):s}function De(e){const{userQuiz:t}=e;return{itemId:t.id,courseId:t.courseId}}function Me(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.answered`)||void 0}function He(e,t){const{userQuiz:s}=e;return Ne(s,`answered.${t}.mark`)||void 0}function Fe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const s=Ne(e,"userQuiz.questionsPerPage")||1;if(s>1)return!1;const n=Ne(e,"userQuiz.currentPage")||1;return Ne(e,"object"===t?`userQuiz.questions[${n-1}]`:`userQuiz.questionIds[${n-1}]`)}const Ue=function(e,t){const{userQuiz:s}=e;return(0,a.select)("learnpress/quiz").getQuestions().find((e=>e.id==t))};function $e(e,t){return-1!==(Ne(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function je(e,t){}const Be=function(e,t){const s=Ne(e,"userQuiz.answered"),n={};for(const e in s)if(s.hasOwnProperty(e)&&(s[e].temp||s[e].blanks)){if(t&&e===t)return s[e].answered;n[e]=s[e].answered}return n};function Je(e){const t=e.userQuiz||{},{answered:s,negativeMarking:n,questions:r,checkedQuestions:i}=t;let o=0;for(let e in s){if(!s.hasOwnProperty(e))continue;e=parseInt(e);const t=s[e],a=t.questionMark?t.questionMark:function(){const t=r.find((t=>t.id===e));return t?t.point:0}();i.indexOf(e),t.temp||(n?t.answered&&(o=t.correct?o+t.mark:o-a):t.answered&&t.correct&&(o+=t.mark))}return o>0?o:0}var Ge=s(965),Ke=s.n(Ge);const We={ENROLL_COURSE_X:(e,t)=>{}};const{controls:Ze}=LP.dataControls;!function(e){let t=()=>{throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")};const s={getState:e.getState,dispatch:function(){return t(...arguments)}};t=Ke()(We)(s)(e.dispatch),e.dispatch=t}((0,a.registerStore)("learnpress/quiz",{reducer:ae,selectors:t,actions:e,controls:{...Ze}}));const{chunk:Ye}=lodash;class Ve extends r.Component{constructor(e){super(...arguments),i(this,"startQuiz",(e=>{this.props.startQuiz()})),this.state={currentPage:1,numPages:0,pages:[]}}componentDidMount(){const{settings:e,setQuizData:t}=this.props,{question_ids:s,questions_per_page:n}=e,r=Ye(s,n);e.currentPage=1,e.numPages=r.length,e.pages=r;const i=!!e.id&&localStorage.getItem(`LP_Quiz_${e.id}_Answered`);i&&(e.answered=JSON.parse(i)),t(e)}componentDidUpdate(e,t,s){const{status:n}=e,r=document.querySelector(".quiz-content");void 0!==n&&r&&(r.style.display="none")}render(){const{status:e,isReviewing:t}=this.props,s=-1!==["","completed","viewed"].indexOf(e)||!e,n=-1!==["","viewed",void 0].indexOf(e)||!e;return void 0!==e&&(0,r.createElement)(r.Fragment,null,(0,r.createElement)("div",null,!t&&"completed"===e&&(0,r.createElement)(F,null),!t&&n&&(0,r.createElement)(d,null),"started"===e&&(0,r.createElement)(j,null),(-1!==["completed","started"].indexOf(e)||t)&&(0,r.createElement)(C,null),(0,r.createElement)(h,null),s&&!t&&(0,r.createElement)(A,null)))}}var Xe=(0,o.compose)([(0,a.withSelect)((e=>{const{getQuestions:t,getData:s}=e("learnpress/quiz");return{questions:t(),status:s("status"),store:s(),answered:s("answered"),isReviewing:"reviewing"===s("mode"),questionIds:s("questionIds"),checkCount:s("instantCheck"),questionsPerPage:s("questionsPerPage")||1}})),(0,a.withDispatch)((e=>{const{setQuizData:t,startQuiz:s}=e("learnpress/quiz");return{setQuizData:t,startQuiz:s}}))])(Ve);s(605);const{modal:{default:et}}=LP;var tt=Xe;const st=(e,t)=>{if(1===lpQuizSettings.checkNorequizenroll){const e="quiz_off_"+lpQuizSettings.id,s=window.localStorage.getItem(e);if(null!==s){const e=JSON.parse(s);if(t.status=e.status,"started"===e.status){const s=Date.now();t.total_time=Math.floor((e.endTime-s)/1e3)}else"completed"===e.status&&(t.results=e.results,t.answered=e.results.answered,t.questions=e.results.questions);if(void 0!==e.checked_questions&&(t.checked_questions=e.checked_questions),void 0!==e.question_options)for(const s in t.questions){let n=t.questions[s];void 0!==e.question_options[n.id]&&(n.options=e.question_options[n.id]),t.questions[s]=n}}}wp.element.render((0,r.createElement)(et,null,(0,r.createElement)(Xe,{settings:t})),[...document.querySelectorAll(e)][0]),LP.Hook.doAction("lp-quiz-compatible-builder")}}(),(window.LP=window.LP||{}).quiz=n}();
assets/js/dist/frontend/single-course.js CHANGED
@@ -365,8 +365,6 @@ __webpack_require__.r(__webpack_exports__);
365
 
366
  function courseCurriculumSkeleton() {
367
  let courseID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
368
- let isLoadingItems = false;
369
- let isLoadingSections = false;
370
 
371
  const Sekeleton = () => {
372
  const elementCurriculum = document.querySelector('.learnpress-course-curriculum');
@@ -548,7 +546,6 @@ function courseCurriculumSkeleton() {
548
  }
549
  }
550
 
551
- isLoadingItems = false;
552
  return {
553
  data3: returnData,
554
  pages3: pages || data.pages,
@@ -592,7 +589,6 @@ function courseCurriculumSkeleton() {
592
  }
593
  }
594
 
595
- isLoadingSections = false;
596
  return {
597
  data2: returnData,
598
  pages2: pages || data.pages,
@@ -606,8 +602,7 @@ function courseCurriculumSkeleton() {
606
  document.addEventListener('click', e => {
607
  const sectionBtns = document.querySelectorAll('.section-item__loadmore');
608
  [...sectionBtns].map(async sectionBtn => {
609
- if (sectionBtn.contains(e.target) && !isLoadingItems) {
610
- isLoadingItems = true;
611
  const sectionItem = sectionBtn.parentNode;
612
  const sectionId = sectionItem.getAttribute('data-section-id');
613
  const sectionContent = sectionItem.querySelector('.section-content');
@@ -645,8 +640,7 @@ function courseCurriculumSkeleton() {
645
 
646
  const moreSections = document.querySelectorAll('.curriculum-more__button');
647
  [...moreSections].map(async moreSection => {
648
- if (moreSection.contains(e.target) && !isLoadingSections) {
649
- isLoadingSections = true;
650
  const paged = parseInt(moreSection.dataset.page);
651
  const sections = moreSection.parentNode.parentNode.querySelector('.curriculum-sections');
652
 
365
 
366
  function courseCurriculumSkeleton() {
367
  let courseID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
 
 
368
 
369
  const Sekeleton = () => {
370
  const elementCurriculum = document.querySelector('.learnpress-course-curriculum');
546
  }
547
  }
548
 
 
549
  return {
550
  data3: returnData,
551
  pages3: pages || data.pages,
589
  }
590
  }
591
 
 
592
  return {
593
  data2: returnData,
594
  pages2: pages || data.pages,
602
  document.addEventListener('click', e => {
603
  const sectionBtns = document.querySelectorAll('.section-item__loadmore');
604
  [...sectionBtns].map(async sectionBtn => {
605
+ if (sectionBtn.contains(e.target)) {
 
606
  const sectionItem = sectionBtn.parentNode;
607
  const sectionId = sectionItem.getAttribute('data-section-id');
608
  const sectionContent = sectionItem.querySelector('.section-content');
640
 
641
  const moreSections = document.querySelectorAll('.curriculum-more__button');
642
  [...moreSections].map(async moreSection => {
643
+ if (moreSection.contains(e.target)) {
 
644
  const paged = parseInt(moreSection.dataset.page);
645
  const sections = moreSection.parentNode.parentNode.querySelector('.curriculum-sections');
646
 
assets/js/dist/frontend/single-curriculum.js CHANGED
@@ -607,8 +607,6 @@ __webpack_require__.r(__webpack_exports__);
607
 
608
  function courseCurriculumSkeleton() {
609
  let courseID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
610
- let isLoadingItems = false;
611
- let isLoadingSections = false;
612
 
613
  const Sekeleton = () => {
614
  const elementCurriculum = document.querySelector('.learnpress-course-curriculum');
@@ -790,7 +788,6 @@ function courseCurriculumSkeleton() {
790
  }
791
  }
792
 
793
- isLoadingItems = false;
794
  return {
795
  data3: returnData,
796
  pages3: pages || data.pages,
@@ -834,7 +831,6 @@ function courseCurriculumSkeleton() {
834
  }
835
  }
836
 
837
- isLoadingSections = false;
838
  return {
839
  data2: returnData,
840
  pages2: pages || data.pages,
@@ -848,8 +844,7 @@ function courseCurriculumSkeleton() {
848
  document.addEventListener('click', e => {
849
  const sectionBtns = document.querySelectorAll('.section-item__loadmore');
850
  [...sectionBtns].map(async sectionBtn => {
851
- if (sectionBtn.contains(e.target) && !isLoadingItems) {
852
- isLoadingItems = true;
853
  const sectionItem = sectionBtn.parentNode;
854
  const sectionId = sectionItem.getAttribute('data-section-id');
855
  const sectionContent = sectionItem.querySelector('.section-content');
@@ -887,8 +882,7 @@ function courseCurriculumSkeleton() {
887
 
888
  const moreSections = document.querySelectorAll('.curriculum-more__button');
889
  [...moreSections].map(async moreSection => {
890
- if (moreSection.contains(e.target) && !isLoadingSections) {
891
- isLoadingSections = true;
892
  const paged = parseInt(moreSection.dataset.page);
893
  const sections = moreSection.parentNode.parentNode.querySelector('.curriculum-sections');
894
 
607
 
608
  function courseCurriculumSkeleton() {
609
  let courseID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
 
 
610
 
611
  const Sekeleton = () => {
612
  const elementCurriculum = document.querySelector('.learnpress-course-curriculum');
788
  }
789
  }
790
 
 
791
  return {
792
  data3: returnData,
793
  pages3: pages || data.pages,
831
  }
832
  }
833
 
 
834
  return {
835
  data2: returnData,
836
  pages2: pages || data.pages,
844
  document.addEventListener('click', e => {
845
  const sectionBtns = document.querySelectorAll('.section-item__loadmore');
846
  [...sectionBtns].map(async sectionBtn => {
847
+ if (sectionBtn.contains(e.target)) {
 
848
  const sectionItem = sectionBtn.parentNode;
849
  const sectionId = sectionItem.getAttribute('data-section-id');
850
  const sectionContent = sectionItem.querySelector('.section-content');
882
 
883
  const moreSections = document.querySelectorAll('.curriculum-more__button');
884
  [...moreSections].map(async moreSection => {
885
+ if (moreSection.contains(e.target)) {
 
886
  const paged = parseInt(moreSection.dataset.page);
887
  const sections = moreSection.parentNode.parentNode.querySelector('.curriculum-sections');
888
 
assets/src/apps/js/admin/pages/tools/database/upgrade.js CHANGED
@@ -103,6 +103,10 @@ const upgradeDB = () => {
103
  const scrollToStepCurrent = ( stepCurrent ) => {
104
  elItemStepCurrent = elGroupStep.find( 'input[value=' + stepCurrent + ']' ).closest( '.lp-item-step' );
105
 
 
 
 
 
106
  const offset = elItemStepCurrent.offset().top - lpModalOverlay.elMainContent.offset().top +
107
  lpModalOverlay.elMainContent.scrollTop();
108
 
103
  const scrollToStepCurrent = ( stepCurrent ) => {
104
  elItemStepCurrent = elGroupStep.find( 'input[value=' + stepCurrent + ']' ).closest( '.lp-item-step' );
105
 
106
+ if ( ! elItemStepCurrent.length ) {
107
+ return;
108
+ }
109
+
110
  const offset = elItemStepCurrent.offset().top - lpModalOverlay.elMainContent.offset().top +
111
  lpModalOverlay.elMainContent.scrollTop();
112
 
assets/src/apps/js/blocks/template/edit.js CHANGED
@@ -30,7 +30,7 @@ export default function Edit( { attributes } ) {
30
  { sprintf(
31
  /* translators: %s is the template title */
32
  __(
33
- 'This is an editor placeholder for the %s. On your store this will be replaced by the template and display with your course image(s), title, price, etc. You can move this placeholder around and add further blocks around it to extend the template.',
34
  'learnpress'
35
  ),
36
  templateTitle
30
  { sprintf(
31
  /* translators: %s is the template title */
32
  __(
33
+ 'This is an editor placeholder for the %s. This will be replaced by the template in your store and displayed with your course image(s), title, price, and so on. You can move this placeholder around and add further blocks around it to extend the template.',
34
  'learnpress'
35
  ),
36
  templateTitle
assets/src/apps/js/frontend/profile/avatar.js CHANGED
@@ -128,9 +128,9 @@ export default function Avatar() {
128
 
129
  let error = '';
130
  if ( parseInt( fileUpload.size ) > 2097152 ) {
131
- error = __( 'File size too large. You need to upload a file < 2MB', 'learnpress' );
132
  } else if ( img.naturalWidth < width || img.naturalHeight < height ) {
133
- error = sprintf( __( 'Image size must be greater than or equal to %1$sx%2$spx', 'learnpress' ), width, height );
134
  }
135
 
136
  if ( error ) {
128
 
129
  let error = '';
130
  if ( parseInt( fileUpload.size ) > 2097152 ) {
131
+ error = __( 'The file size is too large. You need to upload a file < 2MB.', 'learnpress' );
132
  } else if ( img.naturalWidth < width || img.naturalHeight < height ) {
133
+ error = sprintf( __( 'The image size must be greater than or equal to %1$sx%2$spx', 'learnpress' ), width, height );
134
  }
135
 
136
  if ( error ) {
assets/src/apps/js/frontend/question-types/components/question-base/index.js CHANGED
@@ -144,7 +144,7 @@ class QuestionBase extends Component {
144
  };
145
 
146
  getWarningMessage = () => {
147
- return <>{ __( 'Render function should be overwritten from base.', 'learnpress' ) }</>;
148
  };
149
 
150
  getOptionClass = ( option ) => {
144
  };
145
 
146
  getWarningMessage = () => {
147
+ return <>{ __( 'The render function should be overwritten from the base.', 'learnpress' ) }</>;
148
  };
149
 
150
  getOptionClass = ( option ) => {
assets/src/apps/js/frontend/quiz/components/attempts/index.js CHANGED
@@ -12,7 +12,7 @@ const Attempts = () => {
12
  return (
13
  ! hasAttempts ? false : <>
14
  <div className="quiz-attempts">
15
- <h4 className="attempts-heading">{ __( 'Last Attempted', 'learnpress' ) }</h4>
16
 
17
  { hasAttempts && (
18
  <table>
12
  return (
13
  ! hasAttempts ? false : <>
14
  <div className="quiz-attempts">
15
+ <h4 className="attempts-heading">{ __( 'Last Attempt', 'learnpress' ) }</h4>
16
 
17
  { hasAttempts && (
18
  <table>
assets/src/apps/js/frontend/quiz/components/buttons/button-check.js CHANGED
@@ -37,10 +37,10 @@ class ButtonCheck extends Component {
37
  } ) } onClick={ this.checkAnswer }
38
  >
39
  <span className="instant-check__icon" />
40
- { __( 'Check answer', 'learnpress' ) }
41
 
42
  { ! answered && (
43
- <div className="instant-check__info" dangerouslySetInnerHTML={ { __html: __( 'You need to answer the question before check answer.', 'learnpress' ) } } />
44
  ) }
45
  </button>
46
  </>
37
  } ) } onClick={ this.checkAnswer }
38
  >
39
  <span className="instant-check__icon" />
40
+ { __( 'Check answers', 'learnpress' ) }
41
 
42
  { ! answered && (
43
+ <div className="instant-check__info" dangerouslySetInnerHTML={ { __html: __( 'You need to answer the question before checking the answer key.', 'learnpress' ) } } />
44
  ) }
45
  </button>
46
  </>
assets/src/apps/js/frontend/quiz/components/buttons/index.js CHANGED
@@ -14,7 +14,7 @@ class Buttons extends Component {
14
  if ( status === 'completed' ) {
15
  const { confirm, isOpen } = select( 'learnpress/modal' );
16
 
17
- if ( 'no' === confirm( __( 'Are you sure you want to retake quiz?', 'learnpress' ), this.startQuiz ) ) {
18
  ! isOpen() && btn && btn.removeAttribute( 'disabled' );
19
  return;
20
  }
@@ -102,7 +102,7 @@ class Buttons extends Component {
102
 
103
  const { confirm } = select( 'learnpress/modal' );
104
 
105
- if ( 'no' === confirm( __( 'Are you sure to submit quiz?', 'learnpress' ), this.submit ) ) {
106
  return;
107
  }
108
  submitQuiz();
14
  if ( status === 'completed' ) {
15
  const { confirm, isOpen } = select( 'learnpress/modal' );
16
 
17
+ if ( 'no' === confirm( __( 'Are you sure you want to retake the quiz?', 'learnpress' ), this.startQuiz ) ) {
18
  ! isOpen() && btn && btn.removeAttribute( 'disabled' );
19
  return;
20
  }
102
 
103
  const { confirm } = select( 'learnpress/modal' );
104
 
105
+ if ( 'no' === confirm( __( 'Are you sure to submit the quiz?', 'learnpress' ), this.submit ) ) {
106
  return;
107
  }
108
  submitQuiz();
assets/src/apps/js/frontend/quiz/components/status/index.js CHANGED
@@ -64,7 +64,7 @@ const Status = () => {
64
  const submit = () => {
65
  const { confirm } = select( 'learnpress/modal' );
66
 
67
- if ( 'no' === confirm( __( 'Are you sure to submit quiz?', 'learnpress' ), submit ) ) {
68
  return;
69
  }
70
 
64
  const submit = () => {
65
  const { confirm } = select( 'learnpress/modal' );
66
 
67
+ if ( 'no' === confirm( __( 'Are you sure to submit the quiz?', 'learnpress' ), submit ) ) {
68
  return;
69
  }
70
 
assets/src/apps/js/frontend/quiz/store/reducer.js CHANGED
@@ -127,13 +127,12 @@ const submitQuiz = ( state, action ) => {
127
 
128
  const questions = state.questions.map( ( question ) => {
129
  const newArgs = {};
130
-
131
  if ( state.reviewQuestions ) {
132
- if ( action.results.questions[ question.id ].explanation ) {
133
  newArgs.explanation = action.results.questions[ question.id ].explanation;
134
  }
135
 
136
- if ( action.results.questions[ question.id ].options ) {
137
  newArgs.options = action.results.questions[ question.id ].options;
138
  }
139
  }
127
 
128
  const questions = state.questions.map( ( question ) => {
129
  const newArgs = {};
 
130
  if ( state.reviewQuestions ) {
131
+ if ( action.results.questions[ question.id ]?.explanation ) {
132
  newArgs.explanation = action.results.questions[ question.id ].explanation;
133
  }
134
 
135
+ if ( action.results.questions[ question.id ]?.options ) {
136
  newArgs.options = action.results.questions[ question.id ].options;
137
  }
138
  }
assets/src/apps/js/frontend/single-course/student-list.js DELETED
@@ -1,96 +0,0 @@
1
-
2
- const studentListCourse = () => {
3
- const elementStudentList = document.querySelector( '.learnpress-course-student-list' );
4
-
5
- if ( ! elementStudentList ) {
6
- return;
7
- }
8
-
9
- const skeleton = elementStudentList.querySelector( '.lp-skeleton-animation' );
10
- const eleParents = elementStudentList.querySelector( '.content-student-list' );
11
-
12
- const Sekeleton = () => {
13
- const extraQuery = {
14
- status: '',
15
- paged: 1,
16
- };
17
-
18
- getResponse( eleParents, extraQuery );
19
-
20
- const select = document.querySelector( '.students-list-filter' );
21
-
22
- if ( select != null ) {
23
- select.addEventListener( 'change', function() {
24
- eleParents.innerHTML = '';
25
- skeleton.style.display = 'block';
26
- extraQuery.status = this.value;
27
- getResponse( eleParents, extraQuery );
28
- } );
29
- }
30
- };
31
-
32
- const getResponse = async ( ele, extraQuery, append = false, viewMoreEle ) => {
33
- const courseID = ele.dataset.id;
34
- const statusFilter = extraQuery?.status || '';
35
- const paged = extraQuery?.paged || 1;
36
-
37
- try {
38
- const response = await wp.apiFetch( {
39
- path: addQueryArgs( 'lp/v1/lazy-load/student-list', {
40
- courseId: courseID || lpGlobalSettings.post_id || '',
41
- status: statusFilter,
42
- paged,
43
- } ),
44
- method: 'GET',
45
- } );
46
-
47
- const { data, status, message } = response;
48
-
49
- if ( status === 'error' ) {
50
- throw new Error( message || 'Error' );
51
- }
52
-
53
- if ( append ) {
54
- ele.innerHTML += data.content;
55
- } else {
56
- ele.innerHTML = data.content;
57
- }
58
-
59
- if ( viewMoreEle ) {
60
- viewMoreEle.classList.remove( 'loading' );
61
-
62
- const paged = viewMoreEle.dataset.paged;
63
- const numberPage = viewMoreEle.dataset.number;
64
-
65
- if ( numberPage <= paged ) {
66
- viewMoreEle.remove();
67
- }
68
-
69
- viewMoreEle.dataset.paged = parseInt( paged ) + 1;
70
- }
71
- viewMoreStudentList( ele, extraQuery );
72
- } catch ( error ) {
73
- ele.insertAdjacentHTML( 'beforeend', `<div class="learn-press-message error" style="display:block">${ error.message || 'Error: Query lp/v1/lazy-load/course-student-list' }</div>` );
74
- }
75
-
76
- skeleton.style.display = 'none';
77
- };
78
-
79
- const viewMoreStudentList = ( ele, extraQuery ) => {
80
- const viewMoreEle = ele.querySelector( '.lp_student_list_button button.lp-button' );
81
-
82
- if ( viewMoreEle ) {
83
- viewMoreEle.addEventListener( 'click', ( e ) => {
84
- e.preventDefault();
85
-
86
- const paged = viewMoreEle && viewMoreEle.dataset.paged;
87
-
88
- viewMoreEle.classList.add( 'loading' );
89
-
90
- getResponse( ele.querySelector( 'ul.students' ), { ...extraQuery, ...{ paged } }, true, viewMoreEle );
91
- } );
92
- }
93
- };
94
-
95
- Sekeleton();
96
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config/settings/course.php CHANGED
@@ -5,7 +5,7 @@
5
  $generate_course_thumbnail = get_option( 'learn_press_generate_course_thumbnail', 'no' );
6
  $des_option_redirect_finish_course = wp_sprintf(
7
  '%s<br>%s',
8
- esc_html__( 'The site will be redirected to the URL added after clicking finish course button.', 'learnpress' ),
9
  esc_html__( 'Set blank, the site will be redirected to the single course page', 'learnpress' )
10
  );
11
 
@@ -21,7 +21,7 @@ return apply_filters(
21
  ),
22
  array(
23
  'title' => esc_html__( 'Review courses', 'learnpress' ),
24
- 'desc' => esc_html__( 'Courses created by instructors will be pending in review first.', 'learnpress' ),
25
  'id' => 'required_review',
26
  'default' => 'yes',
27
  'type' => 'checkbox',
@@ -31,18 +31,18 @@ return apply_filters(
31
  'id' => 'auto_enroll',
32
  'default' => 'yes',
33
  'type' => 'checkbox',
34
- 'desc' => esc_html__( 'Students will get started courses immediately after successfully purchased.', 'learnpress' ),
35
  ),
36
  array(
37
- 'title' => __( 'Enable confirmation popup finish course, complete item', 'learnpress' ),
38
- 'desc' => __( 'Show confirmation popup before finishing course or completing item.', 'learnpress' ),
39
  'id' => 'enable_popup_confirm_finish',
40
  'default' => 'yes',
41
  'type' => 'checkbox',
42
  ),
43
  array(
44
  'title' => esc_html__( 'Archive page layout', 'learnpress' ),
45
- 'desc' => esc_html__( 'Type display list course on Course Archive page', 'learnpress' ),
46
  'id' => 'archive_courses_layout',
47
  'default' => 'list',
48
  'type' => 'select',
@@ -50,7 +50,7 @@ return apply_filters(
50
  ),
51
  array(
52
  'title' => esc_html__( 'Courses per page', 'learnpress' ),
53
- 'desc' => esc_html__( 'Number of courses displayed per page.', 'learnpress' ),
54
  'id' => 'archive_course_limit',
55
  'default' => '8',
56
  'type' => 'number',
@@ -60,15 +60,15 @@ return apply_filters(
60
  'css' => 'min-width: 50px; width: 50px;',
61
  ),
62
  array(
63
- 'title' => esc_html__( 'Enable loading ajax Courses on the Course Archive page', 'learnpress' ),
64
- 'desc' => __( 'On/Off <i>loading ajax Courses</i>', 'learnpress' ),
65
  'id' => 'courses_load_ajax',
66
  'default' => 'yes',
67
  'type' => 'checkbox',
68
  ),
69
  array(
70
- 'title' => esc_html__( 'Not run Ajax when reloading Course Archive page', 'learnpress' ),
71
- 'desc' => esc_html__( 'Ajax is only applied when selecting pagination, filtering, searching and sorting. Not applicable when reloading Course Archive page.', 'learnpress' ),
72
  'id' => 'courses_first_no_ajax',
73
  'default' => 'no',
74
  'type' => 'checkbox',
@@ -81,7 +81,7 @@ return apply_filters(
81
  'type' => 'image-dimensions',
82
  ),
83
  array(
84
- 'title' => esc_html__( 'Redirect when finish course', 'learnpress' ),
85
  'id' => 'course_finish_redirect',
86
  'default' => '',
87
  'type' => 'url',
@@ -106,14 +106,14 @@ return apply_filters(
106
  'id' => 'section_per_page',
107
  'default' => 1,
108
  'type' => 'number',
109
- 'desc' => esc_html__( 'Number of sections displayed per page ( Enter -1 for display all sections).', 'learnpress' ),
110
  ),
111
  array(
112
  'title' => esc_html__( 'Course Item Per Page', 'learnpress' ),
113
  'id' => 'course_item_per_page',
114
  'default' => 10,
115
  'type' => 'number',
116
- 'desc' => esc_html__( 'Number of course items displayed per page in section ( Enter -1 for display all course items).', 'learnpress' ),
117
  ),
118
  array(
119
  'type' => 'sectionend',
5
  $generate_course_thumbnail = get_option( 'learn_press_generate_course_thumbnail', 'no' );
6
  $des_option_redirect_finish_course = wp_sprintf(
7
  '%s<br>%s',
8
+ esc_html__( 'The site will be redirected to the URL added after clicking the finish course button.', 'learnpress' ),
9
  esc_html__( 'Set blank, the site will be redirected to the single course page', 'learnpress' )
10
  );
11
 
21
  ),
22
  array(
23
  'title' => esc_html__( 'Review courses', 'learnpress' ),
24
+ 'desc' => esc_html__( 'Courses created by instructors will be pending review first.', 'learnpress' ),
25
  'id' => 'required_review',
26
  'default' => 'yes',
27
  'type' => 'checkbox',
31
  'id' => 'auto_enroll',
32
  'default' => 'yes',
33
  'type' => 'checkbox',
34
+ 'desc' => esc_html__( 'Students will get started on courses immediately after successfully purchasing them.', 'learnpress' ),
35
  ),
36
  array(
37
+ 'title' => __( 'Confirmation popup', 'learnpress' ),
38
+ 'desc' => __( 'Show a confirmation popup before finishing the course or completing the item.', 'learnpress' ),
39
  'id' => 'enable_popup_confirm_finish',
40
  'default' => 'yes',
41
  'type' => 'checkbox',
42
  ),
43
  array(
44
  'title' => esc_html__( 'Archive page layout', 'learnpress' ),
45
+ 'desc' => esc_html__( 'Display the List course type on the Course Archive page.', 'learnpress' ),
46
  'id' => 'archive_courses_layout',
47
  'default' => 'list',
48
  'type' => 'select',
50
  ),
51
  array(
52
  'title' => esc_html__( 'Courses per page', 'learnpress' ),
53
+ 'desc' => esc_html__( 'The number of displayed courses per page.', 'learnpress' ),
54
  'id' => 'archive_course_limit',
55
  'default' => '8',
56
  'type' => 'number',
60
  'css' => 'min-width: 50px; width: 50px;',
61
  ),
62
  array(
63
+ 'title' => esc_html__( 'Loading ajax Courses', 'learnpress' ),
64
+ 'desc' => __( 'On/Off <i>loading ajax courses on the Course Archive page </i>.', 'learnpress' ),
65
  'id' => 'courses_load_ajax',
66
  'default' => 'yes',
67
  'type' => 'checkbox',
68
  ),
69
  array(
70
+ 'title' => esc_html__( 'Do not run Ajax when reloading the Course Archive page', 'learnpress' ),
71
+ 'desc' => esc_html__( 'Ajax is only applied when selecting pagination, filtering, searching, and sorting. Not applicable when reloading the Course Archive page.', 'learnpress' ),
72
  'id' => 'courses_first_no_ajax',
73
  'default' => 'no',
74
  'type' => 'checkbox',
81
  'type' => 'image-dimensions',
82
  ),
83
  array(
84
+ 'title' => esc_html__( 'Redirect when finishing the course', 'learnpress' ),
85
  'id' => 'course_finish_redirect',
86
  'default' => '',
87
  'type' => 'url',
106
  'id' => 'section_per_page',
107
  'default' => 1,
108
  'type' => 'number',
109
+ 'desc' => esc_html__( 'The number of displayed sections per page (Enter -1 to display all sections).', 'learnpress' ),
110
  ),
111
  array(
112
  'title' => esc_html__( 'Course Item Per Page', 'learnpress' ),
113
  'id' => 'course_item_per_page',
114
  'default' => 10,
115
  'type' => 'number',
116
+ 'desc' => esc_html__( 'The number of displayed course items per page in a section (Enter -1 to display all course items).', 'learnpress' ),
117
  ),
118
  array(
119
  'type' => 'sectionend',
config/settings/general.php CHANGED
@@ -48,7 +48,7 @@ return apply_filters(
48
  'id' => 'logout_redirect_page_id',
49
  'default' => '',
50
  'type' => 'pages-dropdown',
51
- 'desc' => __( 'The page where user will be redirected to after logging out.', 'learnpress' ),
52
  ),
53
  array(
54
  'type' => 'sectionend',
@@ -76,14 +76,14 @@ return apply_filters(
76
  ),
77
  array(
78
  'title' => esc_html__( 'Thousands separator', 'learnpress' ),
79
- 'desc_tip' => esc_html__( 'This sets the thousand separator of displayed prices.', 'learnpress' ),
80
  'id' => 'thousands_separator',
81
  'default' => ',',
82
  'type' => 'text',
83
  'css' => 'min-width: 50px; width: 50px;',
84
  ),
85
  array(
86
- 'title' => esc_html__( 'Decimals separator', 'learnpress' ),
87
  'desc_tip' => esc_html__( 'This sets the decimal separator of displayed prices.', 'learnpress' ),
88
  'id' => 'decimals_separator',
89
  'default' => '.',
@@ -91,8 +91,8 @@ return apply_filters(
91
  'css' => 'min-width: 50px; width: 50px;',
92
  ),
93
  array(
94
- 'title' => esc_html__( 'Number of decimals', 'learnpress' ),
95
- 'desc_tip' => esc_html__( 'This sets the number of decimal points shown in displayed prices.', 'learnpress' ),
96
  'id' => 'number_of_decimals',
97
  'default' => '2',
98
  'type' => 'number',
@@ -110,8 +110,8 @@ return apply_filters(
110
  'id' => 'publish_profile',
111
  'default' => 'no',
112
  'type' => 'checkbox',
113
- 'desc_tip' => esc_html__( 'This option will add a sub-item "Privacy" under Setting tab on the Profile page. If users want to publish or hide their course, quiz tab when other users visit their profile page, they need to enable/disable that option in the Privacy section.', 'learnpress' ),
114
- 'desc' => __( 'Public all user profile page (Overview tab only).', 'learnpress' ),
115
  ),
116
  array(
117
  'title' => esc_html__( 'Instructor registration', 'learnpress' ),
48
  'id' => 'logout_redirect_page_id',
49
  'default' => '',
50
  'type' => 'pages-dropdown',
51
+ 'desc' => __( 'The page where the user will be redirected to after logging out.', 'learnpress' ),
52
  ),
53
  array(
54
  'type' => 'sectionend',
76
  ),
77
  array(
78
  'title' => esc_html__( 'Thousands separator', 'learnpress' ),
79
+ 'desc_tip' => esc_html__( 'This sets the thousands separator of displayed prices.', 'learnpress' ),
80
  'id' => 'thousands_separator',
81
  'default' => ',',
82
  'type' => 'text',
83
  'css' => 'min-width: 50px; width: 50px;',
84
  ),
85
  array(
86
+ 'title' => esc_html__( 'Decimal separator', 'learnpress' ),
87
  'desc_tip' => esc_html__( 'This sets the decimal separator of displayed prices.', 'learnpress' ),
88
  'id' => 'decimals_separator',
89
  'default' => '.',
91
  'css' => 'min-width: 50px; width: 50px;',
92
  ),
93
  array(
94
+ 'title' => esc_html__( 'The number of decimals', 'learnpress' ),
95
+ 'desc_tip' => esc_html__( 'This sets the number of decimal points shown in the displayed prices.', 'learnpress' ),
96
  'id' => 'number_of_decimals',
97
  'default' => '2',
98
  'type' => 'number',
110
  'id' => 'publish_profile',
111
  'default' => 'no',
112
  'type' => 'checkbox',
113
+ 'desc_tip' => esc_html__( 'This option will add a sub-item \"Privacy\" under the Setting tab on the Profile page. If users want to publish or hide their course, or quiz tab when other users visit their profile page, they need to enable/disable that option in the Privacy section.', 'learnpress' ),
114
+ 'desc' => __( 'Public all user profile pages (only the overview tab).', 'learnpress' ),
115
  ),
116
  array(
117
  'title' => esc_html__( 'Instructor registration', 'learnpress' ),
inc/abstract-settings.php CHANGED
@@ -86,7 +86,7 @@ abstract class LP_Abstract_Settings {
86
  if ( $settings ) {
87
  LP_Meta_Box_Helper::output_fields( $settings );
88
  } else {
89
- echo esc_html__( 'No setting available.', 'learnpress' );
90
  }
91
  }
92
 
86
  if ( $settings ) {
87
  LP_Meta_Box_Helper::output_fields( $settings );
88
  } else {
89
+ echo esc_html__( 'No settings available.', 'learnpress' );
90
  }
91
  }
92
 
inc/abstracts/abstract-addon.php CHANGED
@@ -314,6 +314,10 @@ class LP_Addon {
314
  * Load text domain
315
  */
316
  public function load_text_domain() {
 
 
 
 
317
  $plugin_path = dirname( $this->plugin_file );
318
  $plugin_folder = basename( $plugin_path );
319
  $text_domain = empty( $this->text_domain ) ? $plugin_folder : $this->text_domain;
314
  * Load text domain
315
  */
316
  public function load_text_domain() {
317
+ if ( empty( $this->plugin_file ) ) {
318
+ return;
319
+ }
320
+
321
  $plugin_path = dirname( $this->plugin_file );
322
  $plugin_folder = basename( $plugin_path );
323
  $text_domain = empty( $this->text_domain ) ? $plugin_folder : $this->text_domain;
inc/abstracts/abstract-object-data.php CHANGED
@@ -15,7 +15,6 @@ if ( ! class_exists( 'LP_Abstract_Object_Data' ) ) {
15
  * Class LP_Abstract_Object_Data
16
  */
17
  abstract class LP_Abstract_Object_Data {
18
-
19
  /**
20
  * @var int
21
  */
@@ -246,12 +245,6 @@ if ( ! class_exists( 'LP_Abstract_Object_Data' ) ) {
246
  $this->_set_data( $key, $value, $extra );
247
  }
248
  } elseif ( $key_or_data ) {
249
- $data = $extra ? $this->_extra_data : $this->_data;
250
- $changes = $extra ? $this->_extra_data_changes : $this->_changes;
251
-
252
- if ( $key_or_data === 'total' ) {
253
- }
254
-
255
  if ( $extra ) {
256
  // Do not allow to add extra data with the same key in data
257
  if ( ! array_key_exists( $key_or_data, $this->_data ) ) {
@@ -262,16 +255,15 @@ if ( ! class_exists( 'LP_Abstract_Object_Data' ) ) {
262
  if ( ! is_string( $key_or_data ) && ! is_numeric( $key_or_data ) ) {
263
  throw new Exception( 'error' );
264
  }
 
265
  // Only change the data is already existed
266
- if ( array_key_exists( $key_or_data, $this->_data ) ) {
267
  $this->_data[ $key_or_data ] = $value;
268
- } else {
269
- $this->_extra_data[ $key_or_data ] = $value;
270
- }
271
- } catch ( Exception $ex ) {
272
- print_r( $key_or_data );
273
- print_r( $ex->getMessage() );
274
- die( __FILE__ . '::' . __FUNCTION__ );
275
  }
276
  }
277
  }
@@ -281,39 +273,50 @@ if ( ! class_exists( 'LP_Abstract_Object_Data' ) ) {
281
  * Set extra data
282
  *
283
  * @param array|string $key_or_data
284
- * @param string $value
285
  * @return $this
286
  */
287
  public function set_data( $key_or_data, $value = '' ) {
288
- $this->_set_data( $key_or_data, $value, true );
289
  return $this;
290
  }
291
 
292
  /**
 
 
 
293
  * @param $key
294
  * @param $value
 
 
 
295
  */
296
- public function set_data_date( $key, $value ) {
297
- if ( ! $value instanceof LP_Datetime ) {
298
- $value = new LP_Datetime( $value );
 
299
  }
300
 
301
- $this->_set_data( $key, $value, true );
 
 
302
  }
303
 
304
  /**
305
  * @param $key
306
  * @param $value
 
307
  */
308
  protected function _set_data_date( $key, $value, $extra = false ) {
309
- if ( ! $value instanceof LP_Datetime ) {
310
- $value = new LP_Datetime( $value );
311
- }
312
-
313
- $this->_set_data( $key, $value, $extra );
314
  }
315
 
 
 
 
316
  public function set_data_null_date( $key ) {
 
317
  $this->_set_data( $key, LP_Datetime::getSqlNullDate() );
318
  }
319
 
@@ -341,7 +344,7 @@ if ( ! class_exists( 'LP_Abstract_Object_Data' ) ) {
341
  // If there is at least one method failed
342
  if ( $errors ) {
343
  $errors = array_map( array( $this, 'prefix_set_method' ), $errors );
344
- throw new Exception( sprintf( __( 'The following these functions %1$s do not exists in %2$s', 'learnpress' ), join( ',', $errors ), get_class( $this ) ) );
345
  }
346
  }
347
 
@@ -421,24 +424,28 @@ if ( ! class_exists( 'LP_Abstract_Object_Data' ) ) {
421
  * Get all features are supported by question.
422
  *
423
  * @return array
 
424
  */
425
  public function get_supports() {
 
426
  return LP_Global::get_object_supports( $this->object_type );
427
  }
428
 
429
  /**
430
  * @param $value
 
431
  */
432
- public function set_no_cache( $value ) {
433
  $this->_no_cache = $value;
434
- }
435
 
436
  /**
437
  * @return bool
 
438
  */
439
- public function get_no_cache() {
440
  return $this->_no_cache;
441
- }
442
 
443
  /**
444
  * Read all metas and set to object
15
  * Class LP_Abstract_Object_Data
16
  */
17
  abstract class LP_Abstract_Object_Data {
 
18
  /**
19
  * @var int
20
  */
245
  $this->_set_data( $key, $value, $extra );
246
  }
247
  } elseif ( $key_or_data ) {
 
 
 
 
 
 
248
  if ( $extra ) {
249
  // Do not allow to add extra data with the same key in data
250
  if ( ! array_key_exists( $key_or_data, $this->_data ) ) {
255
  if ( ! is_string( $key_or_data ) && ! is_numeric( $key_or_data ) ) {
256
  throw new Exception( 'error' );
257
  }
258
+
259
  // Only change the data is already existed
260
+ // if ( array_key_exists( $key_or_data, $this->_data ) ) {
261
  $this->_data[ $key_or_data ] = $value;
262
+ // } else {
263
+ // $this->_extra_data[ $key_or_data ] = $value;
264
+ // }
265
+ } catch ( Throwable $ex ) {
266
+ error_log( $ex->getMessage() );
 
 
267
  }
268
  }
269
  }
273
  * Set extra data
274
  *
275
  * @param array|string $key_or_data
276
+ * @param string|mixed $value
277
  * @return $this
278
  */
279
  public function set_data( $key_or_data, $value = '' ) {
280
+ $this->_set_data( $key_or_data, $value );
281
  return $this;
282
  }
283
 
284
  /**
285
+ * Set data datetime
286
+ * if $value is empty, not set is LP_Datetime object
287
+ *
288
  * @param $key
289
  * @param $value
290
+ *
291
+ * @version 4.0.1
292
+ * @return LP_Abstract_Object_Data
293
  */
294
+ public function set_data_date( $key, $value ): LP_Abstract_Object_Data {
295
+ $lp_date = '';
296
+ if ( ! empty( $value ) ) {
297
+ $lp_date = new LP_Datetime( $value );
298
  }
299
 
300
+ $this->set_data( $key, $lp_date );
301
+
302
+ return $this;
303
  }
304
 
305
  /**
306
  * @param $key
307
  * @param $value
308
+ * @deprecated 4.1.7.3
309
  */
310
  protected function _set_data_date( $key, $value, $extra = false ) {
311
+ _deprecated_function( __FUNCTION__, '4.1.7.3', 'set_data_date' );
312
+ $this->set_data_date( $key, $value );
 
 
 
313
  }
314
 
315
+ /**
316
+ * @deprecated 4.1.7.3
317
+ */
318
  public function set_data_null_date( $key ) {
319
+ _deprecated_function( __METHOD__, '4.1.7.3' );
320
  $this->_set_data( $key, LP_Datetime::getSqlNullDate() );
321
  }
322
 
344
  // If there is at least one method failed
345
  if ( $errors ) {
346
  $errors = array_map( array( $this, 'prefix_set_method' ), $errors );
347
+ throw new Exception( sprintf( __( 'The following functions %1$s do not exist in %2$s', 'learnpress' ), join( ',', $errors ), get_class( $this ) ) );
348
  }
349
  }
350
 
424
  * Get all features are supported by question.
425
  *
426
  * @return array
427
+ * @deprecated 4.1.7.3
428
  */
429
  public function get_supports() {
430
+ _deprecated_function( __FUNCTION__, '4.1.7.3' );
431
  return LP_Global::get_object_supports( $this->object_type );
432
  }
433
 
434
  /**
435
  * @param $value
436
+ * @deprecated 4.1.7.3
437
  */
438
+ /*public function set_no_cache( $value ) {
439
  $this->_no_cache = $value;
440
+ }*/
441
 
442
  /**
443
  * @return bool
444
+ * @deprecated 4.1.7.3
445
  */
446
+ /*public function get_no_cache() {
447
  return $this->_no_cache;
448
+ }*/
449
 
450
  /**
451
  * Read all metas and set to object
inc/abstracts/abstract-rest-api.php CHANGED
@@ -47,7 +47,7 @@ abstract class LP_Abstract_API {
47
  }
48
 
49
  public function rest_api_includes() {
50
- // include_once realpath( LP_PLUGIN_PATH . 'inc/rest-api/class-lp-rest-authentication.php' );
51
  }
52
 
53
  /**
47
  }
48
 
49
  public function rest_api_includes() {
50
+
51
  }
52
 
53
  /**
inc/admin/class-lp-admin-ajax.php CHANGED
@@ -216,7 +216,7 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
216
  $post_type = learn_press_get_post_type( $post_id );
217
 
218
  if ( ! $post_id ) {
219
- learn_press_send_json_error( __( 'Ops! ID not found', 'learnpress' ) );
220
  } else {
221
 
222
  $new_item_id = '';
@@ -259,7 +259,7 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
259
  }
260
 
261
  if ( is_wp_error( $new_item_id ) ) {
262
- learn_press_send_json_error( __( 'Duplicate post fail, please try again', 'learnpress' ) );
263
  } else {
264
  learn_press_send_json_success( admin_url( 'post.php?post=' . $new_item_id . '&action=edit' ) );
265
  }
@@ -408,7 +408,7 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
408
  // verify nonce
409
  $nonce = learn_press_get_request( 'remove_nonce' );
410
  if ( ! wp_verify_nonce( $nonce, 'remove_order_item' ) ) {
411
- die( __( 'Check nonce failed', 'learnpress' ) );
412
  }
413
 
414
  // validate order
@@ -516,7 +516,7 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
516
  * @param mixed $params (Optional) List of keys want to get from payload.
517
  *
518
  * @return array|bool|mixed|object
519
- * @depecated 4.1.6.9
520
  */
521
  /*public static function get_php_input( $params = '' ) {
522
  static $data = false;
@@ -547,7 +547,7 @@ if ( ! class_exists( 'LP_Admin_Ajax' ) ) {
547
  * Normally, parse and assign to $_POST or $_GET.
548
  *
549
  * @param $var
550
- * @depecated 4.1.6.9
551
  */
552
  /*public static function parsePhpInput( &$var ) {
553
  $data = self::get_php_input();
216
  $post_type = learn_press_get_post_type( $post_id );
217
 
218
  if ( ! $post_id ) {
219
+ learn_press_send_json_error( __( 'Oops! ID not found', 'learnpress' ) );
220
  } else {
221
 
222
  $new_item_id = '';
259
  }
260
 
261
  if ( is_wp_error( $new_item_id ) ) {
262
+ learn_press_send_json_error( __( 'Duplicate post failed. Please try again', 'learnpress' ) );
263
  } else {
264
  learn_press_send_json_success( admin_url( 'post.php?post=' . $new_item_id . '&action=edit' ) );
265
  }
408
  // verify nonce
409
  $nonce = learn_press_get_request( 'remove_nonce' );
410
  if ( ! wp_verify_nonce( $nonce, 'remove_order_item' ) ) {
411
+ die( __( 'Nonce check failed', 'learnpress' ) );
412
  }
413
 
414
  // validate order
516
  * @param mixed $params (Optional) List of keys want to get from payload.
517
  *
518
  * @return array|bool|mixed|object
519
+ * @deprecated 4.1.6.9
520
  */
521
  /*public static function get_php_input( $params = '' ) {
522
  static $data = false;
547
  * Normally, parse and assign to $_POST or $_GET.
548
  *
549
  * @param $var
550
+ * @deprecated 4.1.6.9
551
  */
552
  /*public static function parsePhpInput( &$var ) {
553
  $data = self::get_php_input();
inc/admin/class-lp-admin-assets.php CHANGED
@@ -29,7 +29,7 @@ class LP_Admin_Assets extends LP_Abstract_Assets {
29
  'learn-press-meta-box-order' => apply_filters(
30
  'learn-press/meta-box-order/script-data',
31
  array(
32
- 'i18n_error' => esc_html__( 'Ooops! Error.', 'learnpress' ),
33
  'i18n_guest' => esc_html__( 'Guest', 'learnpress' ),
34
  )
35
  ),
@@ -37,7 +37,7 @@ class LP_Admin_Assets extends LP_Abstract_Assets {
37
  'learn-press/upgrade/script-data',
38
  array(
39
  'i18n_confirm' => esc_html__(
40
- 'Before taking this action, we strongly recommend you should backup your site first before proceeding. Should any issues come at hand, do not hesitate to contact our Support team. Are you sure to proceed the update protocol?',
41
  'learnpress'
42
  ),
43
  )
29
  'learn-press-meta-box-order' => apply_filters(
30
  'learn-press/meta-box-order/script-data',
31
  array(
32
+ 'i18n_error' => esc_html__( 'Oops! Error.', 'learnpress' ),
33
  'i18n_guest' => esc_html__( 'Guest', 'learnpress' ),
34
  )
35
  ),
37
  'learn-press/upgrade/script-data',
38
  array(
39
  'i18n_confirm' => esc_html__(
40
+ 'Before taking this action, we strongly recommend you backup your site first before proceeding. If you encounter any problems, please do not hesitate to contact our support team. Are you sure to proceed with the update protocol?',
41
  'learnpress'
42
  ),
43
  )
inc/admin/class-lp-admin-menu.php CHANGED
@@ -33,7 +33,6 @@ class LP_Admin_Menu {
33
  */
34
  public function __construct() {
35
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
36
- //add_action( 'admin_menu', array( $this, 'notify_new_course' ) );
37
 
38
  if ( apply_filters( 'learn_press_show_admin_bar_courses_page', true ) ) {
39
  add_action( 'admin_bar_menu', array( $this, 'admin_bar_menus' ), 50 );
@@ -46,19 +45,19 @@ class LP_Admin_Menu {
46
  include_once 'sub-menus/abstract-submenu.php';
47
  }
48
 
 
 
 
 
 
 
 
49
  public function admin_bar_menus( $wp_admin_bar ) {
50
  if ( ! is_admin() || ! is_user_logged_in() ) {
51
  return;
52
  }
53
 
54
- if ( ! is_user_member_of_blog() && ! is_super_admin() ) {
55
- return;
56
- }
57
-
58
- if ( get_option( 'page_on_front' ) == learn_press_get_page_id( 'courses' ) ) {
59
- return;
60
- }
61
-
62
  $wp_admin_bar->add_node(
63
  array(
64
  'parent' => 'site-name',
@@ -67,6 +66,16 @@ class LP_Admin_Menu {
67
  'href' => learn_press_get_page_link( 'courses' ),
68
  )
69
  );
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  /**
@@ -94,23 +103,37 @@ class LP_Admin_Menu {
94
  );
95
 
96
  // Default submenu items
97
- $menu_items = array();
98
- $menu_items['statistic'] = include_once 'sub-menus/class-lp-submenu-statistics.php';
99
- $menu_items['addons'] = include_once 'sub-menus/class-lp-submenu-addons.php';
100
- $menu_items['settings'] = include_once 'sub-menus/class-lp-submenu-settings.php';
101
- $menu_items['tools'] = include_once 'sub-menus/class-lp-submenu-tools.php';
102
-
103
- // Deprecated hooks
104
- $menu_items = apply_filters( 'learn_press_menu_items', $menu_items );
105
 
106
  $menu_items = apply_filters( 'learn-press/admin/menu-items', $menu_items );
107
 
108
  // Sort menu items by it's priority
109
- // uasort( $menu_items, array( $this, 'sort_menu_items' ) );
110
  uasort( $menu_items, 'learn_press_sort_list_by_priority_callback' );
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  if ( $menu_items ) {
113
- foreach ( $menu_items as $item ) {
114
  if ( is_string( $item ) && class_exists( $item ) ) {
115
  $item = new $item();
116
  }
@@ -119,15 +142,20 @@ class LP_Admin_Menu {
119
  continue;
120
  }
121
 
 
 
 
 
 
 
122
  add_submenu_page(
123
  'learn_press',
124
  $item->get_page_title(),
125
  $item->get_menu_title(),
126
  $item->get_capability(),
127
  $item->get_id(),
128
- array( $item, 'display' )
129
  );
130
-
131
  }
132
  $this->menu_items = $menu_items;
133
  }
@@ -151,22 +179,6 @@ class LP_Admin_Menu {
151
  return $this->menu_items;
152
  }
153
 
154
- /*
155
- * Notify an administrator with pending courses
156
- */
157
- public function notify_new_course() {
158
- global $menu;
159
-
160
- $current_user = wp_get_current_user();
161
-