|
|
|
@ -1314,20 +1314,25 @@ class GroupManager |
|
|
|
* Get only students from a group (not tutors). |
|
|
|
* Get only students from a group (not tutors). |
|
|
|
* |
|
|
|
* |
|
|
|
* @param int $group_id iid |
|
|
|
* @param int $group_id iid |
|
|
|
|
|
|
|
* @param bool $filterOnlyActive |
|
|
|
* |
|
|
|
* |
|
|
|
* @return array |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function getStudents($group_id) |
|
|
|
public static function getStudents($group_id, $filterOnlyActive = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$activeCondition = $filterOnlyActive ? 'AND u.active = 1' : ''; |
|
|
|
|
|
|
|
|
|
|
|
$em = Database::getManager(); |
|
|
|
$em = Database::getManager(); |
|
|
|
$subscriptions = $em |
|
|
|
$subscriptions = $em |
|
|
|
->createQuery(' |
|
|
|
->createQuery(" |
|
|
|
SELECT gu |
|
|
|
SELECT u.id FROM ChamiloUserBundle:User u |
|
|
|
FROM ChamiloCourseBundle:CGroupRelUser gu |
|
|
|
INNER JOIN ChamiloCourseBundle:CGroupRelUser gu |
|
|
|
|
|
|
|
WITH u.id = gu.userId |
|
|
|
INNER JOIN ChamiloCourseBundle:CGroupInfo g |
|
|
|
INNER JOIN ChamiloCourseBundle:CGroupInfo g |
|
|
|
WITH gu.groupId = g.id AND g.cId = gu.cId |
|
|
|
WITH gu.groupId = g.id AND g.cId = gu.cId |
|
|
|
WHERE gu.cId = :course AND g.id = :group |
|
|
|
WHERE gu.cId = :course AND g.id = :group |
|
|
|
') |
|
|
|
$activeCondition |
|
|
|
|
|
|
|
") |
|
|
|
->setParameters([ |
|
|
|
->setParameters([ |
|
|
|
'course' => api_get_course_int_id(), |
|
|
|
'course' => api_get_course_int_id(), |
|
|
|
'group' => intval($group_id), |
|
|
|
'group' => intval($group_id), |
|
|
|
@ -1336,9 +1341,8 @@ class GroupManager |
|
|
|
|
|
|
|
|
|
|
|
$users = []; |
|
|
|
$users = []; |
|
|
|
|
|
|
|
|
|
|
|
/** @var CGroupRelUser $subscription */ |
|
|
|
|
|
|
|
foreach ($subscriptions as $subscription) { |
|
|
|
foreach ($subscriptions as $subscription) { |
|
|
|
$users[] = api_get_user_info($subscription->getUserId()); |
|
|
|
$users[] = api_get_user_info($subscription['id']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $users; |
|
|
|
return $users; |
|
|
|
|