| @@ -4,70 +4,85 @@ | ||
| 4 | 4 | * Edit by Nhamdv |
| 5 | 5 | * |
| 6 | 6 | * @author ThimPress |
| 7 | 7 | * @package Learnpress/Templates |
| 8 | - * @version 4.0.10 | |
| 8 | + * @version 4.0.13 | |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +use LearnPress\Models\CourseModel; | |
| 12 | +use LearnPress\Models\UserItems\UserCourseModel; | |
| 13 | +use LearnPress\TemplateHooks\Course\SingleCourseTemplate; | |
| 14 | +use LearnPress\TemplateHooks\UserItem\UserCourseTemplate; | |
| 15 | + | |
| 11 | 16 | defined( 'ABSPATH' ) || exit(); |
| 12 | 17 | |
| 13 | 18 | if ( ! isset( $user ) || ! isset( $course_ids ) || ! isset( $current_page ) || ! isset( $num_pages ) ) { |
| 14 | 19 | return; |
| 15 | 20 | } |
| 21 | + | |
| 22 | +$userCourseTemplate = UserCourseTemplate::instance(); | |
| 23 | +$singleCourseTemplate = SingleCourseTemplate::instance(); | |
| 16 | 24 | ?> |
| 17 | 25 | |
| 18 | 26 | <?php if ( $current_page === 1 ) : ?> |
| 19 | -<div class="lp_profile_course_progress"> | |
| 20 | - <div class="lp_profile_course_progress__item lp_profile_course_progress__header"> | |
| 21 | - <div></div> | |
| 22 | - <div><?php esc_html_e( 'Name', 'learnpress' ); ?></div> | |
| 23 | - <div><?php esc_html_e( 'Result', 'learnpress' ); ?></div> | |
| 24 | - <div><?php esc_html_e( 'Expiration time', 'learnpress' ); ?></div> | |
| 25 | - <div><?php esc_html_e( 'End time', 'learnpress' ); ?></div> | |
| 26 | - </div> | |
| 27 | - <?php endif; ?> | |
| 27 | +<div class="lp-table-wrap"> | |
| 28 | + <table class="lp_profile_course_progress lp-list-table"> | |
| 29 | + <thead> | |
| 30 | + <tr class="lp_profile_course_progress__item lp_profile_course_progress__header"> | |
| 31 | + <th></th> | |
| 32 | + <th><?php esc_html_e( 'Name', 'learnpress' ); ?></th> | |
| 33 | + <th><?php esc_html_e( 'Result', 'learnpress' ); ?></th> | |
| 34 | + <th><?php esc_html_e( 'Expiration time', 'learnpress' ); ?></th> | |
| 35 | + <th><?php esc_html_e( 'End time', 'learnpress' ); ?></th> | |
| 36 | + </tr> | |
| 37 | + </thead> | |
| 38 | + <?php endif; ?> | |
| 39 | + <tbody> | |
| 40 | + <?php | |
| 41 | + foreach ( $course_ids as $id ) { | |
| 42 | + $courseModel = CourseModel::find( $id, true ); | |
| 43 | + if ( ! $courseModel ) { | |
| 44 | + continue; | |
| 45 | + } | |
| 28 | 46 | |
| 29 | - <?php | |
| 30 | - global $post; | |
| 47 | + $userCourseModel = UserCourseModel::find( $user->get_id(), $id, true ); | |
| 48 | + if ( ! $userCourseModel ) { | |
| 49 | + continue; | |
| 50 | + } | |
| 31 | 51 | |
| 32 | - foreach ( $course_ids as $id ) { | |
| 33 | - $course = learn_press_get_course( $id ); | |
| 34 | - if ( ! $course ) { | |
| 35 | - continue; | |
| 36 | - } | |
| 37 | - | |
| 38 | - $post = get_post( $id ); | |
| 39 | - setup_postdata( $post ); | |
| 40 | - | |
| 41 | - $course_data = $user->get_course_data( $id ); | |
| 42 | - if ( ! $course_data ) { | |
| 43 | - continue; | |
| 44 | - } | |
| 45 | - $course_result = $course_data->get_result(); | |
| 46 | - ?> | |
| 47 | - <div class="lp_profile_course_progress__item"> | |
| 48 | - <div> | |
| 49 | - <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> | |
| 50 | - <?php echo wp_kses_post( $course->get_image( 'course_thumbnail' ) ); ?> | |
| 51 | - </a> | |
| 52 | - </div> | |
| 53 | - <div><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></div> | |
| 54 | - <div><?php echo esc_html( $course_result['result'] ); ?>%</div> | |
| 55 | - <div><?php echo ! empty( $course_data->get_expiration_time() ) ? $course_data->get_expiration_time() : '-'; ?></div> | |
| 56 | - <div><?php echo ! empty( $course_data->get_end_time() ) ? $course_data->get_end_time() : '-'; ?></div> | |
| 57 | - </div> | |
| 58 | - <?php | |
| 59 | - } | |
| 60 | - | |
| 61 | - wp_reset_postdata(); | |
| 62 | - ?> | |
| 63 | - | |
| 64 | - <?php if ( $current_page === 1 ) : ?> | |
| 52 | + $course_result = $userCourseModel->calculate_course_results(); | |
| 53 | + ?> | |
| 54 | + <tr class="lp_profile_course_progress__item"> | |
| 55 | + <td style="max-width: 100px"> | |
| 56 | + <a href="<?php echo $courseModel->get_permalink(); ?>" title="<?php echo $courseModel->get_title(); ?>"> | |
| 57 | + <?php echo wp_kses_post( $singleCourseTemplate->html_image( $courseModel ) ); ?> | |
| 58 | + </a> | |
| 59 | + </td> | |
| 60 | + <td> | |
| 61 | + <a href="<?php echo $courseModel->get_permalink(); ?>" | |
| 62 | + title="<?php echo $courseModel->get_title(); ?>"> | |
| 63 | + <?php echo wp_kses_post( $singleCourseTemplate->html_title( $courseModel ) ); ?> | |
| 64 | + </a> | |
| 65 | + </td> | |
| 66 | + <td><?php echo esc_html( $course_result['result'] ); ?>%</td> | |
| 67 | + <td> | |
| 68 | + <?php echo $userCourseTemplate->html_expire_date_time( $userCourseModel ); ?> | |
| 69 | + </td> | |
| 70 | + <td><?php echo $userCourseTemplate->html_end_date_time( $userCourseModel ); ?></td> | |
| 71 | + </tr> | |
| 72 | + <?php | |
| 73 | + } | |
| 74 | + ?> | |
| 75 | + </tbody> | |
| 76 | + <?php if ( $current_page === 1 ) : ?> | |
| 77 | + </table> | |
| 65 | 78 | </div> |
| 66 | 79 | <?php endif; ?> |
| 67 | 80 | |
| 68 | 81 | <?php if ( $num_pages > 1 && $current_page < $num_pages && $current_page === 1 ) : ?> |
| 69 | 82 | <div class="lp_profile_course_progress__nav"> |
| 70 | - <button data-paged="<?php echo absint( $current_page + 1 ); ?>" | |
| 71 | - data-number="<?php echo absint( $num_pages ); ?>"><?php esc_html_e( 'View more', 'learnpress' ); ?></button> | |
| 83 | + <button class="lp-button" | |
| 84 | + data-paged="<?php echo absint( $current_page + 1 ); ?>" | |
| 85 | + data-number="<?php echo absint( $num_pages ); ?>"><?php esc_html_e( 'View more', 'learnpress' ); ?> | |
| 86 | + </button> | |
| 72 | 87 | </div> |
| 73 | 88 | <?php endif; ?> |