| @@ -1,17 +1,20 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 1 | +/******/ (() => { // webpackBootstrap | |
| 2 | 2 | /******/ var __webpack_modules__ = ({ |
| 3 | 3 | |
| 4 | -/***/ "./assets/src/apps/js/frontend/quiz/components/attempts/index.js": | |
| 4 | +/***/ "./assets/src/apps/js/frontend/quiz/components/attempts/index.js" | |
| 5 | 5 | /*!***********************************************************************!*\ |
| 6 | 6 | !*** ./assets/src/apps/js/frontend/quiz/components/attempts/index.js ***! |
| 7 | 7 | \***********************************************************************/ |
| 8 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 8 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 9 | 9 | |
| 10 | 10 | "use strict"; |
| 11 | 11 | __webpack_require__.r(__webpack_exports__); |
| 12 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 13 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 12 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 13 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 14 | +/* harmony export */ }); | |
| 15 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 16 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 14 | 17 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 15 | 18 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); |
| 16 | 19 | /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); |
| 17 | 20 | /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); |
| @@ -19,32 +22,31 @@ | ||
| 19 | 22 | |
| 20 | 23 | |
| 21 | 24 | |
| 22 | 25 | |
| 26 | + | |
| 23 | 27 | /** |
| 24 | 28 | * Displays list of all attempt from a quiz. |
| 25 | 29 | */ |
| 26 | - | |
| 27 | 30 | const Attempts = () => { |
| 28 | 31 | const attempts = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz').getData('attempts') || []; |
| 29 | 32 | const hasAttempts = attempts && !!attempts.length; |
| 30 | - return !hasAttempts ? false : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 33 | + return !hasAttempts ? false : (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 31 | 34 | className: "quiz-attempts" |
| 32 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h4", { | |
| 35 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h4", { | |
| 33 | 36 | className: "attempts-heading" |
| 34 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Last Attempted', 'learnpress')), hasAttempts && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("table", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("thead", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("tr", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 37 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Last Attempt', 'learnpress')), hasAttempts && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("table", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("thead", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("tr", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 35 | 38 | className: "quiz-attempts__questions" |
| 36 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Questions', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 39 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Questions', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 37 | 40 | className: "quiz-attempts__spend" |
| 38 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Time spent', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 41 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Time spent', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 39 | 42 | className: "quiz-attempts__marks" |
| 40 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Marks', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 43 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Marks', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 41 | 44 | className: "quiz-attempts__grade" |
| 42 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Passing grade', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 45 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Passing grade', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("th", { | |
| 43 | 46 | className: "quiz-attempts__result" |
| 44 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Result', 'learnpress')))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("tbody", null, attempts.map((row, key) => { | |
| 47 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Result', 'learnpress')))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("tbody", null, attempts.map((row, key) => { | |
| 45 | 48 | // Re-write value to attempts.timeSpend |
| 46 | - | |
| 47 | 49 | /*if ( lpQuizSettings.checkNorequizenroll === 1 ) { |
| 48 | 50 | const timespendStart = window.localStorage.getItem( 'quiz_start_' + lpQuizSettings.id ), |
| 49 | 51 | timespendEnd = window.localStorage.getItem( 'quiz_end_' + lpQuizSettings.id ); |
| 50 | 52 | if ( timespendStart && timespendEnd ) { |
| @@ -50,28 +52,28 @@ | ||
| 50 | 52 | if ( timespendStart && timespendEnd ) { |
| 51 | 53 | row.timeSpend = timeDifference( timespendStart, timespendEnd ).duration; |
| 52 | 54 | } |
| 53 | 55 | }*/ |
| 54 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("tr", { | |
| 56 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("tr", { | |
| 55 | 57 | key: `attempt-${key}` |
| 56 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 58 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 57 | 59 | className: "quiz-attempts__questions" |
| 58 | - }, `${row.questionCorrect} / ${row.questionCount}`), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 60 | + }, `${row.questionCorrect} / ${row.questionCount}`), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 59 | 61 | className: "quiz-attempts__spend" |
| 60 | - }, row.timeSpend || '--'), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 62 | + }, row.timeSpend || '--'), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 61 | 63 | className: "quiz-attempts__marks" |
| 62 | - }, `${row.userMark} / ${row.mark}`), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 64 | + }, `${row.userMark} / ${row.mark}`), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 63 | 65 | className: "quiz-attempts__grade" |
| 64 | - }, row.passingGrade || '-'), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 66 | + }, row.passingGrade || '-'), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("td", { | |
| 65 | 67 | className: "quiz-attempts__result" |
| 66 | - }, `${parseFloat(row.result).toFixed(2)}%`, " ", (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, row.graduationText))); | |
| 68 | + }, `${parseFloat(row.result).toFixed(2)}%`, " ", (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, row.graduationText))); | |
| 67 | 69 | }))))); |
| 68 | 70 | }; |
| 71 | +function timeDifference(earlierDate, laterDate) { | |
| 72 | + const oDiff = new Object(); | |
| 69 | 73 | |
| 70 | -function timeDifference(earlierDate, laterDate) { | |
| 71 | - const oDiff = new Object(); // Calculate Differences | |
| 74 | + // Calculate Differences | |
| 72 | 75 | // ------------------------------------------------------------------- // |
| 73 | - | |
| 74 | 76 | let nTotalDiff = laterDate - earlierDate; |
| 75 | 77 | oDiff.days = Math.floor(nTotalDiff / 1000 / 60 / 60 / 24); |
| 76 | 78 | nTotalDiff -= oDiff.days * 1000 * 60 * 60 * 24; |
| 77 | 79 | oDiff.hours = Math.floor(nTotalDiff / 1000 / 60 / 60); |
| @@ -77,69 +79,67 @@ | ||
| 77 | 79 | oDiff.hours = Math.floor(nTotalDiff / 1000 / 60 / 60); |
| 78 | 80 | nTotalDiff -= oDiff.hours * 1000 * 60 * 60; |
| 79 | 81 | oDiff.minutes = Math.floor(nTotalDiff / 1000 / 60); |
| 80 | 82 | nTotalDiff -= oDiff.minutes * 1000 * 60; |
| 81 | - oDiff.seconds = Math.floor(nTotalDiff / 1000); // ------------------------------------------------------------------- // | |
| 83 | + oDiff.seconds = Math.floor(nTotalDiff / 1000); | |
| 84 | + // ------------------------------------------------------------------- // | |
| 85 | + | |
| 82 | 86 | // Format Duration |
| 83 | 87 | // ------------------------------------------------------------------- // |
| 84 | 88 | // Format Hours |
| 85 | - | |
| 86 | 89 | let hourtext = '00'; |
| 87 | - | |
| 88 | 90 | if (oDiff.days > 0) { |
| 89 | 91 | hourtext = String(oDiff.days); |
| 90 | 92 | } |
| 91 | - | |
| 92 | 93 | if (hourtext.length == 1) { |
| 93 | 94 | hourtext = '0' + hourtext; |
| 94 | - } // Format Minutes | |
| 95 | + } | |
| 95 | 96 | |
| 96 | - | |
| 97 | + // Format Minutes | |
| 97 | 98 | let mintext = '00'; |
| 98 | - | |
| 99 | 99 | if (oDiff.minutes > 0) { |
| 100 | 100 | mintext = String(oDiff.minutes); |
| 101 | 101 | } |
| 102 | - | |
| 103 | 102 | if (mintext.length == 1) { |
| 104 | 103 | mintext = '0' + mintext; |
| 105 | - } // Format Seconds | |
| 104 | + } | |
| 106 | 105 | |
| 107 | - | |
| 106 | + // Format Seconds | |
| 108 | 107 | let sectext = '00'; |
| 109 | - | |
| 110 | 108 | if (oDiff.seconds > 0) { |
| 111 | 109 | sectext = String(oDiff.seconds); |
| 112 | 110 | } |
| 113 | - | |
| 114 | 111 | if (sectext.length == 1) { |
| 115 | 112 | sectext = '0' + sectext; |
| 116 | - } // Set Duration | |
| 117 | - | |
| 118 | - | |
| 113 | + } | |
| 114 | + // Set Duration | |
| 119 | 115 | const sDuration = hourtext + ':' + mintext + ':' + sectext; |
| 120 | - oDiff.duration = sDuration; // ------------------------------------------------------------------- // | |
| 116 | + oDiff.duration = sDuration; | |
| 117 | + // ------------------------------------------------------------------- // | |
| 121 | 118 | |
| 122 | 119 | return oDiff; |
| 123 | 120 | } |
| 121 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Attempts); | |
| 124 | 122 | |
| 125 | -/* harmony default export */ __webpack_exports__["default"] = (Attempts); | |
| 123 | +/***/ }, | |
| 126 | 124 | |
| 127 | -/***/ }), | |
| 128 | - | |
| 129 | -/***/ "./assets/src/apps/js/frontend/quiz/components/buttons/button-check.js": | |
| 125 | +/***/ "./assets/src/apps/js/frontend/quiz/components/buttons/button-check.js" | |
| 130 | 126 | /*!*****************************************************************************!*\ |
| 131 | 127 | !*** ./assets/src/apps/js/frontend/quiz/components/buttons/button-check.js ***! |
| 132 | 128 | \*****************************************************************************/ |
| 133 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 129 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 134 | 130 | |
| 135 | 131 | "use strict"; |
| 136 | 132 | __webpack_require__.r(__webpack_exports__); |
| 137 | -/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); | |
| 138 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 139 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); | |
| 140 | -/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js"); | |
| 141 | -/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_2__); | |
| 133 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 134 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 135 | +/* harmony export */ }); | |
| 136 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 137 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 138 | +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! classnames */ "./node_modules/classnames/index.js"); | |
| 139 | +/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_1__); | |
| 140 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 141 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); | |
| 142 | 142 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 143 | 143 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__); |
| 144 | 144 | /* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); |
| 145 | 145 | /* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_4__); |
| @@ -150,62 +150,67 @@ | ||
| 150 | 150 | |
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | |
| 154 | - | |
| 155 | - | |
| 156 | -class ButtonCheck extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { | |
| 154 | +class ButtonCheck extends _wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Component { | |
| 157 | 155 | constructor() { |
| 158 | 156 | super(...arguments); |
| 159 | - | |
| 160 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "checkAnswer", () => { | |
| 161 | - const { | |
| 162 | - checkAnswer, | |
| 163 | - question, | |
| 164 | - answered | |
| 165 | - } = this.props; | |
| 166 | - | |
| 167 | - if (answered) { | |
| 168 | - checkAnswer(question.id); | |
| 169 | - this.setState({ | |
| 170 | - loading: true | |
| 171 | - }); | |
| 172 | - } | |
| 173 | - }); | |
| 174 | - | |
| 175 | 157 | this.state = { |
| 176 | 158 | loading: false |
| 177 | 159 | }; |
| 178 | 160 | } |
| 161 | + checkAnswer = () => { | |
| 162 | + const { | |
| 163 | + checkAnswer, | |
| 164 | + question, | |
| 165 | + answered | |
| 166 | + } = this.props; | |
| 179 | 167 | |
| 168 | + // Fix temporary for FIB. | |
| 169 | + if (question.type === 'fill_in_blanks') { | |
| 170 | + const elFIB = document.querySelector(`.question-fill_in_blanks[data-id="${question.id}"]`); | |
| 171 | + const elInputs = elFIB.querySelectorAll('.lp-fib-input > input'); | |
| 172 | + elInputs.forEach(elInput => { | |
| 173 | + if (elInput.value.length > 0) { | |
| 174 | + this.setState({ | |
| 175 | + loading: true | |
| 176 | + }); | |
| 177 | + checkAnswer(question.id); | |
| 178 | + return false; | |
| 179 | + } | |
| 180 | + }); | |
| 181 | + } | |
| 182 | + if (answered) { | |
| 183 | + checkAnswer(question.id); | |
| 184 | + this.setState({ | |
| 185 | + loading: true | |
| 186 | + }); | |
| 187 | + } | |
| 188 | + }; | |
| 180 | 189 | render() { |
| 181 | 190 | const { |
| 182 | 191 | answered |
| 183 | 192 | } = this.props; |
| 184 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 185 | - className: classnames__WEBPACK_IMPORTED_MODULE_2___default()('lp-button', 'instant-check', { | |
| 186 | - loading: this.state.loading, | |
| 187 | - disable: !answered | |
| 193 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 194 | + className: classnames__WEBPACK_IMPORTED_MODULE_1___default()('lp-button', 'instant-check', { | |
| 195 | + loading: this.state.loading | |
| 188 | 196 | }), |
| 189 | 197 | onClick: this.checkAnswer |
| 190 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("span", { | |
| 198 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 191 | 199 | className: "instant-check__icon" |
| 192 | - }), (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Check answer', 'learnpress'), !answered && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 200 | + }), (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Check answers', 'learnpress'), !answered && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 193 | 201 | className: "instant-check__info", |
| 194 | 202 | dangerouslySetInnerHTML: { |
| 195 | - __html: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('You need to answer the question before check answer.', 'learnpress') | |
| 203 | + __html: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('You need to answer the question before checking the answer key.', 'learnpress') | |
| 196 | 204 | } |
| 197 | 205 | }))); |
| 198 | 206 | } |
| 199 | - | |
| 200 | 207 | } |
| 201 | - | |
| 202 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_4__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withSelect)((select, _ref) => { | |
| 203 | - let { | |
| 204 | - question: { | |
| 205 | - id | |
| 206 | - } | |
| 207 | - } = _ref; | |
| 208 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_4__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withSelect)((select, { | |
| 209 | + question: { | |
| 210 | + id | |
| 211 | + } | |
| 212 | +}) => { | |
| 208 | 213 | const { |
| 209 | 214 | getQuestionAnswered |
| 210 | 215 | } = select('learnpress/quiz'); |
| 211 | 216 | return { |
| @@ -210,12 +215,11 @@ | ||
| 210 | 215 | } = select('learnpress/quiz'); |
| 211 | 216 | return { |
| 212 | 217 | answered: getQuestionAnswered(id) |
| 213 | 218 | }; |
| 214 | -}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withDispatch)((dispatch, _ref2) => { | |
| 215 | - let { | |
| 216 | - id | |
| 217 | - } = _ref2; | |
| 219 | +}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withDispatch)((dispatch, { | |
| 220 | + id | |
| 221 | +}) => { | |
| 218 | 222 | const { |
| 219 | 223 | checkAnswer |
| 220 | 224 | } = dispatch('learnpress/quiz'); |
| 221 | 225 | return { |
| @@ -221,23 +225,26 @@ | ||
| 221 | 225 | return { |
| 222 | 226 | checkAnswer(id) { |
| 223 | 227 | checkAnswer(id); |
| 224 | 228 | } |
| 225 | - | |
| 226 | 229 | }; |
| 227 | 230 | }))(ButtonCheck)); |
| 228 | 231 | |
| 229 | -/***/ }), | |
| 232 | +/***/ }, | |
| 230 | 233 | |
| 231 | -/***/ "./assets/src/apps/js/frontend/quiz/components/buttons/button-hint.js": | |
| 234 | +/***/ "./assets/src/apps/js/frontend/quiz/components/buttons/button-hint.js" | |
| 232 | 235 | /*!****************************************************************************!*\ |
| 233 | 236 | !*** ./assets/src/apps/js/frontend/quiz/components/buttons/button-hint.js ***! |
| 234 | 237 | \****************************************************************************/ |
| 235 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 238 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 236 | 239 | |
| 237 | 240 | "use strict"; |
| 238 | 241 | __webpack_require__.r(__webpack_exports__); |
| 239 | -/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); | |
| 242 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 243 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 244 | +/* harmony export */ }); | |
| 245 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 246 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 240 | 247 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); |
| 241 | 248 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); |
| 242 | 249 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 243 | 250 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); |
| @@ -249,39 +256,32 @@ | ||
| 249 | 256 | |
| 250 | 257 | |
| 251 | 258 | |
| 252 | 259 | |
| 253 | - | |
| 254 | - | |
| 255 | 260 | class ButtonHint extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { |
| 256 | - constructor() { | |
| 257 | - super(...arguments); | |
| 258 | - | |
| 259 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "showHint", () => { | |
| 260 | - const { | |
| 261 | - showHint, | |
| 262 | - question | |
| 263 | - } = this.props; | |
| 264 | - showHint(question.id, !question.showHint); | |
| 265 | - }); | |
| 266 | - } | |
| 267 | - | |
| 261 | + /** | |
| 262 | + * Callback to show hint of question | |
| 263 | + */ | |
| 264 | + showHint = () => { | |
| 265 | + const { | |
| 266 | + showHint, | |
| 267 | + question | |
| 268 | + } = this.props; | |
| 269 | + showHint(question.id, !question.showHint); | |
| 270 | + }; | |
| 268 | 271 | render() { |
| 269 | 272 | const { |
| 270 | 273 | question |
| 271 | 274 | } = this.props; |
| 272 | - return question.hint ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 275 | + return question.hint ? (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 273 | 276 | className: "btn-show-hint", |
| 274 | 277 | onClick: this.showHint |
| 275 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Hint', 'learnpress'))) : ''; | |
| 278 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Hint', 'learnpress'))) : ''; | |
| 276 | 279 | } |
| 277 | - | |
| 278 | 280 | } |
| 279 | - | |
| 280 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withDispatch)((dispatch, _ref) => { | |
| 281 | - let { | |
| 282 | - id | |
| 283 | - } = _ref; | |
| 281 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withDispatch)((dispatch, { | |
| 282 | + id | |
| 283 | +}) => { | |
| 284 | 284 | const { |
| 285 | 285 | showHint |
| 286 | 286 | } = dispatch('learnpress/quiz'); |
| 287 | 287 | return { |
| @@ -287,26 +287,27 @@ | ||
| 287 | 287 | return { |
| 288 | 288 | showHint(id, show) { |
| 289 | 289 | showHint(id, show); |
| 290 | 290 | } |
| 291 | - | |
| 292 | 291 | }; |
| 293 | 292 | }))(ButtonHint)); |
| 294 | 293 | |
| 295 | -/***/ }), | |
| 294 | +/***/ }, | |
| 296 | 295 | |
| 297 | -/***/ "./assets/src/apps/js/frontend/quiz/components/buttons/index.js": | |
| 296 | +/***/ "./assets/src/apps/js/frontend/quiz/components/buttons/index.js" | |
| 298 | 297 | /*!**********************************************************************!*\ |
| 299 | 298 | !*** ./assets/src/apps/js/frontend/quiz/components/buttons/index.js ***! |
| 300 | 299 | \**********************************************************************/ |
| 301 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 300 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 302 | 301 | |
| 303 | 302 | "use strict"; |
| 304 | 303 | __webpack_require__.r(__webpack_exports__); |
| 305 | 304 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 306 | -/* harmony export */ "MaybeShowButton": function() { return /* binding */ MaybeShowButton; } | |
| 305 | +/* harmony export */ MaybeShowButton: () => (/* binding */ MaybeShowButton), | |
| 306 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 307 | 307 | /* harmony export */ }); |
| 308 | -/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); | |
| 308 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 309 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 309 | 310 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); |
| 310 | 311 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); |
| 311 | 312 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 312 | 313 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); |
| @@ -318,157 +319,131 @@ | ||
| 318 | 319 | |
| 319 | 320 | |
| 320 | 321 | |
| 321 | 322 | |
| 322 | - | |
| 323 | - | |
| 324 | 323 | class Buttons extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { |
| 325 | - constructor() { | |
| 326 | - super(...arguments); | |
| 327 | - | |
| 328 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "startQuiz", event => { | |
| 329 | - event && event.preventDefault(); | |
| 330 | - const btn = document.querySelector('.lp-button.start'); | |
| 331 | - btn && btn.setAttribute('disabled', 'disabled'); | |
| 332 | - btn.classList.add('loading'); | |
| 324 | + startQuiz = event => { | |
| 325 | + event && event.preventDefault(); | |
| 326 | + const btn = document.querySelector('.lp-button.start'); | |
| 327 | + btn && btn.setAttribute('disabled', 'disabled'); | |
| 328 | + btn.classList.add('loading'); | |
| 329 | + const { | |
| 330 | + startQuiz, | |
| 331 | + status | |
| 332 | + } = this.props; | |
| 333 | + if (status === 'completed') { | |
| 333 | 334 | const { |
| 334 | - startQuiz, | |
| 335 | - status | |
| 336 | - } = this.props; | |
| 337 | - | |
| 338 | - if (status === 'completed') { | |
| 339 | - const { | |
| 340 | - confirm, | |
| 341 | - isOpen | |
| 342 | - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/modal'); | |
| 343 | - | |
| 344 | - if ('no' === confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Are you sure you want to retake quiz?', 'learnpress'), this.startQuiz)) { | |
| 345 | - !isOpen() && btn && btn.removeAttribute('disabled'); | |
| 346 | - return; | |
| 347 | - } | |
| 348 | - } // No require enroll | |
| 349 | - | |
| 350 | - /*if ( lpQuizSettings.checkNorequizenroll === 1 ) { | |
| 351 | - // Reset data | |
| 352 | - window.localStorage.removeItem( 'quiz_start_' + lpQuizSettings.id ); | |
| 353 | - window.localStorage.removeItem( 'quiz_userdata_' + lpQuizSettings.id ); | |
| 354 | - window.localStorage.setItem( 'quiz_start_' + lpQuizSettings.id, Date.now() ); | |
| 355 | - // Set retake to local.storage | |
| 356 | - const retakenNumber = window.localStorage.getItem( 'quiz_retake_' + lpQuizSettings.id ); | |
| 357 | - if ( retakenNumber >= 1 ) { | |
| 358 | - window.localStorage.setItem( 'quiz_retake_' + lpQuizSettings.id, parseInt( retakenNumber ) + 1 ); | |
| 359 | - } else { | |
| 360 | - window.localStorage.setItem( 'quiz_retake_' + lpQuizSettings.id, 1 ); | |
| 361 | - } | |
| 362 | - }*/ | |
| 363 | - | |
| 364 | - | |
| 365 | - startQuiz(); | |
| 366 | - }); | |
| 367 | - | |
| 368 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "nav", to => event => { | |
| 369 | - let { | |
| 370 | - questionNav, | |
| 371 | - currentPage, | |
| 372 | - numPages, | |
| 373 | - setCurrentPage | |
| 374 | - } = this.props; | |
| 375 | - | |
| 376 | - switch (to) { | |
| 377 | - case 'prev': | |
| 378 | - if (currentPage > 1) { | |
| 379 | - currentPage = currentPage - 1; | |
| 380 | - } else if (questionNav === 'infinity') { | |
| 381 | - currentPage = numPages; | |
| 382 | - } else { | |
| 383 | - currentPage = 1; | |
| 384 | - } | |
| 385 | - | |
| 386 | - break; | |
| 387 | - | |
| 388 | - default: | |
| 389 | - if (currentPage < numPages) { | |
| 390 | - currentPage = currentPage + 1; | |
| 391 | - } else if (questionNav === 'infinity') { | |
| 392 | - currentPage = 1; | |
| 393 | - } else { | |
| 394 | - currentPage = numPages; | |
| 395 | - } | |
| 396 | - | |
| 397 | - } | |
| 398 | - | |
| 399 | - setCurrentPage(currentPage); | |
| 400 | - }); | |
| 401 | - | |
| 402 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "moveTo", pageNum => event => { | |
| 403 | - event.preventDefault(); | |
| 404 | - const { | |
| 405 | - numPages, | |
| 406 | - setCurrentPage | |
| 407 | - } = this.props; | |
| 408 | - | |
| 409 | - if (pageNum < 1 || pageNum > numPages) { | |
| 410 | - return; | |
| 411 | - } | |
| 412 | - | |
| 413 | - setCurrentPage(pageNum); | |
| 414 | - }); | |
| 415 | - | |
| 416 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "isLast", () => { | |
| 417 | - const { | |
| 418 | - currentPage, | |
| 419 | - numPages | |
| 420 | - } = this.props; | |
| 421 | - return currentPage === numPages; | |
| 422 | - }); | |
| 423 | - | |
| 424 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "isFirst", () => { | |
| 425 | - const { | |
| 426 | - currentPage | |
| 427 | - } = this.props; | |
| 428 | - return currentPage === 1; | |
| 429 | - }); | |
| 430 | - | |
| 431 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "submit", () => { | |
| 432 | - const { | |
| 433 | - submitQuiz | |
| 434 | - } = this.props; | |
| 435 | - const { | |
| 436 | - confirm | |
| 335 | + confirm, | |
| 336 | + isOpen | |
| 437 | 337 | } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/modal'); |
| 438 | - | |
| 439 | - if ('no' === confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Are you sure to submit quiz?', 'learnpress'), this.submit)) { | |
| 338 | + if ('no' === confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Are you sure you want to retake the quiz?', 'learnpress'), this.startQuiz)) { | |
| 339 | + !isOpen() && btn && btn.removeAttribute('disabled'); | |
| 340 | + btn.classList.remove('loading'); | |
| 440 | 341 | return; |
| 441 | 342 | } |
| 343 | + } | |
| 442 | 344 | |
| 443 | - submitQuiz(); | |
| 444 | - }); | |
| 345 | + // No require enroll | |
| 346 | + /*if ( lpQuizSettings.checkNorequizenroll === 1 ) { | |
| 347 | + // Reset data | |
| 348 | + window.localStorage.removeItem( 'quiz_start_' + lpQuizSettings.id ); | |
| 349 | + window.localStorage.removeItem( 'quiz_userdata_' + lpQuizSettings.id ); | |
| 350 | + window.localStorage.setItem( 'quiz_start_' + lpQuizSettings.id, Date.now() ); | |
| 351 | + // Set retake to local.storage | |
| 352 | + const retakenNumber = window.localStorage.getItem( 'quiz_retake_' + lpQuizSettings.id ); | |
| 353 | + if ( retakenNumber >= 1 ) { | |
| 354 | + window.localStorage.setItem( 'quiz_retake_' + lpQuizSettings.id, parseInt( retakenNumber ) + 1 ); | |
| 355 | + } else { | |
| 356 | + window.localStorage.setItem( 'quiz_retake_' + lpQuizSettings.id, 1 ); | |
| 357 | + } | |
| 358 | + }*/ | |
| 445 | 359 | |
| 446 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "setQuizMode", mode => () => { | |
| 447 | - const { | |
| 448 | - setQuizMode | |
| 449 | - } = this.props; | |
| 450 | - setQuizMode(mode); | |
| 451 | - }); | |
| 452 | - | |
| 453 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "isReviewing", () => { | |
| 454 | - const { | |
| 455 | - isReviewing | |
| 456 | - } = this.props; | |
| 457 | - return isReviewing; | |
| 458 | - }); | |
| 459 | - } | |
| 460 | - | |
| 360 | + startQuiz(); | |
| 361 | + }; | |
| 362 | + nav = to => event => { | |
| 363 | + let { | |
| 364 | + questionNav, | |
| 365 | + currentPage, | |
| 366 | + numPages, | |
| 367 | + setCurrentPage | |
| 368 | + } = this.props; | |
| 369 | + switch (to) { | |
| 370 | + case 'prev': | |
| 371 | + if (currentPage > 1) { | |
| 372 | + currentPage = currentPage - 1; | |
| 373 | + } else if (questionNav === 'infinity') { | |
| 374 | + currentPage = numPages; | |
| 375 | + } else { | |
| 376 | + currentPage = 1; | |
| 377 | + } | |
| 378 | + break; | |
| 379 | + default: | |
| 380 | + if (currentPage < numPages) { | |
| 381 | + currentPage = currentPage + 1; | |
| 382 | + } else if (questionNav === 'infinity') { | |
| 383 | + currentPage = 1; | |
| 384 | + } else { | |
| 385 | + currentPage = numPages; | |
| 386 | + } | |
| 387 | + } | |
| 388 | + setCurrentPage(currentPage); | |
| 389 | + }; | |
| 390 | + moveTo = pageNum => event => { | |
| 391 | + event.preventDefault(); | |
| 392 | + const { | |
| 393 | + numPages, | |
| 394 | + setCurrentPage | |
| 395 | + } = this.props; | |
| 396 | + if (pageNum < 1 || pageNum > numPages) { | |
| 397 | + return; | |
| 398 | + } | |
| 399 | + setCurrentPage(pageNum); | |
| 400 | + }; | |
| 401 | + isLast = () => { | |
| 402 | + const { | |
| 403 | + currentPage, | |
| 404 | + numPages | |
| 405 | + } = this.props; | |
| 406 | + return currentPage === numPages; | |
| 407 | + }; | |
| 408 | + isFirst = () => { | |
| 409 | + const { | |
| 410 | + currentPage | |
| 411 | + } = this.props; | |
| 412 | + return currentPage === 1; | |
| 413 | + }; | |
| 414 | + submit = () => { | |
| 415 | + const { | |
| 416 | + submitQuiz | |
| 417 | + } = this.props; | |
| 418 | + const { | |
| 419 | + confirm | |
| 420 | + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/modal'); | |
| 421 | + if ('no' === confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Are you sure to submit the quiz?', 'learnpress'), this.submit)) { | |
| 422 | + return; | |
| 423 | + } | |
| 424 | + submitQuiz(); | |
| 425 | + }; | |
| 426 | + setQuizMode = mode => () => { | |
| 427 | + const { | |
| 428 | + setQuizMode | |
| 429 | + } = this.props; | |
| 430 | + setQuizMode(mode); | |
| 431 | + }; | |
| 432 | + isReviewing = () => { | |
| 433 | + const { | |
| 434 | + isReviewing | |
| 435 | + } = this.props; | |
| 436 | + return isReviewing; | |
| 437 | + }; | |
| 461 | 438 | pageNumbers(args) { |
| 462 | 439 | const { |
| 463 | 440 | numPages, |
| 464 | 441 | currentPage |
| 465 | 442 | } = this.props; |
| 466 | - | |
| 467 | 443 | if (numPages < 2) { |
| 468 | 444 | return ''; |
| 469 | 445 | } |
| 470 | - | |
| 471 | 446 | args = { |
| 472 | 447 | numPages, |
| 473 | 448 | currentPage, |
| 474 | 449 | midSize: 1, |
| @@ -475,39 +450,34 @@ | ||
| 475 | 450 | endSize: 1, |
| 476 | 451 | prevNext: true, |
| 477 | 452 | ...(args || {}) |
| 478 | 453 | }; |
| 479 | - | |
| 480 | 454 | if (args.endSize < 1) { |
| 481 | 455 | args.endSize = 1; |
| 482 | 456 | } |
| 483 | - | |
| 484 | 457 | if (args.midSize < 0) { |
| 485 | 458 | args.midSize = 1; |
| 486 | 459 | } |
| 487 | - | |
| 488 | 460 | const numbers = [...Array(numPages).keys()]; |
| 489 | 461 | let dots = false; |
| 490 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 462 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 491 | 463 | className: "nav-links" |
| 492 | - }, args.prevNext && !this.isFirst() && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 464 | + }, args.prevNext && !this.isFirst() && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 493 | 465 | className: "page-numbers prev", |
| 494 | 466 | "data-type": "question-navx", |
| 495 | 467 | onClick: this.nav('prev') |
| 496 | 468 | }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Prev', 'learnpress')), numbers.map(number => { |
| 497 | 469 | number = number + 1; |
| 498 | - | |
| 499 | 470 | if (number === args.currentPage) { |
| 500 | 471 | dots = true; |
| 501 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("span", { | |
| 472 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 502 | 473 | key: `page-number-${number}`, |
| 503 | 474 | className: "page-numbers current" |
| 504 | 475 | }, number); |
| 505 | 476 | } |
| 506 | - | |
| 507 | 477 | if (number <= args.endSize || args.currentPage && number >= args.currentPage - args.midSize && number <= args.currentPage + args.midSize || number > args.numPages - args.endSize) { |
| 508 | 478 | dots = true; |
| 509 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 479 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 510 | 480 | key: `page-number-${number}`, |
| 511 | 481 | className: "page-numbers", |
| 512 | 482 | onClick: this.moveTo(number) |
| 513 | 483 | }, number); |
| @@ -512,22 +482,20 @@ | ||
| 512 | 482 | onClick: this.moveTo(number) |
| 513 | 483 | }, number); |
| 514 | 484 | } else if (dots) { |
| 515 | 485 | dots = false; |
| 516 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("span", { | |
| 486 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 517 | 487 | key: `page-number-${number}`, |
| 518 | 488 | className: "page-numbers dots" |
| 519 | 489 | }, "\u2026"); |
| 520 | 490 | } |
| 521 | - | |
| 522 | 491 | return ''; |
| 523 | - }), args.prevNext && !this.isLast() && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 492 | + }), args.prevNext && !this.isLast() && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 524 | 493 | className: "page-numbers next", |
| 525 | 494 | "data-type": "question-navx", |
| 526 | 495 | onClick: this.nav('next') |
| 527 | 496 | }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Next', 'learnpress'))); |
| 528 | 497 | } |
| 529 | - | |
| 530 | 498 | render() { |
| 531 | 499 | const { |
| 532 | 500 | status, |
| 533 | 501 | questionNav, |
| @@ -541,29 +509,23 @@ | ||
| 541 | 509 | requiredPassword, |
| 542 | 510 | allowRetake |
| 543 | 511 | } = this.props; |
| 544 | 512 | const classNames = ['quiz-buttons']; |
| 545 | - | |
| 546 | 513 | if (status === 'started' || isReviewing) { |
| 547 | 514 | classNames.push('align-center'); |
| 548 | 515 | } |
| 549 | - | |
| 550 | 516 | if (questionNav === 'questionNav') { |
| 551 | 517 | classNames.push('infinity'); |
| 552 | 518 | } |
| 553 | - | |
| 554 | 519 | if (this.isFirst()) { |
| 555 | 520 | classNames.push('is-first'); |
| 556 | 521 | } |
| 557 | - | |
| 558 | 522 | if (this.isLast()) { |
| 559 | 523 | classNames.push('is-last'); |
| 560 | 524 | } |
| 561 | - | |
| 562 | 525 | const popupSidebar = document.querySelector('#popup-sidebar'); |
| 563 | 526 | const quizzApp = document.querySelector('#learn-press-quiz-app'); |
| 564 | 527 | let styles = ''; |
| 565 | - | |
| 566 | 528 | if (status === 'started' || isReviewing) { |
| 567 | 529 | styles = { |
| 568 | 530 | marginLeft: popupSidebar && popupSidebar.offsetWidth / 2, |
| 569 | 531 | width: quizzApp && quizzApp.offsetWidth |
| @@ -570,49 +532,44 @@ | ||
| 570 | 532 | }; |
| 571 | 533 | } else { |
| 572 | 534 | styles = null; |
| 573 | 535 | } |
| 574 | - | |
| 575 | 536 | let navPositionClass = ' fixed'; |
| 576 | - | |
| 577 | 537 | if (lpQuizSettings.navigationPosition == 'no') { |
| 578 | 538 | navPositionClass = ' nav-center'; |
| 579 | 539 | } |
| 580 | - | |
| 581 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 540 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 582 | 541 | className: classNames.join(' ') |
| 583 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 542 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 584 | 543 | className: `button-left` + (status === 'started' || isReviewing ? navPositionClass : ''), |
| 585 | 544 | style: styles |
| 586 | - }, (status === 'completed' && canRetry || -1 !== ['', 'viewed'].indexOf(status)) && !isReviewing && !requiredPassword && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 545 | + }, (status === 'completed' && canRetry || -1 !== ['', 'viewed'].indexOf(status)) && !isReviewing && !requiredPassword && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 587 | 546 | className: "lp-button start", |
| 588 | 547 | onClick: this.startQuiz |
| 589 | - }, status === 'completed' ? `${(0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Retake', 'learnpress')} ${!allowRetake ? ` ${retakeNumber ? ` (${retakeNumber})` : ''}` : ''} ` : ' ' + (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Start', 'learnpress')), ('started' === status || isReviewing) && numPages > 1 && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 548 | + }, status === 'completed' ? `${(0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Retake', 'learnpress')} ${!allowRetake ? ` ${retakeNumber ? ` (${retakeNumber})` : ''}` : ''} ` : ' ' + (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Start', 'learnpress')), ('started' === status || isReviewing) && numPages > 1 && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 590 | 549 | className: "questions-pagination" |
| 591 | - }, this.pageNumbers()))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 550 | + }, this.pageNumbers()))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 592 | 551 | className: "button-right" |
| 593 | - }, 'started' === status && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, ('infinity' === questionNav || this.isLast()) && !isReviewing && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 552 | + }, 'started' === status && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, ('infinity' === questionNav || this.isLast()) && !isReviewing && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 594 | 553 | className: "lp-button submit-quiz", |
| 595 | 554 | onClick: this.submit |
| 596 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Finish Quiz', 'learnpress'))), isReviewing && showReview && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 555 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Finish Quiz', 'learnpress'))), isReviewing && showReview && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 597 | 556 | className: "lp-button back-quiz", |
| 598 | 557 | onClick: this.setQuizMode('') |
| 599 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Result', 'learnpress')), 'completed' === status && showReview && !isReviewing && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("button", { | |
| 558 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Result', 'learnpress')), 'completed' === status && showReview && !isReviewing && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 600 | 559 | className: "lp-button review-quiz", |
| 601 | 560 | onClick: this.setQuizMode('reviewing') |
| 602 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Review', 'learnpress')))), this.props.message && this.props.success !== true && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 561 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Review', 'learnpress')))), this.props.message && this.props.success !== true && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 603 | 562 | className: "learn-press-message error" |
| 604 | 563 | }, this.props.message)); |
| 605 | 564 | } |
| 565 | +} | |
| 606 | 566 | |
| 607 | -} | |
| 608 | 567 | /** |
| 609 | 568 | * Helper function to check a button should be show or not. |
| 610 | 569 | * |
| 611 | 570 | * Buttons [hint, check] |
| 612 | 571 | */ |
| 613 | - | |
| 614 | - | |
| 615 | 572 | const MaybeShowButton = (0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withSelect)(select => { |
| 616 | 573 | const { |
| 617 | 574 | getData |
| 618 | 575 | } = select('learnpress/quiz'); |
| @@ -632,42 +589,34 @@ | ||
| 632 | 589 | status, |
| 633 | 590 | type, |
| 634 | 591 | Button |
| 635 | 592 | } = props; |
| 636 | - | |
| 637 | 593 | if (status !== 'started') { |
| 638 | 594 | return false; |
| 639 | 595 | } |
| 640 | - | |
| 641 | - const theButton = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(Button, { | |
| 596 | + const theButton = (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(Button, { | |
| 642 | 597 | question: question |
| 643 | 598 | }); |
| 644 | - | |
| 645 | 599 | switch (type) { |
| 646 | 600 | case 'hint': |
| 647 | 601 | if (!hintedQuestions) { |
| 648 | 602 | return theButton; |
| 649 | 603 | } |
| 650 | - | |
| 651 | 604 | if (!question.hasHint) { |
| 652 | 605 | return false; |
| 653 | 606 | } |
| 654 | - | |
| 655 | 607 | return hintedQuestions.indexOf(question.id) === -1 && theButton; |
| 656 | - | |
| 657 | 608 | case 'check': |
| 658 | 609 | if (!showCheck) { |
| 659 | 610 | return false; |
| 660 | 611 | } |
| 661 | - | |
| 662 | 612 | if (!checkedQuestions) { |
| 663 | 613 | return theButton; |
| 664 | 614 | } |
| 665 | - | |
| 666 | 615 | return checkedQuestions.indexOf(question.id) === -1 && theButton; |
| 667 | 616 | } |
| 668 | 617 | }); |
| 669 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)([(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withSelect)(select => { | |
| 618 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)([(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withSelect)(select => { | |
| 670 | 619 | const { |
| 671 | 620 | getData, |
| 672 | 621 | getCurrentQuestion |
| 673 | 622 | } = select('learnpress/quiz'); |
| @@ -693,16 +642,13 @@ | ||
| 693 | 642 | success: getData('successResponse') !== undefined ? getData('successResponse') : true, |
| 694 | 643 | requiredPassword: getData('requiredPassword'), |
| 695 | 644 | allowRetake: getData('allowRetake') |
| 696 | 645 | }; |
| 697 | - | |
| 698 | 646 | if (data.questionsPerPage === 1) { |
| 699 | 647 | data.question = getCurrentQuestion('object'); |
| 700 | 648 | } |
| 701 | - | |
| 702 | 649 | if (lpQuizSettings.checkNorequizenroll === 1) { |
| 703 | 650 | const retakenCurrent = window.localStorage.getItem('quiz_off_retaken_' + lpQuizSettings.id); |
| 704 | - | |
| 705 | 651 | if (getData('retakeCount') > retakenCurrent) { |
| 706 | 652 | data.retakeNumber = getData('retakeCount') - retakenCurrent; |
| 707 | 653 | data.canRetry = true; |
| 708 | 654 | } else { |
| @@ -708,18 +654,15 @@ | ||
| 708 | 654 | } else { |
| 709 | 655 | data.canRetry = false; |
| 710 | 656 | } |
| 711 | 657 | } |
| 712 | - | |
| 713 | 658 | if (data.allowRetake) { |
| 714 | 659 | data.canRetry = true; |
| 715 | 660 | } |
| 716 | - | |
| 717 | 661 | return data; |
| 718 | -}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withDispatch)((dispatch, _ref) => { | |
| 719 | - let { | |
| 720 | - id | |
| 721 | - } = _ref; | |
| 662 | +}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withDispatch)((dispatch, { | |
| 663 | + id | |
| 664 | +}) => { | |
| 722 | 665 | const { |
| 723 | 666 | startQuiz, |
| 724 | 667 | setCurrentQuestion, |
| 725 | 668 | submitQuiz, |
| @@ -732,51 +675,48 @@ | ||
| 732 | 675 | startQuiz, |
| 733 | 676 | setCurrentQuestion, |
| 734 | 677 | setQuizMode, |
| 735 | 678 | setCurrentPage, |
| 736 | - | |
| 737 | 679 | submitQuiz(id) { |
| 738 | 680 | submitQuiz(id); |
| 739 | 681 | }, |
| 740 | - | |
| 741 | 682 | showHint(id) { |
| 742 | 683 | showHint(id); |
| 743 | 684 | }, |
| 744 | - | |
| 745 | 685 | checkAnswer(id) { |
| 746 | 686 | checkAnswer(id); |
| 747 | 687 | } |
| 748 | - | |
| 749 | 688 | }; |
| 750 | 689 | })])(Buttons)); |
| 751 | 690 | |
| 752 | -/***/ }), | |
| 691 | +/***/ }, | |
| 753 | 692 | |
| 754 | -/***/ "./assets/src/apps/js/frontend/quiz/components/content/index.js": | |
| 693 | +/***/ "./assets/src/apps/js/frontend/quiz/components/content/index.js" | |
| 755 | 694 | /*!**********************************************************************!*\ |
| 756 | 695 | !*** ./assets/src/apps/js/frontend/quiz/components/content/index.js ***! |
| 757 | 696 | \**********************************************************************/ |
| 758 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 697 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 759 | 698 | |
| 760 | 699 | "use strict"; |
| 761 | 700 | __webpack_require__.r(__webpack_exports__); |
| 762 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 763 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 701 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 702 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 703 | +/* harmony export */ }); | |
| 704 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 705 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 764 | 706 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 765 | 707 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); |
| 766 | 708 | |
| 767 | - | |
| 768 | 709 | /** |
| 769 | - * Quizz Content. | |
| 710 | + * Quiz Content. | |
| 770 | 711 | * Edit: Use React hook. |
| 771 | 712 | * |
| 772 | 713 | * @author nhamdv - ThimPress |
| 773 | 714 | */ |
| 774 | 715 | |
| 775 | - | |
| 776 | 716 | const Content = () => { |
| 777 | 717 | const content = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz').getData('content'); |
| 778 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 718 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 779 | 719 | className: "quiz-content", |
| 780 | 720 | dangerouslySetInnerHTML: { |
| 781 | 721 | __html: content |
| 782 | 722 | } |
| @@ -781,25 +721,26 @@ | ||
| 781 | 721 | __html: content |
| 782 | 722 | } |
| 783 | 723 | }); |
| 784 | 724 | }; |
| 725 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Content); | |
| 785 | 726 | |
| 786 | -/* harmony default export */ __webpack_exports__["default"] = (Content); | |
| 727 | +/***/ }, | |
| 787 | 728 | |
| 788 | -/***/ }), | |
| 789 | - | |
| 790 | -/***/ "./assets/src/apps/js/frontend/quiz/components/duration/index.js": | |
| 729 | +/***/ "./assets/src/apps/js/frontend/quiz/components/duration/index.js" | |
| 791 | 730 | /*!***********************************************************************!*\ |
| 792 | 731 | !*** ./assets/src/apps/js/frontend/quiz/components/duration/index.js ***! |
| 793 | 732 | \***********************************************************************/ |
| 794 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 733 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 795 | 734 | |
| 796 | 735 | "use strict"; |
| 797 | 736 | __webpack_require__.r(__webpack_exports__); |
| 737 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 738 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 739 | +/* harmony export */ }); | |
| 798 | 740 | const formatDuration = seconds => { |
| 799 | 741 | let d; |
| 800 | 742 | const dayInSeconds = 3600 * 24; |
| 801 | - | |
| 802 | 743 | if (seconds > dayInSeconds) { |
| 803 | 744 | d = (seconds - seconds % dayInSeconds) / dayInSeconds; |
| 804 | 745 | seconds = seconds % dayInSeconds; |
| 805 | 746 | } else if (seconds == dayInSeconds) { |
| @@ -804,41 +745,37 @@ | ||
| 804 | 745 | seconds = seconds % dayInSeconds; |
| 805 | 746 | } else if (seconds == dayInSeconds) { |
| 806 | 747 | return '24:00'; |
| 807 | 748 | } |
| 808 | - | |
| 809 | 749 | const x = new Date(seconds * 1000).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(':'); |
| 810 | - | |
| 811 | 750 | if (d) { |
| 812 | 751 | x[0] = parseInt(x[0]) + d * 24; |
| 813 | 752 | } |
| 814 | - | |
| 815 | 753 | const html = x.join(':'); |
| 816 | 754 | return html; |
| 817 | 755 | }; |
| 756 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (formatDuration); | |
| 818 | 757 | |
| 819 | -/* harmony default export */ __webpack_exports__["default"] = (formatDuration); | |
| 758 | +/***/ }, | |
| 820 | 759 | |
| 821 | -/***/ }), | |
| 822 | - | |
| 823 | -/***/ "./assets/src/apps/js/frontend/quiz/components/index.js": | |
| 760 | +/***/ "./assets/src/apps/js/frontend/quiz/components/index.js" | |
| 824 | 761 | /*!**************************************************************!*\ |
| 825 | 762 | !*** ./assets/src/apps/js/frontend/quiz/components/index.js ***! |
| 826 | 763 | \**************************************************************/ |
| 827 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 764 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 828 | 765 | |
| 829 | 766 | "use strict"; |
| 830 | 767 | __webpack_require__.r(__webpack_exports__); |
| 831 | 768 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 832 | -/* harmony export */ "Attempts": function() { return /* reexport safe */ _attempts__WEBPACK_IMPORTED_MODULE_5__["default"]; }, | |
| 833 | -/* harmony export */ "Buttons": function() { return /* reexport safe */ _buttons__WEBPACK_IMPORTED_MODULE_3__["default"]; }, | |
| 834 | -/* harmony export */ "Content": function() { return /* reexport safe */ _content__WEBPACK_IMPORTED_MODULE_1__["default"]; }, | |
| 835 | -/* harmony export */ "Meta": function() { return /* reexport safe */ _meta__WEBPACK_IMPORTED_MODULE_2__["default"]; }, | |
| 836 | -/* harmony export */ "Questions": function() { return /* reexport safe */ _questions__WEBPACK_IMPORTED_MODULE_4__["default"]; }, | |
| 837 | -/* harmony export */ "Result": function() { return /* reexport safe */ _result__WEBPACK_IMPORTED_MODULE_7__["default"]; }, | |
| 838 | -/* harmony export */ "Status": function() { return /* reexport safe */ _status__WEBPACK_IMPORTED_MODULE_8__["default"]; }, | |
| 839 | -/* harmony export */ "Timer": function() { return /* reexport safe */ _timer__WEBPACK_IMPORTED_MODULE_6__["default"]; }, | |
| 840 | -/* harmony export */ "Title": function() { return /* reexport safe */ _title__WEBPACK_IMPORTED_MODULE_0__["default"]; } | |
| 769 | +/* harmony export */ Attempts: () => (/* reexport safe */ _attempts__WEBPACK_IMPORTED_MODULE_5__["default"]), | |
| 770 | +/* harmony export */ Buttons: () => (/* reexport safe */ _buttons__WEBPACK_IMPORTED_MODULE_3__["default"]), | |
| 771 | +/* harmony export */ Content: () => (/* reexport safe */ _content__WEBPACK_IMPORTED_MODULE_1__["default"]), | |
| 772 | +/* harmony export */ Meta: () => (/* reexport safe */ _meta__WEBPACK_IMPORTED_MODULE_2__["default"]), | |
| 773 | +/* harmony export */ Questions: () => (/* reexport safe */ _questions__WEBPACK_IMPORTED_MODULE_4__["default"]), | |
| 774 | +/* harmony export */ Result: () => (/* reexport safe */ _result__WEBPACK_IMPORTED_MODULE_7__["default"]), | |
| 775 | +/* harmony export */ Status: () => (/* reexport safe */ _status__WEBPACK_IMPORTED_MODULE_8__["default"]), | |
| 776 | +/* harmony export */ Timer: () => (/* reexport safe */ _timer__WEBPACK_IMPORTED_MODULE_6__["default"]), | |
| 777 | +/* harmony export */ Title: () => (/* reexport safe */ _title__WEBPACK_IMPORTED_MODULE_0__["default"]) | |
| 841 | 778 | /* harmony export */ }); |
| 842 | 779 | /* harmony import */ var _title__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./title */ "./assets/src/apps/js/frontend/quiz/components/title/index.js"); |
| 843 | 780 | /* harmony import */ var _content__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./content */ "./assets/src/apps/js/frontend/quiz/components/content/index.js"); |
| 844 | 781 | /* harmony import */ var _meta__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meta */ "./assets/src/apps/js/frontend/quiz/components/meta/index.js"); |
| @@ -857,20 +794,23 @@ | ||
| 857 | 794 | |
| 858 | 795 | |
| 859 | 796 | |
| 860 | 797 | |
| 861 | -/***/ }), | |
| 798 | +/***/ }, | |
| 862 | 799 | |
| 863 | -/***/ "./assets/src/apps/js/frontend/quiz/components/meta/index.js": | |
| 800 | +/***/ "./assets/src/apps/js/frontend/quiz/components/meta/index.js" | |
| 864 | 801 | /*!*******************************************************************!*\ |
| 865 | 802 | !*** ./assets/src/apps/js/frontend/quiz/components/meta/index.js ***! |
| 866 | 803 | \*******************************************************************/ |
| 867 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 804 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 868 | 805 | |
| 869 | 806 | "use strict"; |
| 870 | 807 | __webpack_require__.r(__webpack_exports__); |
| 871 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 872 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 808 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 809 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 810 | +/* harmony export */ }); | |
| 811 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 812 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 873 | 813 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 874 | 814 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); |
| 875 | 815 | /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); |
| 876 | 816 | /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); |
| @@ -875,9 +815,8 @@ | ||
| 875 | 815 | /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); |
| 876 | 816 | /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); |
| 877 | 817 | /* harmony import */ var _duration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../duration */ "./assets/src/apps/js/frontend/quiz/components/duration/index.js"); |
| 878 | 818 | |
| 879 | - | |
| 880 | 819 | /** |
| 881 | 820 | * Quiz Meta. |
| 882 | 821 | * Edit: Use React Hook. |
| 883 | 822 | * |
| @@ -888,14 +827,12 @@ | ||
| 888 | 827 | |
| 889 | 828 | const { |
| 890 | 829 | Hook |
| 891 | 830 | } = LP; |
| 892 | - | |
| 893 | 831 | const Meta = () => { |
| 894 | 832 | const getData = attr => { |
| 895 | 833 | return (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz').getData(attr); |
| 896 | 834 | }; |
| 897 | - | |
| 898 | 835 | const metaFields = Hook.applyFilters('quiz-meta-fields', { |
| 899 | 836 | duration: { |
| 900 | 837 | title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Duration:', 'learnpress'), |
| 901 | 838 | name: 'duration', |
| @@ -911,21 +848,21 @@ | ||
| 911 | 848 | name: 'questions-count', |
| 912 | 849 | content: getData('questionIds') ? getData('questionIds').length : 0 |
| 913 | 850 | } |
| 914 | 851 | }); |
| 915 | - return metaFields && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("ul", { | |
| 852 | + return metaFields && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("ul", { | |
| 916 | 853 | className: "quiz-intro" |
| 917 | 854 | }, Object.values(metaFields).map((field, i) => { |
| 918 | 855 | const id = field.name || i; |
| 919 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 856 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 920 | 857 | key: `quiz-intro-field-${i}`, |
| 921 | 858 | className: `quiz-intro-item quiz-intro-item--${id}` |
| 922 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 859 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 923 | 860 | className: "quiz-intro-item__title", |
| 924 | 861 | dangerouslySetInnerHTML: { |
| 925 | 862 | __html: field.title |
| 926 | 863 | } |
| 927 | - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 864 | + }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 928 | 865 | className: "quiz-intro-item__content", |
| 929 | 866 | dangerouslySetInnerHTML: { |
| 930 | 867 | __html: field.content |
| 931 | 868 | } |
| @@ -931,32 +868,35 @@ | ||
| 931 | 868 | } |
| 932 | 869 | })); |
| 933 | 870 | }))); |
| 934 | 871 | }; |
| 872 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Meta); | |
| 935 | 873 | |
| 936 | -/* harmony default export */ __webpack_exports__["default"] = (Meta); | |
| 874 | +/***/ }, | |
| 937 | 875 | |
| 938 | -/***/ }), | |
| 939 | - | |
| 940 | -/***/ "./assets/src/apps/js/frontend/quiz/components/questions/buttons.js": | |
| 876 | +/***/ "./assets/src/apps/js/frontend/quiz/components/questions/buttons.js" | |
| 941 | 877 | /*!**************************************************************************!*\ |
| 942 | 878 | !*** ./assets/src/apps/js/frontend/quiz/components/questions/buttons.js ***! |
| 943 | 879 | \**************************************************************************/ |
| 944 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 880 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 945 | 881 | |
| 946 | 882 | "use strict"; |
| 947 | 883 | __webpack_require__.r(__webpack_exports__); |
| 948 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 949 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 884 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 885 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 886 | +/* harmony export */ }); | |
| 887 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 888 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 950 | 889 | /* harmony import */ var _buttons_button_hint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../buttons/button-hint */ "./assets/src/apps/js/frontend/quiz/components/buttons/button-hint.js"); |
| 951 | 890 | /* harmony import */ var _buttons_button_check__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buttons/button-check */ "./assets/src/apps/js/frontend/quiz/components/buttons/button-check.js"); |
| 952 | 891 | /* harmony import */ var _buttons__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../buttons */ "./assets/src/apps/js/frontend/quiz/components/buttons/index.js"); |
| 892 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 893 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__); | |
| 953 | 894 | |
| 954 | 895 | |
| 955 | 896 | |
| 956 | 897 | |
| 957 | 898 | |
| 958 | - | |
| 959 | 899 | const Buttons = function Buttons(props) { |
| 960 | 900 | const { |
| 961 | 901 | question |
| 962 | 902 | } = props; |
| @@ -961,9 +901,9 @@ | ||
| 961 | 901 | question |
| 962 | 902 | } = props; |
| 963 | 903 | const buttons = { |
| 964 | 904 | 'instant-check': () => { |
| 965 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_buttons__WEBPACK_IMPORTED_MODULE_3__.MaybeShowButton, { | |
| 905 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_buttons__WEBPACK_IMPORTED_MODULE_3__.MaybeShowButton, { | |
| 966 | 906 | type: "check", |
| 967 | 907 | Button: _buttons_button_check__WEBPACK_IMPORTED_MODULE_2__["default"], |
| 968 | 908 | question: question |
| 969 | 909 | }); |
| @@ -968,9 +908,9 @@ | ||
| 968 | 908 | question: question |
| 969 | 909 | }); |
| 970 | 910 | }, |
| 971 | 911 | hint: () => { |
| 972 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_buttons__WEBPACK_IMPORTED_MODULE_3__.MaybeShowButton, { | |
| 912 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_buttons__WEBPACK_IMPORTED_MODULE_3__.MaybeShowButton, { | |
| 973 | 913 | type: "hint", |
| 974 | 914 | Button: _buttons_button_hint__WEBPACK_IMPORTED_MODULE_1__["default"], |
| 975 | 915 | question: question |
| 976 | 916 | }); |
| @@ -975,28 +915,31 @@ | ||
| 975 | 915 | question: question |
| 976 | 916 | }); |
| 977 | 917 | } |
| 978 | 918 | }; |
| 979 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, LP.config.questionFooterButtons().map(name => { | |
| 980 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, { | |
| 919 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.Fragment, null, LP.config.questionFooterButtons().map(name => { | |
| 920 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.Fragment, { | |
| 981 | 921 | key: `button-${name}` |
| 982 | 922 | }, buttons[name] && buttons[name]()); |
| 983 | 923 | })); |
| 984 | 924 | }; |
| 925 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Buttons); | |
| 985 | 926 | |
| 986 | -/* harmony default export */ __webpack_exports__["default"] = (Buttons); | |
| 927 | +/***/ }, | |
| 987 | 928 | |
| 988 | -/***/ }), | |
| 989 | - | |
| 990 | -/***/ "./assets/src/apps/js/frontend/quiz/components/questions/index.js": | |
| 929 | +/***/ "./assets/src/apps/js/frontend/quiz/components/questions/index.js" | |
| 991 | 930 | /*!************************************************************************!*\ |
| 992 | 931 | !*** ./assets/src/apps/js/frontend/quiz/components/questions/index.js ***! |
| 993 | 932 | \************************************************************************/ |
| 994 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 933 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 995 | 934 | |
| 996 | 935 | "use strict"; |
| 997 | 936 | __webpack_require__.r(__webpack_exports__); |
| 998 | -/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); | |
| 937 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 938 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 939 | +/* harmony export */ }); | |
| 940 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 941 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 999 | 942 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); |
| 1000 | 943 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); |
| 1001 | 944 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 1002 | 945 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); |
| @@ -1010,56 +953,11 @@ | ||
| 1010 | 953 | |
| 1011 | 954 | |
| 1012 | 955 | |
| 1013 | 956 | |
| 1014 | - | |
| 1015 | - | |
| 1016 | 957 | class Questions extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { |
| 1017 | 958 | constructor(props) { |
| 1018 | 959 | super(...arguments); |
| 1019 | - | |
| 1020 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "startQuiz", event => { | |
| 1021 | - event.preventDefault(); | |
| 1022 | - const { | |
| 1023 | - startQuiz | |
| 1024 | - } = this.props; | |
| 1025 | - startQuiz(); | |
| 1026 | - }); | |
| 1027 | - | |
| 1028 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "isInVisibleRange", (id, index) => { | |
| 1029 | - const { | |
| 1030 | - currentPage, | |
| 1031 | - questionsPerPage | |
| 1032 | - } = this.props; | |
| 1033 | - return currentPage === Math.ceil(index / questionsPerPage); | |
| 1034 | - }); | |
| 1035 | - | |
| 1036 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "nav", event => { | |
| 1037 | - const { | |
| 1038 | - sendKey | |
| 1039 | - } = this.props; | |
| 1040 | - | |
| 1041 | - switch (event.keyCode) { | |
| 1042 | - case 37: | |
| 1043 | - return sendKey('left'); | |
| 1044 | - | |
| 1045 | - case 38: | |
| 1046 | - return; | |
| 1047 | - | |
| 1048 | - case 39: | |
| 1049 | - return sendKey('right'); | |
| 1050 | - | |
| 1051 | - case 40: | |
| 1052 | - return; | |
| 1053 | - | |
| 1054 | - default: | |
| 1055 | - if (event.keyCode >= 49 && event.keyCode <= 57) { | |
| 1056 | - sendKey(event.keyCode - 48); | |
| 1057 | - } | |
| 1058 | - | |
| 1059 | - } | |
| 1060 | - }); | |
| 1061 | - | |
| 1062 | 960 | this.needToTop = false; |
| 1063 | 961 | this.state = { |
| 1064 | 962 | isReviewing: null, |
| 1065 | 963 | currentPage: 0, |
| @@ -1065,26 +963,26 @@ | ||
| 1065 | 963 | currentPage: 0, |
| 1066 | 964 | self: this |
| 1067 | 965 | }; |
| 1068 | 966 | } |
| 1069 | - | |
| 1070 | 967 | static getDerivedStateFromProps(props, state) { |
| 1071 | 968 | const checkProps = ['isReviewing', 'currentPage']; |
| 1072 | 969 | const changedProps = {}; |
| 1073 | - | |
| 1074 | 970 | for (let i = 0; i < checkProps.length; i++) { |
| 1075 | 971 | if (props[checkProps[i]] !== state[checkProps[i]]) { |
| 1076 | 972 | changedProps[checkProps[i]] = props[checkProps[i]]; |
| 1077 | 973 | } |
| 1078 | 974 | } |
| 1079 | - | |
| 1080 | 975 | if (Object.values(changedProps).length) { |
| 1081 | - state.self.needToTop = true; | |
| 976 | + if (props.questionsPerPage === 1) { | |
| 977 | + state.self.needToTop = true; | |
| 978 | + } | |
| 1082 | 979 | return changedProps; |
| 1083 | 980 | } |
| 981 | + return null; | |
| 982 | + } | |
| 1084 | 983 | |
| 1085 | - return null; | |
| 1086 | - } // componentWillReceiveProps(nextProps){ | |
| 984 | + // componentWillReceiveProps(nextProps){ | |
| 1087 | 985 | // const checkProps = ['isReviewing', 'currentPage']; |
| 1088 | 986 | // |
| 1089 | 987 | // for(let i = 0; i < checkProps.length; i++){ |
| 1090 | 988 | // if(this.props[checkProps[i]] !== nextProps[checkProps[i]]){ |
| @@ -1093,14 +991,14 @@ | ||
| 1093 | 991 | // } |
| 1094 | 992 | // } |
| 1095 | 993 | // |
| 1096 | 994 | // } |
| 995 | + | |
| 1097 | 996 | // componentWillUpdate() { |
| 1098 | 997 | // this.needToTop = this.state.needToTop; |
| 1099 | 998 | // this.setState({needToTop: false}); |
| 1100 | 999 | // } |
| 1101 | 1000 | |
| 1102 | - | |
| 1103 | 1001 | componentDidUpdate() { |
| 1104 | 1002 | if (this.needToTop) { |
| 1105 | 1003 | jQuery('#popup-content').animate({ |
| 1106 | 1004 | scrollTop: 0 |
| @@ -1109,9 +1007,41 @@ | ||
| 1109 | 1007 | }); |
| 1110 | 1008 | this.needToTop = false; |
| 1111 | 1009 | } |
| 1112 | 1010 | } |
| 1113 | - | |
| 1011 | + startQuiz = event => { | |
| 1012 | + event.preventDefault(); | |
| 1013 | + const { | |
| 1014 | + startQuiz | |
| 1015 | + } = this.props; | |
| 1016 | + startQuiz(); | |
| 1017 | + }; | |
| 1018 | + isInVisibleRange = (id, index) => { | |
| 1019 | + const { | |
| 1020 | + currentPage, | |
| 1021 | + questionsPerPage | |
| 1022 | + } = this.props; | |
| 1023 | + return currentPage === Math.ceil(index / questionsPerPage); | |
| 1024 | + }; | |
| 1025 | + nav = event => { | |
| 1026 | + const { | |
| 1027 | + sendKey | |
| 1028 | + } = this.props; | |
| 1029 | + switch (event.keyCode) { | |
| 1030 | + case 37: | |
| 1031 | + return sendKey('left'); | |
| 1032 | + case 38: | |
| 1033 | + return; | |
| 1034 | + case 39: | |
| 1035 | + return sendKey('right'); | |
| 1036 | + case 40: | |
| 1037 | + return; | |
| 1038 | + default: | |
| 1039 | + if (event.keyCode >= 49 && event.keyCode <= 57) { | |
| 1040 | + sendKey(event.keyCode - 48); | |
| 1041 | + } | |
| 1042 | + } | |
| 1043 | + }; | |
| 1114 | 1044 | render() { |
| 1115 | 1045 | const { |
| 1116 | 1046 | status, |
| 1117 | 1047 | currentQuestion, |
| @@ -1120,17 +1050,15 @@ | ||
| 1120 | 1050 | isReviewing, |
| 1121 | 1051 | questionsPerPage |
| 1122 | 1052 | } = this.props; |
| 1123 | 1053 | let isShow = true; |
| 1124 | - | |
| 1125 | 1054 | if (status === 'completed' && !isReviewing) { |
| 1126 | 1055 | isShow = false; |
| 1127 | 1056 | } |
| 1128 | - | |
| 1129 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 1057 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1130 | 1058 | tabIndex: 100, |
| 1131 | 1059 | onKeyUp: this.nav |
| 1132 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", { | |
| 1060 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1133 | 1061 | className: "quiz-questions", |
| 1134 | 1062 | style: { |
| 1135 | 1063 | display: isShow ? '' : 'none' |
| 1136 | 1064 | } |
| @@ -1137,9 +1065,9 @@ | ||
| 1137 | 1065 | }, questions.map((question, index) => { |
| 1138 | 1066 | const isCurrent = questionsPerPage ? false : currentQuestion === question.id; |
| 1139 | 1067 | const isRendered = questionsRendered && questionsRendered.indexOf(question.id) !== -1; |
| 1140 | 1068 | const isVisible = this.isInVisibleRange(question.id, index + 1); |
| 1141 | - return isRendered || !isRendered || isVisible ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_question__WEBPACK_IMPORTED_MODULE_5__["default"], { | |
| 1069 | + return isRendered || !isRendered || isVisible ? (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_question__WEBPACK_IMPORTED_MODULE_5__["default"], { | |
| 1142 | 1070 | key: `loop-question-${question.id}`, |
| 1143 | 1071 | isCurrent: isCurrent, |
| 1144 | 1072 | isShow: isVisible, |
| 1145 | 1073 | isShowIndex: questionsPerPage ? index + 1 : false, |
| @@ -1147,12 +1075,10 @@ | ||
| 1147 | 1075 | question: question |
| 1148 | 1076 | }) : ''; |
| 1149 | 1077 | })))); |
| 1150 | 1078 | } |
| 1151 | - | |
| 1152 | 1079 | } |
| 1153 | - | |
| 1154 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withSelect)((select, a, b) => { | |
| 1080 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withSelect)((select, a, b) => { | |
| 1155 | 1081 | const { |
| 1156 | 1082 | getData, |
| 1157 | 1083 | getQuestions |
| 1158 | 1084 | } = select('learnpress/quiz'); |
| @@ -1176,32 +1102,35 @@ | ||
| 1176 | 1102 | sendKey |
| 1177 | 1103 | }; |
| 1178 | 1104 | }))(Questions)); |
| 1179 | 1105 | |
| 1180 | -/***/ }), | |
| 1106 | +/***/ }, | |
| 1181 | 1107 | |
| 1182 | -/***/ "./assets/src/apps/js/frontend/quiz/components/questions/question.js": | |
| 1108 | +/***/ "./assets/src/apps/js/frontend/quiz/components/questions/question.js" | |
| 1183 | 1109 | /*!***************************************************************************!*\ |
| 1184 | 1110 | !*** ./assets/src/apps/js/frontend/quiz/components/questions/question.js ***! |
| 1185 | 1111 | \***************************************************************************/ |
| 1186 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1112 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1187 | 1113 | |
| 1188 | 1114 | "use strict"; |
| 1189 | 1115 | __webpack_require__.r(__webpack_exports__); |
| 1190 | -/* harmony import */ var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/extends */ "./node_modules/@babel/runtime/helpers/esm/extends.js"); | |
| 1191 | -/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); | |
| 1192 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1193 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); | |
| 1194 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1195 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__); | |
| 1196 | -/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); | |
| 1197 | -/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_4__); | |
| 1198 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 1199 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__); | |
| 1200 | -/* harmony import */ var _buttons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./buttons */ "./assets/src/apps/js/frontend/quiz/components/questions/buttons.js"); | |
| 1201 | -/* harmony import */ var _buttons__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../buttons */ "./assets/src/apps/js/frontend/quiz/components/buttons/index.js"); | |
| 1202 | -/* harmony import */ var _buttons_button_check__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../buttons/button-check */ "./assets/src/apps/js/frontend/quiz/components/buttons/button-check.js"); | |
| 1203 | -/* harmony import */ var _buttons_button_hint__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../buttons/button-hint */ "./assets/src/apps/js/frontend/quiz/components/buttons/button-hint.js"); | |
| 1116 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 1117 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1118 | +/* harmony export */ }); | |
| 1119 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 1120 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 1121 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1122 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); | |
| 1123 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1124 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); | |
| 1125 | +/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); | |
| 1126 | +/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__); | |
| 1127 | +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 1128 | +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__); | |
| 1129 | +/* harmony import */ var _buttons__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./buttons */ "./assets/src/apps/js/frontend/quiz/components/questions/buttons.js"); | |
| 1130 | +/* harmony import */ var _buttons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../buttons */ "./assets/src/apps/js/frontend/quiz/components/buttons/index.js"); | |
| 1131 | +/* harmony import */ var _buttons_button_check__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../buttons/button-check */ "./assets/src/apps/js/frontend/quiz/components/buttons/button-check.js"); | |
| 1132 | +/* harmony import */ var _buttons_button_hint__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../buttons/button-hint */ "./assets/src/apps/js/frontend/quiz/components/buttons/button-hint.js"); | |
| 1204 | 1133 | |
| 1205 | 1134 | |
| 1206 | 1135 | |
| 1207 | 1136 | |
| @@ -1209,10 +1138,8 @@ | ||
| 1209 | 1138 | |
| 1210 | 1139 | |
| 1211 | 1140 | |
| 1212 | 1141 | |
| 1213 | - | |
| 1214 | - | |
| 1215 | 1142 | const $ = window.jQuery; |
| 1216 | 1143 | const { |
| 1217 | 1144 | uniqueId, |
| 1218 | 1145 | isArray, |
| @@ -1218,55 +1145,11 @@ | ||
| 1218 | 1145 | isArray, |
| 1219 | 1146 | isNumber, |
| 1220 | 1147 | bind |
| 1221 | 1148 | } = lodash; |
| 1222 | - | |
| 1223 | -class Question extends _wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Component { | |
| 1149 | +class Question extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { | |
| 1224 | 1150 | constructor() { |
| 1225 | 1151 | super(...arguments); |
| 1226 | - | |
| 1227 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__["default"])(this, "setRef", el => { | |
| 1228 | - this.$wrap = $(el); | |
| 1229 | - }); | |
| 1230 | - | |
| 1231 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__["default"])(this, "parseOptions", options => { | |
| 1232 | - if (options) { | |
| 1233 | - options = !isArray(options) ? JSON.parse(CryptoJS.AES.decrypt(options.data, options.key, { | |
| 1234 | - format: CryptoJSAesJson | |
| 1235 | - }).toString(CryptoJS.enc.Utf8)) : options; | |
| 1236 | - options = !isArray(options) ? JSON.parse(options) : options; | |
| 1237 | - } | |
| 1238 | - | |
| 1239 | - return options || []; | |
| 1240 | - }); | |
| 1241 | - | |
| 1242 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__["default"])(this, "getWrapperClass", () => { | |
| 1243 | - const { | |
| 1244 | - question, | |
| 1245 | - answered | |
| 1246 | - } = this.props; | |
| 1247 | - const classes = ['question', 'question-' + question.type]; | |
| 1248 | - const options = this.parseOptions(question.options); | |
| 1249 | - | |
| 1250 | - if (options.length && options[0].isTrue !== undefined) { | |
| 1251 | - classes.push('question-answered'); | |
| 1252 | - } | |
| 1253 | - | |
| 1254 | - return classes; | |
| 1255 | - }); | |
| 1256 | - | |
| 1257 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__["default"])(this, "getEditLink", () => { | |
| 1258 | - const { | |
| 1259 | - question, | |
| 1260 | - editPermalink | |
| 1261 | - } = this.props; | |
| 1262 | - return editPermalink ? editPermalink.replace(/post=(.*[0-9])/, `post=${question.id}`) : ''; | |
| 1263 | - }); | |
| 1264 | - | |
| 1265 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__["default"])(this, "editPermalink", editPermalink => { | |
| 1266 | - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.sprintf)('<a href="%s">%s</a>', editPermalink, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Edit', 'learnpress')); | |
| 1267 | - }); | |
| 1268 | - | |
| 1269 | 1152 | this.state = { |
| 1270 | 1153 | time: null, |
| 1271 | 1154 | showHint: false |
| 1272 | 1155 | }; |
| @@ -1271,9 +1154,8 @@ | ||
| 1271 | 1154 | showHint: false |
| 1272 | 1155 | }; |
| 1273 | 1156 | this.$wrap = null; |
| 1274 | 1157 | } |
| 1275 | - | |
| 1276 | 1158 | componentDidMount(a) { |
| 1277 | 1159 | const { |
| 1278 | 1160 | question, |
| 1279 | 1161 | isCurrent, |
| @@ -1278,28 +1160,56 @@ | ||
| 1278 | 1160 | question, |
| 1279 | 1161 | isCurrent, |
| 1280 | 1162 | markQuestionRendered |
| 1281 | 1163 | } = this.props; |
| 1282 | - | |
| 1283 | 1164 | if (isCurrent) { |
| 1284 | 1165 | markQuestionRendered(question.id); |
| 1285 | 1166 | } |
| 1286 | - | |
| 1287 | 1167 | if (!this.state.time) { |
| 1288 | 1168 | this.setState({ |
| 1289 | 1169 | time: new Date() |
| 1290 | 1170 | }); |
| 1291 | 1171 | } |
| 1292 | - | |
| 1293 | 1172 | LP.Hook.doAction('lp-question-compatible-builder'); |
| 1294 | - | |
| 1295 | - if (typeof MathJax !== 'undefined') { | |
| 1173 | + if (typeof MathJax !== 'undefined' && typeof MathJax.Hub !== 'undefined') { | |
| 1296 | 1174 | MathJax.Hub.Queue(['Typeset', MathJax.Hub]); |
| 1297 | 1175 | } |
| 1298 | - | |
| 1299 | 1176 | return a; |
| 1300 | 1177 | } |
| 1301 | - | |
| 1178 | + setRef = el => { | |
| 1179 | + this.$wrap = $(el); | |
| 1180 | + }; | |
| 1181 | + parseOptions = options => { | |
| 1182 | + if (options) { | |
| 1183 | + options = !isArray(options) ? JSON.parse(CryptoJS.AES.decrypt(options.data, options.key, { | |
| 1184 | + format: CryptoJSAesJson | |
| 1185 | + }).toString(CryptoJS.enc.Utf8)) : options; | |
| 1186 | + options = !isArray(options) ? JSON.parse(options) : options; | |
| 1187 | + } | |
| 1188 | + return options || []; | |
| 1189 | + }; | |
| 1190 | + getWrapperClass = () => { | |
| 1191 | + const { | |
| 1192 | + question, | |
| 1193 | + answered | |
| 1194 | + } = this.props; | |
| 1195 | + const classes = ['question', 'question-' + question.type]; | |
| 1196 | + const options = this.parseOptions(question.options); | |
| 1197 | + if (options.length && options[0].isTrue !== undefined) { | |
| 1198 | + classes.push('question-answered'); | |
| 1199 | + } | |
| 1200 | + return classes; | |
| 1201 | + }; | |
| 1202 | + getEditLink = () => { | |
| 1203 | + const { | |
| 1204 | + question, | |
| 1205 | + editPermalink | |
| 1206 | + } = this.props; | |
| 1207 | + return editPermalink ? editPermalink.replace(/post=(.*[0-9])/, `post=${question.id}`) : ''; | |
| 1208 | + }; | |
| 1209 | + editPermalink = editPermalink => { | |
| 1210 | + return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.sprintf)('<a href="%s">%s</a>', editPermalink, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Edit', 'learnpress')); | |
| 1211 | + }; | |
| 1302 | 1212 | render() { |
| 1303 | 1213 | const { |
| 1304 | 1214 | question, |
| 1305 | 1215 | isShow, |
| @@ -1304,25 +1214,29 @@ | ||
| 1304 | 1214 | question, |
| 1305 | 1215 | isShow, |
| 1306 | 1216 | isShowIndex, |
| 1307 | 1217 | isShowHint, |
| 1308 | - status | |
| 1218 | + status, | |
| 1219 | + results | |
| 1309 | 1220 | } = this.props; |
| 1221 | + if (results && results.questions && results.questions[question.id]) { | |
| 1222 | + if (typeof results.questions[question.id].correct !== 'undefined') { | |
| 1223 | + question.correct = results.questions[question.id].correct; | |
| 1224 | + } | |
| 1225 | + } | |
| 1310 | 1226 | const QuestionTypes = LP.questionTypes.default; |
| 1311 | 1227 | const editPermalink = this.getEditLink(); |
| 1312 | - | |
| 1313 | 1228 | if (editPermalink) { |
| 1314 | 1229 | jQuery('#wp-admin-bar-edit-lp_question').find('.ab-item').attr('href', editPermalink); |
| 1315 | 1230 | } |
| 1316 | - | |
| 1317 | 1231 | const titleParts = { |
| 1318 | 1232 | index: () => { |
| 1319 | - return isShowIndex ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("span", { | |
| 1233 | + return isShowIndex ? (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1320 | 1234 | className: "question-index" |
| 1321 | 1235 | }, isShowIndex, ".") : ''; |
| 1322 | 1236 | }, |
| 1323 | 1237 | title: () => { |
| 1324 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("span", { | |
| 1238 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1325 | 1239 | dangerouslySetInnerHTML: { |
| 1326 | 1240 | __html: question.title |
| 1327 | 1241 | } |
| 1328 | 1242 | }); |
| @@ -1327,14 +1241,14 @@ | ||
| 1327 | 1241 | } |
| 1328 | 1242 | }); |
| 1329 | 1243 | }, |
| 1330 | 1244 | hint: () => { |
| 1331 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_buttons_button_hint__WEBPACK_IMPORTED_MODULE_9__["default"], { | |
| 1245 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_buttons_button_hint__WEBPACK_IMPORTED_MODULE_8__["default"], { | |
| 1332 | 1246 | question: question |
| 1333 | 1247 | }); |
| 1334 | 1248 | }, |
| 1335 | 1249 | 'edit-permalink': () => { |
| 1336 | - return editPermalink && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("span", { | |
| 1250 | + return editPermalink && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1337 | 1251 | dangerouslySetInnerHTML: { |
| 1338 | 1252 | __html: this.editPermalink(editPermalink) |
| 1339 | 1253 | }, |
| 1340 | 1254 | className: "edit-link" |
| @@ -1342,18 +1256,18 @@ | ||
| 1342 | 1256 | } |
| 1343 | 1257 | }; |
| 1344 | 1258 | const blocks = { |
| 1345 | 1259 | title: () => { |
| 1346 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("h4", { | |
| 1260 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h4", { | |
| 1347 | 1261 | className: "question-title" |
| 1348 | 1262 | }, LP.config.questionTitleParts().map(name => { |
| 1349 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Fragment, { | |
| 1263 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, { | |
| 1350 | 1264 | key: `title-part-${name}` |
| 1351 | 1265 | }, titleParts[name] && titleParts[name]()); |
| 1352 | 1266 | })); |
| 1353 | 1267 | }, |
| 1354 | 1268 | content: () => { |
| 1355 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("div", { | |
| 1269 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1356 | 1270 | className: "question-content", |
| 1357 | 1271 | dangerouslySetInnerHTML: { |
| 1358 | 1272 | __html: question.content |
| 1359 | 1273 | } |
| @@ -1359,18 +1273,19 @@ | ||
| 1359 | 1273 | } |
| 1360 | 1274 | }); |
| 1361 | 1275 | }, |
| 1362 | 1276 | 'answer-options': () => { |
| 1363 | - return this.$wrap && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(QuestionTypes, (0,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({}, this.props, { | |
| 1277 | + return this.$wrap && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(QuestionTypes, { | |
| 1278 | + ...this.props, | |
| 1364 | 1279 | $wrap: this.$wrap |
| 1365 | - })); | |
| 1280 | + }); | |
| 1366 | 1281 | }, |
| 1367 | 1282 | explanation: () => { |
| 1368 | - return question.explanation && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("div", { | |
| 1283 | + return question.explanation && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1369 | 1284 | className: "question-explanation-content" |
| 1370 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("strong", { | |
| 1285 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("strong", { | |
| 1371 | 1286 | className: "explanation-title" |
| 1372 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Explanation', 'learnpress'), ":"), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("div", { | |
| 1287 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Explanation', 'learnpress'), ":"), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1373 | 1288 | dangerouslySetInnerHTML: { |
| 1374 | 1289 | __html: question.explanation |
| 1375 | 1290 | } |
| 1376 | 1291 | }))); |
| @@ -1375,13 +1290,13 @@ | ||
| 1375 | 1290 | } |
| 1376 | 1291 | }))); |
| 1377 | 1292 | }, |
| 1378 | 1293 | hint: () => { |
| 1379 | - return question.hint && !question.explanation && question.showHint && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("div", { | |
| 1294 | + return question.hint && !question.explanation && question.showHint && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1380 | 1295 | className: "question-hint-content" |
| 1381 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("strong", { | |
| 1296 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("strong", { | |
| 1382 | 1297 | className: "hint-title" |
| 1383 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Hint', 'learnpress'), ":"), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("div", { | |
| 1298 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Hint', 'learnpress'), ":"), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1384 | 1299 | dangerouslySetInnerHTML: { |
| 1385 | 1300 | __html: question.hint |
| 1386 | 1301 | } |
| 1387 | 1302 | }))); |
| @@ -1386,15 +1301,15 @@ | ||
| 1386 | 1301 | } |
| 1387 | 1302 | }))); |
| 1388 | 1303 | }, |
| 1389 | 1304 | buttons: () => { |
| 1390 | - return 'started' === status && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_buttons__WEBPACK_IMPORTED_MODULE_6__["default"], { | |
| 1305 | + return 'started' === status && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_buttons__WEBPACK_IMPORTED_MODULE_5__["default"], { | |
| 1391 | 1306 | question: question |
| 1392 | 1307 | }); |
| 1393 | 1308 | } |
| 1394 | 1309 | }; |
| 1395 | 1310 | const configBlocks = LP.config.questionBlocks(); |
| 1396 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)("div", { | |
| 1311 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1397 | 1312 | className: this.getWrapperClass().join(' '), |
| 1398 | 1313 | style: { |
| 1399 | 1314 | display: isShow ? '' : 'none' |
| 1400 | 1315 | }, |
| @@ -1400,22 +1315,19 @@ | ||
| 1400 | 1315 | }, |
| 1401 | 1316 | "data-id": question.id, |
| 1402 | 1317 | ref: this.setRef |
| 1403 | 1318 | }, configBlocks.map(name => { |
| 1404 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.Fragment, { | |
| 1319 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, { | |
| 1405 | 1320 | key: `block-${name}` |
| 1406 | 1321 | }, blocks[name] ? blocks[name]() : ''); |
| 1407 | 1322 | }))); |
| 1408 | 1323 | } |
| 1409 | - | |
| 1410 | 1324 | } |
| 1411 | - | |
| 1412 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_4__.compose)([(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withSelect)((select, _ref) => { | |
| 1413 | - let { | |
| 1414 | - question: { | |
| 1415 | - id | |
| 1416 | - } | |
| 1417 | - } = _ref; | |
| 1325 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_3__.compose)([(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withSelect)((select, { | |
| 1326 | + question: { | |
| 1327 | + id | |
| 1328 | + } | |
| 1329 | +}) => { | |
| 1418 | 1330 | const { |
| 1419 | 1331 | getData, |
| 1420 | 1332 | getQuestionAnswered, |
| 1421 | 1333 | getQuestionMark |
| @@ -1426,40 +1338,47 @@ | ||
| 1426 | 1338 | answered: getQuestionAnswered(id), |
| 1427 | 1339 | questionsRendered: getData('questionsRendered'), |
| 1428 | 1340 | editPermalink: getData('editPermalink'), |
| 1429 | 1341 | numPages: getData('numPages'), |
| 1430 | - mark: getQuestionMark(id) || '' | |
| 1342 | + mark: getQuestionMark(id) || '', | |
| 1343 | + results: getData('results') | |
| 1431 | 1344 | }; |
| 1432 | -}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withDispatch)(dispatch => { | |
| 1345 | +}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.withDispatch)(dispatch => { | |
| 1433 | 1346 | const { |
| 1434 | 1347 | updateUserQuestionAnswers, |
| 1348 | + updateUserQuestionFibAnswers, | |
| 1435 | 1349 | markQuestionRendered |
| 1436 | 1350 | } = dispatch('learnpress/quiz'); |
| 1437 | 1351 | return { |
| 1438 | 1352 | markQuestionRendered, |
| 1439 | - updateUserQuestionAnswers | |
| 1353 | + updateUserQuestionAnswers, | |
| 1354 | + updateUserQuestionFibAnswers | |
| 1440 | 1355 | }; |
| 1441 | 1356 | })])(Question)); |
| 1442 | 1357 | |
| 1443 | -/***/ }), | |
| 1358 | +/***/ }, | |
| 1444 | 1359 | |
| 1445 | -/***/ "./assets/src/apps/js/frontend/quiz/components/result/index.js": | |
| 1360 | +/***/ "./assets/src/apps/js/frontend/quiz/components/result/index.js" | |
| 1446 | 1361 | /*!*********************************************************************!*\ |
| 1447 | 1362 | !*** ./assets/src/apps/js/frontend/quiz/components/result/index.js ***! |
| 1448 | 1363 | \*********************************************************************/ |
| 1449 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1364 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1450 | 1365 | |
| 1451 | 1366 | "use strict"; |
| 1452 | 1367 | __webpack_require__.r(__webpack_exports__); |
| 1453 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1454 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 1455 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1456 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); | |
| 1457 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 1458 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); | |
| 1459 | -/* harmony import */ var _single_curriculum_components_items_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../single-curriculum/components/items-progress */ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js"); | |
| 1368 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 1369 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1370 | +/* harmony export */ }); | |
| 1371 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 1372 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 1373 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1374 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); | |
| 1375 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1376 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); | |
| 1377 | +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 1378 | +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); | |
| 1379 | +/* harmony import */ var _single_curriculum_components_items_progress__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../single-curriculum/components/items-progress */ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js"); | |
| 1460 | 1380 | |
| 1461 | - | |
| 1462 | 1381 | /** |
| 1463 | 1382 | * Quizz Result. |
| 1464 | 1383 | * Edit: Use React hook. |
| 1465 | 1384 | * |
| @@ -1471,28 +1390,26 @@ | ||
| 1471 | 1390 | |
| 1472 | 1391 | const { |
| 1473 | 1392 | debounce |
| 1474 | 1393 | } = lodash; |
| 1475 | - | |
| 1476 | 1394 | const Result = () => { |
| 1477 | - const [percentage, setPercentage] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); | |
| 1478 | - const [done, setDone] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(false); | |
| 1479 | - const QuizID = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.useSelect)(select => { | |
| 1395 | + const [percentage, setPercentage] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(0); | |
| 1396 | + const [done, setDone] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(false); | |
| 1397 | + const QuizID = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.useSelect)(select => { | |
| 1480 | 1398 | return select('learnpress/quiz').getData('id'); |
| 1481 | 1399 | }, []); |
| 1482 | - const results = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.useSelect)(select => { | |
| 1400 | + const results = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.useSelect)(select => { | |
| 1483 | 1401 | return select('learnpress/quiz').getData('results'); |
| 1484 | 1402 | }, []); |
| 1485 | - const passingGrade = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.useSelect)(select => { | |
| 1403 | + const passingGrade = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.useSelect)(select => { | |
| 1486 | 1404 | return select('learnpress/quiz').getData('passingGrade'); |
| 1487 | 1405 | }, []); |
| 1488 | - const submitting = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.useSelect)(select => { | |
| 1406 | + const submitting = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.useSelect)(select => { | |
| 1489 | 1407 | return select('learnpress/quiz').getData('submitting'); |
| 1490 | 1408 | }, []); |
| 1491 | - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { | |
| 1409 | + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { | |
| 1492 | 1410 | animate(); |
| 1493 | 1411 | let graduation = ''; |
| 1494 | - | |
| 1495 | 1412 | if (results.graduation) { |
| 1496 | 1413 | graduation = results.graduation; |
| 1497 | 1414 | } else if (results.result >= passingGradeValue) { |
| 1498 | 1415 | graduation = 'passed'; |
| @@ -1498,31 +1415,27 @@ | ||
| 1498 | 1415 | graduation = 'passed'; |
| 1499 | 1416 | } else { |
| 1500 | 1417 | graduation = 'failed'; |
| 1501 | 1418 | } |
| 1502 | - | |
| 1503 | 1419 | if (graduation) { |
| 1504 | 1420 | const ele = document.querySelector(`.course-curriculum .course-item.course-item-${QuizID}`); |
| 1505 | - | |
| 1506 | 1421 | if (ele) { |
| 1507 | 1422 | ele.classList.remove('failed', 'passed'); |
| 1508 | 1423 | ele.classList.add('has-status', 'status-completed', graduation); |
| 1509 | 1424 | } |
| 1510 | 1425 | } |
| 1511 | - | |
| 1512 | 1426 | const item = [...document.querySelectorAll('#popup-header .items-progress')][0]; |
| 1513 | - const elCurriculumSections = document.querySelector('.curriculum-sections'); | |
| 1514 | - | |
| 1515 | - if (item && elCurriculumSections) { | |
| 1427 | + if (item) { | |
| 1516 | 1428 | const totalItems = item.dataset.totalItems; |
| 1517 | 1429 | const itemCompleted = item.querySelector('.items-completed'); |
| 1518 | 1430 | const elProgress = item.querySelector('.learn-press-progress__active'); |
| 1519 | - | |
| 1520 | 1431 | if (itemCompleted) { |
| 1521 | 1432 | // const number = parseInt( itemCompleted.textContent ); |
| 1522 | - const allItemCompleted = document.querySelectorAll('#popup-sidebar .course-curriculum .course-item.status-completed'); | |
| 1523 | - itemCompleted.textContent = parseInt(allItemCompleted.length); // Set progress | |
| 1524 | 1433 | |
| 1434 | + const allItemCompleted = document.querySelectorAll('#popup-sidebar .course-curriculum .course-item__status .completed'); | |
| 1435 | + itemCompleted.textContent = parseInt(allItemCompleted.length); | |
| 1436 | + | |
| 1437 | + // Set progress | |
| 1525 | 1438 | const perCent = parseInt(allItemCompleted.length) * 100 / parseInt(totalItems); |
| 1526 | 1439 | const percentSet = 100 - perCent; |
| 1527 | 1440 | elProgress.style.left = '-' + percentSet + '%'; |
| 1528 | 1441 | } |
| @@ -1527,30 +1440,25 @@ | ||
| 1527 | 1440 | elProgress.style.left = '-' + percentSet + '%'; |
| 1528 | 1441 | } |
| 1529 | 1442 | } |
| 1530 | 1443 | }, [results]); |
| 1531 | - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { | |
| 1444 | + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { | |
| 1532 | 1445 | if (submitting !== undefined) { |
| 1533 | 1446 | updateItemsProgress(); |
| 1534 | 1447 | } |
| 1535 | 1448 | }, [submitting]); |
| 1536 | - | |
| 1537 | 1449 | const updateItemsProgress = () => { |
| 1538 | 1450 | const elements = document.querySelectorAll('.popup-header__inner'); |
| 1539 | - | |
| 1540 | 1451 | if (elements.length > 0 && elements[0].querySelectorAll('form.form-button-finish-course').length === 0) { |
| 1541 | - (0,_single_curriculum_components_items_progress__WEBPACK_IMPORTED_MODULE_3__.getResponse)(elements[0]); | |
| 1452 | + (0,_single_curriculum_components_items_progress__WEBPACK_IMPORTED_MODULE_4__.getResponse)(elements[0]); | |
| 1542 | 1453 | } |
| 1543 | 1454 | }; |
| 1544 | - | |
| 1545 | 1455 | const animate = () => { |
| 1546 | 1456 | setPercentage(0); |
| 1547 | 1457 | setDone(false); |
| 1548 | - | |
| 1549 | 1458 | jQuery.easing._customEasing = function (e, f, a, h, g) { |
| 1550 | 1459 | return h * Math.sqrt(1 - (f = f / g - 1) * f) + a; |
| 1551 | 1460 | }; |
| 1552 | - | |
| 1553 | 1461 | debounce(() => { |
| 1554 | 1462 | const $el = jQuery('<span />').css({ |
| 1555 | 1463 | width: 1, |
| 1556 | 1464 | height: 1 |
| @@ -1578,20 +1486,18 @@ | ||
| 1578 | 1486 | easing: '_customEasing' |
| 1579 | 1487 | }); |
| 1580 | 1488 | }, results.result > 0 ? 1000 : 10)(); |
| 1581 | 1489 | }; |
| 1490 | + | |
| 1582 | 1491 | /** |
| 1583 | 1492 | * Render HTML elements. |
| 1584 | 1493 | * |
| 1585 | 1494 | */ |
| 1586 | 1495 | |
| 1587 | - | |
| 1588 | 1496 | let percentResult = percentage; |
| 1589 | - | |
| 1590 | 1497 | if (!Number.isInteger(percentage)) { |
| 1591 | 1498 | percentResult = parseFloat(percentage).toFixed(2); |
| 1592 | 1499 | } |
| 1593 | - | |
| 1594 | 1500 | const border = 10; |
| 1595 | 1501 | const width = 200; |
| 1596 | 1502 | const radius = width / 2; |
| 1597 | 1503 | const r = (width - border) / 2; |
| @@ -1602,9 +1508,8 @@ | ||
| 1602 | 1508 | strokeDashoffset: offset |
| 1603 | 1509 | }; |
| 1604 | 1510 | const passingGradeValue = parseFloat(results.passingGrade || passingGrade); |
| 1605 | 1511 | let graduation = ''; |
| 1606 | - | |
| 1607 | 1512 | if (results.graduation) { |
| 1608 | 1513 | graduation = results.graduation; |
| 1609 | 1514 | } else if (percentResult >= passingGradeValue) { |
| 1610 | 1515 | graduation = 'passed'; |
| @@ -1610,32 +1515,29 @@ | ||
| 1610 | 1515 | graduation = 'passed'; |
| 1611 | 1516 | } else { |
| 1612 | 1517 | graduation = 'failed'; |
| 1613 | 1518 | } |
| 1614 | - | |
| 1615 | 1519 | let message = ''; |
| 1616 | - | |
| 1617 | 1520 | if (results.graduationText) { |
| 1618 | 1521 | message = results.graduationText; |
| 1619 | 1522 | } else if (graduation === 'passed') { |
| 1620 | - message = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Passed', 'learnpress'); | |
| 1523 | + message = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Passed', 'learnpress'); | |
| 1621 | 1524 | } else { |
| 1622 | - message = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Failed', 'learnpress'); | |
| 1525 | + message = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Failed', 'learnpress'); | |
| 1623 | 1526 | } |
| 1624 | - | |
| 1625 | 1527 | const classNames = ['quiz-result', graduation]; |
| 1626 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1528 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1627 | 1529 | className: classNames.join(' ') |
| 1628 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h3", { | |
| 1530 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h3", { | |
| 1629 | 1531 | className: "result-heading" |
| 1630 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Your Result', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1532 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Your Result', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1631 | 1533 | id: "quizResultGrade", |
| 1632 | 1534 | className: "result-grade" |
| 1633 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", { | |
| 1535 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", { | |
| 1634 | 1536 | className: "circle-progress-bar", |
| 1635 | 1537 | width: width, |
| 1636 | 1538 | height: width |
| 1637 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("circle", { | |
| 1539 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("circle", { | |
| 1638 | 1540 | className: "circle-progress-bar__circle", |
| 1639 | 1541 | stroke: "", |
| 1640 | 1542 | strokeWidth: border, |
| 1641 | 1543 | style: styles, |
| @@ -1642,34 +1544,36 @@ | ||
| 1642 | 1544 | fill: "transparent", |
| 1643 | 1545 | r: r, |
| 1644 | 1546 | cx: radius, |
| 1645 | 1547 | cy: radius |
| 1646 | - })), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1548 | + })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1647 | 1549 | className: "result-achieved" |
| 1648 | - }, `${percentResult}%`), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1550 | + }, `${percentResult}%`), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { | |
| 1649 | 1551 | className: "result-require" |
| 1650 | - }, passingGradeValue + '%' || 0)), done && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", { | |
| 1552 | + }, passingGradeValue + '%' || 0)), done && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", { | |
| 1651 | 1553 | className: "result-message" |
| 1652 | - }, message), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("ul", { | |
| 1554 | + }, message), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("ul", { | |
| 1653 | 1555 | className: "result-statistic" |
| 1654 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1556 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1655 | 1557 | className: "result-statistic-field result-time-spend" |
| 1656 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Time spent', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.timeSpend)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1558 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Time spent', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.timeSpend)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1657 | 1559 | className: "result-statistic-field result-point" |
| 1658 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Points', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.userMark, " / ", results.mark)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1560 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Points', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.userMark, " / ", results.mark)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1659 | 1561 | className: "result-statistic-field result-questions" |
| 1660 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Questions', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionCount)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1562 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Questions', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionCount)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1661 | 1563 | className: "result-statistic-field result-questions-correct" |
| 1662 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Correct', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionCorrect)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1564 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Correct', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionCorrect)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1663 | 1565 | className: "result-statistic-field result-questions-wrong" |
| 1664 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Wrong', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionWrong)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1566 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Wrong', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionWrong)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1665 | 1567 | className: "result-statistic-field result-questions-skipped" |
| 1666 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Skipped', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionEmpty)))); | |
| 1568 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Skipped', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.questionEmpty)), typeof results.minusPoint !== 'undefined' && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { | |
| 1569 | + className: "result-statistic-field result-questions-minus" | |
| 1570 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Minus points', 'learnpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("p", null, results.minusPoint)))); | |
| 1571 | + function timeDifference(earlierDate, laterDate) { | |
| 1572 | + const oDiff = new Object(); | |
| 1667 | 1573 | |
| 1668 | - function timeDifference(earlierDate, laterDate) { | |
| 1669 | - const oDiff = new Object(); // Calculate Differences | |
| 1574 | + // Calculate Differences | |
| 1670 | 1575 | // ------------------------------------------------------------------- // |
| 1671 | - | |
| 1672 | 1576 | let nTotalDiff = laterDate - earlierDate; |
| 1673 | 1577 | oDiff.days = Math.floor(nTotalDiff / 1000 / 60 / 60 / 24); |
| 1674 | 1578 | nTotalDiff -= oDiff.days * 1000 * 60 * 60 * 24; |
| 1675 | 1579 | oDiff.hours = Math.floor(nTotalDiff / 1000 / 60 / 60); |
| @@ -1675,72 +1579,71 @@ | ||
| 1675 | 1579 | oDiff.hours = Math.floor(nTotalDiff / 1000 / 60 / 60); |
| 1676 | 1580 | nTotalDiff -= oDiff.hours * 1000 * 60 * 60; |
| 1677 | 1581 | oDiff.minutes = Math.floor(nTotalDiff / 1000 / 60); |
| 1678 | 1582 | nTotalDiff -= oDiff.minutes * 1000 * 60; |
| 1679 | - oDiff.seconds = Math.floor(nTotalDiff / 1000); // ------------------------------------------------------------------- // | |
| 1583 | + oDiff.seconds = Math.floor(nTotalDiff / 1000); | |
| 1584 | + // ------------------------------------------------------------------- // | |
| 1585 | + | |
| 1680 | 1586 | // Format Duration |
| 1681 | 1587 | // ------------------------------------------------------------------- // |
| 1682 | 1588 | // Format Hours |
| 1683 | - | |
| 1684 | 1589 | let hourtext = '00'; |
| 1685 | - | |
| 1686 | 1590 | if (oDiff.days > 0) { |
| 1687 | 1591 | hourtext = String(oDiff.days); |
| 1688 | 1592 | } |
| 1689 | - | |
| 1690 | 1593 | if (hourtext.length == 1) { |
| 1691 | 1594 | hourtext = '0' + hourtext; |
| 1692 | - } // Format Minutes | |
| 1595 | + } | |
| 1693 | 1596 | |
| 1694 | - | |
| 1597 | + // Format Minutes | |
| 1695 | 1598 | let mintext = '00'; |
| 1696 | - | |
| 1697 | 1599 | if (oDiff.minutes > 0) { |
| 1698 | 1600 | mintext = String(oDiff.minutes); |
| 1699 | 1601 | } |
| 1700 | - | |
| 1701 | 1602 | if (mintext.length == 1) { |
| 1702 | 1603 | mintext = '0' + mintext; |
| 1703 | - } // Format Seconds | |
| 1604 | + } | |
| 1704 | 1605 | |
| 1705 | - | |
| 1606 | + // Format Seconds | |
| 1706 | 1607 | let sectext = '00'; |
| 1707 | - | |
| 1708 | 1608 | if (oDiff.seconds > 0) { |
| 1709 | 1609 | sectext = String(oDiff.seconds); |
| 1710 | 1610 | } |
| 1711 | - | |
| 1712 | 1611 | if (sectext.length == 1) { |
| 1713 | 1612 | sectext = '0' + sectext; |
| 1714 | - } // Set Duration | |
| 1715 | - | |
| 1716 | - | |
| 1613 | + } | |
| 1614 | + // Set Duration | |
| 1717 | 1615 | const sDuration = hourtext + ':' + mintext + ':' + sectext; |
| 1718 | - oDiff.duration = sDuration; // ------------------------------------------------------------------- // | |
| 1616 | + oDiff.duration = sDuration; | |
| 1617 | + // ------------------------------------------------------------------- // | |
| 1719 | 1618 | |
| 1720 | 1619 | return oDiff; |
| 1721 | 1620 | } |
| 1722 | 1621 | }; |
| 1622 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Result); | |
| 1723 | 1623 | |
| 1724 | -/* harmony default export */ __webpack_exports__["default"] = (Result); | |
| 1624 | +/***/ }, | |
| 1725 | 1625 | |
| 1726 | -/***/ }), | |
| 1727 | - | |
| 1728 | -/***/ "./assets/src/apps/js/frontend/quiz/components/status/index.js": | |
| 1626 | +/***/ "./assets/src/apps/js/frontend/quiz/components/status/index.js" | |
| 1729 | 1627 | /*!*********************************************************************!*\ |
| 1730 | 1628 | !*** ./assets/src/apps/js/frontend/quiz/components/status/index.js ***! |
| 1731 | 1629 | \*********************************************************************/ |
| 1732 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1630 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1733 | 1631 | |
| 1734 | 1632 | "use strict"; |
| 1735 | 1633 | __webpack_require__.r(__webpack_exports__); |
| 1736 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1737 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 1738 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1739 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); | |
| 1740 | -/* harmony import */ var _timer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../timer */ "./assets/src/apps/js/frontend/quiz/components/timer/index.js"); | |
| 1741 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 1742 | -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); | |
| 1634 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 1635 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1636 | +/* harmony export */ }); | |
| 1637 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 1638 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 1639 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1640 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); | |
| 1641 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1642 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); | |
| 1643 | +/* harmony import */ var _timer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../timer */ "./assets/src/apps/js/frontend/quiz/components/timer/index.js"); | |
| 1644 | +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); | |
| 1645 | +/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__); | |
| 1743 | 1646 | |
| 1744 | 1647 | |
| 1745 | 1648 | |
| 1746 | 1649 | |
| @@ -1748,53 +1651,38 @@ | ||
| 1748 | 1651 | const $ = jQuery; |
| 1749 | 1652 | const { |
| 1750 | 1653 | debounce |
| 1751 | 1654 | } = lodash; |
| 1752 | - | |
| 1753 | 1655 | const Status = () => { |
| 1754 | 1656 | const { |
| 1755 | 1657 | submitQuiz |
| 1756 | - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('learnpress/quiz'); | |
| 1757 | - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { | |
| 1658 | + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.dispatch)('learnpress/quiz'); | |
| 1659 | + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { | |
| 1758 | 1660 | const $pc = $('#popup-content'); |
| 1759 | - | |
| 1760 | 1661 | if (!$pc.length) { |
| 1761 | 1662 | return; |
| 1762 | 1663 | } |
| 1763 | - | |
| 1764 | 1664 | const $sc = $pc.find('.content-item-scrollable:eq(1)'); |
| 1765 | - const $ciw = $pc.find('.content-item-wrap'); | |
| 1766 | 1665 | const $qs = $pc.find('.quiz-status'); |
| 1767 | 1666 | const pcTop = $qs.offset().top - 92; |
| 1768 | 1667 | let isFixed = false; |
| 1769 | - let marginLeft = '-' + $ciw.css('margin-left'); | |
| 1770 | - $(window).on('resize.refresh-quiz-stauts-bar', debounce(function () { | |
| 1771 | - marginLeft = '-' + $ciw.css('margin-left'); | |
| 1772 | - $qs.css({ | |
| 1773 | - 'margin-left': marginLeft, | |
| 1774 | - 'margin-right': marginLeft | |
| 1775 | - }); | |
| 1776 | - }, 100)).trigger('resize.refresh-quiz-stauts-bar'); | |
| 1668 | + | |
| 1777 | 1669 | /** |
| 1778 | 1670 | * Check when status bar is stopped in the top |
| 1779 | 1671 | * to add new class into html |
| 1780 | 1672 | */ |
| 1781 | - | |
| 1782 | 1673 | $sc.on('scroll', () => { |
| 1783 | 1674 | if ($sc.scrollTop() >= pcTop) { |
| 1784 | 1675 | if (isFixed) { |
| 1785 | 1676 | return; |
| 1786 | 1677 | } |
| 1787 | - | |
| 1788 | 1678 | isFixed = true; |
| 1789 | 1679 | } else { |
| 1790 | 1680 | if (!isFixed) { |
| 1791 | 1681 | return; |
| 1792 | 1682 | } |
| 1793 | - | |
| 1794 | 1683 | isFixed = false; |
| 1795 | 1684 | } |
| 1796 | - | |
| 1797 | 1685 | if (isFixed) { |
| 1798 | 1686 | $pc.addClass('fixed-quiz-status'); |
| 1799 | 1687 | } else { |
| 1800 | 1688 | $pc.removeClass('fixed-quiz-status'); |
| @@ -1800,38 +1688,34 @@ | ||
| 1800 | 1688 | $pc.removeClass('fixed-quiz-status'); |
| 1801 | 1689 | } |
| 1802 | 1690 | }); |
| 1803 | 1691 | }, []); |
| 1692 | + | |
| 1804 | 1693 | /** |
| 1805 | 1694 | * Submit question to record results. |
| 1806 | 1695 | */ |
| 1807 | - | |
| 1808 | 1696 | const submit = () => { |
| 1809 | 1697 | const { |
| 1810 | 1698 | confirm |
| 1811 | - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/modal'); | |
| 1812 | - | |
| 1813 | - if ('no' === confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Are you sure to submit quiz?', 'learnpress'), submit)) { | |
| 1699 | + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/modal'); | |
| 1700 | + if ('no' === confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Are you sure to submit the quiz?', 'learnpress'), submit)) { | |
| 1814 | 1701 | return; |
| 1815 | 1702 | } |
| 1816 | - | |
| 1817 | 1703 | submitQuiz(); |
| 1818 | 1704 | }; |
| 1819 | - | |
| 1820 | 1705 | const getMark = () => { |
| 1821 | - const answered = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz').getData('answered'); | |
| 1706 | + const answered = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/quiz').getData('answered'); | |
| 1822 | 1707 | return Object.values(answered).reduce((m, r) => { |
| 1823 | 1708 | return m + r.mark; |
| 1824 | 1709 | }, 0); |
| 1825 | 1710 | }; |
| 1826 | - | |
| 1827 | 1711 | const { |
| 1828 | 1712 | getData, |
| 1829 | 1713 | getUserMark |
| 1830 | - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz'); | |
| 1714 | + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/quiz'); | |
| 1831 | 1715 | const currentPage = getData('currentPage'); |
| 1832 | 1716 | const questionsPerPage = getData('questionsPerPage'); |
| 1833 | - const questionsCount = getData('questionIds').length; | |
| 1717 | + const questionsCount = getData('numberQuestionsToDo'); | |
| 1834 | 1718 | const submitting = getData('submitting'); |
| 1835 | 1719 | const duration = getData('duration'); |
| 1836 | 1720 | const userMark = getUserMark(); |
| 1837 | 1721 | const classNames = ['quiz-status']; |
| @@ -1838,59 +1722,59 @@ | ||
| 1838 | 1722 | const start = (currentPage - 1) * questionsPerPage + 1; |
| 1839 | 1723 | let end = start + questionsPerPage - 1; |
| 1840 | 1724 | let indexHtml = ''; |
| 1841 | 1725 | end = Math.min(end, questionsCount); |
| 1842 | - | |
| 1843 | 1726 | if (submitting) { |
| 1844 | 1727 | classNames.push('submitting'); |
| 1845 | 1728 | } |
| 1846 | - | |
| 1847 | 1729 | if (end < questionsCount) { |
| 1848 | 1730 | if (questionsPerPage > 1) { |
| 1849 | - indexHtml = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Question <span>%d to %d of %d</span>', 'learnpress'), start, end, questionsCount); | |
| 1731 | + indexHtml = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Question <span>%d to %d of %d</span>', 'learnpress'), start, end, questionsCount); | |
| 1850 | 1732 | } else { |
| 1851 | - indexHtml = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Question <span>%d of %d</span>', 'learnpress'), start, questionsCount); | |
| 1733 | + indexHtml = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Question <span>%d of %d</span>', 'learnpress'), start, questionsCount); | |
| 1852 | 1734 | } |
| 1853 | 1735 | } else { |
| 1854 | - indexHtml = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Question <span>%d to %d</span>', 'learnpress'), start, end); | |
| 1736 | + indexHtml = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Question <span>%d of %d</span>', 'learnpress'), start, end); | |
| 1855 | 1737 | } |
| 1856 | - | |
| 1857 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1738 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1858 | 1739 | className: classNames.join(' ') |
| 1859 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1740 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1860 | 1741 | className: "questions-index", |
| 1861 | 1742 | dangerouslySetInnerHTML: { |
| 1862 | 1743 | __html: indexHtml |
| 1863 | 1744 | } |
| 1864 | - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1745 | + }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1865 | 1746 | className: "current-point" |
| 1866 | - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Earned Point: %s', 'learnpress'), userMark)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1747 | + }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Earned Point: %s', 'learnpress'), userMark)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1867 | 1748 | className: "submit-quiz" |
| 1868 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 1749 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { | |
| 1869 | 1750 | className: "lp-button", |
| 1870 | 1751 | id: "button-submit-quiz", |
| 1871 | 1752 | onClick: submit |
| 1872 | - }, !submitting ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Finish Quiz', 'learnpress') : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Submitting...', 'learnpress'))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_timer__WEBPACK_IMPORTED_MODULE_2__["default"], null)))); | |
| 1753 | + }, !submitting ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Finish Quiz', 'learnpress') : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('Submitting…', 'learnpress'))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_timer__WEBPACK_IMPORTED_MODULE_3__["default"], null)))); | |
| 1873 | 1754 | }; |
| 1755 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Status); | |
| 1874 | 1756 | |
| 1875 | -/* harmony default export */ __webpack_exports__["default"] = (Status); | |
| 1757 | +/***/ }, | |
| 1876 | 1758 | |
| 1877 | -/***/ }), | |
| 1878 | - | |
| 1879 | -/***/ "./assets/src/apps/js/frontend/quiz/components/timer/index.js": | |
| 1759 | +/***/ "./assets/src/apps/js/frontend/quiz/components/timer/index.js" | |
| 1880 | 1760 | /*!********************************************************************!*\ |
| 1881 | 1761 | !*** ./assets/src/apps/js/frontend/quiz/components/timer/index.js ***! |
| 1882 | 1762 | \********************************************************************/ |
| 1883 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1763 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1884 | 1764 | |
| 1885 | 1765 | "use strict"; |
| 1886 | 1766 | __webpack_require__.r(__webpack_exports__); |
| 1887 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1888 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 1889 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1890 | -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); | |
| 1767 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 1768 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1769 | +/* harmony export */ }); | |
| 1770 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 1771 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 1772 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1773 | +/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); | |
| 1774 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); | |
| 1775 | +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); | |
| 1891 | 1776 | |
| 1892 | - | |
| 1893 | 1777 | /** |
| 1894 | 1778 | * Edit: React hook. |
| 1895 | 1779 | * |
| 1896 | 1780 | * @author Nhamdv - ThimPress |
| @@ -1896,33 +1780,26 @@ | ||
| 1896 | 1780 | * @author Nhamdv - ThimPress |
| 1897 | 1781 | */ |
| 1898 | 1782 | |
| 1899 | 1783 | |
| 1900 | - | |
| 1901 | 1784 | const Timer = () => { |
| 1902 | 1785 | const { |
| 1903 | 1786 | getData |
| 1904 | - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz'); | |
| 1787 | + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('learnpress/quiz'); | |
| 1905 | 1788 | const { |
| 1906 | 1789 | submitQuiz |
| 1907 | - } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('learnpress/quiz'); | |
| 1908 | - const totalTime = getData('totalTime'); | |
| 1790 | + } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.dispatch)('learnpress/quiz'); | |
| 1791 | + let totalTime = getData('totalTime'); | |
| 1909 | 1792 | const durationTime = getData('duration'); |
| 1910 | - /* const endTime = getData( 'endTime' ); | |
| 1911 | - const d1 = new Date( endTime.replace( /-/g, '/' ) ); | |
| 1912 | - const d2 = new Date(); | |
| 1913 | - const tz = new Date().getTimezoneOffset(); | |
| 1914 | - const t = parseInt( ( d1.getTime() / 1000 ) - ( ( d2.getTime() / 1000 ) + ( tz * 60 ) ) );*/ | |
| 1915 | - | |
| 1916 | - const [seconds, setSeconds] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(totalTime); | |
| 1917 | - let [timeSpend, setTimeSpend] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); | |
| 1918 | - const limitTime = totalTime > 0; | |
| 1919 | - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { | |
| 1793 | + const timeSpendG = getData('timeSpend'); | |
| 1794 | + const [seconds, setSeconds] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(totalTime); | |
| 1795 | + let [timeSpend, setTimeSpend] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(timeSpendG); | |
| 1796 | + (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { | |
| 1920 | 1797 | const myInterval = setInterval(() => { |
| 1921 | - if (limitTime) { | |
| 1798 | + if (durationTime > 0) { | |
| 1922 | 1799 | let remainSeconds = seconds; |
| 1923 | 1800 | remainSeconds -= 1; |
| 1924 | - | |
| 1801 | + remainSeconds = wp.hooks.applyFilters('js-lp-quiz-remaining_time', remainSeconds, durationTime); | |
| 1925 | 1802 | if (remainSeconds > 0) { |
| 1926 | 1803 | setSeconds(remainSeconds); |
| 1927 | 1804 | timeSpend++; |
| 1928 | 1805 | setTimeSpend(durationTime - remainSeconds); |
| @@ -1938,14 +1815,14 @@ | ||
| 1938 | 1815 | } |
| 1939 | 1816 | }, 1000); |
| 1940 | 1817 | return () => clearInterval(myInterval); |
| 1941 | 1818 | }, [seconds, timeSpend]); |
| 1942 | - | |
| 1943 | - const formatTime = function () { | |
| 1944 | - let separator = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ':'; | |
| 1819 | + const formatTime = (separator = ':') => { | |
| 1945 | 1820 | const t = []; |
| 1946 | 1821 | let m; |
| 1947 | - | |
| 1822 | + if (timeSpendG) { | |
| 1823 | + totalTime = timeSpendG; | |
| 1824 | + } | |
| 1948 | 1825 | if (totalTime < 3600) { |
| 1949 | 1826 | t.push((seconds - seconds % 60) / 60); |
| 1950 | 1827 | t.push(seconds % 60); |
| 1951 | 1828 | } else if (totalTime) { |
| @@ -1953,58 +1830,60 @@ | ||
| 1953 | 1830 | m = seconds % 3600; |
| 1954 | 1831 | t.push((m - m % 60) / 60); |
| 1955 | 1832 | t.push(m % 60); |
| 1956 | 1833 | } |
| 1957 | - | |
| 1958 | 1834 | return t.map(a => { |
| 1959 | 1835 | return a < 10 ? `0${a}` : a; |
| 1960 | 1836 | }).join(separator); |
| 1961 | 1837 | }; |
| 1962 | - | |
| 1963 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1838 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { | |
| 1964 | 1839 | className: "countdown" |
| 1965 | - }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("i", { | |
| 1966 | - className: "fas fa-stopwatch" | |
| 1967 | - }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, formatTime()), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("input", { | |
| 1840 | + }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("i", { | |
| 1841 | + className: "lp-icon-stopwatch" | |
| 1842 | + }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, formatTime()), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("input", { | |
| 1968 | 1843 | type: "hidden", |
| 1969 | 1844 | name: "lp-quiz-time-spend", |
| 1970 | 1845 | value: timeSpend |
| 1971 | 1846 | })); |
| 1972 | 1847 | }; |
| 1848 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Timer); | |
| 1973 | 1849 | |
| 1974 | -/* harmony default export */ __webpack_exports__["default"] = (Timer); | |
| 1850 | +/***/ }, | |
| 1975 | 1851 | |
| 1976 | -/***/ }), | |
| 1977 | - | |
| 1978 | -/***/ "./assets/src/apps/js/frontend/quiz/components/title/index.js": | |
| 1852 | +/***/ "./assets/src/apps/js/frontend/quiz/components/title/index.js" | |
| 1979 | 1853 | /*!********************************************************************!*\ |
| 1980 | 1854 | !*** ./assets/src/apps/js/frontend/quiz/components/title/index.js ***! |
| 1981 | 1855 | \********************************************************************/ |
| 1982 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1856 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1983 | 1857 | |
| 1984 | 1858 | "use strict"; |
| 1985 | 1859 | __webpack_require__.r(__webpack_exports__); |
| 1986 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 1987 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 1860 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 1861 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1862 | +/* harmony export */ }); | |
| 1863 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 1864 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 1988 | 1865 | |
| 1989 | - | |
| 1990 | 1866 | const Title = () => { |
| 1991 | - return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h3", null, "The title"); | |
| 1867 | + return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h3", null, "The title"); | |
| 1992 | 1868 | }; |
| 1869 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Title); | |
| 1993 | 1870 | |
| 1994 | -/* harmony default export */ __webpack_exports__["default"] = (Title); | |
| 1871 | +/***/ }, | |
| 1995 | 1872 | |
| 1996 | -/***/ }), | |
| 1997 | - | |
| 1998 | -/***/ "./assets/src/apps/js/frontend/quiz/index.js": | |
| 1873 | +/***/ "./assets/src/apps/js/frontend/quiz/index.js" | |
| 1999 | 1874 | /*!***************************************************!*\ |
| 2000 | 1875 | !*** ./assets/src/apps/js/frontend/quiz/index.js ***! |
| 2001 | 1876 | \***************************************************/ |
| 2002 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1877 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2003 | 1878 | |
| 2004 | 1879 | "use strict"; |
| 2005 | 1880 | __webpack_require__.r(__webpack_exports__); |
| 2006 | -/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js"); | |
| 1881 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 1882 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 1883 | +/* harmony export */ }); | |
| 1884 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 1885 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 2007 | 1886 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); |
| 2008 | 1887 | /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); |
| 2009 | 1888 | /* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/compose */ "@wordpress/compose"); |
| 2010 | 1889 | /* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_compose__WEBPACK_IMPORTED_MODULE_2__); |
| @@ -2017,21 +1896,14 @@ | ||
| 2017 | 1896 | |
| 2018 | 1897 | |
| 2019 | 1898 | |
| 2020 | 1899 | |
| 2021 | - | |
| 2022 | 1900 | const { |
| 2023 | 1901 | chunk |
| 2024 | 1902 | } = lodash; |
| 2025 | - | |
| 2026 | 1903 | class Quiz extends _wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Component { |
| 2027 | 1904 | constructor(props) { |
| 2028 | 1905 | super(...arguments); |
| 2029 | - | |
| 2030 | - (0,_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__["default"])(this, "startQuiz", event => { | |
| 2031 | - this.props.startQuiz(); | |
| 2032 | - }); | |
| 2033 | - | |
| 2034 | 1906 | this.state = { |
| 2035 | 1907 | currentPage: 1, |
| 2036 | 1908 | numPages: 0, |
| 2037 | 1909 | pages: [] |
| @@ -2036,9 +1908,8 @@ | ||
| 2036 | 1908 | numPages: 0, |
| 2037 | 1909 | pages: [] |
| 2038 | 1910 | }; |
| 2039 | 1911 | } |
| 2040 | - | |
| 2041 | 1912 | componentDidMount() { |
| 2042 | 1913 | const { |
| 2043 | 1914 | settings, |
| 2044 | 1915 | setQuizData |
| @@ -2051,41 +1922,40 @@ | ||
| 2051 | 1922 | settings.currentPage = 1; |
| 2052 | 1923 | settings.numPages = chunks.length; |
| 2053 | 1924 | settings.pages = chunks; |
| 2054 | 1925 | const answered = settings.id ? localStorage.getItem(`LP_Quiz_${settings.id}_Answered`) : false; |
| 2055 | - | |
| 2056 | 1926 | if (answered) { |
| 2057 | 1927 | settings.answered = JSON.parse(answered); |
| 2058 | 1928 | } |
| 2059 | - | |
| 2060 | 1929 | setQuizData(settings); |
| 2061 | 1930 | } |
| 2062 | - | |
| 2063 | 1931 | componentDidUpdate(prevProps, prevState, snapshot) { |
| 2064 | 1932 | const { |
| 2065 | 1933 | status |
| 2066 | 1934 | } = prevProps; |
| 2067 | 1935 | const elQuizContent = document.querySelector('.quiz-content'); |
| 2068 | - | |
| 2069 | 1936 | if (status !== undefined && elQuizContent) { |
| 2070 | 1937 | elQuizContent.style.display = 'none'; |
| 2071 | 1938 | } |
| 2072 | 1939 | } |
| 2073 | - | |
| 1940 | + startQuiz = event => { | |
| 1941 | + this.props.startQuiz(); | |
| 1942 | + }; | |
| 2074 | 1943 | render() { |
| 2075 | 1944 | const { |
| 2076 | 1945 | status, |
| 2077 | - isReviewing | |
| 1946 | + isReviewing, | |
| 1947 | + answered | |
| 2078 | 1948 | } = this.props; |
| 1949 | + wp.hooks.doAction('lp-js-quiz-answer', answered, status); | |
| 2079 | 1950 | const isA = -1 !== ['', 'completed', 'viewed'].indexOf(status) || !status; |
| 2080 | - const notStarted = -1 !== ['', 'viewed', undefined].indexOf(status) || !status; // Just render content if status !== undefined (meant all data loaded) | |
| 1951 | + const notStarted = -1 !== ['', 'viewed', undefined].indexOf(status) || !status; | |
| 2081 | 1952 | |
| 2082 | - return undefined !== status && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)("div", null, !isReviewing && 'completed' === status && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Result, null), !isReviewing && notStarted && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Meta, null), 'started' === status && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Status, null), (-1 !== ['completed', 'started'].indexOf(status) || isReviewing) && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Questions, null), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Buttons, null), isA && !isReviewing && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Attempts, null))); | |
| 1953 | + // Just render content if status !== undefined (meant all data loaded) | |
| 1954 | + return undefined !== status && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, !isReviewing && 'completed' === status && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Result, null), !isReviewing && notStarted && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Meta, null), 'started' === status && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Status, null), (-1 !== ['completed', 'started'].indexOf(status) || isReviewing) && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Questions, null), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Buttons, null), isA && !isReviewing && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components__WEBPACK_IMPORTED_MODULE_4__.Attempts, null))); | |
| 2083 | 1955 | } |
| 2084 | - | |
| 2085 | 1956 | } |
| 2086 | - | |
| 2087 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_2__.compose)([(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withSelect)(select => { | |
| 1957 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_2__.compose)([(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.withSelect)(select => { | |
| 2088 | 1958 | const { |
| 2089 | 1959 | getQuestions, |
| 2090 | 1960 | getData |
| 2091 | 1961 | } = select('learnpress/quiz'); |
| @@ -2109,36 +1979,37 @@ | ||
| 2109 | 1979 | startQuiz |
| 2110 | 1980 | }; |
| 2111 | 1981 | })])(Quiz)); |
| 2112 | 1982 | |
| 2113 | -/***/ }), | |
| 1983 | +/***/ }, | |
| 2114 | 1984 | |
| 2115 | -/***/ "./assets/src/apps/js/frontend/quiz/store/actions.js": | |
| 1985 | +/***/ "./assets/src/apps/js/frontend/quiz/store/actions.js" | |
| 2116 | 1986 | /*!***********************************************************!*\ |
| 2117 | 1987 | !*** ./assets/src/apps/js/frontend/quiz/store/actions.js ***! |
| 2118 | 1988 | \***********************************************************/ |
| 2119 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 1989 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2120 | 1990 | |
| 2121 | 1991 | "use strict"; |
| 2122 | 1992 | __webpack_require__.r(__webpack_exports__); |
| 2123 | 1993 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2124 | -/* harmony export */ "__requestBeforeStartQuiz": function() { return /* binding */ __requestBeforeStartQuiz; }, | |
| 2125 | -/* harmony export */ "__requestCheckAnswerSuccess": function() { return /* binding */ __requestCheckAnswerSuccess; }, | |
| 2126 | -/* harmony export */ "__requestShowHintSuccess": function() { return /* binding */ __requestShowHintSuccess; }, | |
| 2127 | -/* harmony export */ "__requestStartQuizSuccess": function() { return /* binding */ __requestStartQuizSuccess; }, | |
| 2128 | -/* harmony export */ "__requestSubmitQuiz": function() { return /* binding */ __requestSubmitQuiz; }, | |
| 2129 | -/* harmony export */ "__requestSubmitQuizSuccess": function() { return /* binding */ __requestSubmitQuizSuccess; }, | |
| 2130 | -/* harmony export */ "checkAnswer": function() { return /* binding */ checkAnswer; }, | |
| 2131 | -/* harmony export */ "markQuestionRendered": function() { return /* binding */ markQuestionRendered; }, | |
| 2132 | -/* harmony export */ "sendKey": function() { return /* binding */ sendKey; }, | |
| 2133 | -/* harmony export */ "setCurrentPage": function() { return /* binding */ setCurrentPage; }, | |
| 2134 | -/* harmony export */ "setCurrentQuestion": function() { return /* binding */ setCurrentQuestion; }, | |
| 2135 | -/* harmony export */ "setQuizData": function() { return /* binding */ setQuizData; }, | |
| 2136 | -/* harmony export */ "setQuizMode": function() { return /* binding */ setQuizMode; }, | |
| 2137 | -/* harmony export */ "showHint": function() { return /* binding */ showHint; }, | |
| 2138 | -/* harmony export */ "startQuiz": function() { return /* binding */ startQuiz; }, | |
| 2139 | -/* harmony export */ "submitQuiz": function() { return /* binding */ submitQuiz; }, | |
| 2140 | -/* harmony export */ "updateUserQuestionAnswers": function() { return /* binding */ updateUserQuestionAnswers; } | |
| 1994 | +/* harmony export */ __requestBeforeStartQuiz: () => (/* binding */ __requestBeforeStartQuiz), | |
| 1995 | +/* harmony export */ __requestCheckAnswerSuccess: () => (/* binding */ __requestCheckAnswerSuccess), | |
| 1996 | +/* harmony export */ __requestShowHintSuccess: () => (/* binding */ __requestShowHintSuccess), | |
| 1997 | +/* harmony export */ __requestStartQuizSuccess: () => (/* binding */ __requestStartQuizSuccess), | |
| 1998 | +/* harmony export */ __requestSubmitQuiz: () => (/* binding */ __requestSubmitQuiz), | |
| 1999 | +/* harmony export */ __requestSubmitQuizSuccess: () => (/* binding */ __requestSubmitQuizSuccess), | |
| 2000 | +/* harmony export */ checkAnswer: () => (/* binding */ checkAnswer), | |
| 2001 | +/* harmony export */ markQuestionRendered: () => (/* binding */ markQuestionRendered), | |
| 2002 | +/* harmony export */ sendKey: () => (/* binding */ sendKey), | |
| 2003 | +/* harmony export */ setCurrentPage: () => (/* binding */ setCurrentPage), | |
| 2004 | +/* harmony export */ setCurrentQuestion: () => (/* binding */ setCurrentQuestion), | |
| 2005 | +/* harmony export */ setQuizData: () => (/* binding */ setQuizData), | |
| 2006 | +/* harmony export */ setQuizMode: () => (/* binding */ setQuizMode), | |
| 2007 | +/* harmony export */ showHint: () => (/* binding */ showHint), | |
| 2008 | +/* harmony export */ startQuiz: () => (/* binding */ startQuiz), | |
| 2009 | +/* harmony export */ submitQuiz: () => (/* binding */ submitQuiz), | |
| 2010 | +/* harmony export */ updateUserQuestionAnswers: () => (/* binding */ updateUserQuestionAnswers), | |
| 2011 | +/* harmony export */ updateUserQuestionFibAnswers: () => (/* binding */ updateUserQuestionFibAnswers) | |
| 2141 | 2012 | /* harmony export */ }); |
| 2142 | 2013 | /* harmony import */ var _learnpress_data_controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @learnpress/data-controls */ "@learnpress/data-controls"); |
| 2143 | 2014 | /* harmony import */ var _learnpress_data_controls__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_learnpress_data_controls__WEBPACK_IMPORTED_MODULE_0__); |
| 2144 | 2015 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| @@ -2144,10 +2015,8 @@ | ||
| 2144 | 2015 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 2145 | 2016 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); |
| 2146 | 2017 | |
| 2147 | 2018 | |
| 2148 | - | |
| 2149 | - | |
| 2150 | 2019 | function _dispatch() { |
| 2151 | 2020 | const args = [].slice.call(arguments, 2); |
| 2152 | 2021 | const d = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)(arguments[0]); |
| 2153 | 2022 | const f = arguments[1]; |
| @@ -2152,9 +2021,8 @@ | ||
| 2152 | 2021 | const d = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)(arguments[0]); |
| 2153 | 2022 | const f = arguments[1]; |
| 2154 | 2023 | d[f](...args); |
| 2155 | 2024 | } |
| 2156 | - | |
| 2157 | 2025 | const { |
| 2158 | 2026 | camelCaseDashObjectKeys, |
| 2159 | 2027 | Hook |
| 2160 | 2028 | } = LP; |
| @@ -2160,13 +2028,11 @@ | ||
| 2160 | 2028 | } = LP; |
| 2161 | 2029 | /** |
| 2162 | 2030 | * Set user data for app. |
| 2163 | 2031 | * |
| 2164 | - * @param key | |
| 2165 | - * @param data | |
| 2166 | - * @return {{type: string, data: *}} | |
| 2032 | + * @param key | |
| 2033 | + * @param data | |
| 2167 | 2034 | */ |
| 2168 | - | |
| 2169 | 2035 | function setQuizData(key, data) { |
| 2170 | 2036 | if (typeof key === 'string') { |
| 2171 | 2037 | data = { |
| 2172 | 2038 | [key]: data |
| @@ -2172,27 +2038,20 @@ | ||
| 2172 | 2038 | [key]: data |
| 2173 | 2039 | }; |
| 2174 | 2040 | } else { |
| 2175 | 2041 | data = key; |
| 2176 | - } // Save all data for no required enroll available | |
| 2177 | - | |
| 2178 | - /*if ( lpQuizSettings.checkNorequizenroll === 1 && window.localStorage.getItem( 'quiz_userdata_' + lpQuizSettings.id ) !== null ) { | |
| 2179 | - data = JSON.parse( window.localStorage.getItem( 'quiz_userdata_' + lpQuizSettings.id ) ); | |
| 2180 | - }*/ | |
| 2181 | - | |
| 2182 | - | |
| 2042 | + } | |
| 2183 | 2043 | return { |
| 2184 | 2044 | type: 'SET_QUIZ_DATA', |
| 2185 | 2045 | data: camelCaseDashObjectKeys(data) |
| 2186 | 2046 | }; |
| 2187 | 2047 | } |
| 2048 | + | |
| 2188 | 2049 | /** |
| 2189 | 2050 | * Set question will display. |
| 2190 | 2051 | * |
| 2191 | - * @param questionId | |
| 2192 | - * @return {{type: string, data: *}} | |
| 2052 | + * @param questionId | |
| 2193 | 2053 | */ |
| 2194 | - | |
| 2195 | 2054 | function setCurrentQuestion(questionId) { |
| 2196 | 2055 | return { |
| 2197 | 2056 | type: 'SET_CURRENT_QUESTION', |
| 2198 | 2057 | questionId |
| @@ -2218,12 +2077,12 @@ | ||
| 2218 | 2077 | userId, |
| 2219 | 2078 | results |
| 2220 | 2079 | }; |
| 2221 | 2080 | } |
| 2081 | + | |
| 2222 | 2082 | /** |
| 2223 | 2083 | * Request to api for starting a quiz. |
| 2224 | 2084 | */ |
| 2225 | - | |
| 2226 | 2085 | const startQuiz = function* () { |
| 2227 | 2086 | const { |
| 2228 | 2087 | itemId, |
| 2229 | 2088 | courseId |
| @@ -2228,13 +2087,11 @@ | ||
| 2228 | 2087 | itemId, |
| 2229 | 2088 | courseId |
| 2230 | 2089 | } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('learnpress/quiz').getDefaultRestArgs(); |
| 2231 | 2090 | const doStart = Hook.applyFilters('before-start-quiz', true, itemId, courseId); |
| 2232 | - | |
| 2233 | 2091 | if (true !== doStart) { |
| 2234 | 2092 | return; |
| 2235 | 2093 | } |
| 2236 | - | |
| 2237 | 2094 | let response = yield (0,_learnpress_data_controls__WEBPACK_IMPORTED_MODULE_0__.apiFetch)({ |
| 2238 | 2095 | path: 'lp/v1/users/start-quiz', |
| 2239 | 2096 | method: 'POST', |
| 2240 | 2097 | data: { |
| @@ -2242,34 +2099,50 @@ | ||
| 2242 | 2099 | course_id: courseId |
| 2243 | 2100 | } |
| 2244 | 2101 | }); |
| 2245 | 2102 | const btnStart = document.querySelector('.lp-button.start'); |
| 2246 | - | |
| 2247 | 2103 | if (response.status !== 'error') { |
| 2248 | - response = Hook.applyFilters('request-start-quiz-response', response, itemId, courseId); // No require enroll | |
| 2104 | + response = Hook.applyFilters('request-start-quiz-response', response, itemId, courseId); | |
| 2105 | + const { | |
| 2106 | + results | |
| 2107 | + } = response; | |
| 2108 | + const { | |
| 2109 | + duration, | |
| 2110 | + status, | |
| 2111 | + question_ids, | |
| 2112 | + questions | |
| 2113 | + } = results; | |
| 2249 | 2114 | |
| 2115 | + // No require enroll | |
| 2250 | 2116 | if (lpQuizSettings.checkNorequizenroll === 1) { |
| 2251 | 2117 | const keyQuizOff = 'quiz_off_' + lpQuizSettings.id; |
| 2252 | 2118 | window.localStorage.removeItem(keyQuizOff); |
| 2253 | 2119 | const quizDataOff = { |
| 2254 | - endTime: Date.now() + response.results.duration * 1000, | |
| 2255 | - status: response.results.status | |
| 2120 | + endTime: Date.now() + duration * 1000, | |
| 2121 | + status, | |
| 2122 | + question_ids, | |
| 2123 | + questions | |
| 2256 | 2124 | }; |
| 2257 | - window.localStorage.setItem(keyQuizOff, JSON.stringify(quizDataOff)); // Set Retake quiz | |
| 2125 | + window.localStorage.setItem(keyQuizOff, JSON.stringify(quizDataOff)); | |
| 2258 | 2126 | |
| 2127 | + // Set Retake quiz | |
| 2259 | 2128 | const keyQuizOffRetaken = 'quiz_off_retaken_' + lpQuizSettings.id; |
| 2260 | 2129 | let quizOffRetaken = window.localStorage.getItem(keyQuizOffRetaken); |
| 2261 | - | |
| 2262 | 2130 | if (null === quizOffRetaken) { |
| 2263 | 2131 | quizOffRetaken = 0; |
| 2264 | 2132 | } else { |
| 2265 | 2133 | quizOffRetaken++; |
| 2266 | 2134 | } |
| 2135 | + window.localStorage.setItem(keyQuizOffRetaken, quizOffRetaken); | |
| 2136 | + // End | |
| 2137 | + } | |
| 2267 | 2138 | |
| 2268 | - window.localStorage.setItem(keyQuizOffRetaken, quizOffRetaken); // End | |
| 2269 | - } | |
| 2139 | + // Reload when start/retake quiz | |
| 2140 | + window.localStorage.removeItem('LP'); | |
| 2141 | + window.location.href = response.redirect_url; | |
| 2142 | + //window.location.reload(); | |
| 2270 | 2143 | |
| 2271 | - yield _dispatch('learnpress/quiz', '__requestStartQuizSuccess', camelCaseDashObjectKeys(response), itemId, courseId); | |
| 2144 | + //yield _dispatch( 'learnpress/quiz', '__requestStartQuizSuccess', camelCaseDashObjectKeys( response ), itemId, courseId ); | |
| 2272 | 2145 | } else { |
| 2273 | 2146 | const elButtons = document.querySelector('.quiz-buttons'); |
| 2274 | 2147 | const message = `<div class="learn-press-message error">${response.message}</div>`; |
| 2275 | 2148 | elButtons.insertAdjacentHTML('afterend', message); |
| @@ -2276,9 +2149,8 @@ | ||
| 2276 | 2149 | btnStart.classList.remove('loading'); |
| 2277 | 2150 | } |
| 2278 | 2151 | }; |
| 2279 | 2152 | |
| 2280 | - | |
| 2281 | 2153 | function __requestSubmitQuiz() { |
| 2282 | 2154 | return { |
| 2283 | 2155 | type: 'SUBMIT_QUIZ' |
| 2284 | 2156 | }; |
| @@ -2299,37 +2171,41 @@ | ||
| 2299 | 2171 | itemId, |
| 2300 | 2172 | courseId |
| 2301 | 2173 | } = getDefaultRestArgs(); |
| 2302 | 2174 | const doSubmit = Hook.applyFilters('before-submit-quiz', true); |
| 2303 | - | |
| 2304 | 2175 | if (true !== doSubmit) { |
| 2305 | 2176 | return; |
| 2306 | 2177 | } |
| 2307 | - | |
| 2308 | 2178 | const answered = getQuestionsSelectedAnswers(); |
| 2309 | - | |
| 2310 | 2179 | if (lpQuizSettings.checkNorequizenroll === 1) { |
| 2180 | + const keyQuizOff = `quiz_off_${lpQuizSettings.id}`; | |
| 2181 | + const quizDataOffStr = window.localStorage.getItem(keyQuizOff); | |
| 2182 | + const quizDataOff = JSON.parse(quizDataOffStr); | |
| 2311 | 2183 | const keyAnswer = `LP_Quiz_${itemId}_Answered`; |
| 2312 | 2184 | const answerDataStr = localStorage.getItem(keyAnswer); |
| 2313 | - | |
| 2314 | 2185 | if (null !== answerDataStr) { |
| 2315 | 2186 | const data = JSON.parse(answerDataStr); |
| 2316 | - | |
| 2317 | 2187 | for (const [k, v] of Object.entries(data)) { |
| 2318 | 2188 | answered[k] = v.answered; |
| 2319 | 2189 | } |
| 2320 | 2190 | } |
| 2321 | - } // Get time spend did quiz - tungnx | |
| 2322 | 2191 | |
| 2192 | + // Added questions not answered | |
| 2193 | + quizDataOff.question_ids.forEach(question_id => { | |
| 2194 | + if (!answered[question_id]) { | |
| 2195 | + answered[question_id] = ''; | |
| 2196 | + } | |
| 2197 | + }); | |
| 2198 | + } | |
| 2323 | 2199 | |
| 2200 | + // Get time spend did quiz - tungnx | |
| 2324 | 2201 | let timeSpend = 0; |
| 2325 | 2202 | const elTimeSpend = document.querySelector('input[name=lp-quiz-time-spend]'); |
| 2326 | - | |
| 2327 | 2203 | if (elTimeSpend) { |
| 2328 | 2204 | timeSpend = elTimeSpend.value; |
| 2329 | - } // End | |
| 2205 | + } | |
| 2206 | + // End | |
| 2330 | 2207 | |
| 2331 | - | |
| 2332 | 2208 | let response = yield (0,_learnpress_data_controls__WEBPACK_IMPORTED_MODULE_0__.apiFetch)({ |
| 2333 | 2209 | path: 'lp/v1/users/submit-quiz', |
| 2334 | 2210 | method: 'POST', |
| 2335 | 2211 | data: { |
| @@ -2339,14 +2215,12 @@ | ||
| 2339 | 2215 | time_spend: timeSpend |
| 2340 | 2216 | } |
| 2341 | 2217 | }); |
| 2342 | 2218 | response = Hook.applyFilters('request-submit-quiz-response', response, itemId, courseId); |
| 2343 | - | |
| 2344 | 2219 | if (response.status === 'success') { |
| 2345 | 2220 | if (lpQuizSettings.checkNorequizenroll === 1) { |
| 2346 | 2221 | const keyQuizOff = 'quiz_off_' + lpQuizSettings.id; |
| 2347 | 2222 | const quizDataOffStr = window.localStorage.getItem(keyQuizOff); |
| 2348 | - | |
| 2349 | 2223 | if (null !== quizDataOffStr) { |
| 2350 | 2224 | const quizDataOff = JSON.parse(quizDataOffStr); |
| 2351 | 2225 | quizDataOff.status = response.results.status; |
| 2352 | 2226 | quizDataOff.results = response.results.results; |
| @@ -2352,21 +2226,13 @@ | ||
| 2352 | 2226 | quizDataOff.results = response.results.results; |
| 2353 | 2227 | window.localStorage.setItem(keyQuizOff, JSON.stringify(quizDataOff)); |
| 2354 | 2228 | window.localStorage.removeItem('LP_Quiz_' + lpQuizSettings.id + '_Answered'); |
| 2355 | 2229 | } |
| 2356 | - } //console.log( response.results ); | |
| 2357 | - | |
| 2358 | - | |
| 2230 | + } | |
| 2359 | 2231 | yield _dispatch('learnpress/quiz', '__requestSubmitQuizSuccess', camelCaseDashObjectKeys(response.results), itemId, courseId); |
| 2360 | 2232 | } |
| 2361 | - /*if ( lpQuizSettings.checkNorequizenroll == '1' ) { | |
| 2362 | - localStorage.setItem( 'quiz_userdata_' + lpQuizSettings.id, JSON.stringify( wpSelect( 'learnpress/quiz' ).getData() ) ); | |
| 2363 | - }*/ | |
| 2364 | - | |
| 2365 | 2233 | } |
| 2366 | -function updateUserQuestionAnswers(questionId, answers, quizId) { | |
| 2367 | - let courseId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; | |
| 2368 | - let userId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0; | |
| 2234 | +function updateUserQuestionAnswers(questionId, answers, quizId, courseId = 0, userId = 0) { | |
| 2369 | 2235 | return { |
| 2370 | 2236 | type: 'UPDATE_USER_QUESTION_ANSWERS', |
| 2371 | 2237 | questionId, |
| 2372 | 2238 | answers |
| @@ -2371,8 +2237,29 @@ | ||
| 2371 | 2237 | questionId, |
| 2372 | 2238 | answers |
| 2373 | 2239 | }; |
| 2374 | 2240 | } |
| 2241 | + | |
| 2242 | +/** | |
| 2243 | + * Handle when user change value on input fill in blanks. | |
| 2244 | + * | |
| 2245 | + * @param questionId | |
| 2246 | + * @param idInput | |
| 2247 | + * @param valueInput | |
| 2248 | + * @param quizId | |
| 2249 | + * @param courseId | |
| 2250 | + * @param userId | |
| 2251 | + * @since 4.2.5.9 | |
| 2252 | + * @version 1.0.0 | |
| 2253 | + */ | |
| 2254 | +function updateUserQuestionFibAnswers(questionId, idInput, valueInput, quizId, courseId = 0, userId = 0) { | |
| 2255 | + return { | |
| 2256 | + type: 'UPDATE_USER_QUESTION_FIB_ANSWERS', | |
| 2257 | + questionId, | |
| 2258 | + idInput, | |
| 2259 | + valueInput | |
| 2260 | + }; | |
| 2261 | +} | |
| 2375 | 2262 | function __requestShowHintSuccess(id, showHint) { |
| 2376 | 2263 | return { |
| 2377 | 2264 | type: 'SET_QUESTION_HINT', |
| 2378 | 2265 | questionId: id, |
| @@ -2407,19 +2294,16 @@ | ||
| 2407 | 2294 | question_id: id, |
| 2408 | 2295 | answered: getQuestionAnswered(id) || '' |
| 2409 | 2296 | } |
| 2410 | 2297 | }); |
| 2411 | - | |
| 2412 | 2298 | if (result.status === 'success') { |
| 2413 | 2299 | // No require enroll |
| 2414 | 2300 | if (lpQuizSettings.checkNorequizenroll === 1) { |
| 2415 | 2301 | const keyQuizOff = 'quiz_off_' + lpQuizSettings.id; |
| 2416 | 2302 | const quizDataOffStr = window.localStorage.getItem(keyQuizOff); |
| 2417 | - | |
| 2418 | 2303 | if (null !== quizDataOffStr) { |
| 2419 | 2304 | const quizDataOff = JSON.parse(quizDataOffStr); |
| 2420 | 2305 | const questionOptions = result.options; |
| 2421 | - | |
| 2422 | 2306 | if (undefined === quizDataOff.checked_questions) { |
| 2423 | 2307 | quizDataOff.checked_questions = []; |
| 2424 | 2308 | quizDataOff.checked_questions.push(id); |
| 2425 | 2309 | } else if (-1 === quizDataOff.checked_questions.indexOf(id)) { |
| @@ -2424,9 +2308,8 @@ | ||
| 2424 | 2308 | quizDataOff.checked_questions.push(id); |
| 2425 | 2309 | } else if (-1 === quizDataOff.checked_questions.indexOf(id)) { |
| 2426 | 2310 | quizDataOff.checked_questions.push(id); |
| 2427 | 2311 | } |
| 2428 | - | |
| 2429 | 2312 | if (undefined === quizDataOff.question_options) { |
| 2430 | 2313 | quizDataOff.question_options = {}; |
| 2431 | 2314 | quizDataOff.question_options[id] = questionOptions; |
| 2432 | 2315 | } else if (undefined === quizDataOff.question_options[id]) { |
| @@ -2431,13 +2314,13 @@ | ||
| 2431 | 2314 | quizDataOff.question_options[id] = questionOptions; |
| 2432 | 2315 | } else if (undefined === quizDataOff.question_options[id]) { |
| 2433 | 2316 | quizDataOff.question_options[id] = questionOptions; |
| 2434 | 2317 | } |
| 2318 | + window.localStorage.setItem(keyQuizOff, JSON.stringify(quizDataOff)); | |
| 2435 | 2319 | |
| 2436 | - window.localStorage.setItem(keyQuizOff, JSON.stringify(quizDataOff)); //console.log( quizDataOff ); | |
| 2320 | + //console.log( quizDataOff ); | |
| 2437 | 2321 | } |
| 2438 | 2322 | } |
| 2439 | - | |
| 2440 | 2323 | yield _dispatch('learnpress/quiz', '__requestCheckAnswerSuccess', id, camelCaseDashObjectKeys(result)); |
| 2441 | 2324 | } |
| 2442 | 2325 | } |
| 2443 | 2326 | function markQuestionRendered(questionId) { |
| @@ -2461,18 +2344,21 @@ | ||
| 2461 | 2344 | keyPressed |
| 2462 | 2345 | }; |
| 2463 | 2346 | } |
| 2464 | 2347 | |
| 2465 | -/***/ }), | |
| 2348 | +/***/ }, | |
| 2466 | 2349 | |
| 2467 | -/***/ "./assets/src/apps/js/frontend/quiz/store/index.js": | |
| 2350 | +/***/ "./assets/src/apps/js/frontend/quiz/store/index.js" | |
| 2468 | 2351 | /*!*********************************************************!*\ |
| 2469 | 2352 | !*** ./assets/src/apps/js/frontend/quiz/store/index.js ***! |
| 2470 | 2353 | \*********************************************************/ |
| 2471 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2354 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2472 | 2355 | |
| 2473 | 2356 | "use strict"; |
| 2474 | 2357 | __webpack_require__.r(__webpack_exports__); |
| 2358 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 2359 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 2360 | +/* harmony export */ }); | |
| 2475 | 2361 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 2476 | 2362 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); |
| 2477 | 2363 | /* harmony import */ var _reducer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./reducer */ "./assets/src/apps/js/frontend/quiz/store/reducer.js"); |
| 2478 | 2364 | /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./assets/src/apps/js/frontend/quiz/store/actions.js"); |
| @@ -2489,24 +2375,28 @@ | ||
| 2489 | 2375 | const store = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.registerStore)('learnpress/quiz', { |
| 2490 | 2376 | reducer: _reducer__WEBPACK_IMPORTED_MODULE_1__["default"], |
| 2491 | 2377 | selectors: _selectors__WEBPACK_IMPORTED_MODULE_3__, |
| 2492 | 2378 | actions: _actions__WEBPACK_IMPORTED_MODULE_2__, |
| 2493 | - controls: { ...dataControls | |
| 2379 | + controls: { | |
| 2380 | + ...dataControls | |
| 2494 | 2381 | } |
| 2495 | 2382 | }); |
| 2496 | 2383 | (0,_middlewares__WEBPACK_IMPORTED_MODULE_4__["default"])(store); |
| 2497 | -/* harmony default export */ __webpack_exports__["default"] = (store); | |
| 2384 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (store); | |
| 2498 | 2385 | |
| 2499 | -/***/ }), | |
| 2386 | +/***/ }, | |
| 2500 | 2387 | |
| 2501 | -/***/ "./assets/src/apps/js/frontend/quiz/store/middlewares.js": | |
| 2388 | +/***/ "./assets/src/apps/js/frontend/quiz/store/middlewares.js" | |
| 2502 | 2389 | /*!***************************************************************!*\ |
| 2503 | 2390 | !*** ./assets/src/apps/js/frontend/quiz/store/middlewares.js ***! |
| 2504 | 2391 | \***************************************************************/ |
| 2505 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2392 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2506 | 2393 | |
| 2507 | 2394 | "use strict"; |
| 2508 | 2395 | __webpack_require__.r(__webpack_exports__); |
| 2396 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 2397 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 2398 | +/* harmony export */ }); | |
| 2509 | 2399 | /* harmony import */ var refx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! refx */ "./node_modules/refx/refx.js"); |
| 2510 | 2400 | /* harmony import */ var refx__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(refx__WEBPACK_IMPORTED_MODULE_0__); |
| 2511 | 2401 | /** |
| 2512 | 2402 | * External dependencies |
| @@ -2511,8 +2401,9 @@ | ||
| 2511 | 2401 | /** |
| 2512 | 2402 | * External dependencies |
| 2513 | 2403 | */ |
| 2514 | 2404 | |
| 2405 | + | |
| 2515 | 2406 | /** |
| 2516 | 2407 | * Internal dependencies |
| 2517 | 2408 | */ |
| 2518 | 2409 | //import effects from './effects'; |
| @@ -2521,12 +2412,15 @@ | ||
| 2521 | 2412 | ENROLL_COURSE_X: (action, store) => { |
| 2522 | 2413 | enrollCourse: (action, store) => { |
| 2523 | 2414 | const { |
| 2524 | 2415 | dispatch |
| 2525 | - } = store; //dispatch() | |
| 2416 | + } = store; | |
| 2417 | + | |
| 2418 | + //dispatch() | |
| 2526 | 2419 | }; |
| 2527 | 2420 | } |
| 2528 | 2421 | }; |
| 2422 | + | |
| 2529 | 2423 | /** |
| 2530 | 2424 | * Applies the custom middlewares used specifically in the editor module. |
| 2531 | 2425 | * |
| 2532 | 2426 | * @param {Object} store Store Object. |
| @@ -2532,41 +2426,37 @@ | ||
| 2532 | 2426 | * @param {Object} store Store Object. |
| 2533 | 2427 | * |
| 2534 | 2428 | * @return {Object} Update Store Object. |
| 2535 | 2429 | */ |
| 2536 | - | |
| 2537 | 2430 | function applyMiddlewares(store) { |
| 2538 | 2431 | let enhancedDispatch = () => { |
| 2539 | 2432 | throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.'); |
| 2540 | 2433 | }; |
| 2541 | - | |
| 2542 | 2434 | const middlewareAPI = { |
| 2543 | 2435 | getState: store.getState, |
| 2544 | - dispatch: function () { | |
| 2545 | - return enhancedDispatch(...arguments); | |
| 2546 | - } | |
| 2436 | + dispatch: (...args) => enhancedDispatch(...args) | |
| 2547 | 2437 | }; |
| 2548 | 2438 | enhancedDispatch = refx__WEBPACK_IMPORTED_MODULE_0___default()(effects)(middlewareAPI)(store.dispatch); |
| 2549 | 2439 | store.dispatch = enhancedDispatch; |
| 2550 | 2440 | return store; |
| 2551 | 2441 | } |
| 2442 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (applyMiddlewares); | |
| 2552 | 2443 | |
| 2553 | -/* harmony default export */ __webpack_exports__["default"] = (applyMiddlewares); | |
| 2444 | +/***/ }, | |
| 2554 | 2445 | |
| 2555 | -/***/ }), | |
| 2556 | - | |
| 2557 | -/***/ "./assets/src/apps/js/frontend/quiz/store/reducer.js": | |
| 2446 | +/***/ "./assets/src/apps/js/frontend/quiz/store/reducer.js" | |
| 2558 | 2447 | /*!***********************************************************!*\ |
| 2559 | 2448 | !*** ./assets/src/apps/js/frontend/quiz/store/reducer.js ***! |
| 2560 | 2449 | \***********************************************************/ |
| 2561 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2450 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2562 | 2451 | |
| 2563 | 2452 | "use strict"; |
| 2564 | 2453 | __webpack_require__.r(__webpack_exports__); |
| 2565 | 2454 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2566 | -/* harmony export */ "blocks": function() { return /* binding */ blocks; }, | |
| 2567 | -/* harmony export */ "setItemStatus": function() { return /* binding */ setItemStatus; }, | |
| 2568 | -/* harmony export */ "userQuiz": function() { return /* binding */ userQuiz; } | |
| 2455 | +/* harmony export */ blocks: () => (/* binding */ blocks), | |
| 2456 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), | |
| 2457 | +/* harmony export */ setItemStatus: () => (/* binding */ setItemStatus), | |
| 2458 | +/* harmony export */ userQuiz: () => (/* binding */ userQuiz) | |
| 2569 | 2459 | /* harmony export */ }); |
| 2570 | 2460 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 2571 | 2461 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); |
| 2572 | 2462 | |
| @@ -2584,130 +2474,149 @@ | ||
| 2584 | 2474 | set: storageSet |
| 2585 | 2475 | } = LP.localStorage; |
| 2586 | 2476 | const STORE_DATA = {}; |
| 2587 | 2477 | const setItemStatus = (item, status) => { |
| 2588 | - const userSettings = { ...item.userSettings, | |
| 2478 | + const userSettings = { | |
| 2479 | + ...item.userSettings, | |
| 2589 | 2480 | status |
| 2590 | 2481 | }; |
| 2591 | - return { ...item, | |
| 2482 | + return { | |
| 2483 | + ...item, | |
| 2592 | 2484 | userSettings |
| 2593 | 2485 | }; |
| 2594 | 2486 | }; |
| 2595 | - | |
| 2596 | 2487 | const updateUserQuestionAnswer = (state, action) => { |
| 2597 | 2488 | const { |
| 2598 | 2489 | answered, |
| 2599 | 2490 | id |
| 2600 | 2491 | } = state; |
| 2601 | - const newAnswer = { ...(answered[action.questionId] || {}), | |
| 2492 | + const newAnswer = { | |
| 2493 | + ...(answered[action.questionId] || {}), | |
| 2602 | 2494 | answered: action.answers, |
| 2603 | 2495 | temp: true |
| 2604 | 2496 | }; |
| 2605 | - | |
| 2606 | 2497 | if (id) { |
| 2607 | - localStorage.setItem(`LP_Quiz_${id}_Answered`, JSON.stringify({ ...state.answered, | |
| 2498 | + localStorage.setItem(`LP_Quiz_${id}_Answered`, JSON.stringify({ | |
| 2499 | + ...state.answered, | |
| 2608 | 2500 | [action.questionId]: newAnswer |
| 2609 | 2501 | })); |
| 2610 | 2502 | } |
| 2611 | - | |
| 2612 | - return { ...state, | |
| 2613 | - answered: { ...state.answered, | |
| 2503 | + return { | |
| 2504 | + ...state, | |
| 2505 | + answered: { | |
| 2506 | + ...state.answered, | |
| 2614 | 2507 | [action.questionId]: newAnswer |
| 2615 | 2508 | } |
| 2616 | 2509 | }; |
| 2617 | 2510 | }; |
| 2618 | - | |
| 2511 | +const updateUserQuestionFibAnswer = (state, action) => { | |
| 2512 | + const { | |
| 2513 | + id | |
| 2514 | + } = state; | |
| 2515 | + const { | |
| 2516 | + questionId, | |
| 2517 | + idInput, | |
| 2518 | + valueInput | |
| 2519 | + } = action; | |
| 2520 | + if (state.answered.hasOwnProperty(questionId)) { | |
| 2521 | + state.answered[questionId].answered[idInput] = valueInput; | |
| 2522 | + } else { | |
| 2523 | + state.answered[action.questionId] = { | |
| 2524 | + answered: { | |
| 2525 | + [idInput]: valueInput | |
| 2526 | + }, | |
| 2527 | + temp: true | |
| 2528 | + }; | |
| 2529 | + } | |
| 2530 | + localStorage.setItem(`LP_Quiz_${id}_Answered`, JSON.stringify(state.answered)); | |
| 2531 | + return state; | |
| 2532 | +}; | |
| 2619 | 2533 | const markQuestionRendered = (state, action) => { |
| 2620 | 2534 | const { |
| 2621 | 2535 | questionsRendered |
| 2622 | 2536 | } = state; |
| 2623 | - | |
| 2624 | 2537 | if (isArray(questionsRendered)) { |
| 2625 | 2538 | questionsRendered.push(action.questionId); |
| 2626 | - return { ...state, | |
| 2539 | + return { | |
| 2540 | + ...state, | |
| 2627 | 2541 | questionsRendered: [...questionsRendered] |
| 2628 | 2542 | }; |
| 2629 | 2543 | } |
| 2630 | - | |
| 2631 | - return { ...state, | |
| 2544 | + return { | |
| 2545 | + ...state, | |
| 2632 | 2546 | questionsRendered: [action.questionId] |
| 2633 | 2547 | }; |
| 2634 | 2548 | }; |
| 2635 | - | |
| 2636 | 2549 | const resetCurrentPage = (state, args) => { |
| 2637 | 2550 | if (args.currentPage) { |
| 2638 | 2551 | storageSet(`Q${state.id}.currentPage`, args.currentPage); |
| 2639 | 2552 | } |
| 2640 | - | |
| 2641 | - return { ...state, | |
| 2553 | + return { | |
| 2554 | + ...state, | |
| 2642 | 2555 | ...args |
| 2643 | 2556 | }; |
| 2644 | 2557 | }; |
| 2645 | - | |
| 2646 | 2558 | const setQuestionHint = (state, action) => { |
| 2647 | 2559 | const questions = state.questions.map(question => { |
| 2648 | - return question.id == action.questionId ? { ...question, | |
| 2560 | + return question.id == action.questionId ? { | |
| 2561 | + ...question, | |
| 2649 | 2562 | showHint: action.showHint |
| 2650 | 2563 | } : question; |
| 2651 | 2564 | }); |
| 2652 | - return { ...state, | |
| 2565 | + return { | |
| 2566 | + ...state, | |
| 2653 | 2567 | questions: [...questions] |
| 2654 | 2568 | }; |
| 2655 | 2569 | }; |
| 2656 | - | |
| 2657 | 2570 | const checkAnswer = (state, action) => { |
| 2658 | 2571 | const questions = state.questions.map(question => { |
| 2659 | 2572 | if (question.id !== action.questionId) { |
| 2660 | 2573 | return question; |
| 2661 | 2574 | } |
| 2662 | - | |
| 2663 | 2575 | const newArgs = { |
| 2664 | 2576 | explanation: action.explanation |
| 2665 | 2577 | }; |
| 2666 | - | |
| 2667 | 2578 | if (action.options) { |
| 2668 | 2579 | newArgs.options = action.options; |
| 2669 | 2580 | } |
| 2670 | - | |
| 2671 | - return { ...question, | |
| 2581 | + return { | |
| 2582 | + ...question, | |
| 2672 | 2583 | ...newArgs |
| 2673 | 2584 | }; |
| 2674 | 2585 | }); |
| 2675 | - const answered = { ...state.answered, | |
| 2586 | + const answered = { | |
| 2587 | + ...state.answered, | |
| 2676 | 2588 | [action.questionId]: action.result |
| 2677 | 2589 | }; |
| 2678 | 2590 | let newAnswered = localStorage.getItem(`LP_Quiz_${state.id}_Answered`); |
| 2679 | - | |
| 2680 | 2591 | if (newAnswered) { |
| 2681 | - newAnswered = { ...JSON.parse(newAnswered), | |
| 2592 | + newAnswered = { | |
| 2593 | + ...JSON.parse(newAnswered), | |
| 2682 | 2594 | ...answered |
| 2683 | 2595 | }; |
| 2684 | 2596 | localStorage.setItem(`LP_Quiz_${state.id}_Answered`, JSON.stringify(newAnswered)); |
| 2685 | 2597 | } |
| 2686 | - | |
| 2687 | - return { ...state, | |
| 2598 | + return { | |
| 2599 | + ...state, | |
| 2688 | 2600 | questions: [...questions], |
| 2689 | - answered: answered, | |
| 2601 | + answered, | |
| 2690 | 2602 | checkedQuestions: [...state.checkedQuestions, action.questionId] |
| 2691 | 2603 | }; |
| 2692 | 2604 | }; |
| 2693 | - | |
| 2694 | 2605 | const submitQuiz = (state, action) => { |
| 2695 | 2606 | localStorage.removeItem(`LP_Quiz_${state.id}_Answered`); |
| 2696 | 2607 | const questions = state.questions.map(question => { |
| 2697 | 2608 | const newArgs = {}; |
| 2698 | - | |
| 2699 | 2609 | if (state.reviewQuestions) { |
| 2700 | - if (action.results.questions[question.id].explanation) { | |
| 2610 | + if (action.results.questions[question.id]?.explanation) { | |
| 2701 | 2611 | newArgs.explanation = action.results.questions[question.id].explanation; |
| 2702 | 2612 | } |
| 2703 | - | |
| 2704 | - if (action.results.questions[question.id].options) { | |
| 2613 | + if (action.results.questions[question.id]?.options) { | |
| 2705 | 2614 | newArgs.options = action.results.questions[question.id].options; |
| 2706 | 2615 | } |
| 2707 | 2616 | } |
| 2708 | - | |
| 2709 | - return { ...question, | |
| 2617 | + return { | |
| 2618 | + ...question, | |
| 2710 | 2619 | ...newArgs |
| 2711 | 2620 | }; |
| 2712 | 2621 | }); |
| 2713 | 2622 | return resetCurrentPage(state, { |
| @@ -2716,12 +2625,13 @@ | ||
| 2716 | 2625 | ...action.results, |
| 2717 | 2626 | questions: [...questions] |
| 2718 | 2627 | }); |
| 2719 | 2628 | }; |
| 2720 | - | |
| 2721 | 2629 | const startQuizz = (state, action) => { |
| 2722 | 2630 | const successResponse = action.results.success !== undefined ? action.results.success : false; |
| 2723 | 2631 | const messageResponse = action.results.message || false; |
| 2632 | + const chunks = chunk(action.results.results.questionIds, state.questionsPerPage); | |
| 2633 | + state.numPages = chunks.length; | |
| 2724 | 2634 | return resetCurrentPage(state, { |
| 2725 | 2635 | checkedQuestions: [], |
| 2726 | 2636 | hintedQuestions: [], |
| 2727 | 2637 | mode: '', |
| @@ -2730,57 +2640,50 @@ | ||
| 2730 | 2640 | successResponse, |
| 2731 | 2641 | messageResponse |
| 2732 | 2642 | }); |
| 2733 | 2643 | }; |
| 2734 | - | |
| 2735 | -const userQuiz = function () { | |
| 2736 | - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : STORE_DATA; | |
| 2737 | - let action = arguments.length > 1 ? arguments[1] : undefined; | |
| 2738 | - | |
| 2644 | +const userQuiz = (state = STORE_DATA, action) => { | |
| 2739 | 2645 | switch (action.type) { |
| 2740 | 2646 | case 'SET_QUIZ_DATA': |
| 2741 | 2647 | if (1 > action.data.questionsPerPage) { |
| 2742 | 2648 | action.data.questionsPerPage = 1; |
| 2743 | 2649 | } |
| 2744 | - | |
| 2745 | 2650 | const chunks = chunk(state.questionIds || action.data.questionIds, action.data.questionsPerPage); |
| 2746 | 2651 | action.data.numPages = chunks.length; |
| 2747 | 2652 | action.data.pages = chunks; |
| 2748 | - return { ...state, | |
| 2653 | + return { | |
| 2654 | + ...state, | |
| 2749 | 2655 | ...action.data, |
| 2750 | 2656 | currentPage: storageGet(`Q${action.data.id}.currentPage`) || action.data.currentPage |
| 2751 | 2657 | }; |
| 2752 | - | |
| 2753 | 2658 | case 'SUBMIT_QUIZ': |
| 2754 | - return { ...state, | |
| 2659 | + return { | |
| 2660 | + ...state, | |
| 2755 | 2661 | submitting: true |
| 2756 | 2662 | }; |
| 2757 | - | |
| 2758 | 2663 | case 'START_QUIZ': |
| 2759 | 2664 | case 'START_QUIZ_SUCCESS': |
| 2760 | 2665 | return startQuizz(state, action); |
| 2761 | - | |
| 2762 | 2666 | case 'SET_CURRENT_QUESTION': |
| 2763 | 2667 | storageSet(`Q${state.id}.currentQuestion`, action.questionId); |
| 2764 | - return { ...state, | |
| 2668 | + return { | |
| 2669 | + ...state, | |
| 2765 | 2670 | currentQuestion: action.questionId |
| 2766 | 2671 | }; |
| 2767 | - | |
| 2768 | 2672 | case 'SET_CURRENT_PAGE': |
| 2769 | 2673 | storageSet(`Q${state.id}.currentPage`, action.currentPage); |
| 2770 | - return { ...state, | |
| 2674 | + return { | |
| 2675 | + ...state, | |
| 2771 | 2676 | currentPage: action.currentPage |
| 2772 | 2677 | }; |
| 2773 | - | |
| 2774 | 2678 | case 'SUBMIT_QUIZ_SUCCESS': |
| 2775 | 2679 | return submitQuiz(state, action); |
| 2776 | - | |
| 2777 | 2680 | case 'UPDATE_USER_QUESTION_ANSWERS': |
| 2778 | 2681 | return state.status === 'started' ? updateUserQuestionAnswer(state, action) : state; |
| 2779 | - | |
| 2682 | + case 'UPDATE_USER_QUESTION_FIB_ANSWERS': | |
| 2683 | + return state.status === 'started' ? updateUserQuestionFibAnswer(state, action) : state; | |
| 2780 | 2684 | case 'MARK_QUESTION_RENDERED': |
| 2781 | 2685 | return markQuestionRendered(state, action); |
| 2782 | - | |
| 2783 | 2686 | case 'SET_QUIZ_MODE': |
| 2784 | 2687 | if (action.mode == 'reviewing') { |
| 2785 | 2688 | return resetCurrentPage(state, { |
| 2786 | 2689 | mode: action.mode |
| @@ -2785,25 +2688,22 @@ | ||
| 2785 | 2688 | return resetCurrentPage(state, { |
| 2786 | 2689 | mode: action.mode |
| 2787 | 2690 | }); |
| 2788 | 2691 | } |
| 2789 | - | |
| 2790 | - return { ...state, | |
| 2692 | + return { | |
| 2693 | + ...state, | |
| 2791 | 2694 | mode: action.mode |
| 2792 | 2695 | }; |
| 2793 | - | |
| 2794 | 2696 | case 'SET_QUESTION_HINT': |
| 2795 | 2697 | return setQuestionHint(state, action); |
| 2796 | - | |
| 2797 | 2698 | case 'CHECK_ANSWER': |
| 2798 | 2699 | return checkAnswer(state, action); |
| 2799 | - | |
| 2800 | 2700 | case 'SEND_KEY': |
| 2801 | - return { ...state, | |
| 2701 | + return { | |
| 2702 | + ...state, | |
| 2802 | 2703 | keyPressed: action.keyPressed |
| 2803 | 2704 | }; |
| 2804 | 2705 | } |
| 2805 | - | |
| 2806 | 2706 | return state; |
| 2807 | 2707 | }; |
| 2808 | 2708 | const blocks = flow(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.combineReducers, reducer => (state, action) => { |
| 2809 | 2709 | return reducer(state, action); |
| @@ -2811,57 +2711,51 @@ | ||
| 2811 | 2711 | return reducer(state, action); |
| 2812 | 2712 | }, reducer => (state, action) => { |
| 2813 | 2713 | return reducer(state, action); |
| 2814 | 2714 | })({ |
| 2815 | - a() { | |
| 2816 | - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | |
| 2817 | - a: 1 | |
| 2818 | - }; | |
| 2819 | - let action = arguments.length > 1 ? arguments[1] : undefined; | |
| 2715 | + a(state = { | |
| 2716 | + a: 1 | |
| 2717 | + }, action) { | |
| 2820 | 2718 | return state; |
| 2821 | 2719 | }, |
| 2822 | - | |
| 2823 | - b() { | |
| 2824 | - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { | |
| 2825 | - b: 2 | |
| 2826 | - }; | |
| 2827 | - let action = arguments.length > 1 ? arguments[1] : undefined; | |
| 2720 | + b(state = { | |
| 2721 | + b: 2 | |
| 2722 | + }, action) { | |
| 2828 | 2723 | return state; |
| 2829 | 2724 | } |
| 2830 | - | |
| 2831 | 2725 | }); |
| 2832 | -/* harmony default export */ __webpack_exports__["default"] = ((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.combineReducers)({ | |
| 2726 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.combineReducers)({ | |
| 2833 | 2727 | blocks, |
| 2834 | 2728 | userQuiz |
| 2835 | 2729 | })); |
| 2836 | 2730 | |
| 2837 | -/***/ }), | |
| 2731 | +/***/ }, | |
| 2838 | 2732 | |
| 2839 | -/***/ "./assets/src/apps/js/frontend/quiz/store/selectors.js": | |
| 2733 | +/***/ "./assets/src/apps/js/frontend/quiz/store/selectors.js" | |
| 2840 | 2734 | /*!*************************************************************!*\ |
| 2841 | 2735 | !*** ./assets/src/apps/js/frontend/quiz/store/selectors.js ***! |
| 2842 | 2736 | \*************************************************************/ |
| 2843 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2737 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2844 | 2738 | |
| 2845 | 2739 | "use strict"; |
| 2846 | 2740 | __webpack_require__.r(__webpack_exports__); |
| 2847 | 2741 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2848 | -/* harmony export */ "getCurrentQuestion": function() { return /* binding */ getCurrentQuestion; }, | |
| 2849 | -/* harmony export */ "getData": function() { return /* binding */ getData; }, | |
| 2850 | -/* harmony export */ "getDefaultRestArgs": function() { return /* binding */ getDefaultRestArgs; }, | |
| 2851 | -/* harmony export */ "getItemStatus": function() { return /* binding */ getItemStatus; }, | |
| 2852 | -/* harmony export */ "getProp": function() { return /* binding */ getProp; }, | |
| 2853 | -/* harmony export */ "getQuestion": function() { return /* binding */ getQuestion; }, | |
| 2854 | -/* harmony export */ "getQuestionAnswered": function() { return /* binding */ getQuestionAnswered; }, | |
| 2855 | -/* harmony export */ "getQuestionMark": function() { return /* binding */ getQuestionMark; }, | |
| 2856 | -/* harmony export */ "getQuestionOptions": function() { return /* binding */ getQuestionOptions; }, | |
| 2857 | -/* harmony export */ "getQuestions": function() { return /* binding */ getQuestions; }, | |
| 2858 | -/* harmony export */ "getQuestionsSelectedAnswers": function() { return /* binding */ getQuestionsSelectedAnswers; }, | |
| 2859 | -/* harmony export */ "getQuizAnswered": function() { return /* binding */ getQuizAnswered; }, | |
| 2860 | -/* harmony export */ "getQuizAttempts": function() { return /* binding */ getQuizAttempts; }, | |
| 2861 | -/* harmony export */ "getUserMark": function() { return /* binding */ getUserMark; }, | |
| 2862 | -/* harmony export */ "isCheckedAnswer": function() { return /* binding */ isCheckedAnswer; }, | |
| 2863 | -/* harmony export */ "isCorrect": function() { return /* binding */ isCorrect; } | |
| 2742 | +/* harmony export */ getCurrentQuestion: () => (/* binding */ getCurrentQuestion), | |
| 2743 | +/* harmony export */ getData: () => (/* binding */ getData), | |
| 2744 | +/* harmony export */ getDefaultRestArgs: () => (/* binding */ getDefaultRestArgs), | |
| 2745 | +/* harmony export */ getItemStatus: () => (/* binding */ getItemStatus), | |
| 2746 | +/* harmony export */ getProp: () => (/* binding */ getProp), | |
| 2747 | +/* harmony export */ getQuestion: () => (/* binding */ getQuestion), | |
| 2748 | +/* harmony export */ getQuestionAnswered: () => (/* binding */ getQuestionAnswered), | |
| 2749 | +/* harmony export */ getQuestionMark: () => (/* binding */ getQuestionMark), | |
| 2750 | +/* harmony export */ getQuestionOptions: () => (/* binding */ getQuestionOptions), | |
| 2751 | +/* harmony export */ getQuestions: () => (/* binding */ getQuestions), | |
| 2752 | +/* harmony export */ getQuestionsSelectedAnswers: () => (/* binding */ getQuestionsSelectedAnswers), | |
| 2753 | +/* harmony export */ getQuizAnswered: () => (/* binding */ getQuizAnswered), | |
| 2754 | +/* harmony export */ getQuizAttempts: () => (/* binding */ getQuizAttempts), | |
| 2755 | +/* harmony export */ getUserMark: () => (/* binding */ getUserMark), | |
| 2756 | +/* harmony export */ isCheckedAnswer: () => (/* binding */ isCheckedAnswer), | |
| 2757 | +/* harmony export */ isCorrect: () => (/* binding */ isCorrect) | |
| 2864 | 2758 | /* harmony export */ }); |
| 2865 | 2759 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 2866 | 2760 | /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); |
| 2867 | 2761 | |
| @@ -2868,9 +2762,8 @@ | ||
| 2868 | 2762 | const { |
| 2869 | 2763 | get, |
| 2870 | 2764 | isArray |
| 2871 | 2765 | } = lodash; |
| 2872 | - | |
| 2873 | 2766 | const getQuestionOptions = function getQuestionOptions(state, id) { |
| 2874 | 2767 | console.time('parseOptions'); |
| 2875 | 2768 | const question = getQuestion(state, id); |
| 2876 | 2769 | let options = question.options; |
| @@ -2888,9 +2781,8 @@ | ||
| 2888 | 2781 | * |
| 2889 | 2782 | * @param state |
| 2890 | 2783 | * @param itemId |
| 2891 | 2784 | */ |
| 2892 | - | |
| 2893 | 2785 | function getItemStatus(state, itemId) { |
| 2894 | 2786 | const item = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.select)('course-learner/user').getItemById(itemId); |
| 2895 | 2787 | return item ? get(item, 'userSettings.status') : ''; |
| 2896 | 2788 | } |
| @@ -2896,8 +2788,9 @@ | ||
| 2896 | 2788 | } |
| 2897 | 2789 | function getProp(state, prop, defaultValue) { |
| 2898 | 2790 | return state[prop] || defaultValue; |
| 2899 | 2791 | } |
| 2792 | + | |
| 2900 | 2793 | /** |
| 2901 | 2794 | * Get quiz attempted. |
| 2902 | 2795 | * |
| 2903 | 2796 | * @param state |
| @@ -2903,13 +2796,13 @@ | ||
| 2903 | 2796 | * @param state |
| 2904 | 2797 | * @param itemId |
| 2905 | 2798 | * @return {Array} |
| 2906 | 2799 | */ |
| 2907 | - | |
| 2908 | 2800 | function getQuizAttempts(state, itemId) { |
| 2909 | 2801 | const item = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.select)('course-learner/user').getItemById(itemId); |
| 2910 | 2802 | return item ? get(item, 'userSettings.attempts') : []; |
| 2911 | 2803 | } |
| 2804 | + | |
| 2912 | 2805 | /** |
| 2913 | 2806 | * Get answers for a quiz user has did. |
| 2914 | 2807 | * |
| 2915 | 2808 | * @param state |
| @@ -2915,13 +2808,13 @@ | ||
| 2915 | 2808 | * @param state |
| 2916 | 2809 | * @param itemId |
| 2917 | 2810 | * @return {{}} |
| 2918 | 2811 | */ |
| 2919 | - | |
| 2920 | 2812 | function getQuizAnswered(state, itemId) { |
| 2921 | 2813 | const item = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.select)('course-learner/user').getItemById(itemId); |
| 2922 | 2814 | return item ? get(item, 'userSettings.answered', {}) : {}; |
| 2923 | 2815 | } |
| 2816 | + | |
| 2924 | 2817 | /** |
| 2925 | 2818 | * Get all questions in quiz. |
| 2926 | 2819 | * |
| 2927 | 2820 | * @param state |
| @@ -2926,9 +2819,8 @@ | ||
| 2926 | 2819 | * |
| 2927 | 2820 | * @param state |
| 2928 | 2821 | * @return {*} |
| 2929 | 2822 | */ |
| 2930 | - | |
| 2931 | 2823 | function getQuestions(state) { |
| 2932 | 2824 | const { |
| 2933 | 2825 | userQuiz |
| 2934 | 2826 | } = state; |
| @@ -2934,8 +2826,9 @@ | ||
| 2934 | 2826 | } = state; |
| 2935 | 2827 | const questions = get(userQuiz, 'questions'); |
| 2936 | 2828 | return questions ? Object.values(questions) : []; |
| 2937 | 2829 | } |
| 2830 | + | |
| 2938 | 2831 | /** |
| 2939 | 2832 | * Get property of store data. |
| 2940 | 2833 | * |
| 2941 | 2834 | * @param state - Store data |
| @@ -2941,18 +2834,15 @@ | ||
| 2941 | 2834 | * @param state - Store data |
| 2942 | 2835 | * @param prop - Optional. NULL will return all data. |
| 2943 | 2836 | * @return {*} |
| 2944 | 2837 | */ |
| 2945 | - | |
| 2946 | 2838 | function getData(state, prop) { |
| 2947 | 2839 | const { |
| 2948 | 2840 | userQuiz |
| 2949 | 2841 | } = state; |
| 2950 | - | |
| 2951 | 2842 | if (prop) { |
| 2952 | 2843 | return get(userQuiz, prop); |
| 2953 | 2844 | } |
| 2954 | - | |
| 2955 | 2845 | return userQuiz; |
| 2956 | 2846 | } |
| 2957 | 2847 | function getDefaultRestArgs(state) { |
| 2958 | 2848 | const { |
| @@ -2974,8 +2864,9 @@ | ||
| 2974 | 2864 | userQuiz |
| 2975 | 2865 | } = state; |
| 2976 | 2866 | return get(userQuiz, `answered.${id}.mark`) || undefined; |
| 2977 | 2867 | } |
| 2868 | + | |
| 2978 | 2869 | /** |
| 2979 | 2870 | * Get current question is doing. |
| 2980 | 2871 | * |
| 2981 | 2872 | * @param {Object} state |
| @@ -2981,20 +2872,17 @@ | ||
| 2981 | 2872 | * @param {Object} state |
| 2982 | 2873 | * @param {string} ret |
| 2983 | 2874 | * @return {*} |
| 2984 | 2875 | */ |
| 2985 | - | |
| 2986 | -function getCurrentQuestion(state) { | |
| 2987 | - let ret = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | |
| 2876 | +function getCurrentQuestion(state, ret = '') { | |
| 2988 | 2877 | const questionsPerPage = get(state, 'userQuiz.questionsPerPage') || 1; |
| 2989 | - | |
| 2990 | 2878 | if (questionsPerPage > 1) { |
| 2991 | 2879 | return false; |
| 2992 | 2880 | } |
| 2993 | - | |
| 2994 | 2881 | const currentPage = get(state, 'userQuiz.currentPage') || 1; |
| 2995 | 2882 | return ret === 'object' ? get(state, `userQuiz.questions[${currentPage - 1}]`) : get(state, `userQuiz.questionIds[${currentPage - 1}]`); |
| 2996 | 2883 | } |
| 2884 | + | |
| 2997 | 2885 | /** |
| 2998 | 2886 | * Return a question contains fully data with title, content, ... |
| 2999 | 2887 | * |
| 3000 | 2888 | * @param state |
| @@ -2999,9 +2887,8 @@ | ||
| 2999 | 2887 | * |
| 3000 | 2888 | * @param state |
| 3001 | 2889 | * @param theId |
| 3002 | 2890 | */ |
| 3003 | - | |
| 3004 | 2891 | const getQuestion = function getQuestion(state, theId) { |
| 3005 | 2892 | const { |
| 3006 | 2893 | userQuiz |
| 3007 | 2894 | } = state; |
| @@ -3019,14 +2906,14 @@ | ||
| 3019 | 2906 | * @param {Object} state - Global state for app. |
| 3020 | 2907 | * @param {number} id |
| 3021 | 2908 | * @return {boolean} |
| 3022 | 2909 | */ |
| 3023 | - | |
| 3024 | 2910 | function isCheckedAnswer(state, id) { |
| 3025 | 2911 | const checkedQuestions = get(state, 'userQuiz.checkedQuestions') || []; |
| 3026 | 2912 | return checkedQuestions.indexOf(id) !== -1; |
| 3027 | 2913 | } |
| 3028 | 2914 | function isCorrect(state, id) {} |
| 2915 | + | |
| 3029 | 2916 | /** |
| 3030 | 2917 | * Get questions user has selected answers. |
| 3031 | 2918 | * |
| 3032 | 2919 | * @param {Object} state. Global app state |
| @@ -3033,29 +2920,25 @@ | ||
| 3033 | 2920 | * @param state |
| 3034 | 2921 | * @param {number} questionId |
| 3035 | 2922 | * @return {{}} |
| 3036 | 2923 | */ |
| 3037 | - | |
| 3038 | 2924 | const getQuestionsSelectedAnswers = function (state, questionId) { |
| 3039 | 2925 | const data = get(state, 'userQuiz.answered'); |
| 3040 | 2926 | const returnData = {}; |
| 3041 | - | |
| 3042 | 2927 | for (const loopId in data) { |
| 3043 | 2928 | if (!data.hasOwnProperty(loopId)) { |
| 3044 | 2929 | continue; |
| 3045 | - } // Answer filled by user | |
| 2930 | + } | |
| 3046 | 2931 | |
| 3047 | - | |
| 2932 | + // Answer filled by user | |
| 3048 | 2933 | if (data[loopId].temp || data[loopId].blanks) { |
| 3049 | 2934 | // If specific a question then return it only. |
| 3050 | 2935 | if (questionId && loopId === questionId) { |
| 3051 | 2936 | return data[loopId].answered; |
| 3052 | 2937 | } |
| 3053 | - | |
| 3054 | 2938 | returnData[loopId] = data[loopId].answered; |
| 3055 | 2939 | } |
| 3056 | 2940 | } |
| 3057 | - | |
| 3058 | 2941 | return returnData; |
| 3059 | 2942 | }; |
| 3060 | 2943 | |
| 3061 | 2944 | |
| @@ -3065,9 +2948,8 @@ | ||
| 3065 | 2948 | * |
| 3066 | 2949 | * @param state |
| 3067 | 2950 | * @return {number} |
| 3068 | 2951 | */ |
| 3069 | - | |
| 3070 | 2952 | function getUserMark(state) { |
| 3071 | 2953 | const userQuiz = state.userQuiz || {}; |
| 3072 | 2954 | const { |
| 3073 | 2955 | answered, |
| @@ -3075,14 +2957,12 @@ | ||
| 3075 | 2957 | questions, |
| 3076 | 2958 | checkedQuestions |
| 3077 | 2959 | } = userQuiz; |
| 3078 | 2960 | let totalMark = 0; |
| 3079 | - | |
| 3080 | 2961 | for (let id in answered) { |
| 3081 | 2962 | if (!answered.hasOwnProperty(id)) { |
| 3082 | 2963 | continue; |
| 3083 | 2964 | } |
| 3084 | - | |
| 3085 | 2965 | id = parseInt(id); |
| 3086 | 2966 | const data = answered[id]; |
| 3087 | 2967 | const questionMark = data.questionMark ? data.questionMark : function () { |
| 3088 | 2968 | const question = questions.find(q => { |
| @@ -3090,13 +2970,11 @@ | ||
| 3090 | 2970 | }); |
| 3091 | 2971 | return question ? question.point : 0; |
| 3092 | 2972 | }(); |
| 3093 | 2973 | const isChecked = checkedQuestions.indexOf(id) !== -1; |
| 3094 | - | |
| 3095 | 2974 | if (data.temp) { |
| 3096 | 2975 | continue; |
| 3097 | 2976 | } |
| 3098 | - | |
| 3099 | 2977 | if (negativeMarking) { |
| 3100 | 2978 | if (data.answered) { |
| 3101 | 2979 | totalMark = data.correct ? totalMark + data.mark : totalMark - questionMark; |
| 3102 | 2980 | } |
| @@ -3103,40 +2981,38 @@ | ||
| 3103 | 2981 | } else if (data.answered && data.correct) { |
| 3104 | 2982 | totalMark += data.mark; |
| 3105 | 2983 | } |
| 3106 | 2984 | } |
| 3107 | - | |
| 3108 | 2985 | return totalMark > 0 ? totalMark : 0; |
| 3109 | 2986 | } |
| 3110 | 2987 | |
| 3111 | -/***/ }), | |
| 2988 | +/***/ }, | |
| 3112 | 2989 | |
| 3113 | -/***/ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js": | |
| 2990 | +/***/ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js" | |
| 3114 | 2991 | /*!**********************************************************************!*\ |
| 3115 | 2992 | !*** ./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js ***! |
| 3116 | 2993 | \**********************************************************************/ |
| 3117 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 2994 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 3118 | 2995 | |
| 3119 | 2996 | "use strict"; |
| 3120 | 2997 | __webpack_require__.r(__webpack_exports__); |
| 2998 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 2999 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 3000 | +/* harmony export */ }); | |
| 3121 | 3001 | /* harmony import */ var _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/lp-modal-overlay */ "./assets/src/apps/js/utils/lp-modal-overlay.js"); |
| 3122 | 3002 | |
| 3123 | 3003 | const lpModalOverlayCompleteItem = { |
| 3124 | 3004 | elBtnFinishCourse: null, |
| 3125 | 3005 | elBtnCompleteItem: null, |
| 3126 | - | |
| 3127 | 3006 | init() { |
| 3128 | 3007 | if (!_utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].init()) { |
| 3129 | 3008 | return; |
| 3130 | 3009 | } |
| 3131 | - | |
| 3132 | 3010 | if (undefined === lpGlobalSettings || 'yes' !== lpGlobalSettings.option_enable_popup_confirm_finish) { |
| 3133 | 3011 | return; |
| 3134 | 3012 | } |
| 3135 | - | |
| 3136 | 3013 | this.elBtnFinishCourse = document.querySelectorAll('.lp-btn-finish-course'); |
| 3137 | 3014 | this.elBtnCompleteItem = document.querySelector('.lp-btn-complete-item'); |
| 3138 | - | |
| 3139 | 3015 | if (this.elBtnCompleteItem) { |
| 3140 | 3016 | this.elBtnCompleteItem.addEventListener('click', e => { |
| 3141 | 3017 | e.preventDefault(); |
| 3142 | 3018 | const form = e.target.closest('form'); |
| @@ -3141,16 +3017,19 @@ | ||
| 3141 | 3017 | e.preventDefault(); |
| 3142 | 3018 | const form = e.target.closest('form'); |
| 3143 | 3019 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show(); |
| 3144 | 3020 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title); |
| 3145 | - _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>'); | |
| 3146 | - | |
| 3021 | + // ESC html | |
| 3022 | + const div = document.createElement('div'); | |
| 3023 | + div.appendChild(document.createTextNode(form.dataset.confirm)); | |
| 3024 | + const contentModal = div.innerHTML; | |
| 3025 | + // End ESC html | |
| 3026 | + _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + contentModal + '</div>'); | |
| 3147 | 3027 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = () => { |
| 3148 | 3028 | form.submit(); |
| 3149 | 3029 | }; |
| 3150 | 3030 | }); |
| 3151 | 3031 | } |
| 3152 | - | |
| 3153 | 3032 | if (this.elBtnFinishCourse) { |
| 3154 | 3033 | this.elBtnFinishCourse.forEach(element => element.addEventListener('click', e => { |
| 3155 | 3034 | e.preventDefault(); |
| 3156 | 3035 | const form = e.target.closest('form'); |
| @@ -3156,9 +3035,8 @@ | ||
| 3156 | 3035 | const form = e.target.closest('form'); |
| 3157 | 3036 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].elLPOverlay.show(); |
| 3158 | 3037 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setTitleModal(form.dataset.title); |
| 3159 | 3038 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].setContentModal('<div class="pd-2em">' + form.dataset.confirm + '</div>'); |
| 3160 | - | |
| 3161 | 3039 | _utils_lp_modal_overlay__WEBPACK_IMPORTED_MODULE_0__["default"].callBackYes = () => { |
| 3162 | 3040 | form.submit(); |
| 3163 | 3041 | }; |
| 3164 | 3042 | })); |
| @@ -3163,19 +3041,18 @@ | ||
| 3163 | 3041 | }; |
| 3164 | 3042 | })); |
| 3165 | 3043 | } |
| 3166 | 3044 | } |
| 3167 | - | |
| 3168 | 3045 | }; |
| 3169 | -/* harmony default export */ __webpack_exports__["default"] = (lpModalOverlayCompleteItem); | |
| 3046 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlayCompleteItem); | |
| 3170 | 3047 | |
| 3171 | -/***/ }), | |
| 3048 | +/***/ }, | |
| 3172 | 3049 | |
| 3173 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js": | |
| 3050 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js" | |
| 3174 | 3051 | /*!********************************************************************************!*\ |
| 3175 | 3052 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/compatible.js ***! |
| 3176 | 3053 | \********************************************************************************/ |
| 3177 | -/***/ (function() { | |
| 3054 | +() { | |
| 3178 | 3055 | |
| 3179 | 3056 | /** |
| 3180 | 3057 | * Compatible with Page Builder. |
| 3181 | 3058 | * |
| @@ -3180,45 +3057,40 @@ | ||
| 3180 | 3057 | * Compatible with Page Builder. |
| 3181 | 3058 | * |
| 3182 | 3059 | * @author nhamdv |
| 3183 | 3060 | */ |
| 3061 | + | |
| 3184 | 3062 | LP.Hook.addAction('lp-compatible-builder', () => { |
| 3185 | 3063 | LP.Hook.removeAction('lp-compatible-builder'); |
| 3186 | - | |
| 3187 | 3064 | if (typeof elementorFrontend !== 'undefined') { |
| 3188 | 3065 | [...document.querySelectorAll('#popup-content')][0].addEventListener('scroll', () => { |
| 3189 | - Waypoint.refreshAll(); | |
| 3066 | + //Waypoint.refreshAll(); | |
| 3190 | 3067 | window.dispatchEvent(new Event('resize')); |
| 3191 | 3068 | }); |
| 3192 | 3069 | } |
| 3193 | 3070 | |
| 3194 | - if (typeof vc_js !== 'undefined' && typeof VcWaypoint !== 'undefined') { | |
| 3195 | - [...document.querySelectorAll('#popup-content')][0].addEventListener('scroll', () => { | |
| 3196 | - VcWaypoint.refreshAll(); | |
| 3197 | - }); | |
| 3198 | - } | |
| 3071 | + /*if ( typeof vc_js !== 'undefined' && typeof VcWaypoint !== 'undefined' ) { | |
| 3072 | + [ ...document.querySelectorAll( '#popup-content' ) ][ 0 ].addEventListener( 'scroll', () => { | |
| 3073 | + VcWaypoint.refreshAll(); | |
| 3074 | + } ); | |
| 3075 | + }*/ | |
| 3199 | 3076 | }); |
| 3200 | 3077 | LP.Hook.addAction('lp-quiz-compatible-builder', () => { |
| 3201 | 3078 | LP.Hook.removeAction('lp-quiz-compatible-builder'); |
| 3202 | 3079 | LP.Hook.doAction('lp-compatible-builder'); |
| 3203 | - | |
| 3204 | 3080 | if (typeof elementorFrontend !== 'undefined') { |
| 3205 | 3081 | return window.elementorFrontend.init(); |
| 3206 | 3082 | } |
| 3207 | - | |
| 3208 | 3083 | if (typeof vc_js !== 'undefined') { |
| 3209 | 3084 | if (typeof vc_round_charts !== 'undefined') { |
| 3210 | 3085 | vc_round_charts(); |
| 3211 | 3086 | } |
| 3212 | - | |
| 3213 | 3087 | if (typeof vc_pieChart !== 'undefined') { |
| 3214 | 3088 | vc_pieChart(); |
| 3215 | 3089 | } |
| 3216 | - | |
| 3217 | 3090 | if (typeof vc_line_charts !== 'undefined') { |
| 3218 | 3091 | vc_line_charts(); |
| 3219 | 3092 | } |
| 3220 | - | |
| 3221 | 3093 | return window.vc_js(); |
| 3222 | 3094 | } |
| 3223 | 3095 | }); |
| 3224 | 3096 | LP.Hook.addAction('lp-question-compatible-builder', () => { |
| @@ -3224,43 +3096,38 @@ | ||
| 3224 | 3096 | LP.Hook.addAction('lp-question-compatible-builder', () => { |
| 3225 | 3097 | LP.Hook.removeAction('lp-question-compatible-builder'); |
| 3226 | 3098 | LP.Hook.removeAction('lp-quiz-compatible-builder'); |
| 3227 | 3099 | LP.Hook.doAction('lp-compatible-builder'); |
| 3228 | - | |
| 3229 | 3100 | if (typeof elementorFrontend !== 'undefined') { |
| 3230 | 3101 | return window.elementorFrontend.init(); |
| 3231 | 3102 | } |
| 3232 | - | |
| 3233 | 3103 | if (typeof vc_js !== 'undefined') { |
| 3234 | 3104 | if (typeof vc_round_charts !== 'undefined') { |
| 3235 | 3105 | vc_round_charts(); |
| 3236 | 3106 | } |
| 3237 | - | |
| 3238 | 3107 | if (typeof vc_pieChart !== 'undefined') { |
| 3239 | 3108 | vc_pieChart(); |
| 3240 | 3109 | } |
| 3241 | - | |
| 3242 | 3110 | if (typeof vc_line_charts !== 'undefined') { |
| 3243 | 3111 | vc_line_charts(); |
| 3244 | 3112 | } |
| 3245 | - | |
| 3246 | 3113 | return window.vc_js(); |
| 3247 | 3114 | } |
| 3248 | 3115 | }); |
| 3249 | 3116 | |
| 3250 | -/***/ }), | |
| 3117 | +/***/ }, | |
| 3251 | 3118 | |
| 3252 | -/***/ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js": | |
| 3119 | +/***/ "./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js" | |
| 3253 | 3120 | /*!************************************************************************************!*\ |
| 3254 | 3121 | !*** ./assets/src/apps/js/frontend/single-curriculum/components/items-progress.js ***! |
| 3255 | 3122 | \************************************************************************************/ |
| 3256 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 3123 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 3257 | 3124 | |
| 3258 | 3125 | "use strict"; |
| 3259 | 3126 | __webpack_require__.r(__webpack_exports__); |
| 3260 | 3127 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3261 | -/* harmony export */ "getResponse": function() { return /* binding */ getResponse; }, | |
| 3262 | -/* harmony export */ "itemsProgress": function() { return /* binding */ itemsProgress; } | |
| 3128 | +/* harmony export */ getResponse: () => (/* binding */ getResponse), | |
| 3129 | +/* harmony export */ itemsProgress: () => (/* binding */ itemsProgress) | |
| 3263 | 3130 | /* harmony export */ }); |
| 3264 | 3131 | /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); |
| 3265 | 3132 | /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__); |
| 3266 | 3133 | /* harmony import */ var _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../show-lp-overlay-complete-item */ "./assets/src/apps/js/frontend/show-lp-overlay-complete-item.js"); |
| @@ -3268,21 +3135,21 @@ | ||
| 3268 | 3135 | |
| 3269 | 3136 | |
| 3270 | 3137 | const itemsProgress = () => { |
| 3271 | 3138 | const elements = document.querySelectorAll('.popup-header__inner'); |
| 3272 | - | |
| 3273 | 3139 | if (!elements.length) { |
| 3274 | 3140 | return; |
| 3275 | 3141 | } |
| 3276 | - | |
| 3277 | 3142 | if (document.querySelector('#learn-press-quiz-app div.quiz-result') !== null) { |
| 3278 | 3143 | return; |
| 3279 | 3144 | } |
| 3280 | - | |
| 3281 | 3145 | if (elements[0].querySelectorAll('form.form-button-finish-course').length !== 0) { |
| 3282 | 3146 | return; |
| 3283 | 3147 | } |
| 3284 | - | |
| 3148 | + const user_id = lpGlobalSettings.user_id || 0; | |
| 3149 | + if (user_id === 0) { | |
| 3150 | + return; | |
| 3151 | + } | |
| 3285 | 3152 | if ('IntersectionObserver' in window) { |
| 3286 | 3153 | const eleObserver = new IntersectionObserver((entries, observer) => { |
| 3287 | 3154 | entries.forEach(entry => { |
| 3288 | 3155 | if (entry.isIntersecting) { |
| @@ -3306,21 +3173,25 @@ | ||
| 3306 | 3173 | const { |
| 3307 | 3174 | data |
| 3308 | 3175 | } = response; |
| 3309 | 3176 | ele.innerHTML += data; |
| 3177 | + ele.classList.add('can-finish-course'); | |
| 3310 | 3178 | _show_lp_overlay_complete_item__WEBPACK_IMPORTED_MODULE_1__["default"].init(); |
| 3311 | 3179 | }; |
| 3312 | 3180 | |
| 3313 | -/***/ }), | |
| 3181 | +/***/ }, | |
| 3314 | 3182 | |
| 3315 | -/***/ "./assets/src/apps/js/utils/lp-modal-overlay.js": | |
| 3183 | +/***/ "./assets/src/apps/js/utils/lp-modal-overlay.js" | |
| 3316 | 3184 | /*!******************************************************!*\ |
| 3317 | 3185 | !*** ./assets/src/apps/js/utils/lp-modal-overlay.js ***! |
| 3318 | 3186 | \******************************************************/ |
| 3319 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 3187 | +(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 3320 | 3188 | |
| 3321 | 3189 | "use strict"; |
| 3322 | 3190 | __webpack_require__.r(__webpack_exports__); |
| 3191 | +/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3192 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) | |
| 3193 | +/* harmony export */ }); | |
| 3323 | 3194 | const $ = jQuery; |
| 3324 | 3195 | let elLPOverlay = null; |
| 3325 | 3196 | const lpModalOverlay = { |
| 3326 | 3197 | elLPOverlay: null, |
| @@ -3331,20 +3202,16 @@ | ||
| 3331 | 3202 | elFooter: null, |
| 3332 | 3203 | elCalledModal: null, |
| 3333 | 3204 | callBackYes: null, |
| 3334 | 3205 | instance: null, |
| 3335 | - | |
| 3336 | 3206 | init() { |
| 3337 | 3207 | if (this.instance) { |
| 3338 | 3208 | return true; |
| 3339 | 3209 | } |
| 3340 | - | |
| 3341 | 3210 | this.elLPOverlay = $('.lp-overlay'); |
| 3342 | - | |
| 3343 | 3211 | if (!this.elLPOverlay.length) { |
| 3344 | 3212 | return false; |
| 3345 | 3213 | } |
| 3346 | - | |
| 3347 | 3214 | elLPOverlay = this.elLPOverlay; |
| 3348 | 3215 | this.elMainContent = elLPOverlay.find('.main-content'); |
| 3349 | 3216 | this.elTitle = elLPOverlay.find('.modal-title'); |
| 3350 | 3217 | this.elBtnYes = elLPOverlay.find('.btn-yes'); |
| @@ -3355,110 +3222,37 @@ | ||
| 3355 | 3222 | }); |
| 3356 | 3223 | $(document).on('click', '.btn-yes', function (e) { |
| 3357 | 3224 | e.preventDefault(); |
| 3358 | 3225 | e.stopPropagation(); |
| 3359 | - | |
| 3360 | 3226 | if ('function' === typeof lpModalOverlay.callBackYes) { |
| 3361 | - lpModalOverlay.callBackYes(); | |
| 3227 | + lpModalOverlay.callBackYes(e); | |
| 3362 | 3228 | } |
| 3363 | 3229 | }); |
| 3364 | 3230 | this.instance = this; |
| 3365 | 3231 | return true; |
| 3366 | 3232 | }, |
| 3367 | - | |
| 3368 | 3233 | setElCalledModal(elCalledModal) { |
| 3369 | 3234 | this.elCalledModal = elCalledModal; |
| 3370 | 3235 | }, |
| 3371 | - | |
| 3372 | 3236 | setContentModal(content, event) { |
| 3373 | 3237 | this.elMainContent.html(content); |
| 3374 | - | |
| 3375 | 3238 | if ('function' === typeof event) { |
| 3376 | 3239 | event(); |
| 3377 | 3240 | } |
| 3378 | 3241 | }, |
| 3379 | - | |
| 3380 | 3242 | setTitleModal(content) { |
| 3381 | 3243 | this.elTitle.html(content); |
| 3382 | 3244 | } |
| 3383 | - | |
| 3384 | 3245 | }; |
| 3385 | -/* harmony default export */ __webpack_exports__["default"] = (lpModalOverlay); | |
| 3246 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lpModalOverlay); | |
| 3386 | 3247 | |
| 3387 | -/***/ }), | |
| 3248 | +/***/ }, | |
| 3388 | 3249 | |
| 3389 | -/***/ "./node_modules/classnames/index.js": | |
| 3390 | -/*!******************************************!*\ | |
| 3391 | - !*** ./node_modules/classnames/index.js ***! | |
| 3392 | - \******************************************/ | |
| 3393 | -/***/ (function(module, exports) { | |
| 3394 | - | |
| 3395 | -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! | |
| 3396 | - Copyright (c) 2018 Jed Watson. | |
| 3397 | - Licensed under the MIT License (MIT), see | |
| 3398 | - http://jedwatson.github.io/classnames | |
| 3399 | -*/ | |
| 3400 | -/* global define */ | |
| 3401 | - | |
| 3402 | -(function () { | |
| 3403 | - 'use strict'; | |
| 3404 | - | |
| 3405 | - var hasOwn = {}.hasOwnProperty; | |
| 3406 | - | |
| 3407 | - function classNames() { | |
| 3408 | - var classes = []; | |
| 3409 | - | |
| 3410 | - for (var i = 0; i < arguments.length; i++) { | |
| 3411 | - var arg = arguments[i]; | |
| 3412 | - if (!arg) continue; | |
| 3413 | - | |
| 3414 | - var argType = typeof arg; | |
| 3415 | - | |
| 3416 | - if (argType === 'string' || argType === 'number') { | |
| 3417 | - classes.push(arg); | |
| 3418 | - } else if (Array.isArray(arg)) { | |
| 3419 | - if (arg.length) { | |
| 3420 | - var inner = classNames.apply(null, arg); | |
| 3421 | - if (inner) { | |
| 3422 | - classes.push(inner); | |
| 3423 | - } | |
| 3424 | - } | |
| 3425 | - } else if (argType === 'object') { | |
| 3426 | - if (arg.toString === Object.prototype.toString) { | |
| 3427 | - for (var key in arg) { | |
| 3428 | - if (hasOwn.call(arg, key) && arg[key]) { | |
| 3429 | - classes.push(key); | |
| 3430 | - } | |
| 3431 | - } | |
| 3432 | - } else { | |
| 3433 | - classes.push(arg.toString()); | |
| 3434 | - } | |
| 3435 | - } | |
| 3436 | - } | |
| 3437 | - | |
| 3438 | - return classes.join(' '); | |
| 3439 | - } | |
| 3440 | - | |
| 3441 | - if ( true && module.exports) { | |
| 3442 | - classNames.default = classNames; | |
| 3443 | - module.exports = classNames; | |
| 3444 | - } else if (true) { | |
| 3445 | - // register as 'classnames', consistent with npm package name | |
| 3446 | - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { | |
| 3447 | - return classNames; | |
| 3448 | - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | |
| 3449 | - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | |
| 3450 | - } else {} | |
| 3451 | -}()); | |
| 3452 | - | |
| 3453 | - | |
| 3454 | -/***/ }), | |
| 3455 | - | |
| 3456 | -/***/ "./node_modules/refx/refx.js": | |
| 3250 | +/***/ "./node_modules/refx/refx.js" | |
| 3457 | 3251 | /*!***********************************!*\ |
| 3458 | 3252 | !*** ./node_modules/refx/refx.js ***! |
| 3459 | 3253 | \***********************************/ |
| 3460 | -/***/ (function(module) { | |
| 3254 | +(module) { | |
| 3461 | 3255 | |
| 3462 | 3256 | "use strict"; |
| 3463 | 3257 | |
| 3464 | 3258 | |
| @@ -3509,149 +3303,188 @@ | ||
| 3509 | 3303 | |
| 3510 | 3304 | module.exports = refx; |
| 3511 | 3305 | |
| 3512 | 3306 | |
| 3513 | -/***/ }), | |
| 3307 | +/***/ }, | |
| 3514 | 3308 | |
| 3515 | -/***/ "@learnpress/data-controls": | |
| 3309 | +/***/ "react" | |
| 3310 | +/*!************************!*\ | |
| 3311 | + !*** external "React" ***! | |
| 3312 | + \************************/ | |
| 3313 | +(module) { | |
| 3314 | + | |
| 3315 | +"use strict"; | |
| 3316 | +module.exports = window["React"]; | |
| 3317 | + | |
| 3318 | +/***/ }, | |
| 3319 | + | |
| 3320 | +/***/ "@learnpress/data-controls" | |
| 3516 | 3321 | /*!**************************************!*\ |
| 3517 | 3322 | !*** external ["LP","dataControls"] ***! |
| 3518 | 3323 | \**************************************/ |
| 3519 | -/***/ (function(module) { | |
| 3324 | +(module) { | |
| 3520 | 3325 | |
| 3521 | 3326 | "use strict"; |
| 3522 | 3327 | module.exports = window["LP"]["dataControls"]; |
| 3523 | 3328 | |
| 3524 | -/***/ }), | |
| 3329 | +/***/ }, | |
| 3525 | 3330 | |
| 3526 | -/***/ "@wordpress/compose": | |
| 3331 | +/***/ "@wordpress/compose" | |
| 3527 | 3332 | /*!*********************************!*\ |
| 3528 | 3333 | !*** external ["wp","compose"] ***! |
| 3529 | 3334 | \*********************************/ |
| 3530 | -/***/ (function(module) { | |
| 3335 | +(module) { | |
| 3531 | 3336 | |
| 3532 | 3337 | "use strict"; |
| 3533 | 3338 | module.exports = window["wp"]["compose"]; |
| 3534 | 3339 | |
| 3535 | -/***/ }), | |
| 3340 | +/***/ }, | |
| 3536 | 3341 | |
| 3537 | -/***/ "@wordpress/data": | |
| 3342 | +/***/ "@wordpress/data" | |
| 3538 | 3343 | /*!******************************!*\ |
| 3539 | 3344 | !*** external ["wp","data"] ***! |
| 3540 | 3345 | \******************************/ |
| 3541 | -/***/ (function(module) { | |
| 3346 | +(module) { | |
| 3542 | 3347 | |
| 3543 | 3348 | "use strict"; |
| 3544 | 3349 | module.exports = window["wp"]["data"]; |
| 3545 | 3350 | |
| 3546 | -/***/ }), | |
| 3351 | +/***/ }, | |
| 3547 | 3352 | |
| 3548 | -/***/ "@wordpress/element": | |
| 3353 | +/***/ "@wordpress/element" | |
| 3549 | 3354 | /*!*********************************!*\ |
| 3550 | 3355 | !*** external ["wp","element"] ***! |
| 3551 | 3356 | \*********************************/ |
| 3552 | -/***/ (function(module) { | |
| 3357 | +(module) { | |
| 3553 | 3358 | |
| 3554 | 3359 | "use strict"; |
| 3555 | 3360 | module.exports = window["wp"]["element"]; |
| 3556 | 3361 | |
| 3557 | -/***/ }), | |
| 3362 | +/***/ }, | |
| 3558 | 3363 | |
| 3559 | -/***/ "@wordpress/i18n": | |
| 3364 | +/***/ "@wordpress/i18n" | |
| 3560 | 3365 | /*!******************************!*\ |
| 3561 | 3366 | !*** external ["wp","i18n"] ***! |
| 3562 | 3367 | \******************************/ |
| 3563 | -/***/ (function(module) { | |
| 3368 | +(module) { | |
| 3564 | 3369 | |
| 3565 | 3370 | "use strict"; |
| 3566 | 3371 | module.exports = window["wp"]["i18n"]; |
| 3567 | 3372 | |
| 3568 | -/***/ }), | |
| 3373 | +/***/ }, | |
| 3569 | 3374 | |
| 3570 | -/***/ "@wordpress/url": | |
| 3375 | +/***/ "@wordpress/url" | |
| 3571 | 3376 | /*!*****************************!*\ |
| 3572 | 3377 | !*** external ["wp","url"] ***! |
| 3573 | 3378 | \*****************************/ |
| 3574 | -/***/ (function(module) { | |
| 3379 | +(module) { | |
| 3575 | 3380 | |
| 3576 | 3381 | "use strict"; |
| 3577 | 3382 | module.exports = window["wp"]["url"]; |
| 3578 | 3383 | |
| 3579 | -/***/ }), | |
| 3384 | +/***/ }, | |
| 3580 | 3385 | |
| 3581 | -/***/ "./node_modules/@babel/runtime/helpers/esm/defineProperty.js": | |
| 3582 | -/*!*******************************************************************!*\ | |
| 3583 | - !*** ./node_modules/@babel/runtime/helpers/esm/defineProperty.js ***! | |
| 3584 | - \*******************************************************************/ | |
| 3585 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3386 | +/***/ "./node_modules/classnames/index.js" | |
| 3387 | +/*!******************************************!*\ | |
| 3388 | + !*** ./node_modules/classnames/index.js ***! | |
| 3389 | + \******************************************/ | |
| 3390 | +(module, exports) { | |
| 3586 | 3391 | |
| 3587 | -"use strict"; | |
| 3588 | -__webpack_require__.r(__webpack_exports__); | |
| 3589 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3590 | -/* harmony export */ "default": function() { return /* binding */ _defineProperty; } | |
| 3591 | -/* harmony export */ }); | |
| 3592 | -function _defineProperty(obj, key, value) { | |
| 3593 | - if (key in obj) { | |
| 3594 | - Object.defineProperty(obj, key, { | |
| 3595 | - value: value, | |
| 3596 | - enumerable: true, | |
| 3597 | - configurable: true, | |
| 3598 | - writable: true | |
| 3599 | - }); | |
| 3600 | - } else { | |
| 3601 | - obj[key] = value; | |
| 3602 | - } | |
| 3392 | +var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! | |
| 3393 | + Copyright (c) 2018 Jed Watson. | |
| 3394 | + Licensed under the MIT License (MIT), see | |
| 3395 | + http://jedwatson.github.io/classnames | |
| 3396 | +*/ | |
| 3397 | +/* global define */ | |
| 3603 | 3398 | |
| 3604 | - return obj; | |
| 3605 | -} | |
| 3399 | +(function () { | |
| 3400 | + 'use strict'; | |
| 3606 | 3401 | |
| 3607 | -/***/ }), | |
| 3402 | + var hasOwn = {}.hasOwnProperty; | |
| 3608 | 3403 | |
| 3609 | -/***/ "./node_modules/@babel/runtime/helpers/esm/extends.js": | |
| 3610 | -/*!************************************************************!*\ | |
| 3611 | - !*** ./node_modules/@babel/runtime/helpers/esm/extends.js ***! | |
| 3612 | - \************************************************************/ | |
| 3613 | -/***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) { | |
| 3404 | + function classNames () { | |
| 3405 | + var classes = ''; | |
| 3614 | 3406 | |
| 3615 | -"use strict"; | |
| 3616 | -__webpack_require__.r(__webpack_exports__); | |
| 3617 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 3618 | -/* harmony export */ "default": function() { return /* binding */ _extends; } | |
| 3619 | -/* harmony export */ }); | |
| 3620 | -function _extends() { | |
| 3621 | - _extends = Object.assign || function (target) { | |
| 3622 | - for (var i = 1; i < arguments.length; i++) { | |
| 3623 | - var source = arguments[i]; | |
| 3407 | + for (var i = 0; i < arguments.length; i++) { | |
| 3408 | + var arg = arguments[i]; | |
| 3409 | + if (arg) { | |
| 3410 | + classes = appendClass(classes, parseValue(arg)); | |
| 3411 | + } | |
| 3412 | + } | |
| 3624 | 3413 | |
| 3625 | - for (var key in source) { | |
| 3626 | - if (Object.prototype.hasOwnProperty.call(source, key)) { | |
| 3627 | - target[key] = source[key]; | |
| 3628 | - } | |
| 3629 | - } | |
| 3630 | - } | |
| 3414 | + return classes; | |
| 3415 | + } | |
| 3631 | 3416 | |
| 3632 | - return target; | |
| 3633 | - }; | |
| 3417 | + function parseValue (arg) { | |
| 3418 | + if (typeof arg === 'string' || typeof arg === 'number') { | |
| 3419 | + return arg; | |
| 3420 | + } | |
| 3634 | 3421 | |
| 3635 | - return _extends.apply(this, arguments); | |
| 3636 | -} | |
| 3422 | + if (typeof arg !== 'object') { | |
| 3423 | + return ''; | |
| 3424 | + } | |
| 3637 | 3425 | |
| 3638 | -/***/ }) | |
| 3426 | + if (Array.isArray(arg)) { | |
| 3427 | + return classNames.apply(null, arg); | |
| 3428 | + } | |
| 3639 | 3429 | |
| 3430 | + if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { | |
| 3431 | + return arg.toString(); | |
| 3432 | + } | |
| 3433 | + | |
| 3434 | + var classes = ''; | |
| 3435 | + | |
| 3436 | + for (var key in arg) { | |
| 3437 | + if (hasOwn.call(arg, key) && arg[key]) { | |
| 3438 | + classes = appendClass(classes, key); | |
| 3439 | + } | |
| 3440 | + } | |
| 3441 | + | |
| 3442 | + return classes; | |
| 3443 | + } | |
| 3444 | + | |
| 3445 | + function appendClass (value, newClass) { | |
| 3446 | + if (!newClass) { | |
| 3447 | + return value; | |
| 3448 | + } | |
| 3449 | + | |
| 3450 | + if (value) { | |
| 3451 | + return value + ' ' + newClass; | |
| 3452 | + } | |
| 3453 | + | |
| 3454 | + return value + newClass; | |
| 3455 | + } | |
| 3456 | + | |
| 3457 | + if ( true && module.exports) { | |
| 3458 | + classNames.default = classNames; | |
| 3459 | + module.exports = classNames; | |
| 3460 | + } else if (true) { | |
| 3461 | + // register as 'classnames', consistent with npm package name | |
| 3462 | + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { | |
| 3463 | + return classNames; | |
| 3464 | + }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), | |
| 3465 | + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | |
| 3466 | + } else // removed by dead control flow | |
| 3467 | +{} | |
| 3468 | +}()); | |
| 3469 | + | |
| 3470 | + | |
| 3471 | +/***/ } | |
| 3472 | + | |
| 3640 | 3473 | /******/ }); |
| 3641 | 3474 | /************************************************************************/ |
| 3642 | 3475 | /******/ // The module cache |
| 3643 | -/******/ var __webpack_module_cache__ = {}; | |
| 3476 | +/******/ const __webpack_module_cache__ = {}; | |
| 3644 | 3477 | /******/ |
| 3645 | 3478 | /******/ // The require function |
| 3646 | 3479 | /******/ function __webpack_require__(moduleId) { |
| 3647 | 3480 | /******/ // Check if module is in cache |
| 3648 | -/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 3481 | +/******/ const cachedModule = __webpack_module_cache__[moduleId]; | |
| 3649 | 3482 | /******/ if (cachedModule !== undefined) { |
| 3650 | 3483 | /******/ return cachedModule.exports; |
| 3651 | 3484 | /******/ } |
| 3652 | 3485 | /******/ // Create a new module (and put it into the cache) |
| 3653 | -/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 3486 | +/******/ const module = __webpack_module_cache__[moduleId] = { | |
| 3654 | 3487 | /******/ // no module.id needed |
| 3655 | 3488 | /******/ // no module.loaded needed |
| 3656 | 3489 | /******/ exports: {} |
| 3657 | 3490 | /******/ }; |
| @@ -3656,8 +3489,14 @@ | ||
| 3656 | 3489 | /******/ exports: {} |
| 3657 | 3490 | /******/ }; |
| 3658 | 3491 | /******/ |
| 3659 | 3492 | /******/ // Execute the module function |
| 3493 | +/******/ if (!(moduleId in __webpack_modules__)) { | |
| 3494 | +/******/ delete __webpack_module_cache__[moduleId]; | |
| 3495 | +/******/ const e = new Error("Cannot find module '" + moduleId + "'"); | |
| 3496 | +/******/ e.code = 'MODULE_NOT_FOUND'; | |
| 3497 | +/******/ throw e; | |
| 3498 | +/******/ } | |
| 3660 | 3499 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 3661 | 3500 | /******/ |
| 3662 | 3501 | /******/ // Return the exports of the module |
| 3663 | 3502 | /******/ return module.exports; |
| @@ -3664,51 +3503,66 @@ | ||
| 3664 | 3503 | /******/ } |
| 3665 | 3504 | /******/ |
| 3666 | 3505 | /************************************************************************/ |
| 3667 | 3506 | /******/ /* webpack/runtime/compat get default export */ |
| 3668 | -/******/ !function() { | |
| 3507 | +/******/ (() => { | |
| 3669 | 3508 | /******/ // getDefaultExport function for compatibility with non-harmony modules |
| 3670 | -/******/ __webpack_require__.n = function(module) { | |
| 3671 | -/******/ var getter = module && module.__esModule ? | |
| 3672 | -/******/ function() { return module['default']; } : | |
| 3673 | -/******/ function() { return module; }; | |
| 3509 | +/******/ __webpack_require__.n = (module) => { | |
| 3510 | +/******/ const getter = module && module.__esModule ? | |
| 3511 | +/******/ () => (module['default']) : | |
| 3512 | +/******/ () => (module); | |
| 3674 | 3513 | /******/ __webpack_require__.d(getter, { a: getter }); |
| 3675 | 3514 | /******/ return getter; |
| 3676 | 3515 | /******/ }; |
| 3677 | -/******/ }(); | |
| 3516 | +/******/ })(); | |
| 3678 | 3517 | /******/ |
| 3679 | 3518 | /******/ /* webpack/runtime/define property getters */ |
| 3680 | -/******/ !function() { | |
| 3681 | -/******/ // define getter functions for harmony exports | |
| 3682 | -/******/ __webpack_require__.d = function(exports, definition) { | |
| 3683 | -/******/ for(var key in definition) { | |
| 3684 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 3685 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 3519 | +/******/ (() => { | |
| 3520 | +/******/ // define getter/value functions for harmony exports | |
| 3521 | +/******/ __webpack_require__.d = (exports, definition) => { | |
| 3522 | +/******/ if(Array.isArray(definition)) { | |
| 3523 | +/******/ var i = 0; | |
| 3524 | +/******/ while(i < definition.length) { | |
| 3525 | +/******/ var key = definition[i++]; | |
| 3526 | +/******/ var binding = definition[i++]; | |
| 3527 | +/******/ if(!__webpack_require__.o(exports, key)) { | |
| 3528 | +/******/ if(binding === 0) { | |
| 3529 | +/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] }); | |
| 3530 | +/******/ } else { | |
| 3531 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding }); | |
| 3532 | +/******/ } | |
| 3533 | +/******/ } else if(binding === 0) { i++; } | |
| 3686 | 3534 | /******/ } |
| 3535 | +/******/ } else { | |
| 3536 | +/******/ for(var key in definition) { | |
| 3537 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 3538 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 3539 | +/******/ } | |
| 3540 | +/******/ } | |
| 3687 | 3541 | /******/ } |
| 3688 | 3542 | /******/ }; |
| 3689 | -/******/ }(); | |
| 3543 | +/******/ })(); | |
| 3690 | 3544 | /******/ |
| 3691 | 3545 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 3692 | -/******/ !function() { | |
| 3693 | -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | |
| 3694 | -/******/ }(); | |
| 3546 | +/******/ (() => { | |
| 3547 | +/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop)) | |
| 3548 | +/******/ })(); | |
| 3695 | 3549 | /******/ |
| 3696 | 3550 | /******/ /* webpack/runtime/make namespace object */ |
| 3697 | -/******/ !function() { | |
| 3551 | +/******/ (() => { | |
| 3698 | 3552 | /******/ // define __esModule on exports |
| 3699 | -/******/ __webpack_require__.r = function(exports) { | |
| 3700 | -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 3553 | +/******/ __webpack_require__.r = (exports) => { | |
| 3554 | +/******/ if(Symbol.toStringTag) { | |
| 3701 | 3555 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 3702 | 3556 | /******/ } |
| 3703 | 3557 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 3704 | 3558 | /******/ }; |
| 3705 | -/******/ }(); | |
| 3559 | +/******/ })(); | |
| 3706 | 3560 | /******/ |
| 3707 | 3561 | /************************************************************************/ |
| 3708 | -var __webpack_exports__ = {}; | |
| 3709 | -// This entry need to be wrapped in an IIFE because it need to be in strict mode. | |
| 3710 | -!function() { | |
| 3562 | +let __webpack_exports__ = {}; | |
| 3563 | +// This entry needs to be wrapped in an IIFE because it needs to be in strict mode. | |
| 3564 | +(() => { | |
| 3711 | 3565 | "use strict"; |
| 3712 | 3566 | /*!*********************************************!*\ |
| 3713 | 3567 | !*** ./assets/src/apps/js/frontend/quiz.js ***! |
| 3714 | 3568 | \*********************************************/ |
| @@ -3713,12 +3567,13 @@ | ||
| 3713 | 3567 | !*** ./assets/src/apps/js/frontend/quiz.js ***! |
| 3714 | 3568 | \*********************************************/ |
| 3715 | 3569 | __webpack_require__.r(__webpack_exports__); |
| 3716 | 3570 | /* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 3717 | -/* harmony export */ "init": function() { return /* binding */ init; } | |
| 3571 | +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), | |
| 3572 | +/* harmony export */ init: () => (/* binding */ init) | |
| 3718 | 3573 | /* harmony export */ }); |
| 3719 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); | |
| 3720 | -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); | |
| 3574 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 3575 | +/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 3721 | 3576 | /* harmony import */ var _quiz_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./quiz/index */ "./assets/src/apps/js/frontend/quiz/index.js"); |
| 3722 | 3577 | /* harmony import */ var _single_curriculum_components_compatible__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./single-curriculum/components/compatible */ "./assets/src/apps/js/frontend/single-curriculum/components/compatible.js"); |
| 3723 | 3578 | /* harmony import */ var _single_curriculum_components_compatible__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_single_curriculum_components_compatible__WEBPACK_IMPORTED_MODULE_2__); |
| 3724 | 3579 | |
| @@ -3728,19 +3583,18 @@ | ||
| 3728 | 3583 | modal: { |
| 3729 | 3584 | default: Modal |
| 3730 | 3585 | } |
| 3731 | 3586 | } = LP; |
| 3732 | -/* harmony default export */ __webpack_exports__["default"] = (_quiz_index__WEBPACK_IMPORTED_MODULE_1__["default"]); | |
| 3587 | +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_quiz_index__WEBPACK_IMPORTED_MODULE_1__["default"]); | |
| 3733 | 3588 | const init = (elem, settings) => { |
| 3734 | 3589 | // For no require enroll |
| 3735 | 3590 | if (lpQuizSettings.checkNorequizenroll === 1) { |
| 3736 | 3591 | const keyQuizOff = 'quiz_off_' + lpQuizSettings.id; |
| 3737 | 3592 | const quizDataOffStr = window.localStorage.getItem(keyQuizOff); |
| 3738 | - | |
| 3739 | 3593 | if (null !== quizDataOffStr) { |
| 3740 | 3594 | const quizDataOff = JSON.parse(quizDataOffStr); |
| 3741 | 3595 | settings.status = quizDataOff.status; |
| 3742 | - | |
| 3596 | + settings.questions = quizDataOff.questions; | |
| 3743 | 3597 | if ('started' === quizDataOff.status) { |
| 3744 | 3598 | const now = Date.now(); |
| 3745 | 3599 | settings.total_time = Math.floor((quizDataOff.endTime - now) / 1000); |
| 3746 | 3600 | } else if ('completed' === quizDataOff.status) { |
| @@ -3747,35 +3601,34 @@ | ||
| 3747 | 3601 | settings.results = quizDataOff.results; |
| 3748 | 3602 | settings.answered = quizDataOff.results.answered; |
| 3749 | 3603 | settings.questions = quizDataOff.results.questions; |
| 3750 | 3604 | } |
| 3751 | - | |
| 3752 | 3605 | if (undefined !== quizDataOff.checked_questions) { |
| 3753 | 3606 | settings.checked_questions = quizDataOff.checked_questions; |
| 3754 | 3607 | } |
| 3755 | - | |
| 3756 | 3608 | if (undefined !== quizDataOff.question_options) { |
| 3757 | 3609 | //settings.checked_questions = quizDataOff.checked_questions; |
| 3610 | + | |
| 3758 | 3611 | for (const i in settings.questions) { |
| 3759 | - let question = settings.questions[i]; | |
| 3760 | - | |
| 3612 | + const question = settings.questions[i]; | |
| 3761 | 3613 | if (undefined !== quizDataOff.question_options[question.id]) { |
| 3762 | 3614 | question.options = quizDataOff.question_options[question.id]; |
| 3763 | 3615 | } |
| 3764 | - | |
| 3765 | 3616 | settings.questions[i] = question; |
| 3766 | 3617 | } |
| 3767 | 3618 | } |
| 3768 | 3619 | } |
| 3769 | - } //console.log(settings); | |
| 3620 | + } | |
| 3770 | 3621 | |
| 3622 | + //console.log(settings); | |
| 3771 | 3623 | |
| 3772 | - wp.element.render((0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(Modal, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_quiz_index__WEBPACK_IMPORTED_MODULE_1__["default"], { | |
| 3624 | + wp.element.render((0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(Modal, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_quiz_index__WEBPACK_IMPORTED_MODULE_1__["default"], { | |
| 3773 | 3625 | settings: settings |
| 3774 | 3626 | })), [...document.querySelectorAll(elem)][0]); |
| 3775 | 3627 | LP.Hook.doAction('lp-quiz-compatible-builder'); |
| 3776 | 3628 | }; |
| 3777 | -}(); | |
| 3629 | +})(); | |
| 3630 | + | |
| 3778 | 3631 | (window.LP = window.LP || {}).quiz = __webpack_exports__; |
| 3779 | 3632 | /******/ })() |
| 3780 | 3633 | ; |
| 3781 | 3634 | //# sourceMappingURL=quiz.js.map |