MDL-9118: The group/edit page now fetches the groupingid for the selected group if it isn't already provided. Note that this will need changing when/if multiple grouping membership is implemented, since only the first grouping is returned at present.

This commit is contained in:
nicolasconnault 2007-03-30 07:52:56 +00:00
parent 95f4b90172
commit 53b16b2b68
2 changed files with 18 additions and 6 deletions

View File

@ -20,9 +20,6 @@ $id = optional_param('id', false, PARAM_INT);
$groupingid = optional_param('grouping', false, PARAM_INT);
$newgrouping = optional_param('newgrouping', false, PARAM_INT);
$courseid = required_param('courseid', PARAM_INT);
if ($groupingid === false) {
$groupingid = -1;
}
$delete = optional_param('delete', false, PARAM_BOOL);
@ -43,6 +40,16 @@ if ($id) {
}
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/course:managegroups', $context);
// If group given but no groupingid, retrieve grouping id
if (empty($groupingid)) {
$groupings = groups_get_groupings_for_group($id);
if (empty($groupings)) {
$groupingid = -1;
} else {
$groupingid = $groupings[0];
}
}
}
/// First create the form

View File

@ -116,10 +116,15 @@ function UpdatableMembersCombo(wwwRoot, courseId) {
if (o.responseText !== undefined) {
var selectEl = document.getElementById("members");
if (selectEl && o.responseText) {
var members = eval("("+o.responseText+")");
// Clear the members combo box.
if (selectEl) {
while (selectEl.firstChild) {
selectEl.removeChild(selectEl.firstChild);
}
}
// Populate the members combo box.
for (var i=0; i<members.length; i++) {
var optionEl = document.createElement("option");
@ -151,9 +156,9 @@ function UpdatableMembersCombo(wwwRoot, courseId) {
UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
// Add the loader gif image.
createLoaderImg("membersloader", "memberslabel", this.wwwRoot);
var selectEl = document.getElementById("members");
// Clear the members combo box.
var selectEl = document.getElementById("members");
if (selectEl) {
while (selectEl.firstChild) {
selectEl.removeChild(selectEl.firstChild);
@ -164,7 +169,7 @@ UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
document.getElementById("showeditgroupsettingsform").disabled = false;
document.getElementById("deletegroup").disabled = false;
var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&group="+groupId+"&act_ajax_getmembersingroup";
YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null);
YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null);
};