skala
Julio Montoya 12 years ago
commit bec277e0ef
  1. 10
      main/announcements/announcements.inc.php
  2. 10
      main/announcements/resources/js/main.js
  3. 25
      main/inc/lib/course.lib.php

@ -610,8 +610,10 @@ class AnnouncementManager {
foreach ($group_list as $this_group) { foreach ($group_list as $this_group) {
if (is_array($to_already_selected)) { if (is_array($to_already_selected)) {
if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected if (!in_array("GROUP:" . $this_group['id'], $to_already_selected)) { // $to_already_selected is the array containing the groups (and users) that are already selected
echo "<option value=\"GROUP:" . $this_group['id'] . "\">", $user_label = ($this_group['userNb'] > 0) ? get_lang('Users') : get_lang('LowerCaseUser') ;
"G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . get_lang('Users') . $user_disabled = ($this_group['userNb'] > 0) ? "" : "disabled=disabled" ;
echo "<option $user_disabled value=\"GROUP:" . $this_group['id'] . "\">",
"G: ", $this_group['name'], " - " . $this_group['userNb'] . " " . $user_label .
"</option>"; "</option>";
} }
} }
@ -754,9 +756,9 @@ class AnnouncementManager {
public static function get_course_groups() { public static function get_course_groups() {
$session_id = api_get_session_id(); $session_id = api_get_session_id();
if ($session_id != 0) { if ($session_id != 0) {
$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), $session_id); $new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), $session_id, 1);
} else { } else {
$new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), 0); $new_group_list = CourseManager::get_group_list_of_course(api_get_course_id(), 0, 1);
} }
return $new_group_list; return $new_group_list;
} }

@ -155,11 +155,14 @@ function move(fbox, tbox) {
var arrFbox = []; var arrFbox = [];
var arrTbox = []; var arrTbox = [];
var arrLookup = []; var arrLookup = [];
var arrFboxIsDisabled = []; // if this from checkbox after move is disabled or not
var arrTboxIsDisabled = []; // if this to checkbox after move is disabled or not
var i; var i;
for (i = 0; i < tbox.options.length; i++) { for (i = 0; i < tbox.options.length; i++) {
arrLookup[tbox.options[i].text] = tbox.options[i].value; arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[i] = tbox.options[i].text; arrTbox[i] = tbox.options[i].text;
arrTboxIsDisabled[i] = tbox.options[i].disabled;
} }
var fLength = 0; var fLength = 0;
@ -177,6 +180,7 @@ function move(fbox, tbox) {
else else
{ {
arrFbox[fLength] = fbox.options[i].text; arrFbox[fLength] = fbox.options[i].text;
arrFboxIsDisabled[fLength] = fbox.options[i].disabled;
fLength++; fLength++;
} }
} }
@ -229,6 +233,9 @@ function move(fbox, tbox) {
var no = new Option(); var no = new Option();
no.value = arrLookup[arrFbox[c]]; no.value = arrLookup[arrFbox[c]];
no.text = arrFbox[c]; no.text = arrFbox[c];
if (arrFboxIsDisabled[c]) {
no.disabled = "disabled";
}
fbox[c] = no; fbox[c] = no;
} }
for (c = 0; c < arrTbox.length; c++) for (c = 0; c < arrTbox.length; c++)
@ -236,6 +243,9 @@ function move(fbox, tbox) {
var no = new Option(); var no = new Option();
no.value = arrLookup[arrTbox[c]]; no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c]; no.text = arrTbox[c];
if (arrTboxIsDisabled[c]) {
no.disabled = "disabled";
}
tbox[c] = no; tbox[c] = no;
} }
} }

@ -1521,20 +1521,31 @@ class CourseManager {
* Get the list of groups from the course * Get the list of groups from the course
* @param string Course code * @param string Course code
* @param int Session ID (optional) * @param int Session ID (optional)
* @param boolean get empty groups (optional)
* @return array List of groups info * @return array List of groups info
*/ */
public static function get_group_list_of_course($course_code, $session_id = 0) { public static function get_group_list_of_course($course_code, $session_id = 0, $in_get_empty_group = 0) {
$course_info = Database::get_course_info($course_code); $course_info = Database::get_course_info($course_code);
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
$group_list = array(); $group_list = array();
$session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0'; $session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0';
$sql = "SELECT g.id, g.name if ($in_get_empty_group == 0) {
FROM ".Database::get_course_table(TABLE_GROUP)." AS g // get only groups that are not empty
INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu $sql = "SELECT DISTINCT g.id, g.name
ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id) FROM ".Database::get_course_table(TABLE_GROUP)." AS g
$session_condition INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu
ORDER BY g.name"; ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id)
$session_condition
ORDER BY g.name";
}
else {
// get all groups even if they are empty
$sql = "SELECT g.id, g.name
FROM ".Database::get_course_table(TABLE_GROUP)." AS g
$session_condition
AND c_id = $course_id";
}
$result = Database::query($sql); $result = Database::query($sql);
while ($group_data = Database::fetch_array($result)) { while ($group_data = Database::fetch_array($result)) {

Loading…
Cancel
Save