PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | assets/src/js/frontend/profile/statistic.js +54 -54 4.3.8 → 4.4.9 View file →
@@ -1,54 +1,54 @@
1 -import { lpAddQueryArgs, lpFetchAPI, lpOnElementReady } from '../../utils.js';
2 -
3 -// Rest API load content course progress - Nhamdv.
4 -const courseStatistics = () => {
5 - const loadAPICourseStatistic = ( elCourseStatistic ) => {
6 - let apiUrl = 'lp/v1/profile/student/statistic';
7 - const tabActive = document.querySelector( '.lp-profile-nav-tabs li.active' );
8 - if ( ! tabActive ) {
9 - return;
10 - }
11 -
12 - if ( tabActive.classList.contains( 'courses' ) ) {
13 - apiUrl = 'lp/v1/profile/instructor/statistic';
14 - }
15 -
16 - const elArgStatistic = elCourseStatistic.querySelector( '[name="args_query_user_courses_statistic"]' );
17 - if ( ! elArgStatistic ) {
18 - return;
19 - }
20 -
21 - const data = JSON.parse( elArgStatistic.value );
22 -
23 - const callBack = {
24 - success: ( response ) => {
25 - if ( response.status === 'success' && response.data ) {
26 - elCourseStatistic.innerHTML = response.data;
27 - } else {
28 - elCourseStatistic.innerHTML = `<div class="lp-ajax-message error" style="display:block">${ response.message && response.message }</div>`;
29 - }
30 - },
31 - error: ( error ) => {
32 - console.log( error );
33 - },
34 - completed: () => {
35 -
36 - },
37 - };
38 -
39 - apiUrl = lpAddQueryArgs( lpData.lp_rest_url + apiUrl, data );
40 -
41 - if ( 0 !== parseInt( lpData.user_id ) ) {
42 - data.headers = {
43 - 'X-WP-Nonce': lpData.nonce,
44 - };
45 - }
46 - lpFetchAPI( apiUrl, data, callBack );
47 - };
48 -
49 - lpOnElementReady( '.learn-press-profile-course__statistic', ( elCourseStatistic ) => {
50 - loadAPICourseStatistic( elCourseStatistic );
51 - } );
52 -};
53 -
54 -export default courseStatistics;
1 +import { lpAddQueryArgs, lpFetchAPI, lpOnElementReady } from '../../utils.js';
2 +
3 +// Rest API load content course progress - Nhamdv.
4 +const courseStatistics = () => {
5 + const loadAPICourseStatistic = ( elCourseStatistic ) => {
6 + let apiUrl = 'lp/v1/profile/student/statistic';
7 + const tabActive = document.querySelector( '.lp-profile-nav-tabs li.active' );
8 + if ( ! tabActive ) {
9 + return;
10 + }
11 +
12 + if ( tabActive.classList.contains( 'courses' ) ) {
13 + apiUrl = 'lp/v1/profile/instructor/statistic';
14 + }
15 +
16 + const elArgStatistic = elCourseStatistic.querySelector( '[name="args_query_user_courses_statistic"]' );
17 + if ( ! elArgStatistic ) {
18 + return;
19 + }
20 +
21 + const data = JSON.parse( elArgStatistic.value );
22 +
23 + const callBack = {
24 + success: ( response ) => {
25 + if ( response.status === 'success' && response.data ) {
26 + elCourseStatistic.innerHTML = response.data;
27 + } else {
28 + elCourseStatistic.innerHTML = `<div class="lp-ajax-message error" style="display:block">${ response.message && response.message }</div>`;
29 + }
30 + },
31 + error: ( error ) => {
32 + console.log( error );
33 + },
34 + completed: () => {
35 +
36 + },
37 + };
38 +
39 + apiUrl = lpAddQueryArgs( lpData.lp_rest_url + apiUrl, data );
40 +
41 + if ( 0 !== parseInt( lpData.user_id ) ) {
42 + data.headers = {
43 + 'X-WP-Nonce': lpData.nonce,
44 + };
45 + }
46 + lpFetchAPI( apiUrl, data, callBack );
47 + };
48 +
49 + lpOnElementReady( '.learn-press-profile-course__statistic', ( elCourseStatistic ) => {
50 + loadAPICourseStatistic( elCourseStatistic );
51 + } );
52 +};
53 +
54 +export default courseStatistics;