Use parameter instead of global course/session value

pull/2901/head
Julio Montoya 7 years ago
parent 0d4c6a8d42
commit 59e4230c7f
  1. 13
      main/lp/learnpath.class.php
  2. 29
      main/mySpace/myStudents.php

@ -4823,14 +4823,19 @@ class learnpath
* *
* @param CLpCategory $category * @param CLpCategory $category
* @param User $user * @param User $user
* @param int
* @param int
* *
* @return bool * @return bool
*/ */
public static function categoryIsVisibleForStudent( public static function categoryIsVisibleForStudent(
CLpCategory $category, CLpCategory $category,
User $user User $user,
$courseId = 0,
$sessionId = 0
) { ) {
$subscriptionSettings = self::getSubscriptionSettings(); $subscriptionSettings = self::getSubscriptionSettings();
if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) { if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) {
return true; return true;
} }
@ -4851,6 +4856,9 @@ class learnpath
return true; 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)) { if ($category->hasUserAdded($user)) {
return true; return true;
} }
@ -4864,13 +4872,12 @@ class learnpath
/** @var CourseRepository $courseRepo */ /** @var CourseRepository $courseRepo */
$courseRepo = $em->getRepository('ChamiloCoreBundle:Course'); $courseRepo = $em->getRepository('ChamiloCoreBundle:Course');
$sessionId = api_get_session_id();
$session = null; $session = null;
if (!empty($sessionId)) { if (!empty($sessionId)) {
$session = $em->getRepository('ChamiloCoreBundle:Session')->find($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 // Subscribed groups to a LP
$subscribedGroupsInLp = $itemRepo->getGroupsSubscribedToItem( $subscribedGroupsInLp = $itemRepo->getGroupsSubscribedToItem(

@ -334,13 +334,6 @@ switch ($action) {
$totalScore += $bestScore; $totalScore += $bestScore;
} }
/*$score = Tracking::get_avg_student_score(
$user_info['user_id'],
$courseCodeItem,
[],
$sId
);*/
$progress = empty($progress) ? '0%' : $progress.'%'; $progress = empty($progress) ? '0%' : $progress.'%';
$score = empty($bestScore) ? '0%' : $bestScore.'%'; $score = empty($bestScore) ? '0%' : $bestScore.'%';
@ -1406,7 +1399,7 @@ if (empty($details)) {
/** @var CLpCategory $item */ /** @var CLpCategory $item */
foreach ($categories as $item) { foreach ($categories as $item) {
$categoryId = $item->getId(); $categoryId = $item->getId();
if (!learnpath::categoryIsVisibleForStudent($item, $userEntity)) { if (!learnpath::categoryIsVisibleForStudent($item, $userEntity, $courseInfo['real_id'], $sessionId)) {
continue; continue;
} }
@ -1527,9 +1520,9 @@ if (empty($details)) {
} }
if ($i % 2 == 0) { if ($i % 2 == 0) {
$css_class = "row_even"; $css_class = 'row_even';
} else { } else {
$css_class = "row_odd"; $css_class = 'row_odd';
} }
$i++; $i++;
@ -1734,14 +1727,14 @@ if (empty($details)) {
echo '<td>'; echo '<td>';
$sql = 'SELECT exe_id FROM '.$tbl_stats_exercices.' $sql = 'SELECT exe_id FROM '.$tbl_stats_exercices.'
WHERE WHERE
exe_exo_id = "'.$exercise_id.'" AND exe_exo_id = "'.$exercise_id.'" AND
exe_user_id ="'.$student_id.'" AND exe_user_id ="'.$student_id.'" AND
c_id = '.$courseInfo['real_id'].' AND c_id = '.$courseInfo['real_id'].' AND
session_id = "'.$sessionId.'" AND session_id = "'.$sessionId.'" AND
status = "" status = ""
ORDER BY exe_date DESC ORDER BY exe_date DESC
LIMIT 1'; LIMIT 1';
$result_last_attempt = Database::query($sql); $result_last_attempt = Database::query($sql);
if (Database::num_rows($result_last_attempt) > 0) { if (Database::num_rows($result_last_attempt) > 0) {
$id_last_attempt = Database::result($result_last_attempt, 0, 0); $id_last_attempt = Database::result($result_last_attempt, 0, 0);

Loading…
Cancel
Save