Statistics/QuestionnaireStatistics.php
public function getScoreByCategory()
    {
        $categories = array();

        /** @var TemplateInterface $template */
        foreach ($this->getData() as $template) {
            $category = $template->getQuestion()->getCategory();

            if (!isset($categories[$category->getId()])) {
                $categories[$category->getId()] = array(
                    'name' => $category->getName(),
                    'valid' => 0,
                    'total' => 0,
                    'color' => '#' . substr('00000' . dechex(mt_rand(0, 0xffffff)), -6)
                );
            }

            if ($template->isValid()) {
                $categories[$category->getId()]['valid']++;
            }

            $categories[$category->getId()]['total']++;
        }

        return $categories;
    }
public function getScoreByCategory()
    {
        $categories = array();

        /** @var TemplateInterface $template */
        foreach ($this->getData() as $template) {
            $category = $template->getQuestion()->getCategory();

            if (!isset($categories[$category->getId()])) {
                $categories[$category->getId()] = array(
                    'name' => $category->getName(),
                    'valid' => 0,
                    'total' => 0,
                    'color' => '#' . substr('00000' . dechex(mt_rand(0, 0xffffff)), -6)
                );
            }

            if ($template->isValid()) {
                $categories[$category->getId()]['valid']++;
            }

            $categories[$category->getId()]['total']++;
        }

        return $categories;
    }
public function getScoreByCategory ( ) { $ categories = array ( ) ; /** @var TemplateInterface $template */ foreach ( $ this -> getData ( ) as $ template ) { $ category = $ template -> getQuestion ( ) -> getCategory ( ) ; if ( ! isset ( $ categories [ $ category -> getId ( ) ] ) ) { $ categories [ $ category -> getId ( ) ] = array ( 'name' => $ category -> getName ( ) , 'valid' => 0 , 'total' => 0 , 'color' => '#' . substr ( '00000' . dechex ( mt_rand ( 0 , 0xffffff ) ) , - 6 ) ) ; } if ( $ template -> isValid ( ) ) { $ categories [ $ category -> getId ( ) ] [ 'valid' ] ++ ; } $ categories [ $ category -> getId ( ) ] [ 'total' ] ++ ; } return $ categories ; }
Get score by category

@return array
Get score by category