LLMS_Quiz_Attempt::get_next_question( int $last_question = null, string $return = 'id' )
Retrieve the next unanswered question in the attempt
Parameters Parameters
- $last_question
-
(int) (Optional) WP Post ID of the current LLMS_Question the "next" refers to. Default
null.Default value: null
- $return
-
(string) (Optional) Return type 'id|array'. Default 'id'.
Default value: 'id'
Return Return
(int|array|false)
Source Source
File: includes/models/model.llms.quiz.attempt.php
public function get_next_question( $last_question = null, $return = 'id' ) {
$next = false;
foreach ( $this->get_questions() as $question ) {
if ( $next || is_null( $question['answer'] ) ) {
return 'id' === $return ? $question['id'] : $question;
// When rewinding and moving back through we don't want to skip questions.
} elseif ( $last_question && absint( $last_question ) === absint( $question['id'] ) ) {
$next = true;
}
}
return false;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.8.0 | Added $return param, by default "id". |
| 4.2.0 | Use strict type comparison. |
| 3.9.0 | |
| 3.16.0 | Introduced. |