| @@ -1,63 +1,147 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Template for displaying orders statistics tab Courses statistics page. | |
| 3 | + * Template for displaying the Courses statistics dashboard tab. | |
| 4 | + * | |
| 5 | + * Data is rendered by assets/src/js/admin/statistics/tab-courses.js from the | |
| 6 | + * `dashboard` key of the course-statistics endpoint. | |
| 7 | + * | |
| 8 | + * @since 4.4.2 | |
| 4 | 9 | */ |
| 10 | + | |
| 11 | +defined( 'ABSPATH' ) || exit(); | |
| 12 | + | |
| 13 | +$kpi_cards = array( | |
| 14 | + 'published' => __( 'Published courses', 'learnpress' ), | |
| 15 | + 'pending-review' => __( 'Pending review', 'learnpress' ), | |
| 16 | + 'future' => __( 'Future courses', 'learnpress' ), | |
| 17 | + 'enrollments' => __( 'Enrollments', 'learnpress' ), | |
| 18 | + 'avg-completion' => __( 'Avg. completion', 'learnpress' ), | |
| 19 | + 'courses-without-enrollment' => __( 'Courses without enrollment', 'learnpress' ), | |
| 20 | +); | |
| 21 | + | |
| 22 | +$health_checks = array( | |
| 23 | + 'no_curriculum' => array( | |
| 24 | + 'label' => __( 'Published courses with an empty curriculum', 'learnpress' ), | |
| 25 | + 'url' => admin_url( 'edit.php?post_type=lp_course&post_status=publish' ), | |
| 26 | + ), | |
| 27 | + 'no_students' => array( | |
| 28 | + 'label' => __( 'Published courses without any enrollment', 'learnpress' ), | |
| 29 | + 'url' => admin_url( 'edit.php?post_type=lp_course&post_status=publish' ), | |
| 30 | + ), | |
| 31 | + 'low_completion' => array( | |
| 32 | + 'label' => __( 'Courses below the completion target', 'learnpress' ), | |
| 33 | + 'url' => admin_url( 'admin.php?page=learn-press-statistics&tab=courses' ), | |
| 34 | + ), | |
| 35 | + 'low_quiz_pass' => array( | |
| 36 | + 'label' => __( 'Quizzes with a low pass rate', 'learnpress' ), | |
| 37 | + 'url' => admin_url( 'edit.php?post_type=lp_quiz' ), | |
| 38 | + ), | |
| 39 | + 'pending_review' => array( | |
| 40 | + 'label' => __( 'Courses waiting for review', 'learnpress' ), | |
| 41 | + 'url' => admin_url( 'edit.php?post_type=lp_course&post_status=pending' ), | |
| 42 | + ), | |
| 43 | +); | |
| 44 | + | |
| 45 | +// Section config filters — add/remove/relabel cards and lists. @since 4.4.2 | |
| 46 | +$kpi_cards = (array) apply_filters( 'learn-press/statistics/courses/kpi-cards', $kpi_cards ); | |
| 47 | +$health_checks = (array) apply_filters( 'learn-press/statistics/courses/health-checks', $health_checks ); | |
| 5 | 48 | ?> |
| 49 | +<div class="lp-admin-statistics-tab-content lp-stats-tab-courses"> | |
| 50 | + <?php | |
| 51 | + /** | |
| 52 | + * Fires at the top of the Courses statistics tab, inside the tab container. | |
| 53 | + * | |
| 54 | + * @since 4.4.2 | |
| 55 | + */ | |
| 56 | + do_action( 'learn-press/statistics/courses/before' ); | |
| 6 | 57 | |
| 7 | -<div class="lp-admin-statistics-tab-content"> | |
| 8 | - <div class="btn-group btn-group-filter"> | |
| 9 | - <button class="btn-filter-time active" type="button" data-filter="today" ><?php _e( 'Today', 'learnpress' ); ?></button> | |
| 10 | - <!-- <button class="btn-filter-time" type="button" data-filter="yesterday" ><?php _e( 'Yesterday', 'learnpress' ); ?></button> --> | |
| 11 | - <button class="btn-filter-time" type="button" data-filter="last7days" ><?php _e( 'Last 7 days', 'learnpress' ); ?></button> | |
| 12 | - <button class="btn-filter-time" type="button" data-filter="last30days" ><?php _e( 'Last 30 days', 'learnpress' ); ?></button> | |
| 13 | - <!-- <button class="btn-filter-time" type="button" data-filter="thismonth" ><?php _e( 'This month', 'learnpress' ); ?></button> --> | |
| 14 | - <button class="btn-filter-time" type="button" data-filter="last12months"><?php _e( 'Last 12 months', 'learnpress' ); ?></button> | |
| 15 | - <button class="btn-filter-time" type="button" data-filter="thisyear" ><?php _e( 'This year', 'learnpress' ); ?></button> | |
| 16 | - <button class="btn-filter-time" type="button" data-filter="custom" ><?php _e( 'Custom', 'learnpress' ); ?></button> | |
| 17 | - <div class="custom-filter-time"> | |
| 18 | - <input type="date" id="ct-filter-1" /> | |
| 19 | - <input type="date" id="ct-filter-2"> | |
| 20 | - <button class="custom-filter-btn button button-primary" type="button"><?php _e( 'Filter', 'learnpress' ); ?></button> | |
| 58 | + learn_press_admin_view( 'statistics/parts/filter-bar' ); | |
| 59 | + ?> | |
| 60 | + | |
| 61 | + <div class="lp-stats-dashboard-body"> | |
| 62 | + <div class="lp-stats-kpi-grid"> | |
| 63 | + <?php foreach ( $kpi_cards as $key => $title ) : ?> | |
| 64 | + <?php if ( 'avg-completion' === $key ) : ?> | |
| 65 | + <div class="lp-kpi-card lp-kpi-<?php echo esc_attr( $key ); ?>"> | |
| 66 | + <span class="lp-kpi-title"><?php echo esc_html( $title ); ?></span> | |
| 67 | + <span class="lp-kpi-value">–</span> | |
| 68 | + <span class="lp-kpi-delta"></span> | |
| 69 | + <span class="lp-kpi-subline"></span> | |
| 70 | + <span class="lp-kpi-progress"><span class="lp-kpi-progress__bar" style="width: 0;"></span></span> | |
| 71 | + </div> | |
| 72 | + <?php else : ?> | |
| 73 | + <?php | |
| 74 | + learn_press_admin_view( | |
| 75 | + 'statistics/parts/kpi-card', | |
| 76 | + array( | |
| 77 | + 'key' => $key, | |
| 78 | + 'title' => $title, | |
| 79 | + ) | |
| 80 | + ); | |
| 81 | + ?> | |
| 82 | + <?php endif; ?> | |
| 83 | + <?php endforeach; ?> | |
| 21 | 84 | </div> |
| 22 | - </div> | |
| 23 | - <div class="statistics-content"> | |
| 24 | - <input class="statistics-type" type="hidden" value="courses-statistics"> | |
| 25 | - <div class="statistics-group"> | |
| 26 | - <div class="statistics-item"> | |
| 27 | - <span class="statistics-item-title"><?php _e( 'Total Courses', 'learnpress' ); ?></span> | |
| 28 | - <span class="statistics-item-count statistics-courses total">0</span> | |
| 85 | + | |
| 86 | + <div class="lp-stats-overview-grid lp-stats-overview-grid--chart"> | |
| 87 | + <div class="lp-stats-section statistics-content"> | |
| 88 | + <div class="lp-stats-section__header"> | |
| 89 | + <div> | |
| 90 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Course publishing and enrollment', 'learnpress' ); ?></h3> | |
| 91 | + <p class="lp-stats-section__description"><?php esc_html_e( 'Course creation, enrollment, and completion trend for content operations.', 'learnpress' ); ?></p> | |
| 92 | + </div> | |
| 93 | + </div> | |
| 94 | + <div id="course-chart" class="statistics-chart-wrapper"> | |
| 95 | + <?php lp_skeleton_animation_html( 10, 100 ); ?> | |
| 96 | + <canvas id="course-chart-content" style="display: none;"></canvas> | |
| 97 | + </div> | |
| 29 | 98 | </div> |
| 30 | - <div class="statistics-item"> | |
| 31 | - <span class="statistics-item-title"><?php _e( 'Published Courses', 'learnpress' ); ?></span> | |
| 32 | - <span class="statistics-item-count statistics-courses published">0</span> | |
| 99 | + | |
| 100 | + <div class="lp-stats-section"> | |
| 101 | + <div class="lp-stats-section__header"> | |
| 102 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Course health checks', 'learnpress' ); ?></h3> | |
| 103 | + </div> | |
| 104 | + <ul class="lp-stats-health-checks"> | |
| 105 | + <?php foreach ( $health_checks as $check => $item ) : ?> | |
| 106 | + <li> | |
| 107 | + <a href="<?php echo esc_url( $item['url'] ); ?>"> | |
| 108 | + <span class="lp-stats-health-check__count" data-check="<?php echo esc_attr( $check ); ?>">–</span> | |
| 109 | + <?php echo esc_html( $item['label'] ); ?> | |
| 110 | + </a> | |
| 111 | + </li> | |
| 112 | + <?php endforeach; ?> | |
| 113 | + </ul> | |
| 33 | 114 | </div> |
| 34 | - <div class="statistics-item"> | |
| 35 | - <span class="statistics-item-title"><?php _e( 'Pending Courses', 'learnpress' ); ?></span> | |
| 36 | - <span class="statistics-item-count statistics-courses pending">0</span> | |
| 115 | + </div> | |
| 116 | + | |
| 117 | + <div class="lp-stats-overview-grid lp-stats-overview-grid--tables"> | |
| 118 | + <div class="lp-stats-section"> | |
| 119 | + <div class="lp-stats-section__header"> | |
| 120 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Course performance', 'learnpress' ); ?></h3> | |
| 121 | + <button type="button" class="button-link lp-stats-section__action lp-stats-view-all-performance"><?php esc_html_e( 'Open report', 'learnpress' ); ?></button> | |
| 122 | + </div> | |
| 123 | + <?php lp_skeleton_animation_html( 5, 100 ); ?> | |
| 124 | + <div class="lp-stats-table-course-performance"></div> | |
| 37 | 125 | </div> |
| 38 | - <div class="statistics-item"> | |
| 39 | - <span class="statistics-item-title"><?php _e( 'Future Courses', 'learnpress' ); ?></span> | |
| 40 | - <span class="statistics-item-count statistics-courses future">0</span> | |
| 126 | + | |
| 127 | + <div class="lp-stats-section"> | |
| 128 | + <div class="lp-stats-section__header"> | |
| 129 | + <h3 class="lp-stats-section__title"><?php esc_html_e( 'Content inventory', 'learnpress' ); ?></h3> | |
| 130 | + </div> | |
| 131 | + <?php lp_skeleton_animation_html( 4, 100 ); ?> | |
| 132 | + <div class="lp-stats-table-content-inventory"></div> | |
| 41 | 133 | </div> |
| 42 | - <div class="statistics-item"> | |
| 43 | - <span class="statistics-item-title"><?php _e( 'Lessons', 'learnpress' ); ?></span> | |
| 44 | - <span class="statistics-item-count statistics-items lessons">0</span> | |
| 45 | - </div> | |
| 46 | - <div class="statistics-item"> | |
| 47 | - <span class="statistics-item-title"><?php _e( 'Quizes', 'learnpress' ); ?></span> | |
| 48 | - <span class="statistics-item-count statistics-items quizes">0</span> | |
| 49 | - </div> | |
| 50 | - <?php if ( class_exists( 'LP_Assignment' ) ) : ?> | |
| 51 | - <div class="statistics-item"> | |
| 52 | - <span class="statistics-item-title"><?php _e( 'Assginments', 'learnpress' ); ?></span> | |
| 53 | - <span class="statistics-item-count statistics-items assignment">0</span> | |
| 54 | - </div> | |
| 55 | - <?php endif; ?> | |
| 56 | 134 | </div> |
| 57 | - <h3 class="statistics-title"><?php _e( 'Published Courses', 'learnpress' ); ?></h3> | |
| 58 | - <div id="course-chart" class="statistics-chart-wrapper"> | |
| 59 | - <?php lp_skeleton_animation_html( 10, 100 ); ?> | |
| 60 | - <canvas id="course-chart-content" style="display: none;"></canvas> | |
| 61 | - </div> | |
| 62 | 135 | </div> |
| 136 | + | |
| 137 | + <?php | |
| 138 | + learn_press_admin_view( 'statistics/parts/report-modal' ); | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Fires at the bottom of the Courses statistics tab, inside the tab container. | |
| 142 | + * | |
| 143 | + * @since 4.4.2 | |
| 144 | + */ | |
| 145 | + do_action( 'learn-press/statistics/courses/after' ); | |
| 146 | + ?> | |
| 63 | 147 | </div> |