plugin/exo/Repository/AnswerRepository.php
public function findByQuestion(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
    {
        $qb = $this->createQueryBuilder('a')
            ->join('a.paper', 'p', 'WITH', 'p.exercise = :exercise')
            ->where('a.questionId = :question')
            ->setParameters([
                'exercise' => $exercise,
                'question' => $question->getUuid(),
            ]);

        if ($finishedPapersOnly) {
            $qb->andWhere('p.end IS NOT NULL');
        }

        return $qb->getQuery()->getResult();
    }
public function findByQuestion(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
    {
        $qb = $this->createQueryBuilder('a')
            ->join('a.paper', 'p', 'WITH', 'p.exercise = :exercise')
            ->where('a.questionId = :question')
            ->setParameters([
                'exercise' => $exercise,
                'question' => $question->getUuid(),
            ]);

        if ($finishedPapersOnly) {
            $qb->andWhere('p.end IS NOT NULL');
        }

        return $qb->getQuery()->getResult();
    }
public function findByQuestion ( Item $ question , Exercise $ exercise = null , $ finishedPapersOnly = false ) { $ qb = $ this -> createQueryBuilder ( 'a' ) -> join ( 'a.paper' , 'p' , 'WITH' , 'p.exercise = :exercise' ) -> where ( 'a.questionId = :question' ) -> setParameters ( [ 'exercise' => $ exercise , 'question' => $ question -> getUuid ( ) , ] ) ; if ( $ finishedPapersOnly ) { $ qb -> andWhere ( 'p.end IS NOT NULL' ) ; } return $ qb -> getQuery ( ) -> getResult ( ) ; }
Returns all answers to a question.
It can be limited to only one exercise.

@param Item     $question
@param Exercise $exercise
@param bool     $finishedPapersOnly

@return Answer[]
Returns all answers to a question . It can be limited to only one exercise .