From 954181e0533111e7b364e5dde6c76afa903ab450 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 3 Aug 2015 12:21:17 -0500 Subject: [PATCH] Show the progress from the last visited course - refs BT#10092 #TMI --- main/gamification/my_progress.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/main/gamification/my_progress.php b/main/gamification/my_progress.php index 54bcc8a3db..880d9159bd 100644 --- a/main/gamification/my_progress.php +++ b/main/gamification/my_progress.php @@ -26,6 +26,24 @@ $userManager = UserManager::getManager(); $entityManager = Database::getManager(); $user = $userManager->findUserBy(['id' => $userId]); + +if (empty($sessionId)) { + $trackCourseAccessRepository = $entityManager->getRepository( + 'ChamiloCoreBundle:TrackECourseAccess' + ); + + $lastCourseAccess = $trackCourseAccessRepository->getLastAccessByUser($user); + + if (!empty($lastCourseAccess)) { + $urlWithSession = api_get_self() . '?' . http_build_query([ + 'session_id' => $lastCourseAccess->getSessionId() + ]); + + header("Location: $urlWithSession"); + exit; + } +} + $sessionCourseSubscriptions = $user->getSessionCourseSubscriptions(); $currentSession = $entityManager->find('ChamiloCoreBundle:Session', $sessionId);