enrolled
4 years ago
add-to-cart-edd.php
4 years ago
add-to-cart-woocommerce.php
4 years ago
continue-lesson.php
4 years ago
course-benefits.php
4 years ago
course-content.php
4 years ago
course-entry-box.php
4 years ago
course-requirements.php
4 years ago
course-target-audience.php
4 years ago
course-topics.php
4 years ago
instructors.php
3 years ago
lead-info.php
4 years ago
material-includes.php
4 years ago
q_and_a_turned_off.php
4 years ago
reviews-loop.php
4 years ago
reviews.php
4 years ago
social_share.php
4 years ago
tags.php
4 years ago
wc-price-html.php
4 years ago
reviews.php
177 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template for displaying course reviews |
| 4 | * |
| 5 | * @since v.1.0.0 |
| 6 | * |
| 7 | * @author Themeum |
| 8 | * @url https://themeum.com |
| 9 | * |
| 10 | * @package TutorLMS/Templates |
| 11 | * @version 1.4.5 |
| 12 | */ |
| 13 | |
| 14 | $disable = ! get_tutor_option( 'enable_course_review' ); |
| 15 | if ( $disable ) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | $per_page = tutor_utils()->get_option( 'pagination_per_page', 10 ); |
| 20 | $current_page = max(1, (int)tutor_utils()->avalue_dot('current_page', $_POST)); |
| 21 | $offset = ($current_page - 1) * $per_page; |
| 22 | |
| 23 | $current_user_id = get_current_user_id(); |
| 24 | $course_id = isset($_POST['course_id']) ? (int)$_POST['course_id'] : get_the_ID(); |
| 25 | $is_enrolled = tutor_utils()->is_enrolled($course_id, $current_user_id); |
| 26 | |
| 27 | $reviews = tutor_utils()->get_course_reviews($course_id, $offset, $per_page, false, array('approved'), $current_user_id); |
| 28 | $reviews_total = tutor_utils()->get_course_reviews($course_id, null, null, true, array('approved'), $current_user_id); |
| 29 | $rating = tutor_utils()->get_course_rating($course_id); |
| 30 | $my_rating = tutor_utils()->get_reviews_by_user(0, 0, 150, false, $course_id, array('approved', 'hold')); |
| 31 | |
| 32 | if(isset($_POST['course_id'])) { |
| 33 | // It's load more |
| 34 | tutor_load_template('single.course.reviews-loop', array('reviews' => $reviews)); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | do_action( 'tutor_course/single/enrolled/before/reviews' ); |
| 39 | ?> |
| 40 | |
| 41 | <div class="tutor-pagination-wrapper-replaceable"> |
| 42 | <h3 class="tutor-fs-5 tutor-fw-bold tutor-color-black tutor-mb-24"> |
| 43 | <?php |
| 44 | $review_title = apply_filters( 'tutor_course_reviews_section_title', 'Student Ratings & Reviews' ); |
| 45 | echo esc_html( $review_title, 'tutor' ); |
| 46 | ?> |
| 47 | </h3> |
| 48 | |
| 49 | <?php if(! is_array( $reviews ) || ! count( $reviews )): ?> |
| 50 | <?php tutor_utils()->tutor_empty_state(__('No Review Yet', 'tutor')); ?> |
| 51 | <?php else: ?> |
| 52 | <div class="tutor-card tutor-review-card"> |
| 53 | <div class="tutor-review-summary tutor-p-24 tutor-p-lg-40"> |
| 54 | <div class="tutor-row tutor-gx-xl-5 tutor-align-center"> |
| 55 | <div class="tutor-col-lg-auto tutor-text-center tutor-mb-16 tutor-mb-lg-0"> |
| 56 | <div class="tutor-review-summary-average-rating tutor-mb-20"> |
| 57 | <?php echo number_format( $rating->rating_avg, 1 ); ?> |
| 58 | </div> |
| 59 | |
| 60 | <div> |
| 61 | <div class="tutor-d-inline-block"> |
| 62 | <?php tutor_utils()->star_rating_generator_v2( $rating->rating_avg, null, false, '', 'lg' ); ?> |
| 63 | </div> |
| 64 | </div> |
| 65 | |
| 66 | <div class="tutor-fs-6 tutor-color-secondary tutor-mt-12 tutor-total-rating-count"> |
| 67 | <?php esc_html_e( 'Total ', 'tutor' ); ?> |
| 68 | <?php echo $reviews_total; ?> |
| 69 | <?php echo esc_html( _n( ' Rating', ' Ratings', count( $reviews ), 'tutor' ) ); ?> |
| 70 | </div> |
| 71 | </div> |
| 72 | |
| 73 | <div class="tutor-col-lg"> |
| 74 | <div class="tutor-review-summary-ratings"> |
| 75 | <?php foreach ( $rating->count_by_value as $key => $value ) : ?> |
| 76 | <?php $rating_count_percent = ( $value > 0 ) ? ( $value * 100 ) / $rating->rating_count : 0; ?> |
| 77 | <div class="tutor-row tutor-align-center tutor-review-summary-rating"> |
| 78 | <div class="tutor-col-auto"> |
| 79 | <div class="tutor-ratings"> |
| 80 | <div class="tutor-ratings-stars"> |
| 81 | <span class="tutor-icon-star-line" area-hidden="true"></span> |
| 82 | </div> |
| 83 | <div class="tutor-ratings-average"> |
| 84 | <?php echo $key; ?> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | |
| 89 | <div class="tutor-col"> |
| 90 | <div class="tutor-progress-bar tutor-ratings-progress-bar" style="--tutor-progress-value: <?php echo $rating_count_percent; ?>%"> |
| 91 | <span class="tutor-progress-value" area-hidden="true"></span> |
| 92 | </div> |
| 93 | </div> |
| 94 | |
| 95 | <div class="tutor-col-4 tutor-col-lg-3"> |
| 96 | <span class="tutor-fs-6 tutor-color-secondary tutor-individual-star-rating"><?php echo $value . ' ' . ( $value > 1 ? __( 'Ratings', 'tutor' ) : __( 'Rating', 'tutor' ) ); ?></span> |
| 97 | </div> |
| 98 | </div> |
| 99 | <?php endforeach; ?> |
| 100 | </div> |
| 101 | </div> |
| 102 | </div> |
| 103 | </div> |
| 104 | |
| 105 | <div class="tutor-hr" area-hidden="true"></div> |
| 106 | |
| 107 | <div class="tutor-reviews tutor-card-list tutor-pagination-content-appendable"> |
| 108 | <?php tutor_load_template('single.course.reviews-loop', array('reviews' => $reviews)); ?> |
| 109 | </div> |
| 110 | </div> |
| 111 | <?php endif; ?> |
| 112 | |
| 113 | <div class="tutor-row tutor-mt-40 tutor-mb-20"> |
| 114 | <div class="tutor-col"> |
| 115 | <?php if($is_enrolled): ?> |
| 116 | <button class="tutor-btn tutor-btn-primary write-course-review-link-btn"> |
| 117 | <i class="tutor-icon-star-line tutor-mr-8"></i> |
| 118 | <?php |
| 119 | $is_new = !$my_rating || empty($my_rating->rating) || empty($my_rating->comment_content); |
| 120 | $is_new ? _e('Write a review', 'tutor') : _e('Edit review', 'tutor'); |
| 121 | ?> |
| 122 | </button> |
| 123 | <?php endif; ?> |
| 124 | </div> |
| 125 | |
| 126 | <div class="tutor-col-auto"> |
| 127 | <?php |
| 128 | $pagination_data = array( |
| 129 | 'total_items' => $reviews_total, |
| 130 | 'per_page' => $per_page, |
| 131 | 'paged' => $current_page, |
| 132 | 'layout' => array( |
| 133 | 'type' => 'load_more', |
| 134 | 'load_more_text' => __('Load More', 'tutor') |
| 135 | ), |
| 136 | 'ajax' => array( |
| 137 | 'action' => 'tutor_single_course_reviews_load_more', |
| 138 | 'course_id' => $course_id, |
| 139 | ) |
| 140 | ); |
| 141 | $pagination_template_frontend = tutor()->path . 'templates/dashboard/elements/pagination.php'; |
| 142 | tutor_load_template_from_custom_path( $pagination_template_frontend, $pagination_data ); |
| 143 | ?> |
| 144 | </div> |
| 145 | </div> |
| 146 | </div> |
| 147 | |
| 148 | <?php if($is_enrolled): ?> |
| 149 | <div class="tutor-course-enrolled-review-wrap tutor-pt-16"> |
| 150 | <div class="tutor-write-review-form" style="display: none;"> |
| 151 | <form method="post"> |
| 152 | <div class="tutor-star-rating-container"> |
| 153 | <input type="hidden" name="course_id" value="<?php echo $course_id; ?>"/> |
| 154 | <input type="hidden" name="review_id" value="<?php echo $my_rating ? $my_rating->comment_ID : ''; ?>"/> |
| 155 | <input type="hidden" name="action" value="tutor_place_rating"/> |
| 156 | <div class="tutor-form-group"> |
| 157 | <div class="tutor-ratings tutor-ratings-lg tutor-ratings-selectable" tutor-ratings-selectable> |
| 158 | <?php |
| 159 | tutor_utils()->star_rating_generator(tutor_utils()->get_rating_value($my_rating ? $my_rating->rating : 0)); |
| 160 | ?> |
| 161 | </div> |
| 162 | </div> |
| 163 | <div class="tutor-form-group"> |
| 164 | <textarea name="review" placeholder="<?php _e('write a review', 'tutor'); ?>"><?php echo stripslashes($my_rating ? $my_rating->comment_content : ''); ?></textarea> |
| 165 | </div> |
| 166 | <div class="tutor-form-group"> |
| 167 | <button type="submit" class="tutor_submit_review_btn tutor-btn tutor-btn-primary"> |
| 168 | <?php _e('Submit Review', 'tutor'); ?> |
| 169 | </button> |
| 170 | </div> |
| 171 | </div> |
| 172 | </form> |
| 173 | </div> |
| 174 | </div> |
| 175 | <?php endif; ?> |
| 176 | |
| 177 | <?php do_action( 'tutor_course/single/enrolled/after/reviews' ); ?> |