From d22bf7302f5b5da7304217b1cbdfbb5fe06ff23d Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 1 Jul 2016 15:34:42 -0500 Subject: [PATCH] Allow show the badge list even when the badge not have course and/or session - refs BT#10856 --- main/inc/lib/tracking.lib.php | 17 +++++------- main/mySpace/myStudents.php | 8 ++++-- .../Entity/Repository/SkillRepository.php | 26 ++++++++++--------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php index c7a15ffa0a..79c76d6dc4 100755 --- a/main/inc/lib/tracking.lib.php +++ b/main/inc/lib/tracking.lib.php @@ -5835,8 +5835,8 @@ class Tracking /** * Get the HTML code for show a block with the achieved user skill on course/session * @param int $userId - * @param int $courseId - * @param int $sessionId + * @param int $courseId Optional. + * @param int $sessionId Optional. * @return string */ public static function displayUserSkills($userId, $courseId = 0, $sessionId = 0) @@ -5851,13 +5851,8 @@ class Tracking $filter = ['user' => $userId]; - if (!empty($courseId)) { - $filter['course'] = $courseId; - } - - if (!empty($sessionId)) { - $filter['session'] = $sessionId; - } + $filter['course'] = $courseId ?: null; + $filter['session'] = $sessionId ?: null; $em = Database::getManager(); @@ -5883,11 +5878,11 @@ class Tracking '; foreach ($skillsRelUser as $userSkill) { - $skill = $em->find('ChamiloCoreBundle:Skill', $userSkill->getSkill()->getId()); + $skill = $userSkill->getSkill(); $html .= '
  • - +

    ' . $skill->getName() . '

    diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index cefb09c811..ab3cc3b124 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -1304,9 +1304,13 @@ if (!empty($student_id)) {
    createQueryBuilder('s'); - $qb->innerJoin( - 'ChamiloCoreBundle:SkillRelUser', - 'su', - Join::WITH, - 's.id = su.skill' - ) - ->where( - $qb->expr()->eq('su.user', $user) - ); + $qb + ->innerJoin( + 'ChamiloCoreBundle:SkillRelUser', + 'su', + Join::WITH, + 's.id = su.skill' + ) + ->where( + $qb->expr()->eq('su.user', $user->getId()) + ); if ($course) { $qb->andWhere( - $qb->expr()->eq('su.course', $course) + $qb->expr()->eq('su.course', $course->getId()) ); } if ($session) { $qb->andWhere( - $qb->expr()->eq('su.session', $session) + $qb->expr()->eq('su.session', $session->getId()) ); } - $qb->setMaxResults(1) + $qb + ->setMaxResults(1) ->orderBy('su.id', 'DESC'); return $qb->getQuery()->getOneOrNullResult();