comment.php
4 years ago
complete_form.php
4 years ago
content.php
4 years ago
lesson_sidebar.php
4 years ago
required-enroll.php
4 years ago
sidebar_question_and_answer.php
4 years ago
lesson_sidebar.php
272 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 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit; |
| 15 | } |
| 16 | |
| 17 | global $post; |
| 18 | $post_id = get_the_ID(); |
| 19 | if ( ! empty( $_POST['lesson_id'] ) ) { |
| 20 | $post_id = sanitize_text_field( $_POST['lesson_id'] ); |
| 21 | } |
| 22 | $currentPost = $post; |
| 23 | $_is_preview = get_post_meta( $post_id, '_is_preview', true ); |
| 24 | $course_id = 0; |
| 25 | if ( $post->post_type === 'tutor_quiz' ) { |
| 26 | $course = tutor_utils()->get_course_by_quiz( get_the_ID() ); |
| 27 | $course_id = $course->ID; |
| 28 | } elseif ( $post->post_type === 'tutor_assignments' ) { |
| 29 | $course_id = tutor_utils()->get_course_id_by( 'assignment', $post->ID ); |
| 30 | } elseif ( $post->post_type === 'tutor_zoom_meeting' ) { |
| 31 | $course_id = get_post_meta( $post->ID, '_tutor_zm_for_course', true ); |
| 32 | } else { |
| 33 | $course_id = tutor_utils()->get_course_id_by( 'lesson', $post->ID ); |
| 34 | } |
| 35 | $user_id = get_current_user_id(); |
| 36 | $enable_qa_for_this_course = get_post_meta( $course_id, '_tutor_enable_qa', true ) == 'yes'; |
| 37 | $enable_q_and_a_on_course = tutor_utils()->get_option( 'enable_q_and_a_on_course' ) && $enable_qa_for_this_course; |
| 38 | $is_enrolled = tutor_utils()->is_enrolled( $course_id ); |
| 39 | $is_instructor_of_this_course = tutor_utils()->is_instructor_of_this_course( $user_id, $course_id ); |
| 40 | $is_user_admin = current_user_can( 'administrator' ); |
| 41 | ?> |
| 42 | |
| 43 | <?php do_action( 'tutor_lesson/single/before/lesson_sidebar' ); ?> |
| 44 | <div class="tutor-sidebar-tabs-wrap"> |
| 45 | <div class="tutor-lessons-tab-area tutor-<?php echo esc_html( isset( $context ) ? $context : 'desktop' ); ?>-sidebar-area"> |
| 46 | <div data-sidebar-tab="tutor-lesson-sidebar-tab-content" class="tutor-sidebar-tab-item tutor-lessons-tab <?php echo $enable_q_and_a_on_course ? 'active' : ''; ?> flex-center"> |
| 47 | <span class="tutor-icon-education-filled"></span> |
| 48 | <span class="text-medium-caption tutor-color-black-70"> |
| 49 | <?php esc_html_e( 'Lesson List', 'tutor' ); ?> |
| 50 | </span> |
| 51 | </div> |
| 52 | <?php if ( $enable_q_and_a_on_course && ( $is_enrolled || $is_instructor_of_this_course || $is_user_admin ) ): ?> |
| 53 | <div data-sidebar-tab="sideabr-qna-tab-content" class="tutor-sidebar-tab-item tutor-quiz-tab flex-center"> |
| 54 | <span class="tutor-icon-question-filled"></span> |
| 55 | <span class="text-medium-caption tutor-color-black-70"> |
| 56 | <?php esc_html_e( 'Question & Answer', 'tutor' ); ?> |
| 57 | </span> |
| 58 | </div> |
| 59 | <?php endif; ?> |
| 60 | </div> |
| 61 | |
| 62 | <div class="tutor-sidebar-tabs-content"> |
| 63 | <div id="tutor-lesson-sidebar-tab-content" class="tutor-lesson-sidebar-tab-item active"> |
| 64 | <?php |
| 65 | $topics = tutor_utils()->get_topics( $course_id ); |
| 66 | if ( $topics->have_posts() ) { |
| 67 | while ( $topics->have_posts() ) { |
| 68 | $topics->the_post(); |
| 69 | $topic_id = get_the_ID(); |
| 70 | $topic_summery = get_the_content(); |
| 71 | $total_contents = tutor_utils()->count_completed_contents_by_topic( $topic_id ); |
| 72 | ?> |
| 73 | |
| 74 | <div class="tutor-topics-in-single-lesson tutor-topics-<?php echo $topic_id; ?>"> |
| 75 | <div class="tutor-topics-title tutor-d-flex tutor-justify-content-between"> |
| 76 | <div class="tutor-topics-title-left"> |
| 77 | <div class="tutor-topics-title-inner"> |
| 78 | <div class="text-medium-h6 tutor-color-text-brand"><?php the_title(); ?></div> |
| 79 | <?php if ( true ): ?> |
| 80 | <div class="tutor-topics-title-info"> |
| 81 | <div class="tooltip-wrap tutor-d-flex"> |
| 82 | <i class="tutor-icon-circle-outline-info-filled tutor-icon-24 color-black-40"></i> |
| 83 | <span class="tooltip-txt tooltip-bottom"> |
| 84 | <?php echo $topic_summery; ?> |
| 85 | </span> |
| 86 | </div> |
| 87 | </div> |
| 88 | <?php endif; ?> |
| 89 | </div> |
| 90 | </div> |
| 91 | <div class="tutor-topics-title-right"> |
| 92 | <?php if ( isset( $total_contents['contents'] ) && $total_contents['contents'] > 0 ) : ?> |
| 93 | <div class="tutor-topic-subtitle tutor-fs-7 tutor-fw-normal tutor-color-black-60"> |
| 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 | <?php |
| 100 | do_action( 'tutor/lesson_list/before/topic', $topic_id ); |
| 101 | $lessons = tutor_utils()->get_course_contents_by_topic( get_the_ID(), -1 ); |
| 102 | $is_enrolled = tutor_utils()->is_enrolled( $course_id, get_current_user_id() ); |
| 103 | |
| 104 | while ( $lessons->have_posts() ) { |
| 105 | $lessons->the_post(); |
| 106 | $show_permalink = !$_is_preview || $is_enrolled || get_post_meta( $post->ID, '_is_preview', true ); |
| 107 | if ( $post->post_type === 'tutor_quiz' ) { |
| 108 | $quiz = $post; |
| 109 | ?> |
| 110 | <div class="tutor-lessons-under-topic" data-quiz-id="<?php echo $quiz->ID; ?>"> |
| 111 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-design-brand' : ''; ?>"> |
| 112 | <a href="<?php echo $show_permalink ? get_permalink( $quiz->ID ) : '#'; ?>" class="tutor-single-quiz-a tutor-d-flex tutor-justify-content-between" data-quiz-id="<?php echo $quiz->ID; ?>"> |
| 113 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 114 | <span class="tutor-icon-quiz-filled"></span> |
| 115 | <span class="lesson_title tutor-fs-7 tutor-fw-normal tutor-color-black-70"> |
| 116 | <?php echo $quiz->post_title; ?> |
| 117 | </span> |
| 118 | </div> |
| 119 | <div class="tutor-single-lesson-items-right tutor-d-flex tutor-lesson-right-icons"> |
| 120 | <span class="text-regular-caption tutor-color-black-70"> |
| 121 | <?php |
| 122 | $time_limit = tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_value' ); |
| 123 | if ( $time_limit ) { |
| 124 | $time_type = tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_type' ); |
| 125 | |
| 126 | $time_type=='minutes' ? $time_limit=$time_limit*60 : 0; |
| 127 | $time_type=='hours' ? $time_limit=$time_limit*3660 : 0; |
| 128 | $time_type=='days' ? $time_limit=$time_limit*86400 : 0; |
| 129 | $time_type=='weeks' ? $time_limit=$time_limit*86400*7 : 0; |
| 130 | |
| 131 | // To Fix: If time larger than 24 hours, the hour portion starts from 0 again. Fix later. |
| 132 | echo gmdate('H:i:s', $time_limit); |
| 133 | } |
| 134 | |
| 135 | $has_attempt = tutor_utils()->has_attempted_quiz( get_current_user_id(), $quiz->ID ) |
| 136 | ?> |
| 137 | |
| 138 | <?php if($show_permalink): ?> |
| 139 | <input type='checkbox' class='tutor-form-check-input tutor-form-check-circle' disabled="disabled" readonly="readonly" <?php echo esc_attr( $has_attempt ? 'checked="checked"' : '' ); ?>/> |
| 140 | <?php else: ?> |
| 141 | <i class="tutor-icon-lock-stroke-filled"></i> |
| 142 | <?php endif; ?> |
| 143 | </span> |
| 144 | </div> |
| 145 | </a> |
| 146 | </div> |
| 147 | </div> |
| 148 | <?php |
| 149 | |
| 150 | } elseif ( $post->post_type === 'tutor_assignments' ) { |
| 151 | /** |
| 152 | * Assignments |
| 153 | * |
| 154 | * @since this block v.1.3.3 |
| 155 | */ |
| 156 | ?> |
| 157 | <div class="tutor-lessons-under-topic"> |
| 158 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-design-brand' : ''; ?>"> |
| 159 | <a href="<?php echo $show_permalink ? get_permalink( $post->ID ) : '#'; ?>" class="tutor-single-assignment-a tutor-d-flex tutor-justify-content-between" data-assignment-id="<?php echo $post->ID; ?>"> |
| 160 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 161 | <span class="tutor-icon-assignment-filled"></span> |
| 162 | <span class="lesson_title tutor-fs-7 tutor-fw-normal tutor-color-black-70"> |
| 163 | <?php echo $post->post_title; ?> |
| 164 | </span> |
| 165 | </div> |
| 166 | <div class="tutor-single-lesson-items-right tutor-d-flex tutor-lesson-right-icons"> |
| 167 | <?php if($show_permalink): ?> |
| 168 | <?php do_action( 'tutor/assignment/right_icon_area', $post ); ?> |
| 169 | <?php else: ?> |
| 170 | <i class="tutor-icon-lock-stroke-filled"></i> |
| 171 | <?php endif; ?> |
| 172 | </div> |
| 173 | </a> |
| 174 | </div> |
| 175 | </div> |
| 176 | <?php |
| 177 | } elseif ( $post->post_type === 'tutor_zoom_meeting' ) { |
| 178 | /** |
| 179 | * Zoom Meeting |
| 180 | * |
| 181 | * @since this block v.1.7.1 |
| 182 | */ |
| 183 | ?> |
| 184 | <div class="tutor-lessons-under-topic"> |
| 185 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-design-brand' : ''; ?>"> |
| 186 | <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>" class="sidebar-single-zoom-meeting-a tutor-d-flex tutor-justify-content-between"> |
| 187 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 188 | <span class="tutor-icon-zoom"></span> |
| 189 | <span class="lesson_title tutor-fs-7 tutor-fw-normal tutor-color-black-70"> |
| 190 | <?php echo esc_html( $post->post_title ); ?> |
| 191 | </span> |
| 192 | </div> |
| 193 | <div class="tutor-single-lesson-items-right tutor-d-flex tutor-lesson-right-icons"> |
| 194 | <?php if($show_permalink): ?> |
| 195 | <?php do_action( 'tutor/zoom/right_icon_area', $post->ID ); ?> |
| 196 | <?php else: ?> |
| 197 | <i class="tutor-icon-lock-stroke-filled"></i> |
| 198 | <?php endif; ?> |
| 199 | </div> |
| 200 | </a> |
| 201 | </div> |
| 202 | </div> |
| 203 | <?php |
| 204 | |
| 205 | } else { |
| 206 | |
| 207 | /** |
| 208 | * Lesson |
| 209 | */ |
| 210 | |
| 211 | $video = tutor_utils()->get_video_info(); |
| 212 | |
| 213 | $play_time = false; |
| 214 | if ( $video ) { |
| 215 | $play_time = $video->playtime; |
| 216 | } |
| 217 | $is_completed_lesson = tutor_utils()->is_completed_lesson(); |
| 218 | ?> |
| 219 | <div class="tutor-lessons-under-topic"> |
| 220 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-design-brand' : ''; ?>"> |
| 221 | <a href="<?php echo $show_permalink ? get_the_permalink() : '#'; ?>" class="tutor-single-lesson-a tutor-d-flex tutor-justify-content-between" data-lesson-id="<?php the_ID(); ?>"> |
| 222 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 223 | <?php |
| 224 | $tutor_lesson_type_icon = $play_time ? 'youtube-brand' : 'document-file'; |
| 225 | echo "<span class='tutor-icon-$tutor_lesson_type_icon'></span>"; |
| 226 | ?> |
| 227 | <span class="lesson_title tutor-fs-7 tutor-fw-normal tutor-color-black-70"> |
| 228 | <?php the_title(); ?> |
| 229 | </span> |
| 230 | </div> |
| 231 | <div class="tutor-single-lesson-items-right tutor-d-flex"> |
| 232 | <?php |
| 233 | do_action( 'tutor/lesson_list/right_icon_area', $post ); |
| 234 | if ( $play_time ) { |
| 235 | echo "<span class='text-regular-caption tutor-color-black-70'>" . tutor_utils()->get_optimized_duration( $play_time ) . '</span>'; |
| 236 | } |
| 237 | $lesson_complete_icon = $is_completed_lesson ? 'checked' : ''; |
| 238 | |
| 239 | if($show_permalink) { |
| 240 | echo "<input $lesson_complete_icon type='checkbox' class='tutor-form-check-input tutor-form-check-circle' disabled readonly />"; |
| 241 | } else { |
| 242 | echo '<i class="tutor-icon-lock-stroke-filled"></i>'; |
| 243 | } |
| 244 | ?> |
| 245 | </div> |
| 246 | </a> |
| 247 | </div> |
| 248 | </div> |
| 249 | <?php |
| 250 | } |
| 251 | } |
| 252 | $lessons->reset_postdata(); |
| 253 | do_action( 'tutor/lesson_list/after/topic', $topic_id ); |
| 254 | ?> |
| 255 | </div> |
| 256 | <?php |
| 257 | } |
| 258 | $topics->reset_postdata(); |
| 259 | wp_reset_postdata(); |
| 260 | } |
| 261 | ?> |
| 262 | </div> |
| 263 | |
| 264 | <div id="sideabr-qna-tab-content" class="tutor-lesson-sidebar-tab-item"> |
| 265 | <?php |
| 266 | tutor_lesson_sidebar_question_and_answer(); |
| 267 | ?> |
| 268 | </div> |
| 269 | </div> |
| 270 | </div> |
| 271 | <?php do_action( 'tutor_lesson/single/after/lesson_sidebar' ); ?> |
| 272 |