public function findEvaluationsByCompetency(Competency $competency, User $user)
    {
        if ($competency->getRight() - $competency->getLeft() > 1) {
            throw new \Exception('Expected leaf competency');
        }

        $resourceQb = $this->createQueryBuilder('a1')
            ->select('node.id')
            ->join('a1.resources', 'node')
            ->join('a1.competencyAbilities', 'ca')
            ->where('ca.competency = :competency');

        return $this->_em->createQueryBuilder()
            ->select(
                'e.id AS evaluationId',
                'e.status',
                'e.date',
                'n.id AS resourceId',
                'n.name AS resourceName',
                'a.id AS abilityId',
                'a.name AS abilityName',
                'l.name AS levelName'
            )
            ->from('Claroline\CoreBundle\Entity\Resource\ResourceEvaluation', 'e')
            ->join('e.resourceUserEvaluation', 'eru')
            ->join('eru.user', 'u')
            ->join('eru.resourceNode', 'n')
            ->join(
                'HeVinci\CompetencyBundle\Entity\Ability',
                'a',
                'WITH',
                'n IN (SELECT node2 FROM HeVinci\CompetencyBundle\Entity\Ability a2 JOIN a2.resources node2 WHERE a2 = a)'
            )
            ->join('a.competencyAbilities', 'ca2')
            ->join('ca2.level', 'l')
            ->join('ca2.competency', 'c2')
            ->where('c2 = :competency')
            ->where($resourceQb->expr()->in(
                'n',
                $resourceQb->getQuery()->getDQL()
            ))
            ->andWhere('u = :user')
            ->orderBy('e.date, e.id, a.id', 'ASC')
            ->setParameters([
                ':competency' => $competency,
                ':user' => $user,
            ])
            ->getQuery()
            ->getArrayResult();
    }