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.2 3.5.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 / learning-area / subpages / reviews.php
tutor / templates / learning-area / subpages Last commit date
qna 4 days ago reviews 4 days ago announcements.php 4 days ago course-info.php 4 days ago qna.php 4 days ago reviews.php 4 days ago
reviews.php
185 lines
1 <?php
2 /**
3 * Tutor learning area reviews.
4 *
5 * @package Tutor\Templates
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 4.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 use TUTOR\Icon;
14 use TUTOR\Input;
15 use Tutor\Components\Button;
16 use Tutor\Components\ConfirmationModal;
17 use Tutor\Components\Constants\Size;
18 use Tutor\Components\Constants\Variant;
19 use Tutor\Components\EmptyState;
20 use Tutor\Components\Modal;
21 use Tutor\Components\Pagination;
22 use Tutor\Components\Progress;
23 use Tutor\Components\StarRating;
24 use Tutor\Components\SvgIcon;
25
26 // Get course ID from global variable set in learning-area/index.php .
27 global $tutor_course_id,
28 $current_user_id,
29 $tutor_is_enrolled;
30
31 // Pagination setup.
32 $review_per_page = tutor_utils()->get_option( 'pagination_per_page', 10 );
33 $current_page = max( 1, Input::get( 'current_page', 1, Input::TYPE_INT ) );
34 $offset = ( $current_page - 1 ) * $review_per_page;
35
36 $course_rating = tutor_utils()->get_course_rating( $tutor_course_id );
37 $total_items = (int) tutor_utils()->get_course_reviews( $tutor_course_id, null, null, true, array( 'approved' ), $current_user_id );
38 $reviews = tutor_utils()->get_course_reviews( $tutor_course_id, $offset, $review_per_page, false, array( 'approved' ), $current_user_id );
39 $my_rating = tutor_utils()->get_reviews_by_user( 0, 0, null, false, $tutor_course_id, array( 'approved', 'hold' ) );
40
41 if ( ! empty( $my_rating ) ) {
42 $my_rating = is_array( $my_rating ) ? $my_rating[0] : $my_rating;
43 $my_rating_id = $my_rating->comment_ID;
44
45 $reviews = array_filter(
46 $reviews,
47 function ( $review ) use ( $my_rating_id ) {
48 return $review->comment_ID !== $my_rating_id;
49 }
50 );
51
52 $reviews = array_values( $reviews );
53 array_unshift( $reviews, $my_rating );
54 }
55
56 ?>
57
58 <div class="tutor-py-8 tutor-learning-area-reviews">
59 <div class="tutor-flex tutor-items-center tutor-justify-between tutor-mb-5">
60 <h4 class="tutor-h4 tutor-flex tutor-items-center tutor-gap-4">
61 <?php SvgIcon::make()->name( Icon::RATINGS )->size( 24 )->render(); ?>
62 <?php esc_html_e( 'Reviews', 'tutor' ); ?>
63 </h4>
64 <?php
65 if ( $tutor_is_enrolled && empty( $my_rating ) ) {
66 ?>
67 <div>
68 <?php
69 Button::make()
70 ->label( __( 'Write a Review', 'tutor' ) )
71 ->size( Size::SMALL )
72 ->attr( 'x-on:click', 'TutorCore.modal.showModal("create-review-modal")' )
73 ->render();
74
75 $modal_template = tutor_get_template( 'learning-area.subpages.reviews.create-review-modal' );
76 Modal::make()
77 ->id( 'create-review-modal' )
78 ->title( __( 'How Was Your Experience?', 'tutor' ) )
79 ->subtitle( __( 'Your feedback helps others find the right course.', 'tutor' ) )
80 ->width( '452px' )
81 ->template( $modal_template )
82 ->render();
83 ?>
84 </div>
85 <?php
86 }
87 ?>
88 </div>
89
90 <div class="tutor-card tutor-card-rounded-2xl tutor-p-none">
91 <?php if ( empty( $reviews ) ) : ?>
92 <?php
93 EmptyState::make()
94 ->title( __( 'No Reviews Found!', 'tutor' ) )
95 ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/reviews-empty.svg' ) )
96 ->render();
97 ?>
98 <?php else : ?>
99 <div class="tutor-grid tutor-grid-cols-2 tutor-sm-grid-cols-1 tutor-gap-4 tutor-sm-gap-6 tutor-p-6">
100 <div class="tutor-flex tutor-flex-column tutor-gap-4 tutor-justify-between">
101 <div class="tutor-medium tutor-font-medium" style="max-width: 172px;">
102 <?php esc_html_e( 'Student Ratings & Reviews', 'tutor' ); ?>
103 </div>
104 <div class="tutor-average-rating tutor-surface-l1-hover tutor-rounded-sm tutor-py-3 tutor-px-5 tutor-flex tutor-flex-column tutor-gap-1 tutor-w-fit">
105 <div class="tutor-flex tutor-items-center tutor-gap-5">
106 <div class="tutor-h4 tutor-font-bold">
107 <?php echo esc_html( number_format_i18n( (float) $course_rating->rating_avg, 1 ) ); ?>
108 </div>
109 <?php
110 StarRating::make()
111 ->rating( $course_rating->rating_avg )
112 ->show_average( false )
113 ->render();
114 ?>
115 </div>
116 <div class="tutor-tiny tutor-text-secondary">
117 <?php
118 printf(
119 /* translators: %s is total rating count */
120 esc_html( _n( 'Based on %s rating', 'Based on %s ratings', $total_items, 'tutor' ) ),
121 esc_html( number_format_i18n( $total_items ) )
122 );
123 ?>
124 </div>
125 </div>
126 </div>
127 <div class="tutor-flex tutor-flex-column tutor-gap-3">
128 <?php for ( $i = 5; $i >= 1; $i-- ) : ?>
129 <?php
130 $count = (int) ( $course_rating->count_by_value[ $i ] ?? 0 );
131 $percent = $course_rating->rating_count > 0 ? ( $count * 100 ) / $course_rating->rating_count : 0;
132 ?>
133 <div class="tutor-flex tutor-items-center tutor-gap-5">
134 <div class="tutor-flex tutor-items-center tutor-gap-3">
135 <?php SvgIcon::make()->name( Icon::STAR_FILL )->size( 12 )->attr( 'class', 'tutor-icon-exception4' )->render(); ?>
136 <span class="tutor-small" style="font-variant-numeric: tabular-nums;"><?php echo esc_html( $i ); ?></span>
137 </div>
138 <?php Progress::make()->variant( Variant::WARNING )->value( $percent )->animated()->render(); ?>
139 <div class="tutor-small tutor-flex-shrink-0" style="min-width: 80px;">
140 <?php
141 printf(
142 /* translators: %s is rating count */
143 esc_html( _n( '%s rating', '%s ratings', $count, 'tutor' ) ),
144 esc_html( number_format_i18n( $count ) )
145 );
146 ?>
147 </div>
148 </div>
149 <?php endfor; ?>
150 </div>
151 </div>
152
153 <div>
154 <?php foreach ( $reviews as $review ) : ?>
155 <?php tutor_load_template( 'learning-area.subpages.reviews.review-card', array( 'review' => $review ) ); ?>
156 <?php endforeach; ?>
157 </div>
158
159 <div x-data="tutorReviewDeleteModal()" x-cloak>
160 <?php
161 ConfirmationModal::make()
162 ->id( 'review-delete-modal' )
163 ->title( __( 'Delete your Review?', 'tutor' ) )
164 ->message( __( 'Are you sure you want to delete this review? This action cannot be undone.', 'tutor' ) )
165 ->icon( tutor_utils()->get_themed_svg( 'images/illustrations/delete-reviews.svg' ), 80, 80, ConfirmationModal::ICON_TYPE_HTML )
166 ->confirm_handler( 'handleDeleteReview(payload?.id)' )
167 ->mutation_state( 'deleteReviewMutation' )
168 ->confirm_text( __( 'Yes, Delete This', 'tutor' ) )
169 ->cancel_text( __( 'Cancel', 'tutor' ) )
170 ->render();
171 ?>
172 </div>
173 <?php endif; ?>
174 </div>
175
176 <?php
177 Pagination::make()
178 ->current( $current_page )
179 ->total( $total_items )
180 ->limit( $review_per_page )
181 ->attr( 'class', 'tutor-mt-6' )
182 ->render();
183 ?>
184 </div>
185