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. Default true.<br> Cached questions won't take into account the $filte_removed parameter.

Default value: true

$filter_removed

(boolean) (Optional) If true, removed questions will be filtered out. Default false.

Default value: false


Top ↑

Return Return

(mixed)


Top ↑

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();
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.