mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
This is the first check-in of support for groups.
It's very early (it doesn't actually do anything yet!) but you can define groups and get an idea of how the interface is shaping up. I also wanted to show that I have actually done something on this! :-) From here my plan is to add group support to the modules, one by one (forums first), then go back and clean up some of the central interfaces, graphics etc. Finally, test, test, test and get 1.2 out well before the end of February.
This commit is contained in:
parent
ee39bbe0ee
commit
f374fb1006
22 changed files with 1029 additions and 57 deletions
|
@ -22,14 +22,14 @@
|
|||
if (iscreator()) {
|
||||
if (isset($_GET['edit'])) {
|
||||
if ($edit == "on") {
|
||||
$USER->editing = true;
|
||||
$USER->categoryediting = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->editing = false;
|
||||
$USER->categoryediting = false;
|
||||
}
|
||||
}
|
||||
$navbaritem = update_category_button($category->id);
|
||||
|
||||
$creatorediting = !empty($USER->editing);
|
||||
$creatorediting = !empty($USER->categoryediting);
|
||||
$adminediting = (isadmin() and $creatorediting);
|
||||
|
||||
} else {
|
||||
|
|
110
course/edit.html
110
course/edit.html
|
@ -1,7 +1,7 @@
|
|||
<FORM METHOD="post" action="edit.php" NAME="form">
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("category") ?>:</td>
|
||||
<td align="right"><P><?php print_string("category") ?>:</td>
|
||||
<td><?php
|
||||
$displaylist = array();
|
||||
$parentlist = array();
|
||||
|
@ -12,28 +12,75 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("fullname") ?>:</td>
|
||||
<td align="right"><P><?php print_string("fullname") ?>:</td>
|
||||
<td><input type="text" name="fullname" maxlength="254" size=50 value="<?php p($form->fullname) ?>">
|
||||
<?php helpbutton("coursefullname", get_string("fullname")) ?>
|
||||
<?php if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("shortname") ?>:</td>
|
||||
<td align="right"><P><?php print_string("shortname") ?>:</td>
|
||||
<td><input type="text" name="shortname" maxlength="15" size="10" value="<?php p($form->shortname) ?>">
|
||||
<?php helpbutton("courseshortname", get_string("shortname")) ?>
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("summary") ?>:</td>
|
||||
<td><TEXTAREA NAME=summary COLS=50 ROWS=10 WRAP=virtual><?php p($form->summary) ?></TEXTAREA>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
<?php if (isset($err["summary"])) formerr($err["summary"]); ?>
|
||||
<td align="right"><P><?php print_string("summary") ?>:</td>
|
||||
<td><?php
|
||||
print_textarea($usehtmleditor, 10, 50, 660, 200, "summary", $form->summary);
|
||||
helpbutton("text", get_string("helptext"));
|
||||
if (isset($err["summary"])) formerr($err["summary"]);
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("availability") ?>:</td>
|
||||
<td align="right"><P><?php print_string("format") ?>:</td>
|
||||
<td><?php
|
||||
choose_from_menu ($form->courseformats, "format", "$form->format", "");
|
||||
helpbutton("courseformats", get_string("courseformats"));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("startdate") ?>:</td>
|
||||
<td><?php
|
||||
print_date_selector("startday", "startmonth", "startyear", $form->startdate);
|
||||
helpbutton("coursestartdate", get_string("startdate"));
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("numberweeks") ?>:</td>
|
||||
<td><?php
|
||||
for ($i=1; $i<=52; $i++) {
|
||||
$sectionmenu[$i] = "$i";
|
||||
}
|
||||
choose_from_menu ($sectionmenu, "numsections", "$form->numsections", "");
|
||||
helpbutton("coursenumsections", get_string("numberweeks"));
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("groupmode") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices[NOGROUPS] = get_string("groupsnone");
|
||||
$choices[SEPARATEGROUPS] = get_string("groupsseparate");
|
||||
$choices[VISIBLEGROUPS] = get_string("groupsvisible");
|
||||
choose_from_menu ($choices, "groupmode", $form->groupmode, "");
|
||||
helpbutton("groupmode", get_string("groupmode"));
|
||||
|
||||
echo ' ';
|
||||
print_string('force');
|
||||
echo ': ';
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
$choices["1"] = get_string("yes");
|
||||
choose_from_menu ($choices, "groupmodeforce", $form->groupmodeforce, "");
|
||||
helpbutton("groupmodeforce", get_string("groupmodeforce")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("availability") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("courseavailablenot");
|
||||
|
@ -43,14 +90,14 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("enrolmentkey") ?>:</td>
|
||||
<td align="right"><P><?php print_string("enrolmentkey") ?>:</td>
|
||||
<td><input type="text" name="password" size=25 value="<?php p($form->password) ?>">
|
||||
<?php helpbutton("enrolmentkey", get_string("enrolmentkey")) ?>
|
||||
<?php if (isset($err["password"])) formerr($err["password"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("opentoguests") ?>:</td>
|
||||
<td align="right"><P><?php print_string("opentoguests") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("guestsno");
|
||||
|
@ -61,15 +108,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("format") ?>:</td>
|
||||
<td><?php
|
||||
choose_from_menu ($form->courseformats, "format", "$form->format", "");
|
||||
helpbutton("courseformats", get_string("courseformats"));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("newsitemsnumber") ?>:</td>
|
||||
<td align="right"><P><?php print_string("newsitemsnumber") ?>:</td>
|
||||
<td><?php
|
||||
$newsitem = get_string("newsitem");
|
||||
$newsitems = get_string("newsitems");
|
||||
|
@ -91,24 +130,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("startdate") ?>:</td>
|
||||
<td><?php
|
||||
print_date_selector("startday", "startmonth", "startyear", $form->startdate);
|
||||
helpbutton("coursestartdate", get_string("startdate"));
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("numberweeks") ?>:</td>
|
||||
<td><?php
|
||||
for ($i=1; $i<=52; $i++) {
|
||||
$sectionmenu[$i] = "$i";
|
||||
}
|
||||
choose_from_menu ($sectionmenu, "numsections", "$form->numsections", "");
|
||||
helpbutton("coursenumsections", get_string("numberweeks"));
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("showrecent") ?>:</td>
|
||||
<td align="right"><P><?php print_string("showrecent") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
|
@ -118,7 +140,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("showgrades") ?>:</td>
|
||||
<td align="right"><P><?php print_string("showgrades") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
|
@ -128,7 +150,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("showreports") ?>:</td>
|
||||
<td align="right"><P><?php print_string("showreports") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
|
@ -138,7 +160,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("maximumupload") ?>:</td>
|
||||
<td align="right"><P><?php print_string("maximumupload") ?>:</td>
|
||||
<td><?php
|
||||
$choices = get_max_upload_sizes($CFG->maxbytes);
|
||||
choose_from_menu ($choices, "maxbytes", $form->maxbytes, "");
|
||||
|
@ -146,28 +168,28 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("wordforteacher") ?>:</td>
|
||||
<td align="right"><P><?php print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" maxlength="100" size=25 value="<?php p($form->teacher) ?>">
|
||||
(<?php print_string("wordforteachereg") ?>)
|
||||
<?php if (isset($err["teacher"])) formerr($err["teacher"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("wordforteachers") ?>:</td>
|
||||
<td align="right"><P><?php print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" maxlength="100" size=25 value="<?php p($form->teachers) ?>">
|
||||
(<?php print_string("wordforteacherseg") ?>)
|
||||
<?php if (isset($err["teachers"])) formerr($err["teachers"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("wordforstudent") ?>:</td>
|
||||
<td align="right"><P><?php print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" maxlength="100" size=25 value="<?php p($form->student) ?>">
|
||||
(<?php print_string("wordforstudenteg") ?>)
|
||||
<?php if (isset($err["student"])) formerr($err["student"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td><P><?php print_string("wordforstudents") ?>:</td>
|
||||
<td align="right"><P><?php print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" maxlength="100" size=25 value="<?php p($form->students) ?>">
|
||||
(<?php print_string("wordforstudentseg") ?>)
|
||||
<?php if (isset($err["students"])) formerr($err["students"]); ?>
|
||||
|
|
|
@ -116,6 +116,8 @@
|
|||
$form->newsitems = 5;
|
||||
$form->showrecent = 1;
|
||||
$form->showgrades = 1;
|
||||
$form->groupmode = 0;
|
||||
$form->groupmodeforce = 0;
|
||||
$form->category = $category;
|
||||
$form->id = "";
|
||||
$form->visible = 1;
|
||||
|
@ -147,6 +149,8 @@
|
|||
$form->courseformats["$courseformat"] = get_string("format$courseformat");
|
||||
}
|
||||
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
$streditcoursesettings = get_string("editcoursesettings");
|
||||
$straddnewcourse = get_string("addnewcourse");
|
||||
$stradministration = get_string("administration");
|
||||
|
@ -169,6 +173,10 @@
|
|||
|
||||
print_footer($course);
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
/// Functions /////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
require_once("$CFG->dirroot/mod/resource/lib.php");
|
||||
|
||||
$leftwidth = 210;
|
||||
$strgroups = get_string("groups");
|
||||
$strgroupmy = get_string("groupmy");
|
||||
?>
|
||||
|
||||
<table width="100%" border="0" cellspacing="5" cellpadding="5">
|
||||
|
@ -14,6 +16,16 @@
|
|||
<?php
|
||||
$moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
$modicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
|
||||
|
||||
if ($course->groupmode or !$course->groupmodeforce) {
|
||||
if (isteacheredit($course->id) or $course->groupmode == VISIBLEGROUPS) {
|
||||
$moddata[]="<a title=\"$strgroups\" href=\"groups.php?id=$course->id\">$strgroups</a>";
|
||||
} else if ($currentgroup = get_current_group($course->id)) {
|
||||
$moddata[]="<a title=\"$strgroupmy\" href=\"group.php?id=$course->id\">$strgroupmy</a>";
|
||||
}
|
||||
$modicon[]="<img src=\"$CFG->pixpath/i/group.gif\" height=16 width=16 alt=\"\">";
|
||||
}
|
||||
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = "<a title=\"$fullname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".
|
||||
get_string("editmyprofile")."</A>";
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
$stractivities = get_string("activities");
|
||||
$strshowalltopics = get_string("showalltopics");
|
||||
$strtopic = get_string("topic");
|
||||
$strgroups = get_string("groups");
|
||||
$strgroupmy = get_string("groupmy");
|
||||
if (isediting($course->id)) {
|
||||
$strstudents = moodle_strtolower($course->students);
|
||||
$strtopichide = get_string("topichide", "", $strstudents);
|
||||
|
@ -55,6 +57,16 @@
|
|||
/// Links to people
|
||||
$moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
$modicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
|
||||
|
||||
if ($course->groupmode or !$course->groupmodeforce) {
|
||||
if (isteacheredit($course->id) or $course->groupmode == VISIBLEGROUPS) {
|
||||
$moddata[]="<a title=\"$strgroups\" href=\"groups.php?id=$course->id\">$strgroups</a>";
|
||||
} else if ($currentgroup = get_current_group($course->id)) {
|
||||
$moddata[]="<a title=\"$strgroupmy\" href=\"group.php?id=$course->id\">$strgroupmy</a>";
|
||||
}
|
||||
$modicon[]="<img src=\"$CFG->pixpath/i/group.gif\" height=16 width=16 alt=\"\">";
|
||||
}
|
||||
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = "<a title=\"$fullname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</a>";
|
||||
if ($USER->description) {
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
$stractivities = get_string("activities");
|
||||
$strshowallweeks = get_string("showallweeks");
|
||||
$strweek = get_string("week");
|
||||
$strgroups = get_string("groups");
|
||||
$strgroupmy = get_string("groupmy");
|
||||
if (isediting($course->id)) {
|
||||
$strstudents = moodle_strtolower($course->students);
|
||||
$strweekhide = get_string("weekhide", "", $strstudents);
|
||||
|
@ -43,6 +45,16 @@
|
|||
/// Links to people
|
||||
$moddata[]="<a title=\"".get_string("listofallpeople")."\" href=\"../user/index.php?id=$course->id\">".get_string("participants")."</a>";
|
||||
$modicon[]="<img src=\"$CFG->pixpath/i/users.gif\" height=16 width=16 alt=\"\">";
|
||||
|
||||
if ($course->groupmode or !$course->groupmodeforce) {
|
||||
if (isteacheredit($course->id) or $course->groupmode == VISIBLEGROUPS) {
|
||||
$moddata[]="<a title=\"$strgroups\" href=\"groups.php?id=$course->id\">$strgroups</a>";
|
||||
} else if ($currentgroup = get_current_group($course->id)) {
|
||||
$moddata[]="<a title=\"$strgroupmy\" href=\"group.php?id=$course->id\">$strgroupmy</a>";
|
||||
}
|
||||
$modicon[]="<img src=\"$CFG->pixpath/i/group.gif\" height=16 width=16 alt=\"\">";
|
||||
}
|
||||
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = "<a title=\"$fullname\" href=\"../user/edit.php?id=$USER->id&course=$course->id\">".get_string("editmyprofile")."</a>";
|
||||
if ($USER->description) {
|
||||
|
|
103
course/group.php
Normal file
103
course/group.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php // $Id$
|
||||
|
||||
/// Shows current group, and allows editing of the group
|
||||
/// icon and other settings related to that group
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
require_variable($id); // Course id
|
||||
optional_variable($group); // Optionally look at other groups
|
||||
optional_variable($edit); // Turn editing on and off
|
||||
|
||||
if (! $course = get_record('course', 'id', $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
|
||||
if ($group and (isteacheredit($course->id) or $course->groupmode == VISIBLEGROUPS)) {
|
||||
if (! $group = get_record("group", "id", $group)) {
|
||||
error('Specified group could not be found!', "groups.php?id=$course->id");
|
||||
}
|
||||
} else if (! $group = get_current_group($course->id, 'full')) {
|
||||
error('You are not currently in a group!', "view.php?id=$course->id");
|
||||
}
|
||||
|
||||
if (isteacheredit($course->id) or (isteacher($course->id) and ismember($group->id) ) ) {
|
||||
if (isset($edit)) {
|
||||
if ($edit == "on") {
|
||||
$USER->groupediting = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->groupediting = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$USER->groupediting = false;
|
||||
}
|
||||
|
||||
|
||||
/// Print the headers of the page
|
||||
|
||||
$strgroup = get_string('group');
|
||||
$strgroups = get_string('groups');
|
||||
$loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
|
||||
|
||||
if (isteacheredit($course->id) or $course->groupmode == VISIBLEGROUPS) {
|
||||
print_header("$strgroup : $group->name", "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
|
||||
-> <a href=\"groups.php?id=$course->id\">$strgroups</a> -> $group->name",
|
||||
"", "", true, update_group_button($course->id), $loggedinas);
|
||||
} else {
|
||||
print_header("$strgroup : $group->name", "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
|
||||
-> $strgroup -> $group->name", "", "", true, "", $loggedinas);
|
||||
}
|
||||
|
||||
|
||||
/// Display the current group information
|
||||
|
||||
if ($USER->groupediting) { // Make an editing form for group information
|
||||
print_heading($group->name);
|
||||
echo '<div align="center">';
|
||||
print_group_picture($group->id, $course->id, $group->picture, true, false, false);
|
||||
echo '</div>';
|
||||
print_simple_box($group->description, 'center', '50%');
|
||||
|
||||
} else { // Just display the information
|
||||
print_heading($group->name);
|
||||
echo '<div align="center">';
|
||||
print_group_picture($group->id, $course->id, $group->picture, true, false, false);
|
||||
echo '</div>';
|
||||
print_simple_box($group->description, 'center', '50%');
|
||||
}
|
||||
|
||||
echo '<br />';
|
||||
|
||||
if ($users = get_users_in_group($group->id)) {
|
||||
$table->align = array('left', 'left');
|
||||
$table->width = array('100', '*');
|
||||
foreach ($users as $user) {
|
||||
if (!$lastaccess = get_field("user_students", "timeaccess", "userid", $user->id, "course", $course->id)) {
|
||||
if (!$lastaccess = get_field("user_teachers", "timeaccess", "userid", $user->id, "course", $course->id)) {
|
||||
$datestring = get_string("never");
|
||||
}
|
||||
}
|
||||
if ($lastaccess) {
|
||||
$datestring = userdate($lastaccess)."  (".format_time(time() - $lastaccess).")";
|
||||
}
|
||||
$information = '<p><b>'.fullname($user).'</b></p>'.get_string("lastaccess").": $datestring";
|
||||
$table->data[] = array(print_user_picture($user->id, $course->id, $user->picture, true, true), $information);
|
||||
}
|
||||
print_table($table);
|
||||
} else {
|
||||
print_heading(get_string('nousersyet'));
|
||||
}
|
||||
|
||||
|
||||
/// Finish off the page
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
170
course/groups-edit.html
Executable file
170
course/groups-edit.html
Executable file
|
@ -0,0 +1,170 @@
|
|||
<script language="JavaScript">
|
||||
<!-- Begin
|
||||
<?php
|
||||
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 .= "\"$username\"";
|
||||
if ($count < $max) {
|
||||
$useridstring .= ', ';
|
||||
$usernamestring .= ', ';
|
||||
}
|
||||
}
|
||||
$useridstring .= ");\n";
|
||||
$usernamestring .= ");\n";
|
||||
|
||||
echo $useridstring;
|
||||
echo $usernamestring;
|
||||
}
|
||||
?>
|
||||
|
||||
function updateGroup() {
|
||||
document.form1.groupid.value = document.form2.groups.value;
|
||||
document.form3.groupid.value = document.form2.groups.value;
|
||||
}
|
||||
|
||||
|
||||
function updateMembers(selectgroup) {
|
||||
eval('group=group'+selectgroup.value);
|
||||
|
||||
username = group.username;
|
||||
userid = group.userid;
|
||||
|
||||
document.form3['members[]'].length = username.length;
|
||||
|
||||
for (i=0;i<username.length;i++) {
|
||||
document.form3['members[]'].options[i].value = userid[i];
|
||||
document.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,'','');
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// end hiding script -->
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<table border="0" cellspacing="2" cellpadding="10" align="center" class="generalbox">
|
||||
<tr>
|
||||
<td width="33%" align="center" class="generaltableheader"><?php p($strgroupnonmembers) ?></td>
|
||||
<td width="33%" align="center" class="generaltableheader"><?php p($strgroups) ?></td>
|
||||
<td width="33%" align="center" class="generaltableheader"><?php p($strgroupmembersselected) ?></td>
|
||||
</tr>
|
||||
<tr align="center" valign="top">
|
||||
<td class="generalboxcontent"><p>
|
||||
<form name="form1" 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) ?>" />
|
||||
<select name="nonmembers[]" size="15" multiple="multiple">
|
||||
<?php
|
||||
if (!empty($nonmembers)) {
|
||||
foreach ($nonmembers as $id => $nonmembername) {
|
||||
echo "<option value=\"$id\">$nonmembername</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="nonmembersadd" value="<?php p($strgroupaddusers) ?> ->"
|
||||
onclick="updateGroup()" />
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="nonmembersrandom" value="<?php p($strgrouprandomassign) ?> ->" />
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="nonmembersinfo" value="<?php p($strgroupinfopeople) ?>"
|
||||
onclick="return userWindow(document.form1['nonmembers[]']);" />
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
<td class="generalboxcontent"><p>
|
||||
<form name="form2" id="form2" method="post" action="groups.php">
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<select name="groups" size="15" 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>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="groupsinfo" value="<?php p($strgroupinfo) ?>"
|
||||
onclick="return groupWindow(document.form2.groups);"/>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="groupsremove" value="<?php p($strgroupremove) ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<input name="newgroupname" type="text" size="10" />
|
||||
<input type="submit" name="groupsadd" value="<?php p($strgroupadd) ?>" />
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="generalboxcontent"><p>
|
||||
<form name="form3" 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) ?>" />
|
||||
<select name="members[]" size="15" multiple="multiple">
|
||||
<?php
|
||||
if (!empty($members)) {
|
||||
foreach ($members as $id => $membername) {
|
||||
echo "<option value=\"$id\">$membername</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="membersinfo" value="<?php p($strgroupinfomembers) ?>"
|
||||
onclick="return userWindow(document.form3['members[]']);" />
|
||||
</p>
|
||||
<p>
|
||||
<input type="submit" name="membersremove" value="<?php p($strgroupremovemembers) ?>"
|
||||
onclick="updateGroup()" />
|
||||
</p>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
19
course/groups-summary.html
Normal file
19
course/groups-summary.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<table align="center" class="generalbox">
|
||||
<tr>
|
||||
<td valign="top"><?php echo $t->picture ?></td>
|
||||
<td><p style="font-size: larger"><?php echo $t->name ?></p>
|
||||
<p><?php echo $t->description ?></p>
|
||||
<p><ul><?php
|
||||
if ($t->users) {
|
||||
foreach ($t->users as $user) {
|
||||
echo '<li style="font-size: x-small">';
|
||||
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$t->courseid\">$user->fullname</a>";
|
||||
echo '</li>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</ul></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
211
course/groups.php
Normal file
211
course/groups.php
Normal file
|
@ -0,0 +1,211 @@
|
|||
<?php // $Id$
|
||||
|
||||
/// Shows all the groups in a course.
|
||||
/// Editing teachers see a nifty interface for defining groups
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
require_variable($id); // Course id
|
||||
optional_variable($edit); // Turn editing on and off
|
||||
|
||||
if (! $course = get_record('course', 'id', $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
require_login($course->id);
|
||||
|
||||
if (!isteacheredit($course->id) and $course->groupmode != VISIBLEGROUPS) {
|
||||
redirect("group.php?id=$course->id"); // Not allowed to see all groups
|
||||
}
|
||||
|
||||
if (isteacheredit($course->id)) {
|
||||
if (isset($edit)) {
|
||||
if ($edit == "on") {
|
||||
$USER->groupsediting = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->groupsediting = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$USER->groupsediting = false;
|
||||
}
|
||||
|
||||
|
||||
/// Print the header of the page
|
||||
|
||||
$strgroup = get_string('group');
|
||||
$strgroups = get_string('groups');
|
||||
$loggedinas = "<p class=\"logininfo\">".user_login_string($course, $USER)."</p>";
|
||||
|
||||
print_header("$course->shortname: $strgroups", "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
|
||||
-> $strgroups", "", "", true, update_groups_button($course->id), $loggedinas);
|
||||
|
||||
|
||||
/// Get the current list of groups
|
||||
|
||||
$groups = get_groups($course->id);
|
||||
|
||||
if (!$USER->groupsediting) { /// Display an overview of all groups
|
||||
if (!$groups) {
|
||||
print_heading(get_string('groupsnone'));
|
||||
|
||||
} else {
|
||||
$isteacher = isteacher($course->id);
|
||||
foreach ($groups as $group) {
|
||||
$t = $group;
|
||||
$t->picture = print_group_picture($group->id, $course->id, $group->picture, true, true, true);
|
||||
if ($t->users = get_users_in_group($group->id)) {
|
||||
foreach ($t->users as $key => $user) {
|
||||
$t->users[$key]->fullname = fullname($user, $isteacher);
|
||||
}
|
||||
}
|
||||
include('groups-summary.html');
|
||||
}
|
||||
}
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/// We are in editing mode. First, process any inputs there may be.
|
||||
|
||||
if ($data = data_submitted()) {
|
||||
|
||||
if (!empty($data->nonmembersadd)) { /// Add people to a group
|
||||
if (!empty($data->nonmembers) and !empty($data->groupid)) {
|
||||
foreach ($data->nonmembers as $userid) {
|
||||
if (!user_group($courseid, $userid)) { // Just to make sure (another teacher could be editing)
|
||||
$record->groupid = $data->groupid;
|
||||
$record->userid = $userid;
|
||||
if (!insert_record('group_members', $record)) {
|
||||
notify("Error occurred while adding user $userid to group $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)) {
|
||||
delete_records("group", "id", $data->groups);
|
||||
delete_records("group_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();
|
||||
if (!insert_record("group", $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('group_members', 'userid', $userid, "groupid", $data->groupid);
|
||||
}
|
||||
}
|
||||
$selectedgroup = $data->groupid;
|
||||
|
||||
} else if (!empty($data->membersinfo)) { /// Return info about the selected users
|
||||
notify("You must turn Javascript on");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$SESSION->fullnamedisplay = 'firstname lastname';
|
||||
|
||||
|
||||
/// Calculate data ready to create the editing interface
|
||||
|
||||
$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');
|
||||
$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 ($students = get_course_students($course->id)) {
|
||||
foreach ($students as $student) {
|
||||
$nonmembers[$student->id] = fullname($student, true);
|
||||
}
|
||||
unset($students);
|
||||
}
|
||||
|
||||
if ($teachers = get_course_teachers($course->id)) {
|
||||
foreach ($teachers as $teacher) {
|
||||
$prefix = '- ';
|
||||
if (isteacheredit($course->id, $user->id)) {
|
||||
$prefix = '# ';
|
||||
}
|
||||
$nonmembers[$teacher->id] = $prefix.fullname($teacher, true);
|
||||
}
|
||||
unset($teachers);
|
||||
}
|
||||
|
||||
/// Pull out all the members into little arrays
|
||||
|
||||
if ($groups) {
|
||||
foreach ($groups as $group) {
|
||||
$countusers = 0;
|
||||
$listmembers[$group->id] = array();
|
||||
if ($groupusers = get_users_in_group($group->id)) {
|
||||
foreach ($groupusers as $groupuser) {
|
||||
$listmembers[$group->id][$groupuser->id] = $nonmembers[$groupuser->id];
|
||||
unset($nonmembers[$groupuser->id]);
|
||||
$countusers++;
|
||||
}
|
||||
asort($listmembers[$group->id]);
|
||||
}
|
||||
$listgroups[$group->id] = $group->name." ($countusers)";
|
||||
}
|
||||
asort($listgroups);
|
||||
}
|
||||
|
||||
asort($nonmembers);
|
||||
|
||||
if (empty($selectedgroup)) { // Choose the first group by default
|
||||
if ($selectedgroup = array_shift(array_keys($listgroups))) {
|
||||
$members = $listmembers[$selectedgroup];
|
||||
}
|
||||
} else {
|
||||
$members = $listmembers[$selectedgroup];
|
||||
}
|
||||
|
||||
/// Print out the complete form
|
||||
|
||||
include('groups-edit.html');
|
||||
|
||||
print_footer($course);
|
||||
|
||||
?>
|
|
@ -13,14 +13,14 @@
|
|||
if (isadmin()) {
|
||||
if (isset($_GET['edit'])) {
|
||||
if ($edit == "on") {
|
||||
$USER->editing = true;
|
||||
$USER->categoriesediting = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->editing = false;
|
||||
$USER->categoriesediting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$adminediting = (isadmin() and !empty($USER->editing));
|
||||
$adminediting = (isadmin() and !empty($USER->categoriesediting));
|
||||
|
||||
|
||||
/// Unless it's an editing admin, just print the regular listing of courses/categories
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue