| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template for displaying own courses in courses tab of user profile page. |
| 4 |
* Edit by Nhamdv |
| 5 |
* |
| 6 |
* @author ThimPress |
| 7 |
* @package Learnpress/Templates |
| 8 |
* @version 4.0.13 |
| 9 |
*/ |
| 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 |
|
| 16 |
defined( 'ABSPATH' ) || exit(); |
| 17 |
|
| 18 |
if ( ! isset( $user ) || ! isset( $course_ids ) || ! isset( $current_page ) || ! isset( $num_pages ) ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
$userCourseTemplate = UserCourseTemplate::instance(); |
| 23 |
$singleCourseTemplate = SingleCourseTemplate::instance(); |
| 24 |
?> |
| 25 |
|
| 26 |
<?php if ( $current_page === 1 ) : ?> |
| 27 |
<table class="lp_profile_course_progress lp-list-table"> |
| 28 |
<thead> |
| 29 |
<tr class="lp_profile_course_progress__item lp_profile_course_progress__header"> |
| 30 |
<th></th> |
| 31 |
<th><?php esc_html_e( 'Name', 'learnpress' ); ?></th> |
| 32 |
<th><?php esc_html_e( 'Result', 'learnpress' ); ?></th> |
| 33 |
<th><?php esc_html_e( 'Expiration time', 'learnpress' ); ?></th> |
| 34 |
<th><?php esc_html_e( 'End time', 'learnpress' ); ?></th> |
| 35 |
</tr> |
| 36 |
</thead> |
| 37 |
<?php endif; ?> |
| 38 |
<tbody> |
| 39 |
<?php |
| 40 |
foreach ( $course_ids as $id ) { |
| 41 |
$courseModel = CourseModel::find( $id, true ); |
| 42 |
if ( ! $courseModel ) { |
| 43 |
continue; |
| 44 |
} |
| 45 |
|
| 46 |
$userCourseModel = UserCourseModel::find( $user->get_id(), $id, true ); |
| 47 |
if ( ! $userCourseModel ) { |
| 48 |
continue; |
| 49 |
} |
| 50 |
|
| 51 |
$course_result = $userCourseModel->calculate_course_results(); |
| 52 |
?> |
| 53 |
<tr class="lp_profile_course_progress__item"> |
| 54 |
<td> |
| 55 |
<a href="<?php echo $courseModel->get_permalink(); ?>" title="<?php echo $courseModel->get_title(); ?>"> |
| 56 |
<?php echo wp_kses_post( $singleCourseTemplate->html_image( $courseModel ) ); ?> |
| 57 |
</a> |
| 58 |
</td> |
| 59 |
<td> |
| 60 |
<a href="<?php echo $courseModel->get_permalink(); ?>" |
| 61 |
title="<?php echo $courseModel->get_title(); ?>"> |
| 62 |
<?php echo wp_kses_post( $singleCourseTemplate->html_title( $courseModel ) ); ?> |
| 63 |
</a> |
| 64 |
</td> |
| 65 |
<td><?php echo esc_html( $course_result['result'] ); ?>%</td> |
| 66 |
<td> |
| 67 |
<?php echo $userCourseTemplate->html_expire_date_time( $userCourseModel ); ?> |
| 68 |
</td> |
| 69 |
<td><?php echo $userCourseTemplate->html_end_date_time( $userCourseModel ); ?></td> |
| 70 |
</tr> |
| 71 |
<?php |
| 72 |
} |
| 73 |
?> |
| 74 |
</tbody> |
| 75 |
<?php if ( $current_page === 1 ) : ?> |
| 76 |
</table> |
| 77 |
<?php endif; ?> |
| 78 |
|
| 79 |
<?php if ( $num_pages > 1 && $current_page < $num_pages && $current_page === 1 ) : ?> |
| 80 |
<div class="lp_profile_course_progress__nav"> |
| 81 |
<button class="lp-button" |
| 82 |
data-paged="<?php echo absint( $current_page + 1 ); ?>" |
| 83 |
data-number="<?php echo absint( $num_pages ); ?>"><?php esc_html_e( 'View more', 'learnpress' ); ?> |
| 84 |
</button> |
| 85 |
</div> |
| 86 |
<?php endif; ?> |
| 87 |
|