plugin/exo/Manager/AttemptManager.php
public function canPass(Exercise $exercise, User $user = null)
    {
        // TODO : max attempts by day

        $canPass = true;
        if ($user) {
            $max = $exercise->getMaxAttempts();
            if ($max > 0) {
                $nbFinishedPapers = $this->paperManager->countUserFinishedPapers($exercise, $user);
                if ($nbFinishedPapers >= $max) {
                    $canPass = false;
                }
            }
        }

        return $canPass;
    }
public function canPass(Exercise $exercise, User $user = null)
    {
        // TODO : max attempts by day

        $canPass = true;
        if ($user) {
            $max = $exercise->getMaxAttempts();
            if ($max > 0) {
                $nbFinishedPapers = $this->paperManager->countUserFinishedPapers($exercise, $user);
                if ($nbFinishedPapers >= $max) {
                    $canPass = false;
                }
            }
        }

        return $canPass;
    }
public function canPass ( Exercise $ exercise , User $ user = null ) { // TODO : max attempts by day $ canPass = true ; if ( $ user ) { $ max = $ exercise -> getMaxAttempts ( ) ; if ( $ max > 0 ) { $ nbFinishedPapers = $ this -> paperManager -> countUserFinishedPapers ( $ exercise , $ user ) ; if ( $ nbFinishedPapers >= $ max ) { $ canPass = false ; } } } return $ canPass ; }
Checks if a user is allowed to pass a quiz or not.

Based on the maximum attempt allowed and the number of already done by the user.

@param Exercise $exercise
@param User     $user

@return bool
Checks if a user is allowed to pass a quiz or not .