LLMS_Quiz::get_lessons( string $return = 'ids' )

Retrieve lessons this quiz is assigned to


Description Description


Parameters Parameters

$return

(string) (Optional) format of the return [ids|lessons]

Default value: 'ids'


Top ↑

Return Return

(array) array of WP_Post IDs (lesson post types)


Top ↑

Source Source

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

	public function get_lessons( $return = 'ids' ) {

		global $wpdb;
		$query = $wpdb->get_col( $wpdb->prepare(
			"SELECT post_id
			 FROM {$wpdb->postmeta}
			 WHERE meta_key = '_llms_assigned_quiz'
			   AND meta_value = %d;",
			$this->get( 'id' )
		) );

		// return just the ids
		if ( 'ids' === $return ) {
			return $query;
		}

		// setup lesson objects
		$ret = array();
		foreach ( $query as $id ) {
			$ret[] = llms_get_post( $id );
		}
		return $ret;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.12.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: