public function getPaperScoreDistribution(Exercise $exercise, $scoreOn)
    {
        $papers = $this->paperRepository->findBy([
            'exercise' => $exercise,
        ]);

        $scores = $this->getPapersScores($papers, $scoreOn);

        // get unique scores from scores array
        $uniqueScores = array_unique($scores, SORT_NUMERIC);
        sort($uniqueScores);

        $paperScoreDistribution = [];

        foreach ($uniqueScores as $key) {
            $matchingScores = array_filter($scores, function ($score) use ($key) {
                return floatval($score) === floatval($key);
            });

            $paperScoreDistribution[$key] = [
                'yData' => count($matchingScores),
                'xData' => $key,
            ];
        }

        return $paperScoreDistribution;
    }
public function getPaperScoreDistribution(Exercise $exercise, $scoreOn)
    {
        $papers = $this->paperRepository->findBy([
            'exercise' => $exercise,
        ]);

        $scores = $this->getPapersScores($papers, $scoreOn);

        // get unique scores from scores array
        $uniqueScores = array_unique($scores, SORT_NUMERIC);
        sort($uniqueScores);

        $paperScoreDistribution = [];

        foreach ($uniqueScores as $key) {
            $matchingScores = array_filter($scores, function ($score) use ($key) {
                return floatval($score) === floatval($key);
            });

            $paperScoreDistribution[$key] = [
                'yData' => count($matchingScores),
                'xData' => $key,
            ];
        }

        return $paperScoreDistribution;
    }
public function getPaperScoreDistribution ( Exercise $ exercise , $ scoreOn ) { $ papers = $ this -> paperRepository -> findBy ( [ 'exercise' => $ exercise , ] ) ; $ scores = $ this -> getPapersScores ( $ papers , $ scoreOn ) ; // get unique scores from scores array $ uniqueScores = array_unique ( $ scores , SORT_NUMERIC ) ; sort ( $ uniqueScores ) ; $ paperScoreDistribution = [ ] ; foreach ( $ uniqueScores as $ key ) { $ matchingScores = array_filter ( $ scores , function ( $ score ) use ( $ key ) { return floatval ( $ score ) === floatval ( $ key ) ; } ) ; $ paperScoreDistribution [ $ key ] = [ 'yData' => count ( $ matchingScores ) , 'xData' => $ key , ] ; } return $ paperScoreDistribution ; }
Returns the number of papers with a particular score for a given exercise.

@param Exercise $exercise
@param float    $scoreOn

@return array
Returns the number of papers with a particular score for a given exercise .