LLMS_Quiz_Legacy::get_course( $user_id = null )

Retrieve the course associated with the lesson


Description Description


Return Return

(obj|null) Instance of the LLMS_Course or null


Top ↑

Source Source

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

	public function get_course( $user_id = null ) {

		if ( ! $user_id ) {
			$user_id = get_current_user_id();
		}

		$lesson_id = $this->get_assoc_lesson( $user_id );

		// this handles getting the lesson when the quiz hasn't been saved yet or has just been started
		if ( ! $lesson_id ) {
			$session = LLMS()->session->get( 'llms_quiz' );
			$lesson_id = ( $session && isset( $session->assoc_lesson ) ) ? $session->assoc_lesson : false;
		}

		if ( $lesson_id ) {
			$lesson = llms_get_post( $lesson_id );
			return $lesson->get_course();
		}

		return null;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.6.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: