public function exportJsonAction(Exercise $exercise)
    {
        if (!$this->isAdmin($exercise)) {
            // Only administrator or Paper Managers can export Papers
            throw new AccessDeniedException();
        }

        $response = new StreamedResponse(function () use ($exercise) {
            $data = $this->paperManager->serializeExercisePapers($exercise);
            $handle = fopen('php://output', 'w+');
            fwrite($handle, json_encode($data, JSON_PRETTY_PRINT));
            fclose($handle);
        });

        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename="statistics.json"');

        return $response;
    }
public function exportJsonAction(Exercise $exercise)
    {
        if (!$this->isAdmin($exercise)) {
            // Only administrator or Paper Managers can export Papers
            throw new AccessDeniedException();
        }

        $response = new StreamedResponse(function () use ($exercise) {
            $data = $this->paperManager->serializeExercisePapers($exercise);
            $handle = fopen('php://output', 'w+');
            fwrite($handle, json_encode($data, JSON_PRETTY_PRINT));
            fclose($handle);
        });

        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename="statistics.json"');

        return $response;
    }
public function exportJsonAction ( Exercise $ exercise ) { if ( ! $ this -> isAdmin ( $ exercise ) ) { // Only administrator or Paper Managers can export Papers throw new AccessDeniedException ( ) ; } $ response = new StreamedResponse ( function ( ) use ( $ exercise ) { $ data = $ this -> paperManager -> serializeExercisePapers ( $ exercise ) ; $ handle = fopen ( 'php://output' , 'w+' ) ; fwrite ( $ handle , json_encode ( $ data , JSON_PRETTY_PRINT ) ) ; fclose ( $ handle ) ; } ) ; $ response -> headers -> set ( 'Content-Type' , 'application/force-download' ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment; filename="statistics.json"' ) ; return $ response ; }
Exports papers into a json file.

@EXT\Route("/export/json", name="exercise_papers_export_json")
@EXT\Method("GET")

@param Exercise $exercise

@return StreamedResponse
Exports papers into a json file .