LLMS_Student_Quizzes::get_attempts_remaining_for_quiz( int $quiz_id )
Get the # of attempts remaining by a student for a given quiz
Description Description
Parameters Parameters
- $quiz_id
-
(int) (Required) WP Post ID of the Quiz
Return Return
(mixed)
Source Source
File: includes/models/model.llms.student.quizzes.php
public function get_attempts_remaining_for_quiz( $quiz_id ) { $quiz = llms_get_post( $quiz_id ); $ret = _x( 'Unlimited', 'quiz attempts remaining', 'lifterlms' ); if ( $quiz->has_attempt_limit() ) { $allowed = $quiz->get( 'allowed_attempts' ); $used = $this->count_attempts_by_quiz( $quiz->get( 'id' ) ); // ensure undefined, null, '', etc.. show as an int if ( ! $allowed ) { $allowed = 0; } $remaining = ( $allowed - $used ); // don't show negative attempts $ret = max( 0, $remaining ); } return apply_filters( 'llms_student_quiz_attempts_remaining_for_quiz', $ret, $quiz, $this ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.16.0 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: