Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update - add review progress link button to course card when strict mode #579

Merged
merged 2 commits into from
Oct 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions templates/loop/course-continue.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* Course loop continue when enrolled
*
Expand All @@ -10,32 +9,45 @@
* @since 1.7.4
*/

use Tutor\Models\CourseModel;

?>
<div class="list-item-button">
<?php
$user_id = get_current_user_id();
$course_id = get_the_ID();
$enroll_btn = '<a href="' . esc_url( get_the_permalink() ) . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block">
' . __( 'Start Learning', 'tutor' ) . '
</a>
';

$course_id = get_the_ID();
$enroll_btn = '<a href="' . esc_url( get_the_permalink() ) . '" class="tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block">
' . __( 'Start Learning', 'tutor' ) . '
</a>
';
$lesson_url = tutor_utils()->get_course_first_lesson();
$completed_percent = tutor_utils()->get_course_completed_percent();
$is_completed_course = tutor_utils()->is_completed_course();
$retake_course = tutor_utils()->can_user_retake_course();
$button_class = 'tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ';
$can_complete_course = CourseModel::can_complete_course( $course_id, $user_id );
$completion_mode = tutor_utils()->get_option( 'course_completion_process' );

$lesson_url = tutor_utils()->get_course_first_lesson();
$completed_percent = tutor_utils()->get_course_completed_percent();
$is_completed_course = tutor_utils()->is_completed_course();
$retake_course = tutor_utils()->can_user_retake_course();
$button_class = 'tutor-btn tutor-btn-outline-primary tutor-btn-md tutor-btn-block ' . ( $retake_course ? ' tutor-course-retake-button' : '' );
if ( $retake_course && $can_complete_course && CourseModel::MODE_FLEXIBLE === $completion_mode ) {
$button_class .= ' tutor-course-retake-button';
}

if ( $lesson_url && ! $is_completed_course ) {
ob_start();
?>
<a href="<?php echo esc_url( $lesson_url ); ?>" class="<?php echo esc_attr( $button_class ); ?>" data-course_id="<?php echo get_the_ID(); ?>">
<?php
if ( ! $is_completed_course && $completed_percent != 0 ) {
esc_html_e( 'Continue Learning', 'tutor' );
}
if ( 0 == $completed_percent && ! $is_completed_course ) {
esc_html_e( 'Start Learning', 'tutor' );
if ( ! $is_completed_course ) {
if ( 0 === (int) $completed_percent ) {
esc_html_e( 'Start Learning', 'tutor' );
} elseif ( $completed_percent > 0 && $completed_percent < 100 ) {
esc_html_e( 'Continue Learning', 'tutor' );
} elseif ( 100 === (int) $completed_percent && false === $can_complete_course ) {
esc_html_e( 'Review Progress', 'tutor' );
} else {
esc_html_e( 'Continue Learning', 'tutor' );
}
}
?>
</a>
Expand Down
Loading