' . __( 'Complete all lessons to mark this course as complete', 'tutor' ) . '
';
}
$quizzes = array();
$assignments = array();
$course_contents = tutor_utils()->get_course_contents_by_id();
if ( tutor_utils()->count( $course_contents ) ) {
foreach ( $course_contents as $content ) {
if ( 'tutor_quiz' === $content->post_type ) {
$quizzes[] = $content;
}
if ( 'tutor_assignments' === $content->post_type ) {
$assignments[] = $content;
}
}
}
$required_assignment_pass = 0;
foreach ( $assignments as $row ) {
$submitted_assignment = tutor_utils()->is_assignment_submitted( $row->ID );
$is_reviewed_by_instructor = null === $submitted_assignment
? false
: get_comment_meta( $submitted_assignment->comment_ID, 'evaluate_time', true );
if ( $submitted_assignment && $is_reviewed_by_instructor ) {
$pass_mark = tutor_utils()->get_assignment_option( $submitted_assignment->comment_post_ID, 'pass_mark' );
$given_mark = get_comment_meta( $submitted_assignment->comment_ID, 'assignment_mark', true );
if ( $given_mark < $pass_mark ) {
$required_assignment_pass++;
}
} else {
$required_assignment_pass++;
}
}
$is_quiz_pass = true;
$required_quiz_pass = 0;
if ( tutor_utils()->count( $quizzes ) ) {
foreach ( $quizzes as $quiz ) {
$attempt = tutor_utils()->get_quiz_attempt( $quiz->ID );
if ( $attempt ) {
$passing_grade = tutor_utils()->get_quiz_option( $quiz->ID, 'passing_grade', 0 );
$earned_percentage = $attempt->earned_marks > 0 ? ( number_format( ( $attempt->earned_marks * 100 ) / $attempt->total_marks ) ) : 0;
if ( $earned_percentage < $passing_grade ) {
$required_quiz_pass++;
$is_quiz_pass = false;
}
} else {
$required_quiz_pass++;
$is_quiz_pass = false;
}
}
}
if ( ! $is_quiz_pass || $required_assignment_pass > 0 ) {
$_msg = '';
$quiz_str = _n( 'quiz', 'quizzes', $required_quiz_pass, 'tutor' );
$assignment_str = _n( 'assignment', 'assignments', $required_assignment_pass, 'tutor' );
if ( ! $is_quiz_pass && 0 == $required_assignment_pass ) {
/* translators: %1$s: number of quiz/assignment pass required; %2$s: quiz/assignment string */
$_msg = sprintf( __( 'You have to pass %1$s %2$s to complete this course.', 'tutor' ), $required_quiz_pass, $quiz_str );
}
if ( $is_quiz_pass && $required_assignment_pass > 0 ) {
//phpcs:ignore
$_msg = sprintf( __( 'You have to pass %1$s %2$s to complete this course.', 'tutor' ), $required_assignment_pass, $assignment_str );
}
if ( ! $is_quiz_pass && $required_assignment_pass > 0 ) {
/* translators: %1$s: number of quiz pass required; %2$s: quiz string; %3$s: number of assignment pass required; %4$s: assignment string */
$_msg = sprintf( __( 'You have to pass %1$s %2$s and %3$s %4$s to complete this course.', 'tutor' ), $required_quiz_pass, $quiz_str, $required_assignment_pass, $assignment_str );
}
return '