plugin/exo/Serializer/Attempt/PaperSerializer.php
public function serialize(Paper $paper, array $options = [])
    {
        $serialized = [
            'id' => $paper->getUuid(),
            'number' => $paper->getNumber(),
            'finished' => !$paper->isInterrupted(),
            'user' => $paper->getUser() && !$paper->isAnonymized() ? $this->userSerializer->serialize($paper->getUser(), $options) : null,
            'startDate' => $paper->getStart() ? DateNormalizer::normalize($paper->getStart()) : null,
            'endDate' => $paper->getEnd() ? DateNormalizer::normalize($paper->getEnd()) : null,
            'structure' => json_decode($paper->getStructure(), true),
        ];

        // Adds detail information
        if (!in_array(Transfer::MINIMAL, $options)) {
            $serialized['answers'] = $this->serializeAnswers($paper, $options);
        }

        // Adds user score
        if (!in_array(Transfer::INCLUDE_USER_SCORE, $options)) {
            $serialized['score'] = $paper->getScore();
        }

        return $serialized;
    }
public function serialize(Paper $paper, array $options = [])
    {
        $serialized = [
            'id' => $paper->getUuid(),
            'number' => $paper->getNumber(),
            'finished' => !$paper->isInterrupted(),
            'user' => $paper->getUser() && !$paper->isAnonymized() ? $this->userSerializer->serialize($paper->getUser(), $options) : null,
            'startDate' => $paper->getStart() ? DateNormalizer::normalize($paper->getStart()) : null,
            'endDate' => $paper->getEnd() ? DateNormalizer::normalize($paper->getEnd()) : null,
            'structure' => json_decode($paper->getStructure(), true),
        ];

        // Adds detail information
        if (!in_array(Transfer::MINIMAL, $options)) {
            $serialized['answers'] = $this->serializeAnswers($paper, $options);
        }

        // Adds user score
        if (!in_array(Transfer::INCLUDE_USER_SCORE, $options)) {
            $serialized['score'] = $paper->getScore();
        }

        return $serialized;
    }
public function serialize ( Paper $ paper , array $ options = [ ] ) { $ serialized = [ 'id' => $ paper -> getUuid ( ) , 'number' => $ paper -> getNumber ( ) , 'finished' => ! $ paper -> isInterrupted ( ) , 'user' => $ paper -> getUser ( ) && ! $ paper -> isAnonymized ( ) ? $ this -> userSerializer -> serialize ( $ paper -> getUser ( ) , $ options ) : null , 'startDate' => $ paper -> getStart ( ) ? DateNormalizer :: normalize ( $ paper -> getStart ( ) ) : null , 'endDate' => $ paper -> getEnd ( ) ? DateNormalizer :: normalize ( $ paper -> getEnd ( ) ) : null , 'structure' => json_decode ( $ paper -> getStructure ( ) , true ) , ] ; // Adds detail information if ( ! in_array ( Transfer :: MINIMAL , $ options ) ) { $ serialized [ 'answers' ] = $ this -> serializeAnswers ( $ paper , $ options ) ; } // Adds user score if ( ! in_array ( Transfer :: INCLUDE_USER_SCORE , $ options ) ) { $ serialized [ 'score' ] = $ paper -> getScore ( ) ; } return $ serialized ; }
Converts a Paper into a JSON-encodable structure.

@param Paper $paper
@param array $options

@return array
Converts a Paper into a JSON - encodable structure .