From 53b16b2b6879f15e80fc558ce5e8eb67beac5027 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 30 Mar 2007 07:52:56 +0000 Subject: [PATCH] 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. --- group/edit.php | 13 ++++++++++--- group/lib/clientlib.js | 11 ++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/group/edit.php b/group/edit.php index af5295afbc..6c4c5da70e 100755 --- a/group/edit.php +++ b/group/edit.php @@ -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 diff --git a/group/lib/clientlib.js b/group/lib/clientlib.js index 88058e25c9..9ce0ad2f78 100644 --- a/group/lib/clientlib.js +++ b/group/lib/clientlib.js @@ -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