public function exportAction(Exercise $exercise)
    {
        $this->assertHasPermission('ADMINISTRATE', $exercise);

        $file = $this->exerciseManager->export($exercise);

        $response = new StreamedResponse();
        $response->setCallBack(
            function () use ($file) {
                readfile($file);
            }
        );

        $name = $exercise->getResourceNode()->getName().'.json';
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.urlencode($name));
        $response->headers->set('Content-Type', 'application/json');
        $response->headers->set('Connection', 'close');
        $response->send();

        return new Response();
    }
public function exportAction(Exercise $exercise)
    {
        $this->assertHasPermission('ADMINISTRATE', $exercise);

        $file = $this->exerciseManager->export($exercise);

        $response = new StreamedResponse();
        $response->setCallBack(
            function () use ($file) {
                readfile($file);
            }
        );

        $name = $exercise->getResourceNode()->getName().'.json';
        $response->headers->set('Content-Transfer-Encoding', 'octet-stream');
        $response->headers->set('Content-Type', 'application/force-download');
        $response->headers->set('Content-Disposition', 'attachment; filename='.urlencode($name));
        $response->headers->set('Content-Type', 'application/json');
        $response->headers->set('Connection', 'close');
        $response->send();

        return new Response();
    }
public function exportAction ( Exercise $ exercise ) { $ this -> assertHasPermission ( 'ADMINISTRATE' , $ exercise ) ; $ file = $ this -> exerciseManager -> export ( $ exercise ) ; $ response = new StreamedResponse ( ) ; $ response -> setCallBack ( function ( ) use ( $ file ) { readfile ( $ file ) ; } ) ; $ name = $ exercise -> getResourceNode ( ) -> getName ( ) . '.json' ; $ response -> headers -> set ( 'Content-Transfer-Encoding' , 'octet-stream' ) ; $ response -> headers -> set ( 'Content-Type' , 'application/force-download' ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment; filename=' . urlencode ( $ name ) ) ; $ response -> headers -> set ( 'Content-Type' , 'application/json' ) ; $ response -> headers -> set ( 'Connection' , 'close' ) ; $ response -> send ( ) ; return new Response ( ) ; }
download json quiz.

@EXT\Route("/{id}/export", name="exercise_export")
@EXT\Method("GET")
@EXT\ParamConverter("exercise", class="UJMExoBundle:Exercise", options={"mapping": {"id": "uuid"}})

@param Exercise $exercise

@return Response
download json quiz .