LLMS_Query_Quiz_Attempt::parse_args()
Parses data passed to $statuses
Description Description
Convert strings to array and ensure resulting array contains only valid statuses. If no valid statuses, returns to the default.
Return Return
(void)
Source Source
File: includes/class.llms.query.quiz.attempt.php
protected function parse_args() {
// Sanitize post, user, excluded attempts ids.
foreach ( array( 'student_id', 'quiz_id', 'exclude' ) as $key ) {
$this->arguments[ $key ] = $this->sanitize_id_array( $this->arguments[ $key ] );
}
// Validate status args.
$valid_statuses = array_keys( llms_get_quiz_attempt_statuses() );
foreach ( array( 'status', 'status_exclude' ) as $key ) {
// Allow single statuses to be passed in as a string.
if ( is_string( $this->arguments[ $key ] ) ) {
$this->arguments[ $key ] = array( $this->arguments[ $key ] );
}
// Ensure submitted statuses are valid.
if ( $this->arguments[ $key ] ) {
$this->arguments[ $key ] = array_intersect( $valid_statuses, $this->arguments[ $key ] );
}
}
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.2.0 | Added exclude arg sanitization. |
| 3.16.0 | Introduced. |