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