LLMS_Question::get_quizzes()

Retrieve quizzes this quiz is assigned to


Return Return

(array) Array of WP_Post IDs (quiz post types).


Top ↑

Source Source

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

	 * @since 3.12.0
	 *
	 * @return array Array of WP_Post IDs (quiz post types).
	 */
	public function get_quizzes() {

		$id  = absint( $this->get( 'id' ) );
		$len = strlen( strval( $id ) );

		$str_like = '%' . sprintf( 's:2:"id";s:%1$d:"%2$s";', $len, $id ) . '%';
		$int_like = '%' . sprintf( 's:2:"id";i:%1$s;', $id ) . '%';

		global $wpdb;
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		$query = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
			"SELECT post_id
			 FROM {$wpdb->postmeta}
			 WHERE meta_key = '_llms_questions'
			   AND (
			   	      meta_value LIKE '{$str_like}'
			   	   OR meta_value LIKE '{$int_like}'
			   );"
		);
		// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared


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.