MDL-9780 Groups 181 cleanup - part 3
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
<form method="post" enctype="multipart/form-data" action="group.php">
|
||||
<table cellpadding="9" cellspacing="0" align="center">
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("name") ?>:</td>
|
||||
<td><input type="text" name="name" size="30" value="<?php p($group->name) ?>" />
|
||||
<?php if (isset($err["name"])) formerr($err["name"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("description") ?>:<br />
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 8, 35, 660, 200, "description", $group->description);
|
||||
if (isset($err["description"])) formerr($err["description"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string('enrolmentkey') ?>:</td>
|
||||
<td><input type="text" name="password" size="25" value="<?php echo $group->password ?>" alt="<?php print_string('enrolmentkey') ?>" /></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("hidepicture") ?>:</td>
|
||||
<td><?php
|
||||
$options = NULL;
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
choose_from_menu ($options, "hidepicture", $group->hidepicture, "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes);
|
||||
if (!empty($CFG->gdversion) and $maxbytes) {
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="right"><?php print_string("newpicture") ?>:<br />(<?php
|
||||
print_string("maxsize", "", display_size($maxbytes));
|
||||
echo ') ';
|
||||
helpbutton("picture", get_string("helppicture"));
|
||||
?></td>
|
||||
<td>
|
||||
<?php
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
||||
upload_print_form_fragment(1,array('imagefile'),null,false,null,0,0,false);
|
||||
if (isset($err["imagefile"])) formerr($err["imagefile"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
|
||||
</table>
|
||||
|
||||
<input type="hidden" name="group" value="<?php p($group->id) ?>" />
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
</form>
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
/// Shows current group, and allows editing of the group
|
||||
/// icon and other settings related to that group
|
||||
|
||||
/// This script appears within a popup window
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course id
|
||||
$group = optional_param('group', 0, PARAM_INT); // Optionally look at other groups
|
||||
|
||||
if (! $course = get_record('course', 'id', $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (! $group = get_record("groups", "id", $group, "courseid", $course->id)) {
|
||||
notice('Specified group could not be found!', "#");
|
||||
close_window_button();
|
||||
}
|
||||
|
||||
// this is fine since group inherits course settings, this allows 1) teacher to edit all groups
|
||||
// 2 someone with a role with a cap to modify a specific group
|
||||
$context = get_context_instance(CONTEXT_GROUP, $group->id);
|
||||
|
||||
// this is really weird
|
||||
if (!has_capability('moodle/course:managegroups', $context)) {
|
||||
close_window();
|
||||
}
|
||||
|
||||
/// Print the headers of the page
|
||||
|
||||
print_header(get_string('groupinfoedit').' : '.$group->name);
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
if (empty($form->name)) {
|
||||
$err['name'] = get_string("missingname");
|
||||
|
||||
} else {
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
||||
|
||||
$um = new upload_manager('imagefile',false,false,null,false,0,true,true);
|
||||
if ($um->preprocess_files()) {
|
||||
require_once("$CFG->libdir/gdlib.php");
|
||||
|
||||
if (save_profile_image($group->id, $um, 'groups')) {
|
||||
$group->picture = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Setting a new object in order to avoid updating other columns for the record,
|
||||
// which could lead to SQL injection vulnerabilities.
|
||||
|
||||
// Be VERY sure to sanitize all parameters that go into $dataobj!
|
||||
|
||||
$dataobj = new stdClass;
|
||||
$dataobj->id = $group->id;
|
||||
$dataobj->name = clean_text($form->name);
|
||||
$dataobj->description = clean_text($form->description);
|
||||
$dataobj->hidepicture = empty($form->hidepicture) ? 0 : 1;
|
||||
$dataobj->password = required_param('password', PARAM_ALPHANUM);
|
||||
$dataobj->picture = $group->picture;
|
||||
if (!update_record('groups', $dataobj)) {
|
||||
notify("A strange error occurred while trying to save");
|
||||
} else {
|
||||
notify(get_string('changessaved'));
|
||||
}
|
||||
close_window(3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$usehtmleditor = false;
|
||||
|
||||
include('group-edit.html');
|
||||
|
||||
echo "</body></html>";
|
||||
?>
|
||||
@@ -1,182 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
<?php
|
||||
$roleoptions = array(0 => get_string('all'));
|
||||
$roles = get_all_roles();
|
||||
foreach ($roles as $rolex) {
|
||||
$roleoptions[$rolex->id] = $rolex->name;
|
||||
}
|
||||
|
||||
foreach ($listmembers as $groupid => $listmember) {
|
||||
echo "group$groupid = new Object();\n";
|
||||
$useridstring = "group$groupid.userid = new Array(";
|
||||
$usernamestring = "group$groupid.username = new Array(";
|
||||
$max = count($listmember);
|
||||
$count = 0;
|
||||
foreach ($listmember as $userid => $username) {
|
||||
$count++;
|
||||
$useridstring .= "\"$userid\"";
|
||||
$usernamestring .= '"'.addslashes($username).'"';
|
||||
if ($count < $max) {
|
||||
$useridstring .= ', ';
|
||||
$usernamestring .= ', ';
|
||||
}
|
||||
}
|
||||
$useridstring .= ");\n";
|
||||
$usernamestring .= ");\n";
|
||||
|
||||
echo $useridstring;
|
||||
echo $usernamestring;
|
||||
}
|
||||
?>
|
||||
|
||||
function updateGroup() {
|
||||
document.getElementById("form1").groupid.value = document.getElementById("form2").groups.value;
|
||||
document.getElementById("form3").groupid.value = document.getElementById("form2").groups.value;
|
||||
}
|
||||
|
||||
|
||||
function updateMembers(selectgroup) {
|
||||
eval('group=group'+selectgroup.value);
|
||||
|
||||
username = group.username;
|
||||
userid = group.userid;
|
||||
|
||||
document.getElementById("form3")['members[]'].length = username.length;
|
||||
|
||||
for (i=0;i<username.length;i++) {
|
||||
document.getElementById("form3")['members[]'].options[i].value = userid[i];
|
||||
document.getElementById("form3")['members[]'].options[i].text = username[i];
|
||||
}
|
||||
|
||||
updateGroup();
|
||||
}
|
||||
|
||||
function userWindow(selectuser) {
|
||||
num = 0;
|
||||
for (var i=0; i<selectuser.options.length; i++) {
|
||||
if (selectuser.options[i].selected) {
|
||||
num++;
|
||||
user = selectuser.options[i].value;
|
||||
openpopup('/user/view.php?id='+user+'&course=<?php echo $courseid ?>','userinfo'+num,'','');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function groupWindow(selectgroup) {
|
||||
num = 0;
|
||||
for (var i=0; i<selectgroup.options.length; i++) {
|
||||
if (selectgroup.options[i].selected) {
|
||||
num++;
|
||||
group = selectgroup.options[i].value;
|
||||
openpopup('/course/group.php?id=<?php echo $courseid ?>&group='+group,'groupinfo'+num,'menubar=0,directory=0,location=0,scrollbars,resizable,width=600,height=480','');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<form id="rolesform1" action="groups.php" method="get">
|
||||
<input type="hidden" name="id" value="<?php echo $courseid ?>" />
|
||||
<div align="center"><?php echo get_string('currentrole', 'role') ?>:
|
||||
<?php choose_from_menu ($roleoptions, 'roleid', $roleid, '', 'document.getElementById(\'rolesform1\').submit()') ?>
|
||||
</div></form>
|
||||
|
||||
<table cellspacing="0" cellpadding="10" align="center" class="generaltable generalbox">
|
||||
<tr align="center" valign="top">
|
||||
<td class="generalboxcontent">
|
||||
<label for="nonmembers"><?php p($strmemberincourse) ?></label>
|
||||
<form id="form1" method="post" action="groups.php">
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
|
||||
<select name="nonmembers[]" size="15" id="nonmembers" multiple="multiple">
|
||||
<?php
|
||||
if (!empty($nonmembers)) {
|
||||
foreach ($nonmembers as $id => $nonmembername) {
|
||||
if (!is_array($ugroups = user_group($course->id, $id))) {
|
||||
$numgroups = 0;
|
||||
}
|
||||
else {
|
||||
$numgroups = count($ugroups);
|
||||
}
|
||||
echo "<option value=\"$id\" title=\"$nonmembername is in $numgroups groups\">$nonmembername ($numgroups)</option>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="submit" name="nonmembersadd" value="<?php p($strgroupaddusers) ?> ->"
|
||||
onclick="updateGroup()" />
|
||||
<br />
|
||||
<!--
|
||||
<input type="submit" name="nonmembersrandom" value="<?php p($strgrouprandomassign) ?> ->" />
|
||||
<br /> -->
|
||||
<input type="submit" name="nonmembersinfo" value="<?php p($strgroupinfopeople) ?>"
|
||||
onclick="return userWindow(document.getElementById('form1')['nonmembers[]']);" />
|
||||
</form>
|
||||
</td>
|
||||
<td class="generalboxcontent">
|
||||
<label for="groups"><?php p($strgroups) ?></label>
|
||||
<form id="form2" method="post" action="groups.php">
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<select name="groups" size="15" id="groups" onchange="updateMembers(this)">
|
||||
<?php
|
||||
if (!empty($listgroups)) {
|
||||
foreach ($listgroups as $id => $listgroup) {
|
||||
$selected = '';
|
||||
if ($id == $selectedgroup) {
|
||||
$selected = 'selected="selected"';
|
||||
}
|
||||
echo "<option $selected value=\"$id\">$listgroup</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="submit" name="groupsinfo" value="<?php p($strgroupinfoedit) ?>"
|
||||
onclick="return groupWindow(document.getElementById('form2').groups);" />
|
||||
<br />
|
||||
<input type="submit" name="groupsremove" value="<?php p($strgroupremove) ?>" />
|
||||
<br />
|
||||
<label for="groupadd" class="accesshide"><?php p($strgroupadd) ?></label>
|
||||
<input name="newgroupname" id="groupadd" type="text" size="10" />
|
||||
<input type="submit" name="groupsadd" value="<?php p($strgroupadd) ?>" />
|
||||
</form>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="generalboxcontent">
|
||||
<label for="members"><?php p($strgroupmembersselected) ?></label>
|
||||
<form id="form3" method="post" action="groups.php">
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<input type="hidden" name="groupid" value="<?php p($selectedgroup) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>" />
|
||||
<input type="hidden" name="roleid" value="<?php p($roleid) ?>" />
|
||||
<select name="members[]" size="15" id="members" multiple="multiple">
|
||||
<?php
|
||||
if (!empty($members)) {
|
||||
foreach ($members as $id => $membername) {
|
||||
echo "<option value=\"$id\">$membername</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="submit" name="membersinfo" value="<?php p($strgroupinfomembers) ?>"
|
||||
onclick="return userWindow(document.getElementById('form3')['members[]']);" />
|
||||
<br />
|
||||
<input type="submit" name="membersremove" value="<?php p($strgroupremovemembers) ?>"
|
||||
onclick="updateGroup()" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -1,230 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// NOTICE OF COPYRIGHT //
|
||||
// //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// http://moodle.org //
|
||||
// //
|
||||
// Copyright (C) 1999-2004 Martin Dougiamas http://dougiamas.com //
|
||||
// //
|
||||
// This program is free software; you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation; either version 2 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// This program is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details: //
|
||||
// //
|
||||
// http://www.gnu.org/copyleft/gpl.html //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Editing interface to edit all the groups in a course
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
$courseid = required_param('id', PARAM_INT); // Course id
|
||||
$selectedgroup = optional_param('group', NULL, PARAM_INT); // Current group id
|
||||
$roleid = optional_param('roleid', 0, PARAM_INT); // Current role id
|
||||
|
||||
if (! $course = get_record('course', 'id', $courseid) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
if (!has_capability('moodle/course:managegroups', $context)) {
|
||||
redirect("group.php?id=$course->id"); // Not allowed to see all groups
|
||||
}
|
||||
|
||||
/// Get the current list of groups and check the selection is valid
|
||||
|
||||
$groups = get_groups($course->id);
|
||||
|
||||
if ($selectedgroup and !isset($groups[$selectedgroup])) {
|
||||
$selectedgroup = NULL;
|
||||
}
|
||||
|
||||
|
||||
/// Print the header of the page
|
||||
|
||||
$strgroup = get_string('group');
|
||||
$strgroups = get_string('groups');
|
||||
$streditgroupprofile = get_string('editgroupprofile');
|
||||
$strgroupmembers = get_string('groupmembers');
|
||||
$strgroupmemberssee = get_string('groupmemberssee');
|
||||
$strparticipants = get_string('participants');
|
||||
|
||||
print_header("$course->shortname: $strgroups", $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ".
|
||||
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$course->id\">$strparticipants</a> ".
|
||||
"-> $strgroups", "", "", true, '', user_login_string($course, $USER));
|
||||
|
||||
|
||||
/// First, process any inputs there may be.
|
||||
|
||||
if ($data = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
// Clean ALL incoming parameters which go in SQL queries here for good measure
|
||||
$data->id = required_param('id', PARAM_INT);
|
||||
$data->groups = optional_param('groups', 0, PARAM_INT);
|
||||
$data->groupid = optional_param('groupid', 0, PARAM_INT);
|
||||
$data->members = optional_param('members', array(), PARAM_INT);
|
||||
|
||||
if (!empty($data->nonmembersadd)) { /// Add people to a group
|
||||
if (!empty($data->nonmembers) and !empty($data->groupid)) {
|
||||
$groupmodified = false;
|
||||
foreach ($data->nonmembers as $userid) {
|
||||
//since we allow people to be in more than 1 group, this has to go.
|
||||
if (!ismember($data->groupid,$userid)) {// Just to make sure (another teacher could be editing)
|
||||
$record->groupid = $data->groupid;
|
||||
$record->userid = $userid;
|
||||
$record->timeadded = time();
|
||||
if (!insert_record('groups_members', $record)) {
|
||||
notify("Error occurred while adding user $userid to group $data->groupid");
|
||||
}
|
||||
$groupmodified = true;
|
||||
}
|
||||
}
|
||||
if ($groupmodified) {
|
||||
set_field('groups', 'timemodified', time(), 'id', $data->groupid);
|
||||
}
|
||||
}
|
||||
$selectedgroup = $data->groupid;
|
||||
|
||||
|
||||
} else if (!empty($data->nonmembersrandom)) { /// Add all non members to groups
|
||||
notify("Random adding of people into groups is not functional yet.");
|
||||
|
||||
} else if (!empty($data->nonmembersinfo)) { /// Return info about the selected users
|
||||
notify("You must turn Javascript on");
|
||||
|
||||
} else if (!empty($data->groupsremove)) { /// Remove a group, all members become nonmembers
|
||||
if (!empty($data->groups)) {
|
||||
if(!isset($groups[$data->groups])) {
|
||||
error("This is not a valid group to remove");
|
||||
}
|
||||
delete_records("groups", "id", $data->groups);
|
||||
delete_records("groups_members", "groupid", $data->groups);
|
||||
unset($groups[$data->groups]);
|
||||
}
|
||||
|
||||
|
||||
} else if (!empty($data->groupsinfo)) { /// Display full info for a group
|
||||
notify("You must turn Javascript on");
|
||||
|
||||
} else if (!empty($data->groupsadd)) { /// Create a new group
|
||||
if (!empty($data->newgroupname)) {
|
||||
$newgroup->name = $data->newgroupname;
|
||||
$newgroup->courseid = $course->id;
|
||||
$newgroup->lang = current_language();
|
||||
$newgroup->timecreated = time();
|
||||
$newgroup->description = ''; // can not be null MDL-7300
|
||||
if (!insert_record("groups", $newgroup)) {
|
||||
notify("Could not insert the new group '$newgroup->name'");
|
||||
}
|
||||
$groups = get_groups($course->id);
|
||||
}
|
||||
|
||||
} else if (!empty($data->membersremove)) { /// Remove selected people from a particular group
|
||||
|
||||
if (!empty($data->members) and !empty($data->groupid)) {
|
||||
foreach ($data->members as $userid) {
|
||||
delete_records('groups_members', 'userid', $userid, "groupid", $data->groupid);
|
||||
}
|
||||
set_field('groups', 'timemodified', time(), 'id', $data->groupid);
|
||||
}
|
||||
$selectedgroup = $data->groupid;
|
||||
|
||||
} else if (!empty($data->membersinfo)) { /// Return info about the selected users
|
||||
notify("You must turn Javascript on");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Calculate data ready to create the editing interface
|
||||
|
||||
$strmemberincourse = get_string('memberincourse');
|
||||
$strgroupnonmembers = get_string('groupnonmembers');
|
||||
$strgroupmembersselected = get_string('groupmembersselected');
|
||||
$strgroupremovemembers = get_string('groupremovemembers');
|
||||
$strgroupinfomembers = get_string('groupinfomembers');
|
||||
$strgroupadd = get_string('groupadd');
|
||||
$strgroupremove = get_string('groupremove');
|
||||
$strgroupinfo = get_string('groupinfo');
|
||||
$strgroupinfoedit = get_string('groupinfoedit');
|
||||
$strgroupinfopeople = get_string('groupinfopeople');
|
||||
$strgrouprandomassign = get_string('grouprandomassign');
|
||||
$strgroupaddusers = get_string('groupaddusers');
|
||||
$courseid = $course->id;
|
||||
$listgroups = array();
|
||||
$listmembers = array();
|
||||
$nonmembers = array();
|
||||
$groupcount = count($groups);
|
||||
|
||||
|
||||
/// First, get everyone into the nonmembers array
|
||||
|
||||
if ($contextusers = get_role_users($roleid, $context)) {
|
||||
foreach ($contextusers as $contextuser) {
|
||||
$nonmembers[$contextuser->id] = fullname($contextuser, true);
|
||||
}
|
||||
}
|
||||
unset($contextusers);
|
||||
|
||||
/// Pull out all the members into little arrays
|
||||
|
||||
if ($groups) {
|
||||
foreach ($groups as $group) {
|
||||
$countusers = 0;
|
||||
$listmembers[$group->id] = array();
|
||||
if ($groupusers = get_group_users($group->id, 'u.lastname ASC, u.firstname ASC')) {
|
||||
foreach ($groupusers as $key=>$groupuser) {
|
||||
if (!array_key_exists($groupuser->id, $nonmembers)) {
|
||||
// group member with another role
|
||||
unset($groupusers[$key]);
|
||||
} else {
|
||||
$listmembers[$group->id][$groupuser->id] = $nonmembers[$groupuser->id];
|
||||
//we do not remove people from $nonmembers, everyone is displayed
|
||||
//this is to enable people to be registered in multiple groups
|
||||
//unset($nonmembers[$groupuser->id]);
|
||||
$countusers++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$listgroups[$group->id] = $group->name." ($countusers)";
|
||||
}
|
||||
natcasesort($listgroups);
|
||||
}
|
||||
|
||||
if (empty($selectedgroup)) { // Choose the first group by default
|
||||
if ($selectedgroup = array_shift($temparr = array_keys($listgroups))) {
|
||||
$members = $listmembers[$selectedgroup];
|
||||
}
|
||||
} else {
|
||||
$members = $listmembers[$selectedgroup];
|
||||
}
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
//TODO:
|
||||
if (debugging()) {
|
||||
echo '<p>[ <a href="../group/index.php?id='. $courseid .'">New groups</a> - debugging. ]</p>';
|
||||
}
|
||||
|
||||
/// Print out the complete form
|
||||
|
||||
print_heading(get_string('groups'));
|
||||
|
||||
include('groups-edit.html');
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
||||
@@ -1,9 +0,0 @@
|
||||
<div id="addgroupstogroupingform" class="popup">
|
||||
<h3><?php print_string('addgroupstogrouping', 'group'); ?> <span id="selectedgroupingforaddinggroups"></span>
|
||||
</h3>
|
||||
<form action="">
|
||||
<p><select id="groupsnotingrouping" size="15" multiple="multiple" class="select"></select></p>
|
||||
<p><input type="button" id="addgroupstogrouping" value="<?php print_string('addgroupstogrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="canceladdgroupstogrouping" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,73 +0,0 @@
|
||||
|
||||
|
||||
function onAddGroupsToGrouping() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
addGroupsToGrouping();
|
||||
setText('selectedgroupingforaddinggroups', "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Adds the selected groups to the selected groupings
|
||||
*/
|
||||
function addGroupsToGrouping() {
|
||||
//alert("Called addGroupsToGrouping");
|
||||
selectedgroups = getMultipleSelect("groupsnotingrouping");
|
||||
if (selectedgroups != '') {
|
||||
var url = "addgroupstogrouping-xml.php";
|
||||
var requeststring = "groupingid="+selectedgroupingid
|
||||
+"&groups="+selectedgroups;
|
||||
sendPostRequest(request, url, requeststring, addGroupsToGroupingResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in addGroupsToGrouping()
|
||||
*/
|
||||
function addGroupsToGroupingResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("addGroupsToGrouping called");
|
||||
//alert(request.responseText);
|
||||
// Need XML sent back with groupingid
|
||||
// Really want to set this to be the grouping before
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
updateGroupings();
|
||||
hideElement("addgroupstogroupingform");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the groups not in the selected grouping for the form for adding groups to a grouping
|
||||
*/
|
||||
function updateGroupsNotInGrouping() {
|
||||
//alert("updateNonMembers called");
|
||||
var url="getgroupsnotingrouping-xml.php";
|
||||
var requeststring = "groupingid="+selectedgroupingid;
|
||||
sendPostRequest(request, url, requeststring, updateGroupsNotInGroupingResponse);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in updateGroupsNotInGrouping()
|
||||
*/
|
||||
function updateGroupsNotInGroupingResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("updateGroupsNotInGroupingResponse");
|
||||
var xmlDoc = request.responseXML;
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
addOptionsFromXML("groupsnotingrouping", xmlDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Adds an existing group to a grouping.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author J.White AT open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package groups
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$groups = required_param('groups', PARAM_SEQUENCE); //TODO: check.
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupids = explode(',', $groups);
|
||||
|
||||
if ($groupids != false) {
|
||||
foreach($groupids as $groupid) {
|
||||
$groupadded = groups_add_group_to_grouping($groupid, $groupingid);
|
||||
if (!$groupadded) {
|
||||
echo '<error>Failed to add group $groupid to grouping</error>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,9 +0,0 @@
|
||||
<div id="addmembersform" class="popup">
|
||||
<h3><?php print_string('adduserstogroup', 'group'); ?> <span id="selectedgroup"></span></h3>
|
||||
<form action="">
|
||||
<p><input type="checkbox" id="showall" /><?php print_string('showusersalreadyingroup', 'group'); ?> </p>
|
||||
<p><select id="nonmembers" size="15" multiple="multiple" class="select"></select></p>
|
||||
<p><input type="button" id="addmembers" value="<?php print_string('adduserstogroup', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="canceladdmembers" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,81 +0,0 @@
|
||||
|
||||
|
||||
function onAddMembers() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
addMembers();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowAll() {
|
||||
updateNonMembers();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Adds the selected users to the selected group
|
||||
*/
|
||||
function addMembers() {
|
||||
//alert("Called addMembers");
|
||||
users = getMultipleSelect("nonmembers");
|
||||
if (users != '') {
|
||||
var url = "addmembers-xml.php";
|
||||
var requeststring = "groupid="+selectedgroupid+"&users="+users;
|
||||
sendPostRequest(request, url, requeststring, addMembersResponse);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in addMembers()
|
||||
*/
|
||||
function addMembersResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("addMembersResponse called");
|
||||
//alert(request.responseText);
|
||||
// Need XML sent back with groupingid
|
||||
// Really want to set this to be the grouping before
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
updateSelectedGrouping();
|
||||
hideElement("addmembersform");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the list of non members of a group in the form for adding members to a group
|
||||
*/
|
||||
function updateNonMembers() {
|
||||
//alert("updateNonMembers called");
|
||||
var url="getnonmembers-xml.php";
|
||||
// showall indicates if we should show users already in groups in the grouping
|
||||
// we have to turn it into a variable that we can put in a post
|
||||
var showall = getCheckBoxValue('showall');;
|
||||
var requeststring = "groupid="+selectedgroupid
|
||||
+"&groupingid="+selectedgroupingid
|
||||
+"&showall="+showall;
|
||||
|
||||
sendPostRequest(request, url, requeststring, updateNonMembersResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in updateNonMembers()
|
||||
*/
|
||||
function updateNonMembersResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("updateNonMembersResponse");
|
||||
var xmlDoc = request.responseXML;
|
||||
// alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
addOptionsFromXML("nonmembers", xmlDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds users to a group
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$users = required_param('users', PARAM_SEQUENCE);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$userids = explode(',', $users);
|
||||
|
||||
if ($userids != false) {
|
||||
foreach($userids as $userid) {
|
||||
$useradded = groups_add_member($groupid, $userid);
|
||||
if (!$useradded) {
|
||||
echo '<error>Failed to add user $userid to group</error>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,77 +0,0 @@
|
||||
/***********************************************************************************************************
|
||||
* Contains functions for creating and sending Ajax requests.
|
||||
* This code needs to be a bit more careful about creating separate requests for different events - if
|
||||
* somebody presses a button several times in quick succession (such as the delete grouping button) then
|
||||
* we get an error.
|
||||
* There also seems to a problem with IE - need to check this out
|
||||
***********************************************************************************************************/
|
||||
|
||||
|
||||
<?php
|
||||
echo "var courseid = $courseid;";
|
||||
echo "var sesskey = '$sesskey';";
|
||||
?>
|
||||
|
||||
/*
|
||||
* Creates an XMLHttpRequest object
|
||||
* @return The XMLHttpRequest object created.
|
||||
*/
|
||||
function createRequest() {
|
||||
var newrequest = null;
|
||||
try {
|
||||
newrequest = new XMLHttpRequest();
|
||||
} catch (trymicrosoft) {
|
||||
// Deal with Microsoft browsers
|
||||
try {
|
||||
newrequest = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (othermicrosoft) {
|
||||
try {
|
||||
newrequest = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (failed) {
|
||||
newrequest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newrequest == null) {
|
||||
alert("Error creating request object!");
|
||||
} else {
|
||||
return newrequest;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Sends an Ajax post request
|
||||
* @param request - The XMLHttpRequest object
|
||||
* @param url - The URL to send the request to
|
||||
* @param requeststring - The string containing the variables to send in the post request - the format
|
||||
* is basically the same as a GET string
|
||||
* @callbackfunction - The function to call when the response to the request is received
|
||||
*/
|
||||
function sendPostRequest(postrequest, url, requeststring, callbackfunction) {
|
||||
// Add on the date and time to get round caching problem
|
||||
url = url + "?dummy=" + new Date().getTime();
|
||||
// Add the course id and sesskey so we can check these on the server
|
||||
requeststring = 'courseid='+courseid+'&'+'sesskey='+sesskey+'&'+requeststring;
|
||||
postrequest.abort();
|
||||
postrequest.open('post', url, true);
|
||||
postrequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
postrequest.onreadystatechange = callbackfunction;
|
||||
postrequest.send(requeststring);
|
||||
}
|
||||
|
||||
function checkAjaxResponse(request) {
|
||||
process = false;
|
||||
|
||||
if (request.readyState == 4 && request.status == 200) {
|
||||
process = true;
|
||||
}
|
||||
if (request.readyState == 4 && request.status != 200) {
|
||||
alert('An error has occurred - the page returned a '+ request.status + ' error');
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
||||
var responseFailure = function(o){
|
||||
alert("Failure callback");
|
||||
}
|
||||
@@ -1,775 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 0.11.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Connection Manager provides a simplified interface to the XMLHttpRequest
|
||||
* object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
|
||||
* interactive states and server response, returning the results to a pre-defined
|
||||
* callback you create.
|
||||
* @ class
|
||||
*/
|
||||
YAHOO.util.Connect =
|
||||
{
|
||||
/**
|
||||
* Array of MSFT ActiveX ids for XMLHttpRequest.
|
||||
* @private
|
||||
* @type array
|
||||
*/
|
||||
_msxml_progid:[
|
||||
'MSXML2.XMLHTTP.3.0',
|
||||
'MSXML2.XMLHTTP',
|
||||
'Microsoft.XMLHTTP'
|
||||
],
|
||||
|
||||
/**
|
||||
* Object literal of HTTP header(s)
|
||||
* @private
|
||||
* @type object
|
||||
*/
|
||||
_http_header:{},
|
||||
|
||||
/**
|
||||
* Determines if HTTP headers are set.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_has_http_headers:false,
|
||||
|
||||
/**
|
||||
* Determines if a default header of
|
||||
* Content-Type of 'application/x-www-form-urlencoded'
|
||||
* will be added to any client HTTP headers sent for POST
|
||||
* transactions.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_default_post_header:true,
|
||||
|
||||
/**
|
||||
* Property modified by setForm() to determine if the data
|
||||
* should be submitted as an HTML form.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_isFormSubmit:false,
|
||||
|
||||
/**
|
||||
* Property modified by setForm() to determine if a file(s)
|
||||
* upload is expected.
|
||||
* @private
|
||||
* @type boolean
|
||||
*/
|
||||
_isFileUpload:false,
|
||||
|
||||
/**
|
||||
* Property modified by setForm() to set a reference to the HTML
|
||||
* form node if the desired action is file upload.
|
||||
* @private
|
||||
* @type object
|
||||
*/
|
||||
_formNode:null,
|
||||
|
||||
/**
|
||||
* Property modified by setForm() to set the HTML form data
|
||||
* for each transaction.
|
||||
* @private
|
||||
* @type string
|
||||
*/
|
||||
_sFormData:null,
|
||||
|
||||
/**
|
||||
* Collection of polling references to the polling mechanism in handleReadyState.
|
||||
* @private
|
||||
* @type string
|
||||
*/
|
||||
_poll:[],
|
||||
|
||||
/**
|
||||
* Queue of timeout values for each transaction callback with a defined timeout value.
|
||||
* @private
|
||||
* @type string
|
||||
*/
|
||||
_timeOut:[],
|
||||
|
||||
/**
|
||||
* The polling frequency, in milliseconds, for HandleReadyState.
|
||||
* when attempting to determine a transaction's XHR readyState.
|
||||
* The default is 50 milliseconds.
|
||||
* @private
|
||||
* @type int
|
||||
*/
|
||||
_polling_interval:50,
|
||||
|
||||
/**
|
||||
* A transaction counter that increments the transaction id for each transaction.
|
||||
* @private
|
||||
* @type int
|
||||
*/
|
||||
_transaction_id:0,
|
||||
|
||||
/**
|
||||
* Member to add an ActiveX id to the existing xml_progid array.
|
||||
* In the event(unlikely) a new ActiveX id is introduced, it can be added
|
||||
* without internal code modifications.
|
||||
* @public
|
||||
* @param string id The ActiveX id to be added to initialize the XHR object.
|
||||
* @return void
|
||||
*/
|
||||
setProgId:function(id)
|
||||
{
|
||||
this._msxml_progid.unshift(id);
|
||||
},
|
||||
|
||||
/**
|
||||
* Member to enable or disable the default POST header.
|
||||
* @public
|
||||
* @param boolean b Set and use default header - true or false .
|
||||
* @return void
|
||||
*/
|
||||
setDefaultPostHeader:function(b)
|
||||
{
|
||||
this._default_post_header = b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Member to modify the default polling interval.
|
||||
* @public
|
||||
* @param {int} i The polling interval in milliseconds.
|
||||
* @return void
|
||||
*/
|
||||
setPollingInterval:function(i)
|
||||
{
|
||||
if(typeof i == 'number' && isFinite(i)){
|
||||
this._polling_interval = i;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Instantiates a XMLHttpRequest object and returns an object with two properties:
|
||||
* the XMLHttpRequest instance and the transaction id.
|
||||
* @private
|
||||
* @param {int} transactionId Property containing the transaction id for this transaction.
|
||||
* @return connection object
|
||||
*/
|
||||
createXhrObject:function(transactionId)
|
||||
{
|
||||
var obj,http;
|
||||
try
|
||||
{
|
||||
// Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
|
||||
http = new XMLHttpRequest();
|
||||
// Object literal with http and tId properties
|
||||
obj = { conn:http, tId:transactionId };
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
for(var i=0; i<this._msxml_progid.length; ++i){
|
||||
try
|
||||
{
|
||||
// Instantiates XMLHttpRequest for IE and assign to http.
|
||||
http = new ActiveXObject(this._msxml_progid[i]);
|
||||
// Object literal with http and tId properties
|
||||
obj = { conn:http, tId:transactionId };
|
||||
break;
|
||||
}
|
||||
catch(e){}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This method is called by asyncRequest to create a
|
||||
* valid connection object for the transaction. It also passes a
|
||||
* transaction id and increments the transaction id counter.
|
||||
* @private
|
||||
* @return object
|
||||
*/
|
||||
getConnectionObject:function()
|
||||
{
|
||||
var o;
|
||||
var tId = this._transaction_id;
|
||||
|
||||
try
|
||||
{
|
||||
o = this.createXhrObject(tId);
|
||||
if(o){
|
||||
this._transaction_id++;
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
finally
|
||||
{
|
||||
return o;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method for initiating an asynchronous request via the XHR object.
|
||||
* @public
|
||||
* @param {string} method HTTP transaction method
|
||||
* @param {string} uri Fully qualified path of resource
|
||||
* @param callback User-defined callback function or object
|
||||
* @param {string} postData POST body
|
||||
* @return {object} Returns the connection object
|
||||
*/
|
||||
asyncRequest:function(method, uri, callback, postData)
|
||||
{
|
||||
var o = this.getConnectionObject();
|
||||
|
||||
if(!o){
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
if(this._isFormSubmit){
|
||||
if(this._isFileUpload){
|
||||
this.uploadFile(o.tId, callback, uri);
|
||||
this.releaseObject(o);
|
||||
return;
|
||||
}
|
||||
|
||||
//If the specified HTTP method is GET, setForm() will return an
|
||||
//encoded string that is concatenated to the uri to
|
||||
//create a querystring.
|
||||
if(method == 'GET'){
|
||||
uri += "?" + this._sFormData;
|
||||
}
|
||||
else if(method == 'POST'){
|
||||
postData = this._sFormData;
|
||||
}
|
||||
this._sFormData = '';
|
||||
}
|
||||
|
||||
o.conn.open(method, uri, true);
|
||||
|
||||
if(this._isFormSubmit || (postData && this._default_post_header)){
|
||||
this.initHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
if(this._isFormSubmit){
|
||||
this._isFormSubmit = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Verify whether the transaction has any user-defined HTTP headers
|
||||
//and set them.
|
||||
if(this._has_http_headers){
|
||||
this.setHeader(o);
|
||||
}
|
||||
|
||||
this.handleReadyState(o, callback);
|
||||
postData?o.conn.send(postData):o.conn.send(null);
|
||||
|
||||
return o;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This method serves as a timer that polls the XHR object's readyState
|
||||
* property during a transaction, instead of binding a callback to the
|
||||
* onreadystatechange event. Upon readyState 4, handleTransactionResponse
|
||||
* will process the response, and the timer will be cleared.
|
||||
*
|
||||
* @private
|
||||
* @param {object} o The connection object
|
||||
* @param callback User-defined callback object
|
||||
* @return void
|
||||
*/
|
||||
handleReadyState:function(o, callback)
|
||||
{
|
||||
var timeOut = callback.timeout;
|
||||
var oConn = this;
|
||||
|
||||
try
|
||||
{
|
||||
if(timeOut !== undefined){
|
||||
this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true) }, timeOut);
|
||||
}
|
||||
this._poll[o.tId] = window.setInterval(
|
||||
function(){
|
||||
if(o.conn && o.conn.readyState == 4){
|
||||
window.clearInterval(oConn._poll[o.tId]);
|
||||
oConn._poll.splice(o.tId);
|
||||
if(timeOut){
|
||||
oConn._timeOut.splice(o.tId);
|
||||
}
|
||||
|
||||
oConn.handleTransactionResponse(o, callback);
|
||||
}
|
||||
}
|
||||
,this._polling_interval);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
window.clearInterval(oConn._poll[o.tId]);
|
||||
oConn._poll.splice(o.tId);
|
||||
if(timeOut){
|
||||
oConn._timeOut.splice(o.tId);
|
||||
}
|
||||
|
||||
oConn.handleTransactionResponse(o, callback);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This method attempts to interpret the server response and
|
||||
* determine whether the transaction was successful, or if an error or
|
||||
* exception was encountered.
|
||||
*
|
||||
* @private
|
||||
* @param {object} o The connection object
|
||||
* @param {object} callback - User-defined callback object
|
||||
* @param {boolean} determines if the transaction was aborted.
|
||||
* @return void
|
||||
*/
|
||||
handleTransactionResponse:function(o, callback, isAbort)
|
||||
{
|
||||
// If no valid callback is provided, then do not process any callback handling.
|
||||
if(!callback){
|
||||
this.releaseObject(o);
|
||||
return;
|
||||
}
|
||||
|
||||
var httpStatus, responseObject;
|
||||
|
||||
try
|
||||
{
|
||||
if(o.conn.status !== undefined && o.conn.status != 0){
|
||||
httpStatus = o.conn.status;
|
||||
}
|
||||
else{
|
||||
httpStatus = 13030;
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
// 13030 is the custom code to indicate the condition -- in Mozilla/FF --
|
||||
// when the o object's status and statusText properties are
|
||||
// unavailable, and a query attempt throws an exception.
|
||||
httpStatus = 13030;
|
||||
}
|
||||
|
||||
if(httpStatus >= 200 && httpStatus < 300){
|
||||
responseObject = this.createResponseObject(o, callback.argument);
|
||||
if(callback.success){
|
||||
if(!callback.scope){
|
||||
callback.success(responseObject);
|
||||
}
|
||||
else{
|
||||
// If a scope property is defined, the callback will be fired from
|
||||
// the context of the object.
|
||||
callback.success.apply(callback.scope, [responseObject]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
switch(httpStatus){
|
||||
// The following case labels are wininet.dll error codes that may be encountered.
|
||||
// Server timeout
|
||||
case 12002:
|
||||
// 12029 to 12031 correspond to dropped connections.
|
||||
case 12029:
|
||||
case 12030:
|
||||
case 12031:
|
||||
// Connection closed by server.
|
||||
case 12152:
|
||||
// See above comments for variable status.
|
||||
case 13030:
|
||||
responseObject = this.createExceptionObject(o.tId, callback.argument, isAbort);
|
||||
if(callback.failure){
|
||||
if(!callback.scope){
|
||||
callback.failure(responseObject);
|
||||
}
|
||||
else{
|
||||
callback.failure.apply(callback.scope, [responseObject]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
responseObject = this.createResponseObject(o, callback.argument);
|
||||
if(callback.failure){
|
||||
if(!callback.scope){
|
||||
callback.failure(responseObject);
|
||||
}
|
||||
else{
|
||||
callback.failure.apply(callback.scope, [responseObject]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.releaseObject(o);
|
||||
},
|
||||
|
||||
/**
|
||||
* This method evaluates the server response, creates and returns the results via
|
||||
* its properties. Success and failure cases will differ in the response
|
||||
* object's property values.
|
||||
* @private
|
||||
* @param {object} o The connection object
|
||||
* @param {} callbackArg User-defined argument or arguments to be passed to the callback
|
||||
* @return object
|
||||
*/
|
||||
createResponseObject:function(o, callbackArg)
|
||||
{
|
||||
var obj = {};
|
||||
var headerObj = {};
|
||||
|
||||
try
|
||||
{
|
||||
var headerStr = o.conn.getAllResponseHeaders();
|
||||
var header = headerStr.split('\n');
|
||||
for(var i=0; i < header.length; i++){
|
||||
var delimitPos = header[i].indexOf(':');
|
||||
if(delimitPos != -1){
|
||||
headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
|
||||
obj.tId = o.tId;
|
||||
obj.status = o.conn.status;
|
||||
obj.statusText = o.conn.statusText;
|
||||
obj.getResponseHeader = headerObj;
|
||||
obj.getAllResponseHeaders = headerStr;
|
||||
obj.responseText = o.conn.responseText;
|
||||
obj.responseXML = o.conn.responseXML;
|
||||
|
||||
if(typeof callbackArg !== undefined){
|
||||
obj.argument = callbackArg;
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* If a transaction cannot be completed due to dropped or closed connections,
|
||||
* there may be not be enough information to build a full response object.
|
||||
* The failure callback will be fired and this specific condition can be identified
|
||||
* by a status property value of 0.
|
||||
*
|
||||
* If an abort was successful, the status property will report a value of -1.
|
||||
*
|
||||
* @private
|
||||
* @param {int} tId Transaction Id
|
||||
* @param callbackArg The user-defined arguments
|
||||
* @param isAbort Determines if the exception is an abort.
|
||||
* @return object
|
||||
*/
|
||||
createExceptionObject:function(tId, callbackArg, isAbort)
|
||||
{
|
||||
var COMM_CODE = 0;
|
||||
var COMM_ERROR = 'communication failure';
|
||||
var ABORT_CODE = -1;
|
||||
var ABORT_ERROR = 'transaction aborted';
|
||||
|
||||
var obj = {};
|
||||
|
||||
obj.tId = tId;
|
||||
if(isAbort){
|
||||
obj.status = ABORT_CODE;
|
||||
obj.statusText = ABORT_ERROR;
|
||||
}
|
||||
else{
|
||||
obj.status = COMM_CODE;
|
||||
obj.statusText = COMM_ERROR;
|
||||
}
|
||||
|
||||
if(callbackArg){
|
||||
obj.argument = callbackArg;
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* Public method that stores the custom HTTP headers for each transaction.
|
||||
* @public
|
||||
* @param {string} label The HTTP header label
|
||||
* @param {string} value The HTTP header value
|
||||
* @return void
|
||||
*/
|
||||
initHeader:function(label,value)
|
||||
{
|
||||
if(this._http_header[label] === undefined){
|
||||
this._http_header[label] = value;
|
||||
}
|
||||
else{
|
||||
this._http_header[label] = value + "," + this._http_header[label];
|
||||
}
|
||||
|
||||
this._has_http_headers = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Accessor that sets the HTTP headers for each transaction.
|
||||
* @private
|
||||
* @param {object} o The connection object for the transaction.
|
||||
* @return void
|
||||
*/
|
||||
setHeader:function(o)
|
||||
{
|
||||
for(var prop in this._http_header){
|
||||
if(this._http_header.propertyIsEnumerable){
|
||||
o.conn.setRequestHeader(prop, this._http_header[prop]);
|
||||
}
|
||||
}
|
||||
delete this._http_header;
|
||||
|
||||
this._http_header = {};
|
||||
this._has_http_headers = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* This method assembles the form label and value pairs and
|
||||
* constructs an encoded string.
|
||||
* asyncRequest() will automatically initialize the
|
||||
* transaction with a HTTP header Content-Type of
|
||||
* application/x-www-form-urlencoded.
|
||||
* @public
|
||||
* @param {string || object} form id or name attribute, or form object.
|
||||
* @param {string} optional boolean to indicate SSL environment.
|
||||
* @param {string} optional qualified path of iframe resource for SSL in IE.
|
||||
* @return void
|
||||
*/
|
||||
setForm:function(formId, isUpload, secureUri)
|
||||
{
|
||||
this._sFormData = '';
|
||||
if(typeof formId == 'string'){
|
||||
// Determine if the argument is a form id or a form name.
|
||||
// Note form name usage is deprecated by supported
|
||||
// here for legacy reasons.
|
||||
var oForm = (document.getElementById(formId) || document.forms[formId]);
|
||||
}
|
||||
else if(typeof formId == 'object'){
|
||||
var oForm = formId;
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the isUpload argument is true, setForm will call createFrame to initialize
|
||||
// an iframe as the form target.
|
||||
//
|
||||
// The argument secureURI is also required by IE in SSL environments
|
||||
// where the secureURI string is a fully qualified HTTP path, used to set the source
|
||||
// of the iframe, to a stub resource in the same domain.
|
||||
if(isUpload){
|
||||
(typeof secureUri == 'string')?this.createFrame(secureUri):this.createFrame();
|
||||
this._isFormSubmit = true;
|
||||
this._isFileUpload = true;
|
||||
this._formNode = oForm;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var oElement, oName, oValue, oDisabled;
|
||||
var hasSubmit = false;
|
||||
|
||||
// Iterate over the form elements collection to construct the
|
||||
// label-value pairs.
|
||||
for (var i=0; i<oForm.elements.length; i++){
|
||||
oDisabled = oForm.elements[i].disabled;
|
||||
|
||||
// If the name attribute is not populated, the form field's
|
||||
// value will not be submitted.
|
||||
oElement = oForm.elements[i];
|
||||
oName = oForm.elements[i].name;
|
||||
oValue = oForm.elements[i].value;
|
||||
|
||||
// Do not submit fields that are disabled or
|
||||
// do not have a name attribute value.
|
||||
if(!oDisabled && oName)
|
||||
{
|
||||
switch (oElement.type)
|
||||
{
|
||||
case 'select-one':
|
||||
case 'select-multiple':
|
||||
for(var j=0; j<oElement.options.length; j++){
|
||||
if(oElement.options[j].selected){
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].value || oElement.options[j].text) + '&';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'radio':
|
||||
case 'checkbox':
|
||||
if(oElement.checked){
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
|
||||
}
|
||||
break;
|
||||
case 'file':
|
||||
// stub case as XMLHttpRequest will only send the file path as a string.
|
||||
case undefined:
|
||||
// stub case for fieldset element which returns undefined.
|
||||
case 'reset':
|
||||
// stub case for input type reset button.
|
||||
case 'button':
|
||||
// stub case for input type button elements.
|
||||
break;
|
||||
case 'submit':
|
||||
if(hasSubmit == false){
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
|
||||
hasSubmit = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._isFormSubmit = true;
|
||||
this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates an iframe to be used for form file uploads. It is remove from the
|
||||
* document upon completion of the upload transaction.
|
||||
*
|
||||
* @private
|
||||
* @param {string} optional qualified path of iframe resource for SSL in IE.
|
||||
* @return void
|
||||
*/
|
||||
createFrame:function(secureUri){
|
||||
|
||||
// IE does not allow the setting of id and name attributes as DOM
|
||||
// properties. A different iframe creation pattern is required for IE.
|
||||
if(window.ActiveXObject){
|
||||
var io = document.createElement('<IFRAME name="ioFrame" id="ioFrame">');
|
||||
if(secureUri){
|
||||
// IE will throw a security exception in an SSL environment if the
|
||||
// iframe source isn't set to a valid resource.
|
||||
io.src = secureUri;
|
||||
}
|
||||
}
|
||||
else{
|
||||
var io = document.createElement('IFRAME');
|
||||
io.id = 'ioFrame';
|
||||
io.name = 'ioFrame';
|
||||
}
|
||||
|
||||
io.style.position = 'absolute';
|
||||
io.style.top = '-1000px';
|
||||
io.style.left = '-1000px';
|
||||
|
||||
document.body.appendChild(io);
|
||||
},
|
||||
|
||||
/**
|
||||
* Uploads HTML form, including files/attachments, targeting the
|
||||
* iframe created in createFrame.
|
||||
*
|
||||
* @private
|
||||
* @param {int} id The transaction id.
|
||||
* @param {object} callback - User-defined callback object.
|
||||
* @param {string} uri Fully qualified path of resource.
|
||||
* @return void
|
||||
*/
|
||||
uploadFile:function(id, callback, uri){
|
||||
// Initialize the HTML form properties in case they are
|
||||
// not defined in the HTML form.
|
||||
this._formNode.action = uri;
|
||||
this._formNode.enctype = 'multipart/form-data';
|
||||
this._formNode.method = 'POST';
|
||||
this._formNode.target = 'ioFrame';
|
||||
this._formNode.submit();
|
||||
|
||||
// Reset form status properties.
|
||||
this._formNode = null;
|
||||
this._isFileUpload = false;
|
||||
this._isFormSubmit = false;
|
||||
|
||||
// Create the upload callback handler that fires when the iframe
|
||||
// receives the load event. Subsequently, the event handler is detached
|
||||
// and the iframe removed from the document.
|
||||
|
||||
var uploadCallback = function()
|
||||
{
|
||||
var oResponse =
|
||||
{
|
||||
tId: id,
|
||||
responseText: document.getElementById("ioFrame").contentWindow.document.body.innerHTML,
|
||||
argument: callback.argument
|
||||
}
|
||||
|
||||
if(callback.upload && !callback.scope){
|
||||
callback.upload(oResponse);
|
||||
}
|
||||
else{
|
||||
callback.upload.apply(callback.scope, [oResponse]);
|
||||
}
|
||||
|
||||
YAHOO.util.Event.removeListener("ioFrame", "load", uploadCallback);
|
||||
window.ioFrame.location.replace('#');
|
||||
setTimeout("document.body.removeChild(document.getElementById('ioFrame'))",100);
|
||||
};
|
||||
|
||||
// Bind the onload handler to the iframe to detect the file upload response.
|
||||
YAHOO.util.Event.addListener("ioFrame", "load", uploadCallback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Public method to terminate a transaction, if it has not reached readyState 4.
|
||||
* @public
|
||||
* @param {object} o The connection object returned by asyncRequest.
|
||||
* @param {object} callback User-defined callback object.
|
||||
* @param {string} isTimeout boolean to indicate if abort was a timeout.
|
||||
* @return void
|
||||
*/
|
||||
abort:function(o, callback, isTimeout)
|
||||
{
|
||||
if(this.isCallInProgress(o)){
|
||||
window.clearInterval(this._poll[o.tId]);
|
||||
this._poll.splice(o.tId);
|
||||
if(isTimeout){
|
||||
this._timeOut.splice(o.tId);
|
||||
}
|
||||
o.conn.abort();
|
||||
this.handleTransactionResponse(o, callback, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Public method to check if the transaction is still being processed.
|
||||
* @public
|
||||
* @param {object} o The connection object returned by asyncRequest
|
||||
* @return boolean
|
||||
*/
|
||||
isCallInProgress:function(o)
|
||||
{
|
||||
// if the XHR object assigned to the transaction has not been dereferenced,
|
||||
// then check its readyState status. Otherwise, return false.
|
||||
if(o.conn){
|
||||
return o.conn.readyState != 4 && o.conn.readyState != 0;
|
||||
}
|
||||
else{
|
||||
//The XHR object has been destroyed.
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Dereference the XHR instance and the connection object after the transaction is completed.
|
||||
* @private
|
||||
* @param {object} o The connection object
|
||||
* @return void
|
||||
*/
|
||||
releaseObject:function(o)
|
||||
{
|
||||
//dereference the XHR instance.
|
||||
o.conn = null;
|
||||
//dereference the connection object.
|
||||
o = null;
|
||||
}
|
||||
};
|
||||
@@ -1,54 +0,0 @@
|
||||
<div id="createautomaticgroupingform" class="popupwide">
|
||||
<h3><?php print_string('createautomaticgrouping', 'group'); ?></h3>
|
||||
<form name="automaticgroupingform" action="">
|
||||
|
||||
<table cellpadding="10">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<p><?php print_string('groupingname', 'group'); ?></p>
|
||||
<p><input id="automaticgroupingname" type="text" size="40" value="<?php print_string('defaultgroupingname', 'group'); ?>" /></p>
|
||||
<p><?php print_string('groupingdescription', 'group'); ?></p>
|
||||
<p><?php print_textarea($usehtmleditor, 4, 45, 150, 400, 'automaticgroupingdescription'); ?></p>
|
||||
<p> <?php print_string('prefixforgroupnames', 'group'); ?> </p>
|
||||
<p><input id="groupprefix" type="text" size="40 " value="<?php print_string('defaultgroupname', 'group'); ?> " /></p>
|
||||
<p><?php print_string('defaultgroupdescription', 'group'); ?></p>
|
||||
<p><?php print_textarea($usehtmleditor, 4, 45, 150, 400, 'defaultgroupdescription'); ?></p>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<p><input type="checkbox" id="alphabetical" /> <?php print_string('distributealphabetically', 'group'); ?></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td><input type="radio" name ="generationtype" id="nostudents" value="nostudents" checked />
|
||||
</td>
|
||||
<td> <?php print_string('selectnumberineachgroup', 'group'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<p><?php print_string('numberofstudents', 'group'); ?> </p><p><input id="noofstudents" type="text" size="5" /></p>
|
||||
<p><input type="checkbox" id="distribevenly" checked /> <?php print_string('distributeevenly', 'group'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><input type="radio" name ="generationtype" id="nogroups" value="nogroups" /></td>
|
||||
<td><?php print_string('selectnumberofgroups', 'group'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<p><?php print_string('numberofgroups', 'group'); ?></p><p> <input id="noofgroups" type="text" size="5" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p><input type="button" id="createautomaticgrouping" value=" <?php print_string('creategrouping', 'group'); ?>" />
|
||||
<input type="button" id="cancelcreateautomaticgrouping" value=" <?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,81 +0,0 @@
|
||||
function onCreateAutomaticGrouping() {
|
||||
valid = validateAutomaticGroupingForm();
|
||||
if (valid) {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
createAutomaticGrouping();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds an automatically generated grouping with the details as specified in the form
|
||||
*/
|
||||
function createAutomaticGrouping() {
|
||||
//alert("Called createAutomaticGrouping");
|
||||
var url = "createautomaticgrouping-xml.php";
|
||||
var requeststring = "noofstudents="+getTextInputValue('noofstudents')
|
||||
+"&noofgroups="+getTextInputValue('noofgroups')
|
||||
+"&distribevenly="+getCheckBoxValue('distribevenly')
|
||||
+"&alphabetical="+getCheckBoxValue('alphabetical')
|
||||
+"&generationtype="+getRadioValue(document.automaticgroupingform.generationtype)
|
||||
+"&name="+getTextInputValue('automaticgroupingname')
|
||||
+"&description="+getTextInputValue('edit-automaticgroupingdescription')
|
||||
+"&prefix="+getTextInputValue('groupprefix')
|
||||
+"&defaultgroupdescription="+getTextInputValue('edit-defaultgroupdescription');
|
||||
|
||||
// alert(requeststring);
|
||||
sendPostRequest(request, url, requeststring, createAutomaticGroupingResponse);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in createAutomaticGrouping()
|
||||
* It sets the new grouping to be selected in the form.
|
||||
*/
|
||||
function createAutomaticGroupingResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("createAutomaticGroupingResponse");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
selectedgroupingid = getFromXML(request.responseXML, 'groupingid');
|
||||
selectedgroupid = null;
|
||||
updateGroupings();
|
||||
hideElement("createautomaticgroupingform");
|
||||
}
|
||||
}
|
||||
|
||||
function validateAutomaticGroupingForm() {
|
||||
valid = true;
|
||||
generationtype = getRadioValue(document.automaticgroupingform.generationtype);
|
||||
noofstudents = getTextInputValue('noofstudents');
|
||||
noofgroups = getTextInputValue('noofgroups');
|
||||
groupingname = getTextInputValue('automaticgroupingname');
|
||||
|
||||
if (generationtype == 'nostudents') {
|
||||
if (!isPositiveInt(noofstudents)) {
|
||||
alert('The number of students is not valid.');
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
if (!isPositiveInt(noofgroups)) {
|
||||
alert('The number of groups is not valid.');
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupingname == '') {
|
||||
alert('You must enter a name for the new grouping');
|
||||
valid = false;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Sets up an automatic grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
groups_seed_random_number_generator();
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$noofstudents = required_param('noofstudents', PARAM_INT);
|
||||
$noofgroups = required_param('noofgroups', PARAM_INT);
|
||||
$distribevenly = required_param('distribevenly', PARAM_INT); //TODO: PARAM_BOOL ?
|
||||
$alphabetical = required_param('alphabetical', PARAM_INT);
|
||||
$generationtype = required_param('generationtype', PARAM_ALPHA);
|
||||
|
||||
$groupingsettings->name = required_param('name', PARAM_ALPHANUM);
|
||||
$groupingsettings->description = required_param('description', PARAM_ALPHANUM);
|
||||
$groupingsettings->prefix = required_param('prefix');
|
||||
$groupingsettings->defaultgroupdescription = required_param('defaultgroupdescription');
|
||||
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
if ($generationtype == 'nogroups') {
|
||||
$noofstudents = false;
|
||||
}
|
||||
|
||||
$groupingid = groups_create_automatic_grouping($courseid, $noofstudents, $noofgroups,
|
||||
$distribevenly, $groupingsettings, false, $alphabetical);
|
||||
if (!$groupingid) {
|
||||
echo '<error>Failed to create grouping</error>';
|
||||
} else {
|
||||
echo '<groupingid>'.$groupingid.'</groupingid>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,31 +0,0 @@
|
||||
<div id="creategroupform" class="popup">
|
||||
<h3><?php print_string('creategroup', 'group'); ?> <span id="selectedgroupingforcreatinggroup"></span></h3>
|
||||
<form action="">
|
||||
<p><label for="newgroupname"><?php print_string('groupname', 'group'); ?></label></p>
|
||||
<p><input id="newgroupname" type="text" size="40" value="<?php print_string('defaultgroupname', 'group'); ?>" />
|
||||
<p><?php print_string('groupingdescription', 'group'); ?><br />
|
||||
<?php helpbutton("text", get_string("helptext")) ?></p>
|
||||
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, "newgroupdescription");?></p>
|
||||
<p><?php print_string('enrolmentkey', 'group'); ?></p>
|
||||
<p><input type="text" id="newgroupenrolmentkey" size="25" /></p>
|
||||
<?php if ($printuploadpicture) { ?>
|
||||
<p><?php print_string('hidepicture', 'group'); ?></p>
|
||||
<p><?php $options = NULL; $options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
$group->hidepicture = 1;
|
||||
choose_from_menu ($options, "newgrouphidepicture", isset($group)? $group->hidepicture: 1, '');?></p>
|
||||
|
||||
<p><?php print_string('newpicture', 'group'); ?></p>
|
||||
<p><?php upload_print_form_fragment(1,array('newgroupicon'),null,false,null,0,0,false);
|
||||
helpbutton("picture", get_string("helppicture"));
|
||||
print_string("maxsize", "", display_size($maxbytes), 'group'); ?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
<p><input type="button" id="creategroup" value="<?php print_string('creategroup', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="cancelcreategroup" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,61 +0,0 @@
|
||||
|
||||
function onCreateGroup() {
|
||||
valid = validateCreateGroupForm();
|
||||
|
||||
if (valid) {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
createGroup();
|
||||
replaceText('selectedgroupingforcreatinggroup', "");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a group with the name specified in the form to the selected grouping.
|
||||
*/
|
||||
function createGroup() {
|
||||
//alert("Called createGroup");
|
||||
var url = "creategroup-xml.php";
|
||||
var requeststring = "groupname="+getTextInputValue('newgroupname')
|
||||
+"&groupingid="+selectedgroupingid
|
||||
+"&description="+getTextInputValue('edit-newgroupdescription')
|
||||
+"&enrolmentkey="+getTextInputValue('newgroupenrolmentkey');
|
||||
// The picture fields aren't displayed if the right library isn't present
|
||||
if (document.getElementById('menunewgrouphidepicture')) {
|
||||
requeststring = requeststring+"&hidepicture="+getTextInputValue('menunewgrouphidepicture');
|
||||
}
|
||||
sendPostRequest(request, url, requeststring, createGroupResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in createGroup()
|
||||
* The function sets the new group as selected in the form.
|
||||
*/
|
||||
function createGroupResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("createGroupResponse called");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
selectedgroupid = getFromXML(request.responseXML, 'groupid');
|
||||
updateGroupings();
|
||||
hideElement("creategroupform");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function validateCreateGroupForm() {
|
||||
valid = true;
|
||||
groupname = getTextInputValue('newgroupname');
|
||||
|
||||
if (groupname == '') {
|
||||
alert('You must enter a name for the new group');
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds a new group to a grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
|
||||
$groupsettings->name = required_param('groupname', PARAM_ALPHANUM);
|
||||
$groupsettings->description = required_param('description', PARAM_ALPHANUM);
|
||||
$groupsettings->enrolmentkey= required_param('enrolmentkey', PARAM_ALPHANUM);
|
||||
$groupsettings->hidepicture = optional_param('hidepicture', PARAM_INT);
|
||||
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupid = groups_create_group($courseid, $groupsettings);
|
||||
|
||||
if (!$groupid) {
|
||||
echo '<error>Failed to create group</error>';
|
||||
} else {
|
||||
$groupadded = groups_add_group_to_grouping($groupid, $groupingid);
|
||||
|
||||
if (!$groupadded) {
|
||||
echo '<error>Failed to add group to grouping</error>';
|
||||
} else {
|
||||
// Upload a picture file if there was one - note that we don't remove any previous icons
|
||||
require_once($CFG->libdir.'/uploadlib.php');
|
||||
$um = new upload_manager('newgroupicon', false, false, null, false, 0, true, true);
|
||||
if ($um->preprocess_files()) {
|
||||
require_once("$CFG->libdir/gdlib.php");
|
||||
if (save_profile_image($groupid, $um, 'groups')) {
|
||||
$groupsettings->picture = 1;
|
||||
$infoset = groups_set_group_settings($groupid, $groupsettings);
|
||||
if (!$infoset) {
|
||||
echo '<error>Failed to save the fact that the group image was uploaded</error>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '<groupid>'.$groupid.'</groupid>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<div id="creategroupingform" class="popup">
|
||||
<h3><?php print_string('creategrouping', 'group'); ?></h3>
|
||||
<form action="">
|
||||
<p><?php print_string('groupingname', 'group'); ?></p>
|
||||
<p><input id="newgroupingname" type="text" size="40" value="<?php print_string('defaultgroupingname', 'group'); ?>" /></p>
|
||||
<p><?php print_string('groupingdescription', 'group'); ?></p>
|
||||
<p><?php print_textarea($usehtmleditor,5, 45, 200, 400, "newgroupingdescription");?></p>
|
||||
<p><input type="button" id="creategrouping" value="<?php print_string('creategrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="cancelcreategrouping" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,56 +0,0 @@
|
||||
|
||||
|
||||
function onCreateGrouping() {
|
||||
valid = validateCreateGroupingForm();
|
||||
if (valid) {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
createGrouping();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new grouping for the course.
|
||||
*/
|
||||
function createGrouping() {
|
||||
// alert("Called createGrouping");
|
||||
var url = "creategrouping-xml.php";
|
||||
var requeststring = "groupingname="+getTextInputValue('newgroupingname')
|
||||
+"&description="+getTextInputValue('edit-newgroupingdescription');
|
||||
sendPostRequest(request, url, requeststring, createGroupingResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in createGrouping()
|
||||
* It sets the new grouping as selected in the form.
|
||||
*/
|
||||
function createGroupingResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
// alert("createGroupingResponse");
|
||||
// alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
selectedgroupingid = getFromXML(request.responseXML, 'groupingid');
|
||||
selectedgroupid = null;
|
||||
updateGroupings();
|
||||
hideElement("creategroupingform");
|
||||
}
|
||||
}
|
||||
|
||||
function validateCreateGroupingForm() {
|
||||
valid = true;
|
||||
groupingname = getTextInputValue('newgroupingname');
|
||||
|
||||
if (groupingname == '') {
|
||||
alert('You must enter a name for the new grouping');
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds a new grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$groupingsettings->name = required_param('groupingname', PARAM_ALPHANUM);
|
||||
$groupingsettings->description= required_param('description', PARAM_ALPHANUM);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingid = groups_create_grouping($courseid, $groupingsettings);
|
||||
|
||||
if (!$groupingid) {
|
||||
echo '<error>Failed to create grouping</error>';
|
||||
} else {
|
||||
echo '<groupingid>'.$groupingid.'</groupingid>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Deletes a group
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupremoved = groups_delete_group($groupid);
|
||||
|
||||
if ($groupremoved == false) {
|
||||
echo "<error>Could not delete group $groupid</error>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,35 +0,0 @@
|
||||
function onDeleteGroup() {
|
||||
hideAllForms()
|
||||
showElement("groupeditform");
|
||||
deleteGroup();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes the selected group
|
||||
*/
|
||||
function deleteGroup() {
|
||||
//alert("Called deleteGroup");
|
||||
var url = "deletegroup-xml.php";
|
||||
var requeststring = "groupid="+selectedgroupid;
|
||||
sendPostRequest(request, url, requeststring, deleteGroupResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in updateSelectedGrouping()
|
||||
*/
|
||||
function deleteGroupResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("deleteGroupResponse called");
|
||||
// alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
// Need XML sent back with groupingid
|
||||
// Really want to set this to be the grouping before
|
||||
selectedgroupid = null;
|
||||
updateGroupings();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Deletes a specified grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingremoved = groups_delete_grouping($groupingid);
|
||||
if (!$groupingremoved) {
|
||||
echo '<error>Failed to delete grouping</error>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
function onDeleteGrouping() {
|
||||
hideAllForms()
|
||||
showElement("groupeditform");
|
||||
deleteGrouping();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Deletes the selected grouping
|
||||
*/
|
||||
function deleteGrouping() {
|
||||
//alert("Called deleteGrouping");
|
||||
var url = "deletegrouping-xml.php";
|
||||
var requeststring = "groupingid="+selectedgroupingid;
|
||||
confirm('Are you sure you want to delete this grouping and the groups that it contains?');
|
||||
sendPostRequest(request, url, requeststring, deleteGroupingResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in deleteGrouping()
|
||||
*/
|
||||
function deleteGroupingResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("deleteGroupingResponse called");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
selectedgroupingid = null;
|
||||
selectedgroupid = null;
|
||||
updateGroupings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<div id="editgroupingpermissionsform" class="popup">
|
||||
<h3><?php print_string('editgroupingpermissions', 'group'); ?> for <span id="editperm-groupingname"></span></h3>
|
||||
<form action="">
|
||||
<p><input type="checkbox" id="edit-viewowngroup" checked /><?php print_string('viewowngroup', 'group'); ?></p>
|
||||
<p><input type="checkbox" id="edit-viewallgroupsmembers" checked /><?php print_string('viewallgroupsmembers', 'group'); ?></p>
|
||||
<p><input type="checkbox" id="edit-viewallgroupsactivities" checked /><?php print_string('viewallgroupsactivities', 'group'); ?></p>
|
||||
<p><input type="checkbox" id="edit-teachersgroupmark" /><?php print_string('teachersgroupmark', 'group'); ?></p>
|
||||
<p><input type="checkbox" id="edit-teachersgroupview" /><?php print_string('teachersgroupview', 'group'); ?></p>
|
||||
<p><input type="checkbox" id="edit-teachersoverride" /><?php print_string('teachersoverride', 'group'); ?></p>
|
||||
<p><input type="button" id="editgroupingpermissions" value="<?php print_string('save', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="canceleditgroupingpermissions" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,66 +0,0 @@
|
||||
|
||||
function onEditGroupingPermissionsSave() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
editGroupingPermissions() ;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new grouping for the course.
|
||||
*/
|
||||
function editGroupingPermissions() {
|
||||
var url = "editgroupingpermissions-xml.php";
|
||||
var requeststring = "groupingid=" + selectedgroupingid
|
||||
+"&viewowngroup=" + getCheckBoxValue('edit-viewowngroup')
|
||||
+"&viewallgroupsmembers=" + getCheckBoxValue('edit-viewallgroupsmembers')
|
||||
+"&viewallgroupsactivities=" + getCheckBoxValue('edit-viewallgroupsactivities')
|
||||
+"&teachersgroupmark=" + getCheckBoxValue('edit-teachersgroupmark')
|
||||
+"&teachersgroupview=" + getCheckBoxValue('edit-teachersgroupview')
|
||||
+"&teachersoverride=" + getCheckBoxValue('edit-teachersoverride');
|
||||
sendPostRequest(request, url, requeststring, editGroupingPermissionsResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in editgroupingpermissions()
|
||||
* It sets the new grouping as selected in the form.
|
||||
*/
|
||||
function editGroupingPermissionsResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("editGroupingPermissionsResponse called");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
updateGroupings();
|
||||
hideElement("editgroupingpermissionsform");
|
||||
}
|
||||
}
|
||||
|
||||
function getGroupingPermissions() {
|
||||
//alert("Called getgroupingpermissions");
|
||||
var url = "getgroupingpermissions-xml.php";
|
||||
var requeststring = "groupingid="+selectedgroupingid;
|
||||
sendPostRequest(request, url, requeststring, getGroupingPermissionsResponse);
|
||||
}
|
||||
|
||||
function getGroupingPermissionsResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("getgroupingpermissionsResponse");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
xml = request.responseXML;
|
||||
replaceText('editperm-groupingname', getFromXML(xml, 'name'));
|
||||
setCheckBoxValue('edit-viewowngroup', boolStringToBool(getFromXML(xml, 'viewowngroup')));
|
||||
setCheckBoxValue('edit-viewallgroupsmembers', boolStringToBool(getFromXML(xml, 'viewallgroupsmembers')));
|
||||
setCheckBoxValue('edit-viewallgroupsactivities', boolStringToBool(getFromXML(xml, 'viewallgroupsactivities')));
|
||||
setCheckBoxValue('edit-teachersgroupmark', boolStringToBool(getFromXML(xml, 'teachersgroupmark')));
|
||||
setCheckBoxValue('edit-teachersgroupview', boolStringToBool(getFromXML(xml, 'teachersgroupview')));
|
||||
setCheckBoxValue('edit-teachersoverride', boolStringToBool(getFromXML(xml, 'teachersoverride')));
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds a new grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$groupingsettings->viewowngroup = required_param('viewowngroup', PARAM_INT); //TODO: PARAM_BOOL ??
|
||||
$groupingsettings->viewallgroupsmembers = required_param('viewallgroupsmembers', PARAM_INT);
|
||||
$groupingsettings->viewallgroupsactivities = required_param('viewallgroupsactivities', PARAM_INT);
|
||||
$groupingsettings->teachersgroupmark = required_param('teachersgroupmark', PARAM_INT);
|
||||
$groupingsettings->teachersgroupview = required_param('teachersgroupview', PARAM_INT);
|
||||
$groupingsettings->teachersoverride = required_param('teachersoverride', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingid = groups_set_grouping_settings($groupingid, $groupingsettings);
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,11 +0,0 @@
|
||||
<div id="editgroupingsettingsform" class="popup">
|
||||
<h3><?php print_string('editgroupingsettings', 'group'); ?></h3>
|
||||
<form action="">
|
||||
<p><?php print_string('groupingname', 'group'); ?></p>
|
||||
<p><input id="edit-groupingname" type="text" size="40" /></p>
|
||||
<p><?php print_string('groupingdescription', 'group'); ?></p>
|
||||
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, "edit-groupingdescription");?></p>
|
||||
<p><input type="button" id="editgroupingsettings" value="<?php print_string('save', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="canceleditgroupingsettings" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,75 +0,0 @@
|
||||
|
||||
function onEditGroupingSettingsSave() {
|
||||
valid = validateEditGroupingSettingsForm();
|
||||
if (valid) {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
editGroupingSettings() ;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new grouping for the course.
|
||||
*/
|
||||
function editGroupingSettings() {
|
||||
var url = "editgroupingsettings-xml.php";
|
||||
var requeststring = "groupingid="+selectedgroupingid
|
||||
+"&groupingname="+getTextInputValue('edit-groupingname')
|
||||
+"&description="+getTextInputValue('edit-edit-groupingdescription');
|
||||
sendPostRequest(request, url, requeststring, editGroupingSettingsResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in editgroupingsettings()
|
||||
* It sets the new grouping as selected in the form.
|
||||
*/
|
||||
function editGroupingSettingsResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("editGroupingSettingsResponse called");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
updateGroupings();
|
||||
hideElement("editgroupingsettingsform");
|
||||
}
|
||||
}
|
||||
|
||||
function getGroupingSettings() {
|
||||
//alert("Called getgroupingsettings");
|
||||
var url = "getgroupingsettings-xml.php";
|
||||
var requeststring = "groupingid="+selectedgroupingid;
|
||||
sendPostRequest(request, url, requeststring, getGroupingSettingsResponse);
|
||||
}
|
||||
|
||||
function getGroupingSettingsResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("getgroupingsettingsResponse");
|
||||
//alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
xml = request.responseXML;
|
||||
setTextInputValue('edit-groupingname', getFromXML(xml, 'name'));
|
||||
setTextInputValue('edit-edit-groupingdescription', getFromXML(xml, 'description'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function validateEditGroupingSettingsForm() {
|
||||
valid = true;
|
||||
groupingname = getTextInputValue('edit-groupingname');
|
||||
|
||||
if (groupingname == '') {
|
||||
alert('You must enter a name for the new grouping');
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds a new grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
$groupingsettings->name = required_param('groupingname', PARAM_ALPHANUM);
|
||||
$groupingsettings->description= required_param('description', PARAM_ALPHANUM);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingid = groups_set_grouping_settings($groupingid, $groupingsettings);
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,22 +0,0 @@
|
||||
<div id="editgroupsettingsform" class="popup">
|
||||
<h3><?php print_string('editgroupsettings', 'group'); ?></h3>
|
||||
<form action="">
|
||||
<p><?php print_string('groupname', 'group'); ?></p>
|
||||
<p><input id="groupname" type="text" size="40" /></p>
|
||||
<p><?php print_string("description") ?><br />
|
||||
<?php helpbutton("text", get_string("helptext")) ?></p>
|
||||
<p><?php print_textarea($usehtmleditor, 5, 45, 200, 400, "groupdescription");?> </p>
|
||||
<p><?php print_string('enrolmentkey') ?></p>
|
||||
<p><input type="text" id="enrolmentkey" size="25" /></p>
|
||||
<?php if ($printuploadpicture) { ?>
|
||||
<p><?php print_string("hidepicture") ?></p>
|
||||
<p><?php $options = NULL; $options[0] = get_string("no"); $options[1] = get_string("yes");
|
||||
choose_from_menu ($options, "hidepicture", $group->hidepicture, ""); ?></p>
|
||||
<p><?php print_string("newpicture") ?></p>
|
||||
<p><?php upload_print_form_fragment(1,array('groupicon'),null,false,null,0,0,false);
|
||||
helpbutton("picture", get_string("helppicture"));
|
||||
print_string("maxsize", "", display_size($maxbytes), 'group'); ?></p>
|
||||
<?php } ?>
|
||||
<p><input type="button" id="editgroupsettings" value="<?php print_string('save', 'group'); ?>" /> <input type="button" id="canceleditgroupsettings" value="<?php print_string('cancel', 'group'); ?>" /></p>
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,79 +0,0 @@
|
||||
|
||||
function onEditGroupSettingsSave() {
|
||||
valid = validateEditgroupsettingsForm();
|
||||
if (valid) {
|
||||
editgroupsettings() ;
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new group for the course.
|
||||
*/
|
||||
function editGroupSettings() {
|
||||
// alert("Called editgroupsettings");
|
||||
var url = "editgroupsettings-xml.php";
|
||||
var requeststring = "groupid="+selectedgroupid
|
||||
+"&groupname="+getTextInputValue('groupname')
|
||||
+"&description="+getTextInputValue('edit-groupdescription')
|
||||
+"&enrolmentkey="+getTextInputValue('enrolmentkey')
|
||||
+"&hidepicture="+hidepicture;
|
||||
// The picture fields aren't displayed if the right library isn't present
|
||||
if (document.getElementById('menuhidepicture')) {
|
||||
requeststring = requeststring+"&hidepicture="+getTextInputValue('menuhidepicture');
|
||||
}
|
||||
sendPostRequest(request, url, requeststring, editGroupSettingsResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in editgroupsettings(()
|
||||
*/
|
||||
function editGroupSettingsResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
// alert("editgroupsettingsResponse");
|
||||
// alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
updateSelectedGrouping();
|
||||
hideElement("editgroupsettingsform");
|
||||
}
|
||||
}
|
||||
|
||||
function getGroupSettings() {
|
||||
// alert("Called getgroupsettings");
|
||||
groupid = getSelectedGroup();
|
||||
var url = "getgroupsettings-xml.php";
|
||||
var requeststring = "groupid="+groupid;
|
||||
sendPostRequest(request, url, requeststring, getGroupSettingsResponse);
|
||||
}
|
||||
|
||||
function getGroupSettingsResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
// alert("getgroupsettingsResponse");
|
||||
// alert(request.responseText);
|
||||
error = getFromXML(request.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
xml = request.responseXML;
|
||||
setTextInputValue('groupname', getFromXML(xml, 'name'));
|
||||
setTextInputValue('edit-groupdescription', getFromXML(xml, 'description'));
|
||||
setTextInputValue('enrolmentkey', getFromXML(xml, 'enrolmentkey'));
|
||||
}
|
||||
}
|
||||
|
||||
function validateEditgroupsettingsForm() {
|
||||
valid = true;
|
||||
groupname = getTextInputValue('groupname');
|
||||
|
||||
if (groupname == '') {
|
||||
alert('You must enter a name for the new group');
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds a new grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$groupname = required_param('groupname', PARAM_ALPHANUM);
|
||||
$description = required_param('description', PARAM_ALPHANUM);
|
||||
$enrolmentkey= required_param('enrolmentkey', PARAM_ALPHANUM);
|
||||
$hidepicture = required_param('hidepicture', PARAM_INT); //TODO: PARAM_BOOL ??
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupsettings->name = $groupname;
|
||||
$groupsettings->description = $description;
|
||||
$groupsettings->enrolmentkey = $enrolmentkey;
|
||||
$groupsettings->hidepicture = $hidepicture;
|
||||
|
||||
// Upload the group icon if there is one - note that we don't remove any previous icons
|
||||
require_once($CFG->libdir.'/uploadlib.php');
|
||||
$um = new upload_manager('groupicon', false, false, null, false, 0, true, true);
|
||||
if ($um->preprocess_files()) {
|
||||
require_once("$CFG->libdir/gdlib.php");
|
||||
if (save_profile_image($groupid, $um, 'groups')) {
|
||||
$groupsettings->picture = 1;
|
||||
} else {
|
||||
echo '<error>Failed to save group image</error>';
|
||||
}
|
||||
} else {
|
||||
$groupsettings->picture = 0;
|
||||
}
|
||||
|
||||
$infoset = groups_set_group_settings($groupid, $groupsettings);
|
||||
if (!$infoset) {
|
||||
echo "<error>Failed to set new group settings</error>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,52 +0,0 @@
|
||||
.popup
|
||||
{
|
||||
position:absolute;
|
||||
left:300px;
|
||||
top:80px;
|
||||
width:550px;
|
||||
border-style:solid;
|
||||
border-color: grey;
|
||||
border-width: 1px;
|
||||
background-color: white;
|
||||
padding:10px;
|
||||
z-index:1;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.popupwide
|
||||
{
|
||||
position:absolute;
|
||||
left:200px;
|
||||
top:80px;
|
||||
width:900px;
|
||||
border-style:solid;
|
||||
border-color: grey;
|
||||
border-width: 1px;
|
||||
background-color: white;
|
||||
padding:10px;
|
||||
z-index:1;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.select
|
||||
{
|
||||
overflow: visible;
|
||||
clip: auto;
|
||||
width:200px;
|
||||
}
|
||||
|
||||
.groupmanagementtable
|
||||
{
|
||||
padding: 10px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.groupmanagementtableheader
|
||||
{
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<link rel="stylesheet" type="text/css" href="form.css" />
|
||||
|
||||
|
||||
<script type="text/javascript" src="yahoo.js"></script>
|
||||
<script type="text/javascript" src="connection.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
<!-- Begin
|
||||
<?php include('ajax.js'); ?>
|
||||
// end hiding script -->
|
||||
</script>
|
||||
<script type="text/javascript" src="util-form.js"></script>
|
||||
<script type="text/javascript" src="main-buttons-form.js"></script>
|
||||
<script type="text/javascript" src="main-selects-form.js"></script>
|
||||
<script type="text/javascript" src="creategroup-form.js"></script>
|
||||
<script type="text/javascript" src="creategrouping-form.js"></script>
|
||||
<script type="text/javascript" src="editgroupingsettings-form.js"></script>
|
||||
<script type="text/javascript" src="editgroupingpermissions-form.js"></script>
|
||||
<script type="text/javascript" src="editgroupsettings-form.js"></script>
|
||||
<script type="text/javascript" src="createautomaticgrouping-form.js"></script>
|
||||
<script type="text/javascript" src="addmembers-form.js"></script>
|
||||
<script type="text/javascript" src="addgroupstogrouping-form.js"></script>
|
||||
<script type="text/javascript" src="main-init-form.js"></script>
|
||||
<script type="text/javascript" src="deletegroup.js"></script>
|
||||
<script type="text/javascript" src="deletegrouping.js"></script>
|
||||
<script type="text/javascript" src="removegroupfromgrouping.js"></script>
|
||||
<script type="text/javascript" src="removemembers.js"></script>
|
||||
|
||||
|
||||
<noscript>
|
||||
<?php notify(get_string('javascriptrequired')); ?>
|
||||
</noscript>
|
||||
|
||||
<?php include('main-form.html'); ?>
|
||||
<?php include('creategroup-form.html'); ?>
|
||||
<?php include('editgroupsettings-form.html'); ?>
|
||||
<?php include('creategrouping-form.html'); ?>
|
||||
<?php include('editgroupingsettings-form.html'); ?>
|
||||
<?php include('editgroupingpermissions-form.html'); ?>
|
||||
<?php include('addgroupstogrouping-form.html'); ?>
|
||||
<?php include('addmembers-form.html'); ?>
|
||||
<?php include('createautomaticgrouping-form.html'); ?>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Fetches the settings of a grouping and returns
|
||||
* them in an XML format
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingsettings = groups_get_grouping_settings($groupingid);
|
||||
echo '<name>'.$groupingsettings->name.'</name>';
|
||||
|
||||
if ($groupingsettings->viewowngroup) {
|
||||
echo '<viewowngroup>true</viewowngroup>';
|
||||
} else {
|
||||
echo '<viewowngroup>false</viewowngroup>';
|
||||
}
|
||||
|
||||
if ($groupingsettings->viewallgroupsmembers) {
|
||||
echo '<viewallgroupsmembers>true</viewallgroupsmembers>';
|
||||
} else {
|
||||
echo '<viewallgroupsmembers>false</viewallgroupsmembers>';
|
||||
}
|
||||
|
||||
if ($groupingsettings->viewallgroupsactivities) {
|
||||
echo '<viewallgroupsactivities>true</viewallgroupsactivities>';
|
||||
} else {
|
||||
echo '<viewallgroupsactivities>false</viewallgroupsactivities>';
|
||||
}
|
||||
|
||||
if ($groupingsettings->teachersgroupmark) {
|
||||
echo '<teachersgroupmark>true</teachersgroupmark>';
|
||||
} else {
|
||||
echo '<teachersgroupmark>false</teachersgroupmark>';
|
||||
}
|
||||
|
||||
if ($groupingsettings->teachersgroupview) {
|
||||
echo '<teachersgroupview>true</teachersgroupview>';
|
||||
} else {
|
||||
echo '<teachersgroupview>false</teachersgroupview>';
|
||||
}
|
||||
|
||||
if ($groupingsettings->teachersoverride) {
|
||||
echo '<teachersoverride>true</teachersoverride>';
|
||||
} else {
|
||||
echo '<teachersoverride>false</teachersoverride>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Fetches the settings of the groupings for a course
|
||||
* and returns them in an XML format
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingids = groups_get_groupings($courseid);
|
||||
if ($groupingids != false) {
|
||||
// Put the groupings into a hash and sort them
|
||||
foreach($groupingids as $groupingid) {
|
||||
$listgroupings[$groupingid] = groups_get_grouping_displayname($groupingid);
|
||||
}
|
||||
natcasesort($listgroupings);
|
||||
|
||||
// Print out the XML
|
||||
echo '<option>';
|
||||
foreach($listgroupings as $value=>$name) {
|
||||
echo "<name>$name</name>";
|
||||
echo "<value>$value</value>";
|
||||
}
|
||||
echo '</option>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Fetches the settings of a grouping and returns
|
||||
* them in an XML format
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingsettings = groups_get_grouping_settings($groupingid);
|
||||
echo '<name>'.$groupingsettings->name.'</name>';
|
||||
echo '<description>'.$groupingsettings->description.'</description>';
|
||||
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Fetches the settings of a grouping and returns
|
||||
* them in an XML format
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
|
||||
$groupsettings = groups_get_group_settings($groupid);
|
||||
if (!$groupsettings) {
|
||||
echo '<error>Failed to get group details</error>';
|
||||
} else {
|
||||
echo '<name>'.$groupsettings->name.'</name>';
|
||||
echo '<description>'.$groupsettings->description.'</description>';
|
||||
echo '<enrolmentkey>'.$groupsettings->enrolmentkey.'</enrolmentkey>';
|
||||
echo '<hidepicture>'.$groupsettings->hidepicture.'</hidepicture>';
|
||||
echo '<picture>'.$groupsettings->picture.'</picture>';
|
||||
echo '<lang>'.$groupinkfo->lang.'</lang>';
|
||||
echo '<theme>'.$groupsettings->theme.'</theme>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Adds an existing group to a grouping
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupids = groups_get_groups_in_grouping($groupingid);
|
||||
|
||||
if ($groupids != false) {
|
||||
// Put the groupings into a hash and sort them
|
||||
foreach($groupids as $groupid) {
|
||||
$listgroups[$groupid] = groups_get_group_displayname($groupid);
|
||||
}
|
||||
|
||||
natcasesort($listgroups);
|
||||
|
||||
// Print out the XML
|
||||
echo "<option>";
|
||||
foreach($listgroups as $value=>$name) {
|
||||
echo "<name>$name</name>";
|
||||
echo "<value>$value</value>";
|
||||
}
|
||||
echo "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Gets the groups not in a grouping for a course
|
||||
* and returns them in an XML format
|
||||
**********************************************/
|
||||
|
||||
require_once('../lib/lib.php');
|
||||
require_once('../../config.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupids = groups_get_groups_not_in_grouping($groupingid, $courseid);
|
||||
if ($groupids != false) {
|
||||
// Put the groupings into a hash and sort them
|
||||
foreach($groupids as $groupid) {
|
||||
$listgroups[$groupid] = groups_get_group_displayname($groupid);
|
||||
}
|
||||
|
||||
natcasesort($listgroups);
|
||||
|
||||
// Print out the XML
|
||||
echo "<option>";
|
||||
foreach($listgroups as $value=>$name) {
|
||||
echo "<name>$name</name>";
|
||||
echo "<value>$value</value>";
|
||||
}
|
||||
echo "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Gets the members of a group and returns them
|
||||
* in an XMl format
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
|
||||
$userids = groups_get_members($groupid);
|
||||
|
||||
if ($userids != false) {
|
||||
// Put the groupings into a hash and sort them
|
||||
foreach($userids as $userid) {
|
||||
$listmembers[$userid] = groups_get_user_displayname($userid, $courseid);
|
||||
}
|
||||
natcasesort($listmembers);
|
||||
|
||||
|
||||
// Print out the XML
|
||||
|
||||
echo "<option>";
|
||||
foreach($listmembers as $value=>$name) {
|
||||
echo "<name>$name</name>";
|
||||
echo "<value>$value</value>";
|
||||
}
|
||||
echo "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Gets the users registered for a course that
|
||||
* don't belong to a specified group and prints
|
||||
* their detailsin an XML format.
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$showall = required_param('showall', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
echo "$groupingid $groupid";
|
||||
if ($showall == 0) {
|
||||
$userids = groups_get_users_not_in_any_group_in_grouping($courseid,$groupingid, $groupid);
|
||||
} else {
|
||||
$userids = groups_get_users_not_in_group($courseid, $groupid);
|
||||
}
|
||||
|
||||
if ($userids != false) {
|
||||
// Put the groupings into a hash and sorts them
|
||||
foreach($userids as $userid) {
|
||||
$listmembers[$userid] = groups_get_user_displayname($userid, $courseid);
|
||||
}
|
||||
natcasesort($listmembers);
|
||||
|
||||
|
||||
// Print out the XML
|
||||
echo "<option>";
|
||||
foreach($listmembers as $value=>$name) {
|
||||
echo "<name>$name</name>";
|
||||
echo "<value>$value</value>";
|
||||
}
|
||||
echo "</option>";
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,64 +0,0 @@
|
||||
<?php // $Id$
|
||||
/**
|
||||
* The main group management user interface.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author J.White AT open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package groups
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
//require_once('../../course/lib.php');
|
||||
require_once($CFG->libdir.'/moodlelib.php');
|
||||
require_once($CFG->libdir.'/uploadlib.php');
|
||||
|
||||
$error = false;
|
||||
|
||||
$courseid = required_param('id', PARAM_INTEGER);
|
||||
|
||||
// Get the course information so we can print the header and check the course id
|
||||
// is valid
|
||||
$course = groups_get_course_info($courseid);
|
||||
if (!$course) {
|
||||
$error = true;
|
||||
print_error('The course id is invalid');
|
||||
}
|
||||
|
||||
|
||||
if (!$error) {
|
||||
// Make sure that the user is a teacher with edit permission for this course
|
||||
require_login($courseid);
|
||||
if (!isteacheredit($courseid)) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
// Set the session key so we can check this later
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
if (!empty($CFG->gdversion)) { //TODO: and $maxbytes)
|
||||
$printuploadpicture = true;
|
||||
} else {
|
||||
$printuploadpicture = false;
|
||||
}
|
||||
|
||||
|
||||
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $course->maxbytes);
|
||||
$strgroups = get_string('groups');
|
||||
$strparticipants = get_string('participants');
|
||||
// Print the page and form
|
||||
print_header("$course->shortname: $strgroups",
|
||||
$course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
|
||||
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
|
||||
"-> $strgroups", "", "", true, '', user_login_string($course, $USER));
|
||||
|
||||
//TODO: set to false in /course/group.php
|
||||
$usehtmleditor = false;
|
||||
|
||||
require_once('form.html');
|
||||
|
||||
print_footer($course);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,66 +0,0 @@
|
||||
|
||||
|
||||
function onShowAddMembersForm() {
|
||||
hideAllForms();
|
||||
showElement("addmembersform");
|
||||
updateNonMembers();
|
||||
groupname = getSelectedGroupName();
|
||||
replaceText('selectedgroup', groupname);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowAddGroupsToGroupingForm() {
|
||||
hideAllForms();
|
||||
showElement("addgroupstogroupingform");
|
||||
updateGroupsNotInGrouping();
|
||||
groupingname = getSelectedGroupingName();
|
||||
replaceText('selectedgroupingforaddinggroups', groupingname);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowCreateGroupingForm() {
|
||||
hideAllForms();
|
||||
showElement("creategroupingform");
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowCreateGroupForm() {
|
||||
hideAllForms();
|
||||
showElement("creategroupform");
|
||||
groupingname = getSelectedGroupingName();
|
||||
replaceText('selectedgroupingforcreatinggroup', groupingname);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowEditGroupSettingsForm() {
|
||||
hideAllForms();
|
||||
showElement("editgroupsettingsform");
|
||||
getGroupSettings();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowEditGroupingPermissionsForm() {
|
||||
hideAllForms();
|
||||
showElement("editgroupingpermissionsform");
|
||||
getGroupingPermissions();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onShowEditGroupingSettingsForm() {
|
||||
hideAllForms();
|
||||
showElement("editgroupingsettingsform");
|
||||
getGroupingSettings();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function onShowAutomaticGroupingForm() {
|
||||
hideAllForms();
|
||||
showElement("createautomaticgroupingform");
|
||||
return false;
|
||||
}
|
||||
|
||||
function onPrinterFriendly() {
|
||||
document.location.href = "printgrouping.php?courseid="+courseid+"&groupingid="+selectedgroupingid;
|
||||
return false;
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
<form name="groupeditform" id="groupeditform" action="">
|
||||
<table cellpadding="10" class="generaltable generalbox groupmanagementtable">
|
||||
<tr>
|
||||
<th class="header groupmanagementtableheader" scope="col"><?php print_string('groupings', 'group'); ?></th>
|
||||
<th class="header groupmanagementtableheader" scope="col"><?php print_string('groupsinselectedgrouping', 'group'); ?></th>
|
||||
<th class="header groupmanagementtableheader" scope="col"><?php print_string('membersofselectedgroup', 'group'); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="generalboxcontent">
|
||||
<select id="groupings" size="15" class="select"></select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="groups" size="15" class="select"></select>
|
||||
</td>
|
||||
<td>
|
||||
<select id="members" size="15" multiple="multiple" class="select"></select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p><input type="button" id="showeditgroupingsettingsform" value="<?php print_string('editgroupingsettings', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="showeditgroupingpermissionsform" value="<?php print_string('editgroupingpermissions', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="deletegrouping" value="<?php print_string('deletegrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="showcreategroupingform" value="<?php print_string('creategrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="showcreateautomaticgroupingform" value="<?php print_string('createautomaticgrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="printerfriendly" value="<?php print_string('printerfriendly', 'group'); ?>" /></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><input type="button" id="showeditgroupsettingsform" value="<?php print_string('editgroupsettings', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="deletegroup" value="<?php print_string('deleteselectedgroup', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="removegroup" value="<?php print_string('removegroupfromselectedgrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="showcreategroupform" value="<?php print_string('creategroupinselectedgrouping', 'group'); ?>" /></p>
|
||||
<p><input type="button" id="showaddgroupstogroupingform" value="<?php print_string('addexistinggroupstogrouping', 'group'); ?>" /></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><input type="button" id="removemembers" value="<?php print_string('removeselectedusers', 'group'); ?>"/></p>
|
||||
<p><input type="button" id="showaddmembersform" value="<?php print_string('adduserstogroup', 'group'); ?>" /></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file contains all the functions called when the pages loads and also all the functions that are called
|
||||
* on events such as clicking buttons in the forms for the form.html page.
|
||||
*
|
||||
* This script requires functions from ajax.js and form-access.js
|
||||
*
|
||||
* This code also assumes you have a basic understanding of how Ajax works - if
|
||||
* you don't, it won't make much sense!
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Create XMLHttpRequest objects to use
|
||||
var request = createRequest();
|
||||
var updategroupingsrequest = createRequest();
|
||||
var updateselectedgroupingsrequest = createRequest();
|
||||
var updateselectedgrouprequest = createRequest();
|
||||
|
||||
// The selectedgroupingid should always be set to the current selected groupingid and the
|
||||
// selectedgroupid should always be set to the current selected groupid. We initialise them to
|
||||
// be null at the start, but they'll get set when the page loads.
|
||||
var selectedgroupingid = null;
|
||||
var selectedgroupid = null;
|
||||
|
||||
// When the page has loaded called the initPage function
|
||||
window.onload = initPage;
|
||||
|
||||
/**
|
||||
* The initPage function updates the groupings, groups and members in all the selects appropriately
|
||||
*and adds the right javascript events to all the buttons etc.
|
||||
*/
|
||||
function initPage() {
|
||||
// Check that we're using a recent enough version of javascript
|
||||
if (!document.getElementById) {
|
||||
return false;
|
||||
}
|
||||
updateGroupings();
|
||||
|
||||
addEvent('groupings', 'change', onGroupingChange);
|
||||
addEvent('groups', 'change', onGroupChange);
|
||||
addEvent('deletegrouping', 'click', onDeleteGrouping);
|
||||
addEvent('deletegroup', 'click', onDeleteGroup);
|
||||
addEvent('removegroup', 'click', onRemoveGroup);
|
||||
addEvent('removemembers', 'click', onRemoveMembers);
|
||||
addEvent('showaddmembersform', 'click', onShowAddMembersForm);
|
||||
addEvent('showaddgroupstogroupingform', 'click', onShowAddGroupsToGroupingForm);
|
||||
addEvent('showcreategroupingform', 'click', onShowCreateGroupingForm);
|
||||
addEvent('showcreategroupform', 'click', onShowCreateGroupForm);
|
||||
addEvent('showeditgroupsettingsform', 'click', onShowEditGroupSettingsForm);
|
||||
addEvent('showeditgroupingsettingsform', 'click', onShowEditGroupingSettingsForm);
|
||||
addEvent('showeditgroupingpermissionsform', 'click', onShowEditGroupingPermissionsForm);
|
||||
addEvent('showcreateautomaticgroupingform', 'click', onShowAutomaticGroupingForm);
|
||||
addEvent('printerfriendly', 'click', onPrinterFriendly);
|
||||
addEvent('createautomaticgrouping', 'click', onCreateAutomaticGrouping);
|
||||
addEvent('cancelcreateautomaticgrouping', 'click', onCancel);
|
||||
addEvent('addgroupstogrouping', 'click', onAddGroupsToGrouping);
|
||||
addEvent('canceladdgroupstogrouping', 'click', onCancel);
|
||||
addEvent('creategroup', 'click', onCreateGroup);
|
||||
addEvent('cancelcreategroup', 'click', onCancel);
|
||||
addEvent('creategrouping', 'click', onCreateGrouping);
|
||||
addEvent('cancelcreategrouping', 'click', onCancel);
|
||||
addEvent('addmembers', 'click', onAddMembers);
|
||||
addEvent('canceladdmembers', 'click', onCancel);
|
||||
addEvent('showall', 'change', onShowAll);
|
||||
addEvent('editgroupsettings', 'click', onEditGroupSettingsSave);
|
||||
addEvent('canceleditgroupsettings', 'click', onCancel);
|
||||
addEvent('editgroupingsettings', 'click', onEditGroupingSettingsSave);
|
||||
addEvent('canceleditgroupingsettings', 'click', onCancel);
|
||||
addEvent('editgroupingpermissions', 'click', onEditGroupingPermissionsSave);
|
||||
addEvent('canceleditgroupingpermissions', 'click', onCancel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,240 +0,0 @@
|
||||
/**
|
||||
* This file contains various utility functions, primarily to get and set information on form.html
|
||||
* and to take information from XML documents and either return information from them or modifiy the
|
||||
* form appropriately.
|
||||
*/
|
||||
|
||||
|
||||
function onGroupingChange() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
if (!document.getElementById('groupings')) {
|
||||
alert('No groupings id element');
|
||||
} else {
|
||||
groupingselect = document.getElementById('groupings');
|
||||
selectedgroupingid = groupingselect.value;
|
||||
selectedgroupid = null;
|
||||
updateSelectedGrouping();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onGroupChange() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
selectedgroupid = getSelectedGroup();
|
||||
updateSelectedGroup();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getSelectedGroupingName() {
|
||||
if (!document.getElementById('groupings')) {
|
||||
alert('No groupings id element');
|
||||
value = null;
|
||||
} else {
|
||||
groupingselect = document.getElementById('groupings');
|
||||
value = groupingselect.options[groupingselect.selectedIndex].firstChild.nodeValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function getSelectedGroupName() {
|
||||
if (!document.getElementById('groups')) {
|
||||
alert('No groups id element');
|
||||
value = null;
|
||||
} else {
|
||||
groupselect = document.getElementById('groups');
|
||||
value = groupselect.options[groupselect.selectedIndex].firstChild.nodeValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the selected grouping on the form to the grouping whose id is selectedgroupingid
|
||||
*/
|
||||
function setSelectedGrouping() {
|
||||
if (selectedgroupingid == null) {
|
||||
selectedgroupingid = getFirstOption("groupings");
|
||||
}
|
||||
|
||||
if (selectedgroupingid != null) {
|
||||
if (!document.getElementById('groupings')) {
|
||||
alert('No groupings id element');
|
||||
} else {
|
||||
groupingselect = document.getElementById('groupings');
|
||||
groupingselect.value = selectedgroupingid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the id of the group that is currently selected
|
||||
*/
|
||||
function getSelectedGroup() {
|
||||
if (!document.getElementById('groups')) {
|
||||
alert('No groups id element');
|
||||
value = null;
|
||||
} else {
|
||||
groupselect = document.getElementById('groups');
|
||||
value = groupselect.value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the selected group on the form to the group whose id is selectedgroupid
|
||||
*/
|
||||
function setSelectedGroup() {
|
||||
if (selectedgroupid == null) {
|
||||
selectedgroupid = getFirstOption("groups");
|
||||
}
|
||||
|
||||
if (selectedgroupid != null) {
|
||||
if (!document.getElementById('groups')) {
|
||||
alert('No groups id element');
|
||||
} else {
|
||||
groupselect = document.getElementById('groups');
|
||||
groupselect.value = selectedgroupid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the selected users to delete
|
||||
*/
|
||||
function getSelectedUsers() {
|
||||
return getMultipleSelect("members")
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***************************************************************
|
||||
* Functions that just display information (and don't change the data in the database)
|
||||
**********************************************/
|
||||
|
||||
/**
|
||||
* Updates the list of groupings, setting either a specified grouping as selected or
|
||||
* the first grouping as selected.
|
||||
*/
|
||||
function updateGroupings() {
|
||||
alert("updateGroupings called");
|
||||
var url = "getgroupings-xml.php";
|
||||
requeststring = 'courseid='+courseid+'&'+'sesskey='+sesskey;
|
||||
var transaction = YAHOO.util.Connect.asyncRequest('POST', url,
|
||||
updateGroupingsResponseCallback, requeststring);
|
||||
//sendPostRequest(updategroupingsrequest, url, requeststring, updateGroupingsResponse);
|
||||
}
|
||||
|
||||
var updateGroupingsResponseCallback =
|
||||
{
|
||||
success:function(o) {
|
||||
|
||||
// alert("updateGroupingsResponse called");
|
||||
var xmlDoc = o.responseXML;
|
||||
error = getFromXML(o.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
// alert(o.responseXML);
|
||||
var noofoptions = addOptionsFromXML("groupings", xmlDoc);
|
||||
|
||||
// If the selected grouping is not set, set it to the first grouping in the list
|
||||
if(selectedgroupingid == null) {
|
||||
selectedgroupingid = getFirstOption("groupings");
|
||||
selectedgroupid = null;
|
||||
}
|
||||
|
||||
// If there are no groupings, make sure the rest of the form is set up appropriately
|
||||
// i.e. there should be any groups or members shown and various buttons should be disabled
|
||||
// If there are groupings, update the one that is selected and enable any buttons that
|
||||
// might have been disabled.
|
||||
if (noofoptions == 0) {
|
||||
removeOptions("groups");
|
||||
removeOptions("members");
|
||||
disableButton("showaddmembersform");
|
||||
disableButton("showcreategroupform");
|
||||
disableButton("showaddgroupstogroupingform");
|
||||
} else {
|
||||
updateSelectedGrouping();
|
||||
enableButton("showaddmembersform");
|
||||
enableButton("showcreategroupform");
|
||||
enableButton("showaddgroupstogroupingform");
|
||||
}
|
||||
},
|
||||
failure:responseFailure,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Updates the list of groups when groupingid is marked as selected
|
||||
* groupid can be null or a specified group - this is the group that gets marked as
|
||||
* selectedgroupingid cannot be null.
|
||||
*/
|
||||
function updateSelectedGrouping() {
|
||||
//alert("UpdateSelectedGrouping called");
|
||||
setSelectedGrouping();
|
||||
var url = "getgroupsingrouping-xml.php";
|
||||
requeststring = "groupingid="+selectedgroupingid;
|
||||
sendPostRequest(updateselectedgroupingsrequest, url, requeststring, updateSelectedGroupingResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in updateSelectedGrouping()
|
||||
*/
|
||||
function updateSelectedGroupingResponse() {
|
||||
if (checkAjaxResponse(updateselectedgroupingsrequest)) {
|
||||
//alert("updateSelectedGroupingResponse called");
|
||||
var xmlDoc = updateselectedgroupingsrequest.responseXML;
|
||||
error = getFromXML(updateselectedgroupingsrequest.responseXML, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
// alert(updateselectedgroupingsrequest.responseText);
|
||||
var noofoptions = addOptionsFromXML("groups", xmlDoc);
|
||||
if (selectedgroupid == null) {
|
||||
selectedgroupid = getFirstOption("groups");
|
||||
}
|
||||
|
||||
if (noofoptions == 0) {
|
||||
removeOptions("members");
|
||||
disableButton("showaddmembersform");
|
||||
} else {
|
||||
updateSelectedGroup(selectedgroupid);
|
||||
enableButton("showaddmembersform");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the members for the selected group - currently none marked as selected
|
||||
*/
|
||||
function updateSelectedGroup() {
|
||||
//alert("updateSelectedGroup");
|
||||
setSelectedGroup();
|
||||
var url = "getmembers-xml.php";
|
||||
var requeststring = "groupid="+selectedgroupid;
|
||||
sendPostRequest(updateselectedgrouprequest, url, requeststring, updateSelectedGroupResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in updateSelectedGroup()
|
||||
*/
|
||||
function updateSelectedGroupResponse() {
|
||||
if (checkAjaxResponse(updateselectedgrouprequest)) {
|
||||
var xmlDoc = updateselectedgrouprequest.responseXML;
|
||||
//alert("updateSelectedGroupResponse");
|
||||
error = getFromXML(xmlDoc, 'error');
|
||||
if (error != null) {
|
||||
alert(error);
|
||||
}
|
||||
|
||||
//alert(request.responseText);
|
||||
var noofoptions = addOptionsFromXML("members", xmlDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Print groups in groupings, and members of groups.
|
||||
*
|
||||
* @copyright © 2006 The Open University
|
||||
* @author J.White AT open.ac.uk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package groups
|
||||
*/
|
||||
require_once('../../config.php');
|
||||
require_once('../lib.php');
|
||||
|
||||
$success = true;
|
||||
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
|
||||
// Get the course information so we can print the header and
|
||||
// check the course id is valid
|
||||
$course = groups_get_course_info($courseid);
|
||||
if (! $course) {
|
||||
$success = false;
|
||||
print_error('invalidcourse');
|
||||
}
|
||||
|
||||
|
||||
if ($success) {
|
||||
// Make sure that the user has permissions to manage groups.
|
||||
require_login($courseid);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
if (! has_capability('moodle/course:managegroups', $context)) {
|
||||
redirect();
|
||||
}
|
||||
|
||||
//( confirm_sesskey checks that this is a POST request.)
|
||||
|
||||
// Print the page and form
|
||||
$strgroups = get_string('groups');
|
||||
$strparticipants = get_string('participants');
|
||||
print_header("$course->shortname: $strgroups", $course->fullname,
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
|
||||
"-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
|
||||
"-> <a href=\"$CFG->wwwroot/group/groupui/index.php?id=$courseid\">$strgroups</a>".
|
||||
"-> Display grouping", "", "", true, '', user_login_string($course, $USER));
|
||||
|
||||
$groupingname = groups_get_grouping_name($groupingid);
|
||||
if (! $groupingname) {
|
||||
print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
|
||||
} else {
|
||||
// Print the name of the grouping
|
||||
echo "<h1>$groupingname</h1>\n";
|
||||
}
|
||||
|
||||
// Get the groups and group members for the grouping.
|
||||
if (GROUP_NOT_IN_GROUPING == $groupingid) {
|
||||
$groupids = groups_get_groups_not_in_any_grouping($courseid);
|
||||
} else {
|
||||
$groupids = groups_get_groups_in_grouping($groupingid);
|
||||
}
|
||||
|
||||
if ($groupids) {
|
||||
// Make sure the groups are in the right order
|
||||
$group_names = groups_groupids_to_group_names($groupids);
|
||||
|
||||
// Go through each group in turn and print the group name and then the members
|
||||
foreach ($group_names as $group) {
|
||||
|
||||
echo "<h2>{$group->name}</h2>\n";
|
||||
$userids = groups_get_members($group->id);
|
||||
if ($userids != false) {
|
||||
// Make sure the users are in the right order
|
||||
$user_names = groups_userids_to_user_names($userids, $courseid);
|
||||
|
||||
echo "<ol>\n";
|
||||
foreach ($user_names as $user) {
|
||||
|
||||
echo "<li>{$user->name}</li>\n";
|
||||
}
|
||||
echo "</ol>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Removes a specified group from a specified grouping
|
||||
* (but does not delete the group)
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$groupingid = required_param('groupingid', PARAM_INT);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
$groupingremoved = groups_remove_group_from_grouping($groupid, $groupingid);
|
||||
if (!$groupingremoved) {
|
||||
echo '<error>Failed to remove group from grouping</error>';
|
||||
}
|
||||
}
|
||||
|
||||
echo '</groupsresponse>';
|
||||
?>
|
||||
@@ -1,34 +0,0 @@
|
||||
|
||||
function onRemoveGroup() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
removeGroupFromGrouping();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the selected group from the selected grouping, does not delete the group (so it can e.g. be added to
|
||||
* another grouping
|
||||
*/
|
||||
function removeGroupFromGrouping() {
|
||||
//alert("Called removeGroupFromGrouping");
|
||||
var url = "removegroupfromgrouping-xml.php";
|
||||
var requeststring = "groupid="+selectedgroupid+"&groupingid="+selectedgroupingid;
|
||||
sendPostRequest(request, url, requeststring, removeGroupFromGroupingResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in removeGroupFromGrouping()
|
||||
*/
|
||||
function removeGroupFromGroupingResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("removeGroupFromGroupingResponse called");
|
||||
var xmlDoc= request.responseXML;
|
||||
// Need XML sent back with groupingid
|
||||
// Really want to set this to be the grouping before
|
||||
selectedgroupid = null;
|
||||
updateGroupings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**********************************************
|
||||
* Takes a groupid and comma-separated list of
|
||||
* userids, and removes each of those userids
|
||||
* from the specified group
|
||||
**********************************************/
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('../lib/lib.php');
|
||||
|
||||
@header('Content-Type: text/xml; charset=utf-8');
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>';
|
||||
echo '<groupsresponse>';
|
||||
|
||||
$groupid = required_param('groupid', PARAM_INT);
|
||||
$users = required_param('users', PARAM_SEQUENCE);
|
||||
$courseid = required_param('courseid', PARAM_INT);
|
||||
|
||||
require_login($courseid);
|
||||
|
||||
if (confirm_sesskey() and isteacheredit($courseid)) {
|
||||
// Change the comma-separated string of the userids into an array of the userids
|
||||
$userids = explode(',', $users);
|
||||
if ($userids != false) {
|
||||
// Remove each user in turn from the group.
|
||||
foreach($userids as $userid) {
|
||||
$useradded = groups_remove_member($groupid, $userid);
|
||||
if (!$useradded) {
|
||||
echo "<error>Failed to adduser $userid</error>";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo '</groupsresponse>';
|
||||
|
||||
?>
|
||||
@@ -1,33 +0,0 @@
|
||||
|
||||
|
||||
|
||||
function onRemoveMembers() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
removeMembers();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Removes the selected members from the selected group
|
||||
*/
|
||||
function removeMembers() {
|
||||
//alert("Called removeMembers");
|
||||
users = getSelectedUsers();
|
||||
var url = "removemembers-xml.php";
|
||||
var requeststring = "groupid="+selectedgroupid+"&users="+users;
|
||||
sendPostRequest(request, url, requeststring, removeMembersResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* The callback for the response to the request sent in removeMembers()
|
||||
*/
|
||||
function removeMembersResponse() {
|
||||
if (checkAjaxResponse(request)) {
|
||||
//alert("removeMembersResponse called");
|
||||
//alert(request.responseText);
|
||||
updateSelectedGroup();
|
||||
}
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
/**
|
||||
* This file contains various utility functions, primarily to get and set information on form.html
|
||||
* and to take information from XML documents and either return information from them or modifiy the
|
||||
* form appropriately.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Disable the button with the specified id
|
||||
*/
|
||||
function disableButton(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
} else {
|
||||
var node = document.getElementById(id);
|
||||
node.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the button with the specified id
|
||||
*/
|
||||
function enableButton(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
} else {
|
||||
var node = document.getElementById(id);
|
||||
node.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form with the specified id
|
||||
*/
|
||||
function showElement(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
} else {
|
||||
document.getElementById(id).style.visibility = "visible";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the form with the specified id
|
||||
*/
|
||||
function hideElement(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
} else {
|
||||
var node = document.getElementById(id);
|
||||
node.style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hides all the extra forms in form.html
|
||||
*/
|
||||
function hideAllForms() {
|
||||
hideElement("addmembersform");
|
||||
hideElement("addgroupstogroupingform");
|
||||
hideElement("creategroupingform");
|
||||
hideElement("createautomaticgroupingform");
|
||||
hideElement("creategroupform");
|
||||
hideElement("editgroupingsettingsform");
|
||||
hideElement("editgroupingpermissionsform");
|
||||
hideElement("editgroupsettingsform");
|
||||
hideElement("groupeditform");
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
hideAllForms();
|
||||
showElement("groupeditform");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function addEvent(id, eventtype, fn){
|
||||
if (!document.getElementById(id)) {
|
||||
alert('No ' + id + ' element');
|
||||
return false;
|
||||
} else {
|
||||
obj = document.getElementById(id);
|
||||
}
|
||||
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(eventtype, fn, false );
|
||||
} else if (obj.attachEvent) {
|
||||
obj["e"+ eventtype +fn] = fn;
|
||||
obj[eventtype+fn] = function() { obj["e"+ eventtype +fn]( window.event ); }
|
||||
obj.attachEvent( "on"+ eventtype , obj[eventtype+fn] );
|
||||
} else {
|
||||
obj["on"+type] = obj["e"+ eventtype +fn];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the first option in a select
|
||||
*/
|
||||
function getFirstOption(id) {
|
||||
if (document.getElementById(id)) {
|
||||
var node = document.getElementById(id);
|
||||
if (node.hasChildNodes()) {
|
||||
var children
|
||||
firstoption = node.firstChild;
|
||||
if (firstoption.value) {
|
||||
value = firstoption.value;
|
||||
} else {
|
||||
value = null;
|
||||
}
|
||||
} else {
|
||||
value = null;
|
||||
}
|
||||
} else {
|
||||
value = null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
*Turn the values from a multiple select to a comma-separated list
|
||||
*/
|
||||
function getMultipleSelect(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
} else {
|
||||
node = document.getElementById(id);
|
||||
}
|
||||
var selected = ""
|
||||
|
||||
for (var i = 0; i < node.options.length; i++) {
|
||||
if (node.options[i].selected) {
|
||||
selected = selected + node.options[ i ].value + ",";
|
||||
}
|
||||
}
|
||||
// Remove the last comma - there must be a nicer way of doing this!
|
||||
// Maybe easier with regular expressions?
|
||||
var length = selected.length;
|
||||
if (selected.charAt(length - 1) == ',') {
|
||||
selected = selected.substring(0, length -1);
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates an option in a select element with the specified id with the given name and value.
|
||||
*/
|
||||
function createOption(id, value, name) {
|
||||
var node = document.getElementById(id);
|
||||
var option = document.createElement("option");
|
||||
option.setAttribute("value", value);
|
||||
node.appendChild(option);
|
||||
var namenode = document.createTextNode(name);
|
||||
option.appendChild(namenode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes all the options from a select with a given id
|
||||
*/
|
||||
function removeOptions(id) {
|
||||
var node = document.getElementById(id);
|
||||
|
||||
while (node.hasChildNodes())
|
||||
{
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes an XML doc of the form <option><name></name><value></value><name></name><value></value></option>
|
||||
* And adds an option to the selected with the specified id
|
||||
* @param id The id of the select
|
||||
* @param xmlDoc The XML document
|
||||
* @return The number of options added
|
||||
*/
|
||||
function addOptionsFromXML(id, xmlDoc) {
|
||||
// Clear any options that are already there.
|
||||
removeOptions(id);
|
||||
|
||||
var optionelements = xmlDoc.getElementsByTagName('option');
|
||||
var nameelements = xmlDoc.getElementsByTagName('name');
|
||||
var valueelements = xmlDoc.getElementsByTagName('value');
|
||||
|
||||
if (nameelements != null) {
|
||||
for (var i = 0; i < nameelements.length; i++) {
|
||||
var name = nameelements[i].firstChild.nodeValue;
|
||||
var value = valueelements[i].firstChild.nodeValue;
|
||||
createOption(id, value, name);
|
||||
}
|
||||
noofoptions = nameelements.length;
|
||||
} else {
|
||||
noofoptions = 0;
|
||||
}
|
||||
return noofoptions;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets an error from an XML doc contain a tag of the form <error></error>
|
||||
* If it contains more than one such tag, it only return the value from the first one.
|
||||
*/
|
||||
function getErrorFromXML(xmlDoc) {
|
||||
alert(xmlDoc.getElementsByTagName('error'));
|
||||
if (!xmlDoc.getElementsByTagName('error')) {
|
||||
value = null;
|
||||
} else {
|
||||
var errorelement = xmlDoc.getElementsByTagName('error')[0];
|
||||
var value = errorelement.firstChild.nodeValue;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
function addChildrenFromXML(parentnode, xmlparentnode) {
|
||||
xmlChildNodes = xmlparentnode.childNodes;
|
||||
length = xmlChildNodes.length;
|
||||
for (i = 0; i < length; i++) {
|
||||
child = parentnode.appendChild(parentnode, xmlChildNodes[i]);
|
||||
addChildrenFromXML(child, xmlChildNodes[i])
|
||||
}
|
||||
}
|
||||
|
||||
function getTextInputValue(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
value = null;
|
||||
} else {
|
||||
textinput = document.getElementById(id);
|
||||
value = textinput.value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function setTextInputValue(id, value) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id);
|
||||
value = null;
|
||||
} else {
|
||||
textinput = document.getElementById(id);
|
||||
textinput.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
function getCheckBoxValue(id) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id);
|
||||
value= null;
|
||||
} else {
|
||||
checkbox = document.getElementById(id);
|
||||
value = checkbox.checked;
|
||||
}
|
||||
return boolToInt(value);
|
||||
}
|
||||
|
||||
function boolStringToBool(boolstring) {
|
||||
if (boolstring == 'true') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function boolToInt(boolean) {
|
||||
if (boolean) {
|
||||
return '1';
|
||||
} else if (boolean == false) {
|
||||
return '0';
|
||||
} else {
|
||||
return boolean;
|
||||
}
|
||||
}
|
||||
|
||||
function setCheckBoxValue(id, checked) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id);
|
||||
} else {
|
||||
checkbox = document.getElementById(id);
|
||||
checkbox.checked = checked;
|
||||
}
|
||||
}
|
||||
|
||||
function replaceText(id, text) {
|
||||
if (!document.getElementById(id)) {
|
||||
showNoElementError(id)
|
||||
value = null;
|
||||
} else {
|
||||
element = document.getElementById(id);
|
||||
if (element.childNodes) {
|
||||
for (var i = 0; i < element.childNodes.length; i++) {
|
||||
var childNode = element.childNodes[i];
|
||||
element.removeChild(childNode);
|
||||
}
|
||||
}
|
||||
var textnode = document.createTextNode(text);
|
||||
element.appendChild(textnode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getRadioValue(radioelement) {
|
||||
value = "";
|
||||
if (!radioelement) {
|
||||
value = "";
|
||||
}
|
||||
|
||||
|
||||
for(var i = 0; i < radioelement.length; i++) {
|
||||
if(radioelement[i].checked) {
|
||||
value = radioelement[i].value;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the groupid from an XML doc contain a tag of the form <groupid></groupid>
|
||||
* If it contains more than one such tag, it only return the value from the first one.
|
||||
*/
|
||||
function getFromXML(xmlDoc, id) {
|
||||
if (!xmlDoc.getElementsByTagName(id)) {
|
||||
var value = null;
|
||||
} else if (xmlDoc.getElementsByTagName(id).length == 0) {
|
||||
var value = null;
|
||||
} else {
|
||||
var element = xmlDoc.getElementsByTagName(id)[0];
|
||||
if (!element.firstChild) {
|
||||
var value = '';
|
||||
} else {
|
||||
var value = element.firstChild.nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function showNoElementError(id) {
|
||||
alert('Error: No ' + id +' element');
|
||||
}
|
||||
|
||||
function isPositiveInt(str) {
|
||||
isPosInt = true;
|
||||
|
||||
var i = parseInt (str);
|
||||
|
||||
if (isNaN (i)) {
|
||||
isPosInt = false;
|
||||
}
|
||||
|
||||
if (i < 0) {
|
||||
isPosInt = false;
|
||||
// Check not characters at the end of the number
|
||||
}
|
||||
|
||||
if (i.toString() != str) {
|
||||
isPosInt = false;
|
||||
}
|
||||
return isPosInt ;
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 0.11.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Yahoo global namespace
|
||||
* @constructor
|
||||
*/
|
||||
var YAHOO = window.YAHOO || {};
|
||||
|
||||
/**
|
||||
* Returns the namespace specified and creates it if it doesn't exist
|
||||
*
|
||||
* YAHOO.namespace("property.package");
|
||||
* YAHOO.namespace("YAHOO.property.package");
|
||||
*
|
||||
* Either of the above would create YAHOO.property, then
|
||||
* YAHOO.property.package
|
||||
*
|
||||
* @param {String} ns The name of the namespace
|
||||
* @return {Object} A reference to the namespace object
|
||||
*/
|
||||
YAHOO.namespace = function(ns) {
|
||||
|
||||
if (!ns || !ns.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var levels = ns.split(".");
|
||||
var nsobj = YAHOO;
|
||||
|
||||
// YAHOO is implied, so it is ignored if it is included
|
||||
for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
|
||||
nsobj[levels[i]] = nsobj[levels[i]] || {};
|
||||
nsobj = nsobj[levels[i]];
|
||||
}
|
||||
|
||||
return nsobj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses YAHOO.widget.Logger to output a log message, if the widget is available.
|
||||
*
|
||||
* @param {string} sMsg The message to log.
|
||||
* @param {string} sCategory The log category for the message. Default
|
||||
* categories are "info", "warn", "error", time".
|
||||
* Custom categories can be used as well. (opt)
|
||||
* @param {string} sSource The source of the the message (opt)
|
||||
* @return {boolean} True if the log operation was successful.
|
||||
*/
|
||||
YAHOO.log = function(sMsg, sCategory, sSource) {
|
||||
var l = YAHOO.widget.Logger;
|
||||
if(l && l.log) {
|
||||
return l.log(sMsg, sCategory, sSource);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility to set up the prototype, constructor and superclass properties to
|
||||
* support an inheritance strategy that can chain constructors and methods.
|
||||
*
|
||||
* @param {Function} subclass the object to modify
|
||||
* @param {Function} superclass the object to inherit
|
||||
*/
|
||||
YAHOO.extend = function(subclass, superclass) {
|
||||
var f = function() {};
|
||||
f.prototype = superclass.prototype;
|
||||
subclass.prototype = new f();
|
||||
subclass.prototype.constructor = subclass;
|
||||
subclass.superclass = superclass.prototype;
|
||||
if (superclass.prototype.constructor == Object.prototype.constructor) {
|
||||
superclass.prototype.constructor = superclass;
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.namespace("util");
|
||||
YAHOO.namespace("widget");
|
||||
YAHOO.namespace("example");
|
||||
|
||||
Reference in New Issue
Block a user