LLMS_Quiz::is_orphan( bool $deep = false )

Determine if the quiz is an orphan.


Parameters Parameters

$deep

(bool) (Optional) Whether or not deeply check this quiz is orphan. Default false. When set to true will ensure not only that this quiz as a lesson_id property set But also that the lesson with id lesson_id has a quiz property as equal as this quiz id.

Default value: false


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/models/model.llms.quiz.php

	public function is_orphan( $deep = false ) {

		$parent_id = $this->get( 'lesson_id' );

		if ( ! $parent_id ) {
			return true;
		}

		/**
		 * This is to take into account possible data inconsistency.
		 *
		 * @link https://github.com/gocodebox/lifterlms/issues/1039
		 */
		if ( $deep ) {
			$lesson = llms_get_post( $parent_id );
			// Both the ids are already absint, see LLMS_Post_Model::___get().
			if ( ! $lesson || $this->get( 'id' ) !== $lesson->get( 'quiz' ) ) {
				return true;
			}
		}

		return false;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.2.0 Added the $deep parameter.
3.16.12 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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