announcements
4 years ago
assignments
4 years ago
elements
4 years ago
enrolled-courses
4 years ago
instructor
3 years ago
my-courses
4 years ago
my-quiz-attempts
4 years ago
notifications
4 years ago
question-answer
4 years ago
quiz-attempts
4 years ago
reviews
4 years ago
settings
3 years ago
withdraw-method-fields
4 years ago
announcements.php
4 years ago
assignments.php
4 years ago
create-course.php
3 years ago
dashboard.php
3 years ago
enrolled-courses.php
4 years ago
index.php
4 years ago
logged-in.php
4 years ago
my-courses.php
4 years ago
my-profile.php
4 years ago
my-quiz-attempts.php
4 years ago
purchase_history.php
4 years ago
question-answer.php
4 years ago
quiz-attempts.php
4 years ago
registration.php
4 years ago
reviews.php
4 years ago
settings.php
4 years ago
wishlist.php
4 years ago
withdraw.php
3 years ago
my-courses.php
204 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package TutorLMS/Templates |
| 5 | * @version 1.4.3 |
| 6 | */ |
| 7 | |
| 8 | // Get the user ID and active tab |
| 9 | $current_user_id = get_current_user_id(); |
| 10 | !isset($active_tab) ? $active_tab = 'my-courses' : 0; |
| 11 | |
| 12 | // Map required course status according to page |
| 13 | $status_map = array( |
| 14 | 'my-courses' => 'publish', |
| 15 | 'my-courses/draft-courses' => 'draft', |
| 16 | 'my-courses/pending-courses' => 'pending' |
| 17 | ); |
| 18 | |
| 19 | // Set currently required course status fo rcurrent tab |
| 20 | $status = isset( $status_map[$active_tab] ) ? $status_map[$active_tab] : 'publish'; |
| 21 | |
| 22 | // Get counts for course tabs |
| 23 | $count_map = array( |
| 24 | 'publish' => tutor_utils()->get_courses_by_instructor($current_user_id, 'publish', 0, 0, true), |
| 25 | 'pending' => tutor_utils()->get_courses_by_instructor($current_user_id, 'pending', 0, 0, true), |
| 26 | 'draft' => tutor_utils()->get_courses_by_instructor($current_user_id, 'draft', 0, 0, true), |
| 27 | ); |
| 28 | |
| 29 | $course_archive_arg = isset($GLOBALS['tutor_course_archive_arg']) ? $GLOBALS['tutor_course_archive_arg']['column_per_row'] : null; |
| 30 | $courseCols = $course_archive_arg === null ? tutor_utils()->get_option('courses_col_per_row', 4) : $course_archive_arg; |
| 31 | $per_page = tutor_utils()->get_option( 'courses_per_page', 10 ); |
| 32 | $paged = (isset($_GET['current_page']) && is_numeric($_GET['current_page']) && $_GET['current_page'] >= 1) ? $_GET['current_page'] : 1; |
| 33 | $offset = $per_page * ($paged-1); |
| 34 | |
| 35 | $results = tutor_utils()->get_courses_by_instructor($current_user_id, $status, $offset, $per_page); |
| 36 | ?> |
| 37 | |
| 38 | <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-16"> |
| 39 | <?php esc_html_e('My Courses', 'tutor'); ?> |
| 40 | </div> |
| 41 | |
| 42 | <div class="tutor-dashboard-content-inner my-courses"> |
| 43 | <div class="tutor-mb-32"> |
| 44 | <ul class="tutor-nav"> |
| 45 | <li class="tutor-nav-item"> |
| 46 | <a class="tutor-nav-link<?php echo $active_tab == 'my-courses' ? ' is-active' : ''; ?>" href="<?php echo esc_url(tutor_utils()->get_tutor_dashboard_page_permalink('my-courses')); ?>"> |
| 47 | <?php esc_html_e('Publish', 'tutor'); ?> <?php echo "(" . $count_map['publish'] . ")"; ?> |
| 48 | </a> |
| 49 | </li> |
| 50 | <li class="tutor-nav-item"> |
| 51 | <a class="tutor-nav-link<?php echo $active_tab == 'my-courses/pending-courses' ? ' is-active' : ''; ?>" href="<?php echo esc_url(tutor_utils()->get_tutor_dashboard_page_permalink('my-courses/pending-courses')); ?>"> |
| 52 | <?php esc_html_e('Pending', 'tutor'); ?> <?php echo "(" . $count_map['pending'] . ")"; ?> |
| 53 | </a> |
| 54 | </li> |
| 55 | <li class="tutor-nav-item"> |
| 56 | <a class="tutor-nav-link<?php echo $active_tab == 'my-courses/draft-courses' ? ' is-active' : ''; ?>" href="<?php echo esc_url(tutor_utils()->get_tutor_dashboard_page_permalink('my-courses/draft-courses')); ?>"> |
| 57 | <?php esc_html_e('Draft', 'tutor'); ?> <?php echo "(" . $count_map['draft'] . ")"; ?> |
| 58 | </a> |
| 59 | </li> |
| 60 | </ul> |
| 61 | </div> |
| 62 | |
| 63 | <!-- Course list --> |
| 64 | <?php |
| 65 | $placeholder_img = tutor()->url . 'assets/images/placeholder.svg'; |
| 66 | |
| 67 | if (!is_array($results) || (!count($results) && $paged==1)) { |
| 68 | tutor_utils()->tutor_empty_state(tutor_utils()->not_found_text()); |
| 69 | } else { |
| 70 | ?> |
| 71 | <div class="tutor-grid tutor-grid-3"> |
| 72 | <?php |
| 73 | global $post; |
| 74 | foreach ($results as $post) : |
| 75 | setup_postdata($post); |
| 76 | |
| 77 | $avg_rating = tutor_utils()->get_course_rating()->rating_avg; |
| 78 | $tutor_course_img = get_tutor_course_thumbnail_src(); |
| 79 | $id_string_delete = 'tutor_my_courses_delete_' . $post->ID; |
| 80 | $row_id = 'tutor-dashboard-my-course-' . $post->ID; |
| 81 | $course_duration = get_tutor_course_duration_context($post->ID, true); |
| 82 | $course_students = tutor_utils()->count_enrolled_users_by_course(); |
| 83 | ?> |
| 84 | |
| 85 | <div id="<?php echo $row_id; ?>" class="tutor-card tutor-course-card tutor-mycourse-<?php the_ID(); ?>"> |
| 86 | <a href="<?php echo get_the_permalink(); ?>" class="tutor-d-block"> |
| 87 | <div class="tutor-ratio tutor-ratio-16x9"> |
| 88 | <img class="tutor-card-image-top" src="<?php echo empty(esc_url($tutor_course_img)) ? $placeholder_img : esc_url($tutor_course_img) ?>" alt="<?php the_title(); ?>" loading="lazy"> |
| 89 | </div> |
| 90 | </a> |
| 91 | |
| 92 | <div class="tutor-card-body"> |
| 93 | <div class="tutor-meta tutor-mb-8"> |
| 94 | <span> |
| 95 | <?php echo esc_html(get_the_date()); ?> <?php echo esc_html(get_the_time()); ?> |
| 96 | </span> |
| 97 | </div> |
| 98 | |
| 99 | <div class="tutor-course-name tutor-fs-6 tutor-fw-bold tutor-mb-16"> |
| 100 | <a href="<?php echo get_the_permalink(); ?>"><?php the_title(); ?></a> |
| 101 | </div> |
| 102 | |
| 103 | <?php if ( !empty( $course_duration ) || !empty( $course_students ) ) : ?> |
| 104 | <div class="tutor-meta tutor-mt-16"> |
| 105 | <?php if ( !empty( $course_duration ) ) : ?> |
| 106 | <div> |
| 107 | <span class="tutor-icon-clock-line tutor-meta-icon" area-hidden="true"></span> |
| 108 | <span class="tutor-meta-value"><?php echo $course_duration; ?></span> |
| 109 | </div> |
| 110 | <?php endif; ?> |
| 111 | |
| 112 | <?php if ( !empty( $course_students ) ) : ?> |
| 113 | <div> |
| 114 | <span class="tutor-icon-user-line tutor-meta-icon" area-hidden="true"></span> |
| 115 | <span class="tutor-meta-value"><?php echo $course_students; ?></span> |
| 116 | </div> |
| 117 | <?php endif; ?> |
| 118 | </div> |
| 119 | <?php endif; ?> |
| 120 | </div> |
| 121 | |
| 122 | <div class="tutor-card-footer"> |
| 123 | <div class="tutor-d-flex tutor-align-center tutor-justify-between"> |
| 124 | <div class="tutor-d-flex tutor-align-center"> |
| 125 | <span class="tutor-fs-7 tutor-fw-medium tutor-color-muted tutor-mr-4"> |
| 126 | <?php esc_html_e('Price:', 'tutor') ?> |
| 127 | </span> |
| 128 | <span class="tutor-fs-7 tutor-fw-medium tutor-color-black"> |
| 129 | <?php |
| 130 | $price = tutor_utils()->get_course_price(); |
| 131 | if ( null === $price ) { |
| 132 | esc_html_e( 'Free', 'tutor' ); |
| 133 | } else { |
| 134 | echo tutor_utils()->get_course_price(); |
| 135 | } |
| 136 | ?> |
| 137 | </span> |
| 138 | </div> |
| 139 | <div class="tutor-iconic-btn-group tutor-mr-n8"> |
| 140 | <a href="<?php echo tutor_utils()->course_edit_link($post->ID); ?>" class="tutor-iconic-btn"> |
| 141 | <i class="tutor-icon-edit" area-hidden="true"></i> |
| 142 | </a> |
| 143 | <a href="#" data-tutor-modal-target="<?php echo $id_string_delete; ?>" class="tutor-dashboard-element-delete-btn tutor-iconic-btn"> |
| 144 | <i class="tutor-icon-trash-can-line" area-hidden="true"></i> |
| 145 | </a> |
| 146 | </div> |
| 147 | </div> |
| 148 | </div> |
| 149 | |
| 150 | <!-- Delete prompt modal --> |
| 151 | <div id="<?php echo $id_string_delete; ?>" class="tutor-modal"> |
| 152 | <div class="tutor-modal-overlay"></div> |
| 153 | <div class="tutor-modal-window"> |
| 154 | <div class="tutor-modal-content tutor-modal-content-white"> |
| 155 | <button class="tutor-iconic-btn tutor-modal-close-o" data-tutor-modal-close> |
| 156 | <span class="tutor-icon-times" area-hidden="true"></span> |
| 157 | </button> |
| 158 | |
| 159 | <div class="tutor-modal-body tutor-text-center"> |
| 160 | <div class="tutor-mt-48"> |
| 161 | <img class="tutor-d-inline-block" src="<?php echo tutor()->url; ?>assets/images/icon-trash.svg" /> |
| 162 | </div> |
| 163 | |
| 164 | <div class="tutor-fs-3 tutor-fw-medium tutor-color-black tutor-mb-12"><?php esc_html_e('Delete This Course?', 'tutor'); ?></div> |
| 165 | <div class="tutor-fs-6 tutor-color-muted"><?php esc_html_e('Are you sure you want to delete this course permanently from the site? Please confirm your choice.', 'tutor'); ?></div> |
| 166 | |
| 167 | <div class="tutor-d-flex tutor-justify-center tutor-my-48"> |
| 168 | <button data-tutor-modal-close class="tutor-btn tutor-btn-outline-primary"> |
| 169 | <?php esc_html_e('Cancel', 'tutor'); ?> |
| 170 | </button> |
| 171 | <button class="tutor-btn tutor-btn-primary tutor-list-ajax-action tutor-ml-20" data-request_data='{"course_id":<?php echo $post->ID; ?>,"action":"tutor_delete_dashboard_course"}' data-delete_element_id="<?php echo $row_id; ?>"> |
| 172 | <?php esc_html_e('Yes, Delete This', 'tutor'); ?> |
| 173 | </button> |
| 174 | </div> |
| 175 | </div> |
| 176 | </div> |
| 177 | </div> |
| 178 | </div> |
| 179 | </div> |
| 180 | <?php endforeach; |
| 181 | wp_reset_postdata(); ?> |
| 182 | </div> |
| 183 | <div class="tutor-mt-20"> |
| 184 | <?php |
| 185 | if ($count_map[$status] > $per_page) { |
| 186 | $pagination_data = array( |
| 187 | 'total_items' => $count_map[$status], |
| 188 | 'per_page' => $per_page, |
| 189 | 'paged' => $paged, |
| 190 | ); |
| 191 | |
| 192 | tutor_load_template_from_custom_path( |
| 193 | tutor()->path . 'templates/dashboard/elements/pagination.php', |
| 194 | $pagination_data |
| 195 | ); |
| 196 | } |
| 197 | ?> |
| 198 | |
| 199 | </div> |
| 200 | <?php |
| 201 | } |
| 202 | ?> |
| 203 | </div> |
| 204 |