public function saveAction(Exercise $exercise, Request $request)
    {
        if ($this->isAdmin($exercise)) {
            $data = $this->decodeRequestData($request);

            if (null === $data) {
                $errors[] = [
                    'path' => '',
                    'message' => 'Invalid JSON data',
                ];
            } else {
                // Try to save submitted correction
                try {
                    $this->correctionManager->save($data);
                } catch (InvalidDataException $e) {
                    $errors = $e->getErrors();
                }
            }

            if (empty($errors)) {
                // Correction saved
                return new JsonResponse(null, 204);
            } else {
                // Invalid data received
                return new JsonResponse($errors, 422);
            }
        }
    }
public function saveAction(Exercise $exercise, Request $request)
    {
        if ($this->isAdmin($exercise)) {
            $data = $this->decodeRequestData($request);

            if (null === $data) {
                $errors[] = [
                    'path' => '',
                    'message' => 'Invalid JSON data',
                ];
            } else {
                // Try to save submitted correction
                try {
                    $this->correctionManager->save($data);
                } catch (InvalidDataException $e) {
                    $errors = $e->getErrors();
                }
            }

            if (empty($errors)) {
                // Correction saved
                return new JsonResponse(null, 204);
            } else {
                // Invalid data received
                return new JsonResponse($errors, 422);
            }
        }
    }
public function saveAction ( Exercise $ exercise , Request $ request ) { if ( $ this -> isAdmin ( $ exercise ) ) { $ data = $ this -> decodeRequestData ( $ request ) ; if ( null === $ data ) { $ errors [ ] = [ 'path' => '' , 'message' => 'Invalid JSON data' , ] ; } else { // Try to save submitted correction try { $ this -> correctionManager -> save ( $ data ) ; } catch ( InvalidDataException $ e ) { $ errors = $ e -> getErrors ( ) ; } } if ( empty ( $ errors ) ) { // Correction saved return new JsonResponse ( null , 204 ) ; } else { // Invalid data received return new JsonResponse ( $ errors , 422 ) ; } } }
Saves score & feedback for a bulk of answers.

@EXT\Route("/{questionId}", name="exercise_correction_save")
@EXT\Method("PUT")

@param Exercise $exercise
@param Request  $request

@return JsonResponse
Saves score & feedback for a bulk of answers .