LLMS_Question::toArrayAfter( array $arr )

Called before data is sorted and returned by $this->toArray()


Description Description

Extending classes should override this data if custom data should be added when object is converted to an array or json.


Top ↑

Parameters Parameters

$arr

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


Top ↑

Return Return

(array)


Top ↑

Source Source

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

	 *
	 * @param array $arr Array of data to be serialized.
	 * @return array
	 */
	protected function toArrayAfter( $arr ) {

		unset( $arr['author'] );
		unset( $arr['date'] );
		unset( $arr['excerpt'] );
		unset( $arr['modified'] );
		unset( $arr['status'] );

		$choices = array();
		foreach ( $this->get_choices() as $choice ) {
			$choices[] = $choice->get_data();
		}
		$arr['choices'] = $choices;

		if ( 'group' === $this->get( 'question_type' ) ) {
			$arr['questions'] = array();
			foreach ( $this->get_questions() as $question ) {
				$arr['questions'][] = $question->toArray();
			}
		}


Top ↑

Changelog Changelog

Changelog
Version Description
3.3.0
3.16.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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