plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php
public function serialize(ChoiceQuestion $choiceQuestion, array $options = [])
    {
        $serialized = [
            'random' => $choiceQuestion->getShuffle(),
            'multiple' => $choiceQuestion->isMultiple(),
            'numbering' => $choiceQuestion->getNumbering(),
            'direction' => $choiceQuestion->getDirection(),
        ];

        // Serializes choices
        $choices = $this->serializeChoices($choiceQuestion, $options);

        if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
            shuffle($choices);
        }

        $serialized['choices'] = $choices;

        if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
            $serialized['solutions'] = $this->serializeSolutions($choiceQuestion);
        }

        return $serialized;
    }
public function serialize(ChoiceQuestion $choiceQuestion, array $options = [])
    {
        $serialized = [
            'random' => $choiceQuestion->getShuffle(),
            'multiple' => $choiceQuestion->isMultiple(),
            'numbering' => $choiceQuestion->getNumbering(),
            'direction' => $choiceQuestion->getDirection(),
        ];

        // Serializes choices
        $choices = $this->serializeChoices($choiceQuestion, $options);

        if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
            shuffle($choices);
        }

        $serialized['choices'] = $choices;

        if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
            $serialized['solutions'] = $this->serializeSolutions($choiceQuestion);
        }

        return $serialized;
    }
public function serialize ( ChoiceQuestion $ choiceQuestion , array $ options = [ ] ) { $ serialized = [ 'random' => $ choiceQuestion -> getShuffle ( ) , 'multiple' => $ choiceQuestion -> isMultiple ( ) , 'numbering' => $ choiceQuestion -> getNumbering ( ) , 'direction' => $ choiceQuestion -> getDirection ( ) , ] ; // Serializes choices $ choices = $ this -> serializeChoices ( $ choiceQuestion , $ options ) ; if ( $ choiceQuestion -> getShuffle ( ) && in_array ( Transfer :: SHUFFLE_ANSWERS , $ options ) ) { shuffle ( $ choices ) ; } $ serialized [ 'choices' ] = $ choices ; if ( in_array ( Transfer :: INCLUDE_SOLUTIONS , $ options ) ) { $ serialized [ 'solutions' ] = $ this -> serializeSolutions ( $ choiceQuestion ) ; } return $ serialized ; }
Converts a Choice question into a JSON-encodable structure.

@param ChoiceQuestion $choiceQuestion
@param array          $options

@return array
Converts a Choice question into a JSON - encodable structure .