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