LLMS_Quiz_Attempt::get_question_answer( int $question_id, boolean $cache = true, boolean $filter_removed = false )
Retrieve an an answer to a specific question.
Parameters Parameters
- $question_id
-
(int) (Required) Question ID.
- $cache
-
(boolean) (Optional) If
true, save data to to the object for future gets. Defaulttrue.<br> Cached questions won't take into account the$filte_removedparameter.Default value: true
- $filter_removed
-
(boolean) (Optional) If
true, removed questions will be filtered out. Defaultfalse.Default value: false
Return Return
(mixed)
Source Source
File: includes/models/model.llms.quiz.attempt.php
public function get_question_answer( $question_id, $cache = true, $filter_removed = false ) {
$question_objects = $this->get_question_objects( $cache, $filter_removed );
if ( ! $question_objects ) {
return array();
}
foreach ( $question_objects as $attempt_question ) {
$quiz_question = $attempt_question->get_question();
if ( $attempt_question->get_question()->get( 'id' ) === $question_id ) {
$answer = $attempt_question->get( 'answer' );
break;
}
}
return $answer ?? array();
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 7.8.0 | Introduced. |