LLMS_Quiz_Legacy::get_users_last_attempt( $user )


Description Description


Source Source

File: includes/class.llms.quiz.legacy.php

	public function get_users_last_attempt( $user ) {

		if ( is_a( $user, '\LLMS\Users\User' ) ) {
			$user = llms_get_student( $user->get_id() );
		}

		$quiz_data = $user->quizzes()->get_all();

		$last_attempt = array();

		foreach ( (array) $quiz_data as $quiz ) {
			if ( isset( $quiz['id'] ) && (int) $quiz['id'] === (int) $this->get_id()
				&& (int) $this->get_total_attempts_by_user( $user->get_id() ) === (int) $quiz['attempt'] ) {
				$last_attempt = $quiz;
			}
		}

		return $last_attempt;
	}


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: