Version Description
= 4.0.0 = In this version, we have to change the database structure, so that if you have installed LP3 on your site before, please backup your site and follow these steps to upgrade.
= 0.9.19 = In this version, we have changed a little bit about LearnPress Plugin directory structure and moved all add-ons to become independent plugins. If you face any problems related to add-ons, please completely remove old version and re-install LearnPress. It does not affect your current data. Thank you.
Download this release
Release Info
Developer | ThimPress |
Plugin | LearnPress – WordPress LMS Plugin |
Version | 4.0.9-beta-1 |
Comparing to | |
See all releases |
Code changes from version 4.0.8 to 4.0.9-beta-1
- assets/css/learnpress.css +91 -38
- assets/js/dist/frontend/profile.js +459 -0
- assets/js/dist/frontend/profile.min.js +1 -0
- assets/js/dist/frontend/quiz.js +7 -2
- assets/js/dist/frontend/quiz.min.js +2 -2
- assets/js/dist/frontend/single-course.min.js +1 -1
- assets/js/dist/frontend/single-curriculum.min.js +1 -1
- assets/src/apps/js/frontend/profile.js +7 -0
- assets/src/apps/js/frontend/profile/course-tab.js +169 -0
- assets/src/apps/js/frontend/profile/statistic.js +45 -0
- assets/src/apps/js/frontend/quiz/components/buttons/index.js +5 -2
- inc/admin/class-lp-admin-menu.php +2 -1
- inc/admin/settings/class-lp-settings-advanced.php +7 -0
- inc/admin/settings/class-lp-settings-profile.php +0 -8
- inc/class-lp-assets.php +21 -5
- inc/curds/class-lp-course-curd.php +3 -2
- inc/curds/class-lp-question-curd.php +1 -1
- inc/curds/class-lp-user-curd.php +12 -0
- inc/databases/class-lp-course-db.php +1 -2
- inc/databases/class-lp-user-items-db.php +38 -0
- inc/jwt/class-jwt-auth.php +1 -0
- inc/jwt/responsive.http +50 -11
- inc/jwt/rest-api/class-rest-api.php +5 -4
- inc/jwt/rest-api/version1/class-lp-rest-posts-controller.php +0 -17
- inc/jwt/rest-api/version1/class-lp-rest-questions-v1-controller.php +297 -0
- inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php +372 -89
- inc/lp-core-functions.php +1 -1
- inc/lp-template-functions.php +4 -3
- inc/rest-api/class-lp-core-api.php +2 -0
- inc/rest-api/v1/frontend/class-lp-rest-profile-controller.php +162 -0
- inc/templates/class-lp-template-course.php +4 -4
- inc/templates/class-lp-template-profile.php +2 -2
- inc/user-item/class-lp-user-item-course.php +43 -17
- inc/user/abstract-lp-user.php +2 -2
- inc/user/class-lp-profile.php +1 -25
- inc/user/lp-user-functions.php +9 -12
- learnpress.php +1 -1
- readme.txt +12 -2
- templates/profile/dashboard/featured-courses.php +0 -51
- templates/profile/dashboard/latest-courses.php +0 -51
- templates/profile/socials.php +7 -2
- templates/profile/tabs/courses.php +78 -51
- templates/profile/tabs/courses/course-grid.php +44 -0
- templates/profile/tabs/courses/course-list.php +57 -0
- templates/profile/tabs/courses/created.php +0 -74
- templates/profile/tabs/courses/enrolled.php +0 -75
- templates/profile/{dashboard → tabs/courses}/general-statistic.php +0 -0
- templates/profile/tabs/courses/index.php +0 -17
- templates/profile/tabs/quizzes.php +4 -0
- templates/single-course/tabs/instructor.php +4 -1
assets/css/learnpress.css
CHANGED
@@ -1636,20 +1636,20 @@ body div.entry-content > div.learnpress {
|
|
1636 |
}
|
1637 |
|
1638 |
#learn-press-profile .wrapper-profile-header .lp-profile-left {
|
1639 |
-
width: 270px;
|
1640 |
position: absolute;
|
1641 |
bottom: 0;
|
1642 |
left: 0;
|
|
|
1643 |
padding: 20px;
|
1644 |
-
background: #fff;
|
1645 |
border: 1px solid rgba(0, 0, 0, 0.1);
|
1646 |
border-bottom: 0;
|
|
|
1647 |
}
|
1648 |
|
1649 |
#learn-press-profile .wrapper-profile-header .lp-profile-right {
|
1650 |
margin-left: 270px;
|
1651 |
-
padding-left: 35px;
|
1652 |
padding-right: 15px;
|
|
|
1653 |
}
|
1654 |
|
1655 |
#learn-press-profile .wrapper-profile-header .lp-profile-right .lp-profile-username {
|
@@ -1671,12 +1671,12 @@ body div.entry-content > div.learnpress {
|
|
1671 |
padding: 20px 15px;
|
1672 |
}
|
1673 |
#learn-press-profile .wrapper-profile-header .lp-profile-left {
|
1674 |
-
position: static;
|
1675 |
float: left;
|
|
|
1676 |
}
|
1677 |
#learn-press-profile .wrapper-profile-header .lp-profile-right {
|
1678 |
-
width: calc(100% - 270px);
|
1679 |
float: right;
|
|
|
1680 |
margin-left: 0;
|
1681 |
}
|
1682 |
}
|
@@ -1689,8 +1689,8 @@ body div.entry-content > div.learnpress {
|
|
1689 |
width: calc(100% - 220px);
|
1690 |
}
|
1691 |
#learn-press-profile .wrapper-profile-header .lp-user-profile-socials {
|
1692 |
-
margin-left: -5px;
|
1693 |
margin-right: -5px;
|
|
|
1694 |
}
|
1695 |
#learn-press-profile .wrapper-profile-header .lp-user-profile-socials a {
|
1696 |
width: 36px;
|
@@ -1707,8 +1707,8 @@ body div.entry-content > div.learnpress {
|
|
1707 |
}
|
1708 |
#learn-press-profile .wrapper-profile-header .lp-profile-right {
|
1709 |
width: 100%;
|
1710 |
-
text-align: center;
|
1711 |
padding-top: 30px;
|
|
|
1712 |
}
|
1713 |
}
|
1714 |
|
@@ -1877,30 +1877,30 @@ body div.entry-content > div.learnpress {
|
|
1877 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs {
|
1878 |
width: max-content;
|
1879 |
}
|
1880 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs
|
1881 |
display: table;
|
1882 |
-
content: "";
|
1883 |
clear: both;
|
|
|
1884 |
}
|
1885 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li {
|
|
|
1886 |
border: none;
|
1887 |
border-right: 1px solid rgba(204, 204, 204, 0.3);
|
1888 |
-
float: left;
|
1889 |
}
|
1890 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a {
|
1891 |
height: auto;
|
1892 |
padding: 0 20px 0 45px;
|
1893 |
}
|
1894 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a
|
1895 |
margin-left: 10px;
|
1896 |
}
|
1897 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.has-child a
|
1898 |
content: "\f077";
|
1899 |
}
|
1900 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active a {
|
1901 |
padding-left: 45px;
|
1902 |
}
|
1903 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active a
|
1904 |
content: "\f078";
|
1905 |
}
|
1906 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active.has-child ul {
|
@@ -1908,11 +1908,11 @@ body div.entry-content > div.learnpress {
|
|
1908 |
width: max-content;
|
1909 |
transform: translateX(-20%);
|
1910 |
}
|
1911 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active.has-child ul
|
1912 |
display: table;
|
1913 |
-
content: "";
|
1914 |
clear: both;
|
1915 |
box-shadow: 0 0 0;
|
|
|
1916 |
}
|
1917 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active.has-child ul li {
|
1918 |
float: left;
|
@@ -1927,7 +1927,7 @@ body div.entry-content > div.learnpress {
|
|
1927 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs li:hover ul {
|
1928 |
display: none !important;
|
1929 |
}
|
1930 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs li:not(.has-child) > a
|
1931 |
display: none;
|
1932 |
}
|
1933 |
}
|
@@ -1939,7 +1939,7 @@ body div.entry-content > div.learnpress {
|
|
1939 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a {
|
1940 |
font-size: 0;
|
1941 |
}
|
1942 |
-
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a
|
1943 |
margin-left: 0;
|
1944 |
}
|
1945 |
}
|
@@ -1963,14 +1963,14 @@ body div.entry-content > div.learnpress {
|
|
1963 |
width: 100%;
|
1964 |
border: 0;
|
1965 |
}
|
1966 |
-
#learn-press-profile #profile-content .learn-press-tabs .learn-press-tabs__nav
|
1967 |
-
content: "";
|
1968 |
-
clear: both;
|
1969 |
display: table;
|
|
|
|
|
1970 |
}
|
1971 |
#learn-press-profile #profile-content .learn-press-tabs .learn-press-tabs__nav .learn-press-tabs__tab {
|
1972 |
-
border-right: 0;
|
1973 |
float: left;
|
|
|
1974 |
}
|
1975 |
#learn-press-profile #profile-content .learn-press-tabs .learn-press-tabs__nav .learn-press-tabs__tab label {
|
1976 |
padding-right: 25px;
|
@@ -2484,6 +2484,69 @@ div.order-recover input[type="text"] {
|
|
2484 |
flex: 1 1 auto;
|
2485 |
}
|
2486 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2487 |
#learn-press-course-tabs .course-tab-panels .course-tab-panel {
|
2488 |
display: none;
|
2489 |
padding-top: 56px;
|
@@ -5363,6 +5426,7 @@ a {
|
|
5363 |
left: 0;
|
5364 |
background: #fff;
|
5365 |
content: "";
|
|
|
5366 |
}
|
5367 |
|
5368 |
.lp-archive-courses form[name="search-course"] {
|
@@ -7579,6 +7643,11 @@ input[type="radio"]:nth-child(19):checked ~ .switch-btn:nth-child(20)::before {
|
|
7579 |
transform: translateX(-50%);
|
7580 |
}
|
7581 |
|
|
|
|
|
|
|
|
|
|
|
7582 |
#popup-course #popup-content #learn-press-quiz-app .quiz-buttons:not(.infinity).is-first .prev {
|
7583 |
display: none;
|
7584 |
}
|
@@ -7625,28 +7694,12 @@ input[type="radio"]:nth-child(19):checked ~ .switch-btn:nth-child(20)::before {
|
|
7625 |
display: inline-block;
|
7626 |
padding: 8px;
|
7627 |
background: transparent;
|
7628 |
-
font-size:
|
7629 |
text-align: center;
|
7630 |
text-decoration: none;
|
7631 |
text-transform: none;
|
7632 |
}
|
7633 |
|
7634 |
-
#popup-course #popup-content #learn-press-quiz-app .questions-pagination .nav-links .page-numbers.prev::before {
|
7635 |
-
color: #999;
|
7636 |
-
font-family: "Font Awesome 5 Free";
|
7637 |
-
font-size: 16px;
|
7638 |
-
font-weight: 900;
|
7639 |
-
content: "\f104";
|
7640 |
-
}
|
7641 |
-
|
7642 |
-
#popup-course #popup-content #learn-press-quiz-app .questions-pagination .nav-links .page-numbers.next::after {
|
7643 |
-
color: #999;
|
7644 |
-
font-family: "Font Awesome 5 Free";
|
7645 |
-
font-size: 16px;
|
7646 |
-
font-weight: 900;
|
7647 |
-
content: "\f105";
|
7648 |
-
}
|
7649 |
-
|
7650 |
#popup-course #popup-content #learn-press-quiz-app .questions-pagination .nav-links .page-numbers.current, #popup-course #popup-content #learn-press-quiz-app .questions-pagination .nav-links .page-numbers:hover {
|
7651 |
color: var(--lp-primary-color);
|
7652 |
}
|
1636 |
}
|
1637 |
|
1638 |
#learn-press-profile .wrapper-profile-header .lp-profile-left {
|
|
|
1639 |
position: absolute;
|
1640 |
bottom: 0;
|
1641 |
left: 0;
|
1642 |
+
width: 270px;
|
1643 |
padding: 20px;
|
|
|
1644 |
border: 1px solid rgba(0, 0, 0, 0.1);
|
1645 |
border-bottom: 0;
|
1646 |
+
background: #fff;
|
1647 |
}
|
1648 |
|
1649 |
#learn-press-profile .wrapper-profile-header .lp-profile-right {
|
1650 |
margin-left: 270px;
|
|
|
1651 |
padding-right: 15px;
|
1652 |
+
padding-left: 35px;
|
1653 |
}
|
1654 |
|
1655 |
#learn-press-profile .wrapper-profile-header .lp-profile-right .lp-profile-username {
|
1671 |
padding: 20px 15px;
|
1672 |
}
|
1673 |
#learn-press-profile .wrapper-profile-header .lp-profile-left {
|
|
|
1674 |
float: left;
|
1675 |
+
position: static;
|
1676 |
}
|
1677 |
#learn-press-profile .wrapper-profile-header .lp-profile-right {
|
|
|
1678 |
float: right;
|
1679 |
+
width: calc(100% - 270px);
|
1680 |
margin-left: 0;
|
1681 |
}
|
1682 |
}
|
1689 |
width: calc(100% - 220px);
|
1690 |
}
|
1691 |
#learn-press-profile .wrapper-profile-header .lp-user-profile-socials {
|
|
|
1692 |
margin-right: -5px;
|
1693 |
+
margin-left: -5px;
|
1694 |
}
|
1695 |
#learn-press-profile .wrapper-profile-header .lp-user-profile-socials a {
|
1696 |
width: 36px;
|
1707 |
}
|
1708 |
#learn-press-profile .wrapper-profile-header .lp-profile-right {
|
1709 |
width: 100%;
|
|
|
1710 |
padding-top: 30px;
|
1711 |
+
text-align: center;
|
1712 |
}
|
1713 |
}
|
1714 |
|
1877 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs {
|
1878 |
width: max-content;
|
1879 |
}
|
1880 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs::after {
|
1881 |
display: table;
|
|
|
1882 |
clear: both;
|
1883 |
+
content: "";
|
1884 |
}
|
1885 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li {
|
1886 |
+
float: left;
|
1887 |
border: none;
|
1888 |
border-right: 1px solid rgba(204, 204, 204, 0.3);
|
|
|
1889 |
}
|
1890 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a {
|
1891 |
height: auto;
|
1892 |
padding: 0 20px 0 45px;
|
1893 |
}
|
1894 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a::after {
|
1895 |
margin-left: 10px;
|
1896 |
}
|
1897 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.has-child a::after {
|
1898 |
content: "\f077";
|
1899 |
}
|
1900 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active a {
|
1901 |
padding-left: 45px;
|
1902 |
}
|
1903 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active a::after {
|
1904 |
content: "\f078";
|
1905 |
}
|
1906 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active.has-child ul {
|
1908 |
width: max-content;
|
1909 |
transform: translateX(-20%);
|
1910 |
}
|
1911 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active.has-child ul::after {
|
1912 |
display: table;
|
|
|
1913 |
clear: both;
|
1914 |
box-shadow: 0 0 0;
|
1915 |
+
content: "";
|
1916 |
}
|
1917 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li.active.has-child ul li {
|
1918 |
float: left;
|
1927 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs li:hover ul {
|
1928 |
display: none !important;
|
1929 |
}
|
1930 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs li:not(.has-child) > a::after {
|
1931 |
display: none;
|
1932 |
}
|
1933 |
}
|
1939 |
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a {
|
1940 |
font-size: 0;
|
1941 |
}
|
1942 |
+
#learn-press-profile #profile-nav .lp-profile-nav-tabs > li > a::after {
|
1943 |
margin-left: 0;
|
1944 |
}
|
1945 |
}
|
1963 |
width: 100%;
|
1964 |
border: 0;
|
1965 |
}
|
1966 |
+
#learn-press-profile #profile-content .learn-press-tabs .learn-press-tabs__nav::after {
|
|
|
|
|
1967 |
display: table;
|
1968 |
+
clear: both;
|
1969 |
+
content: "";
|
1970 |
}
|
1971 |
#learn-press-profile #profile-content .learn-press-tabs .learn-press-tabs__nav .learn-press-tabs__tab {
|
|
|
1972 |
float: left;
|
1973 |
+
border-right: 0;
|
1974 |
}
|
1975 |
#learn-press-profile #profile-content .learn-press-tabs .learn-press-tabs__nav .learn-press-tabs__tab label {
|
1976 |
padding-right: 25px;
|
2484 |
flex: 1 1 auto;
|
2485 |
}
|
2486 |
|
2487 |
+
.learn-press-profile-course__progress .lp_profile_course_progress {
|
2488 |
+
border: 1px solid #eee;
|
2489 |
+
}
|
2490 |
+
|
2491 |
+
.learn-press-profile-course__progress .lp_profile_course_progress__item {
|
2492 |
+
display: grid;
|
2493 |
+
align-items: center;
|
2494 |
+
padding: 15px;
|
2495 |
+
border-top: 1px solid #eee;
|
2496 |
+
grid-template-columns: 90px 1fr 80px 140px 140px;
|
2497 |
+
column-gap: 20px;
|
2498 |
+
}
|
2499 |
+
|
2500 |
+
.learn-press-profile-course__progress .lp_profile_course_progress__header {
|
2501 |
+
background-color: #eee;
|
2502 |
+
}
|
2503 |
+
|
2504 |
+
.lp_profile_course_progress__nav button.loading::before {
|
2505 |
+
display: inline-block;
|
2506 |
+
margin-right: 5px;
|
2507 |
+
font-family: "Font Awesome 5 Free";
|
2508 |
+
font-weight: 900;
|
2509 |
+
content: "\f110";
|
2510 |
+
-webkit-animation: lp-rotating 1s linear infinite;
|
2511 |
+
-moz-animation: lp-rotating 1s linear infinite;
|
2512 |
+
animation: lp-rotating 1s linear infinite;
|
2513 |
+
}
|
2514 |
+
|
2515 |
+
.learn-press-profile-course__tab__inner {
|
2516 |
+
display: flex;
|
2517 |
+
margin: 40px 0 0 0;
|
2518 |
+
padding: 0;
|
2519 |
+
background: #eee;
|
2520 |
+
list-style: none !important;
|
2521 |
+
}
|
2522 |
+
|
2523 |
+
.learn-press-profile-course__tab__inner > li {
|
2524 |
+
list-style: none;
|
2525 |
+
}
|
2526 |
+
|
2527 |
+
.learn-press-profile-course__tab__inner a {
|
2528 |
+
display: inline-block;
|
2529 |
+
padding: 15px 30px;
|
2530 |
+
font-weight: 600;
|
2531 |
+
}
|
2532 |
+
|
2533 |
+
.learn-press-profile-course__tab__inner a.active {
|
2534 |
+
border-top: 4px solid var(--lp-primary-color);
|
2535 |
+
color: var(--lp-primary-color);
|
2536 |
+
background: #fff;
|
2537 |
+
}
|
2538 |
+
|
2539 |
+
.learn-press-course-tab-filters .learn-press-filters {
|
2540 |
+
margin-top: 20px;
|
2541 |
+
margin-left: 0;
|
2542 |
+
padding: 0;
|
2543 |
+
list-style: none;
|
2544 |
+
}
|
2545 |
+
|
2546 |
+
.learn-press-course-tab-filters .learn-press-filters a.active {
|
2547 |
+
color: var(--lp-primary-color);
|
2548 |
+
}
|
2549 |
+
|
2550 |
#learn-press-course-tabs .course-tab-panels .course-tab-panel {
|
2551 |
display: none;
|
2552 |
padding-top: 56px;
|
5426 |
left: 0;
|
5427 |
background: #fff;
|
5428 |
content: "";
|
5429 |
+
opacity: 0.8%;
|
5430 |
}
|
5431 |
|
5432 |
.lp-archive-courses form[name="search-course"] {
|
7643 |
transform: translateX(-50%);
|
7644 |
}
|
7645 |
|
7646 |
+
#popup-course #popup-content #learn-press-quiz-app .quiz-buttons.align-center .button-left.nav-center {
|
7647 |
+
height: 50px;
|
7648 |
+
margin-left: 0 !important;
|
7649 |
+
}
|
7650 |
+
|
7651 |
#popup-course #popup-content #learn-press-quiz-app .quiz-buttons:not(.infinity).is-first .prev {
|
7652 |
display: none;
|
7653 |
}
|
7694 |
display: inline-block;
|
7695 |
padding: 8px;
|
7696 |
background: transparent;
|
7697 |
+
font-size: 16px;
|
7698 |
text-align: center;
|
7699 |
text-decoration: none;
|
7700 |
text-transform: none;
|
7701 |
}
|
7702 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7703 |
#popup-course #popup-content #learn-press-quiz-app .questions-pagination .nav-links .page-numbers.current, #popup-course #popup-content #learn-press-quiz-app .questions-pagination .nav-links .page-numbers:hover {
|
7704 |
color: var(--lp-primary-color);
|
7705 |
}
|
assets/js/dist/frontend/profile.js
ADDED
@@ -0,0 +1,459 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
this["LP"] = this["LP"] || {}; this["LP"]["profile"] =
|
2 |
+
/******/ (function(modules) { // webpackBootstrap
|
3 |
+
/******/ // The module cache
|
4 |
+
/******/ var installedModules = {};
|
5 |
+
/******/
|
6 |
+
/******/ // The require function
|
7 |
+
/******/ function __webpack_require__(moduleId) {
|
8 |
+
/******/
|
9 |
+
/******/ // Check if module is in cache
|
10 |
+
/******/ if(installedModules[moduleId]) {
|
11 |
+
/******/ return installedModules[moduleId].exports;
|
12 |
+
/******/ }
|
13 |
+
/******/ // Create a new module (and put it into the cache)
|
14 |
+
/******/ var module = installedModules[moduleId] = {
|
15 |
+
/******/ i: moduleId,
|
16 |
+
/******/ l: false,
|
17 |
+
/******/ exports: {}
|
18 |
+
/******/ };
|
19 |
+
/******/
|
20 |
+
/******/ // Execute the module function
|
21 |
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
22 |
+
/******/
|
23 |
+
/******/ // Flag the module as loaded
|
24 |
+
/******/ module.l = true;
|
25 |
+
/******/
|
26 |
+
/******/ // Return the exports of the module
|
27 |
+
/******/ return module.exports;
|
28 |
+
/******/ }
|
29 |
+
/******/
|
30 |
+
/******/
|
31 |
+
/******/ // expose the modules object (__webpack_modules__)
|
32 |
+
/******/ __webpack_require__.m = modules;
|
33 |
+
/******/
|
34 |
+
/******/ // expose the module cache
|
35 |
+
/******/ __webpack_require__.c = installedModules;
|
36 |
+
/******/
|
37 |
+
/******/ // define getter function for harmony exports
|
38 |
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
39 |
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
40 |
+
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
41 |
+
/******/ }
|
42 |
+
/******/ };
|
43 |
+
/******/
|
44 |
+
/******/ // define __esModule on exports
|
45 |
+
/******/ __webpack_require__.r = function(exports) {
|
46 |
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
47 |
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
48 |
+
/******/ }
|
49 |
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
50 |
+
/******/ };
|
51 |
+
/******/
|
52 |
+
/******/ // create a fake namespace object
|
53 |
+
/******/ // mode & 1: value is a module id, require it
|
54 |
+
/******/ // mode & 2: merge all properties of value into the ns
|
55 |
+
/******/ // mode & 4: return value when already ns object
|
56 |
+
/******/ // mode & 8|1: behave like require
|
57 |
+
/******/ __webpack_require__.t = function(value, mode) {
|
58 |
+
/******/ if(mode & 1) value = __webpack_require__(value);
|
59 |
+
/******/ if(mode & 8) return value;
|
60 |
+
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
61 |
+
/******/ var ns = Object.create(null);
|
62 |
+
/******/ __webpack_require__.r(ns);
|
63 |
+
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
64 |
+
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
65 |
+
/******/ return ns;
|
66 |
+
/******/ };
|
67 |
+
/******/
|
68 |
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
69 |
+
/******/ __webpack_require__.n = function(module) {
|
70 |
+
/******/ var getter = module && module.__esModule ?
|
71 |
+
/******/ function getDefault() { return module['default']; } :
|
72 |
+
/******/ function getModuleExports() { return module; };
|
73 |
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
74 |
+
/******/ return getter;
|
75 |
+
/******/ };
|
76 |
+
/******/
|
77 |
+
/******/ // Object.prototype.hasOwnProperty.call
|
78 |
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
79 |
+
/******/
|
80 |
+
/******/ // __webpack_public_path__
|
81 |
+
/******/ __webpack_require__.p = "";
|
82 |
+
/******/
|
83 |
+
/******/
|
84 |
+
/******/ // Load entry module and return exports
|
85 |
+
/******/ return __webpack_require__(__webpack_require__.s = "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile.js");
|
86 |
+
/******/ })
|
87 |
+
/************************************************************************/
|
88 |
+
/******/ ({
|
89 |
+
|
90 |
+
/***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile.js":
|
91 |
+
/*!***************************************************************************************************************************************************************!*\
|
92 |
+
!*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile.js ***!
|
93 |
+
\***************************************************************************************************************************************************************/
|
94 |
+
/*! no exports provided */
|
95 |
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
96 |
+
|
97 |
+
"use strict";
|
98 |
+
__webpack_require__.r(__webpack_exports__);
|
99 |
+
/* harmony import */ var _profile_course_tab__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./profile/course-tab */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile/course-tab.js");
|
100 |
+
/* harmony import */ var _profile_statistic__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./profile/statistic */ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile/statistic.js");
|
101 |
+
|
102 |
+
|
103 |
+
document.addEventListener('DOMContentLoaded', function (event) {
|
104 |
+
Object(_profile_course_tab__WEBPACK_IMPORTED_MODULE_0__["default"])();
|
105 |
+
Object(_profile_statistic__WEBPACK_IMPORTED_MODULE_1__["default"])();
|
106 |
+
});
|
107 |
+
|
108 |
+
/***/ }),
|
109 |
+
|
110 |
+
/***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile/course-tab.js":
|
111 |
+
/*!**************************************************************************************************************************************************************************!*\
|
112 |
+
!*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile/course-tab.js ***!
|
113 |
+
\**************************************************************************************************************************************************************************/
|
114 |
+
/*! exports provided: default */
|
115 |
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
116 |
+
|
117 |
+
"use strict";
|
118 |
+
__webpack_require__.r(__webpack_exports__);
|
119 |
+
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
|
120 |
+
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
|
121 |
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
122 |
+
|
123 |
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
124 |
+
|
125 |
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
126 |
+
|
127 |
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
128 |
+
|
129 |
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
130 |
+
|
131 |
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
132 |
+
|
133 |
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
134 |
+
|
135 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
136 |
+
|
137 |
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
138 |
+
|
139 |
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
140 |
+
|
141 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
142 |
+
|
143 |
+
// Rest API load content course enrolled, created - Nhamdv.
|
144 |
+
|
145 |
+
var courseTab = function courseTab() {
|
146 |
+
var elements = document.querySelectorAll('.learn-press-course-tab__filter__content');
|
147 |
+
|
148 |
+
if (!elements.length) {
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
|
152 |
+
if ('IntersectionObserver' in window) {
|
153 |
+
var eleObserver = new IntersectionObserver(function (entries, observer) {
|
154 |
+
entries.forEach(function (entry) {
|
155 |
+
if (entry.isIntersecting) {
|
156 |
+
var ele = entry.target;
|
157 |
+
var data = JSON.parse(ele.dataset.ajax);
|
158 |
+
getResponse(ele, data);
|
159 |
+
eleObserver.unobserve(ele);
|
160 |
+
}
|
161 |
+
});
|
162 |
+
});
|
163 |
+
|
164 |
+
_toConsumableArray(elements).map(function (ele) {
|
165 |
+
return eleObserver.observe(ele);
|
166 |
+
});
|
167 |
+
}
|
168 |
+
|
169 |
+
var changeFilter = function changeFilter() {
|
170 |
+
var tabs = document.querySelectorAll('.learn-press-course-tab-filters');
|
171 |
+
tabs.forEach(function (tab) {
|
172 |
+
var filters = tab.querySelectorAll('.learn-press-filters a');
|
173 |
+
filters.forEach(function (filter) {
|
174 |
+
filter.addEventListener('click', function (e) {
|
175 |
+
e.preventDefault();
|
176 |
+
var tabName = filter.dataset.tab;
|
177 |
+
|
178 |
+
_toConsumableArray(filters).map(function (ele) {
|
179 |
+
ele.classList.remove('active');
|
180 |
+
});
|
181 |
+
|
182 |
+
filter.classList.add('active');
|
183 |
+
|
184 |
+
_toConsumableArray(tab.querySelectorAll('.learn-press-course-tab__filter__content')).map(function (ele) {
|
185 |
+
ele.style.display = 'none';
|
186 |
+
|
187 |
+
if (ele.dataset.tab === tabName) {
|
188 |
+
ele.style.display = '';
|
189 |
+
}
|
190 |
+
});
|
191 |
+
});
|
192 |
+
});
|
193 |
+
});
|
194 |
+
};
|
195 |
+
|
196 |
+
changeFilter();
|
197 |
+
|
198 |
+
var changeTab = function changeTab() {
|
199 |
+
var tabUls = document.querySelectorAll('.learn-press-profile-course__tab__inner');
|
200 |
+
tabUls.forEach(function (tabUl) {
|
201 |
+
var tabs = tabUl.querySelectorAll('li> a');
|
202 |
+
tabs.forEach(function (tab) {
|
203 |
+
tab.addEventListener('click', function (e) {
|
204 |
+
e.preventDefault();
|
205 |
+
var tabName = tab.dataset.tab;
|
206 |
+
|
207 |
+
_toConsumableArray(tabs).map(function (ele) {
|
208 |
+
ele.classList.remove('active');
|
209 |
+
});
|
210 |
+
|
211 |
+
tab.classList.add('active');
|
212 |
+
|
213 |
+
_toConsumableArray(document.querySelectorAll('.learn-press-course-tab-filters')).map(function (ele) {
|
214 |
+
ele.style.display = 'none';
|
215 |
+
|
216 |
+
if (ele.dataset.tab === tabName) {
|
217 |
+
ele.style.display = '';
|
218 |
+
}
|
219 |
+
});
|
220 |
+
});
|
221 |
+
});
|
222 |
+
});
|
223 |
+
};
|
224 |
+
|
225 |
+
changeTab();
|
226 |
+
|
227 |
+
var getResponse = /*#__PURE__*/function () {
|
228 |
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ele, dataset) {
|
229 |
+
var append,
|
230 |
+
viewMoreEle,
|
231 |
+
response,
|
232 |
+
skeleton,
|
233 |
+
paged,
|
234 |
+
numberPage,
|
235 |
+
_paged,
|
236 |
+
_numberPage,
|
237 |
+
_args = arguments;
|
238 |
+
|
239 |
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
240 |
+
while (1) {
|
241 |
+
switch (_context.prev = _context.next) {
|
242 |
+
case 0:
|
243 |
+
append = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
|
244 |
+
viewMoreEle = _args.length > 3 && _args[3] !== undefined ? _args[3] : false;
|
245 |
+
_context.prev = 2;
|
246 |
+
_context.next = 5;
|
247 |
+
return wp.apiFetch({
|
248 |
+
path: Object(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__["addQueryArgs"])('lp/v1/profile/course-tab', dataset),
|
249 |
+
method: 'GET'
|
250 |
+
});
|
251 |
+
|
252 |
+
case 5:
|
253 |
+
response = _context.sent;
|
254 |
+
|
255 |
+
if (response) {
|
256 |
+
skeleton = ele.querySelector('.lp-skeleton-animation');
|
257 |
+
skeleton && skeleton.remove();
|
258 |
+
|
259 |
+
if (response.status === 'success' && response.data) {
|
260 |
+
if (append) {
|
261 |
+
ele.innerHTML += response.data;
|
262 |
+
} else {
|
263 |
+
ele.innerHTML = response.data;
|
264 |
+
}
|
265 |
+
} else if (append) {
|
266 |
+
ele.innerHTML += "<div class=\"lp-ajax-message\" style=\"display:block\">".concat(response.message && response.message, "</div>");
|
267 |
+
} else {
|
268 |
+
ele.innerHTML = "<div class=\"lp-ajax-message\" style=\"display:block\">".concat(response.message && response.message, "</div>");
|
269 |
+
}
|
270 |
+
|
271 |
+
if (viewMoreEle) {
|
272 |
+
viewMoreEle.classList.remove('loading');
|
273 |
+
paged = viewMoreEle.dataset.paged;
|
274 |
+
numberPage = viewMoreEle.dataset.number;
|
275 |
+
|
276 |
+
if (numberPage <= paged) {
|
277 |
+
viewMoreEle.remove();
|
278 |
+
}
|
279 |
+
|
280 |
+
viewMoreEle.dataset.paged = parseInt(paged) + 1;
|
281 |
+
}
|
282 |
+
|
283 |
+
viewMore(ele, dataset);
|
284 |
+
}
|
285 |
+
|
286 |
+
_context.next = 13;
|
287 |
+
break;
|
288 |
+
|
289 |
+
case 9:
|
290 |
+
_context.prev = 9;
|
291 |
+
_context.t0 = _context["catch"](2);
|
292 |
+
|
293 |
+
if (append) {
|
294 |
+
ele.innerHTML += "<div class=\"lp-ajax-message error\" style=\"display:block\">".concat(_context.t0.message && _context.t0.message, "</div>");
|
295 |
+
} else {
|
296 |
+
ele.innerHTML = "<div class=\"lp-ajax-message error\" style=\"display:block\">".concat(_context.t0.message && _context.t0.message, "</div>");
|
297 |
+
}
|
298 |
+
|
299 |
+
if (viewMoreEle) {
|
300 |
+
viewMoreEle.classList.remove('loading');
|
301 |
+
_paged = viewMoreEle.dataset.paged;
|
302 |
+
_numberPage = viewMoreEle.dataset.number;
|
303 |
+
|
304 |
+
if (_numberPage <= _paged) {
|
305 |
+
viewMoreEle.remove();
|
306 |
+
}
|
307 |
+
|
308 |
+
viewMoreEle.dataset.paged = parseInt(_paged) + 1;
|
309 |
+
}
|
310 |
+
|
311 |
+
case 13:
|
312 |
+
case "end":
|
313 |
+
return _context.stop();
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}, _callee, null, [[2, 9]]);
|
317 |
+
}));
|
318 |
+
|
319 |
+
return function getResponse(_x, _x2) {
|
320 |
+
return _ref.apply(this, arguments);
|
321 |
+
};
|
322 |
+
}();
|
323 |
+
|
324 |
+
var viewMore = function viewMore(ele, dataset) {
|
325 |
+
var viewMoreEle = ele.querySelector('button[data-paged]');
|
326 |
+
|
327 |
+
if (viewMoreEle) {
|
328 |
+
viewMoreEle.addEventListener('click', function (e) {
|
329 |
+
e.preventDefault();
|
330 |
+
var paged = viewMoreEle && viewMoreEle.dataset.paged;
|
331 |
+
viewMoreEle.classList.add('loading');
|
332 |
+
var element = dataset.layout === 'list' ? '.lp_profile_course_progress' : '.learn-press-courses';
|
333 |
+
getResponse(ele.querySelector(element), _objectSpread(_objectSpread({}, dataset), {
|
334 |
+
paged: paged
|
335 |
+
}), true, viewMoreEle);
|
336 |
+
});
|
337 |
+
}
|
338 |
+
};
|
339 |
+
};
|
340 |
+
|
341 |
+
/* harmony default export */ __webpack_exports__["default"] = (courseTab);
|
342 |
+
|
343 |
+
/***/ }),
|
344 |
+
|
345 |
+
/***/ "../../../Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile/statistic.js":
|
346 |
+
/*!*************************************************************************************************************************************************************************!*\
|
347 |
+
!*** E:/Work/Webs/WP/Clouds/Thimpress/Plugins/github.com/learnpress_v4_modify_step_install_after_activated/learnpress/assets/src/apps/js/frontend/profile/statistic.js ***!
|
348 |
+
\*************************************************************************************************************************************************************************/
|
349 |
+
/*! exports provided: default */
|
350 |
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
351 |
+
|
352 |
+
"use strict";
|
353 |
+
__webpack_require__.r(__webpack_exports__);
|
354 |
+
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
|
355 |
+
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
|
356 |
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
357 |
+
|
358 |
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
359 |
+
|
360 |
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
361 |
+
|
362 |
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
363 |
+
|
364 |
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
365 |
+
|
366 |
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
367 |
+
|
368 |
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
369 |
+
|
370 |
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
371 |
+
|
372 |
+
// Rest API load content course progress - Nhamdv.
|
373 |
+
|
374 |
+
var courseStatistics = function courseStatistics() {
|
375 |
+
var elements = document.querySelectorAll('.learn-press-profile-course__statistic');
|
376 |
+
|
377 |
+
if (!elements.length) {
|
378 |
+
return;
|
379 |
+
}
|
380 |
+
|
381 |
+
if ('IntersectionObserver' in window) {
|
382 |
+
var eleObserver = new IntersectionObserver(function (entries, observer) {
|
383 |
+
entries.forEach(function (entry) {
|
384 |
+
if (entry.isIntersecting) {
|
385 |
+
var ele = entry.target;
|
386 |
+
var data = JSON.parse(ele.dataset.ajax);
|
387 |
+
getResponse(ele, data);
|
388 |
+
eleObserver.unobserve(ele);
|
389 |
+
}
|
390 |
+
});
|
391 |
+
});
|
392 |
+
|
393 |
+
_toConsumableArray(elements).map(function (ele) {
|
394 |
+
return eleObserver.observe(ele);
|
395 |
+
});
|
396 |
+
}
|
397 |
+
|
398 |
+
var getResponse = /*#__PURE__*/function () {
|
399 |
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(ele, dataset) {
|
400 |
+
var response;
|
401 |
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
402 |
+
while (1) {
|
403 |
+
switch (_context.prev = _context.next) {
|
404 |
+
case 0:
|
405 |
+
_context.prev = 0;
|
406 |
+
_context.next = 3;
|
407 |
+
return wp.apiFetch({
|
408 |
+
path: Object(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__["addQueryArgs"])('lp/v1/profile/statistic', dataset),
|
409 |
+
method: 'GET'
|
410 |
+
});
|
411 |
+
|
412 |
+
case 3:
|
413 |
+
response = _context.sent;
|
414 |
+
|
415 |
+
if (response.status === 'success' && response.data) {
|
416 |
+
ele.innerHTML += response.data;
|
417 |
+
} else {
|
418 |
+
ele.innerHTML += "<div class=\"lp-ajax-message error\" style=\"display:block\">".concat(response.message && response.message, "</div>");
|
419 |
+
}
|
420 |
+
|
421 |
+
_context.next = 10;
|
422 |
+
break;
|
423 |
+
|
424 |
+
case 7:
|
425 |
+
_context.prev = 7;
|
426 |
+
_context.t0 = _context["catch"](0);
|
427 |
+
ele.innerHTML += "<div class=\"lp-ajax-message error\" style=\"display:block\">".concat(_context.t0.message && _context.t0.message, "</div>");
|
428 |
+
|
429 |
+
case 10:
|
430 |
+
case "end":
|
431 |
+
return _context.stop();
|
432 |
+
}
|
433 |
+
}
|
434 |
+
}, _callee, null, [[0, 7]]);
|
435 |
+
}));
|
436 |
+
|
437 |
+
return function getResponse(_x, _x2) {
|
438 |
+
return _ref.apply(this, arguments);
|
439 |
+
};
|
440 |
+
}();
|
441 |
+
};
|
442 |
+
|
443 |
+
/* harmony default export */ __webpack_exports__["default"] = (courseStatistics);
|
444 |
+
|
445 |
+
/***/ }),
|
446 |
+
|
447 |
+
/***/ "@wordpress/url":
|
448 |
+
/*!*****************************!*\
|
449 |
+
!*** external ["wp","url"] ***!
|
450 |
+
\*****************************/
|
451 |
+
/*! no static exports found */
|
452 |
+
/***/ (function(module, exports) {
|
453 |
+
|
454 |
+
(function() { module.exports = window["wp"]["url"]; }());
|
455 |
+
|
456 |
+
/***/ })
|
457 |
+
|
458 |
+
/******/ });
|
459 |
+
//# sourceMappingURL=profile.js.map
|
assets/js/dist/frontend/profile.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
this.LP=this.LP||{},this.LP.profile=function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=24)}({24:function(e,t,r){"use strict";r.r(t);var n=r(5);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var l=function(){var e=document.querySelectorAll(".learn-press-course-tab__filter__content");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target,a=JSON.parse(n.dataset.ajax);r(n,a),t.unobserve(n)}}))}));c(e).map((function(e){return t.observe(e)}))}document.querySelectorAll(".learn-press-course-tab-filters").forEach((function(e){var t=e.querySelectorAll(".learn-press-filters a");t.forEach((function(r){r.addEventListener("click",(function(n){n.preventDefault();var a=r.dataset.tab;c(t).map((function(e){e.classList.remove("active")})),r.classList.add("active"),c(e.querySelectorAll(".learn-press-course-tab__filter__content")).map((function(e){e.style.display="none",e.dataset.tab===a&&(e.style.display="")}))}))}))}));document.querySelectorAll(".learn-press-profile-course__tab__inner").forEach((function(e){var t=e.querySelectorAll("li> a");t.forEach((function(e){e.addEventListener("click",(function(r){r.preventDefault();var n=e.dataset.tab;c(t).map((function(e){e.classList.remove("active")})),e.classList.add("active"),c(document.querySelectorAll(".learn-press-course-tab-filters")).map((function(e){e.style.display="none",e.dataset.tab===n&&(e.style.display="")}))}))}))}));var r=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var o,i,s,c,u,l,f=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=f.length>2&&void 0!==f[2]&&f[2],i=f.length>3&&void 0!==f[3]&&f[3],e.prev=2,e.next=5,wp.apiFetch({path:Object(n.addQueryArgs)("lp/v1/profile/course-tab",r),method:"GET"});case 5:(s=e.sent)&&((c=t.querySelector(".lp-skeleton-animation"))&&c.remove(),"success"===s.status&&s.data?o?t.innerHTML+=s.data:t.innerHTML=s.data:o?t.innerHTML+='<div class="lp-ajax-message" style="display:block">'.concat(s.message&&s.message,"</div>"):t.innerHTML='<div class="lp-ajax-message" style="display:block">'.concat(s.message&&s.message,"</div>"),i&&(i.classList.remove("loading"),u=i.dataset.paged,i.dataset.number<=u&&i.remove(),i.dataset.paged=parseInt(u)+1),a(t,r)),e.next=13;break;case 9:e.prev=9,e.t0=e.catch(2),o?t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>"):t.innerHTML='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>"),i&&(i.classList.remove("loading"),l=i.dataset.paged,i.dataset.number<=l&&i.remove(),i.dataset.paged=parseInt(l)+1);case 13:case"end":return e.stop()}}),e,null,[[2,9]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){s(o,n,a,i,c,"next",e)}function c(e){s(o,n,a,i,c,"throw",e)}i(void 0)}))});return function(e,r){return t.apply(this,arguments)}}(),a=function(e,t){var n=e.querySelector("button[data-paged]");n&&n.addEventListener("click",(function(a){a.preventDefault();var i=n&&n.dataset.paged;n.classList.add("loading");var s="list"===t.layout?".lp_profile_course_progress":".learn-press-courses";r(e.querySelector(s),o(o({},t),{paged:i}),!0,n)}))}}};function f(e,t,r,n,a,o,i){try{var s=e[o](i),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,a)}function p(e){return function(e){if(Array.isArray(e))return d(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var v=function(){var e=document.querySelectorAll(".learn-press-profile-course__statistic");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target,a=JSON.parse(n.dataset.ajax);r(n,a),t.unobserve(n)}}))}));p(e).map((function(e){return t.observe(e)}))}var r=function(){var e,t=(e=regeneratorRuntime.mark((function e(t,r){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,wp.apiFetch({path:Object(n.addQueryArgs)("lp/v1/profile/statistic",r),method:"GET"});case 3:"success"===(a=e.sent).status&&a.data?t.innerHTML+=a.data:t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(a.message&&a.message,"</div>"),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),t.innerHTML+='<div class="lp-ajax-message error" style="display:block">'.concat(e.t0.message&&e.t0.message,"</div>");case 10:case"end":return e.stop()}}),e,null,[[0,7]])})),function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){f(o,n,a,i,s,"next",e)}function s(e){f(o,n,a,i,s,"throw",e)}i(void 0)}))});return function(e,r){return t.apply(this,arguments)}}()}};document.addEventListener("DOMContentLoaded",(function(e){l(),v()}))},5:function(e,t){e.exports=window.wp.url}});
|
assets/js/dist/frontend/quiz.js
CHANGED
@@ -804,10 +804,16 @@ var Buttons = /*#__PURE__*/function (_Component) {
|
|
804 |
styles = null;
|
805 |
}
|
806 |
|
|
|
|
|
|
|
|
|
|
|
|
|
807 |
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
808 |
className: classNames.join(' ')
|
809 |
}, /*#__PURE__*/React.createElement("div", {
|
810 |
-
className: "button-left" + (status === 'started' || isReviewing ?
|
811 |
style: styles
|
812 |
}, (status === 'completed' && canRetry || -1 !== ['', 'viewed'].indexOf(status)) && !isReviewing && /*#__PURE__*/React.createElement("button", {
|
813 |
className: "lp-button start",
|
@@ -1539,7 +1545,6 @@ var Question = /*#__PURE__*/function (_Component) {
|
|
1539 |
var _this$props2 = _this.props,
|
1540 |
question = _this$props2.question,
|
1541 |
editPermalink = _this$props2.editPermalink;
|
1542 |
-
console.log(123123123);
|
1543 |
return editPermalink ? editPermalink.replace(/post=(.*[0-9])/, "post=".concat(question.id)) : '';
|
1544 |
});
|
1545 |
|
804 |
styles = null;
|
805 |
}
|
806 |
|
807 |
+
var navPositionClass = ' fixed';
|
808 |
+
|
809 |
+
if (lpQuizSettings.navigationPosition == 'no') {
|
810 |
+
navPositionClass = ' nav-center';
|
811 |
+
}
|
812 |
+
|
813 |
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
814 |
className: classNames.join(' ')
|
815 |
}, /*#__PURE__*/React.createElement("div", {
|
816 |
+
className: "button-left" + (status === 'started' || isReviewing ? navPositionClass : ''),
|
817 |
style: styles
|
818 |
}, (status === 'completed' && canRetry || -1 !== ['', 'viewed'].indexOf(status)) && !isReviewing && /*#__PURE__*/React.createElement("button", {
|
819 |
className: "lp-button start",
|
1545 |
var _this$props2 = _this.props,
|
1546 |
question = _this$props2.question,
|
1547 |
editPermalink = _this$props2.editPermalink;
|
|
|
1548 |
return editPermalink ? editPermalink.replace(/post=(.*[0-9])/, "post=".concat(question.id)) : '';
|
1549 |
});
|
1550 |
|
assets/js/dist/frontend/quiz.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},function(e,t){e.exports=window.wp.compose},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},function(e,t
|
2 |
/*!
|
3 |
Copyright (c) 2018 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
-
*/!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return Rn}));var r={};n.r(r),n.d(r,"setQuizData",(function(){return wt})),n.d(r,"setCurrentQuestion",(function(){return Ot})),n.d(r,"setCurrentPage",(function(){return _t})),n.d(r,"__requestBeforeStartQuiz",(function(){return St})),n.d(r,"__requestStartQuizSuccess",(function(){return qt})),n.d(r,"startQuiz",(function(){return jt})),n.d(r,"__requestSubmitQuiz",(function(){return Rt})),n.d(r,"__requestSubmitQuizSuccess",(function(){return Et})),n.d(r,"submitQuiz",(function(){return Pt})),n.d(r,"updateUserQuestionAnswers",(function(){return zt})),n.d(r,"__requestShowHintSuccess",(function(){return kt})),n.d(r,"showHint",(function(){return Qt})),n.d(r,"__requestCheckAnswerSuccess",(function(){return It})),n.d(r,"checkAnswer",(function(){return At})),n.d(r,"markQuestionRendered",(function(){return Ct})),n.d(r,"setQuizMode",(function(){return Nt})),n.d(r,"sendKey",(function(){return Tt}));var o={};n.r(o),n.d(o,"getQuestionOptions",(function(){return Lt})),n.d(o,"getItemStatus",(function(){return Ut})),n.d(o,"getProp",(function(){return Ft})),n.d(o,"getQuizAttempts",(function(){return Ht})),n.d(o,"getQuizAnswered",(function(){return Bt})),n.d(o,"getQuestions",(function(){return Gt})),n.d(o,"getData",(function(){return Jt})),n.d(o,"getDefaultRestArgs",(function(){return Kt})),n.d(o,"getQuestionAnswered",(function(){return Wt})),n.d(o,"getQuestionMark",(function(){return $t})),n.d(o,"getCurrentQuestion",(function(){return Zt})),n.d(o,"getQuestion",(function(){return Yt})),n.d(o,"isCheckedAnswer",(function(){return Vt})),n.d(o,"isCorrect",(function(){return Xt})),n.d(o,"getQuestionsSelectedAnswers",(function(){return en})),n.d(o,"getUserMark",(function(){return tn}));var i=n(2),a=n(4),u=n(1),s=function(){var e=Object(u.select)("learnpress/quiz").getData("content");return React.createElement("div",{className:"quiz-content",dangerouslySetInnerHTML:{__html:e}})},c=n(0),l=function(e){var t;if(e>86400)t=(e-e%86400)/86400,e%=86400;else if(86400==e)return"24:00";var n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")},f=LP.Hook,p=function(){var e=function(e){return Object(u.select)("learnpress/quiz").getData(e)},t=f.applyFilters("quiz-meta-fields",{duration:{title:Object(c.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:Object(c.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:Object(c.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&React.createElement(React.Fragment,null,React.createElement("ul",{className:"quiz-intro"},Object.values(t).map((function(e,t){var n=e.name||t;return React.createElement("li",{key:"quiz-intro-field-".concat(t),className:"quiz-intro-item quiz-intro-item--".concat(n)},React.createElement("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),React.createElement("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S(e);if(t){var o=S(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O(this,n)}}function O(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(i,e);var t,n,r,o=w(i);function i(){var e;h(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return q(_(e=o.call.apply(o,[this].concat(n))),"startQuiz",(function(t){t&&t.preventDefault();var n=document.querySelector(".lp-button.start");n&&n.setAttribute("disabled","disabled");var r=e.props,o=r.startQuiz;if("completed"===r.status){var i=Object(u.select)("learnpress/modal"),a=i.confirm,s=i.isOpen;if("no"===a(Object(c.__)("Are you sure you want to retake quiz?","learnpress"),e.startQuiz))return void(!s()&&n&&n.removeAttribute("disabled"))}if("1"==lpQuizSettings.checkNorequizenroll){window.localStorage.removeItem("quiz_start_"+lpQuizSettings.id),window.localStorage.setItem("quiz_start_"+lpQuizSettings.id,Date.now());var l=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);l>=1?window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,parseInt(l)+1):window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,1),window.localStorage.removeItem("quiz_userdata_"+lpQuizSettings.id)}o()})),q(_(e),"nav",(function(t){return function(n){var r=e.props,o=r.questionNav,i=r.currentPage,a=r.numPages,u=r.setCurrentPage;switch(t){case"prev":i>1?i-=1:i="infinity"===o?a:1;break;default:i<a?i+=1:i="infinity"===o?1:a}u(i)}})),q(_(e),"moveTo",(function(t){return function(n){n.preventDefault();var r=e.props,o=r.numPages,i=r.setCurrentPage;t<1||t>o||i(t)}})),q(_(e),"isLast",(function(){var t=e.props;return t.currentPage===t.numPages})),q(_(e),"isFirst",(function(){return 1===e.props.currentPage})),q(_(e),"submit",(function(){var t=e.props.submitQuiz;"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),e.submit)&&t()})),q(_(e),"setQuizMode",(function(t){return function(){(0,e.props.setQuizMode)(t)}})),q(_(e),"isReviewing",(function(){return e.props.isReviewing})),e}return t=i,(n=[{key:"pageNumbers",value:function(e){var t=this,n=this.props,r=n.numPages,o=n.currentPage;if(r<2)return"";(e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){q(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({numPages:r,currentPage:o,midSize:1,endSize:1,prevNext:!0},e||{})).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);var i=m(Array(r).keys()),a=!1;return React.createElement("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&React.createElement("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},Object(c.__)("Prev","learnpress")),i.map((function(n){return(n+=1)===e.currentPage?(a=!0,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers current"},n)):n<=e.endSize||e.currentPage&&n>=e.currentPage-e.midSize&&n<=e.currentPage+e.midSize||n>e.numPages-e.endSize?(a=!0,React.createElement("button",{key:"page-number-".concat(n),className:"page-numbers",onClick:t.moveTo(n)},n)):a?(a=!1,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers dots"},"…")):""})),e.prevNext&&!this.isLast()&&React.createElement("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},Object(c.__)("Next","learnpress")))}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.questionNav,r=e.isReviewing,o=e.showReview,i=e.numPages,a=(e.question,e.questionsPerPage,e.canRetry),u=e.retakeNumber,s=["quiz-buttons"];("started"===t||r)&&s.push("align-center"),"questionNav"===n&&s.push("infinity"),this.isFirst()&&s.push("is-first"),this.isLast()&&s.push("is-last");var l=document.querySelector("#popup-sidebar"),f=document.querySelector("#learn-press-quiz-app"),p="";return p="started"===t||r?{marginLeft:l&&l.offsetWidth/2,width:f&&f.offsetWidth}:null,React.createElement(React.Fragment,null,React.createElement("div",{className:s.join(" ")},React.createElement("div",{className:"button-left"+("started"===t||r?" fixed":""),style:p},("completed"===t&&a||-1!==["","viewed"].indexOf(t))&&!r&&React.createElement("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===t?"".concat(Object(c.__)("Retake","learnpress")).concat(u?" (".concat(u,")"):""):Object(c.__)("Start","learnpress")),("started"===t||r)&&i>1&&React.createElement(React.Fragment,null,React.createElement("div",{className:"questions-pagination"},this.pageNumbers()))),React.createElement("div",{className:"button-right"},"started"===t&&React.createElement(React.Fragment,null,("infinity"===n||this.isLast())&&!r&&React.createElement("button",{className:"lp-button submit-quiz",onClick:this.submit},Object(c.__)("Finish Quiz","learnpress"))),r&&o&&React.createElement("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},Object(c.__)("Result","learnpress")),"completed"===t&&o&&!r&&React.createElement("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},Object(c.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&React.createElement("div",{className:"learn-press-message error"},this.props.message))}}])&&g(t.prototype,n),r&&g(t,r),i}(i.Component),R=Object(a.compose)(Object(u.withSelect)((function(e){var t=e("learnpress/quiz").getData;return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((function(e){var t=e.showCheck,n=e.checkedQuestions,r=e.hintedQuestions,o=e.question,i=e.status,a=e.type,u=e.Button;if("started"!==i)return!1;var s=React.createElement(u,{question:o});switch(a){case"hint":return r?!!o.hasHint&&(-1===r.indexOf(o.id)&&s):s;case"check":return!!t&&(n?-1===n.indexOf(o.id)&&s:s)}})),E=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getData,r=t.getCurrentQuestion,o={id:n("id"),status:n("status"),questionIds:n("questionIds"),questionNav:n("questionNav"),isReviewing:n("reviewQuestions")&&"reviewing"===n("mode"),showReview:n("reviewQuestions"),showCheck:n("instantCheck"),checkedQuestions:n("checkedQuestions"),hintedQuestions:n("hintedQuestions"),numPages:n("numPages"),pages:n("pages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage"),pageNumbers:n("pageNumbers"),keyPressed:n("keyPressed"),canRetry:n("retakeCount")>0&&n("retaken")<n("retakeCount"),retakeNumber:n("retakeCount")>0&&n("retaken")<n("retakeCount")?n("retakeCount")-n("retaken"):null,message:n("messageResponse")||!1,success:void 0===n("successResponse")||n("successResponse")};if(1===o.questionsPerPage&&(o.question=r("object")),"1"==lpQuizSettings.checkNorequizenroll){var i=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);n("retakeCount")>i?(o.retakeNumber=n("retakeCount")-i,o.canRetry=!0):o.canRetry=!1}return o})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz"),r=n.startQuiz,o=n.setCurrentQuestion,i=n.submitQuiz,a=n.setQuizMode,u=n.showHint,s=n.checkAnswer;return{startQuiz:r,setCurrentQuestion:o,setQuizMode:a,setCurrentPage:n.setCurrentPage,submitQuiz:function(e){i(e)},showHint:function(e){u(e)},checkAnswer:function(e){s(e)}}}))])(j);function P(e){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=N(e);if(t){var o=N(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return A(this,n)}}function A(e,t){return!t||"object"!==P(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(i,e);var t,n,r,o=I(i);function i(){var e;z(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return T(C(e=o.call.apply(o,[this].concat(n))),"showHint",(function(){var t=e.props,n=t.showHint,r=t.question;n(r.id,!r.showHint)})),e}return t=i,(n=[{key:"render",value:function(){return this.props.question.hint?React.createElement("button",{className:"btn-show-hint",onClick:this.showHint},React.createElement("span",null,Object(c.__)("Hint","learnpress"))):""}}])&&k(t.prototype,n),r&&k(t,r),i}(i.Component),D=Object(a.compose)(Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").showHint;return{showHint:function(e,t){n(e,t)}}})))(x),M=n(13),L=n.n(M);function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function F(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=W(e);if(t){var o=W(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return J(this,n)}}function J(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?K(e):t}function K(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function W(e){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&B(e,t)}(i,e);var t,n,r,o=G(i);function i(){var e;return F(this,i),$(K(e=o.apply(this,arguments)),"checkAnswer",(function(){var t=e.props,n=t.checkAnswer,r=t.question;t.answered&&(n(r.id),e.setState({loading:!0}))})),e.state={loading:!1},e}return t=i,(n=[{key:"render",value:function(){var e=this.props.answered;return React.createElement(React.Fragment,null,React.createElement("button",{className:L()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},React.createElement("span",{className:"instant-check__icon"}),Object(c.__)("Check answer","learnpress"),!e&&React.createElement("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:Object(c.__)("You need to answer the question before check answer.","learnpress")}})))}}])&&H(t.prototype,n),r&&H(t,r),i}(i.Component),Y=Object(a.compose)(Object(u.withSelect)((function(e,t){var n=t.question.id;return{answered:(0,e("learnpress/quiz").getQuestionAnswered)(n)}})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").checkAnswer;return{checkAnswer:function(e){n(e)}}})))(Z),V=function(e){var t=e.question,n={"instant-check":function(){return React.createElement(R,{type:"check",Button:Y,question:t})},hint:function(){return React.createElement(R,{type:"hint",Button:D,question:t})}};return React.createElement(React.Fragment,null,LP.config.questionFooterButtons().map((function(e){return React.createElement(i.Fragment,{key:"button-".concat(e)},n[e]&&n[e]())})))};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=se(e);if(t){var o=se(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ae(this,n)}}function ae(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=window.jQuery,fe=lodash,pe=(fe.uniqueId,fe.isArray),de=(fe.isNumber,fe.bind,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(a,e);var t,n,r,o=ie(a);function a(){var e;return ne(this,a),ce(ue(e=o.apply(this,arguments)),"setRef",(function(t){e.$wrap=le(t)})),ce(ue(e),"parseOptions",(function(e){return e&&(e=pe(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=pe(e)?e:JSON.parse(e)),e||[]})),ce(ue(e),"getWrapperClass",(function(){var t=e.props,n=t.question,r=(t.answered,["question","question-"+n.type]),o=e.parseOptions(n.options);return o.length&&void 0!==o[0].isTrue&&r.push("question-answered"),r})),ce(ue(e),"getEditLink",(function(){var t=e.props,n=t.question,r=t.editPermalink;return r?r.replace(/post=(.*[0-9])/,"post=".concat(n.id)):""})),ce(ue(e),"editPermalink",(function(e){return Object(c.sprintf)('<a href="%s">%s</a>',e,Object(c.__)("Edit","learnpress"))})),e.state={time:null,showHint:!1},e.$wrap=null,e}return t=a,(n=[{key:"componentDidMount",value:function(e){var t=this.props,n=t.question,r=t.isCurrent,o=t.markQuestionRendered;return r&&o(n.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),e}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.isShow,o=t.isShowIndex,a=(t.isShowHint,t.status),u=LP.questionTypes.default,s=this.getEditLink();s&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",s);var l={index:function(){return o?React.createElement("span",{className:"question-index"},o,"."):""},title:function(){return React.createElement("span",{dangerouslySetInnerHTML:{__html:n.title}})},hint:function(){return React.createElement(D,{question:n})},"edit-permalink":function(){return s&&React.createElement("span",{dangerouslySetInnerHTML:{__html:e.editPermalink(s)},className:"edit-link"})}},f={title:function(){return React.createElement("h4",{className:"question-title"},LP.config.questionTitleParts().map((function(e){return React.createElement(i.Fragment,{key:"title-part-".concat(e)},l[e]&&l[e]())})))},content:function(){return React.createElement("div",{className:"question-content",dangerouslySetInnerHTML:{__html:n.content}})},"answer-options":function(){return e.$wrap&&React.createElement(u,te(te({},e.props),{},{$wrap:e.$wrap}))},explanation:function(){return n.explanation&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-explanation-content"},React.createElement("strong",{className:"explanation-title"},Object(c.__)("Explanation:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.explanation}})))},hint:function(){return n.hint&&!n.explanation&&n.showHint&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-hint-content"},React.createElement("strong",{className:"hint-title"},Object(c.__)("Hint:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.hint}})))},buttons:function(){return"started"===a&&React.createElement(V,{question:n})}},p=LP.config.questionBlocks();return React.createElement(React.Fragment,null,React.createElement("div",{className:this.getWrapperClass().join(" "),style:{display:r?"":"none"},"data-id":n.id,ref:this.setRef},p.map((function(e){return React.createElement(i.Fragment,{key:"block-".concat(e)},f[e]?f[e]():"")}))))}}])&&re(t.prototype,n),r&&re(t,r),a}(i.Component)),me=Object(a.compose)([Object(u.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.getQuestionAnswered,a=r.getQuestionMark;return{status:o("status"),questions:o("question"),answered:i(n),questionsRendered:o("questionsRendered"),editPermalink:o("editPermalink"),numPages:o("numPages"),mark:a(n)||""}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz"),n=t.updateUserQuestionAnswers;return{markQuestionRendered:t.markQuestionRendered,updateUserQuestionAnswers:n}}))])(de);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?Oe(e):t}function Oe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ge(e,t)}(i,e);var t,n,r,o=ve(i);function i(e){var t;return ye(this,i),Se(Oe(t=o.apply(this,arguments)),"startQuiz",(function(e){e.preventDefault(),(0,t.props.startQuiz)()})),Se(Oe(t),"isInVisibleRange",(function(e,n){var r=t.props,o=r.currentPage,i=r.questionsPerPage;return o===Math.ceil(n/i)})),Se(Oe(t),"nav",(function(e){var n=t.props.sendKey;switch(e.keyCode){case 37:return n("left");case 38:return;case 39:return n("right");case 40:return;default:e.keyCode>=49&&e.keyCode<=57&&n(e.keyCode-48)}})),t.needToTop=!1,t.state={isReviewing:null,currentPage:0,self:Oe(t)},t}return t=i,r=[{key:"getDerivedStateFromProps",value:function(e,t){for(var n=["isReviewing","currentPage"],r={},o=0;o<n.length;o++)e[n[o]]!==t[n[o]]&&(r[n[o]]=e[n[o]]);return Object.values(r).length?(t.self.needToTop=!0,r):null}}],(n=[{key:"componentDidUpdate",value:function(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}},{key:"render",value:function(){var e=this,t=this.props,n=t.status,r=t.currentQuestion,o=t.questions,i=t.questionsRendered,a=t.isReviewing,u=t.questionsPerPage,s=!0;return"completed"!==n||a||(s=!1),React.createElement(React.Fragment,null,React.createElement("div",{tabIndex:100,onKeyUp:this.nav},React.createElement("div",{className:"quiz-questions",style:{display:s?"":"none"}},o.map((function(t,n){var o=!u&&r===t.id,a=i&&-1!==i.indexOf(t.id),s=e.isInVisibleRange(t.id,n+1);return a||!a||s?React.createElement(me,{key:"loop-question-".concat(t.id),isCurrent:o,isShow:s,isShowIndex:!!u&&n+1,questionsPerPage:u,question:t}):""})))))}}])&&he(t.prototype,n),r&&he(t,r),i}(i.Component),je=Object(a.compose)(Object(u.withSelect)((function(e,t,n){var r=e("learnpress/quiz"),o=r.getData,i=r.getQuestions;return{status:o("status"),currentQuestion:o("currentQuestion"),questions:i(),questionsRendered:o("questionsRendered"),isReviewing:"reviewing"===o("mode"),numPages:o("numPages"),currentPage:o("currentPage"),questionsPerPage:o("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{startQuiz:t.startQuiz,sendKey:t.sendKey}})))(qe);var Re=function(){var e=Object(u.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&React.createElement(React.Fragment,null,React.createElement("div",{className:"quiz-attempts"},React.createElement("h4",{className:"attempts-heading"},Object(c.__)("Last Attempted","learnpress")),t&&React.createElement("table",null,React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",{className:"quiz-attempts__questions"},Object(c.__)("Questions","learnpress")),React.createElement("th",{className:"quiz-attempts__spend"},Object(c.__)("Time spend","learnpress")),React.createElement("th",{className:"quiz-attempts__marks"},Object(c.__)("Marks","learnpress")),React.createElement("th",{className:"quiz-attempts__grade"},Object(c.__)("Passing grade","learnpress")),React.createElement("th",{className:"quiz-attempts__result"},Object(c.__)("Result","learnpress")))),React.createElement("tbody",null,e.map((function(e,t){if("1"==lpQuizSettings.checkNorequizenroll){var n=window.localStorage.getItem("quiz_start_"+lpQuizSettings.id),r=window.localStorage.getItem("quiz_end_"+lpQuizSettings.id);n&&r&&(e.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(n,r).duration)}return React.createElement("tr",{key:"attempt-".concat(t)},React.createElement("td",{className:"quiz-attempts__questions"},"".concat(e.questionCorrect," / ").concat(e.questionCount)),React.createElement("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),React.createElement("td",{className:"quiz-attempts__marks"},"".concat(e.userMark," / ").concat(e.mark)),React.createElement("td",{className:"quiz-attempts__grade"},e.passingGrade||_x("-","unknown passing grade value","learnpress")),React.createElement("td",{className:"quiz-attempts__result"},"".concat(parseFloat(e.result).toFixed(2),"%")," ",React.createElement("span",null,e.graduationText)))}))))))};function Ee(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Pe(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Pe(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ze=function(){var e=Object(u.select)("learnpress/quiz").getData,t=Object(u.dispatch)("learnpress/quiz").submitQuiz,n=e("totalTime")?e("totalTime"):e("duration"),r=e("endTime"),o=new Date(r.replace(/-/g,"/")),a=new Date,s=(new Date).getTimezoneOffset(),c=parseInt(o.getTime()/1e3-(a.getTime()/1e3+60*s)),l=Ee(Object(i.useState)(c>0?c:0),2),f=l[0],p=l[1];Object(i.useEffect)((function(){var e=setInterval((function(){var n=f;(n-=1)>0?p(n):(clearInterval(e),t())}),1e3);return function(){return clearInterval(e)}}),[f]);return React.createElement("div",{className:"countdown"},React.createElement("i",{className:"fas fa-stopwatch"}),React.createElement("span",null,function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":",r=[];return n<3600?(r.push((f-f%60)/60),r.push(f%60)):n&&(r.push((f-f%3600)/3600),e=f%3600,r.push((e-e%60)/60),r.push(e%60)),r.map((function(e){return e<10?"0".concat(e):e})).join(t)}()))},ke=n(9);function Qe(e){return function(e){if(Array.isArray(e))return Ce(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ae(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||Ae(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ae(e,t){if(e){if("string"==typeof e)return Ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ce(e,t):void 0}}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=lodash.debounce,Te=function(){var e=Ie(Object(i.useState)(0),2),t=e[0],n=e[1],r=Ie(Object(i.useState)(!1),2),o=r[0],a=r[1],s=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("id")}),[]),l=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("results")}),[]),f=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("passingGrade")}),[]),p=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("submitting")}),[]);Object(i.useEffect)((function(){m();var e="";if(e=l.graduation?l.graduation:l.result>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed"){var t=document.querySelector(".course-curriculum .course-item.course-item-".concat(s));t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}var n=Qe(document.querySelectorAll("#popup-header .items-progress"))[0];if(n){var r=n.querySelector(".items-completed");if(r){parseInt(r.textContent);var o=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");r.textContent=parseInt(o.length)}}}),[l]),Object(i.useEffect)((function(){void 0!==p&&d()}),[p]);var d=function(){var e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&Object(ke.a)(e[0])},m=function(){n(0),a(!1),jQuery.easing._customEasing=function(e,t,n,r,o){return r*Math.sqrt(1-(t=t/o-1)*t)+n},Ne((function(){var e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:l.result},{duration:1500,step:function(e,t){n(e)},done:function(){a(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),Ne((function(){jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),l.result>0?1e3:10)()},b=t;Number.isInteger(t)||(b=parseFloat(t).toFixed(2));var y=190*Math.PI,h=y-b/100*y,g={strokeDasharray:"".concat(y," ").concat(y),strokeDashoffset:h},v=l.passingGrade||f,w="";w=l.graduation?l.graduation:b>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed";var O="";O=l.graduationText?l.graduationText:"passed"===w?Object(c.__)("Passed","learnpress"):Object(c.__)("Failed","learnpress");var _=["quiz-result",w];if("1"==lpQuizSettings.checkNorequizenroll){var S=window.localStorage.getItem("quiz_start_"+s),q=window.localStorage.getItem("quiz_end_"+s);S&&q&&(l.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(S,q).duration)}return React.createElement("div",{className:_.join(" ")},React.createElement("h3",{className:"result-heading"},Object(c.__)("Your Result","learnpress")),React.createElement("div",{id:"quizResultGrade",className:"result-grade"},React.createElement("svg",{className:"circle-progress-bar",width:200,height:200},React.createElement("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),React.createElement("span",{className:"result-achieved"},"".concat(b,"%")),React.createElement("span",{className:"result-require"},v||_x("-","unknown passing grade value","learnpress"))),o&&React.createElement("p",{className:"result-message"},O),React.createElement("ul",{className:"result-statistic"},React.createElement("li",{className:"result-statistic-field result-time-spend"},React.createElement("span",null,Object(c.__)("Time spend","learnpress")),React.createElement("p",null,l.timeSpend)),React.createElement("li",{className:"result-statistic-field result-point"},React.createElement("span",null,Object(c.__)("Point","learnpress")),React.createElement("p",null,l.userMark," / ",l.mark)),React.createElement("li",{className:"result-statistic-field result-questions"},React.createElement("span",null,Object(c.__)("Questions","learnpress")),React.createElement("p",null,l.questionCount)),React.createElement("li",{className:"result-statistic-field result-questions-correct"},React.createElement("span",null,Object(c.__)("Correct","learnpress")),React.createElement("p",null,l.questionCorrect)),React.createElement("li",{className:"result-statistic-field result-questions-wrong"},React.createElement("span",null,Object(c.__)("Wrong","learnpress")),React.createElement("p",null,l.questionWrong)),React.createElement("li",{className:"result-statistic-field result-questions-skipped"},React.createElement("span",null,Object(c.__)("Skipped","learnpress")),React.createElement("p",null,l.questionEmpty))))},xe=jQuery,De=lodash.debounce,Me=function(){var e=Object(u.dispatch)("learnpress/quiz").submitQuiz;Object(i.useEffect)((function(){var e=xe("#popup-content");if(e.length){var t=e.find(".content-item-scrollable:eq(1)"),n=e.find(".content-item-wrap"),r=e.find(".quiz-status"),o=r.offset().top-92,i=!1,a="-"+n.css("margin-left");xe(window).on("resize.refresh-quiz-stauts-bar",De((function(){a="-"+n.css("margin-left"),r.css({"margin-left":a,"margin-right":a})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(function(){if(t.scrollTop()>=o){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}}),[]);var t=Object(u.select)("learnpress/quiz"),n=t.getData,r=t.getUserMark,o=n("currentPage"),a=n("questionsPerPage"),s=n("questionIds").length,l=n("submitting"),f=n("totalTime"),p=n("duration"),d=r(),m=["quiz-status"],b=(o-1)*a+1,y=b+a-1,h="";return y=Math.min(y,s),l&&m.push("submitting"),h=y<s?a>1?Object(c.sprintf)(Object(c.__)("Question <span>%d to %d of %d</span>","learnpress"),b,y,s):Object(c.sprintf)(Object(c.__)("Question <span>%d of %d</span>","learnpress"),b,s):Object(c.sprintf)(Object(c.__)("Question <span>%d to %d</span>","learnpress"),b,y),React.createElement("div",{className:m.join(" ")},React.createElement("div",null,React.createElement("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:h}}),React.createElement("div",{className:"current-point"},Object(c.sprintf)(Object(c.__)("Earned Point: %s","learnpress"),d)),React.createElement("div",null,React.createElement("div",{className:"submit-quiz"},React.createElement("button",{className:"lp-button",id:"button-submit-quiz",onClick:function t(){"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),t)&&e()}},l?Object(c.__)("Submitting...","learnpress"):Object(c.__)("Finish Quiz","learnpress"))),f&&p&&React.createElement(ze,null))))};function Le(e){return function(e){if(Array.isArray(e))return Ue(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ue(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(n),!0).forEach((function(t){Be(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ge=lodash,Je=(Ge.omit,Ge.flow),Ke=Ge.isArray,We=Ge.chunk,$e=(LP.camelCaseDashObjectKeys,LP.localStorage),Ze=$e.get,Ye=$e.set,Ve={},Xe=function(e,t){var n=He(He({},e.answered[t.questionId]||{}),{},{answered:t.answers,temp:!0});return He(He({},e),{},{answered:He(He({},e.answered),{},Be({},t.questionId,n))})},et=function(e,t){var n=e.questionsRendered;return Ke(n)?(n.push(t.questionId),He(He({},e),{},{questionsRendered:Le(n)})):He(He({},e),{},{questionsRendered:[t.questionId]})},tt=function(e,t){return t.currentPage&&Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),t)},nt=function(e,t){var n=e.questions.map((function(e){return e.id==t.questionId?He(He({},e),{},{showHint:t.showHint}):e}));return He(He({},e),{},{questions:Le(n)})},rt=function(e,t){var n=e.questions.map((function(e){if(e.id!==t.questionId)return e;var n={explanation:t.explanation};return t.options&&(n.options=t.options),He(He({},e),n)}));return He(He({},e),{},{questions:Le(n),answered:He(He({},e.answered),{},Be({},t.questionId,t.result)),checkedQuestions:[].concat(Le(e.checkedQuestions),[t.questionId])})},ot=function(e,t){var n=e.questions.map((function(n){var r={};return e.reviewQuestions&&(t.results.questions[n.id].explanation&&(r.explanation=t.results.questions[n.id].explanation),t.results.questions[n.id].options&&(r.options=t.results.questions[n.id].options)),He(He({},n),r)}));return tt(e,He(He({submitting:!1,currentPage:1},t.results),{},{questions:Le(n)}))},it=function(e,t){var n=void 0!==t.results.success&&t.results.success,r=t.results.message||!1;return tt(e,He(He({checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1},t.results.results),{},{successResponse:n,messageResponse:r}))},at=Je(u.combineReducers,(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}))({a:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1};return e},b:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2};return e}}),ut=Object(u.combineReducers)({blocks:at,userQuiz:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);var n=We(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=n.length,t.data.pages=n,He(He(He({},e),t.data),{},{currentPage:Ze("Q".concat(t.data.id,".currentPage"))||t.data.currentPage});case"SUBMIT_QUIZ":return He(He({},e),{},{submitting:!0});case"START_QUIZ":case"START_QUIZ_SUCCESS":return it(e,t);case"SET_CURRENT_QUESTION":return Ye("Q".concat(e.id,".currentQuestion"),t.questionId),He(He({},e),{},{currentQuestion:t.questionId});case"SET_CURRENT_PAGE":return Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),{},{currentPage:t.currentPage});case"SUBMIT_QUIZ_SUCCESS":return ot(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?Xe(e,t):e;case"MARK_QUESTION_RENDERED":return et(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?tt(e,{mode:t.mode}):He(He({},e),{},{mode:t.mode});case"SET_QUESTION_HINT":return nt(e,t);case"CHECK_ANSWER":return rt(e,t);case"SEND_KEY":return He(He({},e),{},{keyPressed:t.keyPressed})}return e}}),st=n(10);function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var lt=regeneratorRuntime.mark(Pt),ft=regeneratorRuntime.mark(Qt),pt=regeneratorRuntime.mark(At);function dt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(e){return function(e){if(Array.isArray(e))return bt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return bt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return bt(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yt(){var e=[].slice.call(arguments,2),t=Object(u.dispatch)(arguments[0]),n=arguments[1];t[n].apply(t,mt(e))}var ht=LP,gt=ht.camelCaseDashObjectKeys,vt=ht.Hook;function wt(e,t){return t="string"==typeof e?dt({},e,t):e,"1"==lpQuizSettings.checkNorequizenroll&&null!==window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id)&&(t=JSON.parse(window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id))),{type:"SET_QUIZ_DATA",data:gt(t)}}function Ot(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function _t(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function St(e,t,n){return{type:"BEFORE_START_QUIZ"}}function qt(e,t,n,r){return vt.doAction("quiz-started",e,t,n,r),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:n,userId:r,results:e}}var jt=regeneratorRuntime.mark((function e(){var t,n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Object(u.select)("learnpress/quiz").getDefaultRestArgs(),n=t.itemId,r=t.courseId,!0===vt.applyFilters("before-start-quiz",!0,n,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,Object(st.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:n,course_id:r}});case 6:return o=e.sent,o=vt.applyFilters("request-start-quiz-response",o,n,r),e.next=10,yt("learnpress/quiz","__requestStartQuizSuccess",gt(o),n,r);case 10:case"end":return e.stop()}}),e)}));function Rt(){return{type:"SUBMIT_QUIZ"}}function Et(e,t,n){return vt.doAction("quiz-submitted",e,t,n),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function Pt(){var e,t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(e=Object(u.select)("learnpress/quiz"),t=e.getDefaultRestArgs,n=e.getQuestionsSelectedAnswers,r=t(),o=r.itemId,i=r.courseId,!0===vt.applyFilters("before-submit-quiz",!0)){c.next=5;break}return c.abrupt("return");case 5:return a=n(),c.next=8,Object(st.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:o,course_id:i,answered:a}});case 8:if(s=c.sent,"1"==lpQuizSettings.checkNorequizenroll&&(window.localStorage.removeItem("quiz_end_"+lpQuizSettings.id),window.localStorage.setItem("quiz_end_"+lpQuizSettings.id,Date.now())),!(s=vt.applyFilters("request-submit-quiz-response",s,o,i)).success){c.next=14;break}return c.next=14,yt("learnpress/quiz","__requestSubmitQuizSuccess",gt(s.results),o,i);case 14:"1"==lpQuizSettings.checkNorequizenroll&&localStorage.setItem("quiz_userdata_"+lpQuizSettings.id,JSON.stringify(Object(u.select)("learnpress/quiz").getData()));case 15:case"end":return c.stop()}}),lt)}function zt(e,t,n){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function kt(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function Qt(e,t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yt("learnpress/quiz","__requestShowHintSuccess",e,t);case 2:case"end":return n.stop()}}),ft)}function It(e,t){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach((function(t){dt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({type:"CHECK_ANSWER",questionId:e},t)}function At(e){var t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return t=Object(u.select)("learnpress/quiz"),n=t.getDefaultRestArgs,r=t.getQuestionAnswered,o=n(),i=o.itemId,a=o.courseId,c.next=4,Object(st.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:i,course_id:a,question_id:e,answered:r(e)||""}});case 4:return s=c.sent,c.next=7,yt("learnpress/quiz","__requestCheckAnswerSuccess",e,gt(s));case 7:case"end":return c.stop()}}),pt)}function Ct(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Nt(e){return{type:"SET_QUIZ_MODE",mode:e}}function Tt(e){return setTimeout((function(){yt("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}var xt=lodash,Dt=xt.get,Mt=xt.isArray,Lt=function(e,t){console.time("parseOptions");var n=Yt(e,t).options;return n=Mt(n)?n:JSON.parse(CryptoJS.AES.decrypt(n.data,n.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),n=Mt(n)?n:JSON.parse(n),console.timeEnd("parseOptions"),n};function Ut(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.status"):""}function Ft(e,t,n){return e[t]||n}function Ht(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.attempts"):[]}function Bt(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.answered",{}):{}}function Gt(e){var t=e.userQuiz,n=Dt(t,"questions");return n?Object.values(n):[]}function Jt(e,t){var n=e.userQuiz;return t?Dt(n,t):n}function Kt(e){var t=e.userQuiz;return{itemId:t.id,courseId:t.courseId}}function Wt(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".answered"))||void 0}function $t(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".mark"))||void 0}function Zt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=Dt(e,"userQuiz.questionsPerPage")||1;if(n>1)return!1;var r=Dt(e,"userQuiz.currentPage")||1;return Dt(e,"object"===t?"userQuiz.questions[".concat(r-1,"]"):"userQuiz.questionIds[".concat(r-1,"]"))}var Yt=function(e,t){e.userQuiz;return Object(u.select)("learnpress/quiz").getQuestions().find((function(e){return e.id==t}))};function Vt(e,t){return-1!==(Dt(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function Xt(e,t){}var en=function(e,t){var n=Dt(e,"userQuiz.answered"),r={};for(var o in n)if(n.hasOwnProperty(o))if("1"==lpQuizSettings.checknorequizenroll){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}else if(n[o].temp||n[o].blanks){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}return r};function tn(e){var t=e.userQuiz||{},n=t.answered,r=t.negativeMarking,o=t.questions,i=t.checkedQuestions,a=0,u=function(e){if(!n.hasOwnProperty(e))return s=e,"continue";e=parseInt(e);var t,u=n[e],c=u.questionMark?u.questionMark:(t=o.find((function(t){return s=e,t.id===e})),s=e,t?t.point:0);i.indexOf(e);if(u.temp)return s=e,"continue";r?u.answered&&(a=u.correct?a+u.mark:a-c):u.answered&&u.correct&&(a+=u.mark),s=e};for(var s in n)u(s);return a>0?a:0}var nn=n(7),rn=n.n(nn),on={ENROLL_COURSE_X:function(e,t){}};var an=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=rn()(on)(n)(e.dispatch),e.dispatch=t,e};function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var cn=LP.dataControls.controls,ln=Object(u.registerStore)("learnpress/quiz",{reducer:ut,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach((function(t){sn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},cn)});an(ln);function fn(e){return(fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function mn(e,t){return(mn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function bn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=gn(e);if(t){var o=gn(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return yn(this,n)}}function yn(e,t){return!t||"object"!==fn(t)&&"function"!=typeof t?hn(e):t}function hn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function gn(e){return(gn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wn=lodash.chunk,On=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mn(e,t)}(i,e);var t,n,r,o=bn(i);function i(e){var t;return pn(this,i),vn(hn(t=o.apply(this,arguments)),"startQuiz",(function(e){t.props.startQuiz()})),t.state={currentPage:1,numPages:0,pages:[]},t}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.settings,n=e.setQuizData,r=t.question_ids,o=t.questions_per_page,i=wn(r,o);t.currentPage=1,t.numPages=i.length,t.pages=i,n(t)}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.isReviewing,r=-1!==["","completed","viewed"].indexOf(t)||!t,o=-1!==["","viewed",void 0].indexOf(t)||!t;return void 0!==t&&React.createElement(React.Fragment,null,React.createElement("div",null,!n&&"completed"===t&&React.createElement(Te,null),!n&&o&&React.createElement(p,null),!n&&o&&React.createElement(s,null),"started"===t&&React.createElement(Me,null),(-1!==["completed","started"].indexOf(t)||n)&&React.createElement(je,null),React.createElement(E,null),r&&!n&&React.createElement(Re,null)))}}])&&dn(t.prototype,n),r&&dn(t,r),i}(i.Component),_n=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getQuestions,r=t.getData;return{questions:n(),status:r("status"),store:r(),answered:r("answered"),isReviewing:"reviewing"===r("mode"),questionIds:r("questionIds"),checkCount:r("instantCheck"),questionsPerPage:r("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{setQuizData:t.setQuizData,startQuiz:t.startQuiz}}))])(On);n(11);function Sn(e){return function(e){if(Array.isArray(e))return qn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qn(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var jn=LP.modal.default,Rn=(t.default=_n,function(e,t){wp.element.render(React.createElement(jn,null,React.createElement(_n,{settings:t})),Sn(document.querySelectorAll(e))[0]),LP.Hook.doAction("lp-quiz-compatible-builder")})}]);
|
1 |
+
this.LP=this.LP||{},this.LP.quiz=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.wp.data},function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},function(e,t,n){"use strict";e.exports=function(e){var t,n={};return function e(t,n){var r;if(Array.isArray(n))for(r=0;r<n.length;r++)e(t,n[r]);else for(r in n)t[r]=(t[r]||[]).concat(n[r])}(n,e),(t=function(e){return function(t){return function(r){var o,i,a=n[r.type],u=t(r);if(a)for(o=0;o<a.length;o++)(i=a[o](r,e))&&e.dispatch(i);return u}}}).effects=n,t}},,function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var r=n(5),o=n(6);function i(e,t,n,r,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,o)}function a(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;c(n),t.unobserve(n)}}))}));a(e).map((function(e){return t.observe(e)}))}},c=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var a=e.apply(t,n);function u(e){i(a,r,o,u,s,"next",e)}function s(e){i(a,r,o,u,s,"throw",e)}u(void 0)}))});return function(e){return t.apply(this,arguments)}}()},function(e,t){!function(){e.exports=this.LP.dataControls}()},function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,function(e,t,n){var r;
|
2 |
/*!
|
3 |
Copyright (c) 2018 Jed Watson.
|
4 |
Licensed under the MIT License (MIT), see
|
5 |
http://jedwatson.github.io/classnames
|
6 |
+
*/!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var i=typeof r;if("string"===i||"number"===i)e.push(r);else if(Array.isArray(r)){if(r.length){var a=o.apply(null,r);a&&e.push(a)}}else if("object"===i)if(r.toString===Object.prototype.toString)for(var u in r)n.call(r,u)&&r[u]&&e.push(u);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return Rn}));var r={};n.r(r),n.d(r,"setQuizData",(function(){return wt})),n.d(r,"setCurrentQuestion",(function(){return Ot})),n.d(r,"setCurrentPage",(function(){return _t})),n.d(r,"__requestBeforeStartQuiz",(function(){return St})),n.d(r,"__requestStartQuizSuccess",(function(){return qt})),n.d(r,"startQuiz",(function(){return jt})),n.d(r,"__requestSubmitQuiz",(function(){return Rt})),n.d(r,"__requestSubmitQuizSuccess",(function(){return Pt})),n.d(r,"submitQuiz",(function(){return Et})),n.d(r,"updateUserQuestionAnswers",(function(){return zt})),n.d(r,"__requestShowHintSuccess",(function(){return kt})),n.d(r,"showHint",(function(){return Qt})),n.d(r,"__requestCheckAnswerSuccess",(function(){return It})),n.d(r,"checkAnswer",(function(){return At})),n.d(r,"markQuestionRendered",(function(){return Ct})),n.d(r,"setQuizMode",(function(){return Nt})),n.d(r,"sendKey",(function(){return Tt}));var o={};n.r(o),n.d(o,"getQuestionOptions",(function(){return Lt})),n.d(o,"getItemStatus",(function(){return Ut})),n.d(o,"getProp",(function(){return Ft})),n.d(o,"getQuizAttempts",(function(){return Ht})),n.d(o,"getQuizAnswered",(function(){return Bt})),n.d(o,"getQuestions",(function(){return Gt})),n.d(o,"getData",(function(){return Jt})),n.d(o,"getDefaultRestArgs",(function(){return Kt})),n.d(o,"getQuestionAnswered",(function(){return Wt})),n.d(o,"getQuestionMark",(function(){return $t})),n.d(o,"getCurrentQuestion",(function(){return Zt})),n.d(o,"getQuestion",(function(){return Yt})),n.d(o,"isCheckedAnswer",(function(){return Vt})),n.d(o,"isCorrect",(function(){return Xt})),n.d(o,"getQuestionsSelectedAnswers",(function(){return en})),n.d(o,"getUserMark",(function(){return tn}));var i=n(2),a=n(4),u=n(1),s=function(){var e=Object(u.select)("learnpress/quiz").getData("content");return React.createElement("div",{className:"quiz-content",dangerouslySetInnerHTML:{__html:e}})},c=n(0),l=function(e){var t;if(e>86400)t=(e-e%86400)/86400,e%=86400;else if(86400==e)return"24:00";var n=new Date(1e3*e).toUTCString().match(/\d{2}:\d{2}:\d{2}/)[0].split(":");return t&&(n[0]=parseInt(n[0])+24*t),n.join(":")},f=LP.Hook,p=function(){var e=function(e){return Object(u.select)("learnpress/quiz").getData(e)},t=f.applyFilters("quiz-meta-fields",{duration:{title:Object(c.__)("Duration:","learnpress"),name:"duration",content:l(e("duration"))||"--"},passingGrade:{title:Object(c.__)("Passing grade:","learnpress"),name:"passing-grade",content:e("passingGrade")||"--"},questionsCount:{title:Object(c.__)("Questions:","learnpress"),name:"questions-count",content:e("questionIds")?e("questionIds").length:0}});return t&&React.createElement(React.Fragment,null,React.createElement("ul",{className:"quiz-intro"},Object.values(t).map((function(e,t){var n=e.name||t;return React.createElement("li",{key:"quiz-intro-field-".concat(t),className:"quiz-intro-item quiz-intro-item--".concat(n)},React.createElement("div",{className:"quiz-intro-item__title",dangerouslySetInnerHTML:{__html:e.title}}),React.createElement("span",{className:"quiz-intro-item__content",dangerouslySetInnerHTML:{__html:e.content}}))}))))};function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function m(e){return function(e){if(Array.isArray(e))return b(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return b(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return b(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function v(e,t){return(v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=S(e);if(t){var o=S(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return O(this,n)}}function O(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?_(e):t}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function q(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&v(e,t)}(i,e);var t,n,r,o=w(i);function i(){var e;h(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return q(_(e=o.call.apply(o,[this].concat(n))),"startQuiz",(function(t){t&&t.preventDefault();var n=document.querySelector(".lp-button.start");n&&n.setAttribute("disabled","disabled");var r=e.props,o=r.startQuiz;if("completed"===r.status){var i=Object(u.select)("learnpress/modal"),a=i.confirm,s=i.isOpen;if("no"===a(Object(c.__)("Are you sure you want to retake quiz?","learnpress"),e.startQuiz))return void(!s()&&n&&n.removeAttribute("disabled"))}if("1"==lpQuizSettings.checkNorequizenroll){window.localStorage.removeItem("quiz_start_"+lpQuizSettings.id),window.localStorage.setItem("quiz_start_"+lpQuizSettings.id,Date.now());var l=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);l>=1?window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,parseInt(l)+1):window.localStorage.setItem("quiz_retake_"+lpQuizSettings.id,1),window.localStorage.removeItem("quiz_userdata_"+lpQuizSettings.id)}o()})),q(_(e),"nav",(function(t){return function(n){var r=e.props,o=r.questionNav,i=r.currentPage,a=r.numPages,u=r.setCurrentPage;switch(t){case"prev":i>1?i-=1:i="infinity"===o?a:1;break;default:i<a?i+=1:i="infinity"===o?1:a}u(i)}})),q(_(e),"moveTo",(function(t){return function(n){n.preventDefault();var r=e.props,o=r.numPages,i=r.setCurrentPage;t<1||t>o||i(t)}})),q(_(e),"isLast",(function(){var t=e.props;return t.currentPage===t.numPages})),q(_(e),"isFirst",(function(){return 1===e.props.currentPage})),q(_(e),"submit",(function(){var t=e.props.submitQuiz;"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),e.submit)&&t()})),q(_(e),"setQuizMode",(function(t){return function(){(0,e.props.setQuizMode)(t)}})),q(_(e),"isReviewing",(function(){return e.props.isReviewing})),e}return t=i,(n=[{key:"pageNumbers",value:function(e){var t=this,n=this.props,r=n.numPages,o=n.currentPage;if(r<2)return"";(e=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?y(Object(n),!0).forEach((function(t){q(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({numPages:r,currentPage:o,midSize:1,endSize:1,prevNext:!0},e||{})).endSize<1&&(e.endSize=1),e.midSize<0&&(e.midSize=1);var i=m(Array(r).keys()),a=!1;return React.createElement("div",{className:"nav-links"},e.prevNext&&!this.isFirst()&&React.createElement("button",{className:"page-numbers prev","data-type":"question-navx",onClick:this.nav("prev")},Object(c.__)("Prev","learnpress")),i.map((function(n){return(n+=1)===e.currentPage?(a=!0,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers current"},n)):n<=e.endSize||e.currentPage&&n>=e.currentPage-e.midSize&&n<=e.currentPage+e.midSize||n>e.numPages-e.endSize?(a=!0,React.createElement("button",{key:"page-number-".concat(n),className:"page-numbers",onClick:t.moveTo(n)},n)):a?(a=!1,React.createElement("span",{key:"page-number-".concat(n),className:"page-numbers dots"},"…")):""})),e.prevNext&&!this.isLast()&&React.createElement("button",{className:"page-numbers next","data-type":"question-navx",onClick:this.nav("next")},Object(c.__)("Next","learnpress")))}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.questionNav,r=e.isReviewing,o=e.showReview,i=e.numPages,a=(e.question,e.questionsPerPage,e.canRetry),u=e.retakeNumber,s=["quiz-buttons"];("started"===t||r)&&s.push("align-center"),"questionNav"===n&&s.push("infinity"),this.isFirst()&&s.push("is-first"),this.isLast()&&s.push("is-last");var l=document.querySelector("#popup-sidebar"),f=document.querySelector("#learn-press-quiz-app"),p="";p="started"===t||r?{marginLeft:l&&l.offsetWidth/2,width:f&&f.offsetWidth}:null;var d=" fixed";return"no"==lpQuizSettings.navigationPosition&&(d=" nav-center"),React.createElement(React.Fragment,null,React.createElement("div",{className:s.join(" ")},React.createElement("div",{className:"button-left"+("started"===t||r?d:""),style:p},("completed"===t&&a||-1!==["","viewed"].indexOf(t))&&!r&&React.createElement("button",{className:"lp-button start",onClick:this.startQuiz},"completed"===t?"".concat(Object(c.__)("Retake","learnpress")).concat(u?" (".concat(u,")"):""):Object(c.__)("Start","learnpress")),("started"===t||r)&&i>1&&React.createElement(React.Fragment,null,React.createElement("div",{className:"questions-pagination"},this.pageNumbers()))),React.createElement("div",{className:"button-right"},"started"===t&&React.createElement(React.Fragment,null,("infinity"===n||this.isLast())&&!r&&React.createElement("button",{className:"lp-button submit-quiz",onClick:this.submit},Object(c.__)("Finish Quiz","learnpress"))),r&&o&&React.createElement("button",{className:"lp-button back-quiz",onClick:this.setQuizMode("")},Object(c.__)("Result","learnpress")),"completed"===t&&o&&!r&&React.createElement("button",{className:"lp-button review-quiz",onClick:this.setQuizMode("reviewing")},Object(c.__)("Review","learnpress")))),this.props.message&&!0!==this.props.success&&React.createElement("div",{className:"learn-press-message error"},this.props.message))}}])&&g(t.prototype,n),r&&g(t,r),i}(i.Component),R=Object(a.compose)(Object(u.withSelect)((function(e){var t=e("learnpress/quiz").getData;return{status:t("status"),showCheck:t("instantCheck"),checkedQuestions:t("checkedQuestions"),hintedQuestions:t("hintedQuestions"),questionsPerPage:t("questionsPerPage")}})))((function(e){var t=e.showCheck,n=e.checkedQuestions,r=e.hintedQuestions,o=e.question,i=e.status,a=e.type,u=e.Button;if("started"!==i)return!1;var s=React.createElement(u,{question:o});switch(a){case"hint":return r?!!o.hasHint&&(-1===r.indexOf(o.id)&&s):s;case"check":return!!t&&(n?-1===n.indexOf(o.id)&&s:s)}})),P=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getData,r=t.getCurrentQuestion,o={id:n("id"),status:n("status"),questionIds:n("questionIds"),questionNav:n("questionNav"),isReviewing:n("reviewQuestions")&&"reviewing"===n("mode"),showReview:n("reviewQuestions"),showCheck:n("instantCheck"),checkedQuestions:n("checkedQuestions"),hintedQuestions:n("hintedQuestions"),numPages:n("numPages"),pages:n("pages"),currentPage:n("currentPage"),questionsPerPage:n("questionsPerPage"),pageNumbers:n("pageNumbers"),keyPressed:n("keyPressed"),canRetry:n("retakeCount")>0&&n("retaken")<n("retakeCount"),retakeNumber:n("retakeCount")>0&&n("retaken")<n("retakeCount")?n("retakeCount")-n("retaken"):null,message:n("messageResponse")||!1,success:void 0===n("successResponse")||n("successResponse")};if(1===o.questionsPerPage&&(o.question=r("object")),"1"==lpQuizSettings.checkNorequizenroll){var i=window.localStorage.getItem("quiz_retake_"+lpQuizSettings.id);n("retakeCount")>i?(o.retakeNumber=n("retakeCount")-i,o.canRetry=!0):o.canRetry=!1}return o})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz"),r=n.startQuiz,o=n.setCurrentQuestion,i=n.submitQuiz,a=n.setQuizMode,u=n.showHint,s=n.checkAnswer;return{startQuiz:r,setCurrentQuestion:o,setQuizMode:a,setCurrentPage:n.setCurrentPage,submitQuiz:function(e){i(e)},showHint:function(e){u(e)},checkAnswer:function(e){s(e)}}}))])(j);function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=N(e);if(t){var o=N(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return A(this,n)}}function A(e,t){return!t||"object"!==E(t)&&"function"!=typeof t?C(e):t}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N(e){return(N=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var x=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Q(e,t)}(i,e);var t,n,r,o=I(i);function i(){var e;z(this,i);for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return T(C(e=o.call.apply(o,[this].concat(n))),"showHint",(function(){var t=e.props,n=t.showHint,r=t.question;n(r.id,!r.showHint)})),e}return t=i,(n=[{key:"render",value:function(){return this.props.question.hint?React.createElement("button",{className:"btn-show-hint",onClick:this.showHint},React.createElement("span",null,Object(c.__)("Hint","learnpress"))):""}}])&&k(t.prototype,n),r&&k(t,r),i}(i.Component),D=Object(a.compose)(Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").showHint;return{showHint:function(e,t){n(e,t)}}})))(x),M=n(13),L=n.n(M);function U(e){return(U="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function F(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function H(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function B(e,t){return(B=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function G(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=W(e);if(t){var o=W(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return J(this,n)}}function J(e,t){return!t||"object"!==U(t)&&"function"!=typeof t?K(e):t}function K(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function W(e){return(W=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function $(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&B(e,t)}(i,e);var t,n,r,o=G(i);function i(){var e;return F(this,i),$(K(e=o.apply(this,arguments)),"checkAnswer",(function(){var t=e.props,n=t.checkAnswer,r=t.question;t.answered&&(n(r.id),e.setState({loading:!0}))})),e.state={loading:!1},e}return t=i,(n=[{key:"render",value:function(){var e=this.props.answered;return React.createElement(React.Fragment,null,React.createElement("button",{className:L()("lp-button","instant-check",{loading:this.state.loading,disable:!e}),onClick:this.checkAnswer},React.createElement("span",{className:"instant-check__icon"}),Object(c.__)("Check answer","learnpress"),!e&&React.createElement("div",{className:"instant-check__info",dangerouslySetInnerHTML:{__html:Object(c.__)("You need to answer the question before check answer.","learnpress")}})))}}])&&H(t.prototype,n),r&&H(t,r),i}(i.Component),Y=Object(a.compose)(Object(u.withSelect)((function(e,t){var n=t.question.id;return{answered:(0,e("learnpress/quiz").getQuestionAnswered)(n)}})),Object(u.withDispatch)((function(e,t){t.id;var n=e("learnpress/quiz").checkAnswer;return{checkAnswer:function(e){n(e)}}})))(Z),V=function(e){var t=e.question,n={"instant-check":function(){return React.createElement(R,{type:"check",Button:Y,question:t})},hint:function(){return React.createElement(R,{type:"hint",Button:D,question:t})}};return React.createElement(React.Fragment,null,LP.config.questionFooterButtons().map((function(e){return React.createElement(i.Fragment,{key:"button-".concat(e)},n[e]&&n[e]())})))};function X(e){return(X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ee(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ee(Object(n),!0).forEach((function(t){ce(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ee(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function re(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function oe(e,t){return(oe=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ie(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=se(e);if(t){var o=se(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return ae(this,n)}}function ae(e,t){return!t||"object"!==X(t)&&"function"!=typeof t?ue(e):t}function ue(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function se(e){return(se=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function ce(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var le=window.jQuery,fe=lodash,pe=(fe.uniqueId,fe.isArray),de=(fe.isNumber,fe.bind,function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&oe(e,t)}(a,e);var t,n,r,o=ie(a);function a(){var e;return ne(this,a),ce(ue(e=o.apply(this,arguments)),"setRef",(function(t){e.$wrap=le(t)})),ce(ue(e),"parseOptions",(function(e){return e&&(e=pe(e)?e:JSON.parse(CryptoJS.AES.decrypt(e.data,e.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),e=pe(e)?e:JSON.parse(e)),e||[]})),ce(ue(e),"getWrapperClass",(function(){var t=e.props,n=t.question,r=(t.answered,["question","question-"+n.type]),o=e.parseOptions(n.options);return o.length&&void 0!==o[0].isTrue&&r.push("question-answered"),r})),ce(ue(e),"getEditLink",(function(){var t=e.props,n=t.question,r=t.editPermalink;return r?r.replace(/post=(.*[0-9])/,"post=".concat(n.id)):""})),ce(ue(e),"editPermalink",(function(e){return Object(c.sprintf)('<a href="%s">%s</a>',e,Object(c.__)("Edit","learnpress"))})),e.state={time:null,showHint:!1},e.$wrap=null,e}return t=a,(n=[{key:"componentDidMount",value:function(e){var t=this.props,n=t.question,r=t.isCurrent,o=t.markQuestionRendered;return r&&o(n.id),this.state.time||this.setState({time:new Date}),LP.Hook.doAction("lp-question-compatible-builder"),e}},{key:"render",value:function(){var e=this,t=this.props,n=t.question,r=t.isShow,o=t.isShowIndex,a=(t.isShowHint,t.status),u=LP.questionTypes.default,s=this.getEditLink();s&&jQuery("#wp-admin-bar-edit-lp_question").find(".ab-item").attr("href",s);var l={index:function(){return o?React.createElement("span",{className:"question-index"},o,"."):""},title:function(){return React.createElement("span",{dangerouslySetInnerHTML:{__html:n.title}})},hint:function(){return React.createElement(D,{question:n})},"edit-permalink":function(){return s&&React.createElement("span",{dangerouslySetInnerHTML:{__html:e.editPermalink(s)},className:"edit-link"})}},f={title:function(){return React.createElement("h4",{className:"question-title"},LP.config.questionTitleParts().map((function(e){return React.createElement(i.Fragment,{key:"title-part-".concat(e)},l[e]&&l[e]())})))},content:function(){return React.createElement("div",{className:"question-content",dangerouslySetInnerHTML:{__html:n.content}})},"answer-options":function(){return e.$wrap&&React.createElement(u,te(te({},e.props),{},{$wrap:e.$wrap}))},explanation:function(){return n.explanation&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-explanation-content"},React.createElement("strong",{className:"explanation-title"},Object(c.__)("Explanation:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.explanation}})))},hint:function(){return n.hint&&!n.explanation&&n.showHint&&React.createElement(React.Fragment,null,React.createElement("div",{className:"question-hint-content"},React.createElement("strong",{className:"hint-title"},Object(c.__)("Hint:","learnpress")),React.createElement("div",{dangerouslySetInnerHTML:{__html:n.hint}})))},buttons:function(){return"started"===a&&React.createElement(V,{question:n})}},p=LP.config.questionBlocks();return React.createElement(React.Fragment,null,React.createElement("div",{className:this.getWrapperClass().join(" "),style:{display:r?"":"none"},"data-id":n.id,ref:this.setRef},p.map((function(e){return React.createElement(i.Fragment,{key:"block-".concat(e)},f[e]?f[e]():"")}))))}}])&&re(t.prototype,n),r&&re(t,r),a}(i.Component)),me=Object(a.compose)([Object(u.withSelect)((function(e,t){var n=t.question.id,r=e("learnpress/quiz"),o=r.getData,i=r.getQuestionAnswered,a=r.getQuestionMark;return{status:o("status"),questions:o("question"),answered:i(n),questionsRendered:o("questionsRendered"),editPermalink:o("editPermalink"),numPages:o("numPages"),mark:a(n)||""}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz"),n=t.updateUserQuestionAnswers;return{markQuestionRendered:t.markQuestionRendered,updateUserQuestionAnswers:n}}))])(de);function be(e){return(be="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ye(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function he(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function ge(e,t){return(ge=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ve(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=_e(e);if(t){var o=_e(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return we(this,n)}}function we(e,t){return!t||"object"!==be(t)&&"function"!=typeof t?Oe(e):t}function Oe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _e(e){return(_e=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function Se(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qe=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&ge(e,t)}(i,e);var t,n,r,o=ve(i);function i(e){var t;return ye(this,i),Se(Oe(t=o.apply(this,arguments)),"startQuiz",(function(e){e.preventDefault(),(0,t.props.startQuiz)()})),Se(Oe(t),"isInVisibleRange",(function(e,n){var r=t.props,o=r.currentPage,i=r.questionsPerPage;return o===Math.ceil(n/i)})),Se(Oe(t),"nav",(function(e){var n=t.props.sendKey;switch(e.keyCode){case 37:return n("left");case 38:return;case 39:return n("right");case 40:return;default:e.keyCode>=49&&e.keyCode<=57&&n(e.keyCode-48)}})),t.needToTop=!1,t.state={isReviewing:null,currentPage:0,self:Oe(t)},t}return t=i,r=[{key:"getDerivedStateFromProps",value:function(e,t){for(var n=["isReviewing","currentPage"],r={},o=0;o<n.length;o++)e[n[o]]!==t[n[o]]&&(r[n[o]]=e[n[o]]);return Object.values(r).length?(t.self.needToTop=!0,r):null}}],(n=[{key:"componentDidUpdate",value:function(){this.needToTop&&(jQuery("#popup-content").animate({scrollTop:0}).find(".content-item-scrollable:last").animate({scrollTop:0}),this.needToTop=!1)}},{key:"render",value:function(){var e=this,t=this.props,n=t.status,r=t.currentQuestion,o=t.questions,i=t.questionsRendered,a=t.isReviewing,u=t.questionsPerPage,s=!0;return"completed"!==n||a||(s=!1),React.createElement(React.Fragment,null,React.createElement("div",{tabIndex:100,onKeyUp:this.nav},React.createElement("div",{className:"quiz-questions",style:{display:s?"":"none"}},o.map((function(t,n){var o=!u&&r===t.id,a=i&&-1!==i.indexOf(t.id),s=e.isInVisibleRange(t.id,n+1);return a||!a||s?React.createElement(me,{key:"loop-question-".concat(t.id),isCurrent:o,isShow:s,isShowIndex:!!u&&n+1,questionsPerPage:u,question:t}):""})))))}}])&&he(t.prototype,n),r&&he(t,r),i}(i.Component),je=Object(a.compose)(Object(u.withSelect)((function(e,t,n){var r=e("learnpress/quiz"),o=r.getData,i=r.getQuestions;return{status:o("status"),currentQuestion:o("currentQuestion"),questions:i(),questionsRendered:o("questionsRendered"),isReviewing:"reviewing"===o("mode"),numPages:o("numPages"),currentPage:o("currentPage"),questionsPerPage:o("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{startQuiz:t.startQuiz,sendKey:t.sendKey}})))(qe);var Re=function(){var e=Object(u.select)("learnpress/quiz").getData("attempts")||[],t=e&&!!e.length;return!!t&&React.createElement(React.Fragment,null,React.createElement("div",{className:"quiz-attempts"},React.createElement("h4",{className:"attempts-heading"},Object(c.__)("Last Attempted","learnpress")),t&&React.createElement("table",null,React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",{className:"quiz-attempts__questions"},Object(c.__)("Questions","learnpress")),React.createElement("th",{className:"quiz-attempts__spend"},Object(c.__)("Time spend","learnpress")),React.createElement("th",{className:"quiz-attempts__marks"},Object(c.__)("Marks","learnpress")),React.createElement("th",{className:"quiz-attempts__grade"},Object(c.__)("Passing grade","learnpress")),React.createElement("th",{className:"quiz-attempts__result"},Object(c.__)("Result","learnpress")))),React.createElement("tbody",null,e.map((function(e,t){if("1"==lpQuizSettings.checkNorequizenroll){var n=window.localStorage.getItem("quiz_start_"+lpQuizSettings.id),r=window.localStorage.getItem("quiz_end_"+lpQuizSettings.id);n&&r&&(e.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(n,r).duration)}return React.createElement("tr",{key:"attempt-".concat(t)},React.createElement("td",{className:"quiz-attempts__questions"},"".concat(e.questionCorrect," / ").concat(e.questionCount)),React.createElement("td",{className:"quiz-attempts__spend"},e.timeSpend||"--"),React.createElement("td",{className:"quiz-attempts__marks"},"".concat(e.userMark," / ").concat(e.mark)),React.createElement("td",{className:"quiz-attempts__grade"},e.passingGrade||_x("-","unknown passing grade value","learnpress")),React.createElement("td",{className:"quiz-attempts__result"},"".concat(parseFloat(e.result).toFixed(2),"%")," ",React.createElement("span",null,e.graduationText)))}))))))};function Pe(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return Ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ee(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ze=function(){var e=Object(u.select)("learnpress/quiz").getData,t=Object(u.dispatch)("learnpress/quiz").submitQuiz,n=e("totalTime")?e("totalTime"):e("duration"),r=e("endTime"),o=new Date(r.replace(/-/g,"/")),a=new Date,s=(new Date).getTimezoneOffset(),c=parseInt(o.getTime()/1e3-(a.getTime()/1e3+60*s)),l=Pe(Object(i.useState)(c>0?c:0),2),f=l[0],p=l[1];Object(i.useEffect)((function(){var e=setInterval((function(){var n=f;(n-=1)>0?p(n):(clearInterval(e),t())}),1e3);return function(){return clearInterval(e)}}),[f]);return React.createElement("div",{className:"countdown"},React.createElement("i",{className:"fas fa-stopwatch"}),React.createElement("span",null,function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:":",r=[];return n<3600?(r.push((f-f%60)/60),r.push(f%60)):n&&(r.push((f-f%3600)/3600),e=f%3600,r.push((e-e%60)/60),r.push(e%60)),r.map((function(e){return e<10?"0".concat(e):e})).join(t)}()))},ke=n(9);function Qe(e){return function(e){if(Array.isArray(e))return Ce(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ae(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ie(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,u=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}(e,t)||Ae(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ae(e,t){if(e){if("string"==typeof e)return Ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ce(e,t):void 0}}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Ne=lodash.debounce,Te=function(){var e=Ie(Object(i.useState)(0),2),t=e[0],n=e[1],r=Ie(Object(i.useState)(!1),2),o=r[0],a=r[1],s=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("id")}),[]),l=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("results")}),[]),f=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("passingGrade")}),[]),p=Object(u.useSelect)((function(e){return e("learnpress/quiz").getData("submitting")}),[]);Object(i.useEffect)((function(){m();var e="";if(e=l.graduation?l.graduation:l.result>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed"){var t=document.querySelector(".course-curriculum .course-item.course-item-".concat(s));t&&(t.classList.remove("failed","passed"),t.classList.add("has-status","status-completed",e))}var n=Qe(document.querySelectorAll("#popup-header .items-progress"))[0];if(n){var r=n.querySelector(".items-completed");if(r){parseInt(r.textContent);var o=document.querySelectorAll("#popup-sidebar .course-curriculum .course-item.status-completed");r.textContent=parseInt(o.length)}}}),[l]),Object(i.useEffect)((function(){void 0!==p&&d()}),[p]);var d=function(){var e=document.querySelectorAll(".popup-header__inner");e.length>0&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&Object(ke.a)(e[0])},m=function(){n(0),a(!1),jQuery.easing._customEasing=function(e,t,n,r,o){return r*Math.sqrt(1-(t=t/o-1)*t)+n},Ne((function(){var e=jQuery("<span />").css({width:1,height:1}).appendTo(document.body);e.css("left",0).animate({left:l.result},{duration:1500,step:function(e,t){n(e)},done:function(){a(!0),e.remove(),jQuery("#quizResultGrade").css({transform:"scale(1.3)",transition:"all 0.25s"}),Ne((function(){jQuery("#quizResultGrade").css({transform:"scale(1)"})}),500)()},easing:"_customEasing"})}),l.result>0?1e3:10)()},b=t;Number.isInteger(t)||(b=parseFloat(t).toFixed(2));var y=190*Math.PI,h=y-b/100*y,g={strokeDasharray:"".concat(y," ").concat(y),strokeDashoffset:h},v=l.passingGrade||f,w="";w=l.graduation?l.graduation:b>=v.replace(/[^0-9\.]+/g,"")?"passed":"failed";var O="";O=l.graduationText?l.graduationText:"passed"===w?Object(c.__)("Passed","learnpress"):Object(c.__)("Failed","learnpress");var _=["quiz-result",w];if("1"==lpQuizSettings.checkNorequizenroll){var S=window.localStorage.getItem("quiz_start_"+s),q=window.localStorage.getItem("quiz_end_"+s);S&&q&&(l.timeSpend=function(e,t){var n=new Object,r=t-e;n.days=Math.floor(r/1e3/60/60/24),r-=1e3*n.days*60*60*24,n.hours=Math.floor(r/1e3/60/60),r-=1e3*n.hours*60*60,n.minutes=Math.floor(r/1e3/60),r-=1e3*n.minutes*60,n.seconds=Math.floor(r/1e3);var o="00";n.days>0&&(o=String(n.days));1==o.length&&(o="0"+o);var i="00";n.minutes>0&&(i=String(n.minutes));1==i.length&&(i="0"+i);var a="00";n.seconds>0&&(a=String(n.seconds));1==a.length&&(a="0"+a);var u=o+":"+i+":"+a;return n.duration=u,n}(S,q).duration)}return React.createElement("div",{className:_.join(" ")},React.createElement("h3",{className:"result-heading"},Object(c.__)("Your Result","learnpress")),React.createElement("div",{id:"quizResultGrade",className:"result-grade"},React.createElement("svg",{className:"circle-progress-bar",width:200,height:200},React.createElement("circle",{className:"circle-progress-bar__circle",stroke:"",strokeWidth:10,style:g,fill:"transparent",r:95,cx:100,cy:100})),React.createElement("span",{className:"result-achieved"},"".concat(b,"%")),React.createElement("span",{className:"result-require"},v||_x("-","unknown passing grade value","learnpress"))),o&&React.createElement("p",{className:"result-message"},O),React.createElement("ul",{className:"result-statistic"},React.createElement("li",{className:"result-statistic-field result-time-spend"},React.createElement("span",null,Object(c.__)("Time spend","learnpress")),React.createElement("p",null,l.timeSpend)),React.createElement("li",{className:"result-statistic-field result-point"},React.createElement("span",null,Object(c.__)("Point","learnpress")),React.createElement("p",null,l.userMark," / ",l.mark)),React.createElement("li",{className:"result-statistic-field result-questions"},React.createElement("span",null,Object(c.__)("Questions","learnpress")),React.createElement("p",null,l.questionCount)),React.createElement("li",{className:"result-statistic-field result-questions-correct"},React.createElement("span",null,Object(c.__)("Correct","learnpress")),React.createElement("p",null,l.questionCorrect)),React.createElement("li",{className:"result-statistic-field result-questions-wrong"},React.createElement("span",null,Object(c.__)("Wrong","learnpress")),React.createElement("p",null,l.questionWrong)),React.createElement("li",{className:"result-statistic-field result-questions-skipped"},React.createElement("span",null,Object(c.__)("Skipped","learnpress")),React.createElement("p",null,l.questionEmpty))))},xe=jQuery,De=lodash.debounce,Me=function(){var e=Object(u.dispatch)("learnpress/quiz").submitQuiz;Object(i.useEffect)((function(){var e=xe("#popup-content");if(e.length){var t=e.find(".content-item-scrollable:eq(1)"),n=e.find(".content-item-wrap"),r=e.find(".quiz-status"),o=r.offset().top-92,i=!1,a="-"+n.css("margin-left");xe(window).on("resize.refresh-quiz-stauts-bar",De((function(){a="-"+n.css("margin-left"),r.css({"margin-left":a,"margin-right":a})}),100)).trigger("resize.refresh-quiz-stauts-bar"),t.on("scroll",(function(){if(t.scrollTop()>=o){if(i)return;i=!0}else{if(!i)return;i=!1}i?e.addClass("fixed-quiz-status"):e.removeClass("fixed-quiz-status")}))}}),[]);var t=Object(u.select)("learnpress/quiz"),n=t.getData,r=t.getUserMark,o=n("currentPage"),a=n("questionsPerPage"),s=n("questionIds").length,l=n("submitting"),f=n("totalTime"),p=n("duration"),d=r(),m=["quiz-status"],b=(o-1)*a+1,y=b+a-1,h="";return y=Math.min(y,s),l&&m.push("submitting"),h=y<s?a>1?Object(c.sprintf)(Object(c.__)("Question <span>%d to %d of %d</span>","learnpress"),b,y,s):Object(c.sprintf)(Object(c.__)("Question <span>%d of %d</span>","learnpress"),b,s):Object(c.sprintf)(Object(c.__)("Question <span>%d to %d</span>","learnpress"),b,y),React.createElement("div",{className:m.join(" ")},React.createElement("div",null,React.createElement("div",{className:"questions-index",dangerouslySetInnerHTML:{__html:h}}),React.createElement("div",{className:"current-point"},Object(c.sprintf)(Object(c.__)("Earned Point: %s","learnpress"),d)),React.createElement("div",null,React.createElement("div",{className:"submit-quiz"},React.createElement("button",{className:"lp-button",id:"button-submit-quiz",onClick:function t(){"no"!==(0,Object(u.select)("learnpress/modal").confirm)(Object(c.__)("Are you sure to submit quiz?","learnpress"),t)&&e()}},l?Object(c.__)("Submitting...","learnpress"):Object(c.__)("Finish Quiz","learnpress"))),f&&p&&React.createElement(ze,null))))};function Le(e){return function(e){if(Array.isArray(e))return Ue(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return Ue(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Ue(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ue(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Fe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(n),!0).forEach((function(t){Be(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Be(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ge=lodash,Je=(Ge.omit,Ge.flow),Ke=Ge.isArray,We=Ge.chunk,$e=(LP.camelCaseDashObjectKeys,LP.localStorage),Ze=$e.get,Ye=$e.set,Ve={},Xe=function(e,t){var n=He(He({},e.answered[t.questionId]||{}),{},{answered:t.answers,temp:!0});return He(He({},e),{},{answered:He(He({},e.answered),{},Be({},t.questionId,n))})},et=function(e,t){var n=e.questionsRendered;return Ke(n)?(n.push(t.questionId),He(He({},e),{},{questionsRendered:Le(n)})):He(He({},e),{},{questionsRendered:[t.questionId]})},tt=function(e,t){return t.currentPage&&Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),t)},nt=function(e,t){var n=e.questions.map((function(e){return e.id==t.questionId?He(He({},e),{},{showHint:t.showHint}):e}));return He(He({},e),{},{questions:Le(n)})},rt=function(e,t){var n=e.questions.map((function(e){if(e.id!==t.questionId)return e;var n={explanation:t.explanation};return t.options&&(n.options=t.options),He(He({},e),n)}));return He(He({},e),{},{questions:Le(n),answered:He(He({},e.answered),{},Be({},t.questionId,t.result)),checkedQuestions:[].concat(Le(e.checkedQuestions),[t.questionId])})},ot=function(e,t){var n=e.questions.map((function(n){var r={};return e.reviewQuestions&&(t.results.questions[n.id].explanation&&(r.explanation=t.results.questions[n.id].explanation),t.results.questions[n.id].options&&(r.options=t.results.questions[n.id].options)),He(He({},n),r)}));return tt(e,He(He({submitting:!1,currentPage:1},t.results),{},{questions:Le(n)}))},it=function(e,t){var n=void 0!==t.results.success&&t.results.success,r=t.results.message||!1;return tt(e,He(He({checkedQuestions:[],hintedQuestions:[],mode:"",currentPage:1},t.results.results),{},{successResponse:n,messageResponse:r}))},at=Je(u.combineReducers,(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}),(function(e){return function(t,n){return e(t,n)}}))({a:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{a:1};return e},b:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{b:2};return e}}),ut=Object(u.combineReducers)({blocks:at,userQuiz:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Ve,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_QUIZ_DATA":1>t.data.questionsPerPage&&(t.data.questionsPerPage=1);var n=We(e.questionIds||t.data.questionIds,t.data.questionsPerPage);return t.data.numPages=n.length,t.data.pages=n,He(He(He({},e),t.data),{},{currentPage:Ze("Q".concat(t.data.id,".currentPage"))||t.data.currentPage});case"SUBMIT_QUIZ":return He(He({},e),{},{submitting:!0});case"START_QUIZ":case"START_QUIZ_SUCCESS":return it(e,t);case"SET_CURRENT_QUESTION":return Ye("Q".concat(e.id,".currentQuestion"),t.questionId),He(He({},e),{},{currentQuestion:t.questionId});case"SET_CURRENT_PAGE":return Ye("Q".concat(e.id,".currentPage"),t.currentPage),He(He({},e),{},{currentPage:t.currentPage});case"SUBMIT_QUIZ_SUCCESS":return ot(e,t);case"UPDATE_USER_QUESTION_ANSWERS":return"started"===e.status?Xe(e,t):e;case"MARK_QUESTION_RENDERED":return et(e,t);case"SET_QUIZ_MODE":return"reviewing"==t.mode?tt(e,{mode:t.mode}):He(He({},e),{},{mode:t.mode});case"SET_QUESTION_HINT":return nt(e,t);case"CHECK_ANSWER":return rt(e,t);case"SEND_KEY":return He(He({},e),{},{keyPressed:t.keyPressed})}return e}}),st=n(10);function ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}var lt=regeneratorRuntime.mark(Et),ft=regeneratorRuntime.mark(Qt),pt=regeneratorRuntime.mark(At);function dt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mt(e){return function(e){if(Array.isArray(e))return bt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return bt(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return bt(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function yt(){var e=[].slice.call(arguments,2),t=Object(u.dispatch)(arguments[0]),n=arguments[1];t[n].apply(t,mt(e))}var ht=LP,gt=ht.camelCaseDashObjectKeys,vt=ht.Hook;function wt(e,t){return t="string"==typeof e?dt({},e,t):e,"1"==lpQuizSettings.checkNorequizenroll&&null!==window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id)&&(t=JSON.parse(window.localStorage.getItem("quiz_userdata_"+lpQuizSettings.id))),{type:"SET_QUIZ_DATA",data:gt(t)}}function Ot(e){return{type:"SET_CURRENT_QUESTION",questionId:e}}function _t(e){return{type:"SET_CURRENT_PAGE",currentPage:e}}function St(e,t,n){return{type:"BEFORE_START_QUIZ"}}function qt(e,t,n,r){return vt.doAction("quiz-started",e,t,n,r),{type:"START_QUIZ_SUCCESS",quizId:t,courseId:n,userId:r,results:e}}var jt=regeneratorRuntime.mark((function e(){var t,n,r,o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=Object(u.select)("learnpress/quiz").getDefaultRestArgs(),n=t.itemId,r=t.courseId,!0===vt.applyFilters("before-start-quiz",!0,n,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,Object(st.apiFetch)({path:"lp/v1/users/start-quiz",method:"POST",data:{item_id:n,course_id:r}});case 6:return o=e.sent,o=vt.applyFilters("request-start-quiz-response",o,n,r),e.next=10,yt("learnpress/quiz","__requestStartQuizSuccess",gt(o),n,r);case 10:case"end":return e.stop()}}),e)}));function Rt(){return{type:"SUBMIT_QUIZ"}}function Pt(e,t,n){return vt.doAction("quiz-submitted",e,t,n),{type:"SUBMIT_QUIZ_SUCCESS",results:e}}function Et(){var e,t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:if(e=Object(u.select)("learnpress/quiz"),t=e.getDefaultRestArgs,n=e.getQuestionsSelectedAnswers,r=t(),o=r.itemId,i=r.courseId,!0===vt.applyFilters("before-submit-quiz",!0)){c.next=5;break}return c.abrupt("return");case 5:return a=n(),c.next=8,Object(st.apiFetch)({path:"lp/v1/users/submit-quiz",method:"POST",data:{item_id:o,course_id:i,answered:a}});case 8:if(s=c.sent,"1"==lpQuizSettings.checkNorequizenroll&&(window.localStorage.removeItem("quiz_end_"+lpQuizSettings.id),window.localStorage.setItem("quiz_end_"+lpQuizSettings.id,Date.now())),!(s=vt.applyFilters("request-submit-quiz-response",s,o,i)).success){c.next=14;break}return c.next=14,yt("learnpress/quiz","__requestSubmitQuizSuccess",gt(s.results),o,i);case 14:"1"==lpQuizSettings.checkNorequizenroll&&localStorage.setItem("quiz_userdata_"+lpQuizSettings.id,JSON.stringify(Object(u.select)("learnpress/quiz").getData()));case 15:case"end":return c.stop()}}),lt)}function zt(e,t,n){return{type:"UPDATE_USER_QUESTION_ANSWERS",questionId:e,answers:t}}function kt(e,t){return{type:"SET_QUESTION_HINT",questionId:e,showHint:t}}function Qt(e,t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,yt("learnpress/quiz","__requestShowHintSuccess",e,t);case 2:case"end":return n.stop()}}),ft)}function It(e,t){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ct(Object(n),!0).forEach((function(t){dt(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ct(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({type:"CHECK_ANSWER",questionId:e},t)}function At(e){var t,n,r,o,i,a,s;return regeneratorRuntime.wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return t=Object(u.select)("learnpress/quiz"),n=t.getDefaultRestArgs,r=t.getQuestionAnswered,o=n(),i=o.itemId,a=o.courseId,c.next=4,Object(st.apiFetch)({path:"lp/v1/users/check-answer",method:"POST",data:{item_id:i,course_id:a,question_id:e,answered:r(e)||""}});case 4:return s=c.sent,c.next=7,yt("learnpress/quiz","__requestCheckAnswerSuccess",e,gt(s));case 7:case"end":return c.stop()}}),pt)}function Ct(e){return{type:"MARK_QUESTION_RENDERED",questionId:e}}function Nt(e){return{type:"SET_QUIZ_MODE",mode:e}}function Tt(e){return setTimeout((function(){yt("learnpress/quiz","sendKey","")}),300),{type:"SEND_KEY",keyPressed:e}}var xt=lodash,Dt=xt.get,Mt=xt.isArray,Lt=function(e,t){console.time("parseOptions");var n=Yt(e,t).options;return n=Mt(n)?n:JSON.parse(CryptoJS.AES.decrypt(n.data,n.key,{format:CryptoJSAesJson}).toString(CryptoJS.enc.Utf8)),n=Mt(n)?n:JSON.parse(n),console.timeEnd("parseOptions"),n};function Ut(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.status"):""}function Ft(e,t,n){return e[t]||n}function Ht(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.attempts"):[]}function Bt(e,t){var n=Object(u.select)("course-learner/user").getItemById(t);return n?Dt(n,"userSettings.answered",{}):{}}function Gt(e){var t=e.userQuiz,n=Dt(t,"questions");return n?Object.values(n):[]}function Jt(e,t){var n=e.userQuiz;return t?Dt(n,t):n}function Kt(e){var t=e.userQuiz;return{itemId:t.id,courseId:t.courseId}}function Wt(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".answered"))||void 0}function $t(e,t){var n=e.userQuiz;return Dt(n,"answered.".concat(t,".mark"))||void 0}function Zt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=Dt(e,"userQuiz.questionsPerPage")||1;if(n>1)return!1;var r=Dt(e,"userQuiz.currentPage")||1;return Dt(e,"object"===t?"userQuiz.questions[".concat(r-1,"]"):"userQuiz.questionIds[".concat(r-1,"]"))}var Yt=function(e,t){e.userQuiz;return Object(u.select)("learnpress/quiz").getQuestions().find((function(e){return e.id==t}))};function Vt(e,t){return-1!==(Dt(e,"userQuiz.checkedQuestions")||[]).indexOf(t)}function Xt(e,t){}var en=function(e,t){var n=Dt(e,"userQuiz.answered"),r={};for(var o in n)if(n.hasOwnProperty(o))if("1"==lpQuizSettings.checknorequizenroll){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}else if(n[o].temp||n[o].blanks){if(t&&o===t)return n[o].answered;r[o]=n[o].answered}return r};function tn(e){var t=e.userQuiz||{},n=t.answered,r=t.negativeMarking,o=t.questions,i=t.checkedQuestions,a=0,u=function(e){if(!n.hasOwnProperty(e))return s=e,"continue";e=parseInt(e);var t,u=n[e],c=u.questionMark?u.questionMark:(t=o.find((function(t){return s=e,t.id===e})),s=e,t?t.point:0);i.indexOf(e);if(u.temp)return s=e,"continue";r?u.answered&&(a=u.correct?a+u.mark:a-c):u.answered&&u.correct&&(a+=u.mark),s=e};for(var s in n)u(s);return a>0?a:0}var nn=n(7),rn=n.n(nn),on={ENROLL_COURSE_X:function(e,t){}};var an=function(e){var t=function(){throw new Error("Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},n={getState:e.getState,dispatch:function(){return t.apply(void 0,arguments)}};return t=rn()(on)(n)(e.dispatch),e.dispatch=t,e};function un(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function sn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var cn=LP.dataControls.controls,ln=Object(u.registerStore)("learnpress/quiz",{reducer:ut,selectors:o,actions:r,controls:function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?un(Object(n),!0).forEach((function(t){sn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):un(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},cn)});an(ln);function fn(e){return(fn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function pn(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dn(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function mn(e,t){return(mn=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function bn(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=gn(e);if(t){var o=gn(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return yn(this,n)}}function yn(e,t){return!t||"object"!==fn(t)&&"function"!=typeof t?hn(e):t}function hn(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function gn(e){return(gn=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function vn(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var wn=lodash.chunk,On=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&mn(e,t)}(i,e);var t,n,r,o=bn(i);function i(e){var t;return pn(this,i),vn(hn(t=o.apply(this,arguments)),"startQuiz",(function(e){t.props.startQuiz()})),t.state={currentPage:1,numPages:0,pages:[]},t}return t=i,(n=[{key:"componentDidMount",value:function(){var e=this.props,t=e.settings,n=e.setQuizData,r=t.question_ids,o=t.questions_per_page,i=wn(r,o);t.currentPage=1,t.numPages=i.length,t.pages=i,n(t)}},{key:"render",value:function(){var e=this.props,t=e.status,n=e.isReviewing,r=-1!==["","completed","viewed"].indexOf(t)||!t,o=-1!==["","viewed",void 0].indexOf(t)||!t;return void 0!==t&&React.createElement(React.Fragment,null,React.createElement("div",null,!n&&"completed"===t&&React.createElement(Te,null),!n&&o&&React.createElement(p,null),!n&&o&&React.createElement(s,null),"started"===t&&React.createElement(Me,null),(-1!==["completed","started"].indexOf(t)||n)&&React.createElement(je,null),React.createElement(P,null),r&&!n&&React.createElement(Re,null)))}}])&&dn(t.prototype,n),r&&dn(t,r),i}(i.Component),_n=Object(a.compose)([Object(u.withSelect)((function(e){var t=e("learnpress/quiz"),n=t.getQuestions,r=t.getData;return{questions:n(),status:r("status"),store:r(),answered:r("answered"),isReviewing:"reviewing"===r("mode"),questionIds:r("questionIds"),checkCount:r("instantCheck"),questionsPerPage:r("questionsPerPage")||1}})),Object(u.withDispatch)((function(e){var t=e("learnpress/quiz");return{setQuizData:t.setQuizData,startQuiz:t.startQuiz}}))])(On);n(11);function Sn(e){return function(e){if(Array.isArray(e))return qn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return qn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qn(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var jn=LP.modal.default,Rn=(t.default=_n,function(e,t){wp.element.render(React.createElement(jn,null,React.createElement(_n,{settings:t})),Sn(document.querySelectorAll(e))[0]),LP.Hook.doAction("lp-quiz-compatible-builder")})}]);
|
assets/js/dist/frontend/single-course.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
this.LP=this.LP||{},this.LP.singleCourse=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=24)}([,,function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},,function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},function(e,t){e.exports=window.wp.url},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return a}));var i=jQuery,a=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},,,,,,,function(e,t){!function(){e.exports=this.LP.quiz}()},function(e,t){},,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return b})),n.d(t,"initCourseTabs",(function(){return w})),n.d(t,"initCourseSidebar",(function(){return S})),n.d(t,"enrollCourse",(function(){return L}));var r=n(2),o=(n(15),n(16),n(8));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(i,e);var t,n,r,o=c(i);function i(){return a(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"render",value:function(){return React.createElement(React.Fragment,null)}}])&&s(t.prototype,n),r&&s(t,r),i}(r.Component);document.addEventListener("DOMContentLoaded",(function(){Object(o.a)()}));n(6);var p=n(5);function v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){y(i,r,o,a,s,"next",e)}function s(e){y(i,r,o,a,s,"throw",e)}a(void 0)}))}}t.default=f;var b=function(){wp.element.render(React.createElement(f,null))},g=jQuery,w=function(){g("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){var t=g('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),g('label[for="'+g(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")}))},S=function(){var e=g(".course-summary-sidebar");if(e.length){var t=g(window),n=e.children(),r=e.offset(),o=e.height(),i=n.height(),a=32;t.on("scroll.fixed-course-sidebar",(function(){var s=t.scrollTop()-r.top+a;if(s<0)return e.removeClass("slide-top slide-down"),void n.css("top","");s>o-i?(e.removeClass("slide-down").addClass("slide-top"),n.css("top",o-i)):(e.removeClass("slide-top").addClass("slide-down"),n.css("top",a))})).trigger("scroll.fixed-course-sidebar")}},L=function(){var e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(r.style.display="none",e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),form.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(function(e){(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))},C=function(){var e=document.querySelectorAll(".lp-form-retake-course");e.length&&e.forEach((function(e){var t=e.querySelector(".button-retake-course"),n=e.querySelector("[name=retake-course]").value,r=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(function(e){e.preventDefault()})),t.addEventListener("click",(function(e){var o;e.preventDefault(),t.classList.add("loading"),t.disabled=!0,o=t,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:n}}).then((function(e){var t=e.status,n=e.message,i=e.data;r.innerHTML=n,null!=t&&"success"===t?(o.style.display="none",setTimeout((function(){window.location.replace(i.url_redirect)}),1e3)):r.classList.add("error")})).catch((function(e){r.classList.add("error"),r.innerHTML="error: "+e.message})).then((function(){o.classList.remove("loading"),o.disabled=!1,r.style.display="block"}))}))}))};g(window).on("load",(function(){var e;g("#popup-course"),g("#learn-press-course-curriculum");v(document.querySelectorAll(".course-extra-box")).map((function(e){var t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(function(){var n=t.nextElementSibling,r=document.querySelector(".course-extra-box.active");r&&!e.classList.contains("active")&&(r.classList.remove("active"),r.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),n.style.display="none"):(e.classList.add("active"),n.style.display="block")}))})),w(),S(),L(),(e=document.querySelectorAll("form.purchase-course")).length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),"success"===i&&a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),e.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=purchase-course]").value,o=e.querySelector("button.button-purchase-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),C(),function(){var e=document.querySelectorAll(".lp-course-progress-wrapper");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,r){e.forEach((function(e){if(e.isIntersecting){var r=e.target;setTimeout((function(){n(r)}),600),t.unobserve(r)}}))}));v(e).map((function(e){return t.observe(e)}))}var n=function(){var e=h(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}});case 2:n=e.sent,r=n.data,t.innerHTML=r;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}(),p.a.init()}))}]);
|
1 |
+
this.LP=this.LP||{},this.LP.singleCourse=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=25)}([,,function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return a}));var i=jQuery,a=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},,,,,,,function(e,t){!function(){e.exports=this.LP.quiz}()},function(e,t){},,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return b})),n.d(t,"initCourseTabs",(function(){return w})),n.d(t,"initCourseSidebar",(function(){return S})),n.d(t,"enrollCourse",(function(){return L}));var r=n(2),o=(n(15),n(16),n(8));function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return u(this,n)}}function u(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(i,e);var t,n,r,o=c(i);function i(){return a(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"render",value:function(){return React.createElement(React.Fragment,null)}}])&&s(t.prototype,n),r&&s(t,r),i}(r.Component);document.addEventListener("DOMContentLoaded",(function(){Object(o.a)()}));n(5);var p=n(6);function v(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function y(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){y(i,r,o,a,s,"next",e)}function s(e){y(i,r,o,a,s,"throw",e)}a(void 0)}))}}t.default=f;var b=function(){wp.element.render(React.createElement(f,null))},g=jQuery,w=function(){g("#learn-press-course-tabs").on("change",'input[name="learn-press-course-tab-radio"]',(function(e){var t=g('input[name="learn-press-course-tab-radio"]:checked').val();LP.Cookies.set("course-tab",t),g('label[for="'+g(e.target).attr("id")+'"]').closest("li").addClass("active").siblings().removeClass("active")}))},S=function(){var e=g(".course-summary-sidebar");if(e.length){var t=g(window),n=e.children(),r=e.offset(),o=e.height(),i=n.height(),a=32;t.on("scroll.fixed-course-sidebar",(function(){var s=t.scrollTop()-r.top+a;if(s<0)return e.removeClass("slide-top slide-down"),void n.css("top","");s>o-i?(e.removeClass("slide-down").addClass("slide-top"),n.css("top",o-i)):(e.removeClass("slide-top").addClass("slide-down"),n.css("top",a))})).trigger("scroll.fixed-course-sidebar")}},L=function(){var e=document.querySelectorAll("form.enroll-course");e.length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/enroll-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(r.style.display="none",e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),form.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=enroll-course]").value,o=e.querySelector("button.button-enroll-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),null!==document.querySelector(".course-detail-info")&&window.addEventListener("pageshow",(function(e){(e.persisted||void 0!==window.performance&&"back_forward"==String(window.performance.getEntriesByType("navigation")[0].type))&&location.reload()}))},C=function(){var e=document.querySelectorAll(".lp-form-retake-course");e.length&&e.forEach((function(e){var t=e.querySelector(".button-retake-course"),n=e.querySelector("[name=retake-course]").value,r=e.querySelector(".lp-ajax-message");e.addEventListener("submit",(function(e){e.preventDefault()})),t.addEventListener("click",(function(e){var o;e.preventDefault(),t.classList.add("loading"),t.disabled=!0,o=t,wp.apiFetch({path:"/lp/v1/courses/retake-course",method:"POST",data:{id:n}}).then((function(e){var t=e.status,n=e.message,i=e.data;r.innerHTML=n,null!=t&&"success"===t?(o.style.display="none",setTimeout((function(){window.location.replace(i.url_redirect)}),1e3)):r.classList.add("error")})).catch((function(e){r.classList.add("error"),r.innerHTML="error: "+e.message})).then((function(){o.classList.remove("loading"),o.disabled=!1,r.style.display="block"}))}))}))};g(window).on("load",(function(){var e;g("#popup-course"),g("#learn-press-course-curriculum");v(document.querySelectorAll(".course-extra-box")).map((function(e){var t=e.querySelector(".course-extra-box__title");t.addEventListener("click",(function(){var n=t.nextElementSibling,r=document.querySelector(".course-extra-box.active");r&&!e.classList.contains("active")&&(r.classList.remove("active"),r.querySelector(".course-extra-box__content").style.display="none"),e.classList.contains("active")?(e.classList.remove("active"),n.style.display="none"):(e.classList.add("active"),n.style.display="block")}))})),w(),S(),L(),(e=document.querySelectorAll("form.purchase-course")).length>0&&e.forEach((function(e){var t=function(){var t=h(regeneratorRuntime.mark((function t(n,r){var o,i,a,s;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,wp.apiFetch({path:"lp/v1/courses/purchase-course",method:"POST",data:{id:n}});case 3:o=t.sent,r.classList.remove("loading"),r.disabled=!1,i=o.status,a=o.data.redirect,(s=o.message)&&i&&(e.innerHTML+='<div class="lp-enroll-notice '.concat(i,'">').concat(s,"</div>"),"success"===i&&a&&(window.location.href=a)),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(0),e.innerHTML+='<div class="lp-enroll-notice error">'.concat(t.t0.message&&t.t0.message,"</div>");case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e,n){return t.apply(this,arguments)}}();e.addEventListener("submit",(function(n){n.preventDefault();var r=e.querySelector("input[name=purchase-course]").value,o=e.querySelector("button.button-purchase-course");o.classList.add("loading"),o.disabled=!0,t(r,o)}))})),C(),function(){var e=document.querySelectorAll(".lp-course-progress-wrapper");if(e.length){if("IntersectionObserver"in window){var t=new IntersectionObserver((function(e,r){e.forEach((function(e){if(e.isIntersecting){var r=e.target;setTimeout((function(){n(r)}),600),t.unobserve(r)}}))}));v(e).map((function(e){return t.observe(e)}))}var n=function(){var e=h(regeneratorRuntime.mark((function e(t){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:"lp/v1/lazy-load/course-progress",method:"POST",data:{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}});case 2:n=e.sent,r=n.data,t.innerHTML=r;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}}(),p.a.init()}))}]);
|
assets/js/dist/frontend/single-curriculum.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
this.LP=this.LP||{},this.LP.singleCurriculum=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=23)}([,,function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},,function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},function(e,t){e.exports=window.wp.url},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return l}));var i=jQuery,l=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},function(e,t,n){"use strict";n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return a}));var r=n(6),o=n(5);function i(e,t,n,r,o,i,l){try{var c=e[i](l),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var u=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;a(n),t.unobserve(n)}}))}));l(e).map((function(e){return t.observe(e)}))}},a=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function c(e){i(l,r,o,c,u,"next",e)}function u(e){i(l,r,o,c,u,"throw",e)}c(void 0)}))});return function(e){return t.apply(this,arguments)}}()},,function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,,,,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return g}));var r=n(2),o=n(8),i=jQuery,l=n(9);n(11);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}jQuery;var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r,o=f(i);function i(){return u(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"checkCourseDurationExpire",value:function(){var e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){var t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}},{key:"render",value:function(){return React.createElement("div",null)}}])&&a(t.prototype,n),r&&a(t,r),i}(r.Component),y=m;document.addEventListener("DOMContentLoaded",(function(){LP.Hook.doAction("lp-compatible-builder"),function(){var e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){var n=t.querySelector(".curriculum-sections"),r=e.querySelector(".search-course"),o=e.querySelector('.search-course input[type="text"]');if(!o||!n||!r)return;var i=n.querySelectorAll("li.section"),l=n.querySelectorAll("li.course-item"),c=[];l.forEach((function(e){var t=e.dataset.id,n=e.querySelector(".item-name");c.push({id:t,name:n?n.textContent.toLowerCase():""})}));var u=function(e){e.preventDefault();var t=o.value;r.classList.add("searching"),t||r.classList.remove("searching");var n=[];c.forEach((function(e){t&&!e.name.match(t.toLowerCase())||(n.push(e.id),l.forEach((function(e){-1!==n.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),i.forEach((function(e){var t=e.querySelectorAll(".course-item"),r=[];t.forEach((function(e){n.includes(e.dataset.id)&&r.push(e.dataset.id)})),0===r.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},a=r.querySelector(".clear");a&&a.addEventListener("click",(function(e){e.preventDefault(),o.value="",u(e)})),r.addEventListener("submit",u),o.addEventListener("keyup",u)}}(),Object(o.a)(),i(".learn-press-progress").each((function(){var e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")})),Object(l.b)(),(new m).checkCourseDurationExpire()}));var v=n(5),h=(n(3),jQuery),b={init:function(){this.scrollToItemViewing=function(){var e=h(".viewing-course-item");if(e.length){var t=h("#learn-press-course-curriculum"),n=(h("#popup-sidebar").outerHeight(),h(".section-title").outerHeight(),h(".section-header").outerHeight()),r=new RegExp("^viewing-course-item-([0-9].*)"),o=e.attr("class").split(/\s+/),i=0;if(h.each(o,(function(e,t){var n=r.exec(t);if(n)return i=n[1],!1})),0===i)return;var l=h(".course-item-"+i),c=(l.offset().top,l.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:c-n},800)}},this.scrollToItemViewing()}},g=(jQuery,t.default=y,function(){wp.element.render(React.createElement(y,null),document.getElementById("learn-press-course-curriculum"))});document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),v.a.init(),b.init()}))}]);
|
1 |
+
this.LP=this.LP||{},this.LP.singleCurriculum=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=23)}([,,function(e,t){e.exports=window.wp.element},function(e,t,n){"use strict";var r=jQuery,o=null,i={elLPOverlay:null,elMainContent:null,elTitle:null,elBtnYes:null,elBtnNo:null,elFooter:null,elCalledModal:null,callBackYes:null,instance:null,init:function(){return!!this.instance||(this.elLPOverlay=r(".lp-overlay"),!!this.elLPOverlay.length&&(o=this.elLPOverlay,this.elMainContent=o.find(".main-content"),this.elTitle=o.find(".modal-title"),this.elBtnYes=o.find(".btn-yes"),this.elBtnNo=o.find(".btn-no"),this.elFooter=o.find(".lp-modal-footer"),r(document).on("click",".close, .btn-no",(function(){o.hide()})),r(document).on("click",".btn-yes",(function(e){e.preventDefault(),e.stopPropagation(),"function"==typeof i.callBackYes&&i.callBackYes()})),this.instance=this,!0))},setElCalledModal:function(e){this.elCalledModal=e},setContentModal:function(e,t){this.elMainContent.html(e),"function"==typeof t&&t()},setTitleModal:function(e){this.elTitle.html(e)}};t.a=i},,function(e,t){e.exports=window.wp.url},function(e,t,n){"use strict";var r=n(3),o=(jQuery,{elBtnFinishCourse:null,elBtnCompleteItem:null,init:function(){r.a.init()&&void 0!==lpGlobalSettings&&"yes"===lpGlobalSettings.option_enable_popup_confirm_finish&&(this.elBtnFinishCourse=document.querySelectorAll(".lp-btn-finish-course"),this.elBtnCompleteItem=document.querySelector(".lp-btn-complete-item"),this.elBtnCompleteItem&&this.elBtnCompleteItem.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}})),this.elBtnFinishCourse&&this.elBtnFinishCourse.forEach((function(e){return e.addEventListener("click",(function(e){e.preventDefault();var t=e.target.closest("form");r.a.elLPOverlay.show(),r.a.setTitleModal(t.dataset.title),r.a.setContentModal('<div class="pd-2em">'+t.dataset.confirm+"</div>"),r.a.callBackYes=function(){t.submit()}}))})))}});t.a=o},,function(e,t,n){"use strict";function r(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return o(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return l}));var i=jQuery,l=(lodash.throttle,function(){var e=document.querySelector("#sidebar-toggle");e&&(i(window).innerWidth()<=768||LP.Cookies.get("sidebar-toggle")?e.setAttribute("checked","checked"):e.removeAttribute("checked"),document.querySelector("#popup-course").addEventListener("click",(function(e){var t;"sidebar-toggle"===e.target.id&&(LP.Cookies.set("sidebar-toggle",!!e.target.checked),t=LP.Cookies.get("sidebar-toggle"),i("body").removeClass("lp-sidebar-toggle__open"),i("body").removeClass("lp-sidebar-toggle__close"),t?i("body").addClass("lp-sidebar-toggle__close"):i("body").addClass("lp-sidebar-toggle__open"))}))),i("#learn-press-course-curriculum").find(".section-desc").each((function(e,t){var n=i('<span class="show-desc"></span>').on("click",(function(){r.toggleClass("c")})),r=i(t).siblings(".section-title").append(n)})),i(".section").each((function(){var e=i(this);e.find(".section-left").on("click",(function(){var t=e.toggleClass("closed").hasClass("closed"),n=LP.Cookies.get("closed-section-"+lpGlobalSettings.post_id)||[],o=parseInt(e.data("section-id")),i=n.findIndex((function(e){return e==o}));t?n.push(parseInt(e.data("section-id"))):n.splice(i,1),LP.Cookies.remove("closed-section-(.*)"),LP.Cookies.set("closed-section-"+lpGlobalSettings.post_id,r(new Set(n)))}))}))})},function(e,t,n){"use strict";n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return a}));var r=n(5),o=n(6);function i(e,t,n,r,o,i,l){try{var c=e[i](l),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function l(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var u=function(){var e=document.querySelectorAll(".popup-header__inner");if(e.length&&null===document.querySelector("#learn-press-quiz-app div.quiz-result")&&0===e[0].querySelectorAll("form.form-button-finish-course").length&&"IntersectionObserver"in window){var t=new IntersectionObserver((function(e,n){e.forEach((function(e){if(e.isIntersecting){var n=e.target;a(n),t.unobserve(n)}}))}));l(e).map((function(e){return t.observe(e)}))}},a=function(){var e,t=(e=regeneratorRuntime.mark((function e(t){var n,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,wp.apiFetch({path:Object(r.addQueryArgs)("lp/v1/lazy-load/items-progress",{courseId:lpGlobalSettings.post_id||"",userId:lpGlobalSettings.user_id||""}),method:"GET"});case 2:n=e.sent,i=n.data,t.innerHTML+=i,o.a.init();case 6:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function c(e){i(l,r,o,c,u,"next",e)}function u(e){i(l,r,o,c,u,"throw",e)}c(void 0)}))});return function(e){return t.apply(this,arguments)}}()},,function(e,t){function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return r(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}LP.Hook.addAction("lp-compatible-builder",(function(){LP.Hook.removeAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){Waypoint.refreshAll(),window.dispatchEvent(new Event("resize"))})),"undefined"!=typeof vc_js&&"undefined"!=typeof VcWaypoint&&n(document.querySelectorAll("#popup-content"))[0].addEventListener("scroll",(function(){VcWaypoint.refreshAll()}))})),LP.Hook.addAction("lp-quiz-compatible-builder",(function(){return LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0})),LP.Hook.addAction("lp-question-compatible-builder",(function(){return LP.Hook.removeAction("lp-question-compatible-builder"),LP.Hook.removeAction("lp-quiz-compatible-builder"),LP.Hook.doAction("lp-compatible-builder"),"undefined"!=typeof elementorFrontend?window.elementorFrontend.init():"undefined"!=typeof vc_js?("undefined"!=typeof vc_round_charts&&vc_round_charts(),"undefined"!=typeof vc_pieChart&&vc_pieChart(),"undefined"!=typeof vc_line_charts&&vc_line_charts(),window.vc_js()):void 0}))},,,,,,,,,,,,function(e,t,n){"use strict";n.r(t),n.d(t,"init",(function(){return g}));var r=n(2),o=n(8),i=jQuery,l=n(9);n(11);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return d(this,n)}}function d(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}jQuery;var m=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r,o=f(i);function i(){return u(this,i),o.apply(this,arguments)}return t=i,(n=[{key:"checkCourseDurationExpire",value:function(){var e=document.getElementsByName("lp-course-timestamp-remaining");if(e.length){var t=e[0].value;t<86400&&setTimeout((function(){window.location.reload(!0)}),1e3*t)}}},{key:"render",value:function(){return React.createElement("div",null)}}])&&a(t.prototype,n),r&&a(t,r),i}(r.Component),y=m;document.addEventListener("DOMContentLoaded",(function(){LP.Hook.doAction("lp-compatible-builder"),function(){var e=document.querySelector("#popup-course"),t=document.querySelector("#learn-press-course-curriculum");if(e&&t){var n=t.querySelector(".curriculum-sections"),r=e.querySelector(".search-course"),o=e.querySelector('.search-course input[type="text"]');if(!o||!n||!r)return;var i=n.querySelectorAll("li.section"),l=n.querySelectorAll("li.course-item"),c=[];l.forEach((function(e){var t=e.dataset.id,n=e.querySelector(".item-name");c.push({id:t,name:n?n.textContent.toLowerCase():""})}));var u=function(e){e.preventDefault();var t=o.value;r.classList.add("searching"),t||r.classList.remove("searching");var n=[];c.forEach((function(e){t&&!e.name.match(t.toLowerCase())||(n.push(e.id),l.forEach((function(e){-1!==n.indexOf(e.dataset.id)?e.classList.remove("hide-if-js"):e.classList.add("hide-if-js")})))})),i.forEach((function(e){var t=e.querySelectorAll(".course-item"),r=[];t.forEach((function(e){n.includes(e.dataset.id)&&r.push(e.dataset.id)})),0===r.length?e.classList.add("hide-if-js"):e.classList.remove("hide-if-js")}))},a=r.querySelector(".clear");a&&a.addEventListener("click",(function(e){e.preventDefault(),o.value="",u(e)})),r.addEventListener("submit",u),o.addEventListener("keyup",u)}}(),Object(o.a)(),i(".learn-press-progress").each((function(){var e=i(this).find(".learn-press-progress__active"),t=e.data("value");void 0!==t&&e.css("left",-(100-parseInt(t))+"%")})),Object(l.b)(),(new m).checkCourseDurationExpire()}));var v=n(6),h=(n(3),jQuery),b={init:function(){this.scrollToItemViewing=function(){var e=h(".viewing-course-item");if(e.length){var t=h("#learn-press-course-curriculum"),n=(h("#popup-sidebar").outerHeight(),h(".section-title").outerHeight(),h(".section-header").outerHeight()),r=new RegExp("^viewing-course-item-([0-9].*)"),o=e.attr("class").split(/\s+/),i=0;if(h.each(o,(function(e,t){var n=r.exec(t);if(n)return i=n[1],!1})),0===i)return;var l=h(".course-item-"+i),c=(l.offset().top,l.offset().top-t.offset().top+t.scrollTop());t.animate({scrollTop:c-n},800)}},this.scrollToItemViewing()}},g=(jQuery,t.default=y,function(){wp.element.render(React.createElement(y,null),document.getElementById("learn-press-course-curriculum"))});document.addEventListener("DOMContentLoaded",(function(e){LP.Hook.doAction("course-ready"),v.a.init(),b.init()}))}]);
|
assets/src/apps/js/frontend/profile.js
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import courseTab from './profile/course-tab';
|
2 |
+
import courseStatistics from './profile/statistic';
|
3 |
+
|
4 |
+
document.addEventListener( 'DOMContentLoaded', function( event ) {
|
5 |
+
courseTab();
|
6 |
+
courseStatistics();
|
7 |
+
} );
|
assets/src/apps/js/frontend/profile/course-tab.js
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { addQueryArgs } from '@wordpress/url';
|
2 |
+
|
3 |
+
// Rest API load content course enrolled, created - Nhamdv.
|
4 |
+
const courseTab = () => {
|
5 |
+
const elements = document.querySelectorAll( '.learn-press-course-tab__filter__content' );
|
6 |
+
|
7 |
+
if ( ! elements.length ) {
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
|
11 |
+
if ( 'IntersectionObserver' in window ) {
|
12 |
+
const eleObserver = new IntersectionObserver( ( entries, observer ) => {
|
13 |
+
entries.forEach( ( entry ) => {
|
14 |
+
if ( entry.isIntersecting ) {
|
15 |
+
const ele = entry.target;
|
16 |
+
const data = JSON.parse( ele.dataset.ajax );
|
17 |
+
|
18 |
+
getResponse( ele, data );
|
19 |
+
|
20 |
+
eleObserver.unobserve( ele );
|
21 |
+
}
|
22 |
+
} );
|
23 |
+
} );
|
24 |
+
|
25 |
+
[ ...elements ].map( ( ele ) => eleObserver.observe( ele ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
const changeFilter = () => {
|
29 |
+
const tabs = document.querySelectorAll( '.learn-press-course-tab-filters' );
|
30 |
+
|
31 |
+
tabs.forEach( ( tab ) => {
|
32 |
+
const filters = tab.querySelectorAll( '.learn-press-filters a' );
|
33 |
+
|
34 |
+
filters.forEach( ( filter ) => {
|
35 |
+
filter.addEventListener( 'click', ( e ) => {
|
36 |
+
e.preventDefault();
|
37 |
+
|
38 |
+
const tabName = filter.dataset.tab;
|
39 |
+
|
40 |
+
[ ...filters ].map( ( ele ) => {
|
41 |
+
ele.classList.remove( 'active' );
|
42 |
+
} );
|
43 |
+
|
44 |
+
filter.classList.add( 'active' );
|
45 |
+
|
46 |
+
[ ...tab.querySelectorAll( '.learn-press-course-tab__filter__content' ) ].map( ( ele ) => {
|
47 |
+
ele.style.display = 'none';
|
48 |
+
|
49 |
+
if ( ele.dataset.tab === tabName ) {
|
50 |
+
ele.style.display = '';
|
51 |
+
}
|
52 |
+
} );
|
53 |
+
} );
|
54 |
+
} );
|
55 |
+
} );
|
56 |
+
};
|
57 |
+
|
58 |
+
changeFilter();
|
59 |
+
|
60 |
+
const changeTab = () => {
|
61 |
+
const tabUls = document.querySelectorAll( '.learn-press-profile-course__tab__inner' );
|
62 |
+
|
63 |
+
tabUls.forEach( ( tabUl ) => {
|
64 |
+
const tabs = tabUl.querySelectorAll( 'li> a' );
|
65 |
+
|
66 |
+
tabs.forEach( ( tab ) => {
|
67 |
+
tab.addEventListener( 'click', ( e ) => {
|
68 |
+
e.preventDefault();
|
69 |
+
|
70 |
+
const tabName = tab.dataset.tab;
|
71 |
+
|
72 |
+
[ ...tabs ].map( ( ele ) => {
|
73 |
+
ele.classList.remove( 'active' );
|
74 |
+
} );
|
75 |
+
|
76 |
+
tab.classList.add( 'active' );
|
77 |
+
|
78 |
+
[ ...document.querySelectorAll( '.learn-press-course-tab-filters' ) ].map( ( ele ) => {
|
79 |
+
ele.style.display = 'none';
|
80 |
+
|
81 |
+
if ( ele.dataset.tab === tabName ) {
|
82 |
+
ele.style.display = '';
|
83 |
+
}
|
84 |
+
} );
|
85 |
+
} );
|
86 |
+
} );
|
87 |
+
} );
|
88 |
+
};
|
89 |
+
changeTab();
|
90 |
+
|
91 |
+
const getResponse = async ( ele, dataset, append = false, viewMoreEle = false ) => {
|
92 |
+
try {
|
93 |
+
const response = await wp.apiFetch( {
|
94 |
+
path: addQueryArgs( 'lp/v1/profile/course-tab', dataset ),
|
95 |
+
method: 'GET',
|
96 |
+
} );
|
97 |
+
|
98 |
+
if ( response ) {
|
99 |
+
const skeleton = ele.querySelector( '.lp-skeleton-animation' );
|
100 |
+
skeleton && skeleton.remove();
|
101 |
+
|
102 |
+
if ( response.status === 'success' && response.data ) {
|
103 |
+
if ( append ) {
|
104 |
+
ele.innerHTML += response.data;
|
105 |
+
} else {
|
106 |
+
ele.innerHTML = response.data;
|
107 |
+
}
|
108 |
+
} else if ( append ) {
|
109 |
+
ele.innerHTML += `<div class="lp-ajax-message" style="display:block">${ response.message && response.message }</div>`;
|
110 |
+
} else {
|
111 |
+
ele.innerHTML = `<div class="lp-ajax-message" style="display:block">${ response.message && response.message }</div>`;
|
112 |
+
}
|
113 |
+
|
114 |
+
if ( viewMoreEle ) {
|
115 |
+
viewMoreEle.classList.remove( 'loading' );
|
116 |
+
|
117 |
+
const paged = viewMoreEle.dataset.paged;
|
118 |
+
const numberPage = viewMoreEle.dataset.number;
|
119 |
+
|
120 |
+
if ( numberPage <= paged ) {
|
121 |
+
viewMoreEle.remove();
|
122 |
+
}
|
123 |
+
|
124 |
+
viewMoreEle.dataset.paged = parseInt( paged ) + 1;
|
125 |
+
}
|
126 |
+
|
127 |
+
viewMore( ele, dataset );
|
128 |
+
}
|
129 |
+
} catch ( error ) {
|
130 |
+
if ( append ) {
|
131 |
+
ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message && error.message }</div>`;
|
132 |
+
} else {
|
133 |
+
ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${ error.message && error.message }</div>`;
|
134 |
+
}
|
135 |
+
|
136 |
+
if ( viewMoreEle ) {
|
137 |
+
viewMoreEle.classList.remove( 'loading' );
|
138 |
+
|
139 |
+
const paged = viewMoreEle.dataset.paged;
|
140 |
+
const numberPage = viewMoreEle.dataset.number;
|
141 |
+
|
142 |
+
if ( numberPage <= paged ) {
|
143 |
+
viewMoreEle.remove();
|
144 |
+
}
|
145 |
+
|
146 |
+
viewMoreEle.dataset.paged = parseInt( paged ) + 1;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
};
|
150 |
+
|
151 |
+
const viewMore = ( ele, dataset ) => {
|
152 |
+
const viewMoreEle = ele.querySelector( 'button[data-paged]' );
|
153 |
+
|
154 |
+
if ( viewMoreEle ) {
|
155 |
+
viewMoreEle.addEventListener( 'click', ( e ) => {
|
156 |
+
e.preventDefault();
|
157 |
+
|
158 |
+
const paged = viewMoreEle && viewMoreEle.dataset.paged;
|
159 |
+
|
160 |
+
viewMoreEle.classList.add( 'loading' );
|
161 |
+
|
162 |
+
const element = dataset.layout === 'list' ? '.lp_profile_course_progress' : '.learn-press-courses';
|
163 |
+
|
164 |
+
getResponse( ele.querySelector( element ), { ...dataset, ...{ paged } }, true, viewMoreEle );
|
165 |
+
} );
|
166 |
+
}
|
167 |
+
};
|
168 |
+
};
|
169 |
+
export default courseTab;
|
assets/src/apps/js/frontend/profile/statistic.js
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { addQueryArgs } from '@wordpress/url';
|
2 |
+
|
3 |
+
// Rest API load content course progress - Nhamdv.
|
4 |
+
const courseStatistics = () => {
|
5 |
+
const elements = document.querySelectorAll( '.learn-press-profile-course__statistic' );
|
6 |
+
|
7 |
+
if ( ! elements.length ) {
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
|
11 |
+
if ( 'IntersectionObserver' in window ) {
|
12 |
+
const eleObserver = new IntersectionObserver( ( entries, observer ) => {
|
13 |
+
entries.forEach( ( entry ) => {
|
14 |
+
if ( entry.isIntersecting ) {
|
15 |
+
const ele = entry.target;
|
16 |
+
const data = JSON.parse( ele.dataset.ajax );
|
17 |
+
|
18 |
+
getResponse( ele, data );
|
19 |
+
|
20 |
+
eleObserver.unobserve( ele );
|
21 |
+
}
|
22 |
+
} );
|
23 |
+
} );
|
24 |
+
|
25 |
+
[ ...elements ].map( ( ele ) => eleObserver.observe( ele ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
const getResponse = async ( ele, dataset ) => {
|
29 |
+
try {
|
30 |
+
const response = await wp.apiFetch( {
|
31 |
+
path: addQueryArgs( 'lp/v1/profile/statistic', dataset ),
|
32 |
+
method: 'GET',
|
33 |
+
} );
|
34 |
+
|
35 |
+
if ( response.status === 'success' && response.data ) {
|
36 |
+
ele.innerHTML += response.data;
|
37 |
+
} else {
|
38 |
+
ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ response.message && response.message }</div>`;
|
39 |
+
}
|
40 |
+
} catch ( error ) {
|
41 |
+
ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ error.message && error.message }</div>`;
|
42 |
+
}
|
43 |
+
};
|
44 |
+
};
|
45 |
+
export default courseStatistics;
|
assets/src/apps/js/frontend/quiz/components/buttons/index.js
CHANGED
@@ -244,12 +244,15 @@ class Buttons extends Component {
|
|
244 |
} else {
|
245 |
styles = null;
|
246 |
}
|
247 |
-
|
|
|
|
|
|
|
248 |
return (
|
249 |
<>
|
250 |
<div className={ classNames.join( ' ' ) }>
|
251 |
<div
|
252 |
-
className={ `button-left` + ( ( status === 'started' || isReviewing ) ?
|
253 |
style={ styles }
|
254 |
>
|
255 |
|
244 |
} else {
|
245 |
styles = null;
|
246 |
}
|
247 |
+
let navPositionClass = ' fixed';
|
248 |
+
if ( lpQuizSettings.navigationPosition == 'no' ) {
|
249 |
+
navPositionClass = ' nav-center';
|
250 |
+
}
|
251 |
return (
|
252 |
<>
|
253 |
<div className={ classNames.join( ' ' ) }>
|
254 |
<div
|
255 |
+
className={ `button-left` + ( ( status === 'started' || isReviewing ) ? navPositionClass : '' ) }
|
256 |
style={ styles }
|
257 |
>
|
258 |
|
inc/admin/class-lp-admin-menu.php
CHANGED
@@ -82,9 +82,10 @@ class LP_Admin_Menu {
|
|
82 |
* Register for menu for admin
|
83 |
*/
|
84 |
public function admin_menu() {
|
|
|
85 |
add_menu_page(
|
86 |
__( 'Learning Management System', 'learnpress' ),
|
87 |
-
|
88 |
$this->get_capability(),
|
89 |
'learn_press',
|
90 |
'',
|
82 |
* Register for menu for admin
|
83 |
*/
|
84 |
public function admin_menu() {
|
85 |
+
// Not for translate menu_title, because it make compare $current_screen with "learnpress_page_.*" wrong
|
86 |
add_menu_page(
|
87 |
__( 'Learning Management System', 'learnpress' ),
|
88 |
+
'LearnPress',
|
89 |
$this->get_capability(),
|
90 |
'learn_press',
|
91 |
'',
|
inc/admin/settings/class-lp-settings-advanced.php
CHANGED
@@ -106,6 +106,13 @@ class LP_Settings_Advanced extends LP_Abstract_Settings_Page {
|
|
106 |
'type' => 'checkbox',
|
107 |
'desc' => sprintf( __( 'Enable cache for static content such as content and settings of course, lesson, quiz. <a href="%1$s">%2$s</a>', 'learnpress' ), admin_url( 'admin.php?page=learn-press-tools&tab=cache' ), esc_html__( 'Advanced', 'learnpress' ) ),
|
108 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
array(
|
110 |
'type' => 'sectionend',
|
111 |
'id' => 'lp_metabox_advanced_other',
|
106 |
'type' => 'checkbox',
|
107 |
'desc' => sprintf( __( 'Enable cache for static content such as content and settings of course, lesson, quiz. <a href="%1$s">%2$s</a>', 'learnpress' ), admin_url( 'admin.php?page=learn-press-tools&tab=cache' ), esc_html__( 'Advanced', 'learnpress' ) ),
|
108 |
),
|
109 |
+
array(
|
110 |
+
'title' => esc_html__( 'Enable', 'learnpress' ),
|
111 |
+
'id' => 'navigation_position',
|
112 |
+
'default' => 'yes',
|
113 |
+
'type' => 'checkbox',
|
114 |
+
'desc' => esc_html__( 'Question navigation position is sticky, if not right below the quiz content', 'learnpress' ),
|
115 |
+
),
|
116 |
array(
|
117 |
'type' => 'sectionend',
|
118 |
'id' => 'lp_metabox_advanced_other',
|
inc/admin/settings/class-lp-settings-profile.php
CHANGED
@@ -146,14 +146,6 @@ class LP_Settings_Profile extends LP_Abstract_Settings_Page {
|
|
146 |
'type' => 'title',
|
147 |
'id' => 'lp_profile_permalinks',
|
148 |
),
|
149 |
-
array(
|
150 |
-
'title' => esc_html__( 'Overview', 'learnpress' ),
|
151 |
-
'id' => 'profile_endpoints[overview]',
|
152 |
-
'type' => 'text',
|
153 |
-
'default' => 'overview',
|
154 |
-
'placeholder' => 'overview',
|
155 |
-
'desc' => sprintf( 'e.g. %s', "{$profile_url}/<code>" . $settings->get( 'profile_endpoints.dashboard', 'overview' ) . '</code>' ),
|
156 |
-
),
|
157 |
array(
|
158 |
'title' => esc_html__( 'Courses', 'learnpress' ),
|
159 |
'id' => 'profile_endpoints[courses]',
|
146 |
'type' => 'title',
|
147 |
'id' => 'lp_profile_permalinks',
|
148 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
array(
|
150 |
'title' => esc_html__( 'Courses', 'learnpress' ),
|
151 |
'id' => 'profile_endpoints[courses]',
|
inc/class-lp-assets.php
CHANGED
@@ -162,7 +162,7 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
162 |
'lp-modal',
|
163 |
'lp-config',
|
164 |
'lp-single-curriculum',
|
165 |
-
'jquery-ui-sortable', //Use in question type: sorting choice - Nhamdv
|
166 |
|
167 |
)
|
168 |
),
|
@@ -205,6 +205,16 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
205 |
0,
|
206 |
1
|
207 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
'lp-become-a-teacher' => new LP_Asset_Key(
|
209 |
self::url( self::$_folder_source . 'js/frontend/become-teacher' . self::$_min_assets . '.js' ),
|
210 |
array( 'jquery', 'lp-utils' ),
|
@@ -288,8 +298,12 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
288 |
$can_load_js = true;
|
289 |
|
290 |
if ( ! empty( $script->_screens ) ) {
|
291 |
-
$can_load_js = apply_filters(
|
292 |
-
|
|
|
|
|
|
|
|
|
293 |
}
|
294 |
|
295 |
if ( $can_load_js ) {
|
@@ -392,8 +406,10 @@ class LP_Assets extends LP_Abstract_Assets {
|
|
392 |
*/
|
393 |
public function show_overlay() {
|
394 |
$page_current = LP_Page_Controller::page_current();
|
395 |
-
if ( ! in_array(
|
396 |
-
|
|
|
|
|
397 |
return;
|
398 |
}
|
399 |
|
162 |
'lp-modal',
|
163 |
'lp-config',
|
164 |
'lp-single-curriculum',
|
165 |
+
'jquery-ui-sortable', // Use in question type: sorting choice - Nhamdv
|
166 |
|
167 |
)
|
168 |
),
|
205 |
0,
|
206 |
1
|
207 |
),
|
208 |
+
'lp-profile-v2' => new LP_Asset_Key(
|
209 |
+
self::url( 'js/dist/frontend/profile' . self::$_min_assets . '.js' ),
|
210 |
+
array_merge(
|
211 |
+
$wp_js,
|
212 |
+
array( 'wp-i18n' )
|
213 |
+
),
|
214 |
+
array( LP_PAGE_PROFILE ),
|
215 |
+
0,
|
216 |
+
1
|
217 |
+
),
|
218 |
'lp-become-a-teacher' => new LP_Asset_Key(
|
219 |
self::url( self::$_folder_source . 'js/frontend/become-teacher' . self::$_min_assets . '.js' ),
|
220 |
array( 'jquery', 'lp-utils' ),
|
298 |
$can_load_js = true;
|
299 |
|
300 |
if ( ! empty( $script->_screens ) ) {
|
301 |
+
$can_load_js = apply_filters(
|
302 |
+
'learnpress/frontend/can-load-js/' . $handle,
|
303 |
+
in_array( $page_current, $script->_screens ),
|
304 |
+
$page_current,
|
305 |
+
$script->_screens
|
306 |
+
);
|
307 |
}
|
308 |
|
309 |
if ( $can_load_js ) {
|
406 |
*/
|
407 |
public function show_overlay() {
|
408 |
$page_current = LP_Page_Controller::page_current();
|
409 |
+
if ( ! in_array(
|
410 |
+
$page_current,
|
411 |
+
array( LP_PAGE_SINGLE_COURSE_CURRICULUM, LP_PAGE_SINGLE_COURSE, LP_PAGE_QUIZ )
|
412 |
+
) ) {
|
413 |
return;
|
414 |
}
|
415 |
|
inc/curds/class-lp-course-curd.php
CHANGED
@@ -522,7 +522,7 @@ if ( ! class_exists( 'LP_Course_CURD' ) ) {
|
|
522 |
* @since 3.0.0
|
523 |
*/
|
524 |
public function remove_item( $item_id, $course_id = 0 ) {
|
525 |
-
|
526 |
global $wpdb;
|
527 |
// allow hook
|
528 |
do_action( 'learn-press/before-remove-section-item', $item_id, $course_id );
|
@@ -568,7 +568,8 @@ if ( ! class_exists( 'LP_Course_CURD' ) ) {
|
|
568 |
|
569 |
foreach ( $course_id as $cid ) {
|
570 |
do_action( 'learn-press/removed-item-from-section', $item_id, $cid );
|
571 |
-
|
|
|
572 |
}
|
573 |
|
574 |
learn_press_reset_auto_increment( 'learnpress_section_items' );
|
522 |
* @since 3.0.0
|
523 |
*/
|
524 |
public function remove_item( $item_id, $course_id = 0 ) {
|
525 |
+
$learnpress_user_item_db = LP_User_Items_DB::getInstance();
|
526 |
global $wpdb;
|
527 |
// allow hook
|
528 |
do_action( 'learn-press/before-remove-section-item', $item_id, $course_id );
|
568 |
|
569 |
foreach ( $course_id as $cid ) {
|
570 |
do_action( 'learn-press/removed-item-from-section', $item_id, $cid );
|
571 |
+
$learnpress_user_item_db->reset_course_current_item( $cid, $item_id );
|
572 |
+
} // end foreach $course_id as $cid
|
573 |
}
|
574 |
|
575 |
learn_press_reset_auto_increment( 'learnpress_section_items' );
|
inc/curds/class-lp-question-curd.php
CHANGED
@@ -210,7 +210,7 @@ if ( ! class_exists( 'LP_Question_CURD' ) ) {
|
|
210 |
'is_true' => ! empty( $option->is_true ) ? $option->is_true : '',
|
211 |
'order' => $option->order,
|
212 |
),
|
213 |
-
array( '%d', '%s', '%s' )
|
214 |
);
|
215 |
}
|
216 |
}
|
210 |
'is_true' => ! empty( $option->is_true ) ? $option->is_true : '',
|
211 |
'order' => $option->order,
|
212 |
),
|
213 |
+
array( '%d', '%s', '%s', '%s', '%s' )
|
214 |
);
|
215 |
}
|
216 |
}
|
inc/curds/class-lp-user-curd.php
CHANGED
@@ -1466,6 +1466,7 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1466 |
SELECT SQL_CALC_FOUND_ROWS ID
|
1467 |
FROM {$wpdb->posts} c
|
1468 |
{$where}
|
|
|
1469 |
LIMIT {$offset}, {$limit}
|
1470 |
";
|
1471 |
|
@@ -1637,6 +1638,17 @@ class LP_User_CURD extends LP_Object_Data_CURD implements LP_Interface_CURD {
|
|
1637 |
}
|
1638 |
}
|
1639 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1640 |
break;
|
1641 |
case 'not-enrolled':
|
1642 |
$where .= $wpdb->prepare(
|
1466 |
SELECT SQL_CALC_FOUND_ROWS ID
|
1467 |
FROM {$wpdb->posts} c
|
1468 |
{$where}
|
1469 |
+
ORDER BY ID DESC
|
1470 |
LIMIT {$offset}, {$limit}
|
1471 |
";
|
1472 |
|
1638 |
}
|
1639 |
}
|
1640 |
|
1641 |
+
break;
|
1642 |
+
case 'in-progress':
|
1643 |
+
$where .= $wpdb->prepare(
|
1644 |
+
' AND ui.status IN( %s )',
|
1645 |
+
array(
|
1646 |
+
'enrolled',
|
1647 |
+
)
|
1648 |
+
);
|
1649 |
+
|
1650 |
+
$having .= $wpdb->prepare( ' AND ui.graduation = %s', 'in-progress' );
|
1651 |
+
|
1652 |
break;
|
1653 |
case 'not-enrolled':
|
1654 |
$where .= $wpdb->prepare(
|
inc/databases/class-lp-course-db.php
CHANGED
@@ -101,9 +101,8 @@ class LP_Course_DB extends LP_Database {
|
|
101 |
ON items.section_id = sections.section_id
|
102 |
AND sections.section_course_id = %d
|
103 |
",
|
104 |
-
$course_id
|
105 |
);
|
106 |
-
|
107 |
$first_item_id = (int) $this->wpdb->get_var( $query );
|
108 |
|
109 |
// Set cache
|
101 |
ON items.section_id = sections.section_id
|
102 |
AND sections.section_course_id = %d
|
103 |
",
|
104 |
+
$course_id,0
|
105 |
);
|
|
|
106 |
$first_item_id = (int) $this->wpdb->get_var( $query );
|
107 |
|
108 |
// Set cache
|
inc/databases/class-lp-user-items-db.php
CHANGED
@@ -186,6 +186,44 @@ class LP_User_Items_DB extends LP_Database {
|
|
186 |
)
|
187 |
);
|
188 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
LP_Course_DB::getInstance();
|
186 |
)
|
187 |
);
|
188 |
}
|
189 |
+
/**
|
190 |
+
* Re-set current item
|
191 |
+
* @param $course_id
|
192 |
+
* @param $item_id
|
193 |
+
* @editor hungkv
|
194 |
+
*/
|
195 |
+
function reset_course_current_item( $course_id, $item_id ) {
|
196 |
+
// Select all course enrolled
|
197 |
+
$query = $this->wpdb->prepare(
|
198 |
+
"
|
199 |
+
SELECT user_item_id
|
200 |
+
FROM {$this->wpdb->prefix}learnpress_user_items
|
201 |
+
WHERE status = %s AND item_id = %d AND graduation = %s
|
202 |
+
",
|
203 |
+
'enrolled', $course_id, 'in-progress'
|
204 |
+
);
|
205 |
+
$user_item_ids = $this->wpdb->get_col( $query );
|
206 |
+
if ( ! empty( $user_item_ids ) ) {
|
207 |
+
foreach ( $user_item_ids as $user_item_id ) {
|
208 |
+
// Check item is current item of all course
|
209 |
+
$query = $this->wpdb->prepare(
|
210 |
+
"
|
211 |
+
SELECT meta_value
|
212 |
+
FROM {$this->wpdb->prefix}learnpress_user_itemmeta
|
213 |
+
WHERE learnpress_user_item_id = %d
|
214 |
+
",
|
215 |
+
$user_item_id
|
216 |
+
);
|
217 |
+
$meta_value_id = $this->wpdb->get_var( $query );
|
218 |
+
// Check if the deleted item is current item or not
|
219 |
+
if ( $meta_value_id == $item_id ) {
|
220 |
+
$course = learn_press_get_course( $course_id );
|
221 |
+
// update _curent_item to database
|
222 |
+
learn_press_update_user_item_meta( $user_item_id, '_current_item', $course->get_first_item_id() );
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
}
|
228 |
|
229 |
LP_Course_DB::getInstance();
|
inc/jwt/class-jwt-auth.php
CHANGED
@@ -38,6 +38,7 @@ class LP_Jwt_Auth {
|
|
38 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php';
|
39 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php';
|
40 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php';
|
|
|
41 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php';
|
42 |
|
43 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/lp-rest-function.php';
|
38 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-courses-v1-controller.php';
|
39 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-lessons-v1-controller.php';
|
40 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-quiz-v1-controller.php';
|
41 |
+
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-questions-v1-controller.php';
|
42 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php';
|
43 |
|
44 |
require_once LP_PLUGIN_PATH . 'inc/jwt/rest-api/lp-rest-function.php';
|
inc/jwt/responsive.http
CHANGED
@@ -6,10 +6,19 @@ Content-Type: application/json
|
|
6 |
"password": "admin"
|
7 |
}
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
###
|
10 |
POST http://learnpress4.local/wp-json/learnpress/v1/token/validate
|
11 |
Content-Type: application/json
|
12 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
13 |
|
14 |
###
|
15 |
GET http://learnpress4.local/wp-json/learnpress/v1/test
|
@@ -22,22 +31,27 @@ Content-Type: application/json
|
|
22 |
###
|
23 |
GET http://learnpress4.local/wp-json/learnpress/v1/courses
|
24 |
Content-Type: application/json
|
25 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
26 |
|
27 |
###
|
28 |
-
GET http://learnpress4.local/wp-json/learnpress/v1/courses/
|
29 |
Content-Type: application/json
|
30 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
31 |
|
32 |
###
|
33 |
GET http://learnpress4.local/wp-json/learnpress/v1/lessons
|
34 |
Content-Type: application/json
|
35 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
36 |
|
37 |
###
|
38 |
GET http://learnpress4.local/wp-json/learnpress/v1/quiz?per_page=2
|
39 |
Content-Type: application/json
|
40 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
|
43 |
###
|
@@ -45,16 +59,41 @@ GET http://learnpress4.local/wp-json/wp/v2/users
|
|
45 |
Content-Type: application/json
|
46 |
|
47 |
###
|
48 |
-
GET http://learnpress4.local/wp-json/learnpress/v1/users
|
49 |
Content-Type: application/json
|
50 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
51 |
|
52 |
###
|
53 |
GET http://learnpress4.local/wp-json/learnpress/v1/users/1
|
54 |
Content-Type: application/json
|
55 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
###
|
58 |
-
|
59 |
Content-Type: application/json
|
60 |
-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
"password": "admin"
|
7 |
}
|
8 |
|
9 |
+
###
|
10 |
+
POST http://learnpress4.local/wp-json/learnpress/v1/token
|
11 |
+
Content-Type: application/json
|
12 |
+
|
13 |
+
{
|
14 |
+
"username": "student",
|
15 |
+
"password": "student"
|
16 |
+
}
|
17 |
+
|
18 |
###
|
19 |
POST http://learnpress4.local/wp-json/learnpress/v1/token/validate
|
20 |
Content-Type: application/json
|
21 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
22 |
|
23 |
###
|
24 |
GET http://learnpress4.local/wp-json/learnpress/v1/test
|
31 |
###
|
32 |
GET http://learnpress4.local/wp-json/learnpress/v1/courses
|
33 |
Content-Type: application/json
|
34 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
35 |
|
36 |
###
|
37 |
+
GET http://learnpress4.local/wp-json/learnpress/v1/courses/529?course_data=true
|
38 |
Content-Type: application/json
|
39 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
40 |
|
41 |
###
|
42 |
GET http://learnpress4.local/wp-json/learnpress/v1/lessons
|
43 |
Content-Type: application/json
|
44 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
45 |
|
46 |
###
|
47 |
GET http://learnpress4.local/wp-json/learnpress/v1/quiz?per_page=2
|
48 |
Content-Type: application/json
|
49 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
50 |
+
|
51 |
+
###
|
52 |
+
GET http://learnpress4.local/wp-json/learnpress/v1/questions
|
53 |
+
Content-Type: application/json
|
54 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
55 |
|
56 |
|
57 |
###
|
59 |
Content-Type: application/json
|
60 |
|
61 |
###
|
62 |
+
GET http://learnpress4.local/wp-json/learnpress/v1/users/?per_page=2
|
63 |
Content-Type: application/json
|
64 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
65 |
|
66 |
###
|
67 |
GET http://learnpress4.local/wp-json/learnpress/v1/users/1
|
68 |
Content-Type: application/json
|
69 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
70 |
+
|
71 |
+
###
|
72 |
+
POST http://learnpress4.local/wp-json/learnpress/v1/users/1/
|
73 |
+
Content-Type: application/json
|
74 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzY2NTU5NSwibmJmIjoxNjIzNjY1NTk1LCJleHAiOjE2MjQyNzAzOTUsImRhdGEiOnsidXNlciI6eyJpZCI6IjEifX19.5tsZ-uQRzt_9eNauqXz3IoYqLSTIrWS-C8dQJ1v1mw0
|
75 |
+
|
76 |
+
{
|
77 |
+
"first_name": "dao",
|
78 |
+
"last_name": "nham",
|
79 |
+
"email": "daonham95@gmail.com",
|
80 |
+
"password": "admin"
|
81 |
+
}
|
82 |
+
|
83 |
+
###
|
84 |
+
GET http://learnpress4.local/wp-json/learnpress/v1/users/2
|
85 |
+
Content-Type: application/json
|
86 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzI5MTgzNiwibmJmIjoxNjIzMjkxODM2LCJleHAiOjE2MjM4OTY2MzYsImRhdGEiOnsidXNlciI6eyJpZCI6IjIifX19.Ls7Q3EiFE5ZHn78Exe6CdnfZJ2JZaPcuJBI0wQHdvzk
|
87 |
|
88 |
###
|
89 |
+
POST http://learnpress4.local/wp-json/learnpress/v1/users/2
|
90 |
Content-Type: application/json
|
91 |
+
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9sZWFybnByZXNzNC5sb2NhbCIsImlhdCI6MTYyMzI5MTgzNiwibmJmIjoxNjIzMjkxODM2LCJleHAiOjE2MjM4OTY2MzYsImRhdGEiOnsidXNlciI6eyJpZCI6IjIifX19.Ls7Q3EiFE5ZHn78Exe6CdnfZJ2JZaPcuJBI0wQHdvzk
|
92 |
+
|
93 |
+
{
|
94 |
+
"first_name": "dao",
|
95 |
+
"last_name": "nham",
|
96 |
+
"email": "studentsss@gmail.com",
|
97 |
+
"password": "student"
|
98 |
+
}
|
99 |
+
|
inc/jwt/rest-api/class-rest-api.php
CHANGED
@@ -35,10 +35,11 @@ class LP_Jwt_RestApi {
|
|
35 |
|
36 |
protected function get_v1_controllers() {
|
37 |
return array(
|
38 |
-
'courses'
|
39 |
-
'lessons'
|
40 |
-
'quiz'
|
41 |
-
'
|
|
|
42 |
);
|
43 |
}
|
44 |
|
35 |
|
36 |
protected function get_v1_controllers() {
|
37 |
return array(
|
38 |
+
'courses' => 'LP_Jwt_Courses_V1_Controller',
|
39 |
+
'lessons' => 'LP_Jwt_Lessons_V1_Controller',
|
40 |
+
'quiz' => 'LP_Jwt_Quiz_V1_Controller',
|
41 |
+
'questions' => 'LP_Jwt_Questions_V1_Controller',
|
42 |
+
'users' => 'LP_Jwt_Users_V1_Controller',
|
43 |
);
|
44 |
}
|
45 |
|
inc/jwt/rest-api/version1/class-lp-rest-posts-controller.php
CHANGED
@@ -192,23 +192,6 @@ abstract class LP_REST_Jwt_Posts_Controller extends LP_REST_Jwt_Controller {
|
|
192 |
return $query_args;
|
193 |
}
|
194 |
|
195 |
-
public function get_all_meta_by_id( $id ) {
|
196 |
-
$meta = get_post_meta( $id );
|
197 |
-
|
198 |
-
$output = array();
|
199 |
-
if ( ! empty( $meta ) ) {
|
200 |
-
foreach ( $meta as $meta_key => $meta_value ) {
|
201 |
-
if ( count( $meta_value ) == 1 ) {
|
202 |
-
$output[ $meta_key ] = maybe_unserialize( $meta_value[0] );
|
203 |
-
} else {
|
204 |
-
$output[ $meta_key ] = array_map( 'maybe_unserialize', array_values( $meta_value ) );
|
205 |
-
}
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
return $output;
|
210 |
-
}
|
211 |
-
|
212 |
public function get_collection_params() {
|
213 |
$params = array();
|
214 |
$params['context'] = $this->get_context_param();
|
192 |
return $query_args;
|
193 |
}
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
public function get_collection_params() {
|
196 |
$params = array();
|
197 |
$params['context'] = $this->get_context_param();
|
inc/jwt/rest-api/version1/class-lp-rest-questions-v1-controller.php
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LP_Jwt_Questions_V1_Controller extends LP_REST_Jwt_Posts_Controller {
|
3 |
+
protected $namespace = 'learnpress/v1';
|
4 |
+
|
5 |
+
protected $rest_base = 'questions';
|
6 |
+
|
7 |
+
protected $post_type = LP_QUESTION_CPT;
|
8 |
+
|
9 |
+
protected $hierarchical = true;
|
10 |
+
|
11 |
+
public function register_routes() {
|
12 |
+
register_rest_route(
|
13 |
+
$this->namespace,
|
14 |
+
'/' . $this->rest_base,
|
15 |
+
array(
|
16 |
+
array(
|
17 |
+
'methods' => WP_REST_Server::READABLE,
|
18 |
+
'callback' => array( $this, 'get_items' ),
|
19 |
+
'permission_callback' => array( $this, 'get_items_permissions_check' ),
|
20 |
+
'args' => $this->get_collection_params(),
|
21 |
+
),
|
22 |
+
'schema' => array( $this, 'get_public_item_schema' ),
|
23 |
+
)
|
24 |
+
);
|
25 |
+
|
26 |
+
register_rest_route(
|
27 |
+
$this->namespace,
|
28 |
+
'/' . $this->rest_base . '/(?P<id>[\d]+)',
|
29 |
+
array(
|
30 |
+
'args' => array(
|
31 |
+
'id' => array(
|
32 |
+
'description' => esc_html__( 'Unique identifier for the resource.', 'learnpress' ),
|
33 |
+
'type' => 'integer',
|
34 |
+
),
|
35 |
+
),
|
36 |
+
array(
|
37 |
+
'methods' => WP_REST_Server::READABLE,
|
38 |
+
'callback' => array( $this, 'get_item' ),
|
39 |
+
'permission_callback' => array( $this, 'get_item_permissions_check' ),
|
40 |
+
'args' => array(
|
41 |
+
'context' => $this->get_context_param(
|
42 |
+
array(
|
43 |
+
'default' => 'view',
|
44 |
+
)
|
45 |
+
),
|
46 |
+
),
|
47 |
+
),
|
48 |
+
'schema' => array( $this, 'get_public_item_schema' ),
|
49 |
+
)
|
50 |
+
);
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function get_object( $question = 0 ) {
|
54 |
+
global $post;
|
55 |
+
|
56 |
+
if ( false === $question && isset( $post, $post->ID ) && LP_QUESTION_CPT === get_post_type( $post->ID ) ) {
|
57 |
+
$id = absint( $post->ID );
|
58 |
+
} elseif ( is_numeric( $question ) ) {
|
59 |
+
$id = $question;
|
60 |
+
} elseif ( $question instanceof LP_Question ) {
|
61 |
+
$id = $question->get_id();
|
62 |
+
} elseif ( ! empty( $question->ID ) ) {
|
63 |
+
$id = $question->ID;
|
64 |
+
}
|
65 |
+
|
66 |
+
return learn_press_get_question( $id );
|
67 |
+
}
|
68 |
+
|
69 |
+
public function prepare_object_for_response( $object, $request ) {
|
70 |
+
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
|
71 |
+
$data = $this->get_lesson_data( $object, $context, $request );
|
72 |
+
|
73 |
+
$response = rest_ensure_response( $data );
|
74 |
+
|
75 |
+
return apply_filters( "lp_jwt_rest_prepare_{$this->post_type}_object", $response, $object, $request );
|
76 |
+
}
|
77 |
+
|
78 |
+
protected function get_lesson_data( $object, $context = 'view' ) {
|
79 |
+
$request = func_num_args() >= 2 ? func_get_arg( 2 ) : new WP_REST_Request( '', '', array( 'context' => $context ) );
|
80 |
+
$fields = $this->get_fields_for_response( $request );
|
81 |
+
|
82 |
+
$id = ! empty( $object->ID ) ? $object->ID : $object->get_id();
|
83 |
+
$post = get_post( $id );
|
84 |
+
$data = array();
|
85 |
+
|
86 |
+
$assigned = $this->get_assigned( $id );
|
87 |
+
|
88 |
+
if ( ! empty( $assigned ) && method_exists( $object, 'set_course' ) ) {
|
89 |
+
$course_id = $assigned['course']['id'];
|
90 |
+
$object->set_course( $course_id );
|
91 |
+
}
|
92 |
+
|
93 |
+
foreach ( $fields as $field ) {
|
94 |
+
switch ( $field ) {
|
95 |
+
case 'id':
|
96 |
+
$data['id'] = $id;
|
97 |
+
break;
|
98 |
+
case 'name':
|
99 |
+
$data['name'] = $post->post_title;
|
100 |
+
break;
|
101 |
+
case 'slug':
|
102 |
+
$data['slug'] = $post->post_name;
|
103 |
+
break;
|
104 |
+
case 'permalink':
|
105 |
+
$data['permalink'] = $object->get_permalink();
|
106 |
+
break;
|
107 |
+
case 'date_created':
|
108 |
+
$data['date_created'] = lp_jwt_prepare_date_response( $post->post_date_gmt, $post->post_date );
|
109 |
+
break;
|
110 |
+
case 'date_created_gmt':
|
111 |
+
$data['date_created_gmt'] = lp_jwt_prepare_date_response( $post->post_date_gmt );
|
112 |
+
break;
|
113 |
+
case 'date_modified':
|
114 |
+
$data['date_modified'] = lp_jwt_prepare_date_response( $post->post_modified_gmt, $post->post_modified );
|
115 |
+
break;
|
116 |
+
case 'date_modified_gmt':
|
117 |
+
$data['date_modified_gmt'] = lp_jwt_prepare_date_response( $post->post_modified_gmt );
|
118 |
+
break;
|
119 |
+
case 'status':
|
120 |
+
$data['status'] = $post->post_status;
|
121 |
+
break;
|
122 |
+
case 'content':
|
123 |
+
$data['content'] = 'view' === $context ? wpautop( do_shortcode( $post->post_content ) ) : $post->post_content;
|
124 |
+
break;
|
125 |
+
case 'excerpt':
|
126 |
+
$data['excerpt'] = $post->post_excerpt;
|
127 |
+
break;
|
128 |
+
case 'assigned':
|
129 |
+
$data['assigned'] = $assigned;
|
130 |
+
break;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
$data['meta_data'] = $this->get_question_meta( $id );
|
135 |
+
|
136 |
+
return $data;
|
137 |
+
}
|
138 |
+
|
139 |
+
public function get_question_meta( $id ) {
|
140 |
+
if ( ! class_exists( 'LP_Meta_Box_Question' ) ) {
|
141 |
+
include_once LP_PLUGIN_PATH . 'inc/admin/views/meta-boxes/question/settings.php';
|
142 |
+
}
|
143 |
+
|
144 |
+
$metabox = new LP_Meta_Box_Question();
|
145 |
+
|
146 |
+
$output = array();
|
147 |
+
foreach ( $metabox->metabox( $id ) as $meta_key => $object ) {
|
148 |
+
if ( is_a( $object, 'LP_Meta_Box_Field' ) ) {
|
149 |
+
$object->id = $meta_key;
|
150 |
+
$output[ $meta_key ] = $object->meta_value( $id );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
return $output;
|
155 |
+
}
|
156 |
+
|
157 |
+
public function get_assigned( $id ) {
|
158 |
+
$curd = new LP_Question_CURD();
|
159 |
+
$quiz = $curd->get_quiz( $id );
|
160 |
+
|
161 |
+
$output = array();
|
162 |
+
|
163 |
+
if ( $quiz ) {
|
164 |
+
$courses = learn_press_get_item_courses( $quiz->ID );
|
165 |
+
|
166 |
+
$output['quiz'] = array(
|
167 |
+
'id' => $quiz->ID,
|
168 |
+
'title' => $quiz->post_title,
|
169 |
+
'slug' => $quiz->post_name,
|
170 |
+
'content' => $quiz->post_content,
|
171 |
+
'author' => $quiz->post_author,
|
172 |
+
);
|
173 |
+
|
174 |
+
if ( $courses ) {
|
175 |
+
foreach ( $courses as $course ) {
|
176 |
+
$output['course'] = array(
|
177 |
+
'id' => $course->ID,
|
178 |
+
'title' => $course->post_title,
|
179 |
+
'slug' => $course->post_name,
|
180 |
+
'content' => $course->post_content,
|
181 |
+
'author' => $course->post_author,
|
182 |
+
);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
return $output;
|
188 |
+
}
|
189 |
+
|
190 |
+
public function get_item_schema() {
|
191 |
+
$schema = array(
|
192 |
+
'$schema' => 'http://json-schema.org/draft-04/schema#',
|
193 |
+
'title' => $this->post_type,
|
194 |
+
'type' => 'object',
|
195 |
+
'properties' => array(
|
196 |
+
'id' => array(
|
197 |
+
'description' => __( 'Unique identifier for the resource.', 'learnpress' ),
|
198 |
+
'type' => 'integer',
|
199 |
+
'context' => array( 'view', 'edit' ),
|
200 |
+
'readonly' => true,
|
201 |
+
),
|
202 |
+
'name' => array(
|
203 |
+
'description' => __( 'Course name.', 'learnpress' ),
|
204 |
+
'type' => 'string',
|
205 |
+
'context' => array( 'view', 'edit' ),
|
206 |
+
),
|
207 |
+
'slug' => array(
|
208 |
+
'description' => __( 'Course slug.', 'learnpress' ),
|
209 |
+
'type' => 'string',
|
210 |
+
'context' => array( 'view', 'edit' ),
|
211 |
+
),
|
212 |
+
'permalink' => array(
|
213 |
+
'description' => __( 'Course URL.', 'learnpress' ),
|
214 |
+
'type' => 'string',
|
215 |
+
'format' => 'uri',
|
216 |
+
'context' => array( 'view', 'edit' ),
|
217 |
+
'readonly' => true,
|
218 |
+
),
|
219 |
+
'date_created' => array(
|
220 |
+
'description' => __( "The date the Course was created, in the site's timezone.", 'learnpress' ),
|
221 |
+
'type' => 'date-time',
|
222 |
+
'context' => array( 'view', 'edit' ),
|
223 |
+
'readonly' => true,
|
224 |
+
),
|
225 |
+
'date_created_gmt' => array(
|
226 |
+
'description' => __( 'The date the Course was created, as GMT.', 'learnpress' ),
|
227 |
+
'type' => 'date-time',
|
228 |
+
'context' => array( 'view', 'edit' ),
|
229 |
+
'readonly' => true,
|
230 |
+
),
|
231 |
+
'date_modified' => array(
|
232 |
+
'description' => __( "The date the Course was last modified, in the site's timezone.", 'learnpress' ),
|
233 |
+
'type' => 'date-time',
|
234 |
+
'context' => array( 'view', 'edit' ),
|
235 |
+
'readonly' => true,
|
236 |
+
),
|
237 |
+
'date_modified_gmt' => array(
|
238 |
+
'description' => __( 'The date the Course was last modified, as GMT.', 'learnpress' ),
|
239 |
+
'type' => 'date-time',
|
240 |
+
'context' => array( 'view', 'edit' ),
|
241 |
+
'readonly' => true,
|
242 |
+
),
|
243 |
+
'status' => array(
|
244 |
+
'description' => __( 'Course status (post status).', 'learnpress' ),
|
245 |
+
'type' => 'string',
|
246 |
+
'default' => 'publish',
|
247 |
+
'enum' => array_merge( array_keys( get_post_statuses() ), array( 'future' ) ),
|
248 |
+
'context' => array( 'view', 'edit' ),
|
249 |
+
),
|
250 |
+
'content' => array(
|
251 |
+
'description' => __( 'Content course.', 'learnpress' ),
|
252 |
+
'type' => 'string',
|
253 |
+
'context' => array( 'view', 'edit' ),
|
254 |
+
),
|
255 |
+
'excerpt' => array(
|
256 |
+
'description' => __( 'Retrieves the course excerpt..', 'learnpress' ),
|
257 |
+
'type' => 'string',
|
258 |
+
'context' => array( 'view', 'edit' ),
|
259 |
+
),
|
260 |
+
'assigned' => array(
|
261 |
+
'description' => __( 'Assigned.', 'learnpress' ),
|
262 |
+
'type' => 'array',
|
263 |
+
'context' => array( 'view', 'edit' ),
|
264 |
+
'items' => array(
|
265 |
+
'id' => array(
|
266 |
+
'description' => __( 'Item ID.', 'learnpress' ),
|
267 |
+
'type' => 'integer',
|
268 |
+
'context' => array( 'view', 'edit' ),
|
269 |
+
),
|
270 |
+
'title' => array(
|
271 |
+
'description' => __( 'Title.', 'learnpress' ),
|
272 |
+
'type' => 'string',
|
273 |
+
'context' => array( 'view', 'edit' ),
|
274 |
+
),
|
275 |
+
'slug' => array(
|
276 |
+
'description' => __( 'Item slug.', 'learnpress' ),
|
277 |
+
'type' => 'string',
|
278 |
+
'context' => array( 'view', 'edit' ),
|
279 |
+
),
|
280 |
+
'content' => array(
|
281 |
+
'description' => __( 'Item Content.', 'learnpress' ),
|
282 |
+
'type' => 'string',
|
283 |
+
'context' => array( 'view', 'edit' ),
|
284 |
+
),
|
285 |
+
'author' => array(
|
286 |
+
'description' => __( 'Item Author.', 'learnpress' ),
|
287 |
+
'type' => 'integer',
|
288 |
+
'context' => array( 'view', 'edit' ),
|
289 |
+
),
|
290 |
+
),
|
291 |
+
),
|
292 |
+
),
|
293 |
+
);
|
294 |
+
|
295 |
+
return $this->add_additional_fields_schema( $schema );
|
296 |
+
}
|
297 |
+
}
|
inc/jwt/rest-api/version1/class-lp-rest-users-v1-controller.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
3 |
protected $namespace = 'learnpress/v1';
|
4 |
|
@@ -49,39 +55,16 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
49 |
),
|
50 |
),
|
51 |
),
|
52 |
-
'schema' => array( $this, 'get_public_item_schema' ),
|
53 |
-
)
|
54 |
-
);
|
55 |
-
|
56 |
-
register_rest_route(
|
57 |
-
$this->namespace,
|
58 |
-
'/' . $this->rest_base . '/(?P<id>[\d]+)/(?P<tab>[\w]+)',
|
59 |
-
array(
|
60 |
-
'args' => array(
|
61 |
-
'id' => array(
|
62 |
-
'description' => esc_html__( 'Unique identifier for the resource.', 'learnpress' ),
|
63 |
-
'type' => 'integer',
|
64 |
-
),
|
65 |
-
'tab' => array(
|
66 |
-
'description' => esc_html__( 'Get content in profile learnpress tab.', 'learnpress' ),
|
67 |
-
'type' => 'string',
|
68 |
-
),
|
69 |
-
),
|
70 |
array(
|
71 |
-
'methods' => WP_REST_Server::
|
72 |
-
'callback' => array( $this, '
|
73 |
-
'permission_callback' => array( $this, '
|
74 |
-
'args' =>
|
75 |
-
'context' => $this->get_context_param(
|
76 |
-
array(
|
77 |
-
'default' => 'view',
|
78 |
-
)
|
79 |
-
),
|
80 |
-
),
|
81 |
),
|
82 |
'schema' => array( $this, 'get_public_item_schema' ),
|
83 |
)
|
84 |
);
|
|
|
85 |
}
|
86 |
|
87 |
public function get_items_permissions_check( $request ) {
|
@@ -126,6 +109,109 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
126 |
return true;
|
127 |
}
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
protected function get_user( $id ) {
|
130 |
$error = new WP_Error(
|
131 |
'rest_user_invalid_id',
|
@@ -149,34 +235,183 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
149 |
return $user;
|
150 |
}
|
151 |
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
|
157 |
-
case 'overview':
|
158 |
-
$output = $this->get_overview_tab_contents( $user );
|
159 |
-
break;
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
|
|
|
|
|
|
|
|
164 |
|
165 |
-
|
166 |
-
$output = $this->get_quiz_tab_contents( $request );
|
167 |
-
break;
|
168 |
|
169 |
-
|
170 |
-
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
$response =
|
|
|
176 |
|
177 |
return $response;
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
public function get_overview_tab_contents( $user ) {
|
181 |
$output = array();
|
182 |
|
@@ -226,10 +461,11 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
226 |
$profile = learn_press_get_profile( $request['id'] );
|
227 |
$user = learn_press_get_user( $request['id'] );
|
228 |
$filters_enrolled = array(
|
229 |
-
'all'
|
230 |
-
'finished'
|
231 |
-
'passed'
|
232 |
-
'failed'
|
|
|
233 |
);
|
234 |
|
235 |
if ( method_exists( $profile, 'query_courses' ) ) {
|
@@ -346,6 +582,40 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
346 |
return $output;
|
347 |
}
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
/**
|
350 |
* Retrieves a single user.
|
351 |
*
|
@@ -587,11 +857,11 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
587 |
case 'meta':
|
588 |
$data['meta'] = $this->meta->get_value( $user->ID, $request );
|
589 |
break;
|
590 |
-
case 'custom_fields':
|
591 |
-
$data['custom_fields'] = $this->custom_register( $user );
|
592 |
-
break;
|
593 |
case 'tabs':
|
594 |
-
$data['tabs'] = $this->get_lp_data_tabs( $user );
|
|
|
|
|
|
|
595 |
break;
|
596 |
}
|
597 |
}
|
@@ -599,42 +869,26 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
599 |
return $data;
|
600 |
}
|
601 |
|
602 |
-
|
603 |
-
* Display register cutom form in LearnPress Setting
|
604 |
-
*
|
605 |
-
* @param object $user
|
606 |
-
* @return array
|
607 |
-
*/
|
608 |
-
public function custom_register( $user ) {
|
609 |
-
$output = array();
|
610 |
-
|
611 |
-
if ( function_exists( 'lp_get_user_custom_register_fields' ) ) {
|
612 |
-
$custom_fields = LP()->settings()->get( 'register_profile_fields' );
|
613 |
-
$custom_profile = lp_get_user_custom_register_fields( $user->ID );
|
614 |
-
|
615 |
-
if ( $custom_fields ) {
|
616 |
-
foreach ( $custom_fields as $field ) {
|
617 |
-
$value = sanitize_key( $field['name'] );
|
618 |
-
$output[ $value ] = isset( $custom_profile[ $value ] ) ? $custom_profile[ $value ] : '';
|
619 |
-
}
|
620 |
-
}
|
621 |
-
}
|
622 |
-
|
623 |
-
return $output;
|
624 |
-
}
|
625 |
-
|
626 |
-
public function get_lp_data_tabs( $user ) {
|
627 |
$output = array();
|
628 |
|
629 |
if ( function_exists( 'learn_press_get_user_profile_tabs' ) ) {
|
630 |
$tabs = learn_press_get_user_profile_tabs();
|
631 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
foreach ( $tabs->get() as $key => $tab ) {
|
633 |
$output[ $key ] = array(
|
634 |
'title' => $tab['title'] ?? '',
|
635 |
'slug' => $tab['slug'] ?? '',
|
636 |
'priority' => $tab['priority'] ?? '',
|
637 |
'icon' => $tab['icon'] ?? '',
|
|
|
638 |
);
|
639 |
|
640 |
if ( ! empty( $tab['sections'] ) ) {
|
@@ -652,6 +906,35 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
652 |
return $output;
|
653 |
}
|
654 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
655 |
/**
|
656 |
* Prepares links for the user request.
|
657 |
*
|
@@ -751,7 +1034,7 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
751 |
'username' => array(
|
752 |
'description' => __( 'Login name for the user.' ),
|
753 |
'type' => 'string',
|
754 |
-
'context' => array( 'edit' ),
|
755 |
'required' => true,
|
756 |
'arg_options' => array(
|
757 |
'sanitize_callback' => array( $this, 'check_username' ),
|
@@ -768,7 +1051,7 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
768 |
'first_name' => array(
|
769 |
'description' => __( 'First name for the user.' ),
|
770 |
'type' => 'string',
|
771 |
-
'context' => array( 'edit' ),
|
772 |
'arg_options' => array(
|
773 |
'sanitize_callback' => 'sanitize_text_field',
|
774 |
),
|
@@ -776,7 +1059,7 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
776 |
'last_name' => array(
|
777 |
'description' => __( 'Last name for the user.' ),
|
778 |
'type' => 'string',
|
779 |
-
'context' => array( 'edit' ),
|
780 |
'arg_options' => array(
|
781 |
'sanitize_callback' => 'sanitize_text_field',
|
782 |
),
|
@@ -785,7 +1068,7 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
785 |
'description' => __( 'The email address for the user.' ),
|
786 |
'type' => 'string',
|
787 |
'format' => 'email',
|
788 |
-
'context' => array( 'edit' ),
|
789 |
'required' => true,
|
790 |
),
|
791 |
'url' => array(
|
@@ -815,7 +1098,7 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
815 |
'nickname' => array(
|
816 |
'description' => __( 'The nickname for the user.' ),
|
817 |
'type' => 'string',
|
818 |
-
'context' => array( 'edit' ),
|
819 |
'arg_options' => array(
|
820 |
'sanitize_callback' => 'sanitize_text_field',
|
821 |
),
|
@@ -864,15 +1147,15 @@ class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
|
864 |
'context' => array( 'edit' ),
|
865 |
'readonly' => true,
|
866 |
),
|
867 |
-
'custom_fields' => array(
|
868 |
-
'description' => __( 'Display custom Register' ),
|
869 |
-
'type' => 'object',
|
870 |
-
'context' => array( 'embed', 'view', 'edit' ),
|
871 |
-
),
|
872 |
'tabs' => array(
|
873 |
'description' => __( 'Get all items in user like course, lesson, quiz...' ),
|
874 |
'type' => 'array',
|
875 |
-
'context' => array( '
|
|
|
|
|
|
|
|
|
|
|
876 |
),
|
877 |
),
|
878 |
);
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* REST API for the user.
|
4 |
+
*
|
5 |
+
* @package LearnPress/JWT/RESTAPI
|
6 |
+
* @author Nhamdv <daonham95@gmail.com>
|
7 |
+
*/
|
8 |
class LP_Jwt_Users_V1_Controller extends LP_REST_Jwt_Controller {
|
9 |
protected $namespace = 'learnpress/v1';
|
10 |
|
55 |
),
|
56 |
),
|
57 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
array(
|
59 |
+
'methods' => WP_REST_Server::EDITABLE,
|
60 |
+
'callback' => array( $this, 'update_item' ),
|
61 |
+
'permission_callback' => array( $this, 'update_item_permissions_check' ),
|
62 |
+
'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ),
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
),
|
64 |
'schema' => array( $this, 'get_public_item_schema' ),
|
65 |
)
|
66 |
);
|
67 |
+
|
68 |
}
|
69 |
|
70 |
public function get_items_permissions_check( $request ) {
|
109 |
return true;
|
110 |
}
|
111 |
|
112 |
+
/**
|
113 |
+
* Checks if a given request has access to update a user.
|
114 |
+
*
|
115 |
+
* @since 4.7.0
|
116 |
+
*
|
117 |
+
* @param WP_REST_Request $request Full details about the request.
|
118 |
+
* @return true|WP_Error True if the request has access to update the item, WP_Error object otherwise.
|
119 |
+
*/
|
120 |
+
public function update_item_permissions_check( $request ) {
|
121 |
+
$user = $this->get_user( $request['id'] );
|
122 |
+
if ( is_wp_error( $user ) ) {
|
123 |
+
return $user;
|
124 |
+
}
|
125 |
+
|
126 |
+
if ( ! empty( $request['roles'] ) ) {
|
127 |
+
if ( ! current_user_can( 'promote_user', $user->ID ) ) {
|
128 |
+
return new WP_Error(
|
129 |
+
'rest_cannot_edit_roles',
|
130 |
+
__( 'Sorry, you are not allowed to edit roles of this user.' ),
|
131 |
+
array( 'status' => rest_authorization_required_code() )
|
132 |
+
);
|
133 |
+
}
|
134 |
+
|
135 |
+
$request_params = array_keys( $request->get_params() );
|
136 |
+
sort( $request_params );
|
137 |
+
// If only 'id' and 'roles' are specified (we are only trying to
|
138 |
+
// edit roles), then only the 'promote_user' cap is required.
|
139 |
+
if ( array( 'id', 'roles' ) === $request_params ) {
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
if ( ! current_user_can( 'edit_user', $user->ID ) ) {
|
145 |
+
return new WP_Error(
|
146 |
+
'rest_cannot_edit',
|
147 |
+
__( 'Sorry, you are not allowed to edit this user.' ),
|
148 |
+
array( 'status' => rest_authorization_required_code() )
|
149 |
+
);
|
150 |
+
}
|
151 |
+
|
152 |
+
return true;
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Determines if the current user is allowed to make the desired roles change.
|
157 |
+
*
|
158 |
+
* @since 4.7.0
|
159 |
+
*
|
160 |
+
* @param int $user_id User ID.
|
161 |
+
* @param array $roles New user roles.
|
162 |
+
* @return true|WP_Error True if the current user is allowed to make the role change,
|
163 |
+
* otherwise a WP_Error object.
|
164 |
+
*/
|
165 |
+
protected function check_role_update( $user_id, $roles ) {
|
166 |
+
global $wp_roles;
|
167 |
+
|
168 |
+
foreach ( $roles as $role ) {
|
169 |
+
|
170 |
+
if ( ! isset( $wp_roles->role_objects[ $role ] ) ) {
|
171 |
+
return new WP_Error(
|
172 |
+
'rest_user_invalid_role',
|
173 |
+
/* translators: %s: Role key. */
|
174 |
+
sprintf( __( 'The role %s does not exist.' ), $role ),
|
175 |
+
array( 'status' => 400 )
|
176 |
+
);
|
177 |
+
}
|
178 |
+
|
179 |
+
$potential_role = $wp_roles->role_objects[ $role ];
|
180 |
+
|
181 |
+
/*
|
182 |
+
* Don't let anyone with 'edit_users' (admins) edit their own role to something without it.
|
183 |
+
* Multisite super admins can freely edit their blog roles -- they possess all caps.
|
184 |
+
*/
|
185 |
+
if ( ! ( is_multisite()
|
186 |
+
&& current_user_can( 'manage_sites' ) )
|
187 |
+
&& get_current_user_id() === $user_id
|
188 |
+
&& ! $potential_role->has_cap( 'edit_users' )
|
189 |
+
) {
|
190 |
+
return new WP_Error(
|
191 |
+
'rest_user_invalid_role',
|
192 |
+
__( 'Sorry, you are not allowed to give users that role.' ),
|
193 |
+
array( 'status' => rest_authorization_required_code() )
|
194 |
+
);
|
195 |
+
}
|
196 |
+
|
197 |
+
// Include user admin functions to get access to get_editable_roles().
|
198 |
+
require_once ABSPATH . 'wp-admin/includes/user.php';
|
199 |
+
|
200 |
+
// The new role must be editable by the logged-in user.
|
201 |
+
$editable_roles = get_editable_roles();
|
202 |
+
|
203 |
+
if ( empty( $editable_roles[ $role ] ) ) {
|
204 |
+
return new WP_Error(
|
205 |
+
'rest_user_invalid_role',
|
206 |
+
__( 'Sorry, you are not allowed to give users that role.' ),
|
207 |
+
array( 'status' => 403 )
|
208 |
+
);
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
return true;
|
213 |
+
}
|
214 |
+
|
215 |
protected function get_user( $id ) {
|
216 |
$error = new WP_Error(
|
217 |
'rest_user_invalid_id',
|
235 |
return $user;
|
236 |
}
|
237 |
|
238 |
+
/**
|
239 |
+
* Updates a single user.
|
240 |
+
*
|
241 |
+
* @param WP_REST_Request $request Full details about the request.
|
242 |
+
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
|
243 |
+
*/
|
244 |
+
public function update_item( $request ) {
|
245 |
+
$user = $this->get_user( $request['id'] );
|
246 |
+
if ( is_wp_error( $user ) ) {
|
247 |
+
return $user;
|
248 |
+
}
|
249 |
|
250 |
+
$id = $user->ID;
|
|
|
|
|
|
|
251 |
|
252 |
+
if ( ! $user ) {
|
253 |
+
return new WP_Error(
|
254 |
+
'rest_user_invalid_id',
|
255 |
+
__( 'Invalid user ID.' ),
|
256 |
+
array( 'status' => 404 )
|
257 |
+
);
|
258 |
+
}
|
259 |
|
260 |
+
$owner_id = email_exists( $request['email'] );
|
|
|
|
|
261 |
|
262 |
+
if ( $owner_id && $owner_id !== $id ) {
|
263 |
+
return new WP_Error(
|
264 |
+
'rest_user_invalid_email',
|
265 |
+
__( 'Invalid email address.' ),
|
266 |
+
array( 'status' => 400 )
|
267 |
+
);
|
268 |
}
|
269 |
|
270 |
+
if ( ! empty( $request['username'] ) && $request['username'] !== $user->user_login ) {
|
271 |
+
return new WP_Error(
|
272 |
+
'rest_user_invalid_argument',
|
273 |
+
__( "Username isn't editable." ),
|
274 |
+
array( 'status' => 400 )
|
275 |
+
);
|
276 |
+
}
|
277 |
+
|
278 |
+
if ( ! empty( $request['slug'] ) && $request['slug'] !== $user->user_nicename && get_user_by( 'slug', $request['slug'] ) ) {
|
279 |
+
return new WP_Error(
|
280 |
+
'rest_user_invalid_slug',
|
281 |
+
__( 'Invalid slug.' ),
|
282 |
+
array( 'status' => 400 )
|
283 |
+
);
|
284 |
+
}
|
285 |
+
|
286 |
+
if ( ! empty( $request['roles'] ) ) {
|
287 |
+
$check_permission = $this->check_role_update( $id, $request['roles'] );
|
288 |
+
|
289 |
+
if ( is_wp_error( $check_permission ) ) {
|
290 |
+
return $check_permission;
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
$user = $this->prepare_item_for_database( $request );
|
295 |
+
|
296 |
+
// Ensure we're operating on the same user we already checked.
|
297 |
+
$user->ID = $id;
|
298 |
+
|
299 |
+
$user_id = wp_update_user( wp_slash( (array) $user ) );
|
300 |
+
|
301 |
+
if ( is_wp_error( $user_id ) ) {
|
302 |
+
return $user_id;
|
303 |
+
}
|
304 |
+
|
305 |
+
$user = get_user_by( 'id', $user_id );
|
306 |
+
|
307 |
+
do_action( 'lp_rest_insert_user', $user, $request, false );
|
308 |
+
|
309 |
+
if ( ! empty( $request['roles'] ) ) {
|
310 |
+
array_map( array( $user, 'add_role' ), $request['roles'] );
|
311 |
+
}
|
312 |
+
|
313 |
+
$schema = $this->get_item_schema();
|
314 |
+
|
315 |
+
if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
|
316 |
+
$meta_update = $this->meta->update_value( $request['meta'], $user_id );
|
317 |
+
|
318 |
+
if ( is_wp_error( $meta_update ) ) {
|
319 |
+
return $meta_update;
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
$user = get_user_by( 'id', $user_id );
|
324 |
+
$fields_update = $this->update_additional_fields_for_object( $user, $request );
|
325 |
+
|
326 |
+
if ( is_wp_error( $fields_update ) ) {
|
327 |
+
return $fields_update;
|
328 |
+
}
|
329 |
+
|
330 |
+
$request->set_param( 'context', 'edit' );
|
331 |
+
|
332 |
+
do_action( 'lp_rest_after_insert_user', $user, $request, false );
|
333 |
|
334 |
+
$response = $this->prepare_item_for_response( $user, $request );
|
335 |
+
$response = rest_ensure_response( $response );
|
336 |
|
337 |
return $response;
|
338 |
}
|
339 |
|
340 |
+
/**
|
341 |
+
* Prepares a single user for creation or update.
|
342 |
+
*
|
343 |
+
* @param WP_REST_Request $request Request object.
|
344 |
+
* @return object User object.
|
345 |
+
*/
|
346 |
+
protected function prepare_item_for_database( $request ) {
|
347 |
+
$prepared_user = new stdClass();
|
348 |
+
|
349 |
+
$schema = $this->get_item_schema();
|
350 |
+
|
351 |
+
// Required arguments.
|
352 |
+
if ( isset( $request['email'] ) && ! empty( $schema['properties']['email'] ) ) {
|
353 |
+
$prepared_user->user_email = $request['email'];
|
354 |
+
}
|
355 |
+
|
356 |
+
if ( isset( $request['username'] ) && ! empty( $schema['properties']['username'] ) ) {
|
357 |
+
$prepared_user->user_login = $request['username'];
|
358 |
+
}
|
359 |
+
|
360 |
+
if ( isset( $request['password'] ) && ! empty( $schema['properties']['password'] ) ) {
|
361 |
+
$prepared_user->user_pass = $request['password'];
|
362 |
+
}
|
363 |
+
|
364 |
+
// Optional arguments.
|
365 |
+
if ( isset( $request['id'] ) ) {
|
366 |
+
$prepared_user->ID = absint( $request['id'] );
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( isset( $request['name'] ) && ! empty( $schema['properties']['name'] ) ) {
|
370 |
+
$prepared_user->display_name = $request['name'];
|
371 |
+
}
|
372 |
+
|
373 |
+
if ( isset( $request['first_name'] ) && ! empty( $schema['properties']['first_name'] ) ) {
|
374 |
+
$prepared_user->first_name = $request['first_name'];
|
375 |
+
}
|
376 |
+
|
377 |
+
if ( isset( $request['last_name'] ) && ! empty( $schema['properties']['last_name'] ) ) {
|
378 |
+
$prepared_user->last_name = $request['last_name'];
|
379 |
+
}
|
380 |
+
|
381 |
+
if ( isset( $request['nickname'] ) && ! empty( $schema['properties']['nickname'] ) ) {
|
382 |
+
$prepared_user->nickname = $request['nickname'];
|
383 |
+
}
|
384 |
+
|
385 |
+
if ( isset( $request['slug'] ) && ! empty( $schema['properties']['slug'] ) ) {
|
386 |
+
$prepared_user->user_nicename = $request['slug'];
|
387 |
+
}
|
388 |
+
|
389 |
+
if ( isset( $request['description'] ) && ! empty( $schema['properties']['description'] ) ) {
|
390 |
+
$prepared_user->description = $request['description'];
|
391 |
+
}
|
392 |
+
|
393 |
+
if ( isset( $request['url'] ) && ! empty( $schema['properties']['url'] ) ) {
|
394 |
+
$prepared_user->user_url = $request['url'];
|
395 |
+
}
|
396 |
+
|
397 |
+
if ( isset( $request['locale'] ) && ! empty( $schema['properties']['locale'] ) ) {
|
398 |
+
$prepared_user->locale = $request['locale'];
|
399 |
+
}
|
400 |
+
|
401 |
+
// Setting roles will be handled outside of this function.
|
402 |
+
if ( isset( $request['roles'] ) ) {
|
403 |
+
$prepared_user->role = false;
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Filters user data before insertion via the REST API.
|
408 |
+
*
|
409 |
+
* @param object $prepared_user User object.
|
410 |
+
* @param WP_REST_Request $request Request object.
|
411 |
+
*/
|
412 |
+
return apply_filters( 'lp_rest_pre_insert_user', $prepared_user, $request );
|
413 |
+
}
|
414 |
+
|
415 |
public function get_overview_tab_contents( $user ) {
|
416 |
$output = array();
|
417 |
|
461 |
$profile = learn_press_get_profile( $request['id'] );
|
462 |
$user = learn_press_get_user( $request['id'] );
|
463 |
$filters_enrolled = array(
|
464 |
+
'all' => 'all',
|
465 |
+
'finished' => 'finished',
|
466 |
+
'passed' => 'passed',
|
467 |
+
'failed' => 'failed',
|
468 |
+
'in-progress' => 'in-progress',
|
469 |
);
|
470 |
|
471 |
if ( method_exists( $profile, 'query_courses' ) ) {
|
582 |
return $output;
|
583 |
}
|
584 |
|
585 |
+
/**
|
586 |
+
* Get order by user id
|
587 |
+
*
|
588 |
+
* @param array $request [id: user ID]
|
589 |
+
* @return array
|
590 |
+
*
|
591 |
+
* @author Nhamdv <daonham95@gmail.com>
|
592 |
+
*/
|
593 |
+
public function get_order_content_tab( $request ) {
|
594 |
+
$output = array();
|
595 |
+
|
596 |
+
$profile = learn_press_get_profile( $request['id'] );
|
597 |
+
|
598 |
+
if ( method_exists( $profile, 'query_orders' ) ) {
|
599 |
+
$query_orders = $profile->query_orders( array( 'fields' => 'ids' ) );
|
600 |
+
|
601 |
+
if ( ! empty( $query_orders['items'] ) ) {
|
602 |
+
foreach ( $query_orders['items'] as $order_id ) {
|
603 |
+
$order = learn_press_get_order( $order_id );
|
604 |
+
|
605 |
+
$output[ $order_id ] = array(
|
606 |
+
'order_key' => $order->get_order_number() ?? '',
|
607 |
+
'total' => $order->get_total(),
|
608 |
+
'currency' => $order->get_currency(),
|
609 |
+
'status' => $order->get_status(),
|
610 |
+
'date' => lp_jwt_prepare_date_response( $order->get_order_date() ),
|
611 |
+
);
|
612 |
+
}
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
return $output;
|
617 |
+
}
|
618 |
+
|
619 |
/**
|
620 |
* Retrieves a single user.
|
621 |
*
|
857 |
case 'meta':
|
858 |
$data['meta'] = $this->meta->get_value( $user->ID, $request );
|
859 |
break;
|
|
|
|
|
|
|
860 |
case 'tabs':
|
861 |
+
$data['tabs'] = $this->get_lp_data_tabs( $user, $request );
|
862 |
+
break;
|
863 |
+
case 'custom_register':
|
864 |
+
$data['custom_register'] = $this->custom_register( $user );
|
865 |
break;
|
866 |
}
|
867 |
}
|
869 |
return $data;
|
870 |
}
|
871 |
|
872 |
+
public function get_lp_data_tabs( $user, $request ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
873 |
$output = array();
|
874 |
|
875 |
if ( function_exists( 'learn_press_get_user_profile_tabs' ) ) {
|
876 |
$tabs = learn_press_get_user_profile_tabs();
|
877 |
|
878 |
+
$content = array(
|
879 |
+
'overview' => $this->get_overview_tab_contents( $user ),
|
880 |
+
'courses' => $this->get_course_tab_contents( $request ),
|
881 |
+
'quiz' => $this->get_quiz_tab_contents( $request ),
|
882 |
+
'orders' => $this->get_order_content_tab( $request ),
|
883 |
+
);
|
884 |
+
|
885 |
foreach ( $tabs->get() as $key => $tab ) {
|
886 |
$output[ $key ] = array(
|
887 |
'title' => $tab['title'] ?? '',
|
888 |
'slug' => $tab['slug'] ?? '',
|
889 |
'priority' => $tab['priority'] ?? '',
|
890 |
'icon' => $tab['icon'] ?? '',
|
891 |
+
'content' => $content[ $key ] ?? '',
|
892 |
);
|
893 |
|
894 |
if ( ! empty( $tab['sections'] ) ) {
|
906 |
return $output;
|
907 |
}
|
908 |
|
909 |
+
/**
|
910 |
+
* Display register cutom form in LearnPress Setting
|
911 |
+
*
|
912 |
+
* @param object $user
|
913 |
+
* @return array
|
914 |
+
*/
|
915 |
+
public function custom_register( $user ) {
|
916 |
+
$output = array();
|
917 |
+
|
918 |
+
if ( function_exists( 'lp_get_user_custom_register_fields' ) ) {
|
919 |
+
$custom_fields = LP()->settings()->get( 'register_profile_fields' );
|
920 |
+
$custom_profile = lp_get_user_custom_register_fields( $user->ID );
|
921 |
+
|
922 |
+
if ( $custom_fields ) {
|
923 |
+
foreach ( $custom_fields as $field ) {
|
924 |
+
$value = $field['id'];
|
925 |
+
$output[ $value ] = array(
|
926 |
+
'title' => $field['name'] ?? '',
|
927 |
+
'type' => $field['type'] ?? '',
|
928 |
+
'required' => $field['required'] ?? 'no',
|
929 |
+
'value' => $custom_profile[ $value ] ?? '',
|
930 |
+
);
|
931 |
+
}
|
932 |
+
}
|
933 |
+
}
|
934 |
+
|
935 |
+
return $output;
|
936 |
+
}
|
937 |
+
|
938 |
/**
|
939 |
* Prepares links for the user request.
|
940 |
*
|
1034 |
'username' => array(
|
1035 |
'description' => __( 'Login name for the user.' ),
|
1036 |
'type' => 'string',
|
1037 |
+
'context' => array( 'view', 'edit' ),
|
1038 |
'required' => true,
|
1039 |
'arg_options' => array(
|
1040 |
'sanitize_callback' => array( $this, 'check_username' ),
|
1051 |
'first_name' => array(
|
1052 |
'description' => __( 'First name for the user.' ),
|
1053 |
'type' => 'string',
|
1054 |
+
'context' => array( 'view', 'edit' ),
|
1055 |
'arg_options' => array(
|
1056 |
'sanitize_callback' => 'sanitize_text_field',
|
1057 |
),
|
1059 |
'last_name' => array(
|
1060 |
'description' => __( 'Last name for the user.' ),
|
1061 |
'type' => 'string',
|
1062 |
+
'context' => array( 'view', 'edit' ),
|
1063 |
'arg_options' => array(
|
1064 |
'sanitize_callback' => 'sanitize_text_field',
|
1065 |
),
|
1068 |
'description' => __( 'The email address for the user.' ),
|
1069 |
'type' => 'string',
|
1070 |
'format' => 'email',
|
1071 |
+
'context' => array( 'view', 'edit' ),
|
1072 |
'required' => true,
|
1073 |
),
|
1074 |
'url' => array(
|
1098 |
'nickname' => array(
|
1099 |
'description' => __( 'The nickname for the user.' ),
|
1100 |
'type' => 'string',
|
1101 |
+
'context' => array( 'view', 'edit' ),
|
1102 |
'arg_options' => array(
|
1103 |
'sanitize_callback' => 'sanitize_text_field',
|
1104 |
),
|
1147 |
'context' => array( 'edit' ),
|
1148 |
'readonly' => true,
|
1149 |
),
|
|
|
|
|
|
|
|
|
|
|
1150 |
'tabs' => array(
|
1151 |
'description' => __( 'Get all items in user like course, lesson, quiz...' ),
|
1152 |
'type' => 'array',
|
1153 |
+
'context' => array( 'view' ),
|
1154 |
+
),
|
1155 |
+
'custom_register' => array(
|
1156 |
+
'description' => __( 'Get custom register fields.' ),
|
1157 |
+
'type' => 'object',
|
1158 |
+
'context' => array( 'view' ),
|
1159 |
),
|
1160 |
),
|
1161 |
);
|
inc/lp-core-functions.php
CHANGED
@@ -1962,7 +1962,7 @@ function learn_press_add_notice( $message, $type = 'updated' ) {
|
|
1962 |
function learn_press_setcookie( $name, $value, $expire = 0, $secure = false ) {
|
1963 |
$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
|
1964 |
|
1965 |
-
@setcookie( $name, $value, $expire,
|
1966 |
}
|
1967 |
|
1968 |
/**
|
1962 |
function learn_press_setcookie( $name, $value, $expire = 0, $secure = false ) {
|
1963 |
$secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
|
1964 |
|
1965 |
+
@setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure );
|
1966 |
}
|
1967 |
|
1968 |
/**
|
inc/lp-template-functions.php
CHANGED
@@ -311,6 +311,7 @@ if ( ! function_exists( 'learn_press_single_quiz_args' ) ) {
|
|
311 |
'remainingTime' => $remaining_time ? $remaining_time->get() : $quiz->get_duration()->get(),
|
312 |
'status' => $user->get_item_status( $quiz->get_id(), LP_Global::course( true ) ),
|
313 |
'checkNorequizenroll' => $course->is_no_required_enroll(),
|
|
|
314 |
);
|
315 |
}
|
316 |
|
@@ -1800,11 +1801,11 @@ function lp_get_email_content( $format, $meta = array(), $field = array() ) {
|
|
1800 |
return $content;
|
1801 |
}
|
1802 |
|
1803 |
-
function lp_skeleton_animation_html( $count_li = 3 ) {
|
1804 |
?>
|
1805 |
-
<ul class="lp-skeleton-animation">
|
1806 |
<?php for ( $i = 0; $i < absint( $count_li ); $i ++ ) : ?>
|
1807 |
-
<li style="width: <?php echo wp_rand( 60, 100 );
|
1808 |
<?php endfor; ?>
|
1809 |
</ul>
|
1810 |
|
311 |
'remainingTime' => $remaining_time ? $remaining_time->get() : $quiz->get_duration()->get(),
|
312 |
'status' => $user->get_item_status( $quiz->get_id(), LP_Global::course( true ) ),
|
313 |
'checkNorequizenroll' => $course->is_no_required_enroll(),
|
314 |
+
'navigationPosition' => LP_Settings::get_option( 'navigation_position','yes' )
|
315 |
);
|
316 |
}
|
317 |
|
1801 |
return $content;
|
1802 |
}
|
1803 |
|
1804 |
+
function lp_skeleton_animation_html( $count_li = 3, $width = 'random', $styleli = '', $styleul = '' ) {
|
1805 |
?>
|
1806 |
+
<ul class="lp-skeleton-animation" style="<?php echo ! empty( $styleul ) ? $styleul : ''; ?>">
|
1807 |
<?php for ( $i = 0; $i < absint( $count_li ); $i ++ ) : ?>
|
1808 |
+
<li style="width: <?php echo $width === 'random' ? wp_rand( 60, 100 ) . '%' : $width; ?>; <?php echo ! empty( $styleli ) ? $styleli : ''; ?>"></li>
|
1809 |
<?php endfor; ?>
|
1810 |
</ul>
|
1811 |
|
inc/rest-api/class-lp-core-api.php
CHANGED
@@ -27,6 +27,7 @@ class LP_Core_API extends LP_Abstract_API {
|
|
27 |
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-users-controller.php';
|
28 |
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-courses-controller.php';
|
29 |
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-lazy-load-controller.php';
|
|
|
30 |
|
31 |
do_action( 'learn-press/core-api/includes' );
|
32 |
}
|
@@ -37,6 +38,7 @@ class LP_Core_API extends LP_Abstract_API {
|
|
37 |
'LP_REST_Users_Controller',
|
38 |
'LP_REST_Courses_Controller',
|
39 |
'LP_REST_Lazy_Load_Controller',
|
|
|
40 |
);
|
41 |
|
42 |
$this->controllers = apply_filters( 'learn-press/core-api/controllers', $controllers );
|
27 |
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-users-controller.php';
|
28 |
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-courses-controller.php';
|
29 |
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-lazy-load-controller.php';
|
30 |
+
include_once dirname( __FILE__ ) . $path_version . '/class-lp-rest-profile-controller.php';
|
31 |
|
32 |
do_action( 'learn-press/core-api/includes' );
|
33 |
}
|
38 |
'LP_REST_Users_Controller',
|
39 |
'LP_REST_Courses_Controller',
|
40 |
'LP_REST_Lazy_Load_Controller',
|
41 |
+
'LP_REST_Profile_Controller',
|
42 |
);
|
43 |
|
44 |
$this->controllers = apply_filters( 'learn-press/core-api/controllers', $controllers );
|
inc/rest-api/v1/frontend/class-lp-rest-profile-controller.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class LP_REST_Profile_Controller extends LP_Abstract_REST_Controller {
|
3 |
+
public function __construct() {
|
4 |
+
$this->namespace = 'lp/v1';
|
5 |
+
$this->rest_base = 'profile';
|
6 |
+
|
7 |
+
parent::__construct();
|
8 |
+
}
|
9 |
+
|
10 |
+
public function register_routes() {
|
11 |
+
$this->routes = array(
|
12 |
+
'statistic' => array(
|
13 |
+
array(
|
14 |
+
'methods' => WP_REST_Server::READABLE,
|
15 |
+
'callback' => array( $this, 'statistic' ),
|
16 |
+
'permission_callback' => array( $this, 'check_admin_permission' ),
|
17 |
+
),
|
18 |
+
),
|
19 |
+
'course-tab' => array(
|
20 |
+
array(
|
21 |
+
'methods' => WP_REST_Server::READABLE,
|
22 |
+
'callback' => array( $this, 'course_tab' ),
|
23 |
+
'permission_callback' => array( $this, 'check_admin_permission' ),
|
24 |
+
),
|
25 |
+
),
|
26 |
+
);
|
27 |
+
|
28 |
+
parent::register_routes();
|
29 |
+
}
|
30 |
+
|
31 |
+
public function check_admin_permission( $request ) {
|
32 |
+
$user_id = $request->get_param( 'userID' );
|
33 |
+
|
34 |
+
if ( empty( $user_id ) ) {
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
$profile = learn_press_get_profile( $user_id );
|
39 |
+
|
40 |
+
if ( ! $profile->current_user_can( 'view-tab-courses' ) ) {
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
public function statistic( $request ) {
|
48 |
+
$request = $request->get_params();
|
49 |
+
$user_id = $request['userID'];
|
50 |
+
$response = new LP_REST_Response();
|
51 |
+
$response->data = '';
|
52 |
+
|
53 |
+
try {
|
54 |
+
if ( empty( $user_id ) ) {
|
55 |
+
throw new Exception( esc_html__( 'No user ID found!', 'learnpress' ) );
|
56 |
+
}
|
57 |
+
|
58 |
+
$profile = learn_press_get_profile( $user_id );
|
59 |
+
|
60 |
+
$query = $profile->query_courses( 'purchased' );
|
61 |
+
|
62 |
+
$counts = $query['counts'];
|
63 |
+
|
64 |
+
$statistic = array(
|
65 |
+
'enrolled_courses' => isset( $counts['all'] ) ? $counts['all'] : 0,
|
66 |
+
'active_courses' => isset( $counts['in-progress'] ) ? $counts['in-progress'] : 0,
|
67 |
+
'completed_courses' => isset( $counts['finished'] ) ? $counts['finished'] : 0,
|
68 |
+
'total_courses' => count_user_posts( $user_id, LP_COURSE_CPT ),
|
69 |
+
'total_users' => learn_press_count_instructor_users( $user_id ),
|
70 |
+
);
|
71 |
+
|
72 |
+
do_action( 'learnpress/rest/frontend/profile/statistic', $request );
|
73 |
+
|
74 |
+
$response->data = learn_press_get_template_content( 'profile/tabs/courses/general-statistic', compact( 'statistic' ) );
|
75 |
+
$response->status = 'success';
|
76 |
+
|
77 |
+
} catch ( Exception $e ) {
|
78 |
+
$response->message = $e->getMessage();
|
79 |
+
}
|
80 |
+
|
81 |
+
return rest_ensure_response( $response );
|
82 |
+
}
|
83 |
+
|
84 |
+
public function course_tab( $request ) {
|
85 |
+
$request = $request->get_params();
|
86 |
+
$user_id = $request['userID'];
|
87 |
+
$status = $request['status'] ?? '';
|
88 |
+
$paged = $request['paged'] ?? 1;
|
89 |
+
$query_type = $request['query'] ?? 'purchased';
|
90 |
+
$layout = $request['layout'] ?? 'grid';
|
91 |
+
$response = new LP_REST_Response();
|
92 |
+
$response->data = '';
|
93 |
+
|
94 |
+
try {
|
95 |
+
if ( empty( $user_id ) ) {
|
96 |
+
throw new Exception( esc_html__( 'No user ID found!', 'learnpress' ) );
|
97 |
+
}
|
98 |
+
|
99 |
+
$profile = learn_press_get_profile( $user_id );
|
100 |
+
|
101 |
+
$query = $profile->query_courses(
|
102 |
+
$query_type,
|
103 |
+
apply_filters(
|
104 |
+
'learnpress/rest/frontend/profile/course_tab/query',
|
105 |
+
array(
|
106 |
+
'status' => $status,
|
107 |
+
'limit' => LP_Settings::get_option( 'archive_course_limit', 6 ),
|
108 |
+
'paged' => $paged,
|
109 |
+
)
|
110 |
+
)
|
111 |
+
);
|
112 |
+
|
113 |
+
// LP_User_Item_Course.
|
114 |
+
$course_item_objects = ! empty( $query['items'] ) ? $query['items'] : false;
|
115 |
+
|
116 |
+
if ( empty( $course_item_objects ) ) {
|
117 |
+
throw new Exception( esc_html__( 'No Course avaliable!', 'learnpress' ) );
|
118 |
+
}
|
119 |
+
|
120 |
+
$course_ids = array_map(
|
121 |
+
function( $course_object ) {
|
122 |
+
return ! is_object( $course_object ) ? absint( $course_object ) : $course_object->get_id();
|
123 |
+
},
|
124 |
+
$course_item_objects
|
125 |
+
);
|
126 |
+
|
127 |
+
if ( empty( $course_ids ) ) {
|
128 |
+
throw new Exception( esc_html__( 'No Course IDs avaliable!', 'learnpress' ) );
|
129 |
+
}
|
130 |
+
|
131 |
+
$user = learn_press_get_user( $user_id );
|
132 |
+
|
133 |
+
if ( empty( $user ) ) {
|
134 |
+
throw new Exception( esc_html__( 'No User avaliable!', 'learnpress' ) );
|
135 |
+
}
|
136 |
+
|
137 |
+
do_action( 'learnpress/rest/frontend/profile/course_tab', $request );
|
138 |
+
|
139 |
+
$num_pages = $query->get_pages();
|
140 |
+
$current_page = $query->get_paged();
|
141 |
+
|
142 |
+
$content = $layout === 'grid' ? 'profile/tabs/courses/course-grid' : 'profile/tabs/courses/course-list';
|
143 |
+
|
144 |
+
$response->data = learn_press_get_template_content(
|
145 |
+
$content,
|
146 |
+
array(
|
147 |
+
'user' => $user,
|
148 |
+
'course_ids' => $course_ids,
|
149 |
+
'num_pages' => absint( $num_pages ) > 1 ? absint( $num_pages ) : 1,
|
150 |
+
'current_page' => absint( $current_page ),
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$response->status = 'success';
|
154 |
+
|
155 |
+
} catch ( Exception $e ) {
|
156 |
+
$response->message = $e->getMessage();
|
157 |
+
}
|
158 |
+
|
159 |
+
return rest_ensure_response( $response );
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
inc/templates/class-lp-template-course.php
CHANGED
@@ -189,10 +189,10 @@ class LP_Template_Course extends LP_Abstract_Template {
|
|
189 |
}
|
190 |
|
191 |
// Course is not require enrolling.
|
192 |
-
if ( $course->is_no_required_enroll()) {
|
193 |
return;
|
194 |
}
|
195 |
-
|
196 |
$args_load_tmpl = array(
|
197 |
'template_name' => 'single-course/buttons/purchase.php',
|
198 |
'template_path' => '',
|
@@ -241,7 +241,7 @@ class LP_Template_Course extends LP_Abstract_Template {
|
|
241 |
}
|
242 |
|
243 |
// Course is not require enrolling.
|
244 |
-
if ( $course->is_no_required_enroll()) {
|
245 |
return;
|
246 |
}
|
247 |
|
@@ -843,7 +843,7 @@ class LP_Template_Course extends LP_Abstract_Template {
|
|
843 |
|
844 |
public function instructor_socials() {
|
845 |
$instructor = $this->course->get_instructor();
|
846 |
-
$socials = $instructor->get_profile_socials();
|
847 |
|
848 |
foreach ( $socials as $social ) {
|
849 |
echo $social;
|
189 |
}
|
190 |
|
191 |
// Course is not require enrolling.
|
192 |
+
if ( $course->is_no_required_enroll() ) {
|
193 |
return;
|
194 |
}
|
195 |
+
|
196 |
$args_load_tmpl = array(
|
197 |
'template_name' => 'single-course/buttons/purchase.php',
|
198 |
'template_path' => '',
|
241 |
}
|
242 |
|
243 |
// Course is not require enrolling.
|
244 |
+
if ( $course->is_no_required_enroll() ) {
|
245 |
return;
|
246 |
}
|
247 |
|
843 |
|
844 |
public function instructor_socials() {
|
845 |
$instructor = $this->course->get_instructor();
|
846 |
+
$socials = $instructor->get_profile_socials( $instructor->get_id() );
|
847 |
|
848 |
foreach ( $socials as $social ) {
|
849 |
echo $social;
|
inc/templates/class-lp-template-profile.php
CHANGED
@@ -67,7 +67,7 @@ class LP_Template_Profile extends LP_Abstract_Template {
|
|
67 |
'total_users' => learn_press_count_instructor_users( $user->get_id() ),
|
68 |
);
|
69 |
|
70 |
-
learn_press_get_template( 'profile/
|
71 |
}
|
72 |
|
73 |
public function dashboard_featured_courses() {
|
@@ -192,7 +192,7 @@ class LP_Template_Profile extends LP_Abstract_Template {
|
|
192 |
return;
|
193 |
}
|
194 |
|
195 |
-
if ( 'yes' !== LP()->settings()->get( 'enable_register_profile' ) ) {
|
196 |
return;
|
197 |
}
|
198 |
|
67 |
'total_users' => learn_press_count_instructor_users( $user->get_id() ),
|
68 |
);
|
69 |
|
70 |
+
learn_press_get_template( 'profile/tabs/courses/general-statistic', compact( 'statistic' ) );
|
71 |
}
|
72 |
|
73 |
public function dashboard_featured_courses() {
|
192 |
return;
|
193 |
}
|
194 |
|
195 |
+
if ( 'yes' !== LP()->settings()->get( 'enable_register_profile' ) || ! get_option( 'users_can_register' ) ) {
|
196 |
return;
|
197 |
}
|
198 |
|
inc/user-item/class-lp-user-item-course.php
CHANGED
@@ -246,8 +246,10 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
246 |
return false;
|
247 |
}
|
248 |
|
249 |
-
$results = LP_Object_Cache::get(
|
250 |
-
'course-
|
|
|
|
|
251 |
|
252 |
if ( $results === false ) {
|
253 |
$course_result = $course->get_evaluation_results_method();
|
@@ -258,8 +260,11 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
258 |
$results = $this->calculate_course_results();
|
259 |
}
|
260 |
|
261 |
-
LP_Object_Cache::set(
|
262 |
-
'course-
|
|
|
|
|
|
|
263 |
}
|
264 |
|
265 |
return $prop && $results && array_key_exists( $prop, $results ) ? $results[ $prop ] : $results;
|
@@ -336,13 +341,20 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
336 |
$graduation = $this->is_finished() ? $this->_is_passed( $results['result'] ) : 'in-progress';
|
337 |
}
|
338 |
|
339 |
-
$results = apply_filters(
|
340 |
-
|
|
|
|
|
|
|
|
|
|
|
341 |
|
342 |
LP_User_Items_Result_DB::instance()->update( $this->get_user_item_id(), wp_json_encode( $results ) );
|
343 |
|
344 |
-
learn_press_update_user_item_field(
|
345 |
-
array( '
|
|
|
|
|
346 |
|
347 |
return $results;
|
348 |
}
|
@@ -615,7 +627,7 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
615 |
}
|
616 |
|
617 |
$result *= 100;
|
618 |
-
$data
|
619 |
'result' => $result,
|
620 |
'status' => $this->get_status(),
|
621 |
);
|
@@ -658,8 +670,10 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
658 |
}
|
659 |
|
660 |
public function is_enrolled() {
|
661 |
-
return in_array(
|
662 |
-
|
|
|
|
|
663 |
}
|
664 |
|
665 |
public function get_level() {
|
@@ -775,6 +789,7 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
775 |
* @param int $section_id - Optional. Get in specific section
|
776 |
*
|
777 |
* @return array|bool|mixed
|
|
|
778 |
*/
|
779 |
public function get_completed_items( $type = '', $with_total = false, $section_id = 0 ) {
|
780 |
|
@@ -783,6 +798,10 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
783 |
// $completed_items = array(0,100);
|
784 |
// return $with_total ? $completed_items : $completed_items[0];
|
785 |
|
|
|
|
|
|
|
|
|
786 |
$key = sprintf(
|
787 |
'%d-%d-%s',
|
788 |
$this->get_user_id(),
|
@@ -790,20 +809,27 @@ class LP_User_Item_Course extends LP_User_Item implements ArrayAccess {
|
|
790 |
md5( build_query( func_get_args() ) )
|
791 |
);
|
792 |
|
793 |
-
|
|
|
|
|
794 |
$completed = 0;
|
795 |
$total = 0;
|
796 |
$section_items = array();
|
797 |
|
798 |
-
if ( $section_id
|
799 |
-
$
|
800 |
|
801 |
-
if ( $
|
802 |
-
$section_items =
|
|
|
|
|
|
|
|
|
803 |
}
|
804 |
}
|
805 |
|
806 |
-
|
|
|
807 |
foreach ( $items as $item ) {
|
808 |
|
809 |
if ( $section_id && ! in_array( $item->get_id(), $section_items ) ) {
|
246 |
return false;
|
247 |
}
|
248 |
|
249 |
+
$results = LP_Object_Cache::get(
|
250 |
+
'course-' . $this->get_item_id() . '-' . $this->get_user_id(),
|
251 |
+
'course-results'
|
252 |
+
);
|
253 |
|
254 |
if ( $results === false ) {
|
255 |
$course_result = $course->get_evaluation_results_method();
|
260 |
$results = $this->calculate_course_results();
|
261 |
}
|
262 |
|
263 |
+
LP_Object_Cache::set(
|
264 |
+
'course-' . $this->get_item_id() . '-' . $this->get_user_id(),
|
265 |
+
$results,
|
266 |
+
'course-results'
|
267 |
+
);
|
268 |
}
|
269 |
|
270 |
return $prop && $results && array_key_exists( $prop, $results ) ? $results[ $prop ] : $results;
|
341 |
$graduation = $this->is_finished() ? $this->_is_passed( $results['result'] ) : 'in-progress';
|
342 |
}
|
343 |
|
344 |
+
$results = apply_filters(
|
345 |
+
'learn-press/update-course-results',
|
346 |
+
$results,
|
347 |
+
$this->get_item_id(),
|
348 |
+
$this->get_user_id(),
|
349 |
+
$this
|
350 |
+
);
|
351 |
|
352 |
LP_User_Items_Result_DB::instance()->update( $this->get_user_item_id(), wp_json_encode( $results ) );
|
353 |
|
354 |
+
learn_press_update_user_item_field(
|
355 |
+
array( 'graduation' => $graduation ),
|
356 |
+
array( 'user_item_id' => $this->get_user_item_id() )
|
357 |
+
);
|
358 |
|
359 |
return $results;
|
360 |
}
|
627 |
}
|
628 |
|
629 |
$result *= 100;
|
630 |
+
$data = array(
|
631 |
'result' => $result,
|
632 |
'status' => $this->get_status(),
|
633 |
);
|
670 |
}
|
671 |
|
672 |
public function is_enrolled() {
|
673 |
+
return in_array(
|
674 |
+
$this->get_status(),
|
675 |
+
learn_press_course_enrolled_slugs() /* array( 'enrolled', 'finished' )*/
|
676 |
+
);
|
677 |
}
|
678 |
|
679 |
public function get_level() {
|
789 |
* @param int $section_id - Optional. Get in specific section
|
790 |
*
|
791 |
* @return array|bool|mixed
|
792 |
+
* @editor tungnx
|
793 |
*/
|
794 |
public function get_completed_items( $type = '', $with_total = false, $section_id = 0 ) {
|
795 |
|
798 |
// $completed_items = array(0,100);
|
799 |
// return $with_total ? $completed_items : $completed_items[0];
|
800 |
|
801 |
+
if ( ! $this->_course ) {
|
802 |
+
return;
|
803 |
+
}
|
804 |
+
|
805 |
$key = sprintf(
|
806 |
'%d-%d-%s',
|
807 |
$this->get_user_id(),
|
809 |
md5( build_query( func_get_args() ) )
|
810 |
);
|
811 |
|
812 |
+
$completed_items = LP_Object_Cache::get( $key, 'learn-press/user-completed-items' );
|
813 |
+
|
814 |
+
if ( false === $completed_items ) {
|
815 |
$completed = 0;
|
816 |
$total = 0;
|
817 |
$section_items = array();
|
818 |
|
819 |
+
if ( $section_id ) {
|
820 |
+
$section = $this->_course->get_sections( 'object', $section_id );
|
821 |
|
822 |
+
if ( $section ) {
|
823 |
+
$section_items = $section->get_items();
|
824 |
+
|
825 |
+
if ( $section_items ) {
|
826 |
+
$section_items = array_keys( $section_items );
|
827 |
+
}
|
828 |
}
|
829 |
}
|
830 |
|
831 |
+
$items = $this->get_items();
|
832 |
+
if ( $items ) {
|
833 |
foreach ( $items as $item ) {
|
834 |
|
835 |
if ( $section_id && ! in_array( $item->get_id(), $section_items ) ) {
|
inc/user/abstract-lp-user.php
CHANGED
@@ -2594,9 +2594,9 @@ if ( ! class_exists( 'LP_Abstract_User' ) ) {
|
|
2594 |
return LP_Profile::instance( $this->get_id() )->get_profile_picture( $type, $size );
|
2595 |
}
|
2596 |
|
2597 |
-
public function get_profile_socials() {
|
2598 |
$socials = array();
|
2599 |
-
$extra_info = learn_press_get_user_extra_profile_info();
|
2600 |
|
2601 |
if ( $extra_info ) {
|
2602 |
foreach ( $extra_info as $k => $v ) {
|
2594 |
return LP_Profile::instance( $this->get_id() )->get_profile_picture( $type, $size );
|
2595 |
}
|
2596 |
|
2597 |
+
public function get_profile_socials( $user_id ) {
|
2598 |
$socials = array();
|
2599 |
+
$extra_info = learn_press_get_user_extra_profile_info( $user_id );
|
2600 |
|
2601 |
if ( $extra_info ) {
|
2602 |
foreach ( $extra_info as $k => $v ) {
|
inc/user/class-lp-profile.php
CHANGED
@@ -241,36 +241,12 @@ if ( ! class_exists( 'LP_Profile' ) ) {
|
|
241 |
$settings = LP()->settings();
|
242 |
$course_sections = array();
|
243 |
|
244 |
-
$course_sections['enrolled'] = array(
|
245 |
-
'title' => esc_html__( 'Enrolled', 'learnpress' ),
|
246 |
-
'slug' => 'enrolled',
|
247 |
-
'callback' => array( $this, 'tab_order_details' ),
|
248 |
-
'priority' => 10,
|
249 |
-
);
|
250 |
-
|
251 |
-
if ( learn_press_user_maybe_is_a_teacher() ) {
|
252 |
-
$course_sections['created'] = array(
|
253 |
-
'title' => esc_html__( 'Created', 'learnpress' ),
|
254 |
-
'slug' => 'created',
|
255 |
-
'callback' => array( $this, 'tab_order_details' ),
|
256 |
-
'priority' => 20,
|
257 |
-
);
|
258 |
-
}
|
259 |
-
|
260 |
$this->_default_settings = array(
|
261 |
-
'overview' => array(
|
262 |
-
'title' => esc_html__( 'Overview', 'learnpress' ),
|
263 |
-
'slug' => $settings->get( 'profile_endpoints.overview', 'overview' ),
|
264 |
-
'callback' => array( $this, 'tab_dashboard' ),
|
265 |
-
'priority' => 10,
|
266 |
-
'icon' => '<i class="fas fa-chalkboard-teacher"></i>',
|
267 |
-
),
|
268 |
'courses' => array(
|
269 |
'title' => esc_html__( 'Courses', 'learnpress' ),
|
270 |
'slug' => $settings->get( 'profile_endpoints.courses', 'courses' ),
|
271 |
'callback' => array( $this, 'tab_courses' ),
|
272 |
-
'priority' =>
|
273 |
-
'sections' => $course_sections,
|
274 |
'icon' => '<i class="fas fa-book-open"></i>',
|
275 |
),
|
276 |
'quizzes' => array(
|
241 |
$settings = LP()->settings();
|
242 |
$course_sections = array();
|
243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
$this->_default_settings = array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
'courses' => array(
|
246 |
'title' => esc_html__( 'Courses', 'learnpress' ),
|
247 |
'slug' => $settings->get( 'profile_endpoints.courses', 'courses' ),
|
248 |
'callback' => array( $this, 'tab_courses' ),
|
249 |
+
'priority' => 1,
|
|
|
250 |
'icon' => '<i class="fas fa-book-open"></i>',
|
251 |
),
|
252 |
'quizzes' => array(
|
inc/user/lp-user-functions.php
CHANGED
@@ -1822,7 +1822,7 @@ function learn_press_user_retake_quiz( $quiz_id, $user_id = 0, $course_id = 0, $
|
|
1822 |
* @return array
|
1823 |
* @since 3.3.0
|
1824 |
*/
|
1825 |
-
function learn_press_rest_prepare_user_questions( $question_ids, $args = array() ) {
|
1826 |
if ( is_numeric( $args ) ) {
|
1827 |
|
1828 |
} else {
|
@@ -1865,14 +1865,17 @@ function learn_press_rest_prepare_user_questions( $question_ids, $args = array()
|
|
1865 |
$hasExplanation = ! ! $theExplanation;
|
1866 |
}
|
1867 |
|
|
|
|
|
1868 |
$questionData = array(
|
1869 |
'id' => absint( $id ),
|
1870 |
'title' => $question->get_title(),
|
1871 |
'type' => $question->get_type(),
|
1872 |
-
'point' =>
|
1873 |
);
|
1874 |
|
1875 |
-
|
|
|
1876 |
$questionData['content'] = $content;
|
1877 |
}
|
1878 |
|
@@ -1899,18 +1902,12 @@ function learn_press_rest_prepare_user_questions( $question_ids, $args = array()
|
|
1899 |
$question,
|
1900 |
array(
|
1901 |
'include_is_true' => $with_true_or_false,
|
1902 |
-
'answer' =>
|
1903 |
)
|
1904 |
);
|
1905 |
}
|
1906 |
|
1907 |
-
$questions[] =
|
1908 |
-
'learn-press/single-quiz-js/question-data',
|
1909 |
-
$questionData,
|
1910 |
-
$question->get_type(),
|
1911 |
-
$question->get_id(),
|
1912 |
-
$question
|
1913 |
-
);
|
1914 |
}
|
1915 |
|
1916 |
/**
|
@@ -1932,7 +1929,7 @@ function learn_press_rest_prepare_user_questions( $question_ids, $args = array()
|
|
1932 |
}
|
1933 |
}
|
1934 |
|
1935 |
-
return $questions;
|
1936 |
}
|
1937 |
|
1938 |
/**
|
1822 |
* @return array
|
1823 |
* @since 3.3.0
|
1824 |
*/
|
1825 |
+
function learn_press_rest_prepare_user_questions( array $question_ids = array(), array $args = array() ) : array {
|
1826 |
if ( is_numeric( $args ) ) {
|
1827 |
|
1828 |
} else {
|
1865 |
$hasExplanation = ! ! $theExplanation;
|
1866 |
}
|
1867 |
|
1868 |
+
$mark = $question->get_mark() ? $question->get_mark() : 1;
|
1869 |
+
|
1870 |
$questionData = array(
|
1871 |
'id' => absint( $id ),
|
1872 |
'title' => $question->get_title(),
|
1873 |
'type' => $question->get_type(),
|
1874 |
+
'point' => $mark,
|
1875 |
);
|
1876 |
|
1877 |
+
$content = $question->get_content();
|
1878 |
+
if ( $content ) {
|
1879 |
$questionData['content'] = $content;
|
1880 |
}
|
1881 |
|
1902 |
$question,
|
1903 |
array(
|
1904 |
'include_is_true' => $with_true_or_false,
|
1905 |
+
'answer' => $answered[ $id ]['answered'] ?? '',
|
1906 |
)
|
1907 |
);
|
1908 |
}
|
1909 |
|
1910 |
+
$questions[] = $questionData;
|
|
|
|
|
|
|
|
|
|
|
|
|
1911 |
}
|
1912 |
|
1913 |
/**
|
1929 |
}
|
1930 |
}
|
1931 |
|
1932 |
+
return apply_filters( 'learn-press/list-questions-data', $questions );
|
1933 |
}
|
1934 |
|
1935 |
/**
|
learnpress.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin URI: http://thimpress.com/learnpress
|
5 |
* Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
|
6 |
* Author: ThimPress
|
7 |
-
* Version: 4.0.
|
8 |
* Author URI: http://thimpress.com
|
9 |
* Requires at least: 3.8
|
10 |
* Tested up to: 5.7
|
4 |
* Plugin URI: http://thimpress.com/learnpress
|
5 |
* Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes.
|
6 |
* Author: ThimPress
|
7 |
+
* Version: 4.0.9-beta-1
|
8 |
* Author URI: http://thimpress.com
|
9 |
* Requires at least: 3.8
|
10 |
* Tested up to: 5.7
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: elearning, education, course, lms, learning management system
|
|
5 |
Requires at least: 5.6
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 7.0
|
8 |
-
Stable tag: 4.0.
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -197,6 +197,16 @@ https://www.transifex.com/projects/p/learnpress/
|
|
197 |
|
198 |
== Changelog ==
|
199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
= 4.0.8 =
|
201 |
~ Added: feature "Allow Repurchase course"
|
202 |
~ Fixed: Custom register fields error with some name not utf8
|
@@ -234,7 +244,7 @@ https://www.transifex.com/projects/p/learnpress/
|
|
234 |
~ Fixed: error table "learnpress_user_itemmeta" doesn’t exist when install new.
|
235 |
~ Fixed: style comment function.
|
236 |
~ Added: form comment on course.
|
237 |
-
~ Fixed: js itemProgress undefined in Eduma
|
238 |
|
239 |
= 4.0.3 =
|
240 |
~ Fixed: tool "Reset course progress"
|
5 |
Requires at least: 5.6
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 7.0
|
8 |
+
Stable tag: 4.0.9-beta-1
|
9 |
License: GPLv2 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
197 |
|
198 |
== Changelog ==
|
199 |
|
200 |
+
= 4.0.9 =
|
201 |
+
~ Added: option enable sticky navigation pagination when user answer question on quiz.
|
202 |
+
~ Fixed: set again current item when manager remove item current when edit course.
|
203 |
+
~ Modified: page profile - load ajax call API, show more info.
|
204 |
+
~ Fixed: can't upgrade DB from 3 to 4 because user translate menu "LearnPress".
|
205 |
+
~ Modified: Navigation on page quiz - change icon next, previous to text.
|
206 |
+
~ Fixed: function "duplicate question" not duplicate "answer option"
|
207 |
+
~ Fixed: Social icons on page profile when user view another user.
|
208 |
+
~ Fixed: on multiple site enable option "Registration is disabled" will not show form register on page Profile.
|
209 |
+
|
210 |
= 4.0.8 =
|
211 |
~ Added: feature "Allow Repurchase course"
|
212 |
~ Fixed: Custom register fields error with some name not utf8
|
244 |
~ Fixed: error table "learnpress_user_itemmeta" doesn’t exist when install new.
|
245 |
~ Fixed: style comment function.
|
246 |
~ Added: form comment on course.
|
247 |
+
~ Fixed: js itemProgress undefined in Eduma theme
|
248 |
|
249 |
= 4.0.3 =
|
250 |
~ Fixed: tool "Reset course progress"
|
templates/profile/dashboard/featured-courses.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template for displaying featured courses in user profile dashboard.
|
4 |
-
*
|
5 |
-
* @author ThimPress
|
6 |
-
* @package LearnPress/Templates
|
7 |
-
* @version 4.0.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
defined( 'ABSPATH' ) || exit;
|
11 |
-
|
12 |
-
$user = LP_Profile::instance()->get_user();
|
13 |
-
|
14 |
-
if ( empty( $courses ) ) {
|
15 |
-
return;
|
16 |
-
}
|
17 |
-
?>
|
18 |
-
|
19 |
-
<div class="profile-courses featured-courses">
|
20 |
-
<h3><?php esc_html_e( 'Featured courses', 'learnpress' ); ?></h3>
|
21 |
-
|
22 |
-
<?php if ( ! empty( $courses ) ) : ?>
|
23 |
-
<div class="lp-archive-courses">
|
24 |
-
<ul <?php lp_item_course_class(); ?> data-size="3" data-layout="grid" id="learn-press-profile-featured-courses">
|
25 |
-
<?php
|
26 |
-
global $post;
|
27 |
-
|
28 |
-
foreach ( $courses as $item ) {
|
29 |
-
$course = learn_press_get_course( $item );
|
30 |
-
$post = get_post( $item );
|
31 |
-
setup_postdata( $post );
|
32 |
-
learn_press_get_template( 'content-course.php' );
|
33 |
-
}
|
34 |
-
|
35 |
-
wp_reset_postdata();
|
36 |
-
?>
|
37 |
-
</ul>
|
38 |
-
</div>
|
39 |
-
|
40 |
-
<?php if ( isset( $max_num_pages ) && $max_num_pages > 1 ) : ?>
|
41 |
-
<button data-container="learn-press-profile-featured-courses"
|
42 |
-
data-pages="<?php echo $max_num_pages; ?>"
|
43 |
-
data-url="<?php echo esc_url( '?lp-ajax=load-more-courses&type=featured&user=' . $user->get_id() ); ?>"
|
44 |
-
class="lp-button btn-load-more-courses btn-ajax-off">
|
45 |
-
<i class="fas fa-spinner icon"></i>
|
46 |
-
<?php esc_html_e( 'View More', 'learnpress' ); ?></button>
|
47 |
-
<?php endif; ?>
|
48 |
-
<?php else : ?>
|
49 |
-
<?php learn_press_display_message( __( 'There is no featured courses.', 'learnpress' ) ); ?>
|
50 |
-
<?php endif; ?>
|
51 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/profile/dashboard/latest-courses.php
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template for displaying latest courses in user profile dashboard.
|
4 |
-
*
|
5 |
-
* @author ThimPress
|
6 |
-
* @package LearnPress/Templates
|
7 |
-
* @version 4.0.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
defined( 'ABSPATH' ) || exit;
|
11 |
-
|
12 |
-
$user = LP_Profile::instance()->get_user();
|
13 |
-
|
14 |
-
if ( empty( $courses ) ) {
|
15 |
-
return;
|
16 |
-
}
|
17 |
-
?>
|
18 |
-
|
19 |
-
<div class="profile-courses newest-courses">
|
20 |
-
<h3><?php esc_html_e( 'Latest courses', 'learnpress' ); ?></h3>
|
21 |
-
|
22 |
-
<?php if ( ! empty( $courses ) ) : ?>
|
23 |
-
<div class="lp-archive-courses">
|
24 |
-
<ul <?php lp_item_course_class(); ?> data-size="3" data-layout="grid" id="learn-press-profile-latest-courses">
|
25 |
-
<?php
|
26 |
-
global $post;
|
27 |
-
|
28 |
-
foreach ( $courses as $item ) {
|
29 |
-
$course = learn_press_get_course( $item );
|
30 |
-
$post = get_post( $item );
|
31 |
-
setup_postdata( $post );
|
32 |
-
learn_press_get_template( 'content-course.php' );
|
33 |
-
}
|
34 |
-
|
35 |
-
wp_reset_postdata();
|
36 |
-
?>
|
37 |
-
</ul>
|
38 |
-
</div>
|
39 |
-
|
40 |
-
<?php if ( isset( $max_num_pages ) && $max_num_pages > 1 ) : ?>
|
41 |
-
<button data-container="learn-press-profile-latest-courses"
|
42 |
-
data-pages="<?php echo $max_num_pages; ?>"
|
43 |
-
data-url="<?php echo esc_url( '?lp-ajax=load-more-courses&type=latest&user=' . $user->get_id() ); ?>"
|
44 |
-
class="lp-button btn-load-more-courses btn-ajax-off">
|
45 |
-
<i class="fas fa-spinner icon"></i>
|
46 |
-
<?php esc_html_e( 'View More', 'learnpress' ); ?></button>
|
47 |
-
<?php endif; ?>
|
48 |
-
<?php else : ?>
|
49 |
-
<?php learn_press_display_message( __( 'There is no courses.', 'learnpress' ) ); ?>
|
50 |
-
<?php endif; ?>
|
51 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/profile/socials.php
CHANGED
@@ -8,9 +8,14 @@
|
|
8 |
*/
|
9 |
|
10 |
defined( 'ABSPATH' ) || exit;
|
|
|
11 |
|
12 |
-
$
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
return;
|
15 |
}
|
16 |
?>
|
8 |
*/
|
9 |
|
10 |
defined( 'ABSPATH' ) || exit;
|
11 |
+
$user = LP_Profile::instance()->get_user();
|
12 |
|
13 |
+
if ( ! $user ) {
|
14 |
+
return;
|
15 |
+
}
|
16 |
+
|
17 |
+
$socials = $user->get_profile_socials( $user->get_id() );
|
18 |
+
if ( empty( $socials ) ) {
|
19 |
return;
|
20 |
}
|
21 |
?>
|
templates/profile/tabs/courses.php
CHANGED
@@ -6,66 +6,93 @@
|
|
6 |
*
|
7 |
* @author ThimPress
|
8 |
* @package Learnpress/Templates
|
9 |
-
* @version
|
10 |
*/
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit();
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
$
|
19 |
-
$query = $profile->query_courses();
|
20 |
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
?>
|
27 |
|
28 |
<div class="learn-press-subtab-content">
|
29 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
</thead>
|
40 |
-
<tbody>
|
41 |
-
<?php foreach ( $query['items'] as $user_course ) { ?>
|
42 |
-
<?php $course = learn_press_get_course( $user_course->get_id() ); ?>
|
43 |
-
<tr>
|
44 |
-
<td class="column-course">
|
45 |
-
<a href="<?php echo $course->get_permalink(); ?>">
|
46 |
-
<?php echo $course->get_title(); ?>
|
47 |
-
</a>
|
48 |
-
</td>
|
49 |
-
<td class="column-date"><?php echo $user_course->get_start_time( 'd M Y' ); ?></td>
|
50 |
-
<td class="column-passing-grade"><?php echo $course->get_passing_condition( true ); ?></td>
|
51 |
-
<td class="column-status">
|
52 |
-
<span class="result-percent"><?php echo $user_course->get_percent_result(); ?></span>
|
53 |
-
<span class="lp-label label-<?php echo esc_attr( $user_course->get_results( 'status' ) ); ?>">
|
54 |
-
<?php echo $user_course->get_status_label( $user_course->get_results( 'status' ) ); ?>
|
55 |
-
</span>
|
56 |
-
</td>
|
57 |
-
</tr>
|
58 |
-
<?php } ?>
|
59 |
-
</tbody>
|
60 |
-
<tfoot>
|
61 |
-
<tr class="list-table-nav">
|
62 |
-
<td colspan="2" class="nav-text">
|
63 |
-
<?php echo $query->get_offset_text(); ?>
|
64 |
-
</td>
|
65 |
-
<td colspan="2" class="nav-pages">
|
66 |
-
<?php $query->get_nav_numbers( true ); ?>
|
67 |
-
</td>
|
68 |
-
</tr>
|
69 |
-
</tfoot>
|
70 |
-
</table>
|
71 |
</div>
|
6 |
*
|
7 |
* @author ThimPress
|
8 |
* @package Learnpress/Templates
|
9 |
+
* @version 4.0.9
|
10 |
*/
|
11 |
|
12 |
defined( 'ABSPATH' ) || exit();
|
13 |
|
14 |
+
if ( ! LP_Profile::instance()->current_user_can( 'view-tab-courses' ) ) {
|
15 |
+
return;
|
16 |
+
}
|
17 |
|
18 |
+
$user = LP_Profile::instance()->get_user();
|
|
|
19 |
|
20 |
+
$data_course_progress = apply_filters(
|
21 |
+
'learnpress/template/profile/tabs/courses/course_progress',
|
22 |
+
array(
|
23 |
+
'userID' => $user->get_id(),
|
24 |
+
'status' => 'in-progress',
|
25 |
+
)
|
26 |
+
);
|
27 |
|
28 |
+
$enrolleds = array(
|
29 |
+
'' => esc_html__( 'All', 'learnpress' ),
|
30 |
+
'in-progress' => esc_html__( 'In-Progress', 'learnpress' ),
|
31 |
+
'finished' => esc_html__( 'Finished', 'learnpress' ),
|
32 |
+
'passed' => esc_html__( 'Passed', 'learnpress' ),
|
33 |
+
'failed' => esc_html__( 'Failed', 'learnpress' ),
|
34 |
+
);
|
35 |
+
|
36 |
+
$createds = array(
|
37 |
+
'' => esc_html__( 'All', 'learnpress' ),
|
38 |
+
'publish' => esc_html__( 'Publish', 'learnpress' ),
|
39 |
+
'pending' => esc_html__( 'Pending', 'learnpress' ),
|
40 |
+
);
|
41 |
+
|
42 |
+
$enrolled_active = ! learn_press_user_maybe_is_a_teacher() ? 'in-progress' : '';
|
43 |
+
$tab_active = ! learn_press_user_maybe_is_a_teacher() ? 'enrolled' : 'created';
|
44 |
?>
|
45 |
|
46 |
<div class="learn-press-subtab-content">
|
47 |
+
<div class="learn-press-profile-course__statistic" data-ajax="<?php echo htmlentities( wp_json_encode( [ 'userID' => $user->get_id() ] ) ); ?>"></div> <?php // phpcs:ignore ?>
|
48 |
+
|
49 |
+
<div class="learn-press-profile-course__tab">
|
50 |
+
<ul class="learn-press-profile-course__tab__inner">
|
51 |
+
<li><a class="<?php echo $tab_active === 'enrolled' ? 'active' : ''; ?>" data-tab="enrolled"><?php esc_html_e( 'Enrolled', 'learnpress' ); ?></a></li>
|
52 |
+
|
53 |
+
<?php if ( learn_press_user_maybe_is_a_teacher() ) : ?>
|
54 |
+
<li><a class="<?php echo $tab_active === 'created' ? 'active' : ''; ?>" data-tab="created"><?php esc_html_e( 'Created', 'learnpress' ); ?></a></li>
|
55 |
+
<?php endif; ?>
|
56 |
+
</ul>
|
57 |
+
|
58 |
+
<div class="learn-press-course-tab-enrolled learn-press-course-tab-filters" data-tab="enrolled" style="<?php echo $tab_active !== 'enrolled' ? 'display: none;' : ''; ?>">
|
59 |
+
<ul class="learn-press-filters">
|
60 |
+
<?php foreach ( $enrolleds as $key => $enrolled ) : ?>
|
61 |
+
<li>
|
62 |
+
<a class="<?php echo $key === $enrolled_active ? 'active' : ''; ?>" data-tab="<?php echo $key === '' ? 'all' : $key; ?>">
|
63 |
+
<?php echo esc_html( $enrolled ); ?>
|
64 |
+
</a>
|
65 |
+
</li>
|
66 |
+
<?php endforeach; ?>
|
67 |
+
</ul>
|
68 |
+
|
69 |
+
<div class="learn-press-profile-course__progress">
|
70 |
+
<?php foreach ( $enrolleds as $key => $enrolled ) : ?>
|
71 |
+
<div class="learn-press-course-tab__filter__content" data-tab="<?php echo $key === '' ? 'all' : $key; ?>" data-ajax="<?php echo htmlentities( wp_json_encode( [ 'userID' => $user->get_id(), 'status' => $key, 'query' => 'purchased', 'layout' => 'list' ] ) ); ?>" style="<?php echo $key !== $enrolled_active ? 'display: none' : ''; ?>"> <?php // phpcs:ignore ?>
|
72 |
+
<?php lp_skeleton_animation_html( 4, 'random', 'height: 30px;border-radius:4px;' ); ?>
|
73 |
+
</div>
|
74 |
+
<?php endforeach; ?>
|
75 |
+
</div>
|
76 |
+
</div>
|
77 |
+
|
78 |
+
<?php if ( learn_press_user_maybe_is_a_teacher() ) : ?>
|
79 |
+
<div class="learn-press-course-tab-created learn-press-course-tab-filters" data-tab="created" style="<?php echo $tab_active !== 'created' ? 'display: none;' : ''; ?>">
|
80 |
+
<ul class="learn-press-filters">
|
81 |
+
<?php foreach ( $createds as $key => $created ) : ?>
|
82 |
+
<li>
|
83 |
+
<a class="<?php echo $key === '' ? 'active' : ''; ?>" data-tab="<?php echo $key === '' ? 'all' : $key; ?>">
|
84 |
+
<?php echo esc_html( $created ); ?>
|
85 |
+
</a>
|
86 |
+
</li>
|
87 |
+
<?php endforeach; ?>
|
88 |
+
</ul>
|
89 |
|
90 |
+
<?php foreach ( $createds as $key => $created ) : ?>
|
91 |
+
<div class="learn-press-course-tab__filter__content" data-tab="<?php echo $key === '' ? 'all' : $key; ?>" data-ajax="<?php echo htmlentities( wp_json_encode( [ 'userID' => $user->get_id(), 'status' => $key, 'query' => 'own' ] ) ); ?>" style="<?php echo $key !== '' ? 'display: none' : ''; ?>"> <?php // phpcs:ignore ?>
|
92 |
+
<?php lp_skeleton_animation_html( 4, 'random', 'height: 30px;border-radius:4px;' ); ?>
|
93 |
+
</div>
|
94 |
+
<?php endforeach; ?>
|
95 |
+
</div>
|
96 |
+
<?php endif; ?>
|
97 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
</div>
|
templates/profile/tabs/courses/course-grid.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for displaying own courses in courses tab of user profile page.
|
4 |
+
* Edit by Nhamdv
|
5 |
+
*
|
6 |
+
* @author ThimPress
|
7 |
+
* @package Learnpress/Templates
|
8 |
+
* @version 4.0.9
|
9 |
+
*/
|
10 |
+
|
11 |
+
defined( 'ABSPATH' ) || exit();
|
12 |
+
?>
|
13 |
+
|
14 |
+
<?php if ( $current_page === 1 ) : ?>
|
15 |
+
<div class="lp-archive-courses">
|
16 |
+
<ul <?php lp_item_course_class( array( 'profile-courses-list' ) ); ?> data-layout="grid" data-size="3">
|
17 |
+
<?php endif; ?>
|
18 |
+
|
19 |
+
<?php
|
20 |
+
global $post;
|
21 |
+
|
22 |
+
foreach ( $course_ids as $id ) {
|
23 |
+
$course = learn_press_get_course( $id );
|
24 |
+
$post = get_post( $id );
|
25 |
+
setup_postdata( $post );
|
26 |
+
|
27 |
+
$course_data = $user->get_course_data( $id );
|
28 |
+
$course_results = $course_data->calculate_course_results();
|
29 |
+
learn_press_get_template( 'content-course.php' );
|
30 |
+
}
|
31 |
+
|
32 |
+
wp_reset_postdata();
|
33 |
+
?>
|
34 |
+
|
35 |
+
<?php if ( $current_page === 1 ) : ?>
|
36 |
+
</ul>
|
37 |
+
</div>
|
38 |
+
<?php endif; ?>
|
39 |
+
|
40 |
+
<?php if ( $num_pages > 1 && $current_page < $num_pages && $current_page === 1 ) : ?>
|
41 |
+
<div class="lp_profile_course_progress__nav">
|
42 |
+
<button data-paged="<?php echo absint( $current_page + 1 ); ?>" data-number="<?php echo absint( $num_pages ); ?>"><?php esc_html_e( 'View more', 'learnpress' ); ?></button>
|
43 |
+
</div>
|
44 |
+
<?php endif; ?>
|
templates/profile/tabs/courses/course-list.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for displaying own courses in courses tab of user profile page.
|
4 |
+
* Edit by Nhamdv
|
5 |
+
*
|
6 |
+
* @author ThimPress
|
7 |
+
* @package Learnpress/Templates
|
8 |
+
* @version 4.0.9
|
9 |
+
*/
|
10 |
+
|
11 |
+
defined( 'ABSPATH' ) || exit();
|
12 |
+
?>
|
13 |
+
|
14 |
+
<?php if ( $current_page === 1 ) : ?>
|
15 |
+
<div class="lp_profile_course_progress">
|
16 |
+
<div class="lp_profile_course_progress__item lp_profile_course_progress__header">
|
17 |
+
<div></div>
|
18 |
+
<div><?php esc_html_e( 'Name', 'learnpress' ); ?></div>
|
19 |
+
<div><?php esc_html_e( 'Result', 'learnpress' ); ?></div>
|
20 |
+
<div><?php esc_html_e( 'Expiration time', 'learnpress' ); ?></div>
|
21 |
+
<div><?php esc_html_e( 'End time', 'learnpress' ); ?></div>
|
22 |
+
</div>
|
23 |
+
<?php endif; ?>
|
24 |
+
|
25 |
+
<?php
|
26 |
+
global $post;
|
27 |
+
|
28 |
+
foreach ( $course_ids as $id ) {
|
29 |
+
$course = learn_press_get_course( $id );
|
30 |
+
$post = get_post( $id );
|
31 |
+
setup_postdata( $post );
|
32 |
+
|
33 |
+
$course_data = $user->get_course_data( $id );
|
34 |
+
$course_results = $course_data->calculate_course_results();
|
35 |
+
?>
|
36 |
+
<div class="lp_profile_course_progress__item">
|
37 |
+
<div><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php echo $course->get_image( 'course_thumbnail' ); ?></a></div>
|
38 |
+
<div><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
|
39 |
+
<div><?php echo absint( $course_results['result'] ); ?>%</div>
|
40 |
+
<div><?php echo ! empty( $course_data->get_expiration_time() ) ? $course_data->get_expiration_time() : '-'; ?></div>
|
41 |
+
<div><?php echo ! empty( $course_data->get_end_time() ) ? $course_data->get_end_time() : '-'; ?></div>
|
42 |
+
</div>
|
43 |
+
<?php
|
44 |
+
}
|
45 |
+
|
46 |
+
wp_reset_postdata();
|
47 |
+
?>
|
48 |
+
|
49 |
+
<?php if ( $current_page === 1 ) : ?>
|
50 |
+
</div>
|
51 |
+
<?php endif; ?>
|
52 |
+
|
53 |
+
<?php if ( $num_pages > 1 && $current_page < $num_pages && $current_page === 1 ) : ?>
|
54 |
+
<div class="lp_profile_course_progress__nav">
|
55 |
+
<button data-paged="<?php echo absint( $current_page + 1 ); ?>" data-number="<?php echo absint( $num_pages ); ?>"><?php esc_html_e( 'View more', 'learnpress' ); ?></button>
|
56 |
+
</div>
|
57 |
+
<?php endif; ?>
|
templates/profile/tabs/courses/created.php
DELETED
@@ -1,74 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template for displaying own courses in courses tab of user profile page.
|
4 |
-
* Edit by Nhamdv
|
5 |
-
*
|
6 |
-
* @author ThimPress
|
7 |
-
* @package Learnpress/Templates
|
8 |
-
* @version 4.0.0
|
9 |
-
*/
|
10 |
-
|
11 |
-
defined( 'ABSPATH' ) || exit();
|
12 |
-
|
13 |
-
$profile = learn_press_get_profile();
|
14 |
-
$user = LP_Profile::instance()->get_user();
|
15 |
-
$filter_status = LP_Request::get_string( 'filter-status' );
|
16 |
-
$query = $profile->query_courses( 'own', array( 'status' => $filter_status ) );
|
17 |
-
$counts = $query['counts'];
|
18 |
-
$filters = $profile->get_own_courses_filters( $filter_status );
|
19 |
-
?>
|
20 |
-
|
21 |
-
<div class="learn-press-subtab-content">
|
22 |
-
<?php if ( $filters ) : ?>
|
23 |
-
<ul class="learn-press-filters">
|
24 |
-
<?php
|
25 |
-
foreach ( $filters as $class => $link ) {
|
26 |
-
$count = ! empty( $counts[ $class ] ) ? absint( $counts[ $class ] ) : false;
|
27 |
-
|
28 |
-
if ( $count ) {
|
29 |
-
?>
|
30 |
-
<li class="<?php echo esc_attr( $class ); ?>">
|
31 |
-
<?php printf( '%s <span class="count">%s</span>', $link, $count ); ?>
|
32 |
-
</li>
|
33 |
-
<?php
|
34 |
-
}
|
35 |
-
}
|
36 |
-
?>
|
37 |
-
</ul>
|
38 |
-
<?php endif; ?>
|
39 |
-
|
40 |
-
<?php if ( ! $query['total'] ) : ?>
|
41 |
-
<?php learn_press_display_message( esc_html__( 'No courses!', 'learnpress' ) ); ?>
|
42 |
-
<?php else : ?>
|
43 |
-
<div class="lp-archive-courses">
|
44 |
-
<ul <?php lp_item_course_class(array('profile-courses-list'));?> id="learn-press-profile-created-courses" data-layout="grid" data-size="3">
|
45 |
-
<?php
|
46 |
-
global $post;
|
47 |
-
|
48 |
-
foreach ( $query['items'] as $item ) {
|
49 |
-
$course = learn_press_get_course( $item );
|
50 |
-
$post = get_post( $item );
|
51 |
-
setup_postdata( $post );
|
52 |
-
learn_press_get_template( 'content-course.php' );
|
53 |
-
}
|
54 |
-
|
55 |
-
wp_reset_postdata();
|
56 |
-
?>
|
57 |
-
</ul>
|
58 |
-
</div>
|
59 |
-
|
60 |
-
<?php
|
61 |
-
$num_pages = $query->get_pages();
|
62 |
-
$current_page = $query->get_paged();
|
63 |
-
?>
|
64 |
-
|
65 |
-
<?php if ( $num_pages > 1 && $current_page < $num_pages ) : ?>
|
66 |
-
<button data-container="learn-press-profile-created-courses"
|
67 |
-
data-pages="<?php echo $num_pages; ?>"
|
68 |
-
data-paged="<?php echo $current_page; ?>"
|
69 |
-
class="lp-button btn-load-more-courses btn-ajax-off">
|
70 |
-
<i class="fas fa-spinner icon"></i>
|
71 |
-
<?php esc_html_e( 'View More', 'learnpress' ); ?></button>
|
72 |
-
<?php endif; ?>
|
73 |
-
<?php endif; ?>
|
74 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/profile/tabs/courses/enrolled.php
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template for displaying purchased courses in courses tab of user profile page.
|
4 |
-
*
|
5 |
-
* @author ThimPress
|
6 |
-
* @package Learnpress/Templates
|
7 |
-
* @version 4.0.0
|
8 |
-
*/
|
9 |
-
|
10 |
-
defined( 'ABSPATH' ) || exit();
|
11 |
-
|
12 |
-
$profile = learn_press_get_profile();
|
13 |
-
$filter_status = LP_Request::get_string( 'filter-status' );
|
14 |
-
$query = $profile->query_courses( 'purchased', array( 'status' => $filter_status ) );
|
15 |
-
$counts = $query['counts'];
|
16 |
-
$filters = $profile->get_purchased_courses_filters( $filter_status );
|
17 |
-
?>
|
18 |
-
|
19 |
-
<div class="learn-press-subtab-content">
|
20 |
-
|
21 |
-
<?php if ( $filters ) : ?>
|
22 |
-
<ul class="learn-press-filters">
|
23 |
-
<?php
|
24 |
-
foreach ( $filters as $class => $link ) {
|
25 |
-
$count = ! empty( $counts[ $class ] ) ? $counts[ $class ] : false;
|
26 |
-
|
27 |
-
if ( $count !== false ) {
|
28 |
-
?>
|
29 |
-
|
30 |
-
<li class="<?php echo esc_attr( $class ); ?>">
|
31 |
-
<?php echo sprintf( '%s <span class="count">%s</span>', $link, $count ); ?>
|
32 |
-
</li>
|
33 |
-
<?php
|
34 |
-
}
|
35 |
-
}
|
36 |
-
?>
|
37 |
-
</ul>
|
38 |
-
<?php endif; ?>
|
39 |
-
|
40 |
-
<?php if ( $query['items'] ) : ?>
|
41 |
-
<div class="lp-archive-courses">
|
42 |
-
<ul <?php lp_item_course_class(array('profile-courses-list'));?> id="learn-press-profile-enrolled-courses" data-layout="grid" data-size="3">
|
43 |
-
<?php
|
44 |
-
global $post;
|
45 |
-
|
46 |
-
foreach ( $query['items'] as $item ) {
|
47 |
-
$course = learn_press_get_course( $item->get_id() );
|
48 |
-
$post = get_post( $item->get_id() );
|
49 |
-
setup_postdata( $post );
|
50 |
-
learn_press_get_template( 'content-course.php' );
|
51 |
-
}
|
52 |
-
|
53 |
-
wp_reset_postdata();
|
54 |
-
?>
|
55 |
-
</ul>
|
56 |
-
</div>
|
57 |
-
|
58 |
-
<?php
|
59 |
-
$num_pages = $query->get_pages();
|
60 |
-
$current_page = $query->get_paged();
|
61 |
-
?>
|
62 |
-
|
63 |
-
<?php if ( $num_pages > 1 && $current_page < $num_pages ) : ?>
|
64 |
-
<button data-container="learn-press-profile-enrolled-courses"
|
65 |
-
data-pages="<?php echo $num_pages; ?>"
|
66 |
-
data-paged="<?php echo $current_page; ?>"
|
67 |
-
class="lp-button btn-load-more-courses btn-ajax-off">
|
68 |
-
<i class="fas fa-spinner icon"></i>
|
69 |
-
<?php esc_html_e( 'View More', 'learnpress' ); ?></button>
|
70 |
-
<?php endif; ?>
|
71 |
-
|
72 |
-
<?php else : ?>
|
73 |
-
<?php learn_press_display_message( esc_html__( 'No courses!', 'learnpress' ) ); ?>
|
74 |
-
<?php endif; ?>
|
75 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/profile/{dashboard → tabs/courses}/general-statistic.php
RENAMED
File without changes
|
templates/profile/tabs/courses/index.php
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Template for displaying index of courses tab of user profile page.
|
4 |
-
*
|
5 |
-
* This template can be overridden by copying it to yourtheme/learnpress/courses/index.php.
|
6 |
-
*
|
7 |
-
* @author ThimPress
|
8 |
-
* @package Learnpress/Templates
|
9 |
-
* @version 3.0.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
defined( 'ABSPATH' ) || exit();
|
13 |
-
?>
|
14 |
-
|
15 |
-
<a href="<?php the_permalink(); ?>" class="course-title">
|
16 |
-
<?php do_action( 'learn_press_courses_loop_item_title' ); ?>
|
17 |
-
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/profile/tabs/quizzes.php
CHANGED
@@ -9,6 +9,10 @@
|
|
9 |
|
10 |
defined( 'ABSPATH' ) || exit();
|
11 |
|
|
|
|
|
|
|
|
|
12 |
$profile = learn_press_get_profile();
|
13 |
$filter_status = LP_Request::get_string( 'filter-status' );
|
14 |
$query = $profile->query_quizzes( array( 'status' => $filter_status ) );
|
9 |
|
10 |
defined( 'ABSPATH' ) || exit();
|
11 |
|
12 |
+
if ( ! LP_Profile::instance()->current_user_can( 'view-tab-quizzes' ) ) {
|
13 |
+
return;
|
14 |
+
}
|
15 |
+
|
16 |
$profile = learn_press_get_profile();
|
17 |
$filter_status = LP_Request::get_string( 'filter-status' );
|
18 |
$query = $profile->query_quizzes( array( 'status' => $filter_status ) );
|
templates/single-course/tabs/instructor.php
CHANGED
@@ -12,6 +12,9 @@
|
|
12 |
defined( 'ABSPATH' ) || exit();
|
13 |
|
14 |
$course = LP_Global::course();
|
|
|
|
|
|
|
15 |
$instructor = $course->get_instructor();
|
16 |
?>
|
17 |
|
@@ -23,7 +26,7 @@ $instructor = $course->get_instructor();
|
|
23 |
<div class="course-author__pull-left">
|
24 |
<?php echo $instructor->get_profile_picture(); ?>
|
25 |
|
26 |
-
<?php $socials = $instructor->get_profile_socials(); ?>
|
27 |
<?php if ( $socials ) : ?>
|
28 |
<div class="author-socials">
|
29 |
<?php echo implode( '', $socials ); ?>
|
12 |
defined( 'ABSPATH' ) || exit();
|
13 |
|
14 |
$course = LP_Global::course();
|
15 |
+
/**
|
16 |
+
* @var LP_User
|
17 |
+
*/
|
18 |
$instructor = $course->get_instructor();
|
19 |
?>
|
20 |
|
26 |
<div class="course-author__pull-left">
|
27 |
<?php echo $instructor->get_profile_picture(); ?>
|
28 |
|
29 |
+
<?php $socials = $instructor->get_profile_socials( $instructor->get_id() ); ?>
|
30 |
<?php if ( $socials ) : ?>
|
31 |
<div class="author-socials">
|
32 |
<?php echo implode( '', $socials ); ?>
|