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 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(

@ -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 '<td>';
$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);

Loading…
Cancel
Save