mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
Fixes MDL-8638 "Can't move groups between groupings"
This commit is contained in:
parent
380b9ab6fe
commit
7e4648a160
@ -18,6 +18,7 @@ $err = array();
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = optional_param('grouping', false, PARAM_INT);
|
||||
$newgrouping= optional_param('newgrouping', false, PARAM_INT);
|
||||
$groupid = optional_param('group', false, PARAM_INT);
|
||||
|
||||
$groupsettings->name = optional_param('name', PARAM_ALPHANUM);
|
||||
@ -66,13 +67,20 @@ if ($success) {
|
||||
$err['name'] = get_string('missingname');
|
||||
}
|
||||
elseif (isset($frm->update)) {
|
||||
if (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
print_error('errornotingrouping', 'group', groups_home_url($courseid), get_string('notingrouping', 'group'));
|
||||
}
|
||||
if (! $groupid) {
|
||||
if (! $groupid) { //OK, new group.
|
||||
if (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
print_error('errornotingrouping', 'group', groups_home_url($courseid), get_string('notingrouping', 'group'));
|
||||
}
|
||||
$success = (bool)$groupid = groups_create_group($courseid); //$groupsettings);
|
||||
$success = groups_add_group_to_grouping($groupid, $groupingid);
|
||||
}
|
||||
elseif ($groupingid != $newgrouping) { //OK, move group.
|
||||
if (GROUP_NOT_IN_GROUPING == $newgrouping) {
|
||||
print_error('errornotingrouping', 'group', groups_home_url($courseid), get_string('notingrouping', 'group'));
|
||||
}
|
||||
$success = $success && groups_remove_group_from_grouping($groupid, $groupingid);
|
||||
$success = $success && groups_add_group_to_grouping($groupid, $newgrouping);
|
||||
}
|
||||
if ($success) {
|
||||
//require_once($CFG->dirroot.'/lib/uploadlib.php');
|
||||
|
||||
@ -193,8 +201,38 @@ if ($success) {
|
||||
?> </label></p>
|
||||
<p><?php upload_print_form_fragment(1, array('groupicon'), null,false,null,0,0,false); ?></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ($groupid) { //OK, editing - option to move grouping.
|
||||
?>
|
||||
<p><label for="groupings"><?php print_string('addgroupstogrouping', 'group'); ?></label></p>
|
||||
<select name="newgrouping" id="groupings" class="select">
|
||||
<?php
|
||||
$groupingids = groups_get_groupings($courseid);
|
||||
if (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
$groupingids[] = GROUP_NOT_IN_GROUPING;
|
||||
}
|
||||
if ($groupingids) {
|
||||
// Put the groupings into a hash and sort them
|
||||
foreach($groupingids as $id) {
|
||||
$listgroupings[$id] = groups_get_grouping_displayname($id, $courseid);
|
||||
}
|
||||
natcasesort($listgroupings);
|
||||
|
||||
// Print out the HTML
|
||||
$count = 1;
|
||||
foreach($listgroupings as $id => $name) {
|
||||
$select = '';
|
||||
if ($groupingid == $id) {
|
||||
$select = ' selected="selected"';
|
||||
}
|
||||
echo "<option value=\"$id\"$select>$name</option>\n";
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php } //IF($groupid) ?>
|
||||
|
||||
<p class="fitem">
|
||||
<label for="id_submit"> </label>
|
||||
|
@ -120,7 +120,7 @@ if ($success) {
|
||||
}
|
||||
redirect(groups_group_edit_url($courseid, null, $groupingid, false));
|
||||
break;
|
||||
case 'addgroupstogroupingsform':
|
||||
case 'addgroupstogroupingform':
|
||||
break;
|
||||
case 'updategroups': //Currently reloading.
|
||||
break;
|
||||
@ -176,7 +176,10 @@ if ($success) {
|
||||
<?php
|
||||
|
||||
$groupingids = groups_get_groupings($courseid);
|
||||
$groupingids[] = GROUP_NOT_IN_GROUPING;
|
||||
if (groups_count_groups_in_grouping(GROUP_NOT_IN_GROUPING, $courseid) > 0) {
|
||||
//NOTE, only show the pseudo-grouping if it has groups.
|
||||
$groupingids[] = GROUP_NOT_IN_GROUPING;
|
||||
}
|
||||
|
||||
if ($groupingids) {
|
||||
// Put the groupings into a hash and sort them
|
||||
@ -248,7 +251,7 @@ if ($success) {
|
||||
<?php } ?>
|
||||
<p><input type="submit" name="act_showcreategroupform" id="showcreategroupform" value="<?php print_string('creategroupinselectedgrouping', 'group'); ?>" /></p>
|
||||
<?php if ($shownotdone) { ?>
|
||||
<p><input type="submit" disabled="disabled" name="act_addgroupstogroupingsform" id="showaddgroupstogroupingform" value="<?php print_string('addexistinggroupstogrouping', 'group'); ?>" /></p>
|
||||
<p><input type="submit" disabled="disabled" name="act_addgroupstogroupingform" id="showaddgroupstogroupingform" value="<?php print_string('addgroupstogrouping', 'group'); ?>" /></p>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -157,7 +157,7 @@ function groups_m_get_selected_group($cmid, $permissiontype, $userid) {
|
||||
function groups_m_get_groups_for_user($cm, $userid) {
|
||||
//echo 'User'; print_object($cm);
|
||||
$groupingid = groups_get_grouping_for_coursemodule($cm);
|
||||
if (!$groupingid) {
|
||||
if (!$groupingid || GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($cm->course) || !groupmode($cm->course, $cm)) {
|
||||
@ -166,9 +166,6 @@ function groups_m_get_groups_for_user($cm, $userid) {
|
||||
elseif (GROUP_ANY_GROUPING == $groupingid) {
|
||||
return groups_get_groups_for_user($userid, $cm->course);
|
||||
}
|
||||
elseif (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
return groups_get_groups_not_in_any_grouping($cm->course);
|
||||
}
|
||||
return groups_get_groups_for_user_in_grouping($userid, $groupingid);
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,7 @@ $string['editgroupsettings'] = 'Edit group settings';
|
||||
$string['deleteselectedgroup'] = 'Delete selected group';
|
||||
$string['removegroupfromselectedgrouping'] = 'Remove group from grouping'; //'selected'
|
||||
$string['creategroupinselectedgrouping'] = 'Create group in grouping';
|
||||
$string['addexistinggroupstogrouping'] = 'Add existing groups to grouping';
|
||||
$string['addgroupstogrouping'] = 'Add groups to grouping';
|
||||
$string['addgroupstogrouping'] = 'Add group to grouping'; //'groupS'
|
||||
|
||||
$string['removeselectedusers'] = 'Remove selected users';
|
||||
$string['adduserstogroup'] = 'Add/remove users'; //'from group'
|
||||
@ -79,7 +78,6 @@ $string['newpicture'] = 'New picture';
|
||||
$string['defaultgroupdescription'] = 'Default group description';
|
||||
|
||||
$string['displaygrouping'] = 'Display grouping';
|
||||
$string['addgroupstogrouping'] = 'Add groups to grouping';
|
||||
$string['showusersalreadyingroup'] = 'Show users already in a group in the grouping';
|
||||
|
||||
$string['save'] = 'Save';
|
||||
|
Loading…
x
Reference in New Issue
Block a user