Minor - remove unused function getCoursesOrderedByPosition

pull/2650/head
Julio Montoya 6 years ago
parent 36034a23da
commit ca2c6421b2
  1. 8
      main/session/about.php
  2. 8
      main/session/resume_session.php
  3. 29
      src/CoreBundle/Repository/SessionRepository.php
  4. 5
      src/CourseBundle/EventListener/CourseListener.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)) {

@ -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,

@ -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 <angel.quiroz@beeznest.com>
* @author Julio Montoya <gugli100@gmail.com>
*/
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();
}
}

@ -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;

Loading…
Cancel
Save