LLMS_Quiz::toArrayAfter( array $arr )

Called before data is sorted and returned by $this->toArray() Extending classes should override this data if custom data should be added when object is converted to an array or json


Description Description


Parameters Parameters

$arr

(array) (Required) array of data to be serialized


Top ↑

Return Return

(array)


Top ↑

Source Source

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

	protected function toArrayAfter( $arr ) {

		$arr['questions'] = array();

		// builder lazy loads questions via ajax
		global $llms_builder_lazy_load;
		if ( ! $llms_builder_lazy_load ) {
			foreach ( $this->get_questions() as $question ) {
				$arr['questions'][] = $question->toArray();
			}
		}

		// if theme support quizzes, add theme metadata to the array
		if ( get_theme_support( 'lifterlms-quizzes' ) ) {
			$layout = llms_get_quiz_theme_setting( 'layout' );
			if ( $layout ) {
				$arr[ $layout['id'] ] = get_post_meta( $this->get( 'id' ), $layout['id'], true );
			}
		}

		return $arr;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: