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.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / dashboard / student / stats.php
tutor / templates / dashboard / student Last commit date
continue-learning.php 1 day ago dashboard-empty.php 1 day ago dashboard.php 1 day ago stat-card.php 1 day ago stats.php 1 day ago time-spent-modal.php 1 day ago
stats.php
113 lines
1 <?php
2 /**
3 * Student Dashboard Stats Container Template
4 *
5 * @package Tutor\Templates
6 * @subpackage Dashboard
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 4.0.0
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Tutor\Models\CourseModel;
15 use TUTOR\Icon;
16
17 $user_id = $user_id ?? get_current_user_id();
18 $user_data = $user_data ?? get_userdata( $user_id );
19
20 // Query metrics and stats data.
21 $enrolled_course = CourseModel::get_enrolled_courses_by_user( $user_id, array( 'private', 'publish' ) );
22 $completed_courses = CourseModel::get_completed_courses_by_user( $user_id, 0, -1, array( 'post_status' => array( 'private', 'publish' ) ) );
23 $has_completed_courses = is_object( $completed_courses ) && $completed_courses->have_posts();
24 $active_courses = CourseModel::get_active_courses_by_user( $user_id, 0, -1, array( 'post_status' => array( 'private', 'publish' ) ) );
25
26 $enrolled_course_count = $enrolled_course ? $enrolled_course->post_count : 0;
27 $completed_course_count = $has_completed_courses ? $completed_courses->post_count : 0;
28 $active_course_count = is_object( $active_courses ) && $active_courses->have_posts() ? $active_courses->post_count : 0;
29 $enrolled_courses_ids = $enrolled_course_count ? wp_list_pluck( $enrolled_course->posts, 'ID' ) : array();
30
31 // Time spent calculation.
32 $time_spent = CourseModel::get_total_estimated_time_spent( $enrolled_courses_ids );
33 $is_hour_format = $time_spent['hours'] > 0;
34 $has_time_spent = $is_hour_format || $time_spent['minutes'] > 0;
35 $time_spent_value = $is_hour_format ? $time_spent['hours'] : $time_spent['minutes'];
36
37 $time_spent_unit = $is_hour_format
38 ? _x( 'h+', 'abbreviation for hours with plus sign', 'tutor' )
39 : _x( 'm+', 'abbreviation for minutes with plus sign', 'tutor' );
40
41 $time_spent_unit_modal = $is_hour_format
42 ? _x( 'hours', 'time unit', 'tutor' )
43 : _x( 'minutes', 'time unit', 'tutor' );
44
45 $time_spent_card_value = $has_time_spent ? sprintf(
46 /* translators: 1: total time spent 2: Unit. */
47 __( '%1$d %2$s', 'tutor' ),
48 $time_spent_value,
49 $time_spent_unit
50 ) : '0';
51
52 $time_spent_modal_value = sprintf(
53 /* translators: 1: total time spent 2: Unit. */
54 __( '%1$d+ %2$s', 'tutor' ),
55 $time_spent_value,
56 $time_spent_unit_modal
57 );
58
59 $cards = array(
60 array(
61 'title' => __( 'Enrolled Courses', 'tutor' ),
62 'icon' => Icon::COURSES,
63 'value' => $enrolled_course_count,
64 'url' => tutor_utils()->tutor_dashboard_url( 'courses' ),
65 'class' => 'tutor-stat-card-enrolled',
66 ),
67 array(
68 'title' => __( 'Active', 'tutor' ),
69 'icon' => Icon::PLAY_LINE,
70 'value' => $active_course_count,
71 'url' => tutor_utils()->tutor_dashboard_url( 'courses/active-courses' ),
72 'class' => 'tutor-stat-card-active',
73 ),
74 array(
75 'title' => __( 'Completed', 'tutor' ),
76 'icon' => Icon::COMPLETED_CIRCLE,
77 'value' => $completed_course_count,
78 'url' => tutor_utils()->tutor_dashboard_url( 'courses/completed-courses' ),
79 'class' => 'tutor-stat-card-completed',
80 ),
81 array(
82 'title' => __( 'Time Spent', 'tutor' ),
83 'icon' => Icon::TIME,
84 'value' => $time_spent_card_value,
85 'class' => 'tutor-stat-card-time-spent',
86 'modal_id' => $has_time_spent ? 'tutor-time-spent-modal' : '',
87 ),
88 );
89 ?>
90
91 <div class="tutor-student-dashboard-stats" x-data>
92 <div class="tutor-grid tutor-sm-grid-cols-2 tutor-gap-5 tutor-mb-7 tutor-grid-cols-4">
93 <?php
94 foreach ( $cards as $card ) {
95 tutor_load_template( 'dashboard.student.stat-card', $card );
96 }
97 ?>
98 </div>
99
100 <?php if ( $has_time_spent ) : ?>
101 <?php
102 tutor_load_template(
103 'dashboard.student.time-spent-modal',
104 array(
105 'user_data' => $user_data,
106 'time_spent' => $time_spent,
107 'time_spent_value' => $time_spent_modal_value,
108 )
109 );
110 ?>
111 <?php endif; ?>
112 </div>
113