From 59e4230c7f7a8dec4cedae6b0fa998bc19cda465 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 7 May 2019 15:00:45 +0200 Subject: [PATCH] Use parameter instead of global course/session value --- main/lp/learnpath.class.php | 13 ++++++++++--- main/mySpace/myStudents.php | 29 +++++++++++------------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index ee693b6461..031db6d307 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -4823,14 +4823,19 @@ class learnpath * * @param CLpCategory $category * @param User $user + * @param int + * @param int * * @return bool */ public static function categoryIsVisibleForStudent( CLpCategory $category, - User $user + User $user, + $courseId = 0, + $sessionId = 0 ) { $subscriptionSettings = self::getSubscriptionSettings(); + if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) { return true; } @@ -4851,6 +4856,9 @@ class learnpath return true; } + $courseId = empty($courseId) ? api_get_course_int_id() : (int) $courseId; + $sessionId = empty($sessionId) ? api_get_session_id() : (int) $sessionId; + if ($category->hasUserAdded($user)) { return true; } @@ -4864,13 +4872,12 @@ class learnpath /** @var CourseRepository $courseRepo */ $courseRepo = $em->getRepository('ChamiloCoreBundle:Course'); - $sessionId = api_get_session_id(); $session = null; if (!empty($sessionId)) { $session = $em->getRepository('ChamiloCoreBundle:Session')->find($sessionId); } - $course = $courseRepo->find(api_get_course_int_id()); + $course = $courseRepo->find($courseId); // Subscribed groups to a LP $subscribedGroupsInLp = $itemRepo->getGroupsSubscribedToItem( diff --git a/main/mySpace/myStudents.php b/main/mySpace/myStudents.php index c092e1f13e..e1730323d1 100755 --- a/main/mySpace/myStudents.php +++ b/main/mySpace/myStudents.php @@ -334,13 +334,6 @@ switch ($action) { $totalScore += $bestScore; } - /*$score = Tracking::get_avg_student_score( - $user_info['user_id'], - $courseCodeItem, - [], - $sId - );*/ - $progress = empty($progress) ? '0%' : $progress.'%'; $score = empty($bestScore) ? '0%' : $bestScore.'%'; @@ -1406,7 +1399,7 @@ if (empty($details)) { /** @var CLpCategory $item */ foreach ($categories as $item) { $categoryId = $item->getId(); - if (!learnpath::categoryIsVisibleForStudent($item, $userEntity)) { + if (!learnpath::categoryIsVisibleForStudent($item, $userEntity, $courseInfo['real_id'], $sessionId)) { continue; } @@ -1527,9 +1520,9 @@ if (empty($details)) { } if ($i % 2 == 0) { - $css_class = "row_even"; + $css_class = 'row_even'; } else { - $css_class = "row_odd"; + $css_class = 'row_odd'; } $i++; @@ -1734,14 +1727,14 @@ if (empty($details)) { echo ''; $sql = 'SELECT exe_id FROM '.$tbl_stats_exercices.' - WHERE - exe_exo_id = "'.$exercise_id.'" AND - exe_user_id ="'.$student_id.'" AND - c_id = '.$courseInfo['real_id'].' AND - session_id = "'.$sessionId.'" AND - status = "" - ORDER BY exe_date DESC - LIMIT 1'; + WHERE + exe_exo_id = "'.$exercise_id.'" AND + exe_user_id ="'.$student_id.'" AND + c_id = '.$courseInfo['real_id'].' AND + session_id = "'.$sessionId.'" AND + status = "" + ORDER BY exe_date DESC + LIMIT 1'; $result_last_attempt = Database::query($sql); if (Database::num_rows($result_last_attempt) > 0) { $id_last_attempt = Database::result($result_last_attempt, 0, 0);