TrackExerciseRepository.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace Entity\Repository;
  3. use Doctrine\ORM\EntityRepository;
  4. use Doctrine\Common\Collections\Criteria;
  5. use Doctrine\ORM\NoResultException;
  6. /**
  7. * TrackExerciseRepository
  8. *
  9. */
  10. class TrackExerciseRepository extends EntityRepository
  11. {
  12. /**
  13. * @param int $exerciseId
  14. * @param int $courseId
  15. * @param int $sessionId
  16. * @return array
  17. */
  18. public function getAverageScorePerForm($exerciseId, $courseId, $sessionId)
  19. {
  20. $qb = $this->createQueryBuilder('e');
  21. $qb->select('AVG(e.exeResult) average, d.title')
  22. ->innerJoin('e.distribution', 'd')
  23. ->where('e.exeExoId = :exerciseId AND e.cId = :courseId AND e.sessionId = :sessionId AND e.status = :status')
  24. ->setParameters(
  25. array(
  26. 'exerciseId' => $exerciseId,
  27. 'courseId' => $courseId,
  28. 'sessionId' => $sessionId,
  29. 'status' => '',
  30. )
  31. )
  32. ->groupBy('e.quizDistributionId');
  33. return $qb->getQuery()->getArrayResult();
  34. }
  35. /**
  36. * @param int $exerciseId
  37. * @param int $courseId
  38. * @param int $sessionId
  39. * @param int $distributionId
  40. * @return array
  41. */
  42. public function getResults($exerciseId, $courseId, $sessionId, $distributionId)
  43. {
  44. $qb = $this->createQueryBuilder('e');
  45. $qb->select('e.exeId, e.exeResult')
  46. ->where('e.exeExoId = :exerciseId AND e.cId = :courseId AND e.sessionId = :sessionId AND e.status = :status')
  47. ->andWhere('e.quizDistributionId = :distributionId')
  48. ->setParameters(
  49. array(
  50. 'exerciseId' => $exerciseId,
  51. 'courseId' => $courseId,
  52. 'sessionId' => $sessionId,
  53. 'status' => '',
  54. 'distributionId' => $distributionId
  55. )
  56. );
  57. $results = $qb->getQuery()->getArrayResult();
  58. $results = \array_column($results, 'exeResult', 'exeId');
  59. return $results;
  60. }
  61. /**
  62. * @param int $exerciseId
  63. * @param int $courseId
  64. * @param int $distributionId
  65. * @return array
  66. */
  67. public function getResultsWithNoSession($exerciseId, $courseId, $distributionId)
  68. {
  69. $qb = $this->createQueryBuilder('e');
  70. $qb->select('e.exeId, e.exeResult')
  71. ->where('e.exeExoId = :exerciseId AND e.cId = :courseId AND e.status = :status')
  72. ->andWhere('e.quizDistributionId = :distributionId')
  73. ->setParameters(
  74. array(
  75. 'exerciseId' => $exerciseId,
  76. 'courseId' => $courseId,
  77. 'status' => '',
  78. 'distributionId' => $distributionId
  79. )
  80. );
  81. $results = $qb->getQuery()->getArrayResult();
  82. $results = \array_column($results, 'exeResult', 'exeId');
  83. return $results;
  84. }
  85. /*public function getResultsPerGlobalCategory($exerciseId, $courseId, $sessionId, $distributionId, $globalCategory)
  86. {
  87. $qb = $this->createQueryBuilder('e');
  88. $qb->select('e.exeId')
  89. ->innerJoin('e.exercise', 'ex')
  90. ->where('e.exeExoId = :exerciseId AND e.cId = :courseId AND e.sessionId = :sessionId AND e.status = :status')
  91. ->andWhere('e.quizDistributionId = :distributionId')
  92. ->setParameters(
  93. array(
  94. 'e.exerciseId' => $exerciseId,
  95. 'e.courseId' => $courseId,
  96. 'e.sessionId' => $sessionId,
  97. 'e.status' => '',
  98. 'e.distributionId' => $distributionId,
  99. 'ex.globalCategoryId' => $globalCategory
  100. )
  101. );
  102. $results = $qb->getQuery()->getArrayResult();
  103. $results = \array_column($results, 'exeId');
  104. return $results;
  105. }*/
  106. }