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
276 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' : ''; ?> tutor-d-flex tutor-align-center"> |
| 47 | <span class="tutor-icon-open-book-o tutor-mr-8" area-hidden="true"></span> |
| 48 | <span class="tutor-fs-7 tutor-fw-medium tutor-color-secondary"> |
| 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="sidebar-qna-tab-content" class="tutor-sidebar-tab-item tutor-quiz-tab tutor-d-flex tutor-align-center"> |
| 54 | <span class="tutor-icon-question tutor-mr-8" area-hidden="true"></span> |
| 55 | <span class="tutor-fs-7 tutor-fw-medium tutor-color-secondary"> |
| 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-row"> |
| 76 | <div class="tutor-topics-title-left tutor-col"> |
| 77 | <div class="tutor-topics-title-inner tutor-fs-6 tutor-fw-medium tutor-color-primary"> |
| 78 | <?php the_title(); ?> |
| 79 | <?php if ( true ) : ?> |
| 80 | <?php if(trim($topic_summery)) : ?> |
| 81 | <div class="tutor-topics-title-info"> |
| 82 | <div class="tooltip-wrap"> |
| 83 | <i class="tutor-topics-title-info-icon tutor-icon-circle-info-o tutor-color-muted"></i> |
| 84 | <span class="tooltip-txt tooltip-bottom"> |
| 85 | <?php echo $topic_summery; ?> |
| 86 | </span> |
| 87 | </div> |
| 88 | </div> |
| 89 | <?php endif; ?> |
| 90 | <?php endif; ?> |
| 91 | </div> |
| 92 | </div> |
| 93 | |
| 94 | <div class="tutor-topics-title-right tutor-col-auto"> |
| 95 | <?php if ( isset( $total_contents['contents'] ) && $total_contents['contents'] > 0 ) : ?> |
| 96 | <div class="tutor-topic-subtitle tutor-fs-7 tutor-color-secondary"> |
| 97 | <?php echo esc_html( isset( $total_contents['completed'] ) ? $total_contents['completed'] : 0 ); ?>/<?php echo esc_html( isset( $total_contents['contents'] ) ? $total_contents['contents'] : 0 ); ?> |
| 98 | </div> |
| 99 | <?php endif; ?> |
| 100 | </div> |
| 101 | </div> |
| 102 | |
| 103 | <?php |
| 104 | do_action( 'tutor/lesson_list/before/topic', $topic_id ); |
| 105 | $lessons = tutor_utils()->get_course_contents_by_topic( get_the_ID(), -1 ); |
| 106 | $is_enrolled = tutor_utils()->is_enrolled( $course_id, get_current_user_id() ); |
| 107 | while ( $lessons->have_posts() ) { |
| 108 | $lessons->the_post(); |
| 109 | $is_public_course = \TUTOR\Course_List::is_public( $course_id ); |
| 110 | $show_permalink = !$_is_preview || $is_enrolled || get_post_meta( $post->ID, '_is_preview', true ) || $is_public_course; |
| 111 | if ( $post->post_type === 'tutor_quiz' ) { |
| 112 | $quiz = $post; |
| 113 | ?> |
| 114 | <div class="tutor-lessons-under-topic" data-quiz-id="<?php echo $quiz->ID; ?>"> |
| 115 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-primary' : ''; ?>"> |
| 116 | <a href="<?php echo $show_permalink ? get_permalink( $quiz->ID ) : '#'; ?>" class="tutor-single-quiz-a tutor-d-flex tutor-justify-between" data-quiz-id="<?php echo $quiz->ID; ?>"> |
| 117 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 118 | <span class="tutor-icon-quiz-o tutor-mr-8" area-hidden="true"></span> |
| 119 | <span class="lesson_title tutor-fs-7 tutor-color-secondary"> |
| 120 | <?php echo $quiz->post_title; ?> |
| 121 | </span> |
| 122 | </div> |
| 123 | <div class="tutor-single-lesson-items-right tutor-d-flex tutor-lesson-right-icons"> |
| 124 | <span class="tutor-fs-7 tutor-color-secondary"> |
| 125 | <?php |
| 126 | $time_limit = (int) tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_value' ); |
| 127 | if ( $time_limit ) { |
| 128 | $time_type = tutor_utils()->get_quiz_option( $quiz->ID, 'time_limit.time_type' ); |
| 129 | |
| 130 | $time_type=='minutes' ? $time_limit=$time_limit*60 : 0; |
| 131 | $time_type=='hours' ? $time_limit=$time_limit*3660 : 0; |
| 132 | $time_type=='days' ? $time_limit=$time_limit*86400 : 0; |
| 133 | $time_type=='weeks' ? $time_limit=$time_limit*86400*7 : 0; |
| 134 | |
| 135 | // To Fix: If time larger than 24 hours, the hour portion starts from 0 again. Fix later. |
| 136 | echo gmdate('H:i:s', $time_limit); |
| 137 | } |
| 138 | |
| 139 | $has_attempt = tutor_utils()->has_attempted_quiz( get_current_user_id(), $quiz->ID ) |
| 140 | ?> |
| 141 | |
| 142 | <?php if($show_permalink): ?> |
| 143 | <input type="checkbox" class="tutor-form-check-input tutor-form-check-circle" disabled="disabled" readonly="readonly" <?php echo esc_attr( $has_attempt ? 'checked="checked"' : '' ); ?>/> |
| 144 | <?php else: ?> |
| 145 | <i class="tutor-icon-lock-line" area-hidden="true"></i> |
| 146 | <?php endif; ?> |
| 147 | </span> |
| 148 | </div> |
| 149 | </a> |
| 150 | </div> |
| 151 | </div> |
| 152 | <?php |
| 153 | |
| 154 | } elseif ( $post->post_type === 'tutor_assignments' ) { |
| 155 | /** |
| 156 | * Assignments |
| 157 | * |
| 158 | * @since this block v.1.3.3 |
| 159 | */ |
| 160 | ?> |
| 161 | <div class="tutor-lessons-under-topic"> |
| 162 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-primary' : ''; ?>"> |
| 163 | <a href="<?php echo $show_permalink ? get_permalink( $post->ID ) : '#'; ?>" class="tutor-single-assignment-a tutor-d-flex tutor-justify-between" data-assignment-id="<?php echo $post->ID; ?>"> |
| 164 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 165 | <span class="tutor-icon-assignment tutor-mr-8" area-hidden="true"></span> |
| 166 | <span class="lesson_title tutor-fs-7 tutor-color-secondary"> |
| 167 | <?php echo $post->post_title; ?> |
| 168 | </span> |
| 169 | </div> |
| 170 | <div class="tutor-single-lesson-items-right tutor-d-flex tutor-lesson-right-icons"> |
| 171 | <?php if($show_permalink): ?> |
| 172 | <?php do_action( 'tutor/assignment/right_icon_area', $post ); ?> |
| 173 | <?php else: ?> |
| 174 | <i class="tutor-icon-lock-line"></i> |
| 175 | <?php endif; ?> |
| 176 | </div> |
| 177 | </a> |
| 178 | </div> |
| 179 | </div> |
| 180 | <?php |
| 181 | } elseif ( $post->post_type === 'tutor_zoom_meeting' ) { |
| 182 | /** |
| 183 | * Zoom Meeting |
| 184 | * |
| 185 | * @since this block v.1.7.1 |
| 186 | */ |
| 187 | ?> |
| 188 | <div class="tutor-lessons-under-topic"> |
| 189 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-primary' : ''; ?>"> |
| 190 | <a href="<?php echo $show_permalink ? esc_url( get_permalink( $post->ID ) ) : '#'; ?>" class="sidebar-single-zoom-meeting-a tutor-d-flex tutor-justify-between"> |
| 191 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 192 | <span class="tutor-icon-brand-zoom-o tutor-mr-8" area-hidden="true"></span> |
| 193 | <span class="lesson_title tutor-fs-7 tutor-color-secondary"> |
| 194 | <?php echo esc_html( $post->post_title ); ?> |
| 195 | </span> |
| 196 | </div> |
| 197 | <div class="tutor-single-lesson-items-right tutor-d-flex tutor-lesson-right-icons"> |
| 198 | <?php if($show_permalink): ?> |
| 199 | <?php do_action( 'tutor/zoom/right_icon_area', $post->ID ); ?> |
| 200 | <?php else: ?> |
| 201 | <i class="tutor-icon-lock-line"></i> |
| 202 | <?php endif; ?> |
| 203 | </div> |
| 204 | </a> |
| 205 | </div> |
| 206 | </div> |
| 207 | <?php |
| 208 | |
| 209 | } else { |
| 210 | |
| 211 | /** |
| 212 | * Lesson |
| 213 | */ |
| 214 | |
| 215 | $video = tutor_utils()->get_video_info(); |
| 216 | |
| 217 | $play_time = false; |
| 218 | if ( $video ) { |
| 219 | $play_time = $video->playtime; |
| 220 | } |
| 221 | $is_completed_lesson = tutor_utils()->is_completed_lesson(); |
| 222 | ?> |
| 223 | <div class="tutor-lessons-under-topic"> |
| 224 | <div class="tutor-single-lesson-items <?php echo ( $currentPost->ID == get_the_ID() ) ? 'active tutor-color-primary' : ''; ?>"> |
| 225 | <a href="<?php echo $show_permalink ? get_the_permalink() : '#'; ?>" class="tutor-single-lesson-a tutor-d-flex tutor-justify-between" data-lesson-id="<?php the_ID(); ?>"> |
| 226 | <div class="tutor-single-lesson-items-left tutor-d-flex"> |
| 227 | <?php |
| 228 | $tutor_lesson_type_icon = $play_time ? 'brand-youtube-bold' : 'file-document'; |
| 229 | echo '<span class="tutor-icon-' . $tutor_lesson_type_icon . ' tutor-mr-8" area-hidden="true"></span>'; |
| 230 | ?> |
| 231 | <span class="lesson_title tutor-fs-7 tutor-color-secondary"> |
| 232 | <?php the_title(); ?> |
| 233 | </span> |
| 234 | </div> |
| 235 | <div class="tutor-single-lesson-items-right tutor-d-flex"> |
| 236 | <?php |
| 237 | do_action( 'tutor/lesson_list/right_icon_area', $post ); |
| 238 | if ( $play_time ) { |
| 239 | echo "<span class='tutor-fs-7 tutor-color-secondary'>" . tutor_utils()->get_optimized_duration( $play_time ) . '</span>'; |
| 240 | } |
| 241 | $lesson_complete_icon = $is_completed_lesson ? 'checked' : ''; |
| 242 | |
| 243 | if($show_permalink) { |
| 244 | echo "<input $lesson_complete_icon type='checkbox' class='tutor-form-check-input tutor-form-check-circle' disabled readonly />"; |
| 245 | } else { |
| 246 | echo '<i class="tutor-icon-lock-line"></i>'; |
| 247 | } |
| 248 | ?> |
| 249 | </div> |
| 250 | </a> |
| 251 | </div> |
| 252 | </div> |
| 253 | <?php |
| 254 | } |
| 255 | } |
| 256 | $lessons->reset_postdata(); |
| 257 | do_action( 'tutor/lesson_list/after/topic', $topic_id ); |
| 258 | ?> |
| 259 | </div> |
| 260 | <?php |
| 261 | } |
| 262 | $topics->reset_postdata(); |
| 263 | wp_reset_postdata(); |
| 264 | } |
| 265 | ?> |
| 266 | </div> |
| 267 | |
| 268 | <div id="sidebar-qna-tab-content" class="tutor-lesson-sidebar-tab-item"> |
| 269 | <?php |
| 270 | tutor_lesson_sidebar_question_and_answer(); |
| 271 | ?> |
| 272 | </div> |
| 273 | </div> |
| 274 | </div> |
| 275 | <?php do_action( 'tutor_lesson/single/after/lesson_sidebar' ); ?> |
| 276 |