LLMS_Quiz_Legacy::get_remaining_attempts_by_user( int $user_id )
Get remaining quiz attempts
Description Description
Parameters Parameters
- $user_id
-
(int) (Required) [ID of user]
Return Return
(int) [number of attempts user has remaining]
Source Source
File: includes/class.llms.quiz.legacy.php
public function get_remaining_attempts_by_user( $user_id ) { $attempts_allowed = $this->get_total_allowed_attempts(); $attempts = $this->get_total_attempts_by_user( $user_id ); if ( ! empty( $attempts_allowed ) ) { if ( empty( $attempts ) ) { $attempts = 0; } $total_attempts_remaining = ( $attempts_allowed - $attempts ); // don't show negative attempts if ( $total_attempts_remaining < 0 ) { $total_attempts_remaining = 0; } } else { $total_attempts_remaining = _x( 'Unlimited', 'quiz attempts remaining', 'lifterlms' ); } return $total_attempts_remaining; }
Expand full source code Collapse full source code View on GitHub