TrackAttemptRepository.php 772 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Entity\Repository;
  3. use Doctrine\ORM\EntityRepository;
  4. use Doctrine\Common\Collections\Criteria;
  5. use Doctrine\ORM\NoResultException;
  6. /**
  7. * TrackAttemptRepository
  8. *
  9. */
  10. class TrackAttemptRepository extends EntityRepository
  11. {
  12. public function getResults($exeIdList)
  13. {
  14. if (empty($exeIdList)) {
  15. return array();
  16. }
  17. $qb = $this->createQueryBuilder('e');
  18. $qb->select('e.questionId, SUM(e.marks) as marks')
  19. //->innerJoin('e.distribution', 'd')
  20. ->where($qb->expr()->in('e.exeId', $exeIdList))
  21. ->groupBy('e.questionId');
  22. $results = $qb->getQuery()->getArrayResult();
  23. $results = \array_column($results, 'marks', 'questionId');
  24. return $results;
  25. }
  26. }