public function statisticsAction(Exercise $exercise)
    {
        if (!$exercise->hasStatistics()) {
            $this->assertHasPermission('EDIT', $exercise);
        }
        $statistics = [];
        $finishedOnly = !$exercise->isAllPapersStatistics();

        foreach ($exercise->getSteps() as $step) {
            foreach ($step->getQuestions() as $question) {
                $itemStats = $this->itemManager->getStatistics($question, $exercise, $finishedOnly);
                $statistics[$question->getUuid()] = !empty($itemStats['solutions']) ? $itemStats['solutions'] : new \stdClass();
            }
        }

        return new JsonResponse($statistics);
    }
public function statisticsAction(Exercise $exercise)
    {
        if (!$exercise->hasStatistics()) {
            $this->assertHasPermission('EDIT', $exercise);
        }
        $statistics = [];
        $finishedOnly = !$exercise->isAllPapersStatistics();

        foreach ($exercise->getSteps() as $step) {
            foreach ($step->getQuestions() as $question) {
                $itemStats = $this->itemManager->getStatistics($question, $exercise, $finishedOnly);
                $statistics[$question->getUuid()] = !empty($itemStats['solutions']) ? $itemStats['solutions'] : new \stdClass();
            }
        }

        return new JsonResponse($statistics);
    }
public function statisticsAction ( Exercise $ exercise ) { if ( ! $ exercise -> hasStatistics ( ) ) { $ this -> assertHasPermission ( 'EDIT' , $ exercise ) ; } $ statistics = [ ] ; $ finishedOnly = ! $ exercise -> isAllPapersStatistics ( ) ; foreach ( $ exercise -> getSteps ( ) as $ step ) { foreach ( $ step -> getQuestions ( ) as $ question ) { $ itemStats = $ this -> itemManager -> getStatistics ( $ question , $ exercise , $ finishedOnly ) ; $ statistics [ $ question -> getUuid ( ) ] = ! empty ( $ itemStats [ 'solutions' ] ) ? $ itemStats [ 'solutions' ] : new \ stdClass ( ) ; } } return new JsonResponse ( $ statistics ) ; }
Gets statistics of an Exercise.

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

@param Exercise $exercise

@return JsonResponse
Gets statistics of an Exercise .