Allow show the badge list even when the badge not have course and/or session - refs BT#10856

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent 45fda2785c
commit d22bf7302f
  1. 17
      main/inc/lib/tracking.lib.php
  2. 8
      main/mySpace/myStudents.php
  3. 12
      src/Chamilo/CoreBundle/Entity/Repository/SkillRepository.php

@ -5835,8 +5835,8 @@ class Tracking
/** /**
* Get the HTML code for show a block with the achieved user skill on course/session * Get the HTML code for show a block with the achieved user skill on course/session
* @param int $userId * @param int $userId
* @param int $courseId * @param int $courseId Optional.
* @param int $sessionId * @param int $sessionId Optional.
* @return string * @return string
*/ */
public static function displayUserSkills($userId, $courseId = 0, $sessionId = 0) public static function displayUserSkills($userId, $courseId = 0, $sessionId = 0)
@ -5851,13 +5851,8 @@ class Tracking
$filter = ['user' => $userId]; $filter = ['user' => $userId];
if (!empty($courseId)) { $filter['course'] = $courseId ?: null;
$filter['course'] = $courseId; $filter['session'] = $sessionId ?: null;
}
if (!empty($sessionId)) {
$filter['session'] = $sessionId;
}
$em = Database::getManager(); $em = Database::getManager();
@ -5883,11 +5878,11 @@ class Tracking
'; ';
foreach ($skillsRelUser as $userSkill) { foreach ($skillsRelUser as $userSkill) {
$skill = $em->find('ChamiloCoreBundle:Skill', $userSkill->getSkill()->getId()); $skill = $userSkill->getSkill();
$html .= ' $html .= '
<li class="thumbnail"> <li class="thumbnail">
<a href="' . api_get_path(WEB_PATH) . 'badge/' . $skill->getId() . '/user/' . $userId . '" target="_blank"> <a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
<img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64"> <img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
<div class="caption"> <div class="caption">
<p class="text-center">' . $skill->getName() . '</p> <p class="text-center">' . $skill->getName() . '</p>

@ -1304,9 +1304,13 @@ if (!empty($student_id)) {
</table> </table>
</div> </div>
<?php <?php
echo Tracking::displayUserSkills($user_info['user_id'], $courseInfo['id'], $sessionId);
} //end details } //end details
echo Tracking::displayUserSkills(
$user_info['user_id'],
$courseInfo ? $courseInfo['real_id'] : 0,
$sessionId
);
} }
if ($export) { if ($export) {

@ -29,29 +29,31 @@ class SkillRepository extends EntityRepository
{ {
$qb = $this->createQueryBuilder('s'); $qb = $this->createQueryBuilder('s');
$qb->innerJoin( $qb
->innerJoin(
'ChamiloCoreBundle:SkillRelUser', 'ChamiloCoreBundle:SkillRelUser',
'su', 'su',
Join::WITH, Join::WITH,
's.id = su.skill' 's.id = su.skill'
) )
->where( ->where(
$qb->expr()->eq('su.user', $user) $qb->expr()->eq('su.user', $user->getId())
); );
if ($course) { if ($course) {
$qb->andWhere( $qb->andWhere(
$qb->expr()->eq('su.course', $course) $qb->expr()->eq('su.course', $course->getId())
); );
} }
if ($session) { if ($session) {
$qb->andWhere( $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'); ->orderBy('su.id', 'DESC');
return $qb->getQuery()->getOneOrNullResult(); return $qb->getQuery()->getOneOrNullResult();

Loading…
Cancel
Save