Version Description
~ Modify, optimize Archive course page - call API - make faster ~ Added: back icon on item page ~ Fixed: some where call old function "get_profile_socials" not has param $user_id
Download this release
Release Info
Developer | ThimPress |
Plugin | LearnPress – WordPress LMS Plugin |
Version | 4.1.2 |
Comparing to | |
See all releases |
Code changes from version 4.1.1 to 4.1.2
- assets/css/learnpress.css +36 -0
- assets/js/dist/frontend/quiz.js +2 -2
- assets/js/dist/frontend/quiz.min.js +1 -1
- assets/js/frontend/courses.min.js +1 -1
- assets/src/apps/js/frontend/quiz/components/questions/question.js +2 -2
- assets/src/js/frontend/courses.js +199 -103
- inc/class-lp-assets.php +14 -3
- inc/class-lp-page-controller.php +40 -50
- inc/curds/class-lp-user-curd.php +19 -7
- inc/jwt/includes/class-jwt-public.php +31 -0
- inc/jwt/responsive.http +25 -3
- inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php +1 -1
- inc/lp-core-functions.php +5 -3
- inc/lp-template-functions.php +62 -11
- inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php +103 -1
- inc/templates/class-lp-template-course.php +4 -0
- inc/user/abstract-lp-user.php +8 -2
- inc/user/class-lp-profile.php +3 -3
- languages/learnpress.pot +10 -1
- learnpress.php +1 -1
- readme.txt +6 -1
- templates/archive-course.php +14 -9
- templates/courses-top-bar.php +5 -1
- templates/global/no-courses-found.php +15 -0
- templates/loop/course/pagination.php +10 -6
- templates/single-course/content-item/popup-header.php +3 -2
assets/css/learnpress.css
CHANGED
@@ -6164,6 +6164,16 @@ a {
|
|
6164 |
outline: 0;
|
6165 |
}
|
6166 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6167 |
.lp-courses-bar .search-courses ::-webkit-input-placeholder {
|
6168 |
color: #999;
|
6169 |
}
|
@@ -6900,6 +6910,32 @@ input[type="radio"]:nth-child(19):checked ~ .switch-btn:nth-child(20)::before {
|
|
6900 |
background: #fff;
|
6901 |
}
|
6902 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6903 |
#popup-course #popup-header {
|
6904 |
display: flex;
|
6905 |
position: fixed;
|
6164 |
outline: 0;
|
6165 |
}
|
6166 |
|
6167 |
+
.lp-courses-bar .search-courses button.loading > i::before {
|
6168 |
+
display: inline-block;
|
6169 |
+
font-family: "Font Awesome 5 Free";
|
6170 |
+
font-weight: 900;
|
6171 |
+
content: "\f110";
|
6172 |
+
-webkit-animation: lp-rotating 1s linear infinite;
|
6173 |
+
-moz-animation: lp-rotating 1s linear infinite;
|
6174 |
+
animation: lp-rotating 1s linear infinite;
|
6175 |
+
}
|
6176 |
+
|
6177 |
.lp-courses-bar .search-courses ::-webkit-input-placeholder {
|
6178 |
color: #999;
|
6179 |
}
|
6910 |
background: #fff;
|
6911 |
}
|
6912 |
|
6913 |
+
#popup-course .back-course {
|
6914 |
+
padding-left: 30px;
|
6915 |
+
padding-right: 30px;
|
6916 |
+
line-height: 70px;
|
6917 |
+
background: rgba(255, 255, 255, 0.1);
|
6918 |
+
color: #fff;
|
6919 |
+
}
|
6920 |
+
|
6921 |
+
#popup-course .back-course:hover {
|
6922 |
+
background: rgba(255, 255, 255, 0.15);
|
6923 |
+
}
|
6924 |
+
|
6925 |
+
@media (max-width: 768px) {
|
6926 |
+
#popup-course .back-course {
|
6927 |
+
background: transparent;
|
6928 |
+
line-height: 50px;
|
6929 |
+
opacity: 0.6;
|
6930 |
+
padding-left: 15px;
|
6931 |
+
padding-right: 15px;
|
6932 |
+
}
|
6933 |
+
#popup-course .back-course:hover {
|
6934 |
+
background: transparent;
|
6935 |
+
opacity: 1;
|
6936 |
+
}
|
6937 |
+
}
|
6938 |
+
|
6939 |
#popup-course #popup-header {
|
6940 |
display: flex;
|
6941 |
position: fixed;
|
assets/js/dist/frontend/quiz.js
CHANGED
@@ -1655,7 +1655,7 @@ var Question = /*#__PURE__*/function (_Component) {
|
|
1655 |
className: "question-explanation-content"
|
1656 |
}, /*#__PURE__*/React.createElement("strong", {
|
1657 |
className: "explanation-title"
|
1658 |
-
}, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Explanation
|
1659 |
dangerouslySetInnerHTML: {
|
1660 |
__html: question.explanation
|
1661 |
}
|
@@ -1666,7 +1666,7 @@ var Question = /*#__PURE__*/function (_Component) {
|
|
1666 |
className: "question-hint-content"
|
1667 |
}, /*#__PURE__*/React.createElement("strong", {
|
1668 |
className: "hint-title"
|
1669 |
-
}, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Hint
|
1670 |
dangerouslySetInnerHTML: {
|
1671 |
__html: question.hint
|
1672 |
}
|
1655 |
className: "question-explanation-content"
|
1656 |
}, /*#__PURE__*/React.createElement("strong", {
|
1657 |
className: "explanation-title"
|
1658 |
+
}, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Explanation', 'learnpress'), ":"), /*#__PURE__*/React.createElement("div", {
|
1659 |
dangerouslySetInnerHTML: {
|
1660 |
__html: question.explanation
|
1661 |
}
|
1666 |
className: "question-hint-content"
|
1667 |
}, /*#__PURE__*/React.createElement("strong", {
|
1668 |
className: "hint-title"
|
1669 |
+
}, Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__["__"])('Hint', 'learnpress'), ":"), /*#__PURE__*/React.createElement("div", {
|
1670 |
dangerouslySetInnerHTML: {
|
1671 |
__html: question.hint
|
1672 |
}
|
assets/js/dist/frontend/quiz.min.js
CHANGED
@@ -3,4 +3,4 @@ this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])retu
|
|
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")})}]);
|
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/frontend/courses.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
1 |
+
const{debounce:debounce}=lodash,lpArchiveAddQueryArgs=(e,t)=>{const r=new URL(e);return Object.keys(t).forEach(e=>{r.searchParams.append(e,t[e])}),r},lpArchiveCourse=()=>{const e=document.querySelectorAll(".lp-archive-course-skeleton");if(e.length&&"IntersectionObserver"in window){const t=new IntersectionObserver((e,r)=>{e.forEach(e=>{if(e.isIntersecting){const r=e.target;if(!lpArchiveSkeleton)return;lpArchiveRequestCourse(lpArchiveSkeleton),t.unobserve(r)}})});[...e].map(e=>t.observe(e))}};let skeleton,skeletonClone,isLoading=!1;const lpArchiveRequestCourse=e=>{const t=lpGlobalSettings.lp_rest_url,r=lpGlobalSettings.user_id||"";if(!t)return;const s=document.querySelector(".lp-archive-courses"),o=s&&s.querySelector("div.lp-archive-courses .lp-content-area"),n=o&&o.querySelector("ul.learn-press-courses");n&&(isLoading||(isLoading=!0,skeletonClone?n.innerHTML=skeletonClone:(skeleton=document.querySelector(".lp-archive-course-skeleton"),skeletonClone=skeleton.outerHTML),fetch(lpArchiveAddQueryArgs(t+"lp/v1/courses/archive-course",{...e,userID:r}),{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>{void 0!==e.data.content&&n&&(n.innerHTML=e.data.content||"");const t=e.data.pagination;if(lpArchiveSearchCourse(),void 0!==t){const e=(new DOMParser).parseFromString(t,"text/html").querySelector(".learn-press-pagination"),r=document.querySelector(".learn-press-pagination");r&&r.remove(),e&&(n.after(e),lpArchivePaginationCourse())}}).catch(e=>{n.innerHTML+=`<div class="lp-ajax-message error" style="display:block">${e.message||"Error: Query lp/v1/courses/archive-course"}</div>`}).finally(()=>{isLoading=!1,skeleton&&skeleton.remove(),jQuery("form.search-courses button").removeClass("loading"),LPArchiveCourseInit(),s.scrollIntoView()})))},lpArchiveSearchCourse=()=>{document.querySelectorAll("form.search-courses").forEach(e=>{const t=e.querySelector('input[name="s"]'),r=e.getAttribute("action"),s=e.querySelector('[name="post_type"]').value||"",o=e.querySelector('[name="taxonomy"]').value||"",n=e.querySelector('[name="term_id"]').value||"",c=e.querySelector('[type="submit"]');t.addEventListener("keyup",debounce(e=>{e.preventDefault();const t=e.target.value;if(!t||t&&t.length>2){c.classList.add("loading"),lpArchiveRequestCourse({...lpArchiveSkeleton,s:t});const e=lpArchiveAddQueryArgs(r,{post_type:s,taxonomy:o,term_id:n,s:t});window.history.pushState("","",e)}},500)),e.addEventListener("submit",t=>{t.preventDefault();const r=e.querySelector('input[name="s"]');r&&r.dispatchEvent(new Event("keyup"))})})},lpArchivePaginationCourse=()=>{const e=document.querySelectorAll(".lp-archive-courses .learn-press-pagination .page-numbers");e.length>0&&e.forEach(t=>t.addEventListener("click",r=>{r.preventDefault(),r.stopPropagation();const s=r.currentTarget.getAttribute("href");if(s){const o=new URL(s),n={};o.searchParams.forEach((e,t)=>{n[t]=e});const c=[...e].filter(e=>e.classList.contains("current")),l=r.currentTarget.textContent||t.classList.contains("next")&&parseInt(c[0].textContent)+1||t.classList.contains("prev")&&parseInt(c[0].textContent)-1;lpArchiveRequestCourse({...n,paged:l}),window.history.pushState("","",s)}}))},lpArchiveGridListCourse=()=>{const e=LP.Cookies.get("courses-layout"),t=document.querySelectorAll('.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]');t.length>0&&[...t].map(t=>t.value===e&&(t.checked=!0))},lpArchiveGridListCourseHandle=()=>{const e=document.querySelectorAll('.lp-archive-courses input[name="lp-switch-layout-btn"]');e.length>0&&e.forEach(e=>e.addEventListener("change",e=>{e.preventDefault();const t=e.target.value;if(t){const e=document.querySelector(".lp-archive-courses .learn-press-courses[data-layout]");e&&(e.dataset.layout=t),LP.Cookies.set("courses-layout",t)}}))};function LPArchiveCourseInit(){lpArchiveCourse(),lpArchiveGridListCourseHandle(),lpArchiveGridListCourse()}LPArchiveCourseInit();
|
assets/src/apps/js/frontend/quiz/components/questions/question.js
CHANGED
@@ -156,7 +156,7 @@ class Question extends Component {
|
|
156 |
question.explanation && (
|
157 |
<>
|
158 |
<div className="question-explanation-content">
|
159 |
-
<strong className="explanation-title">{ __( 'Explanation
|
160 |
<div dangerouslySetInnerHTML={ { __html: question.explanation } }>
|
161 |
</div>
|
162 |
</div>
|
@@ -170,7 +170,7 @@ class Question extends Component {
|
|
170 |
question.hint && ! question.explanation && question.showHint && (
|
171 |
<>
|
172 |
<div className="question-hint-content">
|
173 |
-
<strong className="hint-title">{ __( 'Hint
|
174 |
<div dangerouslySetInnerHTML={ { __html: question.hint } } />
|
175 |
</div>
|
176 |
</>
|
156 |
question.explanation && (
|
157 |
<>
|
158 |
<div className="question-explanation-content">
|
159 |
+
<strong className="explanation-title">{ __( 'Explanation', 'learnpress' ) }:</strong>
|
160 |
<div dangerouslySetInnerHTML={ { __html: question.explanation } }>
|
161 |
</div>
|
162 |
</div>
|
170 |
question.hint && ! question.explanation && question.showHint && (
|
171 |
<>
|
172 |
<div className="question-hint-content">
|
173 |
+
<strong className="hint-title">{ __( 'Hint', 'learnpress' ) }:</strong>
|
174 |
<div dangerouslySetInnerHTML={ { __html: question.hint } } />
|
175 |
</div>
|
176 |
</>
|
assets/src/js/frontend/courses.js
CHANGED
@@ -1,128 +1,224 @@
|
|
1 |
-
( function( $ ) {
|
2 |
-
const { debounce } = lodash;
|
3 |
|
4 |
-
|
5 |
-
const url = args.url || lpGlobalSettings.courses_url;
|
6 |
-
const $wrapElement = args.wrapElement || '.lp-archive-courses';
|
7 |
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
url,
|
18 |
-
data: $.extend( {}, args || {} ),
|
19 |
-
type: 'POST',
|
20 |
-
success: ( response ) => {
|
21 |
-
let newEl = $( response ).contents().find( $wrapElement );
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
}
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
$( $wrapElement ).html( 'LearnPress: No Content.' );
|
31 |
-
}
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
}
|
38 |
|
39 |
-
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
}
|
43 |
-
error: ( response ) => {
|
44 |
-
reject();
|
45 |
-
$( '.lp-archive-courses' ).removeClass( 'loading' );
|
46 |
-
},
|
47 |
} );
|
48 |
} );
|
49 |
-
};
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Ajax searching when user typing on search-box.
|
53 |
-
*
|
54 |
-
* @param event
|
55 |
-
*/
|
56 |
-
const searchCourseHandler = debounce( ( event ) => {
|
57 |
-
event.preventDefault();
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
.trigger( 'change' );
|
93 |
}
|
94 |
-
}
|
|
|
|
|
|
|
|
|
95 |
|
96 |
-
|
97 |
-
event.preventDefault();
|
98 |
|
99 |
-
|
100 |
-
const s = $( '.search-courses input[name="s"]' ).val();
|
101 |
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
} );
|
115 |
-
};
|
116 |
-
|
117 |
-
const bindEventCoursesLayout = function() {
|
118 |
-
$( '.lp-archive-courses' )
|
119 |
-
.on( 'keyup', '.search-courses input[name="s"]', searchCourseHandler )
|
120 |
-
.on( 'change', 'input[name="lp-switch-layout-btn"]', switchCoursesLayoutHandler )
|
121 |
-
.on( 'click', '.learn-press-pagination .page-numbers', coursePaginationHandler );
|
122 |
-
};
|
123 |
-
|
124 |
-
$( document ).ready( function() {
|
125 |
-
bindEventCoursesLayout();
|
126 |
-
selectCoursesLayout();
|
127 |
} );
|
128 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
|
2 |
+
const { debounce } = lodash;
|
|
|
|
|
3 |
|
4 |
+
const lpArchiveAddQueryArgs = ( endpoint, args ) => {
|
5 |
+
const url = new URL( endpoint );
|
6 |
|
7 |
+
Object.keys( args ).forEach( ( arg ) => {
|
8 |
+
url.searchParams.append( arg, args[ arg ] );
|
9 |
+
} );
|
10 |
|
11 |
+
return url;
|
12 |
+
};
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
const lpArchiveCourse = () => {
|
15 |
+
const elements = document.querySelectorAll( '.lp-archive-course-skeleton' );
|
|
|
16 |
|
17 |
+
if ( ! elements.length ) {
|
18 |
+
return;
|
19 |
+
}
|
|
|
|
|
20 |
|
21 |
+
if ( 'IntersectionObserver' in window ) {
|
22 |
+
const eleObserver = new IntersectionObserver( ( entries, observer ) => {
|
23 |
+
entries.forEach( ( entry ) => {
|
24 |
+
if ( entry.isIntersecting ) {
|
25 |
+
const ele = entry.target;
|
26 |
|
27 |
+
if ( ! lpArchiveSkeleton ) {
|
28 |
+
return;
|
29 |
+
}
|
30 |
|
31 |
+
//setTimeout( function() {
|
32 |
+
lpArchiveRequestCourse( lpArchiveSkeleton );
|
33 |
+
//}, 600 );
|
34 |
|
35 |
+
eleObserver.unobserve( ele );
|
36 |
+
}
|
|
|
|
|
|
|
|
|
37 |
} );
|
38 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
[ ...elements ].map( ( ele ) => eleObserver.observe( ele ) );
|
41 |
+
}
|
42 |
+
};
|
43 |
+
|
44 |
+
let skeleton;
|
45 |
+
let skeletonClone;
|
46 |
+
let isLoading = false;
|
47 |
+
const lpArchiveRequestCourse = ( args ) => {
|
48 |
+
const wpRestUrl = lpGlobalSettings.lp_rest_url;
|
49 |
+
const userID = lpGlobalSettings.user_id || '';
|
50 |
+
|
51 |
+
if ( ! wpRestUrl ) {
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
const archive = document.querySelector( '.lp-archive-courses' );
|
56 |
+
const archiveCourse = archive && archive.querySelector( 'div.lp-archive-courses .lp-content-area' );
|
57 |
+
const listCourse = archiveCourse && archiveCourse.querySelector( 'ul.learn-press-courses' );
|
58 |
+
|
59 |
+
if ( ! listCourse ) {
|
60 |
+
return;
|
61 |
+
}
|
62 |
+
|
63 |
+
if ( isLoading ) {
|
64 |
+
return;
|
65 |
+
}
|
66 |
+
|
67 |
+
isLoading = true;
|
68 |
+
|
69 |
+
if ( ! skeletonClone ) {
|
70 |
+
skeleton = document.querySelector( '.lp-archive-course-skeleton' );
|
71 |
+
skeletonClone = skeleton.outerHTML;
|
72 |
+
} else {
|
73 |
+
listCourse.innerHTML = skeletonClone;
|
74 |
+
}
|
75 |
+
|
76 |
+
fetch( lpArchiveAddQueryArgs( wpRestUrl + 'lp/v1/courses/archive-course', { ...args, userID } ), {
|
77 |
+
method: 'GET',
|
78 |
+
headers: {
|
79 |
+
'Content-Type': 'application/json',
|
80 |
+
},
|
81 |
+
} ).then( ( response ) => {
|
82 |
+
return response.json();
|
83 |
+
} ).then( ( response ) => {
|
84 |
+
if ( typeof response.data.content !== 'undefined' && listCourse ) {
|
85 |
+
listCourse.innerHTML = response.data.content || '';
|
86 |
}
|
87 |
|
88 |
+
const pagination = response.data.pagination;
|
89 |
+
|
90 |
+
lpArchiveSearchCourse();
|
91 |
+
|
92 |
+
if ( typeof pagination !== 'undefined' ) {
|
93 |
+
const paginationHTML = new DOMParser().parseFromString( pagination, 'text/html' );
|
94 |
+
const paginationNewNode = paginationHTML.querySelector( '.learn-press-pagination' );
|
95 |
+
//const paginationInnerHTML = paginationSelector && paginationSelector.innerHTML;
|
96 |
+
const paginationEle = document.querySelector( '.learn-press-pagination' );
|
97 |
|
98 |
+
if ( paginationEle ) {
|
99 |
+
paginationEle.remove();
|
100 |
+
}
|
101 |
|
102 |
+
if ( paginationNewNode ) {
|
103 |
+
listCourse.after( paginationNewNode );
|
104 |
+
lpArchivePaginationCourse();
|
105 |
+
}
|
|
|
106 |
}
|
107 |
+
} ).catch( ( error ) => {
|
108 |
+
listCourse.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message || 'Error: Query lp/v1/courses/archive-course' }</div>`;
|
109 |
+
} ).finally( () => {
|
110 |
+
isLoading = false;
|
111 |
+
skeleton && skeleton.remove();
|
112 |
|
113 |
+
jQuery( 'form.search-courses button' ).removeClass( 'loading' );
|
|
|
114 |
|
115 |
+
LPArchiveCourseInit();
|
|
|
116 |
|
117 |
+
// Scroll to archive element
|
118 |
+
archive.scrollIntoView();
|
119 |
+
} );
|
120 |
+
};
|
121 |
|
122 |
+
const lpArchiveSearchCourse = () => {
|
123 |
+
const searchForm = document.querySelectorAll( 'form.search-courses' );
|
124 |
+
|
125 |
+
searchForm.forEach( ( s ) => {
|
126 |
+
const search = s.querySelector( 'input[name="s"]' );
|
127 |
+
const action = s.getAttribute( 'action' );
|
128 |
+
const postType = s.querySelector( '[name="post_type"]' ).value || '';
|
129 |
+
const taxonomy = s.querySelector( '[name="taxonomy"]' ).value || '';
|
130 |
+
const termID = s.querySelector( '[name="term_id"]' ).value || '';
|
131 |
+
const btn = s.querySelector( '[type="submit"]' );
|
132 |
+
|
133 |
+
search.addEventListener( 'keyup', debounce( ( event ) => {
|
134 |
+
event.preventDefault();
|
135 |
+
|
136 |
+
const s = event.target.value;
|
137 |
+
|
138 |
+
if ( ! s || ( s && s.length > 2 ) ) {
|
139 |
+
btn.classList.add( 'loading' );
|
140 |
+
|
141 |
+
lpArchiveRequestCourse( { ...lpArchiveSkeleton, s } );
|
142 |
+
|
143 |
+
const url = lpArchiveAddQueryArgs( action, {
|
144 |
+
post_type: postType,
|
145 |
+
taxonomy,
|
146 |
+
term_id: termID,
|
147 |
+
s,
|
148 |
+
} );
|
149 |
+
|
150 |
+
window.history.pushState( '', '', url );
|
151 |
+
}
|
152 |
+
}, 500 ) );
|
153 |
+
|
154 |
+
s.addEventListener( 'submit', ( e ) => {
|
155 |
+
e.preventDefault();
|
156 |
|
157 |
+
const eleSearch = s.querySelector( 'input[name="s"]' );
|
158 |
+
eleSearch && eleSearch.dispatchEvent( new Event( 'keyup' ) );
|
159 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
} );
|
161 |
+
};
|
162 |
+
|
163 |
+
const lpArchivePaginationCourse = () => {
|
164 |
+
const paginationEle = document.querySelectorAll( '.lp-archive-courses .learn-press-pagination .page-numbers' );
|
165 |
+
|
166 |
+
paginationEle.length > 0 && paginationEle.forEach( ( ele ) => ele.addEventListener( 'click', ( event ) => {
|
167 |
+
event.preventDefault();
|
168 |
+
event.stopPropagation();
|
169 |
+
|
170 |
+
const urlString = event.currentTarget.getAttribute( 'href' );
|
171 |
+
|
172 |
+
if ( urlString ) {
|
173 |
+
const url = new URL( urlString );
|
174 |
+
|
175 |
+
const params = {};
|
176 |
+
url.searchParams.forEach( ( key, value ) => {
|
177 |
+
params[ value ] = key;
|
178 |
+
} );
|
179 |
+
|
180 |
+
const current = [ ...paginationEle ].filter( ( el ) => el.classList.contains( 'current' ) );
|
181 |
+
|
182 |
+
const paged = event.currentTarget.textContent || ( ele.classList.contains( 'next' ) && parseInt( current[ 0 ].textContent ) + 1 ) || ( ele.classList.contains( 'prev' ) && parseInt( current[ 0 ].textContent ) - 1 );
|
183 |
+
|
184 |
+
lpArchiveRequestCourse( { ...params, paged } );
|
185 |
+
|
186 |
+
window.history.pushState( '', '', urlString );
|
187 |
+
}
|
188 |
+
} ) );
|
189 |
+
};
|
190 |
+
|
191 |
+
const lpArchiveGridListCourse = () => {
|
192 |
+
const layout = LP.Cookies.get( 'courses-layout' );
|
193 |
+
|
194 |
+
const switches = document.querySelectorAll( '.lp-courses-bar .switch-layout [name="lp-switch-layout-btn"]' );
|
195 |
+
|
196 |
+
switches.length > 0 && [ ...switches ].map( ( ele ) => ele.value === layout && ( ele.checked = true ) );
|
197 |
+
};
|
198 |
+
|
199 |
+
const lpArchiveGridListCourseHandle = () => {
|
200 |
+
const gridList = document.querySelectorAll( '.lp-archive-courses input[name="lp-switch-layout-btn"]' );
|
201 |
+
|
202 |
+
gridList.length > 0 && gridList.forEach( ( element ) => element.addEventListener( 'change', ( e ) => {
|
203 |
+
e.preventDefault();
|
204 |
+
|
205 |
+
const layout = e.target.value;
|
206 |
+
|
207 |
+
if ( layout ) {
|
208 |
+
const dataLayout = document.querySelector( '.lp-archive-courses .learn-press-courses[data-layout]' );
|
209 |
+
|
210 |
+
dataLayout && ( dataLayout.dataset.layout = layout );
|
211 |
+
LP.Cookies.set( 'courses-layout', layout );
|
212 |
+
}
|
213 |
+
} ) );
|
214 |
+
};
|
215 |
+
|
216 |
+
function LPArchiveCourseInit() {
|
217 |
+
lpArchiveCourse();
|
218 |
+
lpArchiveGridListCourseHandle();
|
219 |
+
lpArchiveGridListCourse();
|
220 |
+
}
|
221 |
+
|
222 |
+
//document.addEventListener( 'DOMContentLoaded', function( event ) {
|
223 |
+
LPArchiveCourseInit();
|
224 |
+
//} );
|
inc/class-lp-assets.php
CHANGED
@@ -46,7 +46,12 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
46 |
);
|
47 |
}
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
return array(
|
51 |
'lp-global' => array(
|
52 |
'url' => learn_press_get_current_url(),
|
@@ -86,7 +91,12 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
86 |
|
87 |
}
|
88 |
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
90 |
$wp_js = array(
|
91 |
'jquery',
|
92 |
'wp-element',
|
@@ -97,7 +107,7 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
97 |
'lodash',
|
98 |
);
|
99 |
|
100 |
-
|
101 |
'learn-press/frontend-default-scripts',
|
102 |
array(
|
103 |
'vue-libs' => new LP_Asset_Key(
|
@@ -231,6 +241,7 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
231 |
|
232 |
wp_set_script_translations( 'lp-quiz', 'learnpress' );
|
233 |
|
|
|
234 |
}
|
235 |
|
236 |
/**
|
46 |
);
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Set localize script data
|
51 |
+
*
|
52 |
+
* @return array
|
53 |
+
*/
|
54 |
+
public function _get_script_data(): array {
|
55 |
return array(
|
56 |
'lp-global' => array(
|
57 |
'url' => learn_press_get_current_url(),
|
91 |
|
92 |
}
|
93 |
|
94 |
+
/**
|
95 |
+
* Config load scripts
|
96 |
+
*
|
97 |
+
* @return array
|
98 |
+
*/
|
99 |
+
public function _get_scripts(): array {
|
100 |
$wp_js = array(
|
101 |
'jquery',
|
102 |
'wp-element',
|
107 |
'lodash',
|
108 |
);
|
109 |
|
110 |
+
$scripts = apply_filters(
|
111 |
'learn-press/frontend-default-scripts',
|
112 |
array(
|
113 |
'vue-libs' => new LP_Asset_Key(
|
241 |
|
242 |
wp_set_script_translations( 'lp-quiz', 'learnpress' );
|
243 |
|
244 |
+
return $scripts;
|
245 |
}
|
246 |
|
247 |
/**
|
inc/class-lp-page-controller.php
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
* Class LP_Page_Controller
|
5 |
*/
|
6 |
class LP_Page_Controller {
|
7 |
-
protected static $_instance
|
8 |
protected $_shortcode_exists = false;
|
9 |
-
protected $_shortcode_tag
|
10 |
protected $_archive_contents = null;
|
11 |
|
12 |
/**
|
@@ -72,12 +72,13 @@ class LP_Page_Controller {
|
|
72 |
|
73 |
// Set title course archive page
|
74 |
if ( ! empty( $course_archive_page_id ) && $wp_query->post &&
|
75 |
-
|
76 |
$title = get_the_title( $course_archive_page_id );
|
77 |
$flag_title_course = true;
|
78 |
} elseif ( learn_press_is_course() ) {
|
79 |
-
|
80 |
-
|
|
|
81 |
|
82 |
$flag_title_course = true;
|
83 |
}
|
@@ -107,7 +108,7 @@ class LP_Page_Controller {
|
|
107 |
array(
|
108 |
$page_title,
|
109 |
'→',
|
110 |
-
$tab['title']
|
111 |
)
|
112 |
)
|
113 |
);
|
@@ -736,7 +737,7 @@ class LP_Page_Controller {
|
|
736 |
$this->_archive_contents = do_shortcode( $this->_shortcode_tag );
|
737 |
if ( class_exists( 'SiteOrigin_Panels' ) ) {
|
738 |
if ( class_exists( 'SiteOrigin_Panels' ) &&
|
739 |
-
|
740 |
) {
|
741 |
remove_shortcode( 'learn_press_archive_course' );
|
742 |
add_filter(
|
@@ -767,7 +768,7 @@ class LP_Page_Controller {
|
|
767 |
if ( is_post_type_archive( LP_COURSE_CPT ) || LEARNPRESS_IS_CATEGORY ) {
|
768 |
$wp_query->is_page = false;
|
769 |
$wp_query->is_archive = true;
|
770 |
-
$wp_query->is_single
|
771 |
} else {
|
772 |
$wp_query->found_posts = 1;
|
773 |
$wp_query->is_single = true;
|
@@ -802,18 +803,23 @@ class LP_Page_Controller {
|
|
802 |
}
|
803 |
|
804 |
/**
|
805 |
-
*
|
806 |
*
|
807 |
* @param $q WP_Query
|
808 |
*
|
809 |
* @return WP_Query
|
|
|
|
|
|
|
810 |
*/
|
811 |
-
public function pre_get_posts( $q ) {
|
812 |
// Affect only the main query and not in admin
|
813 |
-
if ( ! $q->is_main_query() ) {
|
814 |
return $q;
|
815 |
}
|
816 |
|
|
|
|
|
817 |
// Handle 404 if user are viewing course item directly.
|
818 |
$this->set_link_item_course_default_wp_to_page_404( $q );
|
819 |
|
@@ -821,39 +827,23 @@ class LP_Page_Controller {
|
|
821 |
|
822 |
/**
|
823 |
* If current page is used for courses page
|
|
|
824 |
*/
|
825 |
$page_courses_id = learn_press_get_page_id( 'courses' );
|
826 |
|
827 |
if ( $q->is_home() && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $page_courses_id ) {
|
828 |
-
$
|
829 |
-
|
830 |
-
|
831 |
-
! array_diff( array_keys( $_query ),
|
832 |
-
array(
|
833 |
-
'preview',
|
834 |
-
'page',
|
835 |
-
'paged',
|
836 |
-
'cpage',
|
837 |
-
'orderby'
|
838 |
-
)
|
839 |
-
)
|
840 |
-
) {
|
841 |
-
$q->is_page = true;
|
842 |
-
$q->is_home = false;
|
843 |
-
$q->set( 'page_id', get_option( 'page_on_front' ) );
|
844 |
-
$q->set( 'post_type', LP_COURSE_CPT );
|
845 |
-
}
|
846 |
}
|
847 |
|
848 |
/**
|
849 |
-
* If current page is used for courses page and set as
|
850 |
*/
|
851 |
if ( $q->is_page() && 'page' == get_option( 'show_on_front' ) && $page_courses_id && $q->get( 'page_id' ) == $page_courses_id ) {
|
|
|
852 |
|
853 |
-
$
|
854 |
-
$q->set( 'page_id', '' );
|
855 |
-
|
856 |
-
global $wp_post_types;
|
857 |
|
858 |
$course_page = get_post( $page_courses_id );
|
859 |
$this->_queried_object = $course_page;
|
@@ -861,28 +851,28 @@ class LP_Page_Controller {
|
|
861 |
$wp_post_types[ LP_COURSE_CPT ]->post_title = $course_page->post_title;
|
862 |
$wp_post_types[ LP_COURSE_CPT ]->post_name = $course_page->post_name;
|
863 |
$wp_post_types[ LP_COURSE_CPT ]->post_type = $course_page->post_type;
|
864 |
-
$wp_post_types[ LP_COURSE_CPT ]->ancestors = get_ancestors( $course_page->ID, $course_page->post_type )
|
865 |
-
|
866 |
-
$q->is_singular = false;
|
867 |
-
$q->is_post_type_archive = true;
|
868 |
-
$q->is_archive = true;
|
869 |
-
$q->is_page = true;
|
870 |
}
|
871 |
|
872 |
// Set custom posts per page
|
873 |
if ( $this->_is_archive() ) {
|
874 |
-
$
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
880 |
$q->set( 'posts_per_page', $limit );
|
881 |
}
|
882 |
-
|
883 |
-
if ( isset( $q->query['page'] ) ) {
|
884 |
-
$q->set( 'paged', $q->query['page'] );
|
885 |
-
}
|
886 |
}
|
887 |
|
888 |
return $q;
|
4 |
* Class LP_Page_Controller
|
5 |
*/
|
6 |
class LP_Page_Controller {
|
7 |
+
protected static $_instance = null;
|
8 |
protected $_shortcode_exists = false;
|
9 |
+
protected $_shortcode_tag = '[learn_press_archive_course]';
|
10 |
protected $_archive_contents = null;
|
11 |
|
12 |
/**
|
72 |
|
73 |
// Set title course archive page
|
74 |
if ( ! empty( $course_archive_page_id ) && $wp_query->post &&
|
75 |
+
$course_archive_page_id == $wp_query->post->ID ) {
|
76 |
$title = get_the_title( $course_archive_page_id );
|
77 |
$flag_title_course = true;
|
78 |
} elseif ( learn_press_is_course() ) {
|
79 |
+
$item = LP_Global::course_item();
|
80 |
+
if ( $item ) {
|
81 |
+
$title = apply_filters( 'learn-press/document-course-title-parts', get_the_title() . ' → ' . $item->get_title(), $item );
|
82 |
|
83 |
$flag_title_course = true;
|
84 |
}
|
108 |
array(
|
109 |
$page_title,
|
110 |
'→',
|
111 |
+
$tab['title'],
|
112 |
)
|
113 |
)
|
114 |
);
|
737 |
$this->_archive_contents = do_shortcode( $this->_shortcode_tag );
|
738 |
if ( class_exists( 'SiteOrigin_Panels' ) ) {
|
739 |
if ( class_exists( 'SiteOrigin_Panels' ) &&
|
740 |
+
has_filter( 'the_content', array( SiteOrigin_Panels::single(), 'generate_post_content' ) )
|
741 |
) {
|
742 |
remove_shortcode( 'learn_press_archive_course' );
|
743 |
add_filter(
|
768 |
if ( is_post_type_archive( LP_COURSE_CPT ) || LEARNPRESS_IS_CATEGORY ) {
|
769 |
$wp_query->is_page = false;
|
770 |
$wp_query->is_archive = true;
|
771 |
+
$wp_query->is_single = false;
|
772 |
} else {
|
773 |
$wp_query->found_posts = 1;
|
774 |
$wp_query->is_single = true;
|
803 |
}
|
804 |
|
805 |
/**
|
806 |
+
* Query courses if page is archive courses
|
807 |
*
|
808 |
* @param $q WP_Query
|
809 |
*
|
810 |
* @return WP_Query
|
811 |
+
* @editor tungnx
|
812 |
+
* @modify 4.1.2
|
813 |
+
* @throws Exception
|
814 |
*/
|
815 |
+
public function pre_get_posts( WP_Query $q ): WP_Query {
|
816 |
// Affect only the main query and not in admin
|
817 |
+
if ( ! $q->is_main_query() && ! is_admin() ) {
|
818 |
return $q;
|
819 |
}
|
820 |
|
821 |
+
$is_archive_course = false;
|
822 |
+
|
823 |
// Handle 404 if user are viewing course item directly.
|
824 |
$this->set_link_item_course_default_wp_to_page_404( $q );
|
825 |
|
827 |
|
828 |
/**
|
829 |
* If current page is used for courses page
|
830 |
+
* Set on both: "Homepage" and "Posts page" on Reading Settings
|
831 |
*/
|
832 |
$page_courses_id = learn_press_get_page_id( 'courses' );
|
833 |
|
834 |
if ( $q->is_home() && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $page_courses_id ) {
|
835 |
+
$is_archive_course = 1;
|
836 |
+
//$q->is_home = false;
|
837 |
+
//$q->set( 'page_id', get_option( 'page_on_front' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
838 |
}
|
839 |
|
840 |
/**
|
841 |
+
* If current page is used for courses page and set as "Homepage"
|
842 |
*/
|
843 |
if ( $q->is_page() && 'page' == get_option( 'show_on_front' ) && $page_courses_id && $q->get( 'page_id' ) == $page_courses_id ) {
|
844 |
+
$is_archive_course = 1;
|
845 |
|
846 |
+
/*global $wp_post_types;
|
|
|
|
|
|
|
847 |
|
848 |
$course_page = get_post( $page_courses_id );
|
849 |
$this->_queried_object = $course_page;
|
851 |
$wp_post_types[ LP_COURSE_CPT ]->post_title = $course_page->post_title;
|
852 |
$wp_post_types[ LP_COURSE_CPT ]->post_name = $course_page->post_name;
|
853 |
$wp_post_types[ LP_COURSE_CPT ]->post_type = $course_page->post_type;
|
854 |
+
$wp_post_types[ LP_COURSE_CPT ]->ancestors = get_ancestors( $course_page->ID, $course_page->post_type );*/
|
|
|
|
|
|
|
|
|
|
|
855 |
}
|
856 |
|
857 |
// Set custom posts per page
|
858 |
if ( $this->_is_archive() ) {
|
859 |
+
$is_archive_course = 1;
|
860 |
+
}
|
861 |
+
|
862 |
+
if ( $is_archive_course ) {
|
863 |
+
if ( lp_is_archive_course_load_via_api() && ! class_exists( 'TP' ) ) {
|
864 |
+
LP()->template( 'course' )->remove_callback( 'learn-press/after-courses-loop', 'loop/course/pagination.php', 10 );
|
865 |
+
/**
|
866 |
+
* If page is archive course - query set posts_per_page = 1
|
867 |
+
* For fastest - because when page loaded - call API to load list courses
|
868 |
+
*
|
869 |
+
* Current, apply only for LP, not apply for theme Thimpress, because theme override
|
870 |
+
*/
|
871 |
+
$q->set( 'posts_per_page', 1 );
|
872 |
+
} else {
|
873 |
+
$limit = LP_Settings::get_option( 'archive_course_limit', 6 );
|
874 |
$q->set( 'posts_per_page', $limit );
|
875 |
}
|
|
|
|
|
|
|
|
|
876 |
}
|
877 |
|
878 |
return $q;
|
inc/curds/class-lp-user-curd.php
CHANGED
@@ -1391,12 +1391,12 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1391 |
/**
|
1392 |
* Query own courses of an user.
|
1393 |
*
|
1394 |
-
* @param int
|
1395 |
-
* @param
|
1396 |
*
|
1397 |
* @return LP_Query_List_Table
|
1398 |
*/
|
1399 |
-
public function query_own_courses( $user_id, $args =
|
1400 |
global $wpdb, $wp;
|
1401 |
$paged = 1;
|
1402 |
|
@@ -1462,14 +1462,22 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1462 |
}
|
1463 |
|
1464 |
$where = $where . $wpdb->prepare( ' AND post_type = %s AND post_author = %d', LP_COURSE_CPT, $user_id );
|
1465 |
-
|
|
|
|
|
|
|
|
|
|
|
1466 |
SELECT SQL_CALC_FOUND_ROWS ID
|
1467 |
FROM {$wpdb->posts} c
|
|
|
1468 |
{$where}
|
1469 |
ORDER BY ID DESC
|
1470 |
LIMIT {$offset}, {$limit}
|
1471 |
";
|
1472 |
|
|
|
|
|
1473 |
$items = $wpdb->get_results( $sql );
|
1474 |
$count = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
|
1475 |
$all_courses = learnpress_get_count_by_user( $user_id, 'lp_course' );
|
@@ -1507,12 +1515,12 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1507 |
/**
|
1508 |
* Query courses by user
|
1509 |
*
|
1510 |
-
* @param int
|
1511 |
-
* @param
|
1512 |
*
|
1513 |
* @return LP_Query_List_Table
|
1514 |
*/
|
1515 |
-
public function query_purchased_courses( $user_id = 0, $args =
|
1516 |
global $wpdb, $wp;
|
1517 |
$paged = 1;
|
1518 |
|
@@ -1710,6 +1718,8 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1710 |
$limit = '';
|
1711 |
}
|
1712 |
|
|
|
|
|
1713 |
$sql = "
|
1714 |
SELECT SQL_CALC_FOUND_ROWS *
|
1715 |
FROM
|
@@ -1726,6 +1736,8 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1726 |
$limit
|
1727 |
";
|
1728 |
|
|
|
|
|
1729 |
$items = $wpdb->get_results( $sql );
|
1730 |
|
1731 |
if ( $unenrolled_course_ids ) {
|
1391 |
/**
|
1392 |
* Query own courses of an user.
|
1393 |
*
|
1394 |
+
* @param int $user_id
|
1395 |
+
* @param array $args
|
1396 |
*
|
1397 |
* @return LP_Query_List_Table
|
1398 |
*/
|
1399 |
+
public function query_own_courses( int $user_id = 0, array $args = array() ): LP_Query_List_Table {
|
1400 |
global $wpdb, $wp;
|
1401 |
$paged = 1;
|
1402 |
|
1462 |
}
|
1463 |
|
1464 |
$where = $where . $wpdb->prepare( ' AND post_type = %s AND post_author = %d', LP_COURSE_CPT, $user_id );
|
1465 |
+
|
1466 |
+
$join = '';
|
1467 |
+
|
1468 |
+
do_action( 'learnpress/user-curd/query_where_join_own_courses', $where, $join );
|
1469 |
+
|
1470 |
+
$sql = "
|
1471 |
SELECT SQL_CALC_FOUND_ROWS ID
|
1472 |
FROM {$wpdb->posts} c
|
1473 |
+
{$join}
|
1474 |
{$where}
|
1475 |
ORDER BY ID DESC
|
1476 |
LIMIT {$offset}, {$limit}
|
1477 |
";
|
1478 |
|
1479 |
+
do_action( 'learnpress/user-curd/query_string_own_courses', $sql );
|
1480 |
+
|
1481 |
$items = $wpdb->get_results( $sql );
|
1482 |
$count = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
|
1483 |
$all_courses = learnpress_get_count_by_user( $user_id, 'lp_course' );
|
1515 |
/**
|
1516 |
* Query courses by user
|
1517 |
*
|
1518 |
+
* @param int $user_id
|
1519 |
+
* @param array $args
|
1520 |
*
|
1521 |
* @return LP_Query_List_Table
|
1522 |
*/
|
1523 |
+
public function query_purchased_courses( int $user_id = 0, array $args = array() ): LP_Query_List_Table {
|
1524 |
global $wpdb, $wp;
|
1525 |
$paged = 1;
|
1526 |
|
1718 |
$limit = '';
|
1719 |
}
|
1720 |
|
1721 |
+
do_action( 'learnpress/user-curd/query_where_join_purchased_courses', $where, $join );
|
1722 |
+
|
1723 |
$sql = "
|
1724 |
SELECT SQL_CALC_FOUND_ROWS *
|
1725 |
FROM
|
1736 |
$limit
|
1737 |
";
|
1738 |
|
1739 |
+
do_action( 'learnpress/user-curd/query_string_purchased_courses', $sql );
|
1740 |
+
|
1741 |
$items = $wpdb->get_results( $sql );
|
1742 |
|
1743 |
if ( $unenrolled_course_ids ) {
|
inc/jwt/includes/class-jwt-public.php
CHANGED
@@ -67,6 +67,16 @@ class LP_Jwt_Public {
|
|
67 |
'permission_callback' => '__return_true',
|
68 |
)
|
69 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
public function get_item_schema() {
|
@@ -113,6 +123,27 @@ class LP_Jwt_Public {
|
|
113 |
}
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
public function generate_token( WP_REST_Request $request ) {
|
117 |
$secret_key = $this->secret_key;
|
118 |
$username = $request->get_param( 'username' );
|
67 |
'permission_callback' => '__return_true',
|
68 |
)
|
69 |
);
|
70 |
+
|
71 |
+
register_rest_route(
|
72 |
+
$this->namespace,
|
73 |
+
'token/register',
|
74 |
+
array(
|
75 |
+
'methods' => WP_REST_Server::CREATABLE,
|
76 |
+
'callback' => array( $this, 'register' ),
|
77 |
+
'permission_callback' => '__return_true',
|
78 |
+
)
|
79 |
+
);
|
80 |
}
|
81 |
|
82 |
public function get_item_schema() {
|
123 |
}
|
124 |
}
|
125 |
|
126 |
+
public function register( WP_REST_Request $request ) {
|
127 |
+
$username = $request->get_param( 'username' );
|
128 |
+
$password = $request->get_param( 'password' );
|
129 |
+
$confirm_password = $request->get_param( 'confirm_password' );
|
130 |
+
$email = $request->get_param( 'email' );
|
131 |
+
|
132 |
+
$customer_id = LP_Forms_Handler::learnpress_create_new_customer( $email, $username, $password, $confirm_password );
|
133 |
+
|
134 |
+
if ( is_wp_error( $customer_id ) ) {
|
135 |
+
return new WP_Error(
|
136 |
+
$customer_id->get_error_code(),
|
137 |
+
$customer_id->get_error_message(),
|
138 |
+
array(
|
139 |
+
'status' => 403,
|
140 |
+
)
|
141 |
+
);
|
142 |
+
}
|
143 |
+
|
144 |
+
return $this->generate_token( $request );
|
145 |
+
}
|
146 |
+
|
147 |
public function generate_token( WP_REST_Request $request ) {
|
148 |
$secret_key = $this->secret_key;
|
149 |
$username = $request->get_param( 'username' );
|
inc/jwt/responsive.http
CHANGED
@@ -15,6 +15,17 @@ Content-Type: application/json
|
|
15 |
"password": "student"
|
16 |
}
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
###
|
19 |
POST http://learnpress4.local/wp-json/learnpress/v1/token/validate
|
20 |
Content-Type: application/json
|
@@ -38,7 +49,7 @@ Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvX
|
|
38 |
###
|
39 |
POST http://learnpress4.local/wp-json/learnpress/v1/courses/enroll
|
40 |
Content-Type: application/json
|
41 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
42 |
|
43 |
{
|
44 |
"id": "196"
|
@@ -48,7 +59,7 @@ Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvX
|
|
48 |
###
|
49 |
POST http://learnpress4.local/wp-json/learnpress/v1/courses/finish
|
50 |
Content-Type: application/json
|
51 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
52 |
|
53 |
{
|
54 |
"id": "196"
|
@@ -58,7 +69,8 @@ Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvX
|
|
58 |
###
|
59 |
POST http://learnpress4.local/wp-json/learnpress/v1/courses/retake
|
60 |
Content-Type: application/json
|
61 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
|
62 |
|
63 |
{
|
64 |
"id": "196"
|
@@ -188,3 +200,13 @@ Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvX
|
|
188 |
"password": "student"
|
189 |
}
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
"password": "student"
|
16 |
}
|
17 |
|
18 |
+
###
|
19 |
+
POST http://learnpress4.local/wp-json/learnpress/v1/token/register
|
20 |
+
Content-Type: application/json
|
21 |
+
|
22 |
+
{
|
23 |
+
"username": "student4",
|
24 |
+
"password": "student4",
|
25 |
+
"confirm_password": "student4",
|
26 |
+
"email": "student4@gmail.com"
|
27 |
+
}
|
28 |
+
|
29 |
###
|
30 |
POST http://learnpress4.local/wp-json/learnpress/v1/token/validate
|
31 |
Content-Type: application/json
|
49 |
###
|
50 |
POST http://learnpress4.local/wp-json/learnpress/v1/courses/enroll
|
51 |
Content-Type: application/json
|
52 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyNjIzNDYxMiwibmJmIjoxNjI2MjM0NjEyLCJleHAiOjE2MjY4Mzk0MTIsImRhdGEiOnsidXNlciI6eyJpZCI6IjIifX19.qxB0-uGPBk52QyjVAAoqceizynMp8BUt3eOrBB3MF2c
|
53 |
|
54 |
{
|
55 |
"id": "196"
|
59 |
###
|
60 |
POST http://learnpress4.local/wp-json/learnpress/v1/courses/finish
|
61 |
Content-Type: application/json
|
62 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyNjIzNDYxMiwibmJmIjoxNjI2MjM0NjEyLCJleHAiOjE2MjY4Mzk0MTIsImRhdGEiOnsidXNlciI6eyJpZCI6IjIifX19.qxB0-uGPBk52QyjVAAoqceizynMp8BUt3eOrBB3MF2c
|
63 |
|
64 |
{
|
65 |
"id": "196"
|
69 |
###
|
70 |
POST http://learnpress4.local/wp-json/learnpress/v1/courses/retake
|
71 |
Content-Type: application/json
|
72 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyNjIzNDYxMiwibmJmIjoxNjI2MjM0NjEyLCJleHAiOjE2MjY4Mzk0MTIsImRhdGEiOnsidXNlciI6eyJpZCI6IjIifX19.qxB0-uGPBk52QyjVAAoqceizynMp8BUt3eOrBB3MF2c
|
73 |
+
|
74 |
|
75 |
{
|
76 |
"id": "196"
|
200 |
"password": "student"
|
201 |
}
|
202 |
|
203 |
+
####
|
204 |
+
POST http://learnpress4.local/wp-json/wp/v2/users/
|
205 |
+
Content-Type: application/json
|
206 |
+
|
207 |
+
{
|
208 |
+
"username": "student4",
|
209 |
+
"password": "student4",
|
210 |
+
"email": "student4@gmail.com"
|
211 |
+
}
|
212 |
+
|
inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php
CHANGED
@@ -291,7 +291,7 @@ class LP_Jwt_Quiz_V1_Controller extends LP_REST_Jwt_Posts_Controller {
|
|
291 |
return rest_ensure_response( $response );
|
292 |
}
|
293 |
|
294 |
-
if ( ! isset( $answered ) ) {
|
295 |
$response->status = 'error';
|
296 |
$response->message = esc_html__( 'No Answed param.', 'learnpress' );
|
297 |
|
291 |
return rest_ensure_response( $response );
|
292 |
}
|
293 |
|
294 |
+
if ( ! isset( $request['answered'] ) ) {
|
295 |
$response->status = 'error';
|
296 |
$response->message = esc_html__( 'No Answed param.', 'learnpress' );
|
297 |
|
inc/lp-core-functions.php
CHANGED
@@ -3453,17 +3453,19 @@ function learn_press_cookie_get( $name, $namespace = 'LP' ) {
|
|
3453 |
*
|
3454 |
* @return array
|
3455 |
* @since 3.x.x
|
|
|
|
|
3456 |
*/
|
3457 |
-
function learn_press_default_course_levels() {
|
3458 |
$levels = array(
|
3459 |
'beginner' => __( 'Beginner', 'learnpress' ),
|
3460 |
'intermediate' => __( 'Intermediate', 'learnpress' ),
|
3461 |
'expert' => __( 'Expert', 'learnpress' ),
|
3462 |
-
'' => __( 'All
|
3463 |
);
|
3464 |
|
3465 |
return apply_filters( 'learn-press/default-course-levels', $levels );
|
3466 |
-
}
|
3467 |
|
3468 |
/**
|
3469 |
* Get default methods to evaluate course results.
|
3453 |
*
|
3454 |
* @return array
|
3455 |
* @since 3.x.x
|
3456 |
+
* @editor tungnx
|
3457 |
+
* @reason comment - not use
|
3458 |
*/
|
3459 |
+
/*function learn_press_default_course_levels() {
|
3460 |
$levels = array(
|
3461 |
'beginner' => __( 'Beginner', 'learnpress' ),
|
3462 |
'intermediate' => __( 'Intermediate', 'learnpress' ),
|
3463 |
'expert' => __( 'Expert', 'learnpress' ),
|
3464 |
+
'' => __( 'All levels', 'learnpress' ),
|
3465 |
);
|
3466 |
|
3467 |
return apply_filters( 'learn-press/default-course-levels', $levels );
|
3468 |
+
}*/
|
3469 |
|
3470 |
/**
|
3471 |
* Get default methods to evaluate course results.
|
inc/lp-template-functions.php
CHANGED
@@ -292,8 +292,8 @@ if ( ! function_exists( 'learn_press_single_course_args' ) ) {
|
|
292 |
|
293 |
if ( ! function_exists( 'learn_press_single_quiz_args' ) ) {
|
294 |
function learn_press_single_quiz_args() {
|
295 |
-
$args
|
296 |
-
$quiz
|
297 |
$course = LP_Global::course();
|
298 |
if ( $quiz ) {
|
299 |
$user = LP_Global::user();
|
@@ -306,12 +306,12 @@ if ( ! function_exists( 'learn_press_single_quiz_args' ) ) {
|
|
306 |
}
|
307 |
|
308 |
$args = array(
|
309 |
-
'id'
|
310 |
-
'totalTime'
|
311 |
-
'remainingTime'
|
312 |
-
'status'
|
313 |
'checkNorequizenroll' => $course->is_no_required_enroll(),
|
314 |
-
'navigationPosition'
|
315 |
);
|
316 |
}
|
317 |
|
@@ -780,13 +780,16 @@ if ( ! function_exists( 'learn_press_page_title' ) ) {
|
|
780 |
*
|
781 |
* @return string
|
782 |
*/
|
783 |
-
function learn_press_page_title( $echo = true ) {
|
|
|
|
|
784 |
if ( is_search() ) {
|
785 |
-
|
|
|
786 |
|
787 |
if ( get_query_var( 'paged' ) ) {
|
788 |
$page_title .= sprintf( __( ' – Page %s', 'learnpress' ), get_query_var( 'paged' ) );
|
789 |
-
}
|
790 |
} elseif ( is_tax() ) {
|
791 |
|
792 |
$page_title = single_term_title( '', false );
|
@@ -1859,7 +1862,6 @@ if ( ! function_exists( 'lp_archive_course_page_content' ) ) {
|
|
1859 |
$profile_page = get_post( $profile_id );
|
1860 |
|
1861 |
$description = lp_format_page_content( wp_kses_post( $profile_page->post_content ) );
|
1862 |
-
|
1863 |
if ( $description ) {
|
1864 |
echo '<div class="lp-course-page__content">' . $description . '</div>';
|
1865 |
}
|
@@ -1880,3 +1882,52 @@ if ( ! function_exists( 'lp_taxonomy_archive_course_description' ) ) {
|
|
1880 |
}
|
1881 |
}
|
1882 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
|
293 |
if ( ! function_exists( 'learn_press_single_quiz_args' ) ) {
|
294 |
function learn_press_single_quiz_args() {
|
295 |
+
$args = array();
|
296 |
+
$quiz = LP_Global::course_item_quiz();
|
297 |
$course = LP_Global::course();
|
298 |
if ( $quiz ) {
|
299 |
$user = LP_Global::user();
|
306 |
}
|
307 |
|
308 |
$args = array(
|
309 |
+
'id' => $quiz->get_id(),
|
310 |
+
'totalTime' => $quiz->get_duration()->get(),
|
311 |
+
'remainingTime' => $remaining_time ? $remaining_time->get() : $quiz->get_duration()->get(),
|
312 |
+
'status' => $user->get_item_status( $quiz->get_id(), LP_Global::course( true ) ),
|
313 |
'checkNorequizenroll' => $course->is_no_required_enroll(),
|
314 |
+
'navigationPosition' => LP_Settings::get_option( 'navigation_position', 'yes' ),
|
315 |
);
|
316 |
}
|
317 |
|
780 |
*
|
781 |
* @return string
|
782 |
*/
|
783 |
+
function learn_press_page_title( bool $echo = true ): string {
|
784 |
+
$page_title = '';
|
785 |
+
|
786 |
if ( is_search() ) {
|
787 |
+
// Comment by tungnx
|
788 |
+
/*$page_title = sprintf( __( 'Search Results for: “%s”', 'learnpress' ), get_search_query() );
|
789 |
|
790 |
if ( get_query_var( 'paged' ) ) {
|
791 |
$page_title .= sprintf( __( ' – Page %s', 'learnpress' ), get_query_var( 'paged' ) );
|
792 |
+
}*/
|
793 |
} elseif ( is_tax() ) {
|
794 |
|
795 |
$page_title = single_term_title( '', false );
|
1862 |
$profile_page = get_post( $profile_id );
|
1863 |
|
1864 |
$description = lp_format_page_content( wp_kses_post( $profile_page->post_content ) );
|
|
|
1865 |
if ( $description ) {
|
1866 |
echo '<div class="lp-course-page__content">' . $description . '</div>';
|
1867 |
}
|
1882 |
}
|
1883 |
}
|
1884 |
}
|
1885 |
+
|
1886 |
+
function lp_is_archive_course_load_via_api() {
|
1887 |
+
return apply_filters( 'lp/template/archive-course/enable_lazyload', 1 );
|
1888 |
+
}
|
1889 |
+
|
1890 |
+
function lp_archive_skeleton_get_args() {
|
1891 |
+
global $post, $wp;
|
1892 |
+
|
1893 |
+
$args = array();
|
1894 |
+
|
1895 |
+
if ( ! empty( $_GET ) ) {
|
1896 |
+
$args = (array) $_GET;
|
1897 |
+
}
|
1898 |
+
|
1899 |
+
$array = apply_filters(
|
1900 |
+
'lp/template/archive-course/skeleton/args',
|
1901 |
+
array(
|
1902 |
+
'paged',
|
1903 |
+
's',
|
1904 |
+
'orderby',
|
1905 |
+
'order',
|
1906 |
+
)
|
1907 |
+
);
|
1908 |
+
|
1909 |
+
if ( learn_press_is_course_category() || learn_press_is_course_tag() ) {
|
1910 |
+
$cat = get_queried_object();
|
1911 |
+
|
1912 |
+
$args['term_id'] = $cat->term_id;
|
1913 |
+
$args['taxonomy'] = $cat->taxonomy;
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
if ( learn_press_is_course_archive() ) {
|
1917 |
+
foreach ( $array as $a ) {
|
1918 |
+
if ( get_query_var( $a ) ) {
|
1919 |
+
$args[ $a ] = get_query_var( $a );
|
1920 |
+
}
|
1921 |
+
}
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
return $args;
|
1925 |
+
}
|
1926 |
+
|
1927 |
+
add_action(
|
1928 |
+
'learn-press/after-enqueue-scripts',
|
1929 |
+
function() {
|
1930 |
+
$args = lp_archive_skeleton_get_args();
|
1931 |
+
wp_add_inline_script( 'lp-courses', 'const lpArchiveSkeleton= ' . wp_json_encode( $args ) . '' );
|
1932 |
+
}
|
1933 |
+
);
|
inc/rest-api/v1/frontend/class-lp-rest-courses-controller.php
CHANGED
@@ -51,6 +51,13 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
|
|
51 |
),
|
52 |
),
|
53 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
'(?P<key>[\w]+)' => array(
|
55 |
'args' => array(
|
56 |
'id' => array(
|
@@ -85,6 +92,100 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
|
|
85 |
return LP_REST_Authentication::check_admin_permission();
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
public function search_courses( $request ) {
|
89 |
$s = $request['s'];
|
90 |
$page = $request['page'];
|
@@ -147,7 +248,8 @@ class LP_REST_Courses_Controller extends LP_Abstract_REST_Controller {
|
|
147 |
);
|
148 |
}
|
149 |
|
150 |
-
ob_start();
|
|
|
151 |
|
152 |
<div class="course-price">
|
153 |
<?php if ( $course->has_sale_price() ) { ?>
|
51 |
),
|
52 |
),
|
53 |
),
|
54 |
+
'archive-course' => array(
|
55 |
+
array(
|
56 |
+
'methods' => WP_REST_Server::READABLE,
|
57 |
+
'callback' => array( $this, 'archive_course' ),
|
58 |
+
'permission_callback' => '__return_true',
|
59 |
+
),
|
60 |
+
),
|
61 |
'(?P<key>[\w]+)' => array(
|
62 |
'args' => array(
|
63 |
'id' => array(
|
92 |
return LP_REST_Authentication::check_admin_permission();
|
93 |
}
|
94 |
|
95 |
+
public function archive_course( WP_REST_Request $request ) {
|
96 |
+
$response = new LP_REST_Response();
|
97 |
+
$response->data = new stdClass();
|
98 |
+
|
99 |
+
$s = isset( $request['s'] ) ? sanitize_text_field( $request['s'] ) : false;
|
100 |
+
$page = isset( $request['paged'] ) ? absint( wp_unslash( $request['paged'] ) ) : 1;
|
101 |
+
$order = isset( $request['order'] ) ? wp_unslash( $request['order'] ) : false;
|
102 |
+
$orderby = isset( $request['orderby'] ) ? wp_unslash( $request['orderby'] ) : false;
|
103 |
+
$taxonomy = isset( $request['taxonomy'] ) ? wp_unslash( $request['taxonomy'] ) : false;
|
104 |
+
$term_id = isset( $request['term_id'] ) ? wp_unslash( $request['term_id'] ) : false;
|
105 |
+
$user_id = isset( $request['userID'] ) ? absint( wp_unslash( $request['userID'] ) ) : false;
|
106 |
+
$limit = LP_Settings::get_option( 'archive_course_limit', -1 );
|
107 |
+
|
108 |
+
$args = array(
|
109 |
+
'posts_per_page' => $limit,
|
110 |
+
'paged' => $page,
|
111 |
+
'post_type' => LP_COURSE_CPT,
|
112 |
+
);
|
113 |
+
|
114 |
+
if ( ! empty( $s ) ) {
|
115 |
+
$args['s'] = $s;
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( ! empty( $taxonomy ) && ! empty( $term_id ) ) {
|
119 |
+
$args['tax_query'] = array(
|
120 |
+
array(
|
121 |
+
'taxonomy' => $taxonomy,
|
122 |
+
'field' => 'term_id',
|
123 |
+
'terms' => $term_id,
|
124 |
+
),
|
125 |
+
);
|
126 |
+
|
127 |
+
$term_link = get_term_link( $term_id, $taxonomy );
|
128 |
+
}
|
129 |
+
|
130 |
+
if ( ! empty( $order ) ) {
|
131 |
+
$args['order'] = $order;
|
132 |
+
}
|
133 |
+
|
134 |
+
if ( ! empty( $orderby ) ) {
|
135 |
+
$args['orderby'] = $orderby;
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( $user_id && learn_press_user_maybe_is_a_teacher( $user_id ) ) {
|
139 |
+
$args['post_status'] = array( 'publish', 'private' );
|
140 |
+
}
|
141 |
+
|
142 |
+
$args = apply_filters( 'lp/rest-api/frontend/course/archive_course/query_args', $args, $request );
|
143 |
+
|
144 |
+
$query = new WP_Query( $args );
|
145 |
+
|
146 |
+
$num_pages = ! empty( $query->max_num_pages ) ? $query->max_num_pages : 1;
|
147 |
+
|
148 |
+
$archive_link = get_post_type_archive_link( LP_COURSE_CPT );
|
149 |
+
|
150 |
+
if ( isset( $term_link ) && ! is_wp_error( $term_link ) ) {
|
151 |
+
$archive_link = $term_link;
|
152 |
+
}
|
153 |
+
|
154 |
+
$base = esc_url_raw( str_replace( 999999999, '%#%', get_pagenum_link( 999999999, false ) ) );
|
155 |
+
|
156 |
+
global $wp;
|
157 |
+
$base = str_replace( home_url( $wp->request ) . '/', $archive_link, $base );
|
158 |
+
|
159 |
+
$response->data->pagination = learn_press_get_template_content(
|
160 |
+
'loop/course/pagination.php',
|
161 |
+
array(
|
162 |
+
'total' => $num_pages,
|
163 |
+
'paged' => $page,
|
164 |
+
'base' => $base,
|
165 |
+
)
|
166 |
+
);
|
167 |
+
|
168 |
+
ob_start();
|
169 |
+
|
170 |
+
if ( $query->have_posts() ) {
|
171 |
+
global $post;
|
172 |
+
|
173 |
+
while ( $query->have_posts() ) {
|
174 |
+
$query->the_post();
|
175 |
+
learn_press_get_template_part( 'content', 'course' );
|
176 |
+
}
|
177 |
+
|
178 |
+
wp_reset_postdata();
|
179 |
+
} else {
|
180 |
+
LP()->template( 'course' )->no_courses_found();
|
181 |
+
}
|
182 |
+
|
183 |
+
$response->status = 'success';
|
184 |
+
$response->data->content = ob_get_clean();
|
185 |
+
|
186 |
+
return rest_ensure_response( apply_filters( 'lp/rest-api/frontend/course/archive_course/response', $response ) );
|
187 |
+
}
|
188 |
+
|
189 |
public function search_courses( $request ) {
|
190 |
$s = $request['s'];
|
191 |
$page = $request['page'];
|
248 |
);
|
249 |
}
|
250 |
|
251 |
+
ob_start();
|
252 |
+
?>
|
253 |
|
254 |
<div class="course-price">
|
255 |
<?php if ( $course->has_sale_price() ) { ?>
|
inc/templates/class-lp-template-course.php
CHANGED
@@ -989,6 +989,10 @@ class LP_Template_Course extends LP_Abstract_Template {
|
|
989 |
);
|
990 |
}
|
991 |
}
|
|
|
|
|
|
|
|
|
992 |
}
|
993 |
|
994 |
return new LP_Template_Course();
|
989 |
);
|
990 |
}
|
991 |
}
|
992 |
+
|
993 |
+
public function no_courses_found() {
|
994 |
+
learn_press_get_template( 'global/no-courses-found' );
|
995 |
+
}
|
996 |
}
|
997 |
|
998 |
return new LP_Template_Course();
|
inc/user/abstract-lp-user.php
CHANGED
@@ -2493,7 +2493,7 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
|
|
2493 |
*
|
2494 |
* @return LP_Query_List_Table
|
2495 |
*/
|
2496 |
-
public function get_purchased_courses( $args = array() ) {
|
2497 |
return $this->_curd->query_purchased_courses( $this->get_id(), $args );
|
2498 |
}
|
2499 |
|
@@ -2579,7 +2579,13 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
|
|
2579 |
return LP_Profile::instance( $this->get_id() )->get_profile_picture( $type, $size );
|
2580 |
}
|
2581 |
|
2582 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
2583 |
$socials = array();
|
2584 |
$extra_info = learn_press_get_user_extra_profile_info( $user_id );
|
2585 |
|
2493 |
*
|
2494 |
* @return LP_Query_List_Table
|
2495 |
*/
|
2496 |
+
public function get_purchased_courses( array $args = array() ): LP_Query_List_Table {
|
2497 |
return $this->_curd->query_purchased_courses( $this->get_id(), $args );
|
2498 |
}
|
2499 |
|
2579 |
return LP_Profile::instance( $this->get_id() )->get_profile_picture( $type, $size );
|
2580 |
}
|
2581 |
|
2582 |
+
/**
|
2583 |
+
* Get links socials of use on Profile page
|
2584 |
+
*
|
2585 |
+
* @param int $user_id
|
2586 |
+
* @return array
|
2587 |
+
*/
|
2588 |
+
public function get_profile_socials( int $user_id = 0 ): array {
|
2589 |
$socials = array();
|
2590 |
$extra_info = learn_press_get_user_extra_profile_info( $user_id );
|
2591 |
|
inc/user/class-lp-profile.php
CHANGED
@@ -730,11 +730,11 @@ if ( ! class_exists( 'LP_Profile' ) ) {
|
|
730 |
* Query user's courses
|
731 |
*
|
732 |
* @param string $type - Optional. [own, purchased, enrolled, etc]
|
733 |
-
* @param
|
734 |
*
|
735 |
-
* @return
|
736 |
*/
|
737 |
-
public function query_courses( $type = 'own', $args =
|
738 |
$query = false;
|
739 |
switch ( $type ) {
|
740 |
case 'purchased':
|
730 |
* Query user's courses
|
731 |
*
|
732 |
* @param string $type - Optional. [own, purchased, enrolled, etc]
|
733 |
+
* @param array $args - Optional.
|
734 |
*
|
735 |
+
* @return bool|LP_Query_List_Table
|
736 |
*/
|
737 |
+
public function query_courses( string $type = 'own', array $args = array() ) {
|
738 |
$query = false;
|
739 |
switch ( $type ) {
|
740 |
case 'purchased':
|
languages/learnpress.pot
CHANGED
@@ -2458,6 +2458,7 @@ msgstr ""
|
|
2458 |
|
2459 |
#: inc/admin/views/meta-boxes/question/settings.php:35
|
2460 |
#: inc/admin/views/quiz/question-meta.php:50
|
|
|
2461 |
msgid "Explanation"
|
2462 |
msgstr ""
|
2463 |
|
@@ -7355,11 +7356,19 @@ msgctxt "course-item-navigation"
|
|
7355 |
msgid "Prev"
|
7356 |
msgstr ""
|
7357 |
|
|
|
|
|
|
|
|
|
7358 |
#: templates/single-course/content-item/nav.php:39
|
7359 |
msgctxt "course-item-navigation"
|
7360 |
msgid "Next"
|
7361 |
msgstr ""
|
7362 |
|
|
|
|
|
|
|
|
|
7363 |
#: templates/single-course/content-item/popup-header.php:34
|
7364 |
msgid "%1$s of %2$d items"
|
7365 |
msgstr ""
|
@@ -7585,5 +7594,5 @@ msgid "Start"
|
|
7585 |
msgstr ""
|
7586 |
|
7587 |
#: assets/js/dist/frontend/quiz.js:1
|
7588 |
-
msgid "Hint
|
7589 |
msgstr ""
|
2458 |
|
2459 |
#: inc/admin/views/meta-boxes/question/settings.php:35
|
2460 |
#: inc/admin/views/quiz/question-meta.php:50
|
2461 |
+
#: assets/js/dist/frontend/quiz.js:1
|
2462 |
msgid "Explanation"
|
2463 |
msgstr ""
|
2464 |
|
7356 |
msgid "Prev"
|
7357 |
msgstr ""
|
7358 |
|
7359 |
+
#: assets/js/dist/frontend/quiz.js:1
|
7360 |
+
msgid "Prev"
|
7361 |
+
msgstr ""
|
7362 |
+
|
7363 |
#: templates/single-course/content-item/nav.php:39
|
7364 |
msgctxt "course-item-navigation"
|
7365 |
msgid "Next"
|
7366 |
msgstr ""
|
7367 |
|
7368 |
+
#: assets/js/dist/frontend/quiz.js:1
|
7369 |
+
msgid "Next"
|
7370 |
+
msgstr ""
|
7371 |
+
|
7372 |
#: templates/single-course/content-item/popup-header.php:34
|
7373 |
msgid "%1$s of %2$d items"
|
7374 |
msgstr ""
|
7594 |
msgstr ""
|
7595 |
|
7596 |
#: assets/js/dist/frontend/quiz.js:1
|
7597 |
+
msgid "Hint"
|
7598 |
msgstr ""
|
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.1.
|
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.2
|
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.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -197,6 +197,11 @@ https://www.transifex.com/projects/p/learnpress/
|
|
197 |
|
198 |
== Changelog ==
|
199 |
|
|
|
|
|
|
|
|
|
|
|
200 |
= 4.1.1 =
|
201 |
~ Added: tool clean "table session" clean sessions expire after 1 days.
|
202 |
~ Fixed: not show button "continue" when course is blocked.
|
5 |
Requires at least: 5.6
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 7.0
|
8 |
+
Stable tag: 4.1.2
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
197 |
|
198 |
== Changelog ==
|
199 |
|
200 |
+
= 4.1.2 =
|
201 |
+
~ Modify, optimize Archive course page - call API - make faster
|
202 |
+
~ Added: back icon on item page
|
203 |
+
~ Fixed: some where call old function "get_profile_socials" not has param $user_id
|
204 |
+
|
205 |
= 4.1.1 =
|
206 |
~ Added: tool clean "table session" clean sessions expire after 1 days.
|
207 |
~ Fixed: not show button "continue" when course is blocked.
|
templates/archive-course.php
CHANGED
@@ -38,21 +38,26 @@ $page_title = learn_press_page_title( false );
|
|
38 |
* LP Hook
|
39 |
*/
|
40 |
do_action( 'learn-press/before-courses-loop' );
|
41 |
-
|
42 |
LP()->template( 'course' )->begin_courses_loop();
|
43 |
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
|
48 |
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
|
51 |
LP()->template( 'course' )->end_courses_loop();
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @since 3.0.0
|
55 |
-
*/
|
56 |
do_action( 'learn-press/after-courses-loop' );
|
57 |
|
58 |
|
38 |
* LP Hook
|
39 |
*/
|
40 |
do_action( 'learn-press/before-courses-loop' );
|
|
|
41 |
LP()->template( 'course' )->begin_courses_loop();
|
42 |
|
43 |
+
if ( lp_is_archive_course_load_via_api() ) {
|
44 |
+
echo '<div class="lp-archive-course-skeleton" style="width:100%">';
|
45 |
+
echo lp_skeleton_animation_html( 10, 'random', 'height:20px', 'width:100%' );
|
46 |
+
echo '</div>';
|
47 |
+
} else {
|
48 |
+
if ( have_posts() ) {
|
49 |
+
while ( have_posts() ) :
|
50 |
+
the_post();
|
51 |
|
52 |
+
learn_press_get_template_part( 'content', 'course' );
|
53 |
|
54 |
+
endwhile;
|
55 |
+
} else {
|
56 |
+
LP()->template( 'course' )->no_courses_found();
|
57 |
+
}
|
58 |
+
}
|
59 |
|
60 |
LP()->template( 'course' )->end_courses_loop();
|
|
|
|
|
|
|
|
|
61 |
do_action( 'learn-press/after-courses-loop' );
|
62 |
|
63 |
|
templates/courses-top-bar.php
CHANGED
@@ -15,7 +15,11 @@ $s = LP_Request::get( 's' );
|
|
15 |
?>
|
16 |
|
17 |
<div class="lp-courses-bar <?php echo esc_attr( $active ); ?>">
|
18 |
-
<form class="search-courses" method="
|
|
|
|
|
|
|
|
|
19 |
<input type="text" placeholder="<?php esc_attr_e( 'Search courses...', 'learnpress' ); ?>" name="s" value="<?php echo esc_attr( $s ); ?>">
|
20 |
<button type="submit"><i class="fas fa-search"></i></button>
|
21 |
</form>
|
15 |
?>
|
16 |
|
17 |
<div class="lp-courses-bar <?php echo esc_attr( $active ); ?>">
|
18 |
+
<form class="search-courses" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
|
19 |
+
<input type="hidden" name="post_type" value="<?php echo esc_attr( LP_COURSE_CPT ); ?>">
|
20 |
+
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( get_queried_object()->taxonomy ?? $_GET['taxonomy'] ?? '' ); ?>">
|
21 |
+
<input type="hidden" name="term_id" value="<?php echo esc_attr( get_queried_object()->term_id ?? $_GET['term_id'] ?? '' ); ?>">
|
22 |
+
<input type="hidden" name="term" value="<?php echo esc_attr( get_queried_object()->slug ?? $_GET['term'] ?? '' ); ?>">
|
23 |
<input type="text" placeholder="<?php esc_attr_e( 'Search courses...', 'learnpress' ); ?>" name="s" value="<?php echo esc_attr( $s ); ?>">
|
24 |
<button type="submit"><i class="fas fa-search"></i></button>
|
25 |
</form>
|
templates/global/no-courses-found.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Displayed when no course are found matching the current query
|
4 |
+
*
|
5 |
+
* This template can be overridden by copying it to yourtheme/learnpress/global/no-courses-found.php.
|
6 |
+
*
|
7 |
+
* @author ThimPress
|
8 |
+
* @package Learnpress/Templates
|
9 |
+
* @version 4.1.1
|
10 |
+
*/
|
11 |
+
|
12 |
+
defined( 'ABSPATH' ) || exit;
|
13 |
+
?>
|
14 |
+
|
15 |
+
<p class="learn-press-message error"><?php esc_html_e( 'No courses were found matching your selection.', 'learnpress' ); ?></p>
|
templates/loop/course/pagination.php
CHANGED
@@ -6,29 +6,33 @@
|
|
6 |
*
|
7 |
* @author ThimPress
|
8 |
* @package Learnpress/Templates
|
9 |
-
* @version 4.
|
10 |
*/
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit();
|
13 |
|
14 |
global $wp_query;
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
return;
|
18 |
}
|
19 |
?>
|
20 |
|
21 |
-
<nav class="learn-press-pagination">
|
22 |
<?php
|
23 |
echo paginate_links(
|
24 |
apply_filters(
|
25 |
'learn_press_pagination_args',
|
26 |
array(
|
27 |
-
'base' =>
|
28 |
'format' => '',
|
29 |
'add_args' => '',
|
30 |
-
'current' => max( 1,
|
31 |
-
'total' => $
|
32 |
'prev_text' => '<i class="fas fa-angle-left"></i>',
|
33 |
'next_text' => '<i class="fas fa-angle-right"></i>',
|
34 |
'type' => 'list',
|
6 |
*
|
7 |
* @author ThimPress
|
8 |
* @package Learnpress/Templates
|
9 |
+
* @version 4.1.1
|
10 |
*/
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit();
|
13 |
|
14 |
global $wp_query;
|
15 |
|
16 |
+
$total = $total ?? $wp_query->max_num_pages;
|
17 |
+
$paged = $paged ?? get_query_var( 'paged' );
|
18 |
+
$base = $base ?? esc_url_raw( str_replace( 999999999, '%#%', get_pagenum_link( 999999999, false ) ) );
|
19 |
+
|
20 |
+
if ( $total <= 1 ) {
|
21 |
return;
|
22 |
}
|
23 |
?>
|
24 |
|
25 |
+
<nav class="learn-press-pagination navigation pagination">
|
26 |
<?php
|
27 |
echo paginate_links(
|
28 |
apply_filters(
|
29 |
'learn_press_pagination_args',
|
30 |
array(
|
31 |
+
'base' => $base,
|
32 |
'format' => '',
|
33 |
'add_args' => '',
|
34 |
+
'current' => max( 1, $paged ),
|
35 |
+
'total' => $total,
|
36 |
'prev_text' => '<i class="fas fa-angle-left"></i>',
|
37 |
'next_text' => '<i class="fas fa-angle-right"></i>',
|
38 |
'type' => 'list',
|
templates/single-course/content-item/popup-header.php
CHANGED
@@ -38,5 +38,6 @@ $percentage = $course_results['count_items'] ? absint( $course_results['comp
|
|
38 |
</div>
|
39 |
</div>
|
40 |
<?php endif; ?>
|
41 |
-
|
42 |
-
|
|
38 |
</div>
|
39 |
</div>
|
40 |
<?php endif; ?>
|
41 |
+
</div>
|
42 |
+
<a href="<?php echo $course->get_permalink(); ?>" class="back-course"><i class="fa fa-times"></i></a>
|
43 |
+
</div>
|