plugin/exo/Serializer/Attempt/PaperSerializer.php
private function serializeAnswers(Paper $paper, array $options = [])
    {
        // We need to inject the hints available in the structure
        $options['hints'] = [];
        $decoded = json_decode($paper->getStructure(), true);

        foreach ($decoded['steps'] as $step) {
            foreach ($step['items'] as $item) {
                if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) {
                    foreach ($item['hints'] as $hint) {
                        $options['hints'][$hint['id']] = $hint;
                    }
                }
            }
        }

        return array_map(function (Answer $answer) use ($options) {
            return $this->answerSerializer->serialize($answer, $options);
        }, $paper->getAnswers()->toArray());
    }
private function serializeAnswers(Paper $paper, array $options = [])
    {
        // We need to inject the hints available in the structure
        $options['hints'] = [];
        $decoded = json_decode($paper->getStructure(), true);

        foreach ($decoded['steps'] as $step) {
            foreach ($step['items'] as $item) {
                if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) {
                    foreach ($item['hints'] as $hint) {
                        $options['hints'][$hint['id']] = $hint;
                    }
                }
            }
        }

        return array_map(function (Answer $answer) use ($options) {
            return $this->answerSerializer->serialize($answer, $options);
        }, $paper->getAnswers()->toArray());
    }
private function serializeAnswers ( Paper $ paper , array $ options = [ ] ) { // We need to inject the hints available in the structure $ options [ 'hints' ] = [ ] ; $ decoded = json_decode ( $ paper -> getStructure ( ) , true ) ; foreach ( $ decoded [ 'steps' ] as $ step ) { foreach ( $ step [ 'items' ] as $ item ) { if ( 1 === preg_match ( '#^application\/x\.[^/]+\+json$#' , $ item [ 'type' ] ) ) { foreach ( $ item [ 'hints' ] as $ hint ) { $ options [ 'hints' ] [ $ hint [ 'id' ] ] = $ hint ; } } } } return array_map ( function ( Answer $ answer ) use ( $ options ) { return $ this -> answerSerializer -> serialize ( $ answer , $ options ) ; } , $ paper -> getAnswers ( ) -> toArray ( ) ) ; }
Serializes paper answers.

@param Paper $paper
@param array $options

@return array
Serializes paper answers .