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