|
|
|
|
@ -9,6 +9,11 @@ |
|
|
|
|
use Chamilo\CoreBundle\Entity\Repository\SequenceRepository; |
|
|
|
|
use Chamilo\CoreBundle\Entity\SequenceResource; |
|
|
|
|
use Chamilo\CoreBundle\Entity\Promotion; |
|
|
|
|
use Chamilo\CoreBundle\Entity\Session, |
|
|
|
|
Doctrine\Common\Collections\Criteria, |
|
|
|
|
Chamilo\CoreBundle\Entity\SessionRelUser, |
|
|
|
|
Chamilo\CoreBundle\Entity\Repository\SessionRepository, |
|
|
|
|
Chamilo\CoreBundle\Entity\SessionRelCourseRelUser; |
|
|
|
|
|
|
|
|
|
$cidReset = true; |
|
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
|
|
|
@ -46,8 +51,12 @@ $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_C |
|
|
|
|
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); |
|
|
|
|
$table_access_url_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
|
$sessionInfo = api_get_session_info($sessionId); |
|
|
|
|
$session = Database::getManager()->find('ChamiloCoreBundle:Session', $sessionId); |
|
|
|
|
/** @var SessionRepository $sessionRepository */ |
|
|
|
|
$sessionRepository = $em->getRepository('ChamiloCoreBundle:Session'); |
|
|
|
|
/** @var Session $session */ |
|
|
|
|
$session = $sessionRepository->find($sessionId); |
|
|
|
|
$sessionCategory = $session->getCategory(); |
|
|
|
|
|
|
|
|
|
$action = isset($_GET['action']) ? $_GET['action'] : null; |
|
|
|
|
@ -153,81 +162,43 @@ if ($sessionInfo['nbr_courses'] == 0) { |
|
|
|
|
} else { |
|
|
|
|
$count = 0; |
|
|
|
|
$courseItem = ''; |
|
|
|
|
/** @var \Chamilo\CoreBundle\Entity\Repository\SessionRepository $sessionRepository */ |
|
|
|
|
$sessionRepository = Database::getManager()->getRepository('ChamiloCoreBundle:Session'); |
|
|
|
|
$courses = $sessionRepository->getCoursesOrderedByPosition($session); |
|
|
|
|
|
|
|
|
|
foreach ($courses as $course) { |
|
|
|
|
// Select the number of users |
|
|
|
|
$sql = "SELECT count(*) |
|
|
|
|
FROM $tbl_session_rel_user sru, |
|
|
|
|
$tbl_session_rel_course_rel_user srcru |
|
|
|
|
WHERE |
|
|
|
|
srcru.user_id = sru.user_id AND |
|
|
|
|
srcru.session_id = sru.session_id AND |
|
|
|
|
srcru.c_id = '".intval($course->getId())."' AND |
|
|
|
|
sru.relation_type <> ".SESSION_RELATION_TYPE_RRHH." AND |
|
|
|
|
srcru.session_id = '".intval($sessionId)."'"; |
|
|
|
|
|
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
$numberOfUsers = Database::result($rs, 0, 0); |
|
|
|
|
|
|
|
|
|
$numberOfUsers = SessionManager::getCountUsersInCourseSession($course, $session); |
|
|
|
|
// Get coachs of the courses in session |
|
|
|
|
$namesOfCoaches = []; |
|
|
|
|
$coachSubscriptions = $session |
|
|
|
|
->getUserCourseSubscriptionsByStatus($course, Session::COACH) |
|
|
|
|
->forAll(function ($index, SessionRelCourseRelUser $subscription) use (&$namesOfCoaches) { |
|
|
|
|
$namesOfCoaches[] = $subscription->getUser()->getCompleteNameWithUserName(); |
|
|
|
|
|
|
|
|
|
$sql = "SELECT user.lastname, user.firstname, user.username |
|
|
|
|
FROM $tbl_session_rel_course_rel_user session_rcru, $tbl_user user |
|
|
|
|
WHERE |
|
|
|
|
session_rcru.user_id = user.user_id AND |
|
|
|
|
session_rcru.session_id = '".intval($sessionId)."' AND |
|
|
|
|
session_rcru.c_id ='".intval($course->getId())."' AND |
|
|
|
|
session_rcru.status=2"; |
|
|
|
|
$rs = Database::query($sql); |
|
|
|
|
|
|
|
|
|
$coachs = array(); |
|
|
|
|
if (Database::num_rows($rs) > 0) { |
|
|
|
|
while ($info_coach = Database::fetch_array($rs)) { |
|
|
|
|
$coachs[] = api_get_person_name($info_coach['firstname'], $info_coach['lastname']).' ('.$info_coach['username'].')'; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$coach = get_lang('None'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (count($coachs) > 0) { |
|
|
|
|
$coach = implode('<br />', $coachs); |
|
|
|
|
} else { |
|
|
|
|
$coach = get_lang('None'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$orderButtons = null; |
|
|
|
|
|
|
|
|
|
$upIcon = 'up.png'; |
|
|
|
|
$urlUp = api_get_self().'?id_session='.$sessionId.'&course_id='.$course->getId().'&action=move_up'; |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if ($count == 0) { |
|
|
|
|
$upIcon = 'up_na.png'; |
|
|
|
|
$urlUp = '#'; |
|
|
|
|
} |
|
|
|
|
$orderButtons = ''; |
|
|
|
|
|
|
|
|
|
if (SessionManager::orderCourseIsEnabled()) { |
|
|
|
|
$orderButtons = Display::url( |
|
|
|
|
Display::return_icon($upIcon, get_lang('MoveUp')), |
|
|
|
|
$urlUp |
|
|
|
|
Display::return_icon( |
|
|
|
|
!$count ? 'up_na.png' : 'up.png', |
|
|
|
|
get_lang('MoveUp') |
|
|
|
|
), |
|
|
|
|
!$count |
|
|
|
|
? '#' |
|
|
|
|
: api_get_self().'?id_session='.$sessionId.'&course_id='.$course->getId().'&action=move_up' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$downIcon = 'down.png'; |
|
|
|
|
$downUrl = api_get_self().'?id_session='.$sessionId.'&course_id='.$course->getId().'&action=move_down'; |
|
|
|
|
|
|
|
|
|
if ($count + 1 == count($courses)) { |
|
|
|
|
$downIcon = 'down_na.png'; |
|
|
|
|
$downUrl = '#'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$orderButtons .= Display::url( |
|
|
|
|
Display::return_icon($downIcon, get_lang('MoveDown')), |
|
|
|
|
$downUrl |
|
|
|
|
Display::return_icon( |
|
|
|
|
$count + 1 == count($courses) ? 'down_na.png' : 'down.png', |
|
|
|
|
get_lang('MoveDown') |
|
|
|
|
), |
|
|
|
|
$count + 1 == count($courses) |
|
|
|
|
? '#' |
|
|
|
|
: api_get_self().'?id_session='.$sessionId.'&course_id='.$course->getId().'&action=move_down' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (!SessionManager::orderCourseIsEnabled()) { |
|
|
|
|
$orderButtons = ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$courseUrl = api_get_course_url($course->getCode(), $sessionId); |
|
|
|
|
@ -240,7 +211,7 @@ if ($sessionInfo['nbr_courses'] == 0) { |
|
|
|
|
$course->getTitle().' ('.$course->getVisualCode().')', |
|
|
|
|
$courseUrl |
|
|
|
|
).'</td> |
|
|
|
|
<td>'.$coach.'</td> |
|
|
|
|
<td>'.($namesOfCoaches ? implode('<br>', $namesOfCoaches) : get_lang('None')).'</td> |
|
|
|
|
<td>'.$numberOfUsers.'</td> |
|
|
|
|
<td> |
|
|
|
|
<a href="'. $courseUrl.'">'. |
|
|
|
|
@ -364,7 +335,7 @@ if (!empty($userList)) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @var SequenceRepository $repo */ |
|
|
|
|
$repo = Database::getManager()->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
|
|
|
$repo = $em->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
|
|
|
$requirementAndDependencies = $repo->getRequirementAndDependencies( |
|
|
|
|
$sessionId, |
|
|
|
|
SequenceResource::SESSION_TYPE |
|
|
|
|
@ -383,7 +354,7 @@ if (!empty($requirementAndDependencies['dependencies'])) { |
|
|
|
|
|
|
|
|
|
$promotion = null; |
|
|
|
|
if (!empty($sessionInfo['promotion_id'])) { |
|
|
|
|
$promotion = Database::getManager()->getRepository('ChamiloCoreBundle:Promotion'); |
|
|
|
|
$promotion = $em->getRepository('ChamiloCoreBundle:Promotion'); |
|
|
|
|
$promotion = $promotion->find($sessionInfo['promotion_id']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|