diff --git a/main/session/about.php b/main/session/about.php index 0013581701..13c68b9089 100644 --- a/main/session/about.php +++ b/main/session/about.php @@ -2,6 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; +use Chamilo\CoreBundle\Entity\SessionRelCourse; use Chamilo\CoreBundle\Entity\ExtraField; use Chamilo\CoreBundle\Entity\SequenceResource; use Chamilo\CoreBundle\Entity\Session; @@ -34,7 +35,7 @@ if (!$session) { } $htmlHeadXtra[] = api_get_asset('readmore-js/readmore.js'); $courses = []; -$sessionCourses = $em->getRepository('ChamiloCoreBundle:Session')->getCoursesOrderedByPosition($session); +$sessionCourses = $session->getCourses(); $fieldsRepo = $em->getRepository('ChamiloCoreBundle:ExtraField'); $fieldTagsRepo = $em->getRepository('ChamiloCoreBundle:ExtraFieldRelTag'); $userRepo = UserManager::getRepository(); @@ -50,8 +51,9 @@ $courseValues = new ExtraFieldValue('course'); $userValues = new ExtraFieldValue('user'); $sessionValues = new ExtraFieldValue('session'); -/** @var Course $sessionCourse */ -foreach ($sessionCourses as $sessionCourse) { +/** @var SessionRelCourse $sessionRelCourse */ +foreach ($sessionCourses as $sessionRelCourse) { + $sessionCourse = $sessionRelCourse->getCourse(); $courseTags = []; if (!is_null($tagField)) { diff --git a/main/session/resume_session.php b/main/session/resume_session.php index 27009e3283..a45c5f6c62 100644 --- a/main/session/resume_session.php +++ b/main/session/resume_session.php @@ -2,6 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Entity\Course; +use Chamilo\CoreBundle\Entity\SessionRelCourse; use Chamilo\CoreBundle\Entity\SequenceResource; use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser; @@ -156,12 +157,13 @@ if ($session->getNbrCourses() === 0) { } else { $count = 0; $courseItem = ''; - $courses = $sessionRepository->getCoursesOrderedByPosition($session); + $courses = $session->getCourses(); $allowSkills = api_get_configuration_value('allow_skill_rel_items'); - /** @var Course $course */ - foreach ($courses as $course) { + /** @var SessionRelCourse $sessionRelCourse */ + foreach ($courses as $sessionRelCourse) { + $course = $sessionRelCourse->getCourse(); // Select the number of users $numberOfUsers = SessionManager::getCountUsersInCourseSession( $course, diff --git a/src/CoreBundle/Repository/SessionRepository.php b/src/CoreBundle/Repository/SessionRepository.php index 2c52384edc..6701829611 100644 --- a/src/CoreBundle/Repository/SessionRepository.php +++ b/src/CoreBundle/Repository/SessionRepository.php @@ -3,45 +3,16 @@ namespace Chamilo\CoreBundle\Repository; -use Chamilo\CoreBundle\Entity\Course; -use Chamilo\CoreBundle\Entity\Session; use Doctrine\ORM\EntityRepository; -use Doctrine\ORM\Query\Expr\Join; /** * SessionRepository. * * @package Chamilo\CoreBundle\Repository * - * @author Angel Fernando Quiroz Campos * @author Julio Montoya */ class SessionRepository extends EntityRepository { - /** - * Get session's courses ordered by position in session_rel_course. - * - * @param Session $session The session - * - * @return array - */ - public function getCoursesOrderedByPosition(Session $session) - { - $queryBuilder = $this->createQueryBuilder('s'); - $queryBuilder->select('DISTINCT c ') - ->innerJoin('s.courses', 'src') - ->innerJoin( - 'ChamiloCoreBundle:Course', - 'c', - Join::WITH, - 'src.course = c.id' - ) - ->where( - $queryBuilder->expr()->eq('s.id', $session->getId()) - ) - ->orderBy('src.position'); - - return $queryBuilder->getQuery()->getResult(); - } } diff --git a/src/CourseBundle/EventListener/CourseListener.php b/src/CourseBundle/EventListener/CourseListener.php index f521b23789..0899cb3525 100644 --- a/src/CourseBundle/EventListener/CourseListener.php +++ b/src/CourseBundle/EventListener/CourseListener.php @@ -3,17 +3,12 @@ namespace Chamilo\CourseBundle\EventListener; -use Chamilo\CoreBundle\Controller\LegacyController; use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Framework\Container; use Chamilo\CoreBundle\Security\Authorization\Voter\CourseVoter; use Chamilo\CoreBundle\Security\Authorization\Voter\GroupVoter; use Chamilo\CoreBundle\Security\Authorization\Voter\SessionVoter; use Chamilo\CourseBundle\Controller\CourseControllerInterface; -use Chamilo\CourseBundle\Controller\ToolInterface; -use Chamilo\CourseBundle\Event\CourseAccess; -use Chamilo\CourseBundle\Event\SessionAccess; -use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\EntityManager; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerInterface;