comment.php
3 years ago
comments-loop.php
3 years ago
complete_form.php
2 years ago
content.php
2 years ago
lesson_sidebar.php
2 years ago
required-enroll.php
2 years ago
sidebar_question_and_answer.php
3 years ago
lesson_sidebar.php
318 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Display Topics and Lesson lists for learn |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Single\Lesson |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.0.0 |
| 10 | */ |
| 11 | |
| 12 | use TUTOR\Input; |
| 13 | use Tutor\Models\QuizModel; |
| 14 | |
| 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | exit; |
| 17 | } |
| 18 | |
| 19 | global $post; |
| 20 | |
| 21 | $current_post_id = get_the_ID(); |
| 22 | if ( ! empty( Input::post( 'lesson_id' ) ) ) { |
| 23 | $current_post_id = Input::post( 'lesson_id' ); |
| 24 | } |
| 25 | |
| 26 | $current_post = $post; |
| 27 | $_is_preview = get_post_meta( $current_post_id, '_is_preview', true ); |
| 28 | $course_id = tutor_utils()->get_course_id_by_subcontent( $post->ID ); |
| 29 | |
| 30 | $user_id = get_current_user_id(); |
| 31 | $enable_qa_for_this_course = get_post_meta( $course_id, '_tutor_enable_qa', true ) == 'yes'; |
| 32 | $enable_q_and_a_on_course = tutor_utils()->get_option( 'enable_q_and_a_on_course' ) && $enable_qa_for_this_course; |
| 33 | $is_enrolled = tutor_utils()->is_enrolled( $course_id ); |
| 34 | $is_instructor_of_this_course = tutor_utils()->has_user_course_content_access( $user_id, $course_id ); |
| 35 | $is_user_admin = current_user_can( 'administrator' ); |
| 36 | $is_public_course = \TUTOR\Course_List::is_public( $course_id ); |
| 37 | ?> |
| 38 | |
| 39 | <?php do_action( 'tutor_lesson/single/before/lesson_sidebar' ); ?> |
| 40 | <div class="tutor-course-single-sidebar-title tutor-d-flex tutor-justify-between"> |
| 41 | <span class="tutor-fs-6 tutor-fw-medium tutor-color-secondary"><?php esc_html_e( 'Course Content', 'tutor' ); ?></span> |
| 42 | <span class="tutor-d-block tutor-d-xl-none"> |
| 43 | <a href="#" class="tutor-iconic-btn" tutor-hide-course-single-sidebar> |
| 44 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 45 | </a> |
| 46 | </span> |
| 47 | </div> |
| 48 | |
| 49 | <?php |
| 50 | $topics = tutor_utils()->get_topics( $course_id ); |
| 51 | if ( $topics->have_posts() ) { |
| 52 | |
| 53 | // Loop through topics. |
| 54 | while ( $topics->have_posts() ) { |
| 55 | $topics->the_post(); |
| 56 | $topic_id = get_the_ID(); |
| 57 | $topic_summery = get_the_content(); |
| 58 | $total_contents = tutor_utils()->count_completed_contents_by_topic( $topic_id ); |
| 59 | $lessons = tutor_utils()->get_course_contents_by_topic( get_the_ID(), -1 ); |
| 60 | $is_topic_active = ! empty( |
| 61 | array_filter( |
| 62 | $lessons->posts, |
| 63 | function ( $content ) use ( $current_post ) { |
| 64 | return $content->ID == $current_post->ID; |
| 65 | } |
| 66 | ) |
| 67 | ); |
| 68 | ?> |
| 69 | <div class="tutor-course-topic tutor-course-topic-<?php echo esc_attr( $topic_id ); ?>"> |
| 70 | <div class="tutor-accordion-item-header<?php echo $is_topic_active ? ' is-active' : ''; ?>" tutor-course-single-topic-toggler> |
| 71 | <div class="tutor-row tutor-gx-1"> |
| 72 | <div class="tutor-col"> |
| 73 | <div class="tutor-course-topic-title"> |
| 74 | <?php the_title(); ?> |
| 75 | <?php if ( true ) : ?> |
| 76 | <?php if ( trim( $topic_summery ) ) : ?> |
| 77 | <div class="tutor-course-topic-title-info tutor-ml-8"> |
| 78 | <div class="tooltip-wrap"> |
| 79 | <i class="tutor-course-topic-title-info-icon tutor-icon-circle-info-o"></i> |
| 80 | <span class="tooltip-txt tooltip-bottom"> |
| 81 | <?php echo esc_textarea( $topic_summery ); ?> |
| 82 | </span> |
| 83 | </div> |
| 84 | </div> |
| 85 | <?php endif; ?> |
| 86 | <?php endif; ?> |
| 87 | </div> |
| 88 | </div> |
| 89 | |
| 90 | <div class="tutor-col-auto tutor-align-self-center"> |
| 91 | <?php if ( isset( $total_contents['contents'] ) && $total_contents['contents'] > 0 ) : ?> |
| 92 | <div class="tutor-course-topic-summary tutor-pl-8"> |
| 93 | <?php echo esc_html( isset( $total_contents['completed'] ) ? $total_contents['completed'] : 0 ); ?>/<?php echo esc_html( isset( $total_contents['contents'] ) ? $total_contents['contents'] : 0 ); ?> |
| 94 | </div> |
| 95 | <?php endif; ?> |
| 96 | </div> |
| 97 | </div> |
| 98 | </div> |
| 99 | |
| 100 | <div class="tutor-accordion-item-body <?php echo $is_topic_active ? '' : 'tutor-display-none'; ?>"> |
| 101 | <?php |
| 102 | do_action( 'tutor/lesson_list/before/topic', $topic_id ); |
| 103 | |
| 104 | // Loop through lesson, quiz, assignment, zoom lesson. |
| 105 | while ( $lessons->have_posts() ) { |
| 106 | $lessons->the_post(); |
| 107 | |
| 108 | $show_permalink = ! $_is_preview || $is_enrolled || get_post_meta( $post->ID, '_is_preview', true ) || $is_public_course || $is_instructor_of_this_course; |
| 109 | $show_permalink = apply_filters( 'tutor_course/single/content/show_permalink', $show_permalink, get_the_ID() ); |
| 110 | $lock_icon = ! $show_permalink; |
| 111 | $show_permalink = null === $show_permalink ? true : $show_permalink; |
| 112 | |
| 113 | if ( 'tutor_quiz' === $post->post_type ) { |
| 114 | $quiz = $post; |
| 115 | ?> |
| 116 | <div class="tutor-course-topic-item tutor-course-topic-item-quiz<?php echo ( get_the_ID() == $current_post->ID ) ? ' is-active' : ''; ?>" data-quiz-id="<?php echo esc_attr( $quiz->ID ); ?>"> |
| 117 | <a href="<?php echo $show_permalink ? esc_url( get_permalink( $quiz->ID ) ) : '#'; ?>" data-quiz-id="<?php echo esc_attr( $quiz->ID ); ?>"> |
| 118 | <div class="tutor-d-flex tutor-mr-32"> |
| 119 | <span class="tutor-course-topic-item-icon tutor-icon-quiz-o tutor-mr-8 tutor-mt-2" area-hidden="true"></span> |
| 120 | <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium"> |
| 121 | <?php echo esc_html( $quiz->post_title ); ?> |
| 122 | </span> |
| 123 | </div> |
| 124 | <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0"> |
| 125 | <?php |
| 126 | $time_limit = (int) tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_value' ); |
| 127 | $last_attempt = ( new QuizModel() )->get_first_or_last_attempt( $quiz->ID ); |
| 128 | |
| 129 | // $attempt_ended = is_object( $last_attempt ) && ( 'attempt_ended' === ( $last_attempt->attempt_status ) || $last_attempt->is_manually_reviewed ) ? true : false; |
| 130 | |
| 131 | $attempt_ended = is_object( $last_attempt ) && QuizModel::ATTEMPT_STARTED !== $last_attempt->attempt_status; |
| 132 | $result_class = ''; |
| 133 | |
| 134 | $quiz_result = QuizModel::get_quiz_result( $quiz->ID ); |
| 135 | if ( $attempt_ended && QuizModel::ATTEMPT_STARTED !== $last_attempt->attempt_status ) { |
| 136 | if ( 'fail' === $quiz_result ) { |
| 137 | $result_class = 'tutor-check-fail'; |
| 138 | } |
| 139 | if ( 'pending' === $quiz_result ) { |
| 140 | $result_class = 'tutor-check-pending'; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | if ( $time_limit ) { |
| 145 | $time_type = tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_type' ); |
| 146 | 'minutes' == $time_type ? $time_limit = $time_limit * 60 : 0; |
| 147 | 'hours' == $time_type ? $time_limit = $time_limit * 3660 : 0; |
| 148 | 'days' == $time_type ? $time_limit = $time_limit * 86400 : 0; |
| 149 | 'weeks' == $time_type ? $time_limit = $time_limit * 86400 * 7 : 0; |
| 150 | |
| 151 | // To Fix: If time larger than 24 hours, the hour portion starts from 0 again. Fix later. |
| 152 | $markup = '<span class="tutor-course-topic-item-duration tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-8">' . tutor_utils()->course_content_time_format( gmdate( 'H:i:s', $time_limit ) ) . '</span>'; |
| 153 | echo wp_kses( |
| 154 | $markup, |
| 155 | array( |
| 156 | 'span' => array( 'class' => true ), |
| 157 | ) |
| 158 | ); |
| 159 | } |
| 160 | ?> |
| 161 | |
| 162 | <?php if ( ! $lock_icon ) : ?> |
| 163 | <input type="checkbox" |
| 164 | class="tutor-form-check-input tutor-form-check-circle <?php echo esc_attr( $result_class ); ?>" |
| 165 | disabled="disabled" |
| 166 | readonly="readonly" |
| 167 | <?php echo esc_attr( $attempt_ended ? 'checked="checked"' : '' ); ?> /> |
| 168 | <?php else : ?> |
| 169 | <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i> |
| 170 | <?php endif; ?> |
| 171 | </div> |
| 172 | </a> |
| 173 | </div> |
| 174 | <?php } elseif ( 'tutor_assignments' === $post->post_type ) { ?> |
| 175 | <div class="tutor-course-topic-item tutor-course-topic-item-assignment<?php echo esc_attr( get_the_ID() == $current_post->ID ? ' is-active' : '' ); ?>"> |
| 176 | <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>" data-assignment-id="<?php echo esc_attr( $post->ID ); ?>"> |
| 177 | <div class="tutor-d-flex tutor-mr-32"> |
| 178 | <span class="tutor-course-topic-item-icon tutor-icon-assignment tutor-mr-8" area-hidden="true"></span> |
| 179 | <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium"> |
| 180 | <?php echo esc_html( $post->post_title ); ?> |
| 181 | </span> |
| 182 | </div> |
| 183 | <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0"> |
| 184 | <?php if ( $show_permalink ) : ?> |
| 185 | <?php do_action( 'tutor/assignment/right_icon_area', $post, $lock_icon ); ?> |
| 186 | <?php else : ?> |
| 187 | <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i> |
| 188 | <?php endif; ?> |
| 189 | </div> |
| 190 | </a> |
| 191 | </div> |
| 192 | <?php } elseif ( 'tutor_zoom_meeting' === $post->post_type ) { ?> |
| 193 | <div class="tutor-course-topic-item tutor-course-topic-item-zoom<?php echo esc_attr( ( get_the_ID() == $current_post->ID ) ? ' is-active' : '' ); ?>"> |
| 194 | <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>"> |
| 195 | <div class="tutor-d-flex tutor-mr-32"> |
| 196 | <span class="tutor-course-topic-item-icon tutor-icon-brand-zoom-o tutor-mr-8 tutor-mt-2" area-hidden="true"></span> |
| 197 | <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium"> |
| 198 | <?php echo esc_html( $post->post_title ); ?> |
| 199 | </span> |
| 200 | </div> |
| 201 | <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0"> |
| 202 | <?php if ( $show_permalink ) : ?> |
| 203 | <?php do_action( 'tutor/zoom/right_icon_area', $post->ID, $lock_icon ); ?> |
| 204 | <?php else : ?> |
| 205 | <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i> |
| 206 | <?php endif; ?> |
| 207 | </div> |
| 208 | </a> |
| 209 | </div> |
| 210 | <?php } elseif ( 'tutor-google-meet' === $post->post_type ) { ?> |
| 211 | <div class="tutor-course-topic-item tutor-course-topic-item-zoom<?php echo esc_attr( get_the_ID() == $current_post->ID ? ' is-active' : '' ); ?>"> |
| 212 | <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>"> |
| 213 | <div class="tutor-d-flex tutor-mr-32"> |
| 214 | <span class="tutor-course-topic-item-icon tutor-icon-brand-google-meet tutor-mr-8 tutor-mt-2" area-hidden="true"></span> |
| 215 | <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium"> |
| 216 | <?php echo esc_html( $post->post_title ); ?> |
| 217 | </span> |
| 218 | </div> |
| 219 | <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0"> |
| 220 | <?php if ( $show_permalink ) : ?> |
| 221 | <?php do_action( 'tutor/google_meet/right_icon_area', $post->ID, false ); ?> |
| 222 | <?php else : ?> |
| 223 | <i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i> |
| 224 | <?php endif; ?> |
| 225 | </div> |
| 226 | </a> |
| 227 | </div> |
| 228 | <?php } else { ?> |
| 229 | |
| 230 | <?php |
| 231 | $video = tutor_utils()->get_video_info(); |
| 232 | $play_time = false; |
| 233 | if ( $video ) { |
| 234 | $play_time = $video->playtime; |
| 235 | } |
| 236 | $is_completed_lesson = tutor_utils()->is_completed_lesson(); |
| 237 | ?> |
| 238 | <div class="tutor-course-topic-item tutor-course-topic-item-lesson<?php echo esc_attr( get_the_ID() == $current_post->ID ? ' is-active' : '' ); ?>"> |
| 239 | <a href="<?php echo $show_permalink ? esc_url( get_the_permalink() ) : '#'; ?>" data-lesson-id="<?php the_ID(); ?>"> |
| 240 | <div class="tutor-d-flex tutor-mr-32"> |
| 241 | <?php |
| 242 | $tutor_lesson_type_icon = $play_time ? 'brand-youtube-bold' : 'document-text'; |
| 243 | $markup = '<span class="tutor-course-topic-item-icon tutor-icon-' . $tutor_lesson_type_icon . ' tutor-mr-8 tutor-mt-2" area-hidden="true"></span>'; |
| 244 | echo wp_kses( |
| 245 | $markup, |
| 246 | array( |
| 247 | 'span' => array( |
| 248 | 'class' => true, |
| 249 | 'area-hidden' => true, |
| 250 | ), |
| 251 | ) |
| 252 | ); |
| 253 | ?> |
| 254 | <span class="tutor-course-topic-item-title tutor-fs-7 tutor-fw-medium"> |
| 255 | <?php the_title(); ?> |
| 256 | </span> |
| 257 | </div> |
| 258 | |
| 259 | <div class="tutor-d-flex tutor-ml-auto tutor-flex-shrink-0"> |
| 260 | <?php |
| 261 | if ( $play_time ) { |
| 262 | $markup = "<span class='tutor-course-topic-item-duration tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-8'>" . tutor_utils()->get_optimized_duration( $play_time ) . '</span>'; |
| 263 | echo wp_kses( |
| 264 | $markup, |
| 265 | array( |
| 266 | 'span' => array( 'class' => true ), |
| 267 | ) |
| 268 | ); |
| 269 | } |
| 270 | |
| 271 | $lesson_complete_icon = $is_completed_lesson ? 'checked' : ''; |
| 272 | |
| 273 | if ( ! $lock_icon ) { |
| 274 | $markup = "<input $lesson_complete_icon type='checkbox' class='tutor-form-check-input tutor-form-check-circle' disabled readonly />"; |
| 275 | echo wp_kses( |
| 276 | $markup, |
| 277 | array( |
| 278 | 'input' => array( |
| 279 | 'checked' => true, |
| 280 | 'class' => true, |
| 281 | 'type' => true, |
| 282 | 'disabled' => true, |
| 283 | 'readonly' => true, |
| 284 | ), |
| 285 | ) |
| 286 | ); |
| 287 | } else { |
| 288 | $markup = '<i class="tutor-icon-lock-line tutor-fs-7 tutor-color-muted tutor-mr-4" area-hidden="true"></i>'; |
| 289 | echo wp_kses( |
| 290 | $markup, |
| 291 | array( |
| 292 | 'i' => array( |
| 293 | 'class' => true, |
| 294 | 'area-hidden' => true, |
| 295 | ), |
| 296 | ) |
| 297 | ); |
| 298 | } |
| 299 | ?> |
| 300 | </div> |
| 301 | </a> |
| 302 | </div> |
| 303 | <?php |
| 304 | } |
| 305 | } |
| 306 | $lessons->reset_postdata(); |
| 307 | do_action( 'tutor/lesson_list/after/topic', $topic_id ); |
| 308 | ?> |
| 309 | </div> |
| 310 | </div> |
| 311 | <?php |
| 312 | } |
| 313 | $topics->reset_postdata(); |
| 314 | wp_reset_postdata(); |
| 315 | } |
| 316 | ?> |
| 317 | <?php do_action( 'tutor_lesson/single/after/lesson_sidebar' ); ?> |
| 318 |