Skip to content

Commit

Permalink
Use c_group_info.iid to set correct group see BT#14145
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Mar 20, 2018
1 parent 0732b7b commit a2612dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion main/inc/lib/AnnouncementManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,12 @@ public static function load_edit_users($tool, $id)
$id = (int) $id;
$courseId = api_get_course_int_id();

$sql = "SELECT * FROM $table
$sql = "SELECT to_user_id, to_group_id FROM $table
WHERE c_id = $courseId AND tool='$tool' AND ref = $id";
$result = Database::query($sql);
$to = [];
while ($row = Database::fetch_array($result)) {
// This is the iid of c_group_info
$toGroup = $row['to_group_id'];
switch ($toGroup) {
// it was send to one specific user
Expand Down
13 changes: 6 additions & 7 deletions main/inc/lib/course.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2117,9 +2117,7 @@ public static function get_group_list_of_course(
return [];
}

$group_list = [];
$session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0';

if ($in_get_empty_group == 0) {
// get only groups that are not empty
$sql = "SELECT DISTINCT g.id, g.iid, g.name
Expand All @@ -2135,14 +2133,15 @@ public static function get_group_list_of_course(
$session_condition
AND c_id = $course_id";
}
$result = Database::query($sql);

while ($group_data = Database::fetch_array($result)) {
$group_data['userNb'] = GroupManager::number_of_students($group_data['id'], $course_id);
$group_list[$group_data['id']] = $group_data;
$result = Database::query($sql);
$groupList = [];
while ($groupData = Database::fetch_array($result)) {
$groupData['userNb'] = GroupManager::number_of_students($groupData['id'], $course_id);
$groupList[$groupData['iid']] = $groupData;
}

return $group_list;
return $groupList;
}

/**
Expand Down

0 comments on commit a2612dc

Please sign in to comment.