plugin/exo/Serializer/Item/Type/SelectionQuestionSerializer.php
public function serialize(SelectionQuestion $selectionQuestion, array $options = [])
    {
        $serialized = [
            'text' => $selectionQuestion->getText(),
            'mode' => $selectionQuestion->getMode(),
        ];

        if ($selectionQuestion->getPenalty()) {
            $serialized['penalty'] = $selectionQuestion->getPenalty();
        }

        if ($selectionQuestion->getTries()) {
            $serialized['tries'] = $selectionQuestion->getTries();
        }

        switch ($selectionQuestion->getMode()) {
           case SelectionQuestion::MODE_FIND:
               $serialized['tries'] = $selectionQuestion->getTries();
              break;
           case SelectionQuestion::MODE_SELECT:
               $serialized['selections'] = $this->serializeSelections($selectionQuestion);
              break;
           case SelectionQuestion::MODE_HIGHLIGHT:
               $serialized['selections'] = $this->serializeSelections($selectionQuestion);
               $serialized['colors'] = $this->serializeColors($selectionQuestion);
              break;
        }

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

        return $serialized;
    }
public function serialize(SelectionQuestion $selectionQuestion, array $options = [])
    {
        $serialized = [
            'text' => $selectionQuestion->getText(),
            'mode' => $selectionQuestion->getMode(),
        ];

        if ($selectionQuestion->getPenalty()) {
            $serialized['penalty'] = $selectionQuestion->getPenalty();
        }

        if ($selectionQuestion->getTries()) {
            $serialized['tries'] = $selectionQuestion->getTries();
        }

        switch ($selectionQuestion->getMode()) {
           case SelectionQuestion::MODE_FIND:
               $serialized['tries'] = $selectionQuestion->getTries();
              break;
           case SelectionQuestion::MODE_SELECT:
               $serialized['selections'] = $this->serializeSelections($selectionQuestion);
              break;
           case SelectionQuestion::MODE_HIGHLIGHT:
               $serialized['selections'] = $this->serializeSelections($selectionQuestion);
               $serialized['colors'] = $this->serializeColors($selectionQuestion);
              break;
        }

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

        return $serialized;
    }
public function serialize ( SelectionQuestion $ selectionQuestion , array $ options = [ ] ) { $ serialized = [ 'text' => $ selectionQuestion -> getText ( ) , 'mode' => $ selectionQuestion -> getMode ( ) , ] ; if ( $ selectionQuestion -> getPenalty ( ) ) { $ serialized [ 'penalty' ] = $ selectionQuestion -> getPenalty ( ) ; } if ( $ selectionQuestion -> getTries ( ) ) { $ serialized [ 'tries' ] = $ selectionQuestion -> getTries ( ) ; } switch ( $ selectionQuestion -> getMode ( ) ) { case SelectionQuestion :: MODE_FIND : $ serialized [ 'tries' ] = $ selectionQuestion -> getTries ( ) ; break ; case SelectionQuestion :: MODE_SELECT : $ serialized [ 'selections' ] = $ this -> serializeSelections ( $ selectionQuestion ) ; break ; case SelectionQuestion :: MODE_HIGHLIGHT : $ serialized [ 'selections' ] = $ this -> serializeSelections ( $ selectionQuestion ) ; $ serialized [ 'colors' ] = $ this -> serializeColors ( $ selectionQuestion ) ; break ; } if ( in_array ( Transfer :: INCLUDE_SOLUTIONS , $ options ) ) { $ serialized [ 'solutions' ] = $ this -> serializeSolutions ( $ selectionQuestion ) ; } return $ serialized ; }
Converts a Selection question into a JSON-encodable structure.

@param SelectionQuestion $selectionQuestion
@param array             $options

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