|
|
|
@ -165,12 +165,41 @@ if ($session->getNbrCourses() === 0) { |
|
|
|
|
} else { |
|
|
|
|
$count = 0; |
|
|
|
|
$courseItem = ''; |
|
|
|
|
$courses = $sessionRepository->getCoursesOrderedByPosition($session); |
|
|
|
|
//$courses = $sessionRepository->getCoursesOrderedByPosition($session); |
|
|
|
|
|
|
|
|
|
$courses = $session->getCourses(); |
|
|
|
|
$iterator = $courses->getIterator(); |
|
|
|
|
// define ordering closure, using preferred comparison method/field |
|
|
|
|
$iterator->uasort(function ($first, $second) { |
|
|
|
|
return (int) $first->getPosition() > (int) $second->getPosition() ? 1 : -1; |
|
|
|
|
}); |
|
|
|
|
$courseList = []; |
|
|
|
|
$positionList = []; |
|
|
|
|
$courseListByCode = []; |
|
|
|
|
/** @var \Chamilo\CoreBundle\Entity\SessionRelCourse $sessionRelCourse */ |
|
|
|
|
foreach ($iterator as $sessionRelCourse) { |
|
|
|
|
$courseList[] = $sessionRelCourse->getCourse(); |
|
|
|
|
$courseListByCode[$sessionRelCourse->getCourse()->getCode()] = $sessionRelCourse->getCourse(); |
|
|
|
|
$positionList[] = $sessionRelCourse->getPosition(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$checkPosition = array_filter($positionList); |
|
|
|
|
if (empty($checkPosition)) { |
|
|
|
|
// The session course list doesn't have any position, |
|
|
|
|
// then order the course list by course code. |
|
|
|
|
$orderByCode = array_keys($courseListByCode); |
|
|
|
|
sort($orderByCode, SORT_NATURAL); |
|
|
|
|
$newCourseList = []; |
|
|
|
|
foreach ($orderByCode as $code) { |
|
|
|
|
$newCourseList[] = $courseListByCode[$code]; |
|
|
|
|
} |
|
|
|
|
$courseList = $newCourseList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$allowSkills = api_get_configuration_value('allow_skill_rel_items'); |
|
|
|
|
|
|
|
|
|
/** @var Course $course */ |
|
|
|
|
foreach ($courses as $course) { |
|
|
|
|
foreach ($courseList as $course) { |
|
|
|
|
// Select the number of users |
|
|
|
|
$numberOfUsers = SessionManager::getCountUsersInCourseSession($course, $session); |
|
|
|
|
|
|
|
|
|