LearnPress – WordPress LMS Plugin - Version 4.1.0

Version Description

~ Added: feature "Allow repurchase option". Manager can set fixed: Reset/Keep course progress of course or allow student choice. ~ Fixed: show incorrect "Active Courses" on page profile. ~ Fixed: show fake student. ~ Fixed: duplicate label on form Register custom fields.

Download this release

Release Info

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

Code changes from version 4.0.9 to 4.1.0

Files changed (32) hide show
  1. assets/css/learnpress.css +36 -3
  2. assets/js/admin/learnpress.min.js +1 -1
  3. assets/js/dist/frontend/profile.js +2 -2
  4. assets/js/dist/frontend/profile.min.js +1 -1
  5. assets/js/dist/frontend/question-types.min.js +1 -1
  6. assets/js/dist/frontend/quiz.js +2 -2
  7. assets/js/dist/frontend/quiz.min.js +2 -2
  8. assets/js/dist/frontend/single-course.js +85 -14
  9. assets/js/dist/frontend/single-course.min.js +1 -1
  10. assets/js/dist/frontend/single-curriculum.min.js +1 -1
  11. assets/src/apps/js/frontend/profile/statistic.js +2 -2
  12. assets/src/apps/js/frontend/quiz/components/attempts/index.js +1 -1
  13. assets/src/apps/js/frontend/quiz/components/result/index.js +1 -1
  14. assets/src/apps/js/frontend/single-course.js +50 -6
  15. assets/src/js/admin/learnpress.js +59 -0
  16. inc/admin/views/meta-boxes/course/settings.php +22 -5
  17. inc/admin/views/meta-boxes/fields/class-lp-meta-box-fields.php +14 -0
  18. inc/admin/views/meta-boxes/fields/select.php +1 -1
  19. inc/course/abstract-course.php +34 -33
  20. inc/course/class-lp-course.php +4 -0
  21. inc/curds/class-lp-user-curd.php +10 -6
  22. inc/databases/class-lp-user-items-db.php +64 -16
  23. inc/order/lp-order-functions.php +3 -2
  24. inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php +56 -1
  25. inc/rest-api/v1/frontend/class-lp-rest-profile-controller.php +15 -8
  26. inc/user/abstract-lp-user.php +11 -2
  27. inc/user/class-lp-profile.php +1 -0
  28. inc/user/class-lp-user-factory.php +102 -8
  29. inc/user/lp-user-functions.php +17 -14
  30. learnpress.php +1 -1
  31. readme.txt +13 -7
  32. templates/profile/tabs/courses.php +4 -1
assets/css/learnpress.css CHANGED
@@ -1487,6 +1487,12 @@
1487
  box-shadow: 0 0 0 2px #666 !important;
1488
  }
1489
 
 
 
 
 
 
 
1490
  .learn-press-form-login form[name="learn-press-login"] > p > label,
1491
  .learn-press-form-register form[name="learn-press-login"] > p > label {
1492
  color: #666;
@@ -1522,6 +1528,15 @@
1522
  text-decoration: none;
1523
  }
1524
 
 
 
 
 
 
 
 
 
 
1525
  .lp-password-input {
1526
  display: flex;
1527
  flex-direction: column;
@@ -5396,10 +5411,11 @@ a {
5396
  }
5397
  }
5398
 
5399
- .lp-content-area:after, .lp-content-area:before {
5400
- content: "";
5401
  display: table;
5402
  clear: both;
 
5403
  }
5404
 
5405
  .lp-archive-courses.loading ul.learn-press-courses {
@@ -5428,9 +5444,9 @@ a {
5428
  right: 0;
5429
  bottom: 0;
5430
  left: 0;
 
5431
  background: #fff;
5432
  content: "";
5433
- opacity: 0.8%;
5434
  }
5435
 
5436
  .lp-archive-courses form[name="search-course"] {
@@ -6582,6 +6598,23 @@ input[type="radio"]:nth-child(19):checked ~ .switch-btn:nth-child(20)::before {
6582
  }
6583
  }
6584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6585
  #learn-press-course .course-summary-sidebar .course-sidebar-preview {
6586
  margin-bottom: 35px;
6587
  background: #fff;
1487
  box-shadow: 0 0 0 2px #666 !important;
1488
  }
1489
 
1490
+ .learn-press-form-login .form-fields .form-field.required label::after,
1491
+ .learn-press-form-register .form-fields .form-field.required label::after {
1492
+ content: ' *';
1493
+ display: inline;
1494
+ }
1495
+
1496
  .learn-press-form-login form[name="learn-press-login"] > p > label,
1497
  .learn-press-form-register form[name="learn-press-login"] > p > label {
1498
  color: #666;
1528
  text-decoration: none;
1529
  }
1530
 
1531
+ .required label {
1532
+ font-weight: bold;
1533
+ }
1534
+
1535
+ .required label:after {
1536
+ content: ' *';
1537
+ display: inline;
1538
+ }
1539
+
1540
  .lp-password-input {
1541
  display: flex;
1542
  flex-direction: column;
5411
  }
5412
  }
5413
 
5414
+ .lp-content-area::after,
5415
+ .lp-content-area::before {
5416
  display: table;
5417
  clear: both;
5418
+ content: "";
5419
  }
5420
 
5421
  .lp-archive-courses.loading ul.learn-press-courses {
5444
  right: 0;
5445
  bottom: 0;
5446
  left: 0;
5447
+ opacity: 0.8%;
5448
  background: #fff;
5449
  content: "";
 
5450
  }
5451
 
5452
  .lp-archive-courses form[name="search-course"] {
6598
  }
6599
  }
6600
 
6601
+ .lp_allow_repuchase_select {
6602
+ padding: 20px;
6603
+ background: #f7f7f7;
6604
+ }
6605
+
6606
+ .lp_allow_repuchase_select > ul {
6607
+ padding: 0;
6608
+ list-style: none;
6609
+ }
6610
+
6611
+ .lp_allow_repuchase_select > a {
6612
+ display: inline-block;
6613
+ margin-top: 10px;
6614
+ color: #fff;
6615
+ background-color: #222;
6616
+ }
6617
+
6618
  #learn-press-course .course-summary-sidebar .course-sidebar-preview {
6619
  margin-bottom: 35px;
6620
  background: #fff;
assets/js/admin/learnpress.min.js CHANGED
@@ -1 +1 @@
1
- const $=jQuery,$doc=$(document),$win=$(window),makePaymentsSortable=function(){$(".learn-press-payments.sortable tbody").sortable({handle:".dashicons-menu",helper:(e,t)=>(t.children().each((function(){$(this).width($(this).width())})),t),axis:"y",start(e,t){},stop(e,t){},update(e,t){const a=$(this).children().map((function(){return $(this).find('input[name="payment-order"]').val()})).get();$.post({url:"",data:{"lp-ajax":"update-payment-order",order:a},success(e){}})}})},lpMetaboxCustomFields=()=>{$(".lp-metabox__custom-fields").on("click",".lp-metabox-custom-field-button",(function(){const t=$(this).data("row").replace(/lp_metabox_custom_fields_key/gi,Math.floor(1e3*Math.random())+1);return $(this).closest("table").find("tbody").append(t),e($(this).closest(".lp-metabox__custom-fields")),!1})),$(".lp-metabox__custom-fields").on("click","a.delete",(function(){return $(this).closest("tr").remove(),e($(this).closest(".lp-metabox__custom-fields")),!1})),$(".lp-metabox__custom-fields tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,update(t,a){e($(this).closest(".lp-metabox__custom-fields"))}});const e=e=>{e.find("tbody tr").each((function(e,t){$(this).find(".sort .count").val(e)}))}},lpMetaboxExtraInfo=()=>{$(".lp_course_extra_meta_box__add").on("click",(function(){return $(this).closest(".lp_course_extra_meta_box__content").find(".lp_course_extra_meta_box__fields").append($(this).data("add")),$(this).closest(".lp_course_extra_meta_box__content").find(".lp_course_extra_meta_box__field").last().find("input").trigger("focus"),!1})),document.querySelectorAll(".lp_course_extra_meta_box__fields").forEach(e=>{e.addEventListener("keydown",t=>{const a=e.querySelectorAll(".lp_course_extra_meta_box__input");if(13===t.keyCode)return t.preventDefault(),a.forEach(e=>{e.blur()}),!1})}),$(".lp_course_extra_meta_box__fields").on("click","a.delete",(function(){return $(this).closest(".lp_course_extra_meta_box__field").remove(),!1})),$(".lp_course_extra_meta_box__fields").sortable({items:".lp_course_extra_meta_box__field",cursor:"grab",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65}),$(".lp_course_faq_meta_box__add").on("click",(function(){return $(this).closest(".lp_course_faq_meta_box__content").find(".lp_course_faq_meta_box__fields").append($(this).data("add")),!1})),document.querySelectorAll(".lp_course_faq_meta_box__fields").forEach(e=>{e.addEventListener("keydown",t=>{const a=e.querySelectorAll(".lp_course_faq_meta_box__field input"),s=e.querySelectorAll(".lp_course_faq_meta_box__field textarea");if(13===t.keyCode)return t.preventDefault(),[...a,...s].forEach(e=>{e.blur()}),!1})}),$(".lp_course_faq_meta_box__fields").on("click","a.delete",(function(){return $(this).closest(".lp_course_faq_meta_box__field").remove(),!1})),$(".lp_course_faq_meta_box__fields").sortable({items:".lp_course_faq_meta_box__field",cursor:"grab",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65})},lpGetFinalQuiz=()=>{[...document.querySelectorAll(".lp-metabox-get-final-quiz")].map(t=>{t.addEventListener("click",a=>{a.preventDefault();const s=t.textContent,i=t.dataset.loading,l=document.querySelector(".lp-metabox-evaluate-final_quiz");l&&l.remove(),t.textContent=i,e(t).then(e=>{const{message:a,data:i}=e;t.textContent=s;const l=document.createElement("div");l.className="lp-metabox-evaluate-final_quiz",l.innerHTML=i||a,t.parentNode.insertBefore(l,t.nextSibling)})})});const e=async e=>{if(!lpGlobalSettings.root)return;return await wp.apiFetch({path:"lp/v1/admin/course/get_final_quiz",method:"POST",data:{courseId:e.dataset.postid||""}})}},lpMetaboxColorPicker=()=>{$(".lp-metabox__colorpick").iris({change(e,t){$(this).parent().find(".colorpickpreview").css({backgroundColor:t.color.toString()})},hide:!0,border:!0}).on("click focus",(function(e){e.stopPropagation(),$(".iris-picker").hide(),$(this).closest("td").find(".iris-picker").show(),$(this).data("original-value",$(this).val())})).on("change",(function(){if($(this).is(".iris-error")){$(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?$(this).val($(this).data("original-value")).trigger("change"):$(this).val("").trigger("change")}})),$("body").on("click",(function(){$(".iris-picker").hide()}))},lpMetaboxImage=()=>{$(".lp-metabox-field__image").each((e,t)=>{let a;const s=$(t).find(".lp-metabox-field__image--add"),i=$(t).find(".lp-metabox-field__image--delete"),l=$(t).find(".lp-metabox-field__image--image"),n=$(t).find(".lp-metabox-field__image--id");n.val()?(s.hide(),i.show()):(s.show(),i.hide()),s.on("click",e=>{e.preventDefault(),a||(a=wp.media({title:s.data("choose"),button:{text:s.data("update")},multiple:!1}),a.on("select",(function(){const e=a.state().get("selection").first().toJSON(),t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<div class="lp-metabox-field__image--inner"><img src="'+t+'" alt="" style="max-width:100%;"/></div>'),n.val(e.id),s.hide(),i.show()}))),a.open()}),i.on("click",e=>{e.preventDefault(),l.html(""),s.show(),i.hide(),n.val("")})})},lpMetaboxImageAdvanced=()=>{$(".lp-metabox-field__image-advanced").each((e,t)=>{let a;const s=$(t).find("#lp-gallery-images-ids"),i=$(t).find(".lp-metabox-field__image-advanced-images"),l=$(t).find(".lp-metabox-field__image-advanced-upload > a");$(l).on("click",e=>{e.preventDefault(),a||(a=wp.media({title:l.data("choose"),button:{text:l.data("update")},states:[new wp.media.controller.Library({title:l.data("choose"),filterable:"all",multiple:!0})]}),a.on("select",(function(){const e=a.state().get("selection");let t=s.val();e.forEach((function(e){if((e=e.toJSON()).id){t=t?t+","+e.id:e.id;const a=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;i.append('<li class="image" data-attachment_id="'+e.id+'"><img src="'+a+'" /><ul class="actions"><li><a href="#" class="delete" title="'+l.data("delete")+'">'+l.data("text")+"</a></li></ul></li>")}})),s.val(t)}))),a.open()}),i.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"lp-metabox-sortable-placeholder",start(e,t){t.item.css("background-color","#f6f6f6")},stop(e,t){t.item.removeAttr("style")},update(){let e="";i.find("li.image").css("cursor","default").each((function(){const t=$(this).attr("data-attachment_id");e=e+t+","})),s.val(e)}}),$(i).find("li.image").each((e,t)=>{$(t).find("a.delete").on("click",()=>{$(t).remove();let e="";return $(i).find("li.image").css("cursor","default").each((function(){const t=$(this).attr("data-attachment_id");e=e+t+","})),s.val(e),!1})})})},lpMetaboxCourseTabs=()=>{$(document.body).on("lp-metabox-course-tab-panels",(function(){$("ul.lp-meta-box__course-tab__tabs").show(),$("ul.lp-meta-box__course-tab__tabs a").on("click",(function(e){e.preventDefault();const t=$(this).closest("div.lp-meta-box__course-tab");$("ul.lp-meta-box__course-tab__tabs li",t).removeClass("active"),$(this).parent().addClass("active"),$("div.lp-meta-box-course-panels",t).hide(),$($(this).attr("href")).show()})),$("div.lp-meta-box__course-tab").each((function(){$(this).find("ul.lp-meta-box__course-tab__tabs li").eq(0).find("a").trigger("click")}))})).trigger("lp-metabox-course-tab-panels")},initTooltips=function(){$(".learn-press-tooltip").each((function(){const e=$(this),t=$.extend({title:"data-tooltip",offset:10,gravity:"s"},e.data());e.tipsy(t)}))},initSelect2=function(){$.fn.select2&&$(".lp-select-2 select").select2()},initSingleCoursePermalink=function(){$doc.on("change",'.learn-press-single-course-permalink input[type="radio"]',(function(){const e=$(this).closest(".learn-press-single-course-permalink");e.hasClass("custom-base")?e.find('input[type="text"]').prop("readonly",!1):e.siblings(".custom-base").find('input[type="text"]').prop("readonly",!0)})).on("change","input.learn-press-course-base",(function(){$("#course_permalink_structure").val($(this).val())})).on("focus","#course_permalink_structure",(function(){$("#learn_press_custom_permalink").click()})).on("change","#learn_press_courses_page_id",(function(){$("tr.learn-press-courses-page-id").toggleClass("hide-if-js",!parseInt(this.value))}))},togglePaymentStatus=function(e){e.preventDefault();const t=$(this).closest("tr"),a=($(this),t.find(".status").hasClass("enabled")?"no":"yes");$.ajax({url:"",data:{"lp-ajax":"update-payment-status",status:a,id:t.data("payment")},success(e){e=LP.parseJSON(e);for(const t in e)$("#payment-"+t+" .status").toggleClass("enabled",e[t])}})},updateEmailStatus=function(){(function(){$.post({url:window.location.href,data:{"lp-ajax":"update_email_status",status:$(this).parent().hasClass("enabled")?"no":"yes",id:$(this).data("id")},dataType:"text",success:$.proxy((function(e){e=LP.parseJSON(e);for(const t in e)$("#email-"+t+" .status").toggleClass("enabled",e[t])}),this)})}).apply(this)},lpMetaboxsalePriceDate=()=>{if(!$("#course-settings").length)return;$(".lp_sale_dates_fields").each((function(){const e=$(this),t=e.closest("div.lp-meta-box-course-panels");let a=!1;e.find("input").each((function(){""!==$(this).val()&&(a=!0)})),a?(t.find(".lp_sale_price_schedule").hide(),t.find(".lp_sale_dates_fields").show()):(t.find(".lp_sale_price_schedule").show(),t.find(".lp_sale_dates_fields").hide())})),$(".lp-meta-box-course-panels").on("click",".lp_sale_price_schedule",(function(){const e=$(this).closest("div.lp-meta-box-course-panels");return $(this).hide(),e.find(".lp_cancel_sale_schedule").show(),e.find(".lp_sale_dates_fields").show(),!1})),$(".lp-meta-box-course-panels").on("click",".lp_cancel_sale_schedule",(function(){const e=$(this).closest("div.lp-meta-box-course-panels");return $(this).hide(),e.find(".lp_sale_price_schedule").show(),e.find(".lp_sale_dates_fields").hide(),e.find(".lp_sale_dates_fields").find("input").val(""),!1})),$(document).on("input","#price_course_data",(function(e){const t=$(this),a=$(".lp_meta_box_regular_price"),s=$(".lp_meta_box_sale_price"),i=$(e.target).attr("id");t.find(".learn-press-tip-floating").remove(),parseInt(s.val())>parseInt(a.val())&&("_lp_price"===i?a.parent(".form-field").append('<div class="learn-press-tip-floating">'+lpAdminCourseEditorSettings.i18n.notice_price+"</div>"):"_lp_sale_price"===i&&s.parent(".form-field").append('<div class="learn-press-tip-floating">'+lpAdminCourseEditorSettings.i18n.notice_sale_price+"</div>"))}));const e=function(e){const t=$(e).is("#_lp_sale_start")?"minDate":"maxDate",a=$("minDate"===t?"#_lp_sale_end":"#_lp_sale_start"),s=$(e).datetimepicker("getDate");$(a).datetimepicker("option",t,s),$(e).trigger("change")};$(".lp_sale_dates_fields").each((function(){$(this).find("input").datetimepicker({timeFormat:"HH:mm",separator:" ",dateFormat:"yy-mm-dd",showButtonPanel:!0,onSelect(){e($(this))}}),$(this).find("input").each((function(){e($(this))}))}))},lpHidePassingGrade=()=>{const e=["evaluate_final_quiz","evaluate_final_assignment"];[...document.querySelectorAll("input[type=radio][name=_lp_course_result]")].map((t,a)=>(t.checked&&e.includes(t.value)&&$("._lp_passing_condition_field").hide(),null)),$("input[type=radio][name=_lp_course_result]").on("change",(function(t){e.includes(t.target.value)?$("._lp_passing_condition_field").hide():$("._lp_passing_condition_field").show()}))},callbackFilterTemplates=function(){const e=$(this);if(e.hasClass("current"))return!1;const t=$("#learn-press-template-files"),a=t.find("tr[data-template]"),s=e.data("template"),i=e.data("filter");return e.addClass("current").siblings("a").removeClass("current"),s?a.map((function(){$(this).toggleClass("hide-if-js",$(this).data("template")!==s)})):i?a.map((function(){$(this).toggleClass("hide-if-js","yes"!==$(this).data("filter-"+i))})):a.removeClass("hide-if-js"),$("#learn-press-no-templates").toggleClass("hide-if-js",!!t.find("tr.template-row:not(.hide-if-js):first").length),!1},toggleEmails=function(e){e.preventDefault();const t=$(this).data("status");$.ajax({url:"",data:{"lp-ajax":"update_email_status",status:t},success(e){e=LP.parseJSON(e);for(const t in e)$("#email-"+t+" .status").toggleClass("enabled",e[t])}})},importCourses=function(){const t=$("#learn-press-install-sample-data-notice"),a=$(this).attr("data-action");a&&(e.preventDefault(),"yes"===a?t.find(".install-sample-data-notice").slideUp().siblings(".install-sample-data-loading").slideDown():t.fadeOut(),$.ajax({url:ajaxurl,dataType:"html",type:"post",data:{action:"learnpress_install_sample_data",yes:a},success(e){(e=LP.parseJSON(e)).url?$.ajax({url:e.url,success(){t.find(".install-sample-data-notice").html(e.message).slideDown().siblings(".install-sample-data-loading").slideUp()}}):t.find(".install-sample-data-notice").html(e.message).slideDown().siblings(".install-sample-data-loading").slideUp()}}))},onReady=function(){$(".learn-press-payments.sortable tbody").sortable({handle:".dashicons-menu",helper:(e,t)=>(t.children().each((function(){$(this).width($(this).width())})),t),axis:"y",start(e,t){},stop(e,t){},update(e,t){const a=$(this).children().map((function(){return $(this).find('input[name="payment-order"]').val()})).get();$.post({url:"",data:{"lp-ajax":"update-payment-order",order:a},success(e){}})}}),$.fn.select2&&$(".lp-select-2 select").select2(),$(".learn-press-tooltip").each((function(){const e=$(this),t=$.extend({title:"data-tooltip",offset:10,gravity:"s"},e.data());e.tipsy(t)})),$doc.on("change",'.learn-press-single-course-permalink input[type="radio"]',(function(){const e=$(this).closest(".learn-press-single-course-permalink");e.hasClass("custom-base")?e.find('input[type="text"]').prop("readonly",!1):e.siblings(".custom-base").find('input[type="text"]').prop("readonly",!0)})).on("change","input.learn-press-course-base",(function(){$("#course_permalink_structure").val($(this).val())})).on("focus","#course_permalink_structure",(function(){$("#learn_press_custom_permalink").click()})).on("change","#learn_press_courses_page_id",(function(){$("tr.learn-press-courses-page-id").toggleClass("hide-if-js",!parseInt(this.value))})),lpMetaboxCourseTabs(),lpMetaboxCustomFields(),lpMetaboxColorPicker(),lpMetaboxImageAdvanced(),$(".lp-metabox-field__image").each((e,t)=>{let a;const s=$(t).find(".lp-metabox-field__image--add"),i=$(t).find(".lp-metabox-field__image--delete"),l=$(t).find(".lp-metabox-field__image--image"),n=$(t).find(".lp-metabox-field__image--id");n.val()?(s.hide(),i.show()):(s.show(),i.hide()),s.on("click",e=>{e.preventDefault(),a||(a=wp.media({title:s.data("choose"),button:{text:s.data("update")},multiple:!1}),a.on("select",(function(){const e=a.state().get("selection").first().toJSON(),t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<div class="lp-metabox-field__image--inner"><img src="'+t+'" alt="" style="max-width:100%;"/></div>'),n.val(e.id),s.hide(),i.show()}))),a.open()}),i.on("click",e=>{e.preventDefault(),l.html(""),s.show(),i.hide(),n.val("")})}),lpMetaboxsalePriceDate(),lpMetaboxExtraInfo(),lpHidePassingGrade(),lpGetFinalQuiz(),$(document).on("click",".learn-press-payments .status .dashicons",togglePaymentStatus).on("click",".change-email-status",updateEmailStatus).on("click",".learn-press-filter-template",callbackFilterTemplates).on("click","#learn-press-enable-emails, #learn-press-disable-emails",toggleEmails).on("click","#learn-press-install-sample-data-notice a",importCourses)};$(document).ready(onReady);
1
+ const $=jQuery,$doc=$(document),$win=$(window),makePaymentsSortable=function(){$(".learn-press-payments.sortable tbody").sortable({handle:".dashicons-menu",helper:(e,t)=>(t.children().each((function(){$(this).width($(this).width())})),t),axis:"y",start(e,t){},stop(e,t){},update(e,t){const a=$(this).children().map((function(){return $(this).find('input[name="payment-order"]').val()})).get();$.post({url:"",data:{"lp-ajax":"update-payment-order",order:a},success(e){}})}})},lpMetaboxCustomFields=()=>{$(".lp-metabox__custom-fields").on("click",".lp-metabox-custom-field-button",(function(){const t=$(this).data("row").replace(/lp_metabox_custom_fields_key/gi,Math.floor(1e3*Math.random())+1);return $(this).closest("table").find("tbody").append(t),e($(this).closest(".lp-metabox__custom-fields")),!1})),$(".lp-metabox__custom-fields").on("click","a.delete",(function(){return $(this).closest("tr").remove(),e($(this).closest(".lp-metabox__custom-fields")),!1})),$(".lp-metabox__custom-fields tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,update(t,a){e($(this).closest(".lp-metabox__custom-fields"))}});const e=e=>{e.find("tbody tr").each((function(e,t){$(this).find(".sort .count").val(e)}))}},lpMetaboxExtraInfo=()=>{$(".lp_course_extra_meta_box__add").on("click",(function(){return $(this).closest(".lp_course_extra_meta_box__content").find(".lp_course_extra_meta_box__fields").append($(this).data("add")),$(this).closest(".lp_course_extra_meta_box__content").find(".lp_course_extra_meta_box__field").last().find("input").trigger("focus"),!1})),document.querySelectorAll(".lp_course_extra_meta_box__fields").forEach(e=>{e.addEventListener("keydown",t=>{const a=e.querySelectorAll(".lp_course_extra_meta_box__input");if(13===t.keyCode)return t.preventDefault(),a.forEach(e=>{e.blur()}),!1})}),$(".lp_course_extra_meta_box__fields").on("click","a.delete",(function(){return $(this).closest(".lp_course_extra_meta_box__field").remove(),!1})),$(".lp_course_extra_meta_box__fields").sortable({items:".lp_course_extra_meta_box__field",cursor:"grab",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65}),$(".lp_course_faq_meta_box__add").on("click",(function(){return $(this).closest(".lp_course_faq_meta_box__content").find(".lp_course_faq_meta_box__fields").append($(this).data("add")),!1})),document.querySelectorAll(".lp_course_faq_meta_box__fields").forEach(e=>{e.addEventListener("keydown",t=>{const a=e.querySelectorAll(".lp_course_faq_meta_box__field input"),s=e.querySelectorAll(".lp_course_faq_meta_box__field textarea");if(13===t.keyCode)return t.preventDefault(),[...a,...s].forEach(e=>{e.blur()}),!1})}),$(".lp_course_faq_meta_box__fields").on("click","a.delete",(function(){return $(this).closest(".lp_course_faq_meta_box__field").remove(),!1})),$(".lp_course_faq_meta_box__fields").sortable({items:".lp_course_faq_meta_box__field",cursor:"grab",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65})},lpGetFinalQuiz=()=>{[...document.querySelectorAll(".lp-metabox-get-final-quiz")].map(t=>{t.addEventListener("click",a=>{a.preventDefault();const s=t.textContent,i=t.dataset.loading,l=document.querySelector(".lp-metabox-evaluate-final_quiz");l&&l.remove(),t.textContent=i,e(t).then(e=>{const{message:a,data:i}=e;t.textContent=s;const l=document.createElement("div");l.className="lp-metabox-evaluate-final_quiz",l.innerHTML=i||a,t.parentNode.insertBefore(l,t.nextSibling)})})});const e=async e=>{if(!lpGlobalSettings.root)return;return await wp.apiFetch({path:"lp/v1/admin/course/get_final_quiz",method:"POST",data:{courseId:e.dataset.postid||""}})}},lpMetaboxColorPicker=()=>{$(".lp-metabox__colorpick").iris({change(e,t){$(this).parent().find(".colorpickpreview").css({backgroundColor:t.color.toString()})},hide:!0,border:!0}).on("click focus",(function(e){e.stopPropagation(),$(".iris-picker").hide(),$(this).closest("td").find(".iris-picker").show(),$(this).data("original-value",$(this).val())})).on("change",(function(){if($(this).is(".iris-error")){$(this).data("original-value").match(/^\#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/)?$(this).val($(this).data("original-value")).trigger("change"):$(this).val("").trigger("change")}})),$("body").on("click",(function(){$(".iris-picker").hide()}))},lpMetaboxImage=()=>{$(".lp-metabox-field__image").each((e,t)=>{let a;const s=$(t).find(".lp-metabox-field__image--add"),i=$(t).find(".lp-metabox-field__image--delete"),l=$(t).find(".lp-metabox-field__image--image"),o=$(t).find(".lp-metabox-field__image--id");o.val()?(s.hide(),i.show()):(s.show(),i.hide()),s.on("click",e=>{e.preventDefault(),a||(a=wp.media({title:s.data("choose"),button:{text:s.data("update")},multiple:!1}),a.on("select",(function(){const e=a.state().get("selection").first().toJSON(),t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<div class="lp-metabox-field__image--inner"><img src="'+t+'" alt="" style="max-width:100%;"/></div>'),o.val(e.id),s.hide(),i.show()}))),a.open()}),i.on("click",e=>{e.preventDefault(),l.html(""),s.show(),i.hide(),o.val("")})})},lpMetaboxImageAdvanced=()=>{$(".lp-metabox-field__image-advanced").each((e,t)=>{let a;const s=$(t).find("#lp-gallery-images-ids"),i=$(t).find(".lp-metabox-field__image-advanced-images"),l=$(t).find(".lp-metabox-field__image-advanced-upload > a");$(l).on("click",e=>{e.preventDefault(),a||(a=wp.media({title:l.data("choose"),button:{text:l.data("update")},states:[new wp.media.controller.Library({title:l.data("choose"),filterable:"all",multiple:!0})]}),a.on("select",(function(){const e=a.state().get("selection");let t=s.val();e.forEach((function(e){if((e=e.toJSON()).id){t=t?t+","+e.id:e.id;const a=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;i.append('<li class="image" data-attachment_id="'+e.id+'"><img src="'+a+'" /><ul class="actions"><li><a href="#" class="delete" title="'+l.data("delete")+'">'+l.data("text")+"</a></li></ul></li>")}})),s.val(t)}))),a.open()}),i.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"lp-metabox-sortable-placeholder",start(e,t){t.item.css("background-color","#f6f6f6")},stop(e,t){t.item.removeAttr("style")},update(){let e="";i.find("li.image").css("cursor","default").each((function(){const t=$(this).attr("data-attachment_id");e=e+t+","})),s.val(e)}}),$(i).find("li.image").each((e,t)=>{$(t).find("a.delete").on("click",()=>{$(t).remove();let e="";return $(i).find("li.image").css("cursor","default").each((function(){const t=$(this).attr("data-attachment_id");e=e+t+","})),s.val(e),!1})})})},lpMetaboxCourseTabs=()=>{$(document.body).on("lp-metabox-course-tab-panels",(function(){$("ul.lp-meta-box__course-tab__tabs").show(),$("ul.lp-meta-box__course-tab__tabs a").on("click",(function(e){e.preventDefault();const t=$(this).closest("div.lp-meta-box__course-tab");$("ul.lp-meta-box__course-tab__tabs li",t).removeClass("active"),$(this).parent().addClass("active"),$("div.lp-meta-box-course-panels",t).hide(),$($(this).attr("href")).show()})),$("div.lp-meta-box__course-tab").each((function(){$(this).find("ul.lp-meta-box__course-tab__tabs li").eq(0).find("a").trigger("click")}))})).trigger("lp-metabox-course-tab-panels")},lpMetaboxCondition=()=>{document.querySelectorAll(".lp-meta-box .form-field").forEach(e=>{e.hasAttribute("data-show")&&e.dataset.show?lpMetaboxConditionType(e,e.dataset.show,"show"):e.hasAttribute("data-hide")&&e.dataset.hide&&lpMetaboxConditionType(e,e.dataset.hide,"hide")})},lpMetaboxConditionType=(e,t,a="show")=>{const s=JSON.parse(t),i=document.querySelectorAll(`input[id^="${s[0]}"]`),l="="===s[1]?"=":"!=",o=s[2],n=(t,s,i)=>{switch(t){case"checkbox":let t=o;"yes"===o||"1"===o||1===o||"true"===o?t=!0:"no"!==o&&"0"!==o&&0!==o&&"false"!==o||(t=!1),"!="==l&&t!==Boolean(i?i.checked:s.checked)||"="==l&&t==Boolean(i?i.checked:s.checked)?e.style.display="show"===a?"flex":"none":e.style.display="show"===a?"none":"flex"}};i.forEach(e=>{const t=e.getAttribute("type");n(t,e),e.addEventListener("change",a=>{const s=a.target;n(t,e,s)})})},initTooltips=function(){$(".learn-press-tooltip").each((function(){const e=$(this),t=$.extend({title:"data-tooltip",offset:10,gravity:"s"},e.data());e.tipsy(t)}))},initSelect2=function(){$.fn.select2&&$(".lp-select-2 select").select2()},initSingleCoursePermalink=function(){$doc.on("change",'.learn-press-single-course-permalink input[type="radio"]',(function(){const e=$(this).closest(".learn-press-single-course-permalink");e.hasClass("custom-base")?e.find('input[type="text"]').prop("readonly",!1):e.siblings(".custom-base").find('input[type="text"]').prop("readonly",!0)})).on("change","input.learn-press-course-base",(function(){$("#course_permalink_structure").val($(this).val())})).on("focus","#course_permalink_structure",(function(){$("#learn_press_custom_permalink").click()})).on("change","#learn_press_courses_page_id",(function(){$("tr.learn-press-courses-page-id").toggleClass("hide-if-js",!parseInt(this.value))}))},togglePaymentStatus=function(e){e.preventDefault();const t=$(this).closest("tr"),a=($(this),t.find(".status").hasClass("enabled")?"no":"yes");$.ajax({url:"",data:{"lp-ajax":"update-payment-status",status:a,id:t.data("payment")},success(e){e=LP.parseJSON(e);for(const t in e)$("#payment-"+t+" .status").toggleClass("enabled",e[t])}})},updateEmailStatus=function(){(function(){$.post({url:window.location.href,data:{"lp-ajax":"update_email_status",status:$(this).parent().hasClass("enabled")?"no":"yes",id:$(this).data("id")},dataType:"text",success:$.proxy((function(e){e=LP.parseJSON(e);for(const t in e)$("#email-"+t+" .status").toggleClass("enabled",e[t])}),this)})}).apply(this)},lpMetaboxsalePriceDate=()=>{if(!$("#course-settings").length)return;$(".lp_sale_dates_fields").each((function(){const e=$(this),t=e.closest("div.lp-meta-box-course-panels");let a=!1;e.find("input").each((function(){""!==$(this).val()&&(a=!0)})),a?(t.find(".lp_sale_price_schedule").hide(),t.find(".lp_sale_dates_fields").show()):(t.find(".lp_sale_price_schedule").show(),t.find(".lp_sale_dates_fields").hide())})),$(".lp-meta-box-course-panels").on("click",".lp_sale_price_schedule",(function(){const e=$(this).closest("div.lp-meta-box-course-panels");return $(this).hide(),e.find(".lp_cancel_sale_schedule").show(),e.find(".lp_sale_dates_fields").show(),!1})),$(".lp-meta-box-course-panels").on("click",".lp_cancel_sale_schedule",(function(){const e=$(this).closest("div.lp-meta-box-course-panels");return $(this).hide(),e.find(".lp_sale_price_schedule").show(),e.find(".lp_sale_dates_fields").hide(),e.find(".lp_sale_dates_fields").find("input").val(""),!1})),$(document).on("input","#price_course_data",(function(e){const t=$(this),a=$(".lp_meta_box_regular_price"),s=$(".lp_meta_box_sale_price"),i=$(e.target).attr("id");t.find(".learn-press-tip-floating").remove(),parseInt(s.val())>parseInt(a.val())&&("_lp_price"===i?a.parent(".form-field").append('<div class="learn-press-tip-floating">'+lpAdminCourseEditorSettings.i18n.notice_price+"</div>"):"_lp_sale_price"===i&&s.parent(".form-field").append('<div class="learn-press-tip-floating">'+lpAdminCourseEditorSettings.i18n.notice_sale_price+"</div>"))}));const e=function(e){const t=$(e).is("#_lp_sale_start")?"minDate":"maxDate",a=$("minDate"===t?"#_lp_sale_end":"#_lp_sale_start"),s=$(e).datetimepicker("getDate");$(a).datetimepicker("option",t,s),$(e).trigger("change")};$(".lp_sale_dates_fields").each((function(){$(this).find("input").datetimepicker({timeFormat:"HH:mm",separator:" ",dateFormat:"yy-mm-dd",showButtonPanel:!0,onSelect(){e($(this))}}),$(this).find("input").each((function(){e($(this))}))}))},lpHidePassingGrade=()=>{const e=["evaluate_final_quiz","evaluate_final_assignment"];[...document.querySelectorAll("input[type=radio][name=_lp_course_result]")].map((t,a)=>(t.checked&&e.includes(t.value)&&$("._lp_passing_condition_field").hide(),null)),$("input[type=radio][name=_lp_course_result]").on("change",(function(t){e.includes(t.target.value)?$("._lp_passing_condition_field").hide():$("._lp_passing_condition_field").show()}))},callbackFilterTemplates=function(){const e=$(this);if(e.hasClass("current"))return!1;const t=$("#learn-press-template-files"),a=t.find("tr[data-template]"),s=e.data("template"),i=e.data("filter");return e.addClass("current").siblings("a").removeClass("current"),s?a.map((function(){$(this).toggleClass("hide-if-js",$(this).data("template")!==s)})):i?a.map((function(){$(this).toggleClass("hide-if-js","yes"!==$(this).data("filter-"+i))})):a.removeClass("hide-if-js"),$("#learn-press-no-templates").toggleClass("hide-if-js",!!t.find("tr.template-row:not(.hide-if-js):first").length),!1},toggleEmails=function(e){e.preventDefault();const t=$(this).data("status");$.ajax({url:"",data:{"lp-ajax":"update_email_status",status:t},success(e){e=LP.parseJSON(e);for(const t in e)$("#email-"+t+" .status").toggleClass("enabled",e[t])}})},importCourses=function(){const t=$("#learn-press-install-sample-data-notice"),a=$(this).attr("data-action");a&&(e.preventDefault(),"yes"===a?t.find(".install-sample-data-notice").slideUp().siblings(".install-sample-data-loading").slideDown():t.fadeOut(),$.ajax({url:ajaxurl,dataType:"html",type:"post",data:{action:"learnpress_install_sample_data",yes:a},success(e){(e=LP.parseJSON(e)).url?$.ajax({url:e.url,success(){t.find(".install-sample-data-notice").html(e.message).slideDown().siblings(".install-sample-data-loading").slideUp()}}):t.find(".install-sample-data-notice").html(e.message).slideDown().siblings(".install-sample-data-loading").slideUp()}}))},onReady=function(){$(".learn-press-payments.sortable tbody").sortable({handle:".dashicons-menu",helper:(e,t)=>(t.children().each((function(){$(this).width($(this).width())})),t),axis:"y",start(e,t){},stop(e,t){},update(e,t){const a=$(this).children().map((function(){return $(this).find('input[name="payment-order"]').val()})).get();$.post({url:"",data:{"lp-ajax":"update-payment-order",order:a},success(e){}})}}),$.fn.select2&&$(".lp-select-2 select").select2(),$(".learn-press-tooltip").each((function(){const e=$(this),t=$.extend({title:"data-tooltip",offset:10,gravity:"s"},e.data());e.tipsy(t)})),$doc.on("change",'.learn-press-single-course-permalink input[type="radio"]',(function(){const e=$(this).closest(".learn-press-single-course-permalink");e.hasClass("custom-base")?e.find('input[type="text"]').prop("readonly",!1):e.siblings(".custom-base").find('input[type="text"]').prop("readonly",!0)})).on("change","input.learn-press-course-base",(function(){$("#course_permalink_structure").val($(this).val())})).on("focus","#course_permalink_structure",(function(){$("#learn_press_custom_permalink").click()})).on("change","#learn_press_courses_page_id",(function(){$("tr.learn-press-courses-page-id").toggleClass("hide-if-js",!parseInt(this.value))})),lpMetaboxCourseTabs(),lpMetaboxCustomFields(),lpMetaboxColorPicker(),lpMetaboxImageAdvanced(),$(".lp-metabox-field__image").each((e,t)=>{let a;const s=$(t).find(".lp-metabox-field__image--add"),i=$(t).find(".lp-metabox-field__image--delete"),l=$(t).find(".lp-metabox-field__image--image"),o=$(t).find(".lp-metabox-field__image--id");o.val()?(s.hide(),i.show()):(s.show(),i.hide()),s.on("click",e=>{e.preventDefault(),a||(a=wp.media({title:s.data("choose"),button:{text:s.data("update")},multiple:!1}),a.on("select",(function(){const e=a.state().get("selection").first().toJSON(),t=e.sizes&&e.sizes.thumbnail?e.sizes.thumbnail.url:e.url;l.append('<div class="lp-metabox-field__image--inner"><img src="'+t+'" alt="" style="max-width:100%;"/></div>'),o.val(e.id),s.hide(),i.show()}))),a.open()}),i.on("click",e=>{e.preventDefault(),l.html(""),s.show(),i.hide(),o.val("")})}),lpMetaboxsalePriceDate(),lpMetaboxExtraInfo(),lpHidePassingGrade(),lpGetFinalQuiz(),document.querySelectorAll(".lp-meta-box .form-field").forEach(e=>{e.hasAttribute("data-show")&&e.dataset.show?lpMetaboxConditionType(e,e.dataset.show,"show"):e.hasAttribute("data-hide")&&e.dataset.hide&&lpMetaboxConditionType(e,e.dataset.hide,"hide")}),$(document).on("click",".learn-press-payments .status .dashicons",togglePaymentStatus).on("click",".change-email-status",updateEmailStatus).on("click",".learn-press-filter-template",callbackFilterTemplates).on("click","#learn-press-enable-emails, #learn-press-disable-emails",toggleEmails).on("click","#learn-press-install-sample-data-notice a",importCourses)};$(document).ready(onReady);
assets/js/dist/frontend/profile.js CHANGED
@@ -413,9 +413,9 @@ var courseStatistics = function courseStatistics() {
413
  response = _context.sent;
414
 
415
  if (response.status === 'success' && response.data) {
416
- ele.innerHTML += response.data;
417
  } else {
418
- ele.innerHTML += "<div class=\"lp-ajax-message error\" style=\"display:block\">".concat(response.message && response.message, "</div>");
419
  }
420
 
421
  _context.next = 10;
413
  response = _context.sent;
414
 
415
  if (response.status === 'success' && response.data) {
416
+ ele.innerHTML = response.data;
417
  } else {
418
+ ele.innerHTML = "<div class=\"lp-ajax-message error\" style=\"display:block\">".concat(response.message && response.message, "</div>");
419
  }
420
 
421
  _context.next = 10;
assets/js/dist/frontend/profile.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.profile=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=24)}({24:function(e,t,r){"use strict";r.r(t);var n=r(5);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var l=function(){var e=document.querySelectorAll(".learn-press-course-tab__filter__content");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target,a=JSON.parse(n.dataset.ajax);r(n,a),t.unobserve(n)}}))}));c(e).map((function(e){return t.observe(e)}))}document.querySelectorAll(".learn-press-course-tab-filters").forEach((function(e){var t=e.querySelectorAll(".learn-press-filters a");t.forEach((function(r){r.addEventListener("click",(function(n){n.preventDefault();var a=r.dataset.tab;c(t).map((function(e){e.classList.remove("active")})),r.classList.add("active"),c(e.querySelectorAll(".learn-press-course-tab__filter__content")).map((function(e){e.style.display="none",e.dataset.tab===a&&(e.style.display="")}))}))}))}));document.querySelectorAll(".learn-press-profile-course__tab__inner").forEach((function(e){var t=e.querySelectorAll("li> a");t.forEach((function(e){e.addEventListener("click",(function(r){r.preventDefault();var n=e.dataset.tab;c(t).map((function(e){e.classList.remove("active")})),e.classList.add("active"),c(document.querySelectorAll(".learn-press-course-tab-filters")).map((function(e){e.style.display="none",e.dataset.tab===n&&(e.style.display="")}))}))}))}));var r=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var o,i,s,c,u,l,f=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=f.length>2&&void 0!==f[2]&&f[2],i=f.length>3&&void 0!==f[3]&&f[3],e.prev=2,e.next=5,wp.apiFetch({path:Object(n.addQueryArgs)("lp/v1/profile/course-tab",r),method:"GET"});case 5:(s=e.sent)&&((c=t.querySelector(".lp-skeleton-animation"))&&c.remove(),"success"===s.status&&s.data?o?t.innerHTML+=s.data:t.innerHTML=s.data:o?t.innerHTML+='<div class="lp-ajax-message" style="display:block">'.concat(s.message&&s.message,"</div>"):t.innerHTML='<div class="lp-ajax-message" style="display:block">'.concat(s.message&&s.message,"</div>"),i&&(i.classList.remove("loading"),u=i.dataset.paged,i.dataset.number<=u&&i.remove(),i.dataset.paged=parseInt(u)+1),a(t,r)),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),o?t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>"):t.innerHTML='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>"),i&&(i.classList.remove("loading"),l=i.dataset.paged,i.dataset.number<=l&&i.remove(),i.dataset.paged=parseInt(l)+1);case 13:case"end":return e.stop()}}),e,null,[[2,9]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){s(o,n,a,i,c,"next",e)}function c(e){s(o,n,a,i,c,"throw",e)}i(void 0)}))});return function(e,r){return t.apply(this,arguments)}}(),a=function(e,t){var n=e.querySelector("button[data-paged]");n&&n.addEventListener("click",(function(a){a.preventDefault();var i=n&&n.dataset.paged;n.classList.add("loading");var s="list"===t.layout?".lp_profile_course_progress":".learn-press-courses";r(e.querySelector(s),o(o({},t),{paged:i}),!0,n)}))}}};function f(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function p(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var v=function(){var e=document.querySelectorAll(".learn-press-profile-course__statistic");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target,a=JSON.parse(n.dataset.ajax);r(n,a),t.unobserve(n)}}))}));p(e).map((function(e){return t.observe(e)}))}var r=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,wp.apiFetch({path:Object(n.addQueryArgs)("lp/v1/profile/statistic",r),method:"GET"});case 3:"success"===(a=e.sent).status&&a.data?t.innerHTML+=a.data:t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(a.message&&a.message,"</div>"),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,s,"next",e)}function s(e){f(o,n,a,i,s,"throw",e)}i(void 0)}))});return function(e,r){return t.apply(this,arguments)}}()}};document.addEventListener("DOMContentLoaded",(function(e){l(),v()}))},5:function(e,t){e.exports=window.wp.url}});
1
+ this.LP=this.LP||{},this.LP.profile=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=24)}({24:function(e,t,r){"use strict";r.r(t);var n=r(5);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var l=function(){var e=document.querySelectorAll(".learn-press-course-tab__filter__content");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target,a=JSON.parse(n.dataset.ajax);r(n,a),t.unobserve(n)}}))}));c(e).map((function(e){return t.observe(e)}))}document.querySelectorAll(".learn-press-course-tab-filters").forEach((function(e){var t=e.querySelectorAll(".learn-press-filters a");t.forEach((function(r){r.addEventListener("click",(function(n){n.preventDefault();var a=r.dataset.tab;c(t).map((function(e){e.classList.remove("active")})),r.classList.add("active"),c(e.querySelectorAll(".learn-press-course-tab__filter__content")).map((function(e){e.style.display="none",e.dataset.tab===a&&(e.style.display="")}))}))}))}));document.querySelectorAll(".learn-press-profile-course__tab__inner").forEach((function(e){var t=e.querySelectorAll("li> a");t.forEach((function(e){e.addEventListener("click",(function(r){r.preventDefault();var n=e.dataset.tab;c(t).map((function(e){e.classList.remove("active")})),e.classList.add("active"),c(document.querySelectorAll(".learn-press-course-tab-filters")).map((function(e){e.style.display="none",e.dataset.tab===n&&(e.style.display="")}))}))}))}));var r=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var o,i,s,c,u,l,f=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=f.length>2&&void 0!==f[2]&&f[2],i=f.length>3&&void 0!==f[3]&&f[3],e.prev=2,e.next=5,wp.apiFetch({path:Object(n.addQueryArgs)("lp/v1/profile/course-tab",r),method:"GET"});case 5:(s=e.sent)&&((c=t.querySelector(".lp-skeleton-animation"))&&c.remove(),"success"===s.status&&s.data?o?t.innerHTML+=s.data:t.innerHTML=s.data:o?t.innerHTML+='<div class="lp-ajax-message" style="display:block">'.concat(s.message&&s.message,"</div>"):t.innerHTML='<div class="lp-ajax-message" style="display:block">'.concat(s.message&&s.message,"</div>"),i&&(i.classList.remove("loading"),u=i.dataset.paged,i.dataset.number<=u&&i.remove(),i.dataset.paged=parseInt(u)+1),a(t,r)),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),o?t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>"):t.innerHTML='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>"),i&&(i.classList.remove("loading"),l=i.dataset.paged,i.dataset.number<=l&&i.remove(),i.dataset.paged=parseInt(l)+1);case 13:case"end":return e.stop()}}),e,null,[[2,9]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){s(o,n,a,i,c,"next",e)}function c(e){s(o,n,a,i,c,"throw",e)}i(void 0)}))});return function(e,r){return t.apply(this,arguments)}}(),a=function(e,t){var n=e.querySelector("button[data-paged]");n&&n.addEventListener("click",(function(a){a.preventDefault();var i=n&&n.dataset.paged;n.classList.add("loading");var s="list"===t.layout?".lp_profile_course_progress":".learn-press-courses";r(e.querySelector(s),o(o({},t),{paged:i}),!0,n)}))}}};function f(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function p(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var v=function(){var e=document.querySelectorAll(".learn-press-profile-course__statistic");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target,a=JSON.parse(n.dataset.ajax);r(n,a),t.unobserve(n)}}))}));p(e).map((function(e){return t.observe(e)}))}var r=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,wp.apiFetch({path:Object(n.addQueryArgs)("lp/v1/profile/statistic",r),method:"GET"});case 3:"success"===(a=e.sent).status&&a.data?t.innerHTML=a.data:t.innerHTML='<div class="lp-ajax-message error" style="display:block">'.concat(a.message&&a.message,"</div>"),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,s,"next",e)}function s(e){f(o,n,a,i,s,"throw",e)}i(void 0)}))});return function(e,r){return t.apply(this,arguments)}}()}};document.addEventListener("DOMContentLoaded",(function(e){l(),v()}))},5:function(e,t){e.exports=window.wp.url}});
assets/js/dist/frontend/question-types.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.questionTypes=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=21)}({0:function(e,t){e.exports=window.wp.i18n},1:function(e,t){e.exports=window.wp.data},2:function(e,t){e.exports=window.wp.element},21:function(e,t,r){"use strict";r.r(t),r.d(t,"QuestionBase",(function(){return v})),r.d(t,"SingleChoice",(function(){return E})),r.d(t,"MultipleChoices",(function(){return U})),r.d(t,"TrueOrFalse",(function(){return Y})),r.d(t,"FillInBlanks",(function(){return le})),r.d(t,"SortingChoice",(function(){return je}));var n=r(2),o=r(4),i=r(1),c=r(0);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b(e);if(t){var o=b(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return p(this,r)}}function p(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?y(e):t}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var h=lodash,d=h.isArray,v=(h.get,h.set,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(u,e);var t,r,n,o=f(u);function u(e){var t;a(this,u),m(y(t=o.apply(this,arguments)),"prepare",(function(e,t){var r=e.question;return r&&r.id!==t.questionId?{options:t.self.parseOptions(r.options)}:null})),m(y(t),"setInputRef",(function(e,r){t.inputs||(t.inputs={}),t.inputs[r]=e})),m(y(t),"maybeShowCorrectAnswer",(function(){var e=t.props,r=e.status,n=e.isCheckedAnswer,o=e.showCorrectReview,i=e.isReviewing;return"completed"===r&&o||n&&!i})),m(y(t),"maybeDisabledOption",(function(e){var r=t.props,n=(r.answered,r.status);return r.isCheckedAnswer||"started"!==n})),m(y(t),"setAnswerChecked",(function(){return function(e){var r=t.props,n=r.updateUserQuestionAnswers,o=r.question;if("started"!==r.status)return Object(c.__)("LP Error: can not set answers","learnpress");var i=t.$wrap.find(".option-check"),u=[],a="multi_choice"!==o.type;i.each((function(e,t){if(t.checked&&(u.push(t.value),a))return!1})),n(o.id,a?u[0]:u)}})),m(y(t),"maybeCheckedAnswer",(function(e){var r=t.props.answered;return d(r)?!!r.find((function(t){return t==e})):e==r})),m(y(t),"getOptionType",(function(e,t){var r="radio";switch(e){case"multi_choice":r="checkbox"}return r})),m(y(t),"isDefaultType",(function(){return t.props.supportOptions})),m(y(t),"getWarningMessage",(function(){return React.createElement(React.Fragment,null,Object(c.__)("Render function should be overwritten from base.","learnpress"))})),m(y(t),"getOptionClass",(function(e){t.props.answered;return["answer-option"]})),m(y(t),"parseOptions",(function(e){return e&&(e=d(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=d(e)?e:JSON.parse(e)),e||[]})),m(y(t),"getOptions",(function(){return t.state.options||[]})),m(y(t),"isCorrect",(function(){var e,r,n,o=t.props.answered;if(!o)return!1;for(e=0,n=t.getOptions();e<n.length;e++)if("yes"===(r=n[e]).isTrue&&o==r.value)return!0;return!1})),m(y(t),"isChecked",(function(){var e=t.props.question;return Object(i.select)("learnpress/quiz").isCheckedAnswer(e.id)})),m(y(t),"getCorrectLabel",(function(){var e=t.props,r=(e.status,e.answered,e.question),n=(LP.config.isQuestionCorrect[r.type]||t.isCorrect).call(y(t));return t.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response"+(n?" correct":" incorrect")},React.createElement("span",{className:"label"},n?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),n?r.point:0,r.point)))}));var r=e.question;return t.state={optionClass:["answer-option"],questionId:0,options:r?t.parseOptions(r.options):[],self:y(t)},e.$wrap&&(t.$wrap=e.$wrap),t}return t=u,n=[{key:"getDerivedStateFromProps",value:function(e,t){return t.self.prepare(e,t)}}],(r=[{key:"componentDidMount",value:function(){var e=this.prepare(this.props,this.state);e&&this.setState(e)}},{key:"render",value:function(){var e=this,t=this.props,r=t.question,n=t.status;return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(r.id),className:"answer-options"},this.getOptions().map((function(t){var o="learn-press-answer-option-".concat(t.uid);return React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.uid)},React.createElement("input",{type:e.getOptionType(r.type,t),className:"option-check",name:"started"===n?"learn-press-question-".concat(r.id):"",id:o,ref:function(r){e.setInputRef(r,t.value)},onChange:e.setAnswerChecked(),disabled:e.maybeDisabledOption(t),checked:e.maybeCheckedAnswer(t.value),value:"started"===n?t.value:""}),React.createElement("label",{htmlFor:o,className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}}))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&s(t.prototype,r),n&&s(t,n),u}(n.Component));function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return O(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=A(e);if(t){var o=A(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return R(this,r)}}function R(e,t){return!t||"object"!==w(t)&&"function"!=typeof t?P(e):t}function P(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var E=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}(r,e);var t=S(r);function r(){var e;j(this,r);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return C(P(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var r=e.props.answered,n=g(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&n.push("answer-correct"),r&&("yes"===t.isTrue?r===t.value&&n.push("answered-correct"):r===t.value&&n.push("answered-wrong"))),n})),e}return r}(v);function T(e){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return q(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=B(e);if(t){var o=B(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return L(this,r)}}function L(e,t){return!t||"object"!==T(t)&&"function"!=typeof t?M(e):t}function M(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var F=lodash.isBoolean,U=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&I(e,t)}(r,e);var t=N(r);function r(){var e;x(this,r);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return D(M(e=t.call.apply(t,[this].concat(o))),"isCorrect",(function(){var t,r,n,o=e.props.answered;if(F(o)||!o)return!1;for(t=0,n=e.getOptions();t<n.length;t++)if("yes"===(r=n[t]).isTrue){if(-1===o.indexOf(r.value))return!1}else if(-1!==o.indexOf(r.value))return!1;return!0})),D(M(e),"getOptionClass",(function(t){var r=e.props.answered,n=k(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&n.push("answer-correct"),r&&("yes"===t.isTrue?-1!==r.indexOf(t.value)&&n.push("answered-correct"):-1!==r.indexOf(t.value)&&n.push("answered-wrong"))),n})),e}return r}(v);function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Q(e){return function(e){if(Array.isArray(e))return $(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=K(e);if(t){var o=K(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return V(this,r)}}function V(e,t){return!t||"object"!==H(t)&&"function"!=typeof t?G(e):t}function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&J(e,t)}(r,e);var t=W(r);function r(){var e;z(this,r);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return X(G(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var r=e.props.answered,n=Q(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&n.push("answer-correct"),r&&("yes"===t.isTrue?r===t.value&&n.push("answered-correct"):r===t.value&&n.push("answered-wrong"))),n})),e}return r}(v);function Z(e){return(Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e){return function(e){if(Array.isArray(e))return te(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return te(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return te(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ne(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ae(e);if(t){var o=ae(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return ce(this,r)}}function ce(e,t){return!t||"object"!==Z(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ae(e){return(ae=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function se(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(i,e);var t,r,n,o=ie(i);function i(){var e;re(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return se(ue(e=o.call.apply(o,[this].concat(r))),"updateFibAnswer",(function(){var t=document.querySelectorAll(".lp-fib-input > input"),r={};ee(t).map((function(t){t.addEventListener("input",(function(n){e.setAnswered(r,t.dataset.id,n.target.value)})),t.addEventListener("paste",(function(n){e.setAnswered(r,t.dataset.id,n.target.value)}))}))})),se(ue(e),"setAnswered",(function(t,r,n){var o=e.props,i=o.updateUserQuestionAnswers,c=o.question;if("started"!==o.status)return"LP Error: can not set answers";var u=Object.assign(t,se({},r,n));i(c.id,u)})),se(ue(e),"getCorrectLabel",(function(){var t=e.props,r=t.question,n=t.mark,o=n||0;return n&&(Number.isInteger(n)||(o=n.toFixed(2))),e.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response correct"},React.createElement("span",{className:"label"},Object(c.__)("Points","learnpress")),React.createElement("span",{className:"point"},"".concat(o,"/").concat(r.point," ").concat(Object(c.__)("point","learnpress"))),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#00adff"}}),Object(c.__)("Correct","learnpress")),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#d85554"}}),Object(c.__)("Incorrect","learnpress")))})),e}return t=i,(r=[{key:"componentDidMount",value:function(){this.updateFibAnswer()}},{key:"componentDidUpdate",value:function(e){e.answered||this.updateFibAnswer()}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{className:"lp-fib-content"},this.getOptions().map((function(e){return React.createElement("div",{key:"blank-".concat(e.uid),dangerouslySetInnerHTML:{__html:e.title||e.value}})}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&ne(t.prototype,r),n&&ne(t,n),i}(v);function fe(e){return(fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pe(e){return function(e){if(Array.isArray(e))return ye(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ye(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ye(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function me(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ge(e);if(t){var o=ge(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return ve(this,r)}}function ve(e,t){return!t||"object"!==fe(t)&&"function"!=typeof t?we(e):t}function we(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ge(e){return(ge=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Oe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&he(e,t)}(i,e);var t,r,n,o=de(i);function i(){var e;be(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Oe(we(e=o.call.apply(o,[this].concat(r))),"isCorrect",(function(){var t,r,n,o=e.props.answered;if(!o)return!1;for(t=0,n=e.getOptions();t<n.length;t++)if(o[(r=n[t]).sorting]!==r.value)return!1;return!0})),Oe(we(e),"getCorrectLabel",(function(){var t=e.props.question,r=e.isCorrect.call(we(e));return e.maybeShowCorrectAnswer()&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-response"+(r?" correct":" incorrect")},React.createElement("span",{className:"label"},r?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),r?t.point:0,t.point))))})),Oe(we(e),"getAnswerSortingChoice",(function(){var t=e.props.question.options||[],r=e.isCorrect.call(we(e)),n=[];return!r&&t.length>0&&t.map((function(e){var t=e.sorting;if(void 0!==t)return n[t]=e.title})),n})),e}return t=i,(r=[{key:"componentDidMount",value:function(){var e=this.props,t=e.updateUserQuestionAnswers,r=e.question,n=document.querySelector("#answer-options-".concat(r.id));return jQuery(n).sortable({items:".answer-option",cursor:"move",axis:"y",handle:".option-drag",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,update:function(e,o){var i=n.querySelectorAll(".answer-option"),c=[];pe(i).map((function(e){return c.push(e.dataset.value)})),c.length>0&&t(r.id,c)}})}},{key:"render",value:function(){var e=this,t=this.props.question,r=this.getAnswerSortingChoice();return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(t.id),className:"answer-options lp-sorting-choice-ul"},this.getOptions().map((function(t,n){return React.createElement(React.Fragment,null,React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.value),"data-value":t.value},React.createElement("span",{className:"option-drag",style:{display:"flex",alignItems:"center",position:"absolute",height:"100%",left:14}},React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24"},React.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),React.createElement("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"}))),React.createElement("label",{htmlFor:"learn-press-answer-option-".concat(t.value),className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}})),r.length>0&&void 0!==r[n]&&React.createElement("div",{className:"lp-sorting-choice__check-answer",key:"lp-checked-answer-".concat(n),style:{marginBottom:10}},r[n]))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&me(t.prototype,r),n&&me(t,n),i}(v);function _e(e){return(_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Se(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Ae(e,t){return(Ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ce(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ke(e);if(t){var o=ke(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Ee(this,r)}}function Ee(e,t){return!t||"object"!==_e(t)&&"function"!=typeof t?Te(e):t}function Te(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ke(e){return(ke=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function qe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var xe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ae(e,t)}(i,e);var t,r,n,o=Ce(i);function i(){var e;Re(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return qe(Te(e=o.call.apply(o,[this].concat(r))),"getQuestion",(function(){var t=e.props.question;return LP.Hook.applyFilters("question-types",{single_choice:LP.questionTypes.SingleChoice,multi_choice:LP.questionTypes.MultipleChoices,true_or_false:LP.questionTypes.TrueOrFalse,fill_in_blanks:LP.questionTypes.FillInBlanks,sorting_choice:LP.questionTypes.SortingChoice})[t.type]})),e}return t=i,(r=[{key:"render",value:function(){var e=this.props,t=e.question,r=e.supportOptions,n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Se(Object(r),!0).forEach((function(t){qe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Se(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},this.props);n.supportOptions=-1!==r.indexOf(t.type);var o=this.getQuestion()||function(){return React.createElement("div",{className:"question-types",dangerouslySetInnerHTML:{__html:Object(c.sprintf)(Object(c.__)("Question <code>%s</code> invalid!","learnpress"),t.type)}})};return React.createElement(React.Fragment,null,React.createElement(o,n))}}])&&Pe(t.prototype,r),n&&Pe(t,n),i}(n.Component),Ie=Object(o.compose)(Object(i.withSelect)((function(e,t){var r=t.question.id,n=e("learnpress/quiz"),o=n.getData,i=n.isCheckedAnswer;return{supportOptions:o("supportOptions"),isCheckedAnswer:i(r),keyPressed:o("keyPressed"),showCorrectReview:o("showCorrectReview"),isReviewing:"reviewing"===o("mode")}})),Object(i.withDispatch)((function(){return{}})))(xe);t.default=Ie},4:function(e,t){e.exports=window.wp.compose}});
1
+ this.LP=this.LP||{},this.LP.questionTypes=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=21)}({0:function(e,t){e.exports=window.wp.i18n},1:function(e,t){e.exports=window.wp.data},21:function(e,t,r){"use strict";r.r(t),r.d(t,"QuestionBase",(function(){return v})),r.d(t,"SingleChoice",(function(){return E})),r.d(t,"MultipleChoices",(function(){return U})),r.d(t,"TrueOrFalse",(function(){return Y})),r.d(t,"FillInBlanks",(function(){return le})),r.d(t,"SortingChoice",(function(){return je}));var n=r(3),o=r(4),i=r(1),c=r(0);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b(e);if(t){var o=b(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return p(this,r)}}function p(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?y(e):t}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var h=lodash,d=h.isArray,v=(h.get,h.set,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(u,e);var t,r,n,o=f(u);function u(e){var t;a(this,u),m(y(t=o.apply(this,arguments)),"prepare",(function(e,t){var r=e.question;return r&&r.id!==t.questionId?{options:t.self.parseOptions(r.options)}:null})),m(y(t),"setInputRef",(function(e,r){t.inputs||(t.inputs={}),t.inputs[r]=e})),m(y(t),"maybeShowCorrectAnswer",(function(){var e=t.props,r=e.status,n=e.isCheckedAnswer,o=e.showCorrectReview,i=e.isReviewing;return"completed"===r&&o||n&&!i})),m(y(t),"maybeDisabledOption",(function(e){var r=t.props,n=(r.answered,r.status);return r.isCheckedAnswer||"started"!==n})),m(y(t),"setAnswerChecked",(function(){return function(e){var r=t.props,n=r.updateUserQuestionAnswers,o=r.question;if("started"!==r.status)return Object(c.__)("LP Error: can not set answers","learnpress");var i=t.$wrap.find(".option-check"),u=[],a="multi_choice"!==o.type;i.each((function(e,t){if(t.checked&&(u.push(t.value),a))return!1})),n(o.id,a?u[0]:u)}})),m(y(t),"maybeCheckedAnswer",(function(e){var r=t.props.answered;return d(r)?!!r.find((function(t){return t==e})):e==r})),m(y(t),"getOptionType",(function(e,t){var r="radio";switch(e){case"multi_choice":r="checkbox"}return r})),m(y(t),"isDefaultType",(function(){return t.props.supportOptions})),m(y(t),"getWarningMessage",(function(){return React.createElement(React.Fragment,null,Object(c.__)("Render function should be overwritten from base.","learnpress"))})),m(y(t),"getOptionClass",(function(e){t.props.answered;return["answer-option"]})),m(y(t),"parseOptions",(function(e){return e&&(e=d(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=d(e)?e:JSON.parse(e)),e||[]})),m(y(t),"getOptions",(function(){return t.state.options||[]})),m(y(t),"isCorrect",(function(){var e,r,n,o=t.props.answered;if(!o)return!1;for(e=0,n=t.getOptions();e<n.length;e++)if("yes"===(r=n[e]).isTrue&&o==r.value)return!0;return!1})),m(y(t),"isChecked",(function(){var e=t.props.question;return Object(i.select)("learnpress/quiz").isCheckedAnswer(e.id)})),m(y(t),"getCorrectLabel",(function(){var e=t.props,r=(e.status,e.answered,e.question),n=(LP.config.isQuestionCorrect[r.type]||t.isCorrect).call(y(t));return t.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response"+(n?" correct":" incorrect")},React.createElement("span",{className:"label"},n?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),n?r.point:0,r.point)))}));var r=e.question;return t.state={optionClass:["answer-option"],questionId:0,options:r?t.parseOptions(r.options):[],self:y(t)},e.$wrap&&(t.$wrap=e.$wrap),t}return t=u,n=[{key:"getDerivedStateFromProps",value:function(e,t){return t.self.prepare(e,t)}}],(r=[{key:"componentDidMount",value:function(){var e=this.prepare(this.props,this.state);e&&this.setState(e)}},{key:"render",value:function(){var e=this,t=this.props,r=t.question,n=t.status;return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(r.id),className:"answer-options"},this.getOptions().map((function(t){var o="learn-press-answer-option-".concat(t.uid);return React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.uid)},React.createElement("input",{type:e.getOptionType(r.type,t),className:"option-check",name:"started"===n?"learn-press-question-".concat(r.id):"",id:o,ref:function(r){e.setInputRef(r,t.value)},onChange:e.setAnswerChecked(),disabled:e.maybeDisabledOption(t),checked:e.maybeCheckedAnswer(t.value),value:"started"===n?t.value:""}),React.createElement("label",{htmlFor:o,className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}}))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&s(t.prototype,r),n&&s(t,n),u}(n.Component));function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return O(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return O(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function j(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=A(e);if(t){var o=A(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return R(this,r)}}function R(e,t){return!t||"object"!==w(t)&&"function"!=typeof t?P(e):t}function P(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function C(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var E=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}(r,e);var t=S(r);function r(){var e;j(this,r);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return C(P(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var r=e.props.answered,n=g(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&n.push("answer-correct"),r&&("yes"===t.isTrue?r===t.value&&n.push("answered-correct"):r===t.value&&n.push("answered-wrong"))),n})),e}return r}(v);function T(e){return(T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e){return function(e){if(Array.isArray(e))return q(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return q(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){return(I=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=B(e);if(t){var o=B(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return L(this,r)}}function L(e,t){return!t||"object"!==T(t)&&"function"!=typeof t?M(e):t}function M(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B(e){return(B=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function D(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var F=lodash.isBoolean,U=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&I(e,t)}(r,e);var t=N(r);function r(){var e;x(this,r);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return D(M(e=t.call.apply(t,[this].concat(o))),"isCorrect",(function(){var t,r,n,o=e.props.answered;if(F(o)||!o)return!1;for(t=0,n=e.getOptions();t<n.length;t++)if("yes"===(r=n[t]).isTrue){if(-1===o.indexOf(r.value))return!1}else if(-1!==o.indexOf(r.value))return!1;return!0})),D(M(e),"getOptionClass",(function(t){var r=e.props.answered,n=k(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&n.push("answer-correct"),r&&("yes"===t.isTrue?-1!==r.indexOf(t.value)&&n.push("answered-correct"):-1!==r.indexOf(t.value)&&n.push("answered-wrong"))),n})),e}return r}(v);function H(e){return(H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Q(e){return function(e){if(Array.isArray(e))return $(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return $(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function $(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,t){return(J=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function W(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=K(e);if(t){var o=K(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return V(this,r)}}function V(e,t){return!t||"object"!==H(t)&&"function"!=typeof t?G(e):t}function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function K(e){return(K=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function X(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Y=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&J(e,t)}(r,e);var t=W(r);function r(){var e;z(this,r);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return X(G(e=t.call.apply(t,[this].concat(o))),"getOptionClass",(function(t){var r=e.props.answered,n=Q(e.state.optionClass);return e.maybeShowCorrectAnswer()&&("yes"===t.isTrue&&n.push("answer-correct"),r&&("yes"===t.isTrue?r===t.value&&n.push("answered-correct"):r===t.value&&n.push("answered-wrong"))),n})),e}return r}(v);function Z(e){return(Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e){return function(e){if(Array.isArray(e))return te(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return te(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return te(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function te(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ne(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ae(e);if(t){var o=ae(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return ce(this,r)}}function ce(e,t){return!t||"object"!==Z(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ae(e){return(ae=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function se(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var le=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(i,e);var t,r,n,o=ie(i);function i(){var e;re(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return se(ue(e=o.call.apply(o,[this].concat(r))),"updateFibAnswer",(function(){var t=document.querySelectorAll(".lp-fib-input > input"),r={};ee(t).map((function(t){t.addEventListener("input",(function(n){e.setAnswered(r,t.dataset.id,n.target.value)})),t.addEventListener("paste",(function(n){e.setAnswered(r,t.dataset.id,n.target.value)}))}))})),se(ue(e),"setAnswered",(function(t,r,n){var o=e.props,i=o.updateUserQuestionAnswers,c=o.question;if("started"!==o.status)return"LP Error: can not set answers";var u=Object.assign(t,se({},r,n));i(c.id,u)})),se(ue(e),"getCorrectLabel",(function(){var t=e.props,r=t.question,n=t.mark,o=n||0;return n&&(Number.isInteger(n)||(o=n.toFixed(2))),e.maybeShowCorrectAnswer()&&React.createElement("div",{className:"question-response correct"},React.createElement("span",{className:"label"},Object(c.__)("Points","learnpress")),React.createElement("span",{className:"point"},"".concat(o,"/").concat(r.point," ").concat(Object(c.__)("point","learnpress"))),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#00adff"}}),Object(c.__)("Correct","learnpress")),React.createElement("span",{className:"lp-fib-note"},React.createElement("span",{style:{background:"#d85554"}}),Object(c.__)("Incorrect","learnpress")))})),e}return t=i,(r=[{key:"componentDidMount",value:function(){this.updateFibAnswer()}},{key:"componentDidUpdate",value:function(e){e.answered||this.updateFibAnswer()}},{key:"render",value:function(){return React.createElement(React.Fragment,null,React.createElement("div",{className:"lp-fib-content"},this.getOptions().map((function(e){return React.createElement("div",{key:"blank-".concat(e.uid),dangerouslySetInnerHTML:{__html:e.title||e.value}})}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&ne(t.prototype,r),n&&ne(t,n),i}(v);function fe(e){return(fe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pe(e){return function(e){if(Array.isArray(e))return ye(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return ye(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ye(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function be(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function me(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function de(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ge(e);if(t){var o=ge(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return ve(this,r)}}function ve(e,t){return!t||"object"!==fe(t)&&"function"!=typeof t?we(e):t}function we(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ge(e){return(ge=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Oe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var je=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&he(e,t)}(i,e);var t,r,n,o=de(i);function i(){var e;be(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return Oe(we(e=o.call.apply(o,[this].concat(r))),"isCorrect",(function(){var t,r,n,o=e.props.answered;if(!o)return!1;for(t=0,n=e.getOptions();t<n.length;t++)if(o[(r=n[t]).sorting]!==r.value)return!1;return!0})),Oe(we(e),"getCorrectLabel",(function(){var t=e.props.question,r=e.isCorrect.call(we(e));return e.maybeShowCorrectAnswer()&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-response"+(r?" correct":" incorrect")},React.createElement("span",{className:"label"},r?Object(c.__)("Correct","learnpress"):Object(c.__)("Incorrect","learnpress")),React.createElement("span",{className:"point"},sprintf(Object(c.__)("%d/%d point","learnpress"),r?t.point:0,t.point))))})),Oe(we(e),"getAnswerSortingChoice",(function(){var t=e.props.question.options||[],r=e.isCorrect.call(we(e)),n=[];return!r&&t.length>0&&t.map((function(e){var t=e.sorting;if(void 0!==t)return n[t]=e.title})),n})),e}return t=i,(r=[{key:"componentDidMount",value:function(){var e=this.props,t=e.updateUserQuestionAnswers,r=e.question,n=document.querySelector("#answer-options-".concat(r.id));return jQuery(n).sortable({items:".answer-option",cursor:"move",axis:"y",handle:".option-drag",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,update:function(e,o){var i=n.querySelectorAll(".answer-option"),c=[];pe(i).map((function(e){return c.push(e.dataset.value)})),c.length>0&&t(r.id,c)}})}},{key:"render",value:function(){var e=this,t=this.props.question,r=this.getAnswerSortingChoice();return React.createElement("div",{className:"question-answers"},this.isDefaultType()&&React.createElement("ul",{id:"answer-options-".concat(t.id),className:"answer-options lp-sorting-choice-ul"},this.getOptions().map((function(t,n){return React.createElement(React.Fragment,null,React.createElement("li",{className:e.getOptionClass(t).join(" "),key:"answer-option-".concat(t.value),"data-value":t.value},React.createElement("span",{className:"option-drag",style:{display:"flex",alignItems:"center",position:"absolute",height:"100%",left:14}},React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24"},React.createElement("path",{d:"M0 0h24v24H0z",fill:"none"}),React.createElement("path",{d:"M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"}))),React.createElement("label",{htmlFor:"learn-press-answer-option-".concat(t.value),className:"option-title",dangerouslySetInnerHTML:{__html:t.title||t.value}})),r.length>0&&void 0!==r[n]&&React.createElement("div",{className:"lp-sorting-choice__check-answer",key:"lp-checked-answer-".concat(n),style:{marginBottom:10}},r[n]))}))),!this.isDefaultType()&&this.getWarningMessage(),this.getCorrectLabel())}}])&&me(t.prototype,r),n&&me(t,n),i}(v);function _e(e){return(_e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Se(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Re(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pe(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function Ae(e,t){return(Ae=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Ce(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=ke(e);if(t){var o=ke(this).constructor;r=Reflect.construct(n,arguments,o)}else r=n.apply(this,arguments);return Ee(this,r)}}function Ee(e,t){return!t||"object"!==_e(t)&&"function"!=typeof t?Te(e):t}function Te(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ke(e){return(ke=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function qe(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var xe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Ae(e,t)}(i,e);var t,r,n,o=Ce(i);function i(){var e;Re(this,i);for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return qe(Te(e=o.call.apply(o,[this].concat(r))),"getQuestion",(function(){var t=e.props.question;return LP.Hook.applyFilters("question-types",{single_choice:LP.questionTypes.SingleChoice,multi_choice:LP.questionTypes.MultipleChoices,true_or_false:LP.questionTypes.TrueOrFalse,fill_in_blanks:LP.questionTypes.FillInBlanks,sorting_choice:LP.questionTypes.SortingChoice})[t.type]})),e}return t=i,(r=[{key:"render",value:function(){var e=this.props,t=e.question,r=e.supportOptions,n=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Se(Object(r),!0).forEach((function(t){qe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Se(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},this.props);n.supportOptions=-1!==r.indexOf(t.type);var o=this.getQuestion()||function(){return React.createElement("div",{className:"question-types",dangerouslySetInnerHTML:{__html:Object(c.sprintf)(Object(c.__)("Question <code>%s</code> invalid!","learnpress"),t.type)}})};return React.createElement(React.Fragment,null,React.createElement(o,n))}}])&&Pe(t.prototype,r),n&&Pe(t,n),i}(n.Component),Ie=Object(o.compose)(Object(i.withSelect)((function(e,t){var r=t.question.id,n=e("learnpress/quiz"),o=n.getData,i=n.isCheckedAnswer;return{supportOptions:o("supportOptions"),isCheckedAnswer:i(r),keyPressed:o("keyPressed"),showCorrectReview:o("showCorrectReview"),isReviewing:"reviewing"===o("mode")}})),Object(i.withDispatch)((function(){return{}})))(xe);t.default=Ie},3:function(e,t){e.exports=window.wp.element},4:function(e,t){e.exports=window.wp.compose}});
assets/js/dist/frontend/quiz.js CHANGED
@@ -185,7 +185,7 @@ var Attempts = function Attempts() {
185
  className: "quiz-attempts__marks"
186
  }, "".concat(row.userMark, " / ").concat(row.mark)), /*#__PURE__*/React.createElement("td", {
187
  className: "quiz-attempts__grade"
188
- }, row.passingGrade || _x('-', 'unknown passing grade value', 'learnpress')), /*#__PURE__*/React.createElement("td", {
189
  className: "quiz-attempts__result"
190
  }, "".concat(parseFloat(row.result).toFixed(2), "%"), " ", /*#__PURE__*/React.createElement("span", null, row.graduationText)));
191
  })))));
@@ -1961,7 +1961,7 @@ var Result = function Result() {
1961
  className: "result-achieved"
1962
  }, "".concat(percentResult, "%")), /*#__PURE__*/React.createElement("span", {
1963
  className: "result-require"
1964
- }, passingGradeValue || _x('-', 'unknown passing grade value', 'learnpress'))), done && /*#__PURE__*/React.createElement("p", {
1965
  className: "result-message"
1966
  }, message), /*#__PURE__*/React.createElement("ul", {
1967
  className: "result-statistic"
185
  className: "quiz-attempts__marks"
186
  }, "".concat(row.userMark, " / ").concat(row.mark)), /*#__PURE__*/React.createElement("td", {
187
  className: "quiz-attempts__grade"
188
+ }, row.passingGrade || '-'), /*#__PURE__*/React.createElement("td", {
189
  className: "quiz-attempts__result"
190
  }, "".concat(parseFloat(row.result).toFixed(2), "%"), " ", /*#__PURE__*/React.createElement("span", null, row.graduationText)));
191
  })))));
1961
  className: "result-achieved"
1962
  }, "".concat(percentResult, "%")), /*#__PURE__*/React.createElement("span", {
1963
  className: "result-require"
1964
+ }, passingGradeValue || '-')), done && /*#__PURE__*/React.createElement("p", {
1965
  className: "result-message"
1966
  }, message), /*#__PURE__*/React.createElement("ul", {
1967
  className: "result-statistic"
assets/js/dist/frontend/quiz.min.js CHANGED
@@ -1,6 +1,6 @@
1
- this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,i,a=n[r.type],u=t(r);if(a)for(o=0;o<a.length;o++)(i=a[o](r,e))&&e.dispatch(i);return u}}}).effects=n,t}},,function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n(5),o=n(6);function i(e,t,n,r,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,o)}function a(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;c(n),t.unobserve(n)}}))}));a(e).map((function(e){return t.observe(e)}))}},c=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,s,"next",e)}function s(e){i(a,r,o,u,s,"throw",e)}u(void 0)}))});return function(e){return t.apply(this,arguments)}}()},function(e,t){!function(){e.exports=this.LP.dataControls}()},function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,function(e,t,n){var r;
2
  /*!
3
  Copyright (c) 2018 Jed Watson.
4
  Licensed under the MIT License (MIT), see
5
  http://jedwatson.github.io/classnames
6
- */!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return Rn}));var r={};n.r(r),n.d(r,"setQuizData",(function(){return wt})),n.d(r,"setCurrentQuestion",(function(){return Ot})),n.d(r,"setCurrentPage",(function(){return _t})),n.d(r,"__requestBeforeStartQuiz",(function(){return St})),n.d(r,"__requestStartQuizSuccess",(function(){return qt})),n.d(r,"startQuiz",(function(){return jt})),n.d(r,"__requestSubmitQuiz",(function(){return Rt})),n.d(r,"__requestSubmitQuizSuccess",(function(){return Pt})),n.d(r,"submitQuiz",(function(){return Et})),n.d(r,"updateUserQuestionAnswers",(function(){return zt})),n.d(r,"__requestShowHintSuccess",(function(){return kt})),n.d(r,"showHint",(function(){return Qt})),n.d(r,"__requestCheckAnswerSuccess",(function(){return It})),n.d(r,"checkAnswer",(function(){return At})),n.d(r,"markQuestionRendered",(function(){return Ct})),n.d(r,"setQuizMode",(function(){return Nt})),n.d(r,"sendKey",(function(){return Tt}));var o={};n.r(o),n.d(o,"getQuestionOptions",(function(){return Lt})),n.d(o,"getItemStatus",(function(){return Ut})),n.d(o,"getProp",(function(){return Ft})),n.d(o,"getQuizAttempts",(function(){return Ht})),n.d(o,"getQuizAnswered",(function(){return Bt})),n.d(o,"getQuestions",(function(){return Gt})),n.d(o,"getData",(function(){return Jt})),n.d(o,"getDefaultRestArgs",(function(){return Kt})),n.d(o,"getQuestionAnswered",(function(){return Wt})),n.d(o,"getQuestionMark",(function(){return $t})),n.d(o,"getCurrentQuestion",(function(){return Zt})),n.d(o,"getQuestion",(function(){return Yt})),n.d(o,"isCheckedAnswer",(function(){return Vt})),n.d(o,"isCorrect",(function(){return Xt})),n.d(o,"getQuestionsSelectedAnswers",(function(){return en})),n.d(o,"getUserMark",(function(){return tn}));var i=n(2),a=n(4),u=n(1),s=function(){var e=Object(u.select)("learnpress/quiz").getData("content");return React.createElement("div",{className:"quiz-content",dangerouslySetInnerHTML:{__html:e}})},c=n(0),l=function(e){var t;if(e>86400)t=(e-e%86400)/86400,e%=86400;else if(86400==e)return"24:00";var n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")},f=LP.Hook,p=function(){var e=function(e){return Object(u.select)("learnpress/quiz").getData(e)},t=f.applyFilters("quiz-meta-fields",{duration:{title:Object(c.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:Object(c.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:Object(c.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&React.createElement(React.Fragment,null,React.createElement("ul",{className:"quiz-intro"},Object.values(t).map((function(e,t){var n=e.name||t;return React.createElement("li",{key:"quiz-intro-field-".concat(t),className:"quiz-intro-item quiz-intro-item--".concat(n)},React.createElement("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),React.createElement("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S(e);if(t){var o=S(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O(this,n)}}function O(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(i,e);var t,n,r,o=w(i);function i(){var e;h(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return q(_(e=o.call.apply(o,[this].concat(n))),"startQuiz",(function(t){t&&t.preventDefault();var n=document.querySelector(".lp-button.start");n&&n.setAttribute("disabled","disabled");var r=e.props,o=r.startQuiz;if("completed"===r.status){var i=Object(u.select)("learnpress/modal"),a=i.confirm,s=i.isOpen;if("no"===a(Object(c.__)("Are you sure you want to retake quiz?","learnpress"),e.startQuiz))return void(!s()&&n&&n.removeAttribute("disabled"))}if("1"==lpQuizSettings.checkNorequizenroll){window.localStorage.removeItem("quiz_start_"+lpQuizSettings.id),window.localStorage.setItem("quiz_start_"+lpQuizSettings.id,Date.now());var l=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);l>=1?window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,parseInt(l)+1):window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,1),window.localStorage.removeItem("quiz_userdata_"+lpQuizSettings.id)}o()})),q(_(e),"nav",(function(t){return function(n){var r=e.props,o=r.questionNav,i=r.currentPage,a=r.numPages,u=r.setCurrentPage;switch(t){case"prev":i>1?i-=1:i="infinity"===o?a:1;break;default:i<a?i+=1:i="infinity"===o?1:a}u(i)}})),q(_(e),"moveTo",(function(t){return function(n){n.preventDefault();var r=e.props,o=r.numPages,i=r.setCurrentPage;t<1||t>o||i(t)}})),q(_(e),"isLast",(function(){var t=e.props;return t.currentPage===t.numPages})),q(_(e),"isFirst",(function(){return 1===e.props.currentPage})),q(_(e),"submit",(function(){var t=e.props.submitQuiz;"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),e.submit)&&t()})),q(_(e),"setQuizMode",(function(t){return function(){(0,e.props.setQuizMode)(t)}})),q(_(e),"isReviewing",(function(){return e.props.isReviewing})),e}return t=i,(n=[{key:"pageNumbers",value:function(e){var t=this,n=this.props,r=n.numPages,o=n.currentPage;if(r<2)return"";(e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){q(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({numPages:r,currentPage:o,midSize:1,endSize:1,prevNext:!0},e||{})).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);var i=m(Array(r).keys()),a=!1;return React.createElement("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&React.createElement("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},Object(c.__)("Prev","learnpress")),i.map((function(n){return(n+=1)===e.currentPage?(a=!0,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers current"},n)):n<=e.endSize||e.currentPage&&n>=e.currentPage-e.midSize&&n<=e.currentPage+e.midSize||n>e.numPages-e.endSize?(a=!0,React.createElement("button",{key:"page-number-".concat(n),className:"page-numbers",onClick:t.moveTo(n)},n)):a?(a=!1,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers dots"},"…")):""})),e.prevNext&&!this.isLast()&&React.createElement("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},Object(c.__)("Next","learnpress")))}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.questionNav,r=e.isReviewing,o=e.showReview,i=e.numPages,a=(e.question,e.questionsPerPage,e.canRetry),u=e.retakeNumber,s=["quiz-buttons"];("started"===t||r)&&s.push("align-center"),"questionNav"===n&&s.push("infinity"),this.isFirst()&&s.push("is-first"),this.isLast()&&s.push("is-last");var l=document.querySelector("#popup-sidebar"),f=document.querySelector("#learn-press-quiz-app"),p="";p="started"===t||r?{marginLeft:l&&l.offsetWidth/2,width:f&&f.offsetWidth}:null;var d=" fixed";return"no"==lpQuizSettings.navigationPosition&&(d=" nav-center"),React.createElement(React.Fragment,null,React.createElement("div",{className:s.join(" ")},React.createElement("div",{className:"button-left"+("started"===t||r?d:""),style:p},("completed"===t&&a||-1!==["","viewed"].indexOf(t))&&!r&&React.createElement("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===t?"".concat(Object(c.__)("Retake","learnpress")).concat(u?" (".concat(u,")"):""):Object(c.__)("Start","learnpress")),("started"===t||r)&&i>1&&React.createElement(React.Fragment,null,React.createElement("div",{className:"questions-pagination"},this.pageNumbers()))),React.createElement("div",{className:"button-right"},"started"===t&&React.createElement(React.Fragment,null,("infinity"===n||this.isLast())&&!r&&React.createElement("button",{className:"lp-button submit-quiz",onClick:this.submit},Object(c.__)("Finish Quiz","learnpress"))),r&&o&&React.createElement("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},Object(c.__)("Result","learnpress")),"completed"===t&&o&&!r&&React.createElement("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},Object(c.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&React.createElement("div",{className:"learn-press-message error"},this.props.message))}}])&&g(t.prototype,n),r&&g(t,r),i}(i.Component),R=Object(a.compose)(Object(u.withSelect)((function(e){var t=e("learnpress/quiz").getData;return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((function(e){var t=e.showCheck,n=e.checkedQuestions,r=e.hintedQuestions,o=e.question,i=e.status,a=e.type,u=e.Button;if("started"!==i)return!1;var s=React.createElement(u,{question:o});switch(a){case"hint":return r?!!o.hasHint&&(-1===r.indexOf(o.id)&&s):s;case"check":return!!t&&(n?-1===n.indexOf(o.id)&&s:s)}})),P=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getData,r=t.getCurrentQuestion,o={id:n("id"),status:n("status"),questionIds:n("questionIds"),questionNav:n("questionNav"),isReviewing:n("reviewQuestions")&&"reviewing"===n("mode"),showReview:n("reviewQuestions"),showCheck:n("instantCheck"),checkedQuestions:n("checkedQuestions"),hintedQuestions:n("hintedQuestions"),numPages:n("numPages"),pages:n("pages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage"),pageNumbers:n("pageNumbers"),keyPressed:n("keyPressed"),canRetry:n("retakeCount")>0&&n("retaken")<n("retakeCount"),retakeNumber:n("retakeCount")>0&&n("retaken")<n("retakeCount")?n("retakeCount")-n("retaken"):null,message:n("messageResponse")||!1,success:void 0===n("successResponse")||n("successResponse")};if(1===o.questionsPerPage&&(o.question=r("object")),"1"==lpQuizSettings.checkNorequizenroll){var i=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);n("retakeCount")>i?(o.retakeNumber=n("retakeCount")-i,o.canRetry=!0):o.canRetry=!1}return o})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz"),r=n.startQuiz,o=n.setCurrentQuestion,i=n.submitQuiz,a=n.setQuizMode,u=n.showHint,s=n.checkAnswer;return{startQuiz:r,setCurrentQuestion:o,setQuizMode:a,setCurrentPage:n.setCurrentPage,submitQuiz:function(e){i(e)},showHint:function(e){u(e)},checkAnswer:function(e){s(e)}}}))])(j);function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=N(e);if(t){var o=N(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return A(this,n)}}function A(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(i,e);var t,n,r,o=I(i);function i(){var e;z(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return T(C(e=o.call.apply(o,[this].concat(n))),"showHint",(function(){var t=e.props,n=t.showHint,r=t.question;n(r.id,!r.showHint)})),e}return t=i,(n=[{key:"render",value:function(){return this.props.question.hint?React.createElement("button",{className:"btn-show-hint",onClick:this.showHint},React.createElement("span",null,Object(c.__)("Hint","learnpress"))):""}}])&&k(t.prototype,n),r&&k(t,r),i}(i.Component),D=Object(a.compose)(Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").showHint;return{showHint:function(e,t){n(e,t)}}})))(x),M=n(13),L=n.n(M);function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function F(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=W(e);if(t){var o=W(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return J(this,n)}}function J(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?K(e):t}function K(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function W(e){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&B(e,t)}(i,e);var t,n,r,o=G(i);function i(){var e;return F(this,i),$(K(e=o.apply(this,arguments)),"checkAnswer",(function(){var t=e.props,n=t.checkAnswer,r=t.question;t.answered&&(n(r.id),e.setState({loading:!0}))})),e.state={loading:!1},e}return t=i,(n=[{key:"render",value:function(){var e=this.props.answered;return React.createElement(React.Fragment,null,React.createElement("button",{className:L()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},React.createElement("span",{className:"instant-check__icon"}),Object(c.__)("Check answer","learnpress"),!e&&React.createElement("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:Object(c.__)("You need to answer the question before check answer.","learnpress")}})))}}])&&H(t.prototype,n),r&&H(t,r),i}(i.Component),Y=Object(a.compose)(Object(u.withSelect)((function(e,t){var n=t.question.id;return{answered:(0,e("learnpress/quiz").getQuestionAnswered)(n)}})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").checkAnswer;return{checkAnswer:function(e){n(e)}}})))(Z),V=function(e){var t=e.question,n={"instant-check":function(){return React.createElement(R,{type:"check",Button:Y,question:t})},hint:function(){return React.createElement(R,{type:"hint",Button:D,question:t})}};return React.createElement(React.Fragment,null,LP.config.questionFooterButtons().map((function(e){return React.createElement(i.Fragment,{key:"button-".concat(e)},n[e]&&n[e]())})))};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=se(e);if(t){var o=se(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ae(this,n)}}function ae(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=window.jQuery,fe=lodash,pe=(fe.uniqueId,fe.isArray),de=(fe.isNumber,fe.bind,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(a,e);var t,n,r,o=ie(a);function a(){var e;return ne(this,a),ce(ue(e=o.apply(this,arguments)),"setRef",(function(t){e.$wrap=le(t)})),ce(ue(e),"parseOptions",(function(e){return e&&(e=pe(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=pe(e)?e:JSON.parse(e)),e||[]})),ce(ue(e),"getWrapperClass",(function(){var t=e.props,n=t.question,r=(t.answered,["question","question-"+n.type]),o=e.parseOptions(n.options);return o.length&&void 0!==o[0].isTrue&&r.push("question-answered"),r})),ce(ue(e),"getEditLink",(function(){var t=e.props,n=t.question,r=t.editPermalink;return r?r.replace(/post=(.*[0-9])/,"post=".concat(n.id)):""})),ce(ue(e),"editPermalink",(function(e){return Object(c.sprintf)('<a href="%s">%s</a>',e,Object(c.__)("Edit","learnpress"))})),e.state={time:null,showHint:!1},e.$wrap=null,e}return t=a,(n=[{key:"componentDidMount",value:function(e){var t=this.props,n=t.question,r=t.isCurrent,o=t.markQuestionRendered;return r&&o(n.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),e}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.isShow,o=t.isShowIndex,a=(t.isShowHint,t.status),u=LP.questionTypes.default,s=this.getEditLink();s&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",s);var l={index:function(){return o?React.createElement("span",{className:"question-index"},o,"."):""},title:function(){return React.createElement("span",{dangerouslySetInnerHTML:{__html:n.title}})},hint:function(){return React.createElement(D,{question:n})},"edit-permalink":function(){return s&&React.createElement("span",{dangerouslySetInnerHTML:{__html:e.editPermalink(s)},className:"edit-link"})}},f={title:function(){return React.createElement("h4",{className:"question-title"},LP.config.questionTitleParts().map((function(e){return React.createElement(i.Fragment,{key:"title-part-".concat(e)},l[e]&&l[e]())})))},content:function(){return React.createElement("div",{className:"question-content",dangerouslySetInnerHTML:{__html:n.content}})},"answer-options":function(){return e.$wrap&&React.createElement(u,te(te({},e.props),{},{$wrap:e.$wrap}))},explanation:function(){return n.explanation&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-explanation-content"},React.createElement("strong",{className:"explanation-title"},Object(c.__)("Explanation:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.explanation}})))},hint:function(){return n.hint&&!n.explanation&&n.showHint&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-hint-content"},React.createElement("strong",{className:"hint-title"},Object(c.__)("Hint:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.hint}})))},buttons:function(){return"started"===a&&React.createElement(V,{question:n})}},p=LP.config.questionBlocks();return React.createElement(React.Fragment,null,React.createElement("div",{className:this.getWrapperClass().join(" "),style:{display:r?"":"none"},"data-id":n.id,ref:this.setRef},p.map((function(e){return React.createElement(i.Fragment,{key:"block-".concat(e)},f[e]?f[e]():"")}))))}}])&&re(t.prototype,n),r&&re(t,r),a}(i.Component)),me=Object(a.compose)([Object(u.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.getQuestionAnswered,a=r.getQuestionMark;return{status:o("status"),questions:o("question"),answered:i(n),questionsRendered:o("questionsRendered"),editPermalink:o("editPermalink"),numPages:o("numPages"),mark:a(n)||""}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz"),n=t.updateUserQuestionAnswers;return{markQuestionRendered:t.markQuestionRendered,updateUserQuestionAnswers:n}}))])(de);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?Oe(e):t}function Oe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ge(e,t)}(i,e);var t,n,r,o=ve(i);function i(e){var t;return ye(this,i),Se(Oe(t=o.apply(this,arguments)),"startQuiz",(function(e){e.preventDefault(),(0,t.props.startQuiz)()})),Se(Oe(t),"isInVisibleRange",(function(e,n){var r=t.props,o=r.currentPage,i=r.questionsPerPage;return o===Math.ceil(n/i)})),Se(Oe(t),"nav",(function(e){var n=t.props.sendKey;switch(e.keyCode){case 37:return n("left");case 38:return;case 39:return n("right");case 40:return;default:e.keyCode>=49&&e.keyCode<=57&&n(e.keyCode-48)}})),t.needToTop=!1,t.state={isReviewing:null,currentPage:0,self:Oe(t)},t}return t=i,r=[{key:"getDerivedStateFromProps",value:function(e,t){for(var n=["isReviewing","currentPage"],r={},o=0;o<n.length;o++)e[n[o]]!==t[n[o]]&&(r[n[o]]=e[n[o]]);return Object.values(r).length?(t.self.needToTop=!0,r):null}}],(n=[{key:"componentDidUpdate",value:function(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}},{key:"render",value:function(){var e=this,t=this.props,n=t.status,r=t.currentQuestion,o=t.questions,i=t.questionsRendered,a=t.isReviewing,u=t.questionsPerPage,s=!0;return"completed"!==n||a||(s=!1),React.createElement(React.Fragment,null,React.createElement("div",{tabIndex:100,onKeyUp:this.nav},React.createElement("div",{className:"quiz-questions",style:{display:s?"":"none"}},o.map((function(t,n){var o=!u&&r===t.id,a=i&&-1!==i.indexOf(t.id),s=e.isInVisibleRange(t.id,n+1);return a||!a||s?React.createElement(me,{key:"loop-question-".concat(t.id),isCurrent:o,isShow:s,isShowIndex:!!u&&n+1,questionsPerPage:u,question:t}):""})))))}}])&&he(t.prototype,n),r&&he(t,r),i}(i.Component),je=Object(a.compose)(Object(u.withSelect)((function(e,t,n){var r=e("learnpress/quiz"),o=r.getData,i=r.getQuestions;return{status:o("status"),currentQuestion:o("currentQuestion"),questions:i(),questionsRendered:o("questionsRendered"),isReviewing:"reviewing"===o("mode"),numPages:o("numPages"),currentPage:o("currentPage"),questionsPerPage:o("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{startQuiz:t.startQuiz,sendKey:t.sendKey}})))(qe);var Re=function(){var e=Object(u.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&React.createElement(React.Fragment,null,React.createElement("div",{className:"quiz-attempts"},React.createElement("h4",{className:"attempts-heading"},Object(c.__)("Last Attempted","learnpress")),t&&React.createElement("table",null,React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",{className:"quiz-attempts__questions"},Object(c.__)("Questions","learnpress")),React.createElement("th",{className:"quiz-attempts__spend"},Object(c.__)("Time spend","learnpress")),React.createElement("th",{className:"quiz-attempts__marks"},Object(c.__)("Marks","learnpress")),React.createElement("th",{className:"quiz-attempts__grade"},Object(c.__)("Passing grade","learnpress")),React.createElement("th",{className:"quiz-attempts__result"},Object(c.__)("Result","learnpress")))),React.createElement("tbody",null,e.map((function(e,t){if("1"==lpQuizSettings.checkNorequizenroll){var n=window.localStorage.getItem("quiz_start_"+lpQuizSettings.id),r=window.localStorage.getItem("quiz_end_"+lpQuizSettings.id);n&&r&&(e.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(n,r).duration)}return React.createElement("tr",{key:"attempt-".concat(t)},React.createElement("td",{className:"quiz-attempts__questions"},"".concat(e.questionCorrect," / ").concat(e.questionCount)),React.createElement("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),React.createElement("td",{className:"quiz-attempts__marks"},"".concat(e.userMark," / ").concat(e.mark)),React.createElement("td",{className:"quiz-attempts__grade"},e.passingGrade||_x("-","unknown passing grade value","learnpress")),React.createElement("td",{className:"quiz-attempts__result"},"".concat(parseFloat(e.result).toFixed(2),"%")," ",React.createElement("span",null,e.graduationText)))}))))))};function Pe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ee(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ze=function(){var e=Object(u.select)("learnpress/quiz").getData,t=Object(u.dispatch)("learnpress/quiz").submitQuiz,n=e("totalTime")?e("totalTime"):e("duration"),r=e("endTime"),o=new Date(r.replace(/-/g,"/")),a=new Date,s=(new Date).getTimezoneOffset(),c=parseInt(o.getTime()/1e3-(a.getTime()/1e3+60*s)),l=Pe(Object(i.useState)(c>0?c:0),2),f=l[0],p=l[1];Object(i.useEffect)((function(){var e=setInterval((function(){var n=f;(n-=1)>0?p(n):(clearInterval(e),t())}),1e3);return function(){return clearInterval(e)}}),[f]);return React.createElement("div",{className:"countdown"},React.createElement("i",{className:"fas fa-stopwatch"}),React.createElement("span",null,function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":",r=[];return n<3600?(r.push((f-f%60)/60),r.push(f%60)):n&&(r.push((f-f%3600)/3600),e=f%3600,r.push((e-e%60)/60),r.push(e%60)),r.map((function(e){return e<10?"0".concat(e):e})).join(t)}()))},ke=n(9);function Qe(e){return function(e){if(Array.isArray(e))return Ce(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ae(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||Ae(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ae(e,t){if(e){if("string"==typeof e)return Ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ce(e,t):void 0}}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=lodash.debounce,Te=function(){var e=Ie(Object(i.useState)(0),2),t=e[0],n=e[1],r=Ie(Object(i.useState)(!1),2),o=r[0],a=r[1],s=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("id")}),[]),l=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("results")}),[]),f=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("passingGrade")}),[]),p=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("submitting")}),[]);Object(i.useEffect)((function(){m();var e="";if(e=l.graduation?l.graduation:l.result>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed"){var t=document.querySelector(".course-curriculum .course-item.course-item-".concat(s));t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}var n=Qe(document.querySelectorAll("#popup-header .items-progress"))[0];if(n){var r=n.querySelector(".items-completed");if(r){parseInt(r.textContent);var o=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");r.textContent=parseInt(o.length)}}}),[l]),Object(i.useEffect)((function(){void 0!==p&&d()}),[p]);var d=function(){var e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&Object(ke.a)(e[0])},m=function(){n(0),a(!1),jQuery.easing._customEasing=function(e,t,n,r,o){return r*Math.sqrt(1-(t=t/o-1)*t)+n},Ne((function(){var e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:l.result},{duration:1500,step:function(e,t){n(e)},done:function(){a(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),Ne((function(){jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),l.result>0?1e3:10)()},b=t;Number.isInteger(t)||(b=parseFloat(t).toFixed(2));var y=190*Math.PI,h=y-b/100*y,g={strokeDasharray:"".concat(y," ").concat(y),strokeDashoffset:h},v=l.passingGrade||f,w="";w=l.graduation?l.graduation:b>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed";var O="";O=l.graduationText?l.graduationText:"passed"===w?Object(c.__)("Passed","learnpress"):Object(c.__)("Failed","learnpress");var _=["quiz-result",w];if("1"==lpQuizSettings.checkNorequizenroll){var S=window.localStorage.getItem("quiz_start_"+s),q=window.localStorage.getItem("quiz_end_"+s);S&&q&&(l.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(S,q).duration)}return React.createElement("div",{className:_.join(" ")},React.createElement("h3",{className:"result-heading"},Object(c.__)("Your Result","learnpress")),React.createElement("div",{id:"quizResultGrade",className:"result-grade"},React.createElement("svg",{className:"circle-progress-bar",width:200,height:200},React.createElement("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),React.createElement("span",{className:"result-achieved"},"".concat(b,"%")),React.createElement("span",{className:"result-require"},v||_x("-","unknown passing grade value","learnpress"))),o&&React.createElement("p",{className:"result-message"},O),React.createElement("ul",{className:"result-statistic"},React.createElement("li",{className:"result-statistic-field result-time-spend"},React.createElement("span",null,Object(c.__)("Time spend","learnpress")),React.createElement("p",null,l.timeSpend)),React.createElement("li",{className:"result-statistic-field result-point"},React.createElement("span",null,Object(c.__)("Point","learnpress")),React.createElement("p",null,l.userMark," / ",l.mark)),React.createElement("li",{className:"result-statistic-field result-questions"},React.createElement("span",null,Object(c.__)("Questions","learnpress")),React.createElement("p",null,l.questionCount)),React.createElement("li",{className:"result-statistic-field result-questions-correct"},React.createElement("span",null,Object(c.__)("Correct","learnpress")),React.createElement("p",null,l.questionCorrect)),React.createElement("li",{className:"result-statistic-field result-questions-wrong"},React.createElement("span",null,Object(c.__)("Wrong","learnpress")),React.createElement("p",null,l.questionWrong)),React.createElement("li",{className:"result-statistic-field result-questions-skipped"},React.createElement("span",null,Object(c.__)("Skipped","learnpress")),React.createElement("p",null,l.questionEmpty))))},xe=jQuery,De=lodash.debounce,Me=function(){var e=Object(u.dispatch)("learnpress/quiz").submitQuiz;Object(i.useEffect)((function(){var e=xe("#popup-content");if(e.length){var t=e.find(".content-item-scrollable:eq(1)"),n=e.find(".content-item-wrap"),r=e.find(".quiz-status"),o=r.offset().top-92,i=!1,a="-"+n.css("margin-left");xe(window).on("resize.refresh-quiz-stauts-bar",De((function(){a="-"+n.css("margin-left"),r.css({"margin-left":a,"margin-right":a})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(function(){if(t.scrollTop()>=o){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}}),[]);var t=Object(u.select)("learnpress/quiz"),n=t.getData,r=t.getUserMark,o=n("currentPage"),a=n("questionsPerPage"),s=n("questionIds").length,l=n("submitting"),f=n("totalTime"),p=n("duration"),d=r(),m=["quiz-status"],b=(o-1)*a+1,y=b+a-1,h="";return y=Math.min(y,s),l&&m.push("submitting"),h=y<s?a>1?Object(c.sprintf)(Object(c.__)("Question <span>%d to %d of %d</span>","learnpress"),b,y,s):Object(c.sprintf)(Object(c.__)("Question <span>%d of %d</span>","learnpress"),b,s):Object(c.sprintf)(Object(c.__)("Question <span>%d to %d</span>","learnpress"),b,y),React.createElement("div",{className:m.join(" ")},React.createElement("div",null,React.createElement("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:h}}),React.createElement("div",{className:"current-point"},Object(c.sprintf)(Object(c.__)("Earned Point: %s","learnpress"),d)),React.createElement("div",null,React.createElement("div",{className:"submit-quiz"},React.createElement("button",{className:"lp-button",id:"button-submit-quiz",onClick:function t(){"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),t)&&e()}},l?Object(c.__)("Submitting...","learnpress"):Object(c.__)("Finish Quiz","learnpress"))),f&&p&&React.createElement(ze,null))))};function Le(e){return function(e){if(Array.isArray(e))return Ue(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ue(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(n),!0).forEach((function(t){Be(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ge=lodash,Je=(Ge.omit,Ge.flow),Ke=Ge.isArray,We=Ge.chunk,$e=(LP.camelCaseDashObjectKeys,LP.localStorage),Ze=$e.get,Ye=$e.set,Ve={},Xe=function(e,t){var n=He(He({},e.answered[t.questionId]||{}),{},{answered:t.answers,temp:!0});return He(He({},e),{},{answered:He(He({},e.answered),{},Be({},t.questionId,n))})},et=function(e,t){var n=e.questionsRendered;return Ke(n)?(n.push(t.questionId),He(He({},e),{},{questionsRendered:Le(n)})):He(He({},e),{},{questionsRendered:[t.questionId]})},tt=function(e,t){return t.currentPage&&Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),t)},nt=function(e,t){var n=e.questions.map((function(e){return e.id==t.questionId?He(He({},e),{},{showHint:t.showHint}):e}));return He(He({},e),{},{questions:Le(n)})},rt=function(e,t){var n=e.questions.map((function(e){if(e.id!==t.questionId)return e;var n={explanation:t.explanation};return t.options&&(n.options=t.options),He(He({},e),n)}));return He(He({},e),{},{questions:Le(n),answered:He(He({},e.answered),{},Be({},t.questionId,t.result)),checkedQuestions:[].concat(Le(e.checkedQuestions),[t.questionId])})},ot=function(e,t){var n=e.questions.map((function(n){var r={};return e.reviewQuestions&&(t.results.questions[n.id].explanation&&(r.explanation=t.results.questions[n.id].explanation),t.results.questions[n.id].options&&(r.options=t.results.questions[n.id].options)),He(He({},n),r)}));return tt(e,He(He({submitting:!1,currentPage:1},t.results),{},{questions:Le(n)}))},it=function(e,t){var n=void 0!==t.results.success&&t.results.success,r=t.results.message||!1;return tt(e,He(He({checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1},t.results.results),{},{successResponse:n,messageResponse:r}))},at=Je(u.combineReducers,(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}))({a:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1};return e},b:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2};return e}}),ut=Object(u.combineReducers)({blocks:at,userQuiz:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);var n=We(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=n.length,t.data.pages=n,He(He(He({},e),t.data),{},{currentPage:Ze("Q".concat(t.data.id,".currentPage"))||t.data.currentPage});case"SUBMIT_QUIZ":return He(He({},e),{},{submitting:!0});case"START_QUIZ":case"START_QUIZ_SUCCESS":return it(e,t);case"SET_CURRENT_QUESTION":return Ye("Q".concat(e.id,".currentQuestion"),t.questionId),He(He({},e),{},{currentQuestion:t.questionId});case"SET_CURRENT_PAGE":return Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),{},{currentPage:t.currentPage});case"SUBMIT_QUIZ_SUCCESS":return ot(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?Xe(e,t):e;case"MARK_QUESTION_RENDERED":return et(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?tt(e,{mode:t.mode}):He(He({},e),{},{mode:t.mode});case"SET_QUESTION_HINT":return nt(e,t);case"CHECK_ANSWER":return rt(e,t);case"SEND_KEY":return He(He({},e),{},{keyPressed:t.keyPressed})}return e}}),st=n(10);function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var lt=regeneratorRuntime.mark(Et),ft=regeneratorRuntime.mark(Qt),pt=regeneratorRuntime.mark(At);function dt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(e){return function(e){if(Array.isArray(e))return bt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return bt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return bt(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yt(){var e=[].slice.call(arguments,2),t=Object(u.dispatch)(arguments[0]),n=arguments[1];t[n].apply(t,mt(e))}var ht=LP,gt=ht.camelCaseDashObjectKeys,vt=ht.Hook;function wt(e,t){return t="string"==typeof e?dt({},e,t):e,"1"==lpQuizSettings.checkNorequizenroll&&null!==window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id)&&(t=JSON.parse(window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id))),{type:"SET_QUIZ_DATA",data:gt(t)}}function Ot(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function _t(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function St(e,t,n){return{type:"BEFORE_START_QUIZ"}}function qt(e,t,n,r){return vt.doAction("quiz-started",e,t,n,r),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:n,userId:r,results:e}}var jt=regeneratorRuntime.mark((function e(){var t,n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Object(u.select)("learnpress/quiz").getDefaultRestArgs(),n=t.itemId,r=t.courseId,!0===vt.applyFilters("before-start-quiz",!0,n,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,Object(st.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:n,course_id:r}});case 6:return o=e.sent,o=vt.applyFilters("request-start-quiz-response",o,n,r),e.next=10,yt("learnpress/quiz","__requestStartQuizSuccess",gt(o),n,r);case 10:case"end":return e.stop()}}),e)}));function Rt(){return{type:"SUBMIT_QUIZ"}}function Pt(e,t,n){return vt.doAction("quiz-submitted",e,t,n),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function Et(){var e,t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(e=Object(u.select)("learnpress/quiz"),t=e.getDefaultRestArgs,n=e.getQuestionsSelectedAnswers,r=t(),o=r.itemId,i=r.courseId,!0===vt.applyFilters("before-submit-quiz",!0)){c.next=5;break}return c.abrupt("return");case 5:return a=n(),c.next=8,Object(st.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:o,course_id:i,answered:a}});case 8:if(s=c.sent,"1"==lpQuizSettings.checkNorequizenroll&&(window.localStorage.removeItem("quiz_end_"+lpQuizSettings.id),window.localStorage.setItem("quiz_end_"+lpQuizSettings.id,Date.now())),!(s=vt.applyFilters("request-submit-quiz-response",s,o,i)).success){c.next=14;break}return c.next=14,yt("learnpress/quiz","__requestSubmitQuizSuccess",gt(s.results),o,i);case 14:"1"==lpQuizSettings.checkNorequizenroll&&localStorage.setItem("quiz_userdata_"+lpQuizSettings.id,JSON.stringify(Object(u.select)("learnpress/quiz").getData()));case 15:case"end":return c.stop()}}),lt)}function zt(e,t,n){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function kt(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function Qt(e,t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yt("learnpress/quiz","__requestShowHintSuccess",e,t);case 2:case"end":return n.stop()}}),ft)}function It(e,t){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach((function(t){dt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({type:"CHECK_ANSWER",questionId:e},t)}function At(e){var t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return t=Object(u.select)("learnpress/quiz"),n=t.getDefaultRestArgs,r=t.getQuestionAnswered,o=n(),i=o.itemId,a=o.courseId,c.next=4,Object(st.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:i,course_id:a,question_id:e,answered:r(e)||""}});case 4:return s=c.sent,c.next=7,yt("learnpress/quiz","__requestCheckAnswerSuccess",e,gt(s));case 7:case"end":return c.stop()}}),pt)}function Ct(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Nt(e){return{type:"SET_QUIZ_MODE",mode:e}}function Tt(e){return setTimeout((function(){yt("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}var xt=lodash,Dt=xt.get,Mt=xt.isArray,Lt=function(e,t){console.time("parseOptions");var n=Yt(e,t).options;return n=Mt(n)?n:JSON.parse(CryptoJS.AES.decrypt(n.data,n.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),n=Mt(n)?n:JSON.parse(n),console.timeEnd("parseOptions"),n};function Ut(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.status"):""}function Ft(e,t,n){return e[t]||n}function Ht(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.attempts"):[]}function Bt(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.answered",{}):{}}function Gt(e){var t=e.userQuiz,n=Dt(t,"questions");return n?Object.values(n):[]}function Jt(e,t){var n=e.userQuiz;return t?Dt(n,t):n}function Kt(e){var t=e.userQuiz;return{itemId:t.id,courseId:t.courseId}}function Wt(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".answered"))||void 0}function $t(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".mark"))||void 0}function Zt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=Dt(e,"userQuiz.questionsPerPage")||1;if(n>1)return!1;var r=Dt(e,"userQuiz.currentPage")||1;return Dt(e,"object"===t?"userQuiz.questions[".concat(r-1,"]"):"userQuiz.questionIds[".concat(r-1,"]"))}var Yt=function(e,t){e.userQuiz;return Object(u.select)("learnpress/quiz").getQuestions().find((function(e){return e.id==t}))};function Vt(e,t){return-1!==(Dt(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function Xt(e,t){}var en=function(e,t){var n=Dt(e,"userQuiz.answered"),r={};for(var o in n)if(n.hasOwnProperty(o))if("1"==lpQuizSettings.checknorequizenroll){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}else if(n[o].temp||n[o].blanks){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}return r};function tn(e){var t=e.userQuiz||{},n=t.answered,r=t.negativeMarking,o=t.questions,i=t.checkedQuestions,a=0,u=function(e){if(!n.hasOwnProperty(e))return s=e,"continue";e=parseInt(e);var t,u=n[e],c=u.questionMark?u.questionMark:(t=o.find((function(t){return s=e,t.id===e})),s=e,t?t.point:0);i.indexOf(e);if(u.temp)return s=e,"continue";r?u.answered&&(a=u.correct?a+u.mark:a-c):u.answered&&u.correct&&(a+=u.mark),s=e};for(var s in n)u(s);return a>0?a:0}var nn=n(7),rn=n.n(nn),on={ENROLL_COURSE_X:function(e,t){}};var an=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=rn()(on)(n)(e.dispatch),e.dispatch=t,e};function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var cn=LP.dataControls.controls,ln=Object(u.registerStore)("learnpress/quiz",{reducer:ut,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach((function(t){sn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},cn)});an(ln);function fn(e){return(fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function mn(e,t){return(mn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function bn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=gn(e);if(t){var o=gn(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return yn(this,n)}}function yn(e,t){return!t||"object"!==fn(t)&&"function"!=typeof t?hn(e):t}function hn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function gn(e){return(gn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wn=lodash.chunk,On=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mn(e,t)}(i,e);var t,n,r,o=bn(i);function i(e){var t;return pn(this,i),vn(hn(t=o.apply(this,arguments)),"startQuiz",(function(e){t.props.startQuiz()})),t.state={currentPage:1,numPages:0,pages:[]},t}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.settings,n=e.setQuizData,r=t.question_ids,o=t.questions_per_page,i=wn(r,o);t.currentPage=1,t.numPages=i.length,t.pages=i,n(t)}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.isReviewing,r=-1!==["","completed","viewed"].indexOf(t)||!t,o=-1!==["","viewed",void 0].indexOf(t)||!t;return void 0!==t&&React.createElement(React.Fragment,null,React.createElement("div",null,!n&&"completed"===t&&React.createElement(Te,null),!n&&o&&React.createElement(p,null),!n&&o&&React.createElement(s,null),"started"===t&&React.createElement(Me,null),(-1!==["completed","started"].indexOf(t)||n)&&React.createElement(je,null),React.createElement(P,null),r&&!n&&React.createElement(Re,null)))}}])&&dn(t.prototype,n),r&&dn(t,r),i}(i.Component),_n=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getQuestions,r=t.getData;return{questions:n(),status:r("status"),store:r(),answered:r("answered"),isReviewing:"reviewing"===r("mode"),questionIds:r("questionIds"),checkCount:r("instantCheck"),questionsPerPage:r("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{setQuizData:t.setQuizData,startQuiz:t.startQuiz}}))])(On);n(11);function Sn(e){return function(e){if(Array.isArray(e))return qn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qn(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var jn=LP.modal.default,Rn=(t.default=_n,function(e,t){wp.element.render(React.createElement(jn,null,React.createElement(_n,{settings:t})),Sn(document.querySelectorAll(e))[0]),LP.Hook.doAction("lp-quiz-compatible-builder")})}]);
1
+ this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.data},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(2),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,i,a=n[r.type],u=t(r);if(a)for(o=0;o<a.length;o++)(i=a[o](r,e))&&e.dispatch(i);return u}}}).effects=n,t}},,function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n(5),o=n(6);function i(e,t,n,r,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,o)}function a(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;c(n),t.unobserve(n)}}))}));a(e).map((function(e){return t.observe(e)}))}},c=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,s,"next",e)}function s(e){i(a,r,o,u,s,"throw",e)}u(void 0)}))});return function(e){return t.apply(this,arguments)}}()},function(e,t){!function(){e.exports=this.LP.dataControls}()},function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,function(e,t,n){var r;
2
  /*!
3
  Copyright (c) 2018 Jed Watson.
4
  Licensed under the MIT License (MIT), see
5
  http://jedwatson.github.io/classnames
6
+ */!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return Rn}));var r={};n.r(r),n.d(r,"setQuizData",(function(){return wt})),n.d(r,"setCurrentQuestion",(function(){return Ot})),n.d(r,"setCurrentPage",(function(){return _t})),n.d(r,"__requestBeforeStartQuiz",(function(){return St})),n.d(r,"__requestStartQuizSuccess",(function(){return qt})),n.d(r,"startQuiz",(function(){return jt})),n.d(r,"__requestSubmitQuiz",(function(){return Rt})),n.d(r,"__requestSubmitQuizSuccess",(function(){return Pt})),n.d(r,"submitQuiz",(function(){return Et})),n.d(r,"updateUserQuestionAnswers",(function(){return zt})),n.d(r,"__requestShowHintSuccess",(function(){return kt})),n.d(r,"showHint",(function(){return Qt})),n.d(r,"__requestCheckAnswerSuccess",(function(){return It})),n.d(r,"checkAnswer",(function(){return At})),n.d(r,"markQuestionRendered",(function(){return Ct})),n.d(r,"setQuizMode",(function(){return Nt})),n.d(r,"sendKey",(function(){return Tt}));var o={};n.r(o),n.d(o,"getQuestionOptions",(function(){return Lt})),n.d(o,"getItemStatus",(function(){return Ut})),n.d(o,"getProp",(function(){return Ft})),n.d(o,"getQuizAttempts",(function(){return Ht})),n.d(o,"getQuizAnswered",(function(){return Bt})),n.d(o,"getQuestions",(function(){return Gt})),n.d(o,"getData",(function(){return Jt})),n.d(o,"getDefaultRestArgs",(function(){return Kt})),n.d(o,"getQuestionAnswered",(function(){return Wt})),n.d(o,"getQuestionMark",(function(){return $t})),n.d(o,"getCurrentQuestion",(function(){return Zt})),n.d(o,"getQuestion",(function(){return Yt})),n.d(o,"isCheckedAnswer",(function(){return Vt})),n.d(o,"isCorrect",(function(){return Xt})),n.d(o,"getQuestionsSelectedAnswers",(function(){return en})),n.d(o,"getUserMark",(function(){return tn}));var i=n(3),a=n(4),u=n(1),s=function(){var e=Object(u.select)("learnpress/quiz").getData("content");return React.createElement("div",{className:"quiz-content",dangerouslySetInnerHTML:{__html:e}})},c=n(0),l=function(e){var t;if(e>86400)t=(e-e%86400)/86400,e%=86400;else if(86400==e)return"24:00";var n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")},f=LP.Hook,p=function(){var e=function(e){return Object(u.select)("learnpress/quiz").getData(e)},t=f.applyFilters("quiz-meta-fields",{duration:{title:Object(c.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:Object(c.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:Object(c.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&React.createElement(React.Fragment,null,React.createElement("ul",{className:"quiz-intro"},Object.values(t).map((function(e,t){var n=e.name||t;return React.createElement("li",{key:"quiz-intro-field-".concat(t),className:"quiz-intro-item quiz-intro-item--".concat(n)},React.createElement("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),React.createElement("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S(e);if(t){var o=S(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O(this,n)}}function O(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(i,e);var t,n,r,o=w(i);function i(){var e;h(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return q(_(e=o.call.apply(o,[this].concat(n))),"startQuiz",(function(t){t&&t.preventDefault();var n=document.querySelector(".lp-button.start");n&&n.setAttribute("disabled","disabled");var r=e.props,o=r.startQuiz;if("completed"===r.status){var i=Object(u.select)("learnpress/modal"),a=i.confirm,s=i.isOpen;if("no"===a(Object(c.__)("Are you sure you want to retake quiz?","learnpress"),e.startQuiz))return void(!s()&&n&&n.removeAttribute("disabled"))}if("1"==lpQuizSettings.checkNorequizenroll){window.localStorage.removeItem("quiz_start_"+lpQuizSettings.id),window.localStorage.setItem("quiz_start_"+lpQuizSettings.id,Date.now());var l=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);l>=1?window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,parseInt(l)+1):window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,1),window.localStorage.removeItem("quiz_userdata_"+lpQuizSettings.id)}o()})),q(_(e),"nav",(function(t){return function(n){var r=e.props,o=r.questionNav,i=r.currentPage,a=r.numPages,u=r.setCurrentPage;switch(t){case"prev":i>1?i-=1:i="infinity"===o?a:1;break;default:i<a?i+=1:i="infinity"===o?1:a}u(i)}})),q(_(e),"moveTo",(function(t){return function(n){n.preventDefault();var r=e.props,o=r.numPages,i=r.setCurrentPage;t<1||t>o||i(t)}})),q(_(e),"isLast",(function(){var t=e.props;return t.currentPage===t.numPages})),q(_(e),"isFirst",(function(){return 1===e.props.currentPage})),q(_(e),"submit",(function(){var t=e.props.submitQuiz;"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),e.submit)&&t()})),q(_(e),"setQuizMode",(function(t){return function(){(0,e.props.setQuizMode)(t)}})),q(_(e),"isReviewing",(function(){return e.props.isReviewing})),e}return t=i,(n=[{key:"pageNumbers",value:function(e){var t=this,n=this.props,r=n.numPages,o=n.currentPage;if(r<2)return"";(e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){q(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({numPages:r,currentPage:o,midSize:1,endSize:1,prevNext:!0},e||{})).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);var i=m(Array(r).keys()),a=!1;return React.createElement("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&React.createElement("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},Object(c.__)("Prev","learnpress")),i.map((function(n){return(n+=1)===e.currentPage?(a=!0,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers current"},n)):n<=e.endSize||e.currentPage&&n>=e.currentPage-e.midSize&&n<=e.currentPage+e.midSize||n>e.numPages-e.endSize?(a=!0,React.createElement("button",{key:"page-number-".concat(n),className:"page-numbers",onClick:t.moveTo(n)},n)):a?(a=!1,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers dots"},"…")):""})),e.prevNext&&!this.isLast()&&React.createElement("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},Object(c.__)("Next","learnpress")))}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.questionNav,r=e.isReviewing,o=e.showReview,i=e.numPages,a=(e.question,e.questionsPerPage,e.canRetry),u=e.retakeNumber,s=["quiz-buttons"];("started"===t||r)&&s.push("align-center"),"questionNav"===n&&s.push("infinity"),this.isFirst()&&s.push("is-first"),this.isLast()&&s.push("is-last");var l=document.querySelector("#popup-sidebar"),f=document.querySelector("#learn-press-quiz-app"),p="";p="started"===t||r?{marginLeft:l&&l.offsetWidth/2,width:f&&f.offsetWidth}:null;var d=" fixed";return"no"==lpQuizSettings.navigationPosition&&(d=" nav-center"),React.createElement(React.Fragment,null,React.createElement("div",{className:s.join(" ")},React.createElement("div",{className:"button-left"+("started"===t||r?d:""),style:p},("completed"===t&&a||-1!==["","viewed"].indexOf(t))&&!r&&React.createElement("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===t?"".concat(Object(c.__)("Retake","learnpress")).concat(u?" (".concat(u,")"):""):Object(c.__)("Start","learnpress")),("started"===t||r)&&i>1&&React.createElement(React.Fragment,null,React.createElement("div",{className:"questions-pagination"},this.pageNumbers()))),React.createElement("div",{className:"button-right"},"started"===t&&React.createElement(React.Fragment,null,("infinity"===n||this.isLast())&&!r&&React.createElement("button",{className:"lp-button submit-quiz",onClick:this.submit},Object(c.__)("Finish Quiz","learnpress"))),r&&o&&React.createElement("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},Object(c.__)("Result","learnpress")),"completed"===t&&o&&!r&&React.createElement("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},Object(c.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&React.createElement("div",{className:"learn-press-message error"},this.props.message))}}])&&g(t.prototype,n),r&&g(t,r),i}(i.Component),R=Object(a.compose)(Object(u.withSelect)((function(e){var t=e("learnpress/quiz").getData;return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((function(e){var t=e.showCheck,n=e.checkedQuestions,r=e.hintedQuestions,o=e.question,i=e.status,a=e.type,u=e.Button;if("started"!==i)return!1;var s=React.createElement(u,{question:o});switch(a){case"hint":return r?!!o.hasHint&&(-1===r.indexOf(o.id)&&s):s;case"check":return!!t&&(n?-1===n.indexOf(o.id)&&s:s)}})),P=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getData,r=t.getCurrentQuestion,o={id:n("id"),status:n("status"),questionIds:n("questionIds"),questionNav:n("questionNav"),isReviewing:n("reviewQuestions")&&"reviewing"===n("mode"),showReview:n("reviewQuestions"),showCheck:n("instantCheck"),checkedQuestions:n("checkedQuestions"),hintedQuestions:n("hintedQuestions"),numPages:n("numPages"),pages:n("pages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage"),pageNumbers:n("pageNumbers"),keyPressed:n("keyPressed"),canRetry:n("retakeCount")>0&&n("retaken")<n("retakeCount"),retakeNumber:n("retakeCount")>0&&n("retaken")<n("retakeCount")?n("retakeCount")-n("retaken"):null,message:n("messageResponse")||!1,success:void 0===n("successResponse")||n("successResponse")};if(1===o.questionsPerPage&&(o.question=r("object")),"1"==lpQuizSettings.checkNorequizenroll){var i=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);n("retakeCount")>i?(o.retakeNumber=n("retakeCount")-i,o.canRetry=!0):o.canRetry=!1}return o})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz"),r=n.startQuiz,o=n.setCurrentQuestion,i=n.submitQuiz,a=n.setQuizMode,u=n.showHint,s=n.checkAnswer;return{startQuiz:r,setCurrentQuestion:o,setQuizMode:a,setCurrentPage:n.setCurrentPage,submitQuiz:function(e){i(e)},showHint:function(e){u(e)},checkAnswer:function(e){s(e)}}}))])(j);function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=N(e);if(t){var o=N(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return A(this,n)}}function A(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(i,e);var t,n,r,o=I(i);function i(){var e;z(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return T(C(e=o.call.apply(o,[this].concat(n))),"showHint",(function(){var t=e.props,n=t.showHint,r=t.question;n(r.id,!r.showHint)})),e}return t=i,(n=[{key:"render",value:function(){return this.props.question.hint?React.createElement("button",{className:"btn-show-hint",onClick:this.showHint},React.createElement("span",null,Object(c.__)("Hint","learnpress"))):""}}])&&k(t.prototype,n),r&&k(t,r),i}(i.Component),D=Object(a.compose)(Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").showHint;return{showHint:function(e,t){n(e,t)}}})))(x),M=n(13),L=n.n(M);function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function F(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=W(e);if(t){var o=W(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return J(this,n)}}function J(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?K(e):t}function K(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function W(e){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&B(e,t)}(i,e);var t,n,r,o=G(i);function i(){var e;return F(this,i),$(K(e=o.apply(this,arguments)),"checkAnswer",(function(){var t=e.props,n=t.checkAnswer,r=t.question;t.answered&&(n(r.id),e.setState({loading:!0}))})),e.state={loading:!1},e}return t=i,(n=[{key:"render",value:function(){var e=this.props.answered;return React.createElement(React.Fragment,null,React.createElement("button",{className:L()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},React.createElement("span",{className:"instant-check__icon"}),Object(c.__)("Check answer","learnpress"),!e&&React.createElement("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:Object(c.__)("You need to answer the question before check answer.","learnpress")}})))}}])&&H(t.prototype,n),r&&H(t,r),i}(i.Component),Y=Object(a.compose)(Object(u.withSelect)((function(e,t){var n=t.question.id;return{answered:(0,e("learnpress/quiz").getQuestionAnswered)(n)}})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").checkAnswer;return{checkAnswer:function(e){n(e)}}})))(Z),V=function(e){var t=e.question,n={"instant-check":function(){return React.createElement(R,{type:"check",Button:Y,question:t})},hint:function(){return React.createElement(R,{type:"hint",Button:D,question:t})}};return React.createElement(React.Fragment,null,LP.config.questionFooterButtons().map((function(e){return React.createElement(i.Fragment,{key:"button-".concat(e)},n[e]&&n[e]())})))};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=se(e);if(t){var o=se(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ae(this,n)}}function ae(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=window.jQuery,fe=lodash,pe=(fe.uniqueId,fe.isArray),de=(fe.isNumber,fe.bind,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(a,e);var t,n,r,o=ie(a);function a(){var e;return ne(this,a),ce(ue(e=o.apply(this,arguments)),"setRef",(function(t){e.$wrap=le(t)})),ce(ue(e),"parseOptions",(function(e){return e&&(e=pe(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=pe(e)?e:JSON.parse(e)),e||[]})),ce(ue(e),"getWrapperClass",(function(){var t=e.props,n=t.question,r=(t.answered,["question","question-"+n.type]),o=e.parseOptions(n.options);return o.length&&void 0!==o[0].isTrue&&r.push("question-answered"),r})),ce(ue(e),"getEditLink",(function(){var t=e.props,n=t.question,r=t.editPermalink;return r?r.replace(/post=(.*[0-9])/,"post=".concat(n.id)):""})),ce(ue(e),"editPermalink",(function(e){return Object(c.sprintf)('<a href="%s">%s</a>',e,Object(c.__)("Edit","learnpress"))})),e.state={time:null,showHint:!1},e.$wrap=null,e}return t=a,(n=[{key:"componentDidMount",value:function(e){var t=this.props,n=t.question,r=t.isCurrent,o=t.markQuestionRendered;return r&&o(n.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),e}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.isShow,o=t.isShowIndex,a=(t.isShowHint,t.status),u=LP.questionTypes.default,s=this.getEditLink();s&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",s);var l={index:function(){return o?React.createElement("span",{className:"question-index"},o,"."):""},title:function(){return React.createElement("span",{dangerouslySetInnerHTML:{__html:n.title}})},hint:function(){return React.createElement(D,{question:n})},"edit-permalink":function(){return s&&React.createElement("span",{dangerouslySetInnerHTML:{__html:e.editPermalink(s)},className:"edit-link"})}},f={title:function(){return React.createElement("h4",{className:"question-title"},LP.config.questionTitleParts().map((function(e){return React.createElement(i.Fragment,{key:"title-part-".concat(e)},l[e]&&l[e]())})))},content:function(){return React.createElement("div",{className:"question-content",dangerouslySetInnerHTML:{__html:n.content}})},"answer-options":function(){return e.$wrap&&React.createElement(u,te(te({},e.props),{},{$wrap:e.$wrap}))},explanation:function(){return n.explanation&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-explanation-content"},React.createElement("strong",{className:"explanation-title"},Object(c.__)("Explanation:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.explanation}})))},hint:function(){return n.hint&&!n.explanation&&n.showHint&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-hint-content"},React.createElement("strong",{className:"hint-title"},Object(c.__)("Hint:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.hint}})))},buttons:function(){return"started"===a&&React.createElement(V,{question:n})}},p=LP.config.questionBlocks();return React.createElement(React.Fragment,null,React.createElement("div",{className:this.getWrapperClass().join(" "),style:{display:r?"":"none"},"data-id":n.id,ref:this.setRef},p.map((function(e){return React.createElement(i.Fragment,{key:"block-".concat(e)},f[e]?f[e]():"")}))))}}])&&re(t.prototype,n),r&&re(t,r),a}(i.Component)),me=Object(a.compose)([Object(u.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.getQuestionAnswered,a=r.getQuestionMark;return{status:o("status"),questions:o("question"),answered:i(n),questionsRendered:o("questionsRendered"),editPermalink:o("editPermalink"),numPages:o("numPages"),mark:a(n)||""}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz"),n=t.updateUserQuestionAnswers;return{markQuestionRendered:t.markQuestionRendered,updateUserQuestionAnswers:n}}))])(de);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?Oe(e):t}function Oe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ge(e,t)}(i,e);var t,n,r,o=ve(i);function i(e){var t;return ye(this,i),Se(Oe(t=o.apply(this,arguments)),"startQuiz",(function(e){e.preventDefault(),(0,t.props.startQuiz)()})),Se(Oe(t),"isInVisibleRange",(function(e,n){var r=t.props,o=r.currentPage,i=r.questionsPerPage;return o===Math.ceil(n/i)})),Se(Oe(t),"nav",(function(e){var n=t.props.sendKey;switch(e.keyCode){case 37:return n("left");case 38:return;case 39:return n("right");case 40:return;default:e.keyCode>=49&&e.keyCode<=57&&n(e.keyCode-48)}})),t.needToTop=!1,t.state={isReviewing:null,currentPage:0,self:Oe(t)},t}return t=i,r=[{key:"getDerivedStateFromProps",value:function(e,t){for(var n=["isReviewing","currentPage"],r={},o=0;o<n.length;o++)e[n[o]]!==t[n[o]]&&(r[n[o]]=e[n[o]]);return Object.values(r).length?(t.self.needToTop=!0,r):null}}],(n=[{key:"componentDidUpdate",value:function(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}},{key:"render",value:function(){var e=this,t=this.props,n=t.status,r=t.currentQuestion,o=t.questions,i=t.questionsRendered,a=t.isReviewing,u=t.questionsPerPage,s=!0;return"completed"!==n||a||(s=!1),React.createElement(React.Fragment,null,React.createElement("div",{tabIndex:100,onKeyUp:this.nav},React.createElement("div",{className:"quiz-questions",style:{display:s?"":"none"}},o.map((function(t,n){var o=!u&&r===t.id,a=i&&-1!==i.indexOf(t.id),s=e.isInVisibleRange(t.id,n+1);return a||!a||s?React.createElement(me,{key:"loop-question-".concat(t.id),isCurrent:o,isShow:s,isShowIndex:!!u&&n+1,questionsPerPage:u,question:t}):""})))))}}])&&he(t.prototype,n),r&&he(t,r),i}(i.Component),je=Object(a.compose)(Object(u.withSelect)((function(e,t,n){var r=e("learnpress/quiz"),o=r.getData,i=r.getQuestions;return{status:o("status"),currentQuestion:o("currentQuestion"),questions:i(),questionsRendered:o("questionsRendered"),isReviewing:"reviewing"===o("mode"),numPages:o("numPages"),currentPage:o("currentPage"),questionsPerPage:o("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{startQuiz:t.startQuiz,sendKey:t.sendKey}})))(qe);var Re=function(){var e=Object(u.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&React.createElement(React.Fragment,null,React.createElement("div",{className:"quiz-attempts"},React.createElement("h4",{className:"attempts-heading"},Object(c.__)("Last Attempted","learnpress")),t&&React.createElement("table",null,React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",{className:"quiz-attempts__questions"},Object(c.__)("Questions","learnpress")),React.createElement("th",{className:"quiz-attempts__spend"},Object(c.__)("Time spend","learnpress")),React.createElement("th",{className:"quiz-attempts__marks"},Object(c.__)("Marks","learnpress")),React.createElement("th",{className:"quiz-attempts__grade"},Object(c.__)("Passing grade","learnpress")),React.createElement("th",{className:"quiz-attempts__result"},Object(c.__)("Result","learnpress")))),React.createElement("tbody",null,e.map((function(e,t){if("1"==lpQuizSettings.checkNorequizenroll){var n=window.localStorage.getItem("quiz_start_"+lpQuizSettings.id),r=window.localStorage.getItem("quiz_end_"+lpQuizSettings.id);n&&r&&(e.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(n,r).duration)}return React.createElement("tr",{key:"attempt-".concat(t)},React.createElement("td",{className:"quiz-attempts__questions"},"".concat(e.questionCorrect," / ").concat(e.questionCount)),React.createElement("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),React.createElement("td",{className:"quiz-attempts__marks"},"".concat(e.userMark," / ").concat(e.mark)),React.createElement("td",{className:"quiz-attempts__grade"},e.passingGrade||"-"),React.createElement("td",{className:"quiz-attempts__result"},"".concat(parseFloat(e.result).toFixed(2),"%")," ",React.createElement("span",null,e.graduationText)))}))))))};function Pe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ee(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ze=function(){var e=Object(u.select)("learnpress/quiz").getData,t=Object(u.dispatch)("learnpress/quiz").submitQuiz,n=e("totalTime")?e("totalTime"):e("duration"),r=e("endTime"),o=new Date(r.replace(/-/g,"/")),a=new Date,s=(new Date).getTimezoneOffset(),c=parseInt(o.getTime()/1e3-(a.getTime()/1e3+60*s)),l=Pe(Object(i.useState)(c>0?c:0),2),f=l[0],p=l[1];Object(i.useEffect)((function(){var e=setInterval((function(){var n=f;(n-=1)>0?p(n):(clearInterval(e),t())}),1e3);return function(){return clearInterval(e)}}),[f]);return React.createElement("div",{className:"countdown"},React.createElement("i",{className:"fas fa-stopwatch"}),React.createElement("span",null,function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":",r=[];return n<3600?(r.push((f-f%60)/60),r.push(f%60)):n&&(r.push((f-f%3600)/3600),e=f%3600,r.push((e-e%60)/60),r.push(e%60)),r.map((function(e){return e<10?"0".concat(e):e})).join(t)}()))},ke=n(9);function Qe(e){return function(e){if(Array.isArray(e))return Ce(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ae(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||Ae(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ae(e,t){if(e){if("string"==typeof e)return Ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ce(e,t):void 0}}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=lodash.debounce,Te=function(){var e=Ie(Object(i.useState)(0),2),t=e[0],n=e[1],r=Ie(Object(i.useState)(!1),2),o=r[0],a=r[1],s=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("id")}),[]),l=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("results")}),[]),f=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("passingGrade")}),[]),p=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("submitting")}),[]);Object(i.useEffect)((function(){m();var e="";if(e=l.graduation?l.graduation:l.result>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed"){var t=document.querySelector(".course-curriculum .course-item.course-item-".concat(s));t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}var n=Qe(document.querySelectorAll("#popup-header .items-progress"))[0];if(n){var r=n.querySelector(".items-completed");if(r){parseInt(r.textContent);var o=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");r.textContent=parseInt(o.length)}}}),[l]),Object(i.useEffect)((function(){void 0!==p&&d()}),[p]);var d=function(){var e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&Object(ke.a)(e[0])},m=function(){n(0),a(!1),jQuery.easing._customEasing=function(e,t,n,r,o){return r*Math.sqrt(1-(t=t/o-1)*t)+n},Ne((function(){var e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:l.result},{duration:1500,step:function(e,t){n(e)},done:function(){a(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),Ne((function(){jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),l.result>0?1e3:10)()},b=t;Number.isInteger(t)||(b=parseFloat(t).toFixed(2));var y=190*Math.PI,h=y-b/100*y,g={strokeDasharray:"".concat(y," ").concat(y),strokeDashoffset:h},v=l.passingGrade||f,w="";w=l.graduation?l.graduation:b>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed";var O="";O=l.graduationText?l.graduationText:"passed"===w?Object(c.__)("Passed","learnpress"):Object(c.__)("Failed","learnpress");var _=["quiz-result",w];if("1"==lpQuizSettings.checkNorequizenroll){var S=window.localStorage.getItem("quiz_start_"+s),q=window.localStorage.getItem("quiz_end_"+s);S&&q&&(l.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(S,q).duration)}return React.createElement("div",{className:_.join(" ")},React.createElement("h3",{className:"result-heading"},Object(c.__)("Your Result","learnpress")),React.createElement("div",{id:"quizResultGrade",className:"result-grade"},React.createElement("svg",{className:"circle-progress-bar",width:200,height:200},React.createElement("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),React.createElement("span",{className:"result-achieved"},"".concat(b,"%")),React.createElement("span",{className:"result-require"},v||"-")),o&&React.createElement("p",{className:"result-message"},O),React.createElement("ul",{className:"result-statistic"},React.createElement("li",{className:"result-statistic-field result-time-spend"},React.createElement("span",null,Object(c.__)("Time spend","learnpress")),React.createElement("p",null,l.timeSpend)),React.createElement("li",{className:"result-statistic-field result-point"},React.createElement("span",null,Object(c.__)("Point","learnpress")),React.createElement("p",null,l.userMark," / ",l.mark)),React.createElement("li",{className:"result-statistic-field result-questions"},React.createElement("span",null,Object(c.__)("Questions","learnpress")),React.createElement("p",null,l.questionCount)),React.createElement("li",{className:"result-statistic-field result-questions-correct"},React.createElement("span",null,Object(c.__)("Correct","learnpress")),React.createElement("p",null,l.questionCorrect)),React.createElement("li",{className:"result-statistic-field result-questions-wrong"},React.createElement("span",null,Object(c.__)("Wrong","learnpress")),React.createElement("p",null,l.questionWrong)),React.createElement("li",{className:"result-statistic-field result-questions-skipped"},React.createElement("span",null,Object(c.__)("Skipped","learnpress")),React.createElement("p",null,l.questionEmpty))))},xe=jQuery,De=lodash.debounce,Me=function(){var e=Object(u.dispatch)("learnpress/quiz").submitQuiz;Object(i.useEffect)((function(){var e=xe("#popup-content");if(e.length){var t=e.find(".content-item-scrollable:eq(1)"),n=e.find(".content-item-wrap"),r=e.find(".quiz-status"),o=r.offset().top-92,i=!1,a="-"+n.css("margin-left");xe(window).on("resize.refresh-quiz-stauts-bar",De((function(){a="-"+n.css("margin-left"),r.css({"margin-left":a,"margin-right":a})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(function(){if(t.scrollTop()>=o){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}}),[]);var t=Object(u.select)("learnpress/quiz"),n=t.getData,r=t.getUserMark,o=n("currentPage"),a=n("questionsPerPage"),s=n("questionIds").length,l=n("submitting"),f=n("totalTime"),p=n("duration"),d=r(),m=["quiz-status"],b=(o-1)*a+1,y=b+a-1,h="";return y=Math.min(y,s),l&&m.push("submitting"),h=y<s?a>1?Object(c.sprintf)(Object(c.__)("Question <span>%d to %d of %d</span>","learnpress"),b,y,s):Object(c.sprintf)(Object(c.__)("Question <span>%d of %d</span>","learnpress"),b,s):Object(c.sprintf)(Object(c.__)("Question <span>%d to %d</span>","learnpress"),b,y),React.createElement("div",{className:m.join(" ")},React.createElement("div",null,React.createElement("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:h}}),React.createElement("div",{className:"current-point"},Object(c.sprintf)(Object(c.__)("Earned Point: %s","learnpress"),d)),React.createElement("div",null,React.createElement("div",{className:"submit-quiz"},React.createElement("button",{className:"lp-button",id:"button-submit-quiz",onClick:function t(){"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),t)&&e()}},l?Object(c.__)("Submitting...","learnpress"):Object(c.__)("Finish Quiz","learnpress"))),f&&p&&React.createElement(ze,null))))};function Le(e){return function(e){if(Array.isArray(e))return Ue(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ue(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(n),!0).forEach((function(t){Be(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ge=lodash,Je=(Ge.omit,Ge.flow),Ke=Ge.isArray,We=Ge.chunk,$e=(LP.camelCaseDashObjectKeys,LP.localStorage),Ze=$e.get,Ye=$e.set,Ve={},Xe=function(e,t){var n=He(He({},e.answered[t.questionId]||{}),{},{answered:t.answers,temp:!0});return He(He({},e),{},{answered:He(He({},e.answered),{},Be({},t.questionId,n))})},et=function(e,t){var n=e.questionsRendered;return Ke(n)?(n.push(t.questionId),He(He({},e),{},{questionsRendered:Le(n)})):He(He({},e),{},{questionsRendered:[t.questionId]})},tt=function(e,t){return t.currentPage&&Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),t)},nt=function(e,t){var n=e.questions.map((function(e){return e.id==t.questionId?He(He({},e),{},{showHint:t.showHint}):e}));return He(He({},e),{},{questions:Le(n)})},rt=function(e,t){var n=e.questions.map((function(e){if(e.id!==t.questionId)return e;var n={explanation:t.explanation};return t.options&&(n.options=t.options),He(He({},e),n)}));return He(He({},e),{},{questions:Le(n),answered:He(He({},e.answered),{},Be({},t.questionId,t.result)),checkedQuestions:[].concat(Le(e.checkedQuestions),[t.questionId])})},ot=function(e,t){var n=e.questions.map((function(n){var r={};return e.reviewQuestions&&(t.results.questions[n.id].explanation&&(r.explanation=t.results.questions[n.id].explanation),t.results.questions[n.id].options&&(r.options=t.results.questions[n.id].options)),He(He({},n),r)}));return tt(e,He(He({submitting:!1,currentPage:1},t.results),{},{questions:Le(n)}))},it=function(e,t){var n=void 0!==t.results.success&&t.results.success,r=t.results.message||!1;return tt(e,He(He({checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1},t.results.results),{},{successResponse:n,messageResponse:r}))},at=Je(u.combineReducers,(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}))({a:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1};return e},b:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2};return e}}),ut=Object(u.combineReducers)({blocks:at,userQuiz:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);var n=We(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=n.length,t.data.pages=n,He(He(He({},e),t.data),{},{currentPage:Ze("Q".concat(t.data.id,".currentPage"))||t.data.currentPage});case"SUBMIT_QUIZ":return He(He({},e),{},{submitting:!0});case"START_QUIZ":case"START_QUIZ_SUCCESS":return it(e,t);case"SET_CURRENT_QUESTION":return Ye("Q".concat(e.id,".currentQuestion"),t.questionId),He(He({},e),{},{currentQuestion:t.questionId});case"SET_CURRENT_PAGE":return Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),{},{currentPage:t.currentPage});case"SUBMIT_QUIZ_SUCCESS":return ot(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?Xe(e,t):e;case"MARK_QUESTION_RENDERED":return et(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?tt(e,{mode:t.mode}):He(He({},e),{},{mode:t.mode});case"SET_QUESTION_HINT":return nt(e,t);case"CHECK_ANSWER":return rt(e,t);case"SEND_KEY":return He(He({},e),{},{keyPressed:t.keyPressed})}return e}}),st=n(10);function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var lt=regeneratorRuntime.mark(Et),ft=regeneratorRuntime.mark(Qt),pt=regeneratorRuntime.mark(At);function dt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(e){return function(e){if(Array.isArray(e))return bt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return bt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return bt(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yt(){var e=[].slice.call(arguments,2),t=Object(u.dispatch)(arguments[0]),n=arguments[1];t[n].apply(t,mt(e))}var ht=LP,gt=ht.camelCaseDashObjectKeys,vt=ht.Hook;function wt(e,t){return t="string"==typeof e?dt({},e,t):e,"1"==lpQuizSettings.checkNorequizenroll&&null!==window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id)&&(t=JSON.parse(window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id))),{type:"SET_QUIZ_DATA",data:gt(t)}}function Ot(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function _t(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function St(e,t,n){return{type:"BEFORE_START_QUIZ"}}function qt(e,t,n,r){return vt.doAction("quiz-started",e,t,n,r),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:n,userId:r,results:e}}var jt=regeneratorRuntime.mark((function e(){var t,n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Object(u.select)("learnpress/quiz").getDefaultRestArgs(),n=t.itemId,r=t.courseId,!0===vt.applyFilters("before-start-quiz",!0,n,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,Object(st.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:n,course_id:r}});case 6:return o=e.sent,o=vt.applyFilters("request-start-quiz-response",o,n,r),e.next=10,yt("learnpress/quiz","__requestStartQuizSuccess",gt(o),n,r);case 10:case"end":return e.stop()}}),e)}));function Rt(){return{type:"SUBMIT_QUIZ"}}function Pt(e,t,n){return vt.doAction("quiz-submitted",e,t,n),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function Et(){var e,t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(e=Object(u.select)("learnpress/quiz"),t=e.getDefaultRestArgs,n=e.getQuestionsSelectedAnswers,r=t(),o=r.itemId,i=r.courseId,!0===vt.applyFilters("before-submit-quiz",!0)){c.next=5;break}return c.abrupt("return");case 5:return a=n(),c.next=8,Object(st.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:o,course_id:i,answered:a}});case 8:if(s=c.sent,"1"==lpQuizSettings.checkNorequizenroll&&(window.localStorage.removeItem("quiz_end_"+lpQuizSettings.id),window.localStorage.setItem("quiz_end_"+lpQuizSettings.id,Date.now())),!(s=vt.applyFilters("request-submit-quiz-response",s,o,i)).success){c.next=14;break}return c.next=14,yt("learnpress/quiz","__requestSubmitQuizSuccess",gt(s.results),o,i);case 14:"1"==lpQuizSettings.checkNorequizenroll&&localStorage.setItem("quiz_userdata_"+lpQuizSettings.id,JSON.stringify(Object(u.select)("learnpress/quiz").getData()));case 15:case"end":return c.stop()}}),lt)}function zt(e,t,n){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function kt(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function Qt(e,t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yt("learnpress/quiz","__requestShowHintSuccess",e,t);case 2:case"end":return n.stop()}}),ft)}function It(e,t){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach((function(t){dt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({type:"CHECK_ANSWER",questionId:e},t)}function At(e){var t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return t=Object(u.select)("learnpress/quiz"),n=t.getDefaultRestArgs,r=t.getQuestionAnswered,o=n(),i=o.itemId,a=o.courseId,c.next=4,Object(st.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:i,course_id:a,question_id:e,answered:r(e)||""}});case 4:return s=c.sent,c.next=7,yt("learnpress/quiz","__requestCheckAnswerSuccess",e,gt(s));case 7:case"end":return c.stop()}}),pt)}function Ct(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Nt(e){return{type:"SET_QUIZ_MODE",mode:e}}function Tt(e){return setTimeout((function(){yt("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}var xt=lodash,Dt=xt.get,Mt=xt.isArray,Lt=function(e,t){console.time("parseOptions");var n=Yt(e,t).options;return n=Mt(n)?n:JSON.parse(CryptoJS.AES.decrypt(n.data,n.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),n=Mt(n)?n:JSON.parse(n),console.timeEnd("parseOptions"),n};function Ut(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.status"):""}function Ft(e,t,n){return e[t]||n}function Ht(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.attempts"):[]}function Bt(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.answered",{}):{}}function Gt(e){var t=e.userQuiz,n=Dt(t,"questions");return n?Object.values(n):[]}function Jt(e,t){var n=e.userQuiz;return t?Dt(n,t):n}function Kt(e){var t=e.userQuiz;return{itemId:t.id,courseId:t.courseId}}function Wt(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".answered"))||void 0}function $t(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".mark"))||void 0}function Zt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=Dt(e,"userQuiz.questionsPerPage")||1;if(n>1)return!1;var r=Dt(e,"userQuiz.currentPage")||1;return Dt(e,"object"===t?"userQuiz.questions[".concat(r-1,"]"):"userQuiz.questionIds[".concat(r-1,"]"))}var Yt=function(e,t){e.userQuiz;return Object(u.select)("learnpress/quiz").getQuestions().find((function(e){return e.id==t}))};function Vt(e,t){return-1!==(Dt(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function Xt(e,t){}var en=function(e,t){var n=Dt(e,"userQuiz.answered"),r={};for(var o in n)if(n.hasOwnProperty(o))if("1"==lpQuizSettings.checknorequizenroll){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}else if(n[o].temp||n[o].blanks){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}return r};function tn(e){var t=e.userQuiz||{},n=t.answered,r=t.negativeMarking,o=t.questions,i=t.checkedQuestions,a=0,u=function(e){if(!n.hasOwnProperty(e))return s=e,"continue";e=parseInt(e);var t,u=n[e],c=u.questionMark?u.questionMark:(t=o.find((function(t){return s=e,t.id===e})),s=e,t?t.point:0);i.indexOf(e);if(u.temp)return s=e,"continue";r?u.answered&&(a=u.correct?a+u.mark:a-c):u.answered&&u.correct&&(a+=u.mark),s=e};for(var s in n)u(s);return a>0?a:0}var nn=n(7),rn=n.n(nn),on={ENROLL_COURSE_X:function(e,t){}};var an=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=rn()(on)(n)(e.dispatch),e.dispatch=t,e};function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var cn=LP.dataControls.controls,ln=Object(u.registerStore)("learnpress/quiz",{reducer:ut,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach((function(t){sn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},cn)});an(ln);function fn(e){return(fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function mn(e,t){return(mn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function bn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=gn(e);if(t){var o=gn(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return yn(this,n)}}function yn(e,t){return!t||"object"!==fn(t)&&"function"!=typeof t?hn(e):t}function hn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function gn(e){return(gn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wn=lodash.chunk,On=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mn(e,t)}(i,e);var t,n,r,o=bn(i);function i(e){var t;return pn(this,i),vn(hn(t=o.apply(this,arguments)),"startQuiz",(function(e){t.props.startQuiz()})),t.state={currentPage:1,numPages:0,pages:[]},t}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.settings,n=e.setQuizData,r=t.question_ids,o=t.questions_per_page,i=wn(r,o);t.currentPage=1,t.numPages=i.length,t.pages=i,n(t)}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.isReviewing,r=-1!==["","completed","viewed"].indexOf(t)||!t,o=-1!==["","viewed",void 0].indexOf(t)||!t;return void 0!==t&&React.createElement(React.Fragment,null,React.createElement("div",null,!n&&"completed"===t&&React.createElement(Te,null),!n&&o&&React.createElement(p,null),!n&&o&&React.createElement(s,null),"started"===t&&React.createElement(Me,null),(-1!==["completed","started"].indexOf(t)||n)&&React.createElement(je,null),React.createElement(P,null),r&&!n&&React.createElement(Re,null)))}}])&&dn(t.prototype,n),r&&dn(t,r),i}(i.Component),_n=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getQuestions,r=t.getData;return{questions:n(),status:r("status"),store:r(),answered:r("answered"),isReviewing:"reviewing"===r("mode"),questionIds:r("questionIds"),checkCount:r("instantCheck"),questionsPerPage:r("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{setQuizData:t.setQuizData,startQuiz:t.startQuiz}}))])(On);n(11);function Sn(e){return function(e){if(Array.isArray(e))return qn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qn(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var jn=LP.modal.default,Rn=(t.default=_n,function(e,t){wp.element.render(React.createElement(jn,null,React.createElement(_n,{settings:t})),Sn(document.querySelectorAll(e))[0]),LP.Hook.doAction("lp-quiz-compatible-builder")})}]);
assets/js/dist/frontend/single-course.js CHANGED
@@ -166,6 +166,7 @@ __webpack_require__.r(__webpack_exports__);
166
  /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
167
  /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_1__);
168
  /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./show-lp-overlay-complete-item */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
 
169
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
170
 
171
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -185,6 +186,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
185
 
186
 
187
 
 
188
  /* harmony default export */ __webpack_exports__["default"] = (_single_course_index__WEBPACK_IMPORTED_MODULE_0__["default"]);
189
  var init = function init() {
190
  wp.element.render( /*#__PURE__*/React.createElement(_single_course_index__WEBPACK_IMPORTED_MODULE_0__["default"], null));
@@ -326,29 +328,97 @@ var purchaseCourse = function purchaseCourse() {
326
 
327
  if (forms.length > 0) {
328
  forms.forEach(function (form) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  var submit = /*#__PURE__*/function () {
330
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(id, btn) {
331
- var response, status, redirect, message;
 
 
 
 
 
 
 
 
 
 
332
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
333
  while (1) {
334
  switch (_context2.prev = _context2.next) {
335
  case 0:
336
- _context2.prev = 0;
337
- _context2.next = 3;
 
338
  return wp.apiFetch({
339
  path: 'lp/v1/courses/purchase-course',
340
  method: 'POST',
341
  data: {
342
- id: id
 
343
  }
344
  });
345
 
346
- case 3:
347
  response = _context2.sent;
348
- btn.classList.remove('loading');
349
- btn.disabled = false;
350
- status = response.status, redirect = response.data.redirect, message = response.message;
351
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  if (message && status) {
353
  form.innerHTML += "<div class=\"lp-enroll-notice ".concat(status, "\">").concat(message, "</div>");
354
 
@@ -357,20 +427,21 @@ var purchaseCourse = function purchaseCourse() {
357
  }
358
  }
359
 
360
- _context2.next = 13;
 
361
  break;
362
 
363
- case 10:
364
- _context2.prev = 10;
365
- _context2.t0 = _context2["catch"](0);
366
  form.innerHTML += "<div class=\"lp-enroll-notice error\">".concat(_context2.t0.message && _context2.t0.message, "</div>");
367
 
368
- case 13:
369
  case "end":
370
  return _context2.stop();
371
  }
372
  }
373
- }, _callee2, null, [[0, 10]]);
374
  }));
375
 
376
  return function submit(_x3, _x4) {
166
  /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
167
  /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_1__);
168
  /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./show-lp-overlay-complete-item */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/show-lp-overlay-complete-item.js");
169
+ /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/lp-modal-overlay */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/utils/lp-modal-overlay.js");
170
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
171
 
172
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
186
 
187
 
188
 
189
+
190
  /* harmony default export */ __webpack_exports__["default"] = (_single_course_index__WEBPACK_IMPORTED_MODULE_0__["default"]);
191
  var init = function init() {
192
  wp.element.render( /*#__PURE__*/React.createElement(_single_course_index__WEBPACK_IMPORTED_MODULE_0__["default"], null));
328
 
329
  if (forms.length > 0) {
330
  forms.forEach(function (form) {
331
+ // Allow Repurchase.
332
+ var allowRepurchase = function allowRepurchase() {
333
+ var continueRepurchases = document.querySelectorAll('.lp_allow_repuchase_select');
334
+ continueRepurchases.forEach(function (repurchase) {
335
+ var radios = repurchase.querySelectorAll('[name=_lp_allow_repurchase_type]');
336
+
337
+ for (var i = 0, length = radios.length; i < length; i++) {
338
+ if (radios[i].checked) {
339
+ var repurchaseType = radios[i].value;
340
+ var id = form.querySelector('input[name=purchase-course]').value;
341
+ var btnBuynow = form.querySelector('button.button-purchase-course');
342
+ btnBuynow.classList.add('loading');
343
+ btnBuynow.disabled = true;
344
+ submit(id, btnBuynow, repurchaseType);
345
+ break;
346
+ }
347
+ }
348
+ });
349
+ };
350
+
351
  var submit = /*#__PURE__*/function () {
352
  var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(id, btn) {
353
+ var repurchaseType,
354
+ response,
355
+ status,
356
+ _response$data,
357
+ redirect,
358
+ type,
359
+ html,
360
+ titlePopup,
361
+ message,
362
+ _args2 = arguments;
363
+
364
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
365
  while (1) {
366
  switch (_context2.prev = _context2.next) {
367
  case 0:
368
+ repurchaseType = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
369
+ _context2.prev = 1;
370
+ _context2.next = 4;
371
  return wp.apiFetch({
372
  path: 'lp/v1/courses/purchase-course',
373
  method: 'POST',
374
  data: {
375
+ id: id,
376
+ repurchaseType: repurchaseType
377
  }
378
  });
379
 
380
+ case 4:
381
  response = _context2.sent;
 
 
 
382
 
383
+ if (btn) {
384
+ btn.classList.remove('loading');
385
+ btn.disabled = false;
386
+ }
387
+
388
+ status = response.status, _response$data = response.data, redirect = _response$data.redirect, type = _response$data.type, html = _response$data.html, titlePopup = _response$data.titlePopup, message = response.message;
389
+
390
+ if (!(type === 'allow_repurchase' && status === 'success')) {
391
+ _context2.next = 17;
392
+ break;
393
+ }
394
+
395
+ if (form.querySelector('.lp_allow_repuchase_select')) {
396
+ _context2.next = 15;
397
+ break;
398
+ }
399
+
400
+ if (_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].init()) {
401
+ _context2.next = 11;
402
+ break;
403
+ }
404
+
405
+ return _context2.abrupt("return");
406
+
407
+ case 11:
408
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].elLPOverlay.show();
409
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].setTitleModal(titlePopup || '');
410
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].setContentModal(html);
411
+
412
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].callBackYes = function () {
413
+ _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_3__["default"].elLPOverlay.hide();
414
+ allowRepurchase();
415
+ };
416
+
417
+ case 15:
418
+ _context2.next = 18;
419
+ break;
420
+
421
+ case 17:
422
  if (message && status) {
423
  form.innerHTML += "<div class=\"lp-enroll-notice ".concat(status, "\">").concat(message, "</div>");
424
 
427
  }
428
  }
429
 
430
+ case 18:
431
+ _context2.next = 23;
432
  break;
433
 
434
+ case 20:
435
+ _context2.prev = 20;
436
+ _context2.t0 = _context2["catch"](1);
437
  form.innerHTML += "<div class=\"lp-enroll-notice error\">".concat(_context2.t0.message && _context2.t0.message, "</div>");
438
 
439
+ case 23:
440
  case "end":
441
  return _context2.stop();
442
  }
443
  }
444
+ }, _callee2, null, [[1, 20]]);
445
  }));
446
 
447
  return function submit(_x3, _x4) {
assets/js/dist/frontend/single-course.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.singleCourse=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=25)}([,,function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return a}));var i=jQuery,a=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},,,,,,,function(e,t){!function(){e.exports=this.LP.quiz}()},function(e,t){},,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return b})),n.d(t,"initCourseTabs",(function(){return w})),n.d(t,"initCourseSidebar",(function(){return S})),n.d(t,"enrollCourse",(function(){return L}));var r=n(2),o=(n(15),n(16),n(8));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(i,e);var t,n,r,o=c(i);function i(){return a(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"render",value:function(){return React.createElement(React.Fragment,null)}}])&&s(t.prototype,n),r&&s(t,r),i}(r.Component);document.addEventListener("DOMContentLoaded",(function(){Object(o.a)()}));n(5);var p=n(6);function v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){y(i,r,o,a,s,"next",e)}function s(e){y(i,r,o,a,s,"throw",e)}a(void 0)}))}}t.default=f;var b=function(){wp.element.render(React.createElement(f,null))},g=jQuery,w=function(){g("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){var t=g('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),g('label[for="'+g(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")}))},S=function(){var e=g(".course-summary-sidebar");if(e.length){var t=g(window),n=e.children(),r=e.offset(),o=e.height(),i=n.height(),a=32;t.on("scroll.fixed-course-sidebar",(function(){var s=t.scrollTop()-r.top+a;if(s<0)return e.removeClass("slide-top slide-down"),void n.css("top","");s>o-i?(e.removeClass("slide-down").addClass("slide-top"),n.css("top",o-i)):(e.removeClass("slide-top").addClass("slide-down"),n.css("top",a))})).trigger("scroll.fixed-course-sidebar")}},L=function(){var e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(r.style.display="none",e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),form.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(function(e){(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))},C=function(){var e=document.querySelectorAll(".lp-form-retake-course");e.length&&e.forEach((function(e){var t=e.querySelector(".button-retake-course"),n=e.querySelector("[name=retake-course]").value,r=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(function(e){e.preventDefault()})),t.addEventListener("click",(function(e){var o;e.preventDefault(),t.classList.add("loading"),t.disabled=!0,o=t,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:n}}).then((function(e){var t=e.status,n=e.message,i=e.data;r.innerHTML=n,null!=t&&"success"===t?(o.style.display="none",setTimeout((function(){window.location.replace(i.url_redirect)}),1e3)):r.classList.add("error")})).catch((function(e){r.classList.add("error"),r.innerHTML="error: "+e.message})).then((function(){o.classList.remove("loading"),o.disabled=!1,r.style.display="block"}))}))}))};g(window).on("load",(function(){var e;g("#popup-course"),g("#learn-press-course-curriculum");v(document.querySelectorAll(".course-extra-box")).map((function(e){var t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(function(){var n=t.nextElementSibling,r=document.querySelector(".course-extra-box.active");r&&!e.classList.contains("active")&&(r.classList.remove("active"),r.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),n.style.display="none"):(e.classList.add("active"),n.style.display="block")}))})),w(),S(),L(),(e=document.querySelectorAll("form.purchase-course")).length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),"success"===i&&a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),e.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=purchase-course]").value,o=e.querySelector("button.button-purchase-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),C(),function(){var e=document.querySelectorAll(".lp-course-progress-wrapper");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,r){e.forEach((function(e){if(e.isIntersecting){var r=e.target;setTimeout((function(){n(r)}),600),t.unobserve(r)}}))}));v(e).map((function(e){return t.observe(e)}))}var n=function(){var e=h(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}});case 2:n=e.sent,r=n.data,t.innerHTML=r;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}(),p.a.init()}))}]);
1
+ this.LP=this.LP||{},this.LP.singleCourse=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=25)}([,,function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},function(e,t){e.exports=window.wp.element},,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(2),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return a}));var i=jQuery,a=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},,,,,,,function(e,t){!function(){e.exports=this.LP.quiz}()},function(e,t){},,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return g})),n.d(t,"initCourseTabs",(function(){return S})),n.d(t,"initCourseSidebar",(function(){return L})),n.d(t,"enrollCourse",(function(){return C}));var r=n(3),o=(n(15),n(16),n(8));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r,o=c(i);function i(){return a(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"render",value:function(){return React.createElement(React.Fragment,null)}}])&&l(t.prototype,n),r&&l(t,r),i}(r.Component);document.addEventListener("DOMContentLoaded",(function(){Object(o.a)()}));n(5);var p=n(6),v=n(2);function m(e){return function(e){if(Array.isArray(e))return y(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return y(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function h(e,t,n,r,o,i,a){try{var l=e[i](a),s=l.value}catch(e){return void n(e)}l.done?t(s):Promise.resolve(s).then(r,o)}function b(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){h(i,r,o,a,l,"next",e)}function l(e){h(i,r,o,a,l,"throw",e)}a(void 0)}))}}t.default=f;var g=function(){wp.element.render(React.createElement(f,null))},w=jQuery,S=function(){w("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){var t=w('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),w('label[for="'+w(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")}))},L=function(){var e=w(".course-summary-sidebar");if(e.length){var t=w(window),n=e.children(),r=e.offset(),o=e.height(),i=n.height(),a=32;t.on("scroll.fixed-course-sidebar",(function(){var l=t.scrollTop()-r.top+a;if(l<0)return e.removeClass("slide-top slide-down"),void n.css("top","");l>o-i?(e.removeClass("slide-down").addClass("slide-top"),n.css("top",o-i)):(e.removeClass("slide-top").addClass("slide-down"),n.css("top",a))})).trigger("scroll.fixed-course-sidebar")}},C=function(){var e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((function(e){var t=function(){var t=b(regeneratorRuntime.mark((function t(n,r){var o,i,a,l;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(l=o.message)&&i&&(r.style.display="none",e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(l,"</div>"),a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),form.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(function(e){(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))},k=function(){var e=document.querySelectorAll(".lp-form-retake-course");e.length&&e.forEach((function(e){var t=e.querySelector(".button-retake-course"),n=e.querySelector("[name=retake-course]").value,r=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(function(e){e.preventDefault()})),t.addEventListener("click",(function(e){var o;e.preventDefault(),t.classList.add("loading"),t.disabled=!0,o=t,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:n}}).then((function(e){var t=e.status,n=e.message,i=e.data;r.innerHTML=n,null!=t&&"success"===t?(o.style.display="none",setTimeout((function(){window.location.replace(i.url_redirect)}),1e3)):r.classList.add("error")})).catch((function(e){r.classList.add("error"),r.innerHTML="error: "+e.message})).then((function(){o.classList.remove("loading"),o.disabled=!1,r.style.display="block"}))}))}))};w(window).on("load",(function(){var e;w("#popup-course"),w("#learn-press-course-curriculum");m(document.querySelectorAll(".course-extra-box")).map((function(e){var t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(function(){var n=t.nextElementSibling,r=document.querySelector(".course-extra-box.active");r&&!e.classList.contains("active")&&(r.classList.remove("active"),r.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),n.style.display="none"):(e.classList.add("active"),n.style.display="block")}))})),S(),L(),C(),(e=document.querySelectorAll("form.purchase-course")).length>0&&e.forEach((function(e){var t=function(){document.querySelectorAll(".lp_allow_repuchase_select").forEach((function(t){for(var r=t.querySelectorAll("[name=_lp_allow_repurchase_type]"),o=0,i=r.length;o<i;o++)if(r[o].checked){var a=r[o].value,l=e.querySelector("input[name=purchase-course]").value,s=e.querySelector("button.button-purchase-course");s.classList.add("loading"),s.disabled=!0,n(l,s,a);break}}))},n=function(){var n=b(regeneratorRuntime.mark((function n(r,o){var i,a,l,s,c,u,d,f,p,m=arguments;return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return i=m.length>2&&void 0!==m[2]&&m[2],n.prev=1,n.next=4,wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:r,repurchaseType:i}});case 4:if(a=n.sent,o&&(o.classList.remove("loading"),o.disabled=!1),l=a.status,s=a.data,c=s.redirect,u=s.type,d=s.html,f=s.titlePopup,p=a.message,"allow_repurchase"!==u||"success"!==l){n.next=17;break}if(e.querySelector(".lp_allow_repuchase_select")){n.next=15;break}if(v.a.init()){n.next=11;break}return n.abrupt("return");case 11:v.a.elLPOverlay.show(),v.a.setTitleModal(f||""),v.a.setContentModal(d),v.a.callBackYes=function(){v.a.elLPOverlay.hide(),t()};case 15:n.next=18;break;case 17:p&&l&&(e.innerHTML+='<div class="lp-enroll-notice '.concat(l,'">').concat(p,"</div>"),"success"===l&&c&&(window.location.href=c));case 18:n.next=23;break;case 20:n.prev=20,n.t0=n.catch(1),e.innerHTML+='<div class="lp-enroll-notice error">'.concat(n.t0.message&&n.t0.message,"</div>");case 23:case"end":return n.stop()}}),n,null,[[1,20]])})));return function(e,t){return n.apply(this,arguments)}}();e.addEventListener("submit",(function(t){t.preventDefault();var r=e.querySelector("input[name=purchase-course]").value,o=e.querySelector("button.button-purchase-course");o.classList.add("loading"),o.disabled=!0,n(r,o)}))})),k(),function(){var e=document.querySelectorAll(".lp-course-progress-wrapper");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,r){e.forEach((function(e){if(e.isIntersecting){var r=e.target;setTimeout((function(){n(r)}),600),t.unobserve(r)}}))}));m(e).map((function(e){return t.observe(e)}))}var n=function(){var e=b(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}});case 2:n=e.sent,r=n.data,t.innerHTML=r;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}(),p.a.init()}))}]);
assets/js/dist/frontend/single-curriculum.min.js CHANGED
@@ -1 +1 @@
1
- this.LP=this.LP||{},this.LP.singleCurriculum=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=23)}([,,function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return l}));var i=jQuery,l=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},function(e,t,n){"use strict";n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return a}));var r=n(5),o=n(6);function i(e,t,n,r,o,i,l){try{var c=e[i](l),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var u=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;a(n),t.unobserve(n)}}))}));l(e).map((function(e){return t.observe(e)}))}},a=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function c(e){i(l,r,o,c,u,"next",e)}function u(e){i(l,r,o,c,u,"throw",e)}c(void 0)}))});return function(e){return t.apply(this,arguments)}}()},,function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,,,,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return g}));var r=n(2),o=n(8),i=jQuery,l=n(9);n(11);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}jQuery;var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r,o=f(i);function i(){return u(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"checkCourseDurationExpire",value:function(){var e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){var t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}},{key:"render",value:function(){return React.createElement("div",null)}}])&&a(t.prototype,n),r&&a(t,r),i}(r.Component),y=m;document.addEventListener("DOMContentLoaded",(function(){LP.Hook.doAction("lp-compatible-builder"),function(){var e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){var n=t.querySelector(".curriculum-sections"),r=e.querySelector(".search-course"),o=e.querySelector('.search-course input[type="text"]');if(!o||!n||!r)return;var i=n.querySelectorAll("li.section"),l=n.querySelectorAll("li.course-item"),c=[];l.forEach((function(e){var t=e.dataset.id,n=e.querySelector(".item-name");c.push({id:t,name:n?n.textContent.toLowerCase():""})}));var u=function(e){e.preventDefault();var t=o.value;r.classList.add("searching"),t||r.classList.remove("searching");var n=[];c.forEach((function(e){t&&!e.name.match(t.toLowerCase())||(n.push(e.id),l.forEach((function(e){-1!==n.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),i.forEach((function(e){var t=e.querySelectorAll(".course-item"),r=[];t.forEach((function(e){n.includes(e.dataset.id)&&r.push(e.dataset.id)})),0===r.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},a=r.querySelector(".clear");a&&a.addEventListener("click",(function(e){e.preventDefault(),o.value="",u(e)})),r.addEventListener("submit",u),o.addEventListener("keyup",u)}}(),Object(o.a)(),i(".learn-press-progress").each((function(){var e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")})),Object(l.b)(),(new m).checkCourseDurationExpire()}));var v=n(6),h=(n(3),jQuery),b={init:function(){this.scrollToItemViewing=function(){var e=h(".viewing-course-item");if(e.length){var t=h("#learn-press-course-curriculum"),n=(h("#popup-sidebar").outerHeight(),h(".section-title").outerHeight(),h(".section-header").outerHeight()),r=new RegExp("^viewing-course-item-([0-9].*)"),o=e.attr("class").split(/\s+/),i=0;if(h.each(o,(function(e,t){var n=r.exec(t);if(n)return i=n[1],!1})),0===i)return;var l=h(".course-item-"+i),c=(l.offset().top,l.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:c-n},800)}},this.scrollToItemViewing()}},g=(jQuery,t.default=y,function(){wp.element.render(React.createElement(y,null),document.getElementById("learn-press-course-curriculum"))});document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),v.a.init(),b.init()}))}]);
1
+ this.LP=this.LP||{},this.LP.singleCurriculum=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=23)}([,,function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},function(e,t){e.exports=window.wp.element},,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(2),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return l}));var i=jQuery,l=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},function(e,t,n){"use strict";n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return a}));var r=n(5),o=n(6);function i(e,t,n,r,o,i,l){try{var c=e[i](l),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var u=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;a(n),t.unobserve(n)}}))}));l(e).map((function(e){return t.observe(e)}))}},a=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function c(e){i(l,r,o,c,u,"next",e)}function u(e){i(l,r,o,c,u,"throw",e)}c(void 0)}))});return function(e){return t.apply(this,arguments)}}()},,function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,,,,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return g}));var r=n(3),o=n(8),i=jQuery,l=n(9);n(11);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}jQuery;var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r,o=f(i);function i(){return u(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"checkCourseDurationExpire",value:function(){var e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){var t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}},{key:"render",value:function(){return React.createElement("div",null)}}])&&a(t.prototype,n),r&&a(t,r),i}(r.Component),y=m;document.addEventListener("DOMContentLoaded",(function(){LP.Hook.doAction("lp-compatible-builder"),function(){var e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){var n=t.querySelector(".curriculum-sections"),r=e.querySelector(".search-course"),o=e.querySelector('.search-course input[type="text"]');if(!o||!n||!r)return;var i=n.querySelectorAll("li.section"),l=n.querySelectorAll("li.course-item"),c=[];l.forEach((function(e){var t=e.dataset.id,n=e.querySelector(".item-name");c.push({id:t,name:n?n.textContent.toLowerCase():""})}));var u=function(e){e.preventDefault();var t=o.value;r.classList.add("searching"),t||r.classList.remove("searching");var n=[];c.forEach((function(e){t&&!e.name.match(t.toLowerCase())||(n.push(e.id),l.forEach((function(e){-1!==n.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),i.forEach((function(e){var t=e.querySelectorAll(".course-item"),r=[];t.forEach((function(e){n.includes(e.dataset.id)&&r.push(e.dataset.id)})),0===r.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},a=r.querySelector(".clear");a&&a.addEventListener("click",(function(e){e.preventDefault(),o.value="",u(e)})),r.addEventListener("submit",u),o.addEventListener("keyup",u)}}(),Object(o.a)(),i(".learn-press-progress").each((function(){var e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")})),Object(l.b)(),(new m).checkCourseDurationExpire()}));var v=n(6),h=(n(2),jQuery),b={init:function(){this.scrollToItemViewing=function(){var e=h(".viewing-course-item");if(e.length){var t=h("#learn-press-course-curriculum"),n=(h("#popup-sidebar").outerHeight(),h(".section-title").outerHeight(),h(".section-header").outerHeight()),r=new RegExp("^viewing-course-item-([0-9].*)"),o=e.attr("class").split(/\s+/),i=0;if(h.each(o,(function(e,t){var n=r.exec(t);if(n)return i=n[1],!1})),0===i)return;var l=h(".course-item-"+i),c=(l.offset().top,l.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:c-n},800)}},this.scrollToItemViewing()}},g=(jQuery,t.default=y,function(){wp.element.render(React.createElement(y,null),document.getElementById("learn-press-course-curriculum"))});document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),v.a.init(),b.init()}))}]);
assets/src/apps/js/frontend/profile/statistic.js CHANGED
@@ -33,9 +33,9 @@ const courseStatistics = () => {
33
  } );
34
 
35
  if ( response.status === 'success' && response.data ) {
36
- ele.innerHTML += response.data;
37
  } else {
38
- ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ response.message && response.message }</div>`;
39
  }
40
  } catch ( error ) {
41
  ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message && error.message }</div>`;
33
  } );
34
 
35
  if ( response.status === 'success' && response.data ) {
36
+ ele.innerHTML = response.data;
37
  } else {
38
+ ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${ response.message && response.message }</div>`;
39
  }
40
  } catch ( error ) {
41
  ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message && error.message }</div>`;
assets/src/apps/js/frontend/quiz/components/attempts/index.js CHANGED
@@ -40,7 +40,7 @@ const Attempts = () => {
40
  <td className="quiz-attempts__questions">{ `${ row.questionCorrect } / ${ row.questionCount }` }</td>
41
  <td className="quiz-attempts__spend">{ row.timeSpend || '--' }</td>
42
  <td className="quiz-attempts__marks">{ `${ row.userMark } / ${ row.mark }` }</td>
43
- <td className="quiz-attempts__grade">{ row.passingGrade || _x( '-', 'unknown passing grade value', 'learnpress' ) }</td>
44
  <td className="quiz-attempts__result">{ `${ parseFloat( row.result ).toFixed( 2 ) }%` } <span>{ row.graduationText }</span></td>
45
  </tr>
46
  );
40
  <td className="quiz-attempts__questions">{ `${ row.questionCorrect } / ${ row.questionCount }` }</td>
41
  <td className="quiz-attempts__spend">{ row.timeSpend || '--' }</td>
42
  <td className="quiz-attempts__marks">{ `${ row.userMark } / ${ row.mark }` }</td>
43
+ <td className="quiz-attempts__grade">{ row.passingGrade || '-' }</td>
44
  <td className="quiz-attempts__result">{ `${ parseFloat( row.result ).toFixed( 2 ) }%` } <span>{ row.graduationText }</span></td>
45
  </tr>
46
  );
assets/src/apps/js/frontend/quiz/components/result/index.js CHANGED
@@ -180,7 +180,7 @@ const Result = () => {
180
 
181
  <span className="result-achieved">{ `${ percentResult }%` }</span>
182
  <span className="result-require">
183
- { passingGradeValue || _x( '-', 'unknown passing grade value', 'learnpress' ) }
184
  </span>
185
  </div>
186
 
180
 
181
  <span className="result-achieved">{ `${ percentResult }%` }</span>
182
  <span className="result-require">
183
+ { passingGradeValue || '-' }
184
  </span>
185
  </div>
186
 
assets/src/apps/js/frontend/single-course.js CHANGED
@@ -1,6 +1,7 @@
1
  import SingleCourse from './single-course/index';
2
  import { addQueryArgs } from '@wordpress/url';
3
  import lpModalOverlayCompleteItem from './show-lp-overlay-complete-item';
 
4
 
5
  export default SingleCourse;
6
 
@@ -126,20 +127,63 @@ const purchaseCourse = () => {
126
 
127
  if ( forms.length > 0 ) {
128
  forms.forEach( ( form ) => {
129
- const submit = async ( id, btn ) => {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  try {
131
  const response = await wp.apiFetch( {
132
  path: 'lp/v1/courses/purchase-course',
133
  method: 'POST',
134
- data: { id },
135
  } );
136
 
137
- btn.classList.remove( 'loading' );
138
- btn.disabled = false;
 
 
139
 
140
- const { status, data: { redirect }, message } = response;
141
 
142
- if ( message && status ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  form.innerHTML += `<div class="lp-enroll-notice ${ status }">${ message }</div>`;
144
 
145
  if ( 'success' === status && redirect ) {
1
  import SingleCourse from './single-course/index';
2
  import { addQueryArgs } from '@wordpress/url';
3
  import lpModalOverlayCompleteItem from './show-lp-overlay-complete-item';
4
+ import lpModalOverlay from '../utils/lp-modal-overlay';
5
 
6
  export default SingleCourse;
7
 
127
 
128
  if ( forms.length > 0 ) {
129
  forms.forEach( ( form ) => {
130
+ // Allow Repurchase.
131
+ const allowRepurchase = () => {
132
+ const continueRepurchases = document.querySelectorAll( '.lp_allow_repuchase_select' );
133
+
134
+ continueRepurchases.forEach( ( repurchase ) => {
135
+ const radios = repurchase.querySelectorAll( '[name=_lp_allow_repurchase_type]' );
136
+
137
+ for ( let i = 0, length = radios.length; i < length; i++ ) {
138
+ if ( radios[ i ].checked ) {
139
+ const repurchaseType = radios[ i ].value;
140
+ const id = form.querySelector( 'input[name=purchase-course]' ).value;
141
+
142
+ const btnBuynow = form.querySelector( 'button.button-purchase-course' );
143
+ btnBuynow.classList.add( 'loading' );
144
+ btnBuynow.disabled = true;
145
+
146
+ submit( id, btnBuynow, repurchaseType );
147
+ break;
148
+ }
149
+ }
150
+ } );
151
+ };
152
+
153
+ const submit = async ( id, btn, repurchaseType = false ) => {
154
  try {
155
  const response = await wp.apiFetch( {
156
  path: 'lp/v1/courses/purchase-course',
157
  method: 'POST',
158
+ data: { id, repurchaseType },
159
  } );
160
 
161
+ if ( btn ) {
162
+ btn.classList.remove( 'loading' );
163
+ btn.disabled = false;
164
+ }
165
 
166
+ const { status, data: { redirect, type, html, titlePopup }, message } = response;
167
 
168
+ if ( type === 'allow_repurchase' && status === 'success' ) {
169
+ if ( ! form.querySelector( '.lp_allow_repuchase_select' ) ) {
170
+ if ( ! lpModalOverlay.init() ) {
171
+ return;
172
+ }
173
+
174
+ lpModalOverlay.elLPOverlay.show();
175
+
176
+ lpModalOverlay.setTitleModal( titlePopup || '' );
177
+
178
+ lpModalOverlay.setContentModal( html );
179
+
180
+ lpModalOverlay.callBackYes = () => {
181
+ lpModalOverlay.elLPOverlay.hide();
182
+
183
+ allowRepurchase();
184
+ };
185
+ }
186
+ } else if ( message && status ) {
187
  form.innerHTML += `<div class="lp-enroll-notice ${ status }">${ message }</div>`;
188
 
189
  if ( 'success' === status && redirect ) {
assets/src/js/admin/learnpress.js CHANGED
@@ -37,6 +37,8 @@ const makePaymentsSortable = function makePaymentsSortable() {
37
  } );
38
  };
39
 
 
 
40
  const lpMetaboxCustomFields = () => {
41
  $( '.lp-metabox__custom-fields' ).on( 'click', '.lp-metabox-custom-field-button', function() {
42
  const row = $( this ).data( 'row' ).replace( /lp_metabox_custom_fields_key/gi, Math.floor( Math.random() * 1000 ) + 1 );
@@ -429,6 +431,62 @@ const lpMetaboxCourseTabs = () => {
429
  } ).trigger( 'lp-metabox-course-tab-panels' );
430
  };
431
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
432
  const initTooltips = function initTooltips() {
433
  $( '.learn-press-tooltip' ).each( function() {
434
  const $el = $( this ),
@@ -732,6 +790,7 @@ const onReady = function onReady() {
732
  lpMetaboxExtraInfo();
733
  lpHidePassingGrade();
734
  lpGetFinalQuiz();
 
735
 
736
  $( document )
737
  .on( 'click', '.learn-press-payments .status .dashicons', togglePaymentStatus )
37
  } );
38
  };
39
 
40
+ /** Start Nhamdv code */
41
+
42
  const lpMetaboxCustomFields = () => {
43
  $( '.lp-metabox__custom-fields' ).on( 'click', '.lp-metabox-custom-field-button', function() {
44
  const row = $( this ).data( 'row' ).replace( /lp_metabox_custom_fields_key/gi, Math.floor( Math.random() * 1000 ) + 1 );
431
  } ).trigger( 'lp-metabox-course-tab-panels' );
432
  };
433
 
434
+ // use to show and hide field condition logic metabox.
435
+ const lpMetaboxCondition = () => {
436
+ const fields = document.querySelectorAll( '.lp-meta-box .form-field' );
437
+
438
+ fields.forEach( ( field ) => {
439
+ if ( field.hasAttribute( 'data-show' ) && field.dataset.show ) {
440
+ lpMetaboxConditionType( field, field.dataset.show, 'show' );
441
+ } else if ( field.hasAttribute( 'data-hide' ) && field.dataset.hide ) {
442
+ lpMetaboxConditionType( field, field.dataset.hide, 'hide' );
443
+ }
444
+ } );
445
+ };
446
+
447
+ const lpMetaboxConditionType = ( field, conditions, typeCondition = 'show' ) => {
448
+ const condition = JSON.parse( conditions ),
449
+ eles = document.querySelectorAll( `input[id^="${ condition[ 0 ] }"]` ),
450
+ logic = condition[ 1 ] === '=' ? '=' : '!=',
451
+ dataLogic = condition[ 2 ];
452
+
453
+ const switchCase = ( type, ele, target ) => {
454
+ switch ( type ) {
455
+ case 'checkbox':
456
+ let val = dataLogic;
457
+
458
+ if ( dataLogic === 'yes' || dataLogic === '1' || dataLogic === 1 || dataLogic === 'true' ) {
459
+ val = true;
460
+ } else if ( dataLogic === 'no' || dataLogic === '0' || dataLogic === 0 || dataLogic === 'false' ) {
461
+ val = false;
462
+ }
463
+
464
+ if ( logic == '!=' && val !== Boolean( target ? target.checked : ele.checked ) ) {
465
+ field.style.display = typeCondition === 'show' ? 'flex' : 'none';
466
+ } else if ( logic == '=' && val == Boolean( target ? target.checked : ele.checked ) ) {
467
+ field.style.display = typeCondition === 'show' ? 'flex' : 'none';
468
+ } else {
469
+ field.style.display = typeCondition === 'show' ? 'none' : 'flex';
470
+ }
471
+ break;
472
+ }
473
+ };
474
+
475
+ eles.forEach( ( ele ) => {
476
+ const type = ele.getAttribute( 'type' );
477
+
478
+ switchCase( type, ele );
479
+
480
+ ele.addEventListener( 'change', ( e ) => {
481
+ const target = e.target;
482
+
483
+ switchCase( type, ele, target );
484
+ } );
485
+ } );
486
+ };
487
+
488
+ /** End Nhamdv code */
489
+
490
  const initTooltips = function initTooltips() {
491
  $( '.learn-press-tooltip' ).each( function() {
492
  const $el = $( this ),
790
  lpMetaboxExtraInfo();
791
  lpHidePassingGrade();
792
  lpGetFinalQuiz();
793
+ lpMetaboxCondition();
794
 
795
  $( document )
796
  .on( 'click', '.learn-press-payments .status .dashicons', togglePaymentStatus )
inc/admin/views/meta-boxes/course/settings.php CHANGED
@@ -64,6 +64,10 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
64
  }
65
 
66
  public function general( $thepostid ) {
 
 
 
 
67
  return apply_filters(
68
  'lp/course/meta-box/fields/general',
69
  array(
@@ -94,6 +98,19 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
94
  esc_html__( 'Allow users to repurchase this course after course finished or blocked ( Do not apply to free courses ).', 'learnpress' ),
95
  'no'
96
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  '_lp_level' => new LP_Meta_Box_Select_Field(
98
  esc_html__( 'Level', 'learnpress' ),
99
  esc_html__( 'Choose a difficulty level.', 'learnpress' ),
@@ -188,7 +205,7 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
188
  return apply_filters(
189
  'lp/course/meta-box/fields/price',
190
  array(
191
- '_lp_price' => new LP_Meta_Box_Text_Field(
192
  esc_html__( 'Regular price', 'learnpress' ),
193
  sprintf( __( 'Set a regular price (<strong>%s</strong>). Leave it blank for <strong>Free</strong>.', 'learnpress' ), learn_press_get_currency() ),
194
  $price,
@@ -202,7 +219,7 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
202
  'class' => 'lp_meta_box_regular_price',
203
  )
204
  ),
205
- '_lp_sale_price' => new LP_Meta_Box_Text_Field(
206
  esc_html__( 'Sale price', 'learnpress' ),
207
  '<a href="#" class="lp_sale_price_schedule">' . esc_html__( 'Schedule', 'learnpress' ) . '</a>',
208
  $sale_price,
@@ -216,7 +233,7 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
216
  'class' => 'lp_meta_box_sale_price',
217
  )
218
  ),
219
- '_lp_sale_start' => new LP_Meta_Box_Date_Field(
220
  esc_html__( 'Sale start dates', 'learnpress' ),
221
  '',
222
  '',
@@ -225,7 +242,7 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
225
  'placeholder' => _x( 'From&hellip;', 'placeholder', 'learnpress' ),
226
  )
227
  ),
228
- '_lp_sale_end' => new LP_Meta_Box_Date_Field(
229
  esc_html__( 'Sale end dates', 'learnpress' ),
230
  '',
231
  '',
@@ -235,7 +252,7 @@ class LP_Meta_Box_Course extends LP_Meta_Box {
235
  'cancel' => true,
236
  )
237
  ),
238
- '_lp_no_required_enroll' => new LP_Meta_Box_Checkbox_Field(
239
  esc_html__( 'No requirement enroll', 'learnpress' ),
240
  esc_html__( 'Students can see the content of all course items and do the quiz without login.', 'learnpress' ),
241
  'no'
64
  }
65
 
66
  public function general( $thepostid ) {
67
+ $repurchase_option_desc = sprintf( '1. %s', __( 'Reset course progress: The course progress and results of student will be removed.' ) );
68
+ $repurchase_option_desc .= '<br/>' . sprintf( '2. %s', __( 'Keep course progress: The course progress and results of student will remain.' ) );
69
+ $repurchase_option_desc .= '<br/>' . sprintf( '3. %s', __( 'Open popup: The student can decide whether their course progress will be reset with the confirm popup.' ) );
70
+
71
  return apply_filters(
72
  'lp/course/meta-box/fields/general',
73
  array(
98
  esc_html__( 'Allow users to repurchase this course after course finished or blocked ( Do not apply to free courses ).', 'learnpress' ),
99
  'no'
100
  ),
101
+ '_lp_course_repurchase_option' => new LP_Meta_Box_Select_Field(
102
+ esc_html__( 'Repurchase action', 'learnpress' ),
103
+ $repurchase_option_desc,
104
+ 'reset',
105
+ array(
106
+ 'options' => array(
107
+ 'reset' => esc_html__( 'Reset course progress', 'learnpress' ),
108
+ 'keep' => esc_html__( 'Keep course progress', 'learnpress' ),
109
+ 'popup' => esc_html__( 'Open popup', 'learnpress' ),
110
+ ),
111
+ 'show' => array( '_lp_allow_course_repurchase', '=', 'yes' ), // use 'show' or 'hide'
112
+ )
113
+ ),
114
  '_lp_level' => new LP_Meta_Box_Select_Field(
115
  esc_html__( 'Level', 'learnpress' ),
116
  esc_html__( 'Choose a difficulty level.', 'learnpress' ),
205
  return apply_filters(
206
  'lp/course/meta-box/fields/price',
207
  array(
208
+ '_lp_price' => new LP_Meta_Box_Text_Field(
209
  esc_html__( 'Regular price', 'learnpress' ),
210
  sprintf( __( 'Set a regular price (<strong>%s</strong>). Leave it blank for <strong>Free</strong>.', 'learnpress' ), learn_press_get_currency() ),
211
  $price,
219
  'class' => 'lp_meta_box_regular_price',
220
  )
221
  ),
222
+ '_lp_sale_price' => new LP_Meta_Box_Text_Field(
223
  esc_html__( 'Sale price', 'learnpress' ),
224
  '<a href="#" class="lp_sale_price_schedule">' . esc_html__( 'Schedule', 'learnpress' ) . '</a>',
225
  $sale_price,
233
  'class' => 'lp_meta_box_sale_price',
234
  )
235
  ),
236
+ '_lp_sale_start' => new LP_Meta_Box_Date_Field(
237
  esc_html__( 'Sale start dates', 'learnpress' ),
238
  '',
239
  '',
242
  'placeholder' => _x( 'From&hellip;', 'placeholder', 'learnpress' ),
243
  )
244
  ),
245
+ '_lp_sale_end' => new LP_Meta_Box_Date_Field(
246
  esc_html__( 'Sale end dates', 'learnpress' ),
247
  '',
248
  '',
252
  'cancel' => true,
253
  )
254
  ),
255
+ '_lp_no_required_enroll' => new LP_Meta_Box_Checkbox_Field(
256
  esc_html__( 'No requirement enroll', 'learnpress' ),
257
  esc_html__( 'Students can see the content of all course items and do the quiz without login.', 'learnpress' ),
258
  'no'
inc/admin/views/meta-boxes/fields/class-lp-meta-box-fields.php CHANGED
@@ -43,6 +43,11 @@ class LP_Meta_Box_Field {
43
  */
44
  public $extra = array();
45
 
 
 
 
 
 
46
  /**
47
  * LP_Meta_Box_Attribute constructor.
48
  *
@@ -60,6 +65,15 @@ class LP_Meta_Box_Field {
60
  $this->description = $description;
61
  $this->default = $default;
62
  $this->extra = $extra;
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
  public function meta_value( $thepostid ) {
43
  */
44
  public $extra = array();
45
 
46
+ /**
47
+ * Condition logic show or hide when checkbox, select or...
48
+ */
49
+ public $condition = false;
50
+
51
  /**
52
  * LP_Meta_Box_Attribute constructor.
53
  *
65
  $this->description = $description;
66
  $this->default = $default;
67
  $this->extra = $extra;
68
+
69
+ $show = ! empty( $extra['show'] ) ? htmlentities( wp_json_encode( $extra['show'] ) ) : false;
70
+ $hide = ! empty( $extra['hide'] ) ? htmlentities( wp_json_encode( $extra['hide'] ) ) : false;
71
+
72
+ if ( $show ) {
73
+ $this->condition = 'data-show="' . $show . '"';
74
+ } elseif ( $hide ) {
75
+ $this->condition = 'data-hide="' . $hide . '"';
76
+ }
77
  }
78
 
79
  public function meta_value( $thepostid ) {
inc/admin/views/meta-boxes/fields/select.php CHANGED
@@ -76,7 +76,7 @@ class LP_Meta_Box_Select_Field extends LP_Meta_Box_Field {
76
  $description = ! empty( $field['description'] ) && false === $field['desc_tip'] ? $field['description'] : '';
77
  ?>
78
 
79
- <p class="form-field <?php echo esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ); ?>">
80
  <label for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo wp_kses_post( $field['label'] ); ?></label>
81
  <select <?php echo lp_implode_html_attributes( $field_attributes ); ?>>
82
  <?php
76
  $description = ! empty( $field['description'] ) && false === $field['desc_tip'] ? $field['description'] : '';
77
  ?>
78
 
79
+ <p class="form-field <?php echo esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ); ?>" <?php echo $this->condition ? $this->condition : ''; ?>>
80
  <label for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo wp_kses_post( $field['label'] ); ?></label>
81
  <select <?php echo lp_implode_html_attributes( $field_attributes ); ?>>
82
  <?php
inc/course/abstract-course.php CHANGED
@@ -148,34 +148,35 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
148
  $post_object = get_post( $id );
149
  $this->_set_data(
150
  array(
151
- 'status' => $post_object->post_status,
152
- 'no_required_enroll' => get_post_meta( $id, '_lp_no_required_enroll', true ),
153
- 'price' => get_post_meta( $id, '_lp_price', true ),
154
- 'sale_price' => get_post_meta( $id, '_lp_sale_price', true ),
155
- 'sale_start' => get_post_meta( $id, '_lp_sale_start', true ),
156
- 'sale_end' => get_post_meta( $id, '_lp_sale_end', true ),
157
- 'duration' => get_post_meta( $id, '_lp_duration', true ),
158
- 'max_students' => get_post_meta( $id, '_lp_max_students', true ),
159
- 'students' => false,
160
- 'fake_students' => get_post_meta( $id, '_lp_students', true ),
161
- 'retake_count' => get_post_meta( $id, '_lp_retake_count', true ),
162
- 'featured' => get_post_meta( $id, '_lp_featured', true ),
163
- 'block_lesson_content' => get_post_meta( $id, '_lp_block_lesson_content', true ),
164
- 'course_result' => get_post_meta( $id, '_lp_course_result', true ),
165
- 'passing_condition' => get_post_meta( $id, '_lp_passing_condition', true ),
166
- 'final_quiz' => get_post_meta( $id, '_lp_final_quiz', true ),
167
- 'external_link' => get_post_meta( $id, '_lp_external_link_buy_course', true ),
168
- 'block_course_duration_expire' => get_post_meta(
169
  $id,
170
  '_lp_block_expire_duration',
171
  true
172
  ),
173
- 'block_course_finished' => get_post_meta(
174
  $id,
175
  '_lp_block_finished',
176
  true
177
  ),
178
- 'allow_repurchase' => get_post_meta( $id, '_lp_allow_course_repurchase', true ),
 
179
  )
180
  );
181
  }
@@ -189,7 +190,8 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
189
  $item_by_types = array();
190
  $section_items = array();
191
 
192
- if ( $items = $this->_curd->read_course_curriculum( $this->get_id() ) ) {
 
193
  foreach ( $items as $item ) {
194
  $item_ids[] = $item->id;
195
 
@@ -574,12 +576,12 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
574
  }
575
 
576
  /**
 
 
577
  * @return int
578
  */
579
- public function get_fake_students() {
580
- $count = $this->get_data( 'fake_students' );
581
-
582
- return is_numeric( $count ) ? absint( $count ) : 0;
583
  }
584
 
585
  /**
@@ -598,9 +600,6 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
598
 
599
  $enrolled = absint( $enrolled );
600
 
601
- // @deprecated
602
- $enrolled = apply_filters( 'learn_press_count_users_enrolled', $enrolled, $this );
603
-
604
  return apply_filters( 'learn-press/course/users-enrolled', $enrolled, $this );
605
  }
606
 
@@ -989,16 +988,18 @@ if ( ! function_exists( 'LP_Abstract_Course' ) ) {
989
  * and add the fake value if both are set.
990
  *
991
  * @return int
 
 
992
  */
993
- public function count_students() {
994
  $count_users = LP()->utils->count_course_users( $this->get_id(), true );
995
  $total = ! empty( $count_users['total'] ) ? $count_users['total'] : 0;
996
 
997
- $append_students = LP()->settings()->get( 'enrolled_students_number' );
998
 
999
- if ( ( 'yes' == $append_students ) || ! in_array( $append_students, array( 'yes', 'no' ) ) ) {
1000
- $total += $this->get_fake_students();
1001
- }
1002
 
1003
  return $total;
1004
  }
148
  $post_object = get_post( $id );
149
  $this->_set_data(
150
  array(
151
+ 'status' => $post_object->post_status,
152
+ 'no_required_enroll' => get_post_meta( $id, '_lp_no_required_enroll', true ),
153
+ 'price' => get_post_meta( $id, '_lp_price', true ),
154
+ 'sale_price' => get_post_meta( $id, '_lp_sale_price', true ),
155
+ 'sale_start' => get_post_meta( $id, '_lp_sale_start', true ),
156
+ 'sale_end' => get_post_meta( $id, '_lp_sale_end', true ),
157
+ 'duration' => get_post_meta( $id, '_lp_duration', true ),
158
+ 'max_students' => get_post_meta( $id, '_lp_max_students', true ),
159
+ 'students' => false,
160
+ 'fake_students' => get_post_meta( $id, '_lp_students', true ),
161
+ 'retake_count' => get_post_meta( $id, '_lp_retake_count', true ),
162
+ 'featured' => get_post_meta( $id, '_lp_featured', true ),
163
+ 'block_lesson_content' => get_post_meta( $id, '_lp_block_lesson_content', true ),
164
+ 'course_result' => get_post_meta( $id, '_lp_course_result', true ),
165
+ 'passing_condition' => get_post_meta( $id, '_lp_passing_condition', true ),
166
+ 'final_quiz' => get_post_meta( $id, '_lp_final_quiz', true ),
167
+ 'external_link' => get_post_meta( $id, '_lp_external_link_buy_course', true ),
168
+ 'block_course_duration_expire' => get_post_meta(
169
  $id,
170
  '_lp_block_expire_duration',
171
  true
172
  ),
173
+ 'block_course_finished' => get_post_meta(
174
  $id,
175
  '_lp_block_finished',
176
  true
177
  ),
178
+ 'allow_repurchase' => get_post_meta( $id, '_lp_allow_course_repurchase', true ),
179
+ 'allow_repurchase_course_option' => get_post_meta( $id, '_lp_course_repurchase_option', true ),
180
  )
181
  );
182
  }
190
  $item_by_types = array();
191
  $section_items = array();
192
 
193
+ $items = $this->_curd->read_course_curriculum( $this->get_id() );
194
+ if ( $items ) {
195
  foreach ( $items as $item ) {
196
  $item_ids[] = $item->id;
197
 
576
  }
577
 
578
  /**
579
+ * Get total students fake.
580
+ *
581
  * @return int
582
  */
583
+ public function get_fake_students() : int {
584
+ return absint( $this->get_data( 'fake_students', 0 ) );
 
 
585
  }
586
 
587
  /**
600
 
601
  $enrolled = absint( $enrolled );
602
 
 
 
 
603
  return apply_filters( 'learn-press/course/users-enrolled', $enrolled, $this );
604
  }
605
 
988
  * and add the fake value if both are set.
989
  *
990
  * @return int
991
+ * @editor tungnx
992
+ * @Todo: view and rewrite this function
993
  */
994
+ public function count_students(): int {
995
  $count_users = LP()->utils->count_course_users( $this->get_id(), true );
996
  $total = ! empty( $count_users['total'] ) ? $count_users['total'] : 0;
997
 
998
+ // $append_students = LP()->settings()->get( 'enrolled_students_number' );
999
 
1000
+ // if ( ( 'yes' == $append_students ) || ! in_array( $append_students, array( 'yes', 'no' ) ) ) {
1001
+ $total += $this->get_fake_students();
1002
+ // }
1003
 
1004
  return $total;
1005
  }
inc/course/class-lp-course.php CHANGED
@@ -271,6 +271,10 @@ if ( ! class_exists( 'LP_Course' ) ) {
271
  return 'yes' === $this->get_data( 'allow_repurchase' );
272
  }
273
 
 
 
 
 
274
  /**
275
  * Get first item of course
276
  *
271
  return 'yes' === $this->get_data( 'allow_repurchase' );
272
  }
273
 
274
+ public function allow_repurchase_course_option() : string {
275
+ return $this->get_data( 'allow_repurchase_course_option', 'reset' );
276
+ }
277
+
278
  /**
279
  * Get first item of course
280
  *
inc/curds/class-lp-user-curd.php CHANGED
@@ -1596,17 +1596,19 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
1596
 
1597
  // JOIN
1598
  $join = $wpdb->prepare(
1599
- "INNER JOIN {$wpdb->posts} c ON c.ID = ui.item_id AND c.post_type = %s",
1600
  LP_COURSE_CPT
1601
  );
1602
 
1603
- // WHERE
1604
  $where = $wpdb->prepare(
1605
  '
1606
  WHERE ui.user_id = %d
1607
  AND c.ID IN(' . join( ',', $course_ids ) . ')
1608
- ',
1609
- $user_id
 
 
1610
  );
1611
  $count_where = $where;
1612
 
@@ -1666,7 +1668,8 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
1666
  $unenrolled_course_ids = $this->query_courses_by_order( $user_id );
1667
  }
1668
 
1669
- $where .= $wpdb->prepare( ' AND ui.status NOT IN(%s) ', 'pending' );
 
1670
 
1671
  $query_parts = apply_filters(
1672
  'learn-press/query/user-purchased-courses',
@@ -1797,7 +1800,8 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
1797
  LP_COURSE_CPT
1798
  );
1799
 
1800
- if ( $rows = $wpdb->get_results( $sql ) ) {
 
1801
  foreach ( $rows as $row ) {
1802
  $counts[ $row->status ] = $row->count;
1803
  }
1596
 
1597
  // JOIN
1598
  $join = $wpdb->prepare(
1599
+ "INNER JOIN {$wpdb->posts} c ON ui.item_id = c.ID AND c.post_type = %s",
1600
  LP_COURSE_CPT
1601
  );
1602
 
1603
+ // WHERE - modify by tungnx
1604
  $where = $wpdb->prepare(
1605
  '
1606
  WHERE ui.user_id = %d
1607
  AND c.ID IN(' . join( ',', $course_ids ) . ')
1608
+ AND c.post_status = %s
1609
+ ',
1610
+ $user_id,
1611
+ 'publish'
1612
  );
1613
  $count_where = $where;
1614
 
1668
  $unenrolled_course_ids = $this->query_courses_by_order( $user_id );
1669
  }
1670
 
1671
+ // Comment by tungnx
1672
+ //$where .= $wpdb->prepare( ' AND ui.status NOT IN(%s) ', 'pending' );
1673
 
1674
  $query_parts = apply_filters(
1675
  'learn-press/query/user-purchased-courses',
1800
  LP_COURSE_CPT
1801
  );
1802
 
1803
+ $rows = $wpdb->get_results( $sql );
1804
+ if ( $rows ) {
1805
  foreach ( $rows as $row ) {
1806
  $counts[ $row->status ] = $row->count;
1807
  }
inc/databases/class-lp-user-items-db.php CHANGED
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  class LP_User_Items_DB extends LP_Database {
15
  private static $_instance;
16
  public static $user_item_id_col = 'learnpress_user_item_id';
17
- public static $extra_value_col = 'extra_value';
18
 
19
  protected function __construct() {
20
  parent::__construct();
@@ -129,8 +129,10 @@ class LP_User_Items_DB extends LP_Database {
129
  WHERE ref_id = %d
130
  AND ref_type = %s
131
  AND item_id = %d
132
- ",
133
- $course_id, 'lp_course', $item_id
 
 
134
  );
135
 
136
  return $this->wpdb->get_var( $query );
@@ -147,22 +149,35 @@ class LP_User_Items_DB extends LP_Database {
147
  * @author tungnx
148
  */
149
  public function update_extra_value( $user_item_id = 0, $meta_key = '', $value = '' ) {
150
- $data = array( 'learnpress_user_item_id' => $user_item_id, 'meta_key' => $meta_key, 'extra_value' => $value );
 
 
 
 
151
  $format = array( '%s', '%s' );
152
 
153
  $check_exist_data = $this->wpdb->get_var(
154
- $this->wpdb->prepare( "
 
155
  SELECT meta_id FROM $this->tb_lp_user_itemmeta
156
- WHERE " . self::$user_item_id_col . " = %d
157
  AND meta_key = %s
158
- ",
159
- $user_item_id, $meta_key
 
160
  )
161
  );
162
 
163
  if ( $check_exist_data ) {
164
- $this->wpdb->update( $this->tb_lp_user_itemmeta, $data,
165
- array( self::$user_item_id_col => $user_item_id, 'meta_key' => $meta_key ), $format );
 
 
 
 
 
 
 
166
  } else {
167
  $this->wpdb->insert( $this->tb_lp_user_itemmeta, $data, $format );
168
  }
@@ -176,11 +191,12 @@ class LP_User_Items_DB extends LP_Database {
176
  */
177
  public function get_extra_value( $user_item_id = 0, $meta_key = '' ) {
178
  return $this->wpdb->get_var(
179
- $this->wpdb->prepare( "
180
- SELECT " . self::$extra_value_col . " FROM $this->tb_lp_user_itemmeta
181
- WHERE " . self::$user_item_id_col . " = %d
 
182
  AND meta_key = %s
183
- ",
184
  $user_item_id,
185
  $meta_key
186
  )
@@ -192,7 +208,7 @@ class LP_User_Items_DB extends LP_Database {
192
  * @param $item_id
193
  * @editor hungkv
194
  */
195
- function reset_course_current_item( $course_id, $item_id ) {
196
  // Select all course enrolled
197
  $query = $this->wpdb->prepare(
198
  "
@@ -200,7 +216,9 @@ class LP_User_Items_DB extends LP_Database {
200
  FROM {$this->wpdb->prefix}learnpress_user_items
201
  WHERE status = %s AND item_id = %d AND graduation = %s
202
  ",
203
- 'enrolled', $course_id, 'in-progress'
 
 
204
  );
205
  $user_item_ids = $this->wpdb->get_col( $query );
206
  if ( ! empty( $user_item_ids ) ) {
@@ -224,6 +242,36 @@ class LP_User_Items_DB extends LP_Database {
224
  }
225
  }
226
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
 
229
  LP_Course_DB::getInstance();
14
  class LP_User_Items_DB extends LP_Database {
15
  private static $_instance;
16
  public static $user_item_id_col = 'learnpress_user_item_id';
17
+ public static $extra_value_col = 'extra_value';
18
 
19
  protected function __construct() {
20
  parent::__construct();
129
  WHERE ref_id = %d
130
  AND ref_type = %s
131
  AND item_id = %d
132
+ ",
133
+ $course_id,
134
+ 'lp_course',
135
+ $item_id
136
  );
137
 
138
  return $this->wpdb->get_var( $query );
149
  * @author tungnx
150
  */
151
  public function update_extra_value( $user_item_id = 0, $meta_key = '', $value = '' ) {
152
+ $data = array(
153
+ 'learnpress_user_item_id' => $user_item_id,
154
+ 'meta_key' => $meta_key,
155
+ 'extra_value' => $value,
156
+ );
157
  $format = array( '%s', '%s' );
158
 
159
  $check_exist_data = $this->wpdb->get_var(
160
+ $this->wpdb->prepare(
161
+ "
162
  SELECT meta_id FROM $this->tb_lp_user_itemmeta
163
+ WHERE " . self::$user_item_id_col . ' = %d
164
  AND meta_key = %s
165
+ ',
166
+ $user_item_id,
167
+ $meta_key
168
  )
169
  );
170
 
171
  if ( $check_exist_data ) {
172
+ $this->wpdb->update(
173
+ $this->tb_lp_user_itemmeta,
174
+ $data,
175
+ array(
176
+ self::$user_item_id_col => $user_item_id,
177
+ 'meta_key' => $meta_key,
178
+ ),
179
+ $format
180
+ );
181
  } else {
182
  $this->wpdb->insert( $this->tb_lp_user_itemmeta, $data, $format );
183
  }
191
  */
192
  public function get_extra_value( $user_item_id = 0, $meta_key = '' ) {
193
  return $this->wpdb->get_var(
194
+ $this->wpdb->prepare(
195
+ '
196
+ SELECT ' . self::$extra_value_col . " FROM $this->tb_lp_user_itemmeta
197
+ WHERE " . self::$user_item_id_col . ' = %d
198
  AND meta_key = %s
199
+ ',
200
  $user_item_id,
201
  $meta_key
202
  )
208
  * @param $item_id
209
  * @editor hungkv
210
  */
211
+ public function reset_course_current_item( $course_id, $item_id ) {
212
  // Select all course enrolled
213
  $query = $this->wpdb->prepare(
214
  "
216
  FROM {$this->wpdb->prefix}learnpress_user_items
217
  WHERE status = %s AND item_id = %d AND graduation = %s
218
  ",
219
+ 'enrolled',
220
+ $course_id,
221
+ 'in-progress'
222
  );
223
  $user_item_ids = $this->wpdb->get_col( $query );
224
  if ( ! empty( $user_item_ids ) ) {
242
  }
243
  }
244
  }
245
+
246
+ /**
247
+ * Get total courses is has graduation is 'in_progress'
248
+ *
249
+ * @param int $user_id
250
+ * @param string $status
251
+ * @return int
252
+ * @throws Exception
253
+ */
254
+ public function get_total_courses_has_status( int $user_id, string $status ): int {
255
+ $query = $this->wpdb->prepare(
256
+ "
257
+ SELECT COUNT(DISTINCT(item_id)) total
258
+ FROM $this->tb_lp_user_items
259
+ INNER JOIN $this->tb_posts AS p
260
+ ON item_id = p.ID
261
+ WHERE item_type = %s
262
+ AND user_id = %d
263
+ AND graduation = %s
264
+ AND p.post_status = 'publish'
265
+ ",
266
+ LP_COURSE_CPT,
267
+ $user_id,
268
+ $status
269
+ );
270
+
271
+ $this->check_execute_has_error();
272
+
273
+ return (int) $this->wpdb->get_var( $query );
274
+ }
275
  }
276
 
277
  LP_Course_DB::getInstance();
inc/order/lp-order-functions.php CHANGED
@@ -827,8 +827,9 @@ add_action( 'init', 'learn_press_cancel_order_process' );
827
  *
828
  * @param $result
829
  * @param $order_id
 
830
  */
831
- function _learn_press_checkout_auto_enroll_free_course( $result, $order_id ) {
832
  return;
833
  $enrolled = false;
834
  $order = learn_press_get_order( $order_id, true );
@@ -859,5 +860,5 @@ function _learn_press_checkout_auto_enroll_free_course( $result, $order_id ) {
859
  }
860
 
861
  return $result;
862
- }
863
 
827
  *
828
  * @param $result
829
  * @param $order_id
830
+ * @editor tungnx - comment - for not use
831
  */
832
+ /*function _learn_press_checkout_auto_enroll_free_course( $result, $order_id ) {
833
  return;
834
  $enrolled = false;
835
  $order = learn_press_get_order( $order_id, true );
860
  }
861
 
862
  return $result;
863
+ }*/
864
 
inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php CHANGED
@@ -307,7 +307,8 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
307
  $params = $request->get_params();
308
 
309
  try {
310
- $course_id = $params['id'];
 
311
 
312
  if ( ! $course_id ) {
313
  throw new Exception( __( 'Error: Invalid Course ID.', 'learnpress' ) );
@@ -325,6 +326,56 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
325
  throw new Exception( esc_html__( 'Error: Cannot purchase course!.', 'learnpress' ) );
326
  }
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  LP()->session->set( 'order_awaiting_payment', '' );
329
 
330
  $cart = LP()->cart;
@@ -344,6 +395,10 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
344
  throw new Exception( __( 'Error: Can\'t add Course to cart.', 'learnpress' ) );
345
  }
346
 
 
 
 
 
347
  $redirect = apply_filters(
348
  'learnpress/rest-api/courses/purchase/redirect',
349
  learn_press_get_page_link( 'checkout' ),
307
  $params = $request->get_params();
308
 
309
  try {
310
+ $course_id = $params['id'];
311
+ $allow_repurchase_type = $params['repurchaseType'] ?? false;
312
 
313
  if ( ! $course_id ) {
314
  throw new Exception( __( 'Error: Invalid Course ID.', 'learnpress' ) );
326
  throw new Exception( esc_html__( 'Error: Cannot purchase course!.', 'learnpress' ) );
327
  }
328
 
329
+ global $wpdb;
330
+
331
+ // Allow Repurchase.
332
+ $latest_user_item_id = $wpdb->get_var(
333
+ $wpdb->prepare(
334
+ "SELECT MAX(user_item_id) user_item_id
335
+ FROM {$wpdb->learnpress_user_items}
336
+ WHERE ref_type = %s
337
+ AND item_type = %s
338
+ AND item_id = %d
339
+ AND user_id = %d",
340
+ LP_ORDER_CPT,
341
+ LP_COURSE_CPT,
342
+ $course_id,
343
+ $user->get_id()
344
+ )
345
+ );
346
+
347
+ if ( $course->allow_repurchase() && ! empty( $latest_user_item_id ) && empty( $allow_repurchase_type ) ) {
348
+ if ( $course->allow_repurchase_course_option() === 'popup' ) {
349
+ ob_start();
350
+ ?>
351
+ <div class="lp_allow_repuchase_select">
352
+ <ul>
353
+ <li>
354
+ <label>
355
+ <input name="_lp_allow_repurchase_type" value="reset" type="radio" checked="checked" />
356
+ <?php esc_html_e( 'Reset Course progress', 'learnpress' ); ?>
357
+ </label>
358
+ </li>
359
+ <li>
360
+ <label>
361
+ <input name="_lp_allow_repurchase_type" value="keep" type="radio" />
362
+ <?php esc_html_e( 'Continue Course progress', 'learnpress' ); ?>
363
+ </label>
364
+ </li>
365
+ </ul>
366
+ </div>
367
+ <?php
368
+ $response->data->html = ob_get_clean();
369
+ $response->data->type = 'allow_repurchase';
370
+ $response->data->titlePopup = esc_html__( 'Repurchase Options', 'learnpress' );
371
+ $response->status = 'success';
372
+
373
+ return rest_ensure_response( $response );
374
+ } else {
375
+ learn_press_update_user_item_meta( $latest_user_item_id, '_lp_allow_repurchase_type', $course->allow_repurchase_course_option() );
376
+ }
377
+ }
378
+
379
  LP()->session->set( 'order_awaiting_payment', '' );
380
 
381
  $cart = LP()->cart;
395
  throw new Exception( __( 'Error: Can\'t add Course to cart.', 'learnpress' ) );
396
  }
397
 
398
+ if ( ! empty( $allow_repurchase_type ) ) {
399
+ learn_press_update_user_item_meta( $latest_user_item_id, '_lp_allow_repurchase_type', $allow_repurchase_type );
400
+ }
401
+
402
  $redirect = apply_filters(
403
  'learnpress/rest-api/courses/purchase/redirect',
404
  learn_press_get_page_link( 'checkout' ),
inc/rest-api/v1/frontend/class-lp-rest-profile-controller.php CHANGED
@@ -44,11 +44,11 @@ class LP_REST_Profile_Controller extends LP_Abstract_REST_Controller {
44
  return true;
45
  }
46
 
47
- public function statistic( $request ) {
48
- $request = $request->get_params();
49
- $user_id = $request['userID'];
50
- $response = new LP_REST_Response();
51
- $response->data = '';
52
 
53
  try {
54
  if ( empty( $user_id ) ) {
@@ -57,14 +57,21 @@ class LP_REST_Profile_Controller extends LP_Abstract_REST_Controller {
57
 
58
  $profile = learn_press_get_profile( $user_id );
59
 
 
 
 
 
60
  $query = $profile->query_courses( 'purchased' );
61
 
62
  $counts = $query['counts'];
63
 
 
 
 
64
  $statistic = array(
65
- 'enrolled_courses' => isset( $counts['all'] ) ? $counts['all'] : 0,
66
- 'active_courses' => isset( $counts['in-progress'] ) ? $counts['in-progress'] : 0,
67
- 'completed_courses' => isset( $counts['finished'] ) ? $counts['finished'] : 0,
68
  'total_courses' => count_user_posts( $user_id, LP_COURSE_CPT ),
69
  'total_users' => learn_press_count_instructor_users( $user_id ),
70
  );
44
  return true;
45
  }
46
 
47
+ public function statistic( WP_REST_Request $request ) {
48
+ $user_id = $request->get_param( 'userID' );
49
+ $response = new LP_REST_Response();
50
+ $response->data = '';
51
+ $lp_user_items_db = LP_User_Items_DB::getInstance();
52
 
53
  try {
54
  if ( empty( $user_id ) ) {
57
 
58
  $profile = learn_press_get_profile( $user_id );
59
 
60
+ if ( $profile instanceof WP_Error ) {
61
+ throw new Exception( $profile->get_error_message() );
62
+ }
63
+
64
  $query = $profile->query_courses( 'purchased' );
65
 
66
  $counts = $query['counts'];
67
 
68
+ // Count total courses has status 'in-progress'
69
+ $total_courses_has_status = $lp_user_items_db->get_total_courses_has_status( $user_id, 'in-progress' );
70
+
71
  $statistic = array(
72
+ 'enrolled_courses' => $counts['all'] ?? 0,
73
+ 'active_courses' => $total_courses_has_status,
74
+ 'completed_courses' => $counts['finished'] ?? 0,
75
  'total_courses' => count_user_posts( $user_id, LP_COURSE_CPT ),
76
  'total_users' => learn_press_count_instructor_users( $user_id ),
77
  );
inc/user/abstract-lp-user.php CHANGED
@@ -2328,7 +2328,14 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
2328
  $course_item['ref_type'] = ( $order_id != 0 ) ? learn_press_get_post_type( $order_id ) : '';
2329
  $course_item['start_time'] = current_time( 'mysql', true );
2330
  $course_item['access_level'] = 50;
2331
- $course_item['graduation'] = 'in-progress';
 
 
 
 
 
 
 
2332
 
2333
  $user_course = new LP_User_Item_Course( $course_item );
2334
  $user_course->set_status( LP_COURSE_PURCHASED );
@@ -2396,12 +2403,14 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
2396
  * @param int $order_id
2397
  * @param bool $force - Optional. Force create db record for preview quiz case
2398
  * @param bool $wp_error - Optional. TRUE will return WP_Error object if there is an error.
2399
- *
2400
  * @return bool|mixed|WP_Error
2401
  */
2402
  public function enroll( $course_id, $order_id, $force = false, $wp_error = false ) {
2403
  global $wpdb;
2404
 
 
 
2405
  try {
2406
  $course = learn_press_get_course( $course_id );
2407
  $user_id = $this->get_id();
2328
  $course_item['ref_type'] = ( $order_id != 0 ) ? learn_press_get_post_type( $order_id ) : '';
2329
  $course_item['start_time'] = current_time( 'mysql', true );
2330
  $course_item['access_level'] = 50;
2331
+
2332
+ /**
2333
+ * @editor tungnx
2334
+ * @fixed: case no auto enroll
2335
+ */
2336
+ if ( 'yes' == LP_Settings::get_option( 'auto_enroll' ) ) {
2337
+ $course_item['graduation'] = 'in-progress';
2338
+ }
2339
 
2340
  $user_course = new LP_User_Item_Course( $course_item );
2341
  $user_course->set_status( LP_COURSE_PURCHASED );
2403
  * @param int $order_id
2404
  * @param bool $force - Optional. Force create db record for preview quiz case
2405
  * @param bool $wp_error - Optional. TRUE will return WP_Error object if there is an error.
2406
+ * @editor tungnx - comment - not use
2407
  * @return bool|mixed|WP_Error
2408
  */
2409
  public function enroll( $course_id, $order_id, $force = false, $wp_error = false ) {
2410
  global $wpdb;
2411
 
2412
+ _deprecated_function( __FUNCTION__, '4.1.0' );
2413
+
2414
  try {
2415
  $course = learn_press_get_course( $course_id );
2416
  $user_id = $this->get_id();
inc/user/class-lp-profile.php CHANGED
@@ -744,6 +744,7 @@ if ( ! class_exists( 'LP_Profile' ) ) {
744
  break;
745
  case 'own':
746
  $query = $this->_curd->query_own_courses( $this->get_user_data( 'id' ), $args );
 
747
  }
748
 
749
  return $query;
744
  break;
745
  case 'own':
746
  $query = $this->_curd->query_own_courses( $this->get_user_data( 'id' ), $args );
747
+ break;
748
  }
749
 
750
  return $query;
inc/user/class-lp-user-factory.php CHANGED
@@ -176,15 +176,109 @@ class LP_User_Factory {
176
  $user_item_id = LP_Course_DB::getInstance()->get_user_item_id( $order->get_id(), $item['course_id'], $user_id );
177
 
178
  if ( $user_item_id ) {
179
- $user_item_id = $curd->update_user_item(
180
- $user_id,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  $item['course_id'],
182
- array(
183
- 'ref_id' => $order->get_id(),
184
- 'ref_type' => LP_ORDER_CPT,
185
- 'parent_id' => 0,
186
- )
187
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  } else {
189
  $user_item_id = $user->enroll_course( $item['course_id'], $order->get_id(), false, false );
190
  }
176
  $user_item_id = LP_Course_DB::getInstance()->get_user_item_id( $order->get_id(), $item['course_id'], $user_id );
177
 
178
  if ( $user_item_id ) {
179
+ continue;
180
+ }
181
+
182
+ $course = learn_press_get_course( $item['course_id'] );
183
+
184
+ /** Get latest user_item_id of course for allow_repurchase */
185
+ $latest_user_item_id = $wpdb->get_var(
186
+ $wpdb->prepare(
187
+ "SELECT MAX(user_item_id) user_item_id
188
+ FROM {$wpdb->learnpress_user_items}
189
+ WHERE ref_type = %s
190
+ AND item_type = %s
191
+ AND item_id = %d
192
+ AND user_id = %d",
193
+ LP_ORDER_CPT,
194
+ LP_COURSE_CPT,
195
  $item['course_id'],
196
+ $user_id
197
+ )
198
+ );
199
+
200
+ /** Get allow_repurchase_type for reset, update. Add in: rest-api/v1/frontend/class-lp-courses-controller.php: purchase_course */
201
+ $allow_repurchase_type = learn_press_get_user_item_meta( $latest_user_item_id, '_lp_allow_repurchase_type' );
202
+
203
+ /** If allow_repurchase. */
204
+ if ( $course->allow_repurchase() && ! empty( $latest_user_item_id ) && ! $course->is_free() && ! empty( $allow_repurchase_type ) ) {
205
+
206
+ /** If keep course progress will reset start_time, graduation.. */
207
+ if ( $allow_repurchase_type === 'keep' ) {
208
+ do_action( 'lp/allow_repurchase_options/continue/db/update', $latest_user_item_id );
209
+
210
+ /**
211
+ * Update latest user_item_id to continue course progress.
212
+ *
213
+ * @author Nhamdv.
214
+ */
215
+ $update = $wpdb->update(
216
+ $wpdb->learnpress_user_items,
217
+ array(
218
+ 'ref_id' => $order->get_id(),
219
+ 'start_time' => current_time( 'mysql', true ),
220
+ 'end_time' => null,
221
+ 'graduation' => 'in-progress',
222
+ 'status' => LP_COURSE_ENROLLED,
223
+ ),
224
+ array(
225
+ 'user_item_id' => $latest_user_item_id,
226
+ ),
227
+ array( '%d', '%s', '%s', '%s', '%s' ),
228
+ array( '%d' )
229
+ );
230
+
231
+ if ( $update ) {
232
+ $user_item_id = false;
233
+ }
234
+ } elseif ( $allow_repurchase_type === 'reset' ) {
235
+ /** Delete user_item_id in table learnpress_user_items */
236
+ $wpdb->delete(
237
+ $wpdb->learnpress_user_items,
238
+ array(
239
+ 'user_item_id' => $latest_user_item_id,
240
+ ),
241
+ array( '%d' )
242
+ );
243
+
244
+ /** Get list user_item_id for lesson, quiz... by course user_item_id in table learnpress_user_items */
245
+ $user_item_ids = $wpdb->get_col(
246
+ $wpdb->prepare(
247
+ "SELECT user_item_id FROM $wpdb->learnpress_user_items
248
+ WHERE parent_id=%d
249
+ ",
250
+ $latest_user_item_id
251
+ )
252
+ );
253
+
254
+ /** Delete all lesson, quiz... by course parent user_item_id */
255
+ $wpdb->delete(
256
+ $wpdb->learnpress_user_items,
257
+ array(
258
+ 'parent_id' => absint( $latest_user_item_id ),
259
+ ),
260
+ array( '%d' )
261
+ );
262
+
263
+ /** Delete all user_item_meta for lesson, quiz... */
264
+ if ( ! empty( $user_item_ids ) ) {
265
+ foreach ( $user_item_ids as $user_item_id ) {
266
+ $wpdb->delete(
267
+ $wpdb->learnpress_user_itemmeta,
268
+ array(
269
+ 'learnpress_user_item_id' => absint( $user_item_id ),
270
+ ),
271
+ array( '%d' )
272
+ );
273
+
274
+ LP_User_Items_Result_DB::instance()->delete( absint( $user_item_id ) );
275
+ }
276
+ }
277
+
278
+ $user_item_id = $user->enroll_course( $item['course_id'], $order->get_id(), false, false );
279
+ }
280
+
281
+ learn_press_delete_user_item_meta( $latest_user_item_id, '_lp_allow_repurchase_type' );
282
  } else {
283
  $user_item_id = $user->enroll_course( $item['course_id'], $order->get_id(), false, false );
284
  }
inc/user/lp-user-functions.php CHANGED
@@ -2055,6 +2055,16 @@ function lp_custom_register_fields_display() {
2055
  $cf_class = '';
2056
  if ( $custom_field['required'] == 'yes' ) {
2057
  $cf_class = ' required';
 
 
 
 
 
 
 
 
 
 
2058
  }
2059
 
2060
  if ( isset( $custom_field['id'] ) ) {
@@ -2062,40 +2072,33 @@ function lp_custom_register_fields_display() {
2062
  <?php $value = $custom_field['id']; ?>
2063
 
2064
  <li class="form-field<?php echo esc_attr( $cf_class ); ?>">
2065
- <label for="description">
2066
- <?php
2067
- echo $custom_field['name'];
2068
- if ( $custom_field['required'] == 'yes' ) {
2069
- echo '&nbsp;' . '<span class="required">*</span>';
2070
- }
2071
- ?>
2072
- </label>
2073
  <?php
2074
  switch ( $custom_field['type'] ) {
2075
  case 'text':
2076
  case 'number':
2077
  case 'email':
2078
  case 'url':
 
 
 
2079
  case 'tel':
2080
  ?>
2081
  <input name="_lp_custom_register_form[<?php echo $value; ?>]"
2082
- type="<?php echo $custom_field['type']; ?>"
2083
- placeholder="<?php echo esc_attr( $custom_field['name'] ); ?>" class="regular-text"
2084
- value="">
2085
  <?php
2086
  break;
2087
  case 'textarea':
2088
  ?>
2089
  <label for="description"><?php echo esc_html( $custom_field['name'] ); ?></label>
2090
- <textarea name="_lp_custom_register_form[<?php echo $value; ?>]"
2091
- placeholder="<?php echo esc_attr( $custom_field['name'] ); ?>"></textarea>
2092
  <?php
2093
  break;
2094
  case 'checkbox':
2095
  ?>
2096
  <label>
2097
  <input name="_lp_custom_register_form[<?php echo $value; ?>]"
2098
- type="<?php echo $custom_field['type']; ?>" value="1">
2099
  <?php echo esc_html( $custom_field['name'] ); ?>
2100
  </label>
2101
  <?php
2055
  $cf_class = '';
2056
  if ( $custom_field['required'] == 'yes' ) {
2057
  $cf_class = ' required';
2058
+ ?>
2059
+ <style>
2060
+ .required label {
2061
+ font-weight: bold;
2062
+ }
2063
+ .required label:after {
2064
+ content: ' *';
2065
+ display:inline;
2066
+ }
2067
+ </style> <?php
2068
  }
2069
 
2070
  if ( isset( $custom_field['id'] ) ) {
2072
  <?php $value = $custom_field['id']; ?>
2073
 
2074
  <li class="form-field<?php echo esc_attr( $cf_class ); ?>">
 
 
 
 
 
 
 
 
2075
  <?php
2076
  switch ( $custom_field['type'] ) {
2077
  case 'text':
2078
  case 'number':
2079
  case 'email':
2080
  case 'url':
2081
+ ?>
2082
+ <label for="description"><?php echo esc_html( $custom_field['name'] ); ?></label>
2083
+ <?php
2084
  case 'tel':
2085
  ?>
2086
  <input name="_lp_custom_register_form[<?php echo $value; ?>]"
2087
+ type="<?php echo $custom_field['type']; ?>" class="regular-text"
2088
+ value="">
 
2089
  <?php
2090
  break;
2091
  case 'textarea':
2092
  ?>
2093
  <label for="description"><?php echo esc_html( $custom_field['name'] ); ?></label>
2094
+ <textarea name="_lp_custom_register_form[<?php echo $value; ?>]"></textarea>
 
2095
  <?php
2096
  break;
2097
  case 'checkbox':
2098
  ?>
2099
  <label>
2100
  <input name="_lp_custom_register_form[<?php echo $value; ?>]"
2101
+ type="<?php echo $custom_field['type']; ?>" value="1">
2102
  <?php echo esc_html( $custom_field['name'] ); ?>
2103
  </label>
2104
  <?php
learnpress.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
- * Version: 4.0.9
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
  * Tested up to: 5.7
4
  * Plugin URI: http://thimpress.com/learnpress
5
  * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
6
  * Author: ThimPress
7
+ * Version: 4.1.0
8
  * Author URI: http://thimpress.com
9
  * Requires at least: 5.6
10
  * Tested up to: 5.7
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: elearning, education, course, lms, learning management system
5
  Requires at least: 5.6
6
  Tested up to: 5.7
7
  Requires PHP: 7.0
8
- Stable tag: 4.0.9
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -15,18 +15,18 @@ A WordPress LMS Plugin to create WordPress Learning Management System. Turn your
15
 
16
  **<a href="https://thimpress.com/learnpress" target="_blank">WordPress LMS Plugin</a>** - LearnPress is a comprehensive *WordPress LMS Plugin* for WordPress. This is one of the best WordPress LMS Plugins which can be used to easily create & sell courses online. You can create a course curriculum with lessons & quizzes included which is managed with an easy-to-use interface for users. Having this WordPress LMS Plugin, now you have a chance to quickly and easily create education, online school, online-course websites with no coding knowledge required.
17
 
18
- <a href="https://demo-learnpress.thimpress.com/" target="_blank">Live Demo</a> | <a href="https://themeforest.net/item/education-wordpress-theme-education-wp/14058034" target="_blank">LearnPress Themes</a> | <a href="https://thimpress.com/forums/forum/plugins/learnpress-plugin/" target="_blank">Support</a> | <a href="https://docspress.thimpress.com/learnpress-4-0/" target="_blank">Documentation</a>
19
 
20
  LearnPress is free and always will be, but it is still a premium high-quality WordPress Plugin that definitely helps you with making money from your **WordPress based LMS**. Just try and see how it is. LearnPress WordPress Online Course plugin is lightweight and super powerful with lots of Add-Ons to empower its core system.
21
 
22
  > Highly recommended by LearnPress users, we are pleased to introduce you to our best Education WordPress Themes which have LearnPress Theme Bundle included already.
23
- > [Eduma – Education WordPress Theme](https://themeforest.net/item/education-wordpress-theme-education-wp/14058034) (#1 Selling Education WordPress Theme).
24
- > [Coaching | Life & Fitness Coaching WordPress Theme](https://themeforest.net/item/speaker-and-life-coach-wordpress-theme-coaching-wp/17097658) (Rising Star).
25
- > [CorpTrain | Corporate Training WordPress Theme](https://themeforest.net/item/course-builder-wordpress-learning-management-system-theme-elearning-software/20370918) (Potential).
26
 
27
  ###LMS & Education WordPress Themes###
28
 
29
- Take a look at **[Premium Theme](https://themeforest.net/category/wordpress/education?sort=sales&term=thimpress#content)** (someone calls it LMS WordPress Template) we designed to work with LearnPress. All developers are welcome to develop WordPress LMS Theme based on LMS Plugin for WordPress - LearnPress. More WordPress LMS Themes are coming soon, both free and premium WordPress Themes for LearnPress.
30
 
31
  ###LearnPress Tutorials###
32
 
@@ -197,10 +197,16 @@ https://www.transifex.com/projects/p/learnpress/
197
 
198
  == Changelog ==
199
 
 
 
 
 
 
 
200
  = 4.0.9 =
201
  ~ Added: option enable sticky navigation pagination when user answer question on quiz.
202
  ~ Fixed: set again current item when manager remove item current when edit course.
203
- ~ Modified: page profile - load ajax call API, show more info...
204
  ~ Fixed: can't upgrade DB from 3 to 4 because user translate menu "LearnPress".
205
  ~ Modified: Navigation on page quiz - change icon next, previous to text.
206
  ~ Fixed: function "duplicate course" not duplicate "answer option"
5
  Requires at least: 5.6
6
  Tested up to: 5.7
7
  Requires PHP: 7.0
8
+ Stable tag: 4.1.0
9
  License: GPLv2 or later
10
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
 
15
 
16
  **<a href="https://thimpress.com/learnpress" target="_blank">WordPress LMS Plugin</a>** - LearnPress is a comprehensive *WordPress LMS Plugin* for WordPress. This is one of the best WordPress LMS Plugins which can be used to easily create & sell courses online. You can create a course curriculum with lessons & quizzes included which is managed with an easy-to-use interface for users. Having this WordPress LMS Plugin, now you have a chance to quickly and easily create education, online school, online-course websites with no coding knowledge required.
17
 
18
+ <a href="https://demo-learnpress.thimpress.com/" target="_blank">Live Demo</a> | <a href="https://1.envato.market/G5Ook" target="_blank">LearnPress Themes</a> | <a href="https://thimpress.com/forums/forum/plugins/learnpress-plugin/" target="_blank">Support</a> | <a href="https://docspress.thimpress.com/learnpress-4-0/" target="_blank">Documentation</a>
19
 
20
  LearnPress is free and always will be, but it is still a premium high-quality WordPress Plugin that definitely helps you with making money from your **WordPress based LMS**. Just try and see how it is. LearnPress WordPress Online Course plugin is lightweight and super powerful with lots of Add-Ons to empower its core system.
21
 
22
  > Highly recommended by LearnPress users, we are pleased to introduce you to our best Education WordPress Themes which have LearnPress Theme Bundle included already.
23
+ > [Eduma – Education WordPress Theme](https://1.envato.market/G5Ook) (#1 Selling Education WordPress Theme).
24
+ > [Coaching | Life & Fitness Coaching WordPress Theme](https://1.envato.market/Xq2Ra) (Rising Star).
25
+ > [CorpTrain | Corporate Training WordPress Theme](https://1.envato.market/13Zkd) (Potential).
26
 
27
  ###LMS & Education WordPress Themes###
28
 
29
+ Take a look at **[Premium Theme](https://1.envato.market/AoKx3D)** (someone calls it LMS WordPress Template) we designed to work with LearnPress. All developers are welcome to develop WordPress LMS Theme based on LMS Plugin for WordPress - LearnPress. More WordPress LMS Themes are coming soon, both free and premium WordPress Themes for LearnPress.
30
 
31
  ###LearnPress Tutorials###
32
 
197
 
198
  == Changelog ==
199
 
200
+ = 4.1.0 =
201
+ ~ Added: feature "Allow repurchase option". Manager can set fixed: Reset/Keep course progress of course or allow student choice.
202
+ ~ Fixed: show incorrect "Active Courses" on page profile.
203
+ ~ Fixed: show fake student.
204
+ ~ Fixed: duplicate label on form Register custom fields.
205
+
206
  = 4.0.9 =
207
  ~ Added: option enable sticky navigation pagination when user answer question on quiz.
208
  ~ Fixed: set again current item when manager remove item current when edit course.
209
+ ~ Modified: page profile - load ajax call API, show more info.
210
  ~ Fixed: can't upgrade DB from 3 to 4 because user translate menu "LearnPress".
211
  ~ Modified: Navigation on page quiz - change icon next, previous to text.
212
  ~ Fixed: function "duplicate course" not duplicate "answer option"
templates/profile/tabs/courses.php CHANGED
@@ -44,7 +44,10 @@ $tab_active = ! learn_press_user_maybe_is_a_teacher() ? 'enrolled' : 'creat
44
  ?>
45
 
46
  <div class="learn-press-subtab-content">
47
- <div class="learn-press-profile-course__statistic" data-ajax="<?php echo htmlentities( wp_json_encode( [ 'userID' => $user->get_id() ] ) ); ?>"></div> <?php // phpcs:ignore ?>
 
 
 
48
 
49
  <div class="learn-press-profile-course__tab">
50
  <ul class="learn-press-profile-course__tab__inner">
44
  ?>
45
 
46
  <div class="learn-press-subtab-content">
47
+ <div class="learn-press-profile-course__statistic"
48
+ data-ajax="<?php echo htmlentities( wp_json_encode( array( 'userID' => $user->get_id() ) ) ); ?>">
49
+ <?php lp_skeleton_animation_html( 4, 'random', 'height: 30px;border-radius:4px;' ); ?>
50
+ </div>
51
 
52
  <div class="learn-press-profile-course__tab">
53
  <ul class="learn-press-profile-course__tab__inner">