diff --git a/blocks/participants/block_participants.php b/blocks/participants/block_participants.php
index 02d55a6..60e9d20 100644
--- a/blocks/participants/block_participants.php
+++ b/blocks/participants/block_participants.php
@@ -19,18 +19,18 @@ class block_participants extends block_list {
         if (empty($this->instance->pageid)) {
             return '';
         }
-        
+
         $this->content = new object();
         $this->content->items = array();
         $this->content->icons = array();
         $this->content->footer = '';
-        
+
         /// MDL-13252 Always get the course context or else the context may be incorrect in the user/index.php
         if (!$currentcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id)) {
             $this->content = '';
             return $this->content;
         }
-        
+
         if ($COURSE->id == SITEID) {
             if (!has_capability('moodle/site:viewparticipants', get_context_instance(CONTEXT_SYSTEM))) {
                 $this->content = '';
@@ -47,6 +47,16 @@ class block_participants extends block_list {
                                   $CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.get_string('participants').'</a>';
         $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" class="icon" alt="" />';
 
+        $this->course = get_record('course', 'id', $this->instance->pageid);
+
+        if ($this->course->groupmode!=NOGROUPS) {
+            $this->content->items[] = '<a title="'.get_string('groups').'" href="'.
+                $CFG->wwwroot.'/user/groups.php?courseid='.$this->instance->pageid.'">'.
+                get_string('groups').'</a>';
+            $this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/group.gif" height="16" width="16" alt="" />';
+        }
+
+
         return $this->content;
     }
 
diff --git a/course/modedit.php b/course/modedit.php
index 2170034..c634df0 100644
--- a/course/modedit.php
+++ b/course/modedit.php
@@ -54,7 +54,7 @@
         if($add=='resource' || $add=='glossary' || $add=='label') {
             $form->groupingid=0;
         }
-        
+
         if (!empty($type)) {
             $form->type = $type;
         }
@@ -264,6 +264,42 @@
                 set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
             }
 
+            // Copy Groups and Members
+            if($fromform->assignmenttype == "uploadsinglegroup") {
+                $already_copied=array(); // needed if a group is in more than one groupings to prevent from copying it twice.
+                $groups = get_groups($course->id);
+                $groupids=array_keys($groups);
+                foreach($groupids as $id) {
+
+                    if(!in_array($id,$already_copied)) {
+
+                        if(isset($fromform->{'groupid_'.$id}) &&
+                           $fromform->{'groupid_'.$id} == 1) { // Gruppe wurde ausgew�hlt -> Kopiere Sie
+
+                            $fields_groups=get_records_sql("SELECT * FROM ".$CFG->prefix."groups WHERE id=".$id);
+
+                            // Copy group
+                            foreach($fields_groups as $field) {
+
+                                $field->assignmentid = $fromform->instance;
+                                $new_groupid = insert_record("groups_assignment",$field,true,"id",true);
+
+                                $sql = "SELECT * FROM ".$CFG->prefix."groups_members WHERE groupid=".$id;
+                                $fields_groups_members = get_records_sql($sql);
+
+                                // Copy group members
+                                foreach($fields_groups_members as $gm_field) {
+                                    $gm_field->assignmentid = $fromform->instance;
+                                    $gm_field->groupid = $new_groupid;
+                                    insert_record("groups_members_assignment",$gm_field);
+                                }
+                                array_push($already_copied,$id);
+                            }
+                        }
+                    }
+                }
+            }
+
             add_to_log($course->id, "course", "update mod",
                        "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
                        "$fromform->modulename $fromform->instance");
@@ -273,6 +309,35 @@
 
         } else if (!empty($fromform->add)){
 
+            // New activity is beeing added, now save group constellation for "uploadsinglegroup"
+            if($fromform->assignmenttype == "uploadsinglegroup") {
+                $groups = get_groups($course->id);
+                $groupids=array_keys($groups);
+                $useringroups=array();
+                $dublicate_useringroups=array();
+                $no_groups_selected=true;
+                foreach($groupids as $id) {
+                    if($fromform->{'groupid_'.$id} == 1) { // Gruppe wurde ausgewählt -> Kopiere Sie
+                        $no_groups_selected=false;
+                        $fields_groups_members=get_records_sql("SELECT * FROM ".$CFG->prefix."groups_members WHERE groupid=".$id);
+                        // First check if there are members who are in more than one group
+                        foreach($fields_groups_members as $member) {
+                            if($member->userid == $USER->id) {
+                                $self_error=true;
+                            }
+                            if(in_array($member->userid,$useringroups)) {
+                                $dublicate_error=true;
+                                $userobjekt=get_record("user","id",$member->userid);
+                                array_push($dublicate_useringroups,$userobjekt->firstname.' '.$userobjekt->lastname);
+                            } else {
+                                array_push($useringroups,$member->userid);
+                            }
+                        }
+                    }
+                }
+            }
+
+
             if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
                 $fromform->groupmode = 0; // do not set groupmode
             }
@@ -291,6 +356,34 @@
 
             $fromform->instance = $returnfromfunc;
 
+            // Copy Groups and Members
+            if($fromform->assignmenttype == "uploadsinglegroup") {
+                $already_copied=array(); // needed if a group is in more than one groupings to prevent from copying it twice.
+                foreach($groupids as $id) {
+
+                    if(!in_array($id,$already_copied)) {
+                        if($fromform->{'groupid_'.$id} == 1) { // Gruppe wurde ausgew�hlt -> Kopiere Sie
+                            $fields_groups_members=get_records_sql("SELECT * FROM ".$CFG->prefix."groups_members WHERE groupid=".$id);
+                            $fields_groups=get_records_sql("SELECT * FROM ".$CFG->prefix."groups WHERE id=".$id);
+                            // Copy group
+                            foreach($fields_groups as $field) {
+                                $field->assignmentid=$fromform->instance;
+                                if (!insert_record("groups_assignment",$field,true,"id",true)) {
+                                    echo mysql_error();
+                                }
+                            }
+                            // Copy group members
+                            foreach($fields_groups_members as $field) {
+                                $field->assignmentid=$fromform->instance;
+                                insert_record("groups_members_assignment",$field);
+                            }
+                            array_push($already_copied,$id);
+                        }
+                    }
+
+                }
+            }
+
             // course_modules and course_sections each contain a reference
             // to each other, so we have to update one of them twice.
 
@@ -313,6 +406,17 @@
                 set_coursemodule_idnumber($fromform->coursemodule, $fromform->cmidnumber);
             }
 
+            if($no_groups_selected == true) {
+                error("No Groups selected",$CFG->wwwroot.'/course/view.php?id='.$course->id);
+            }
+            if(isset($self_error)) {
+                error("You must not be member of one of the selected groups",$CFG->wwwroot.'/group/index.php?id='.$course->id);
+            }
+            if(isset($dublicate_error)) {
+                error(get_string("duplicate_members","assignment",implode(", ",$dublicate_useringroups)),$CFG->wwwroot.'/group/index.php?id='.$course->id);
+            }
+
+
             add_to_log($course->id, "course", "add mod",
                        "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
                        "$fromform->modulename $fromform->instance");
@@ -414,7 +518,7 @@
         rebuild_course_cache($course->id);
         grade_regrade_final_grades($course->id);
 
-        if (isset($fromform->submitbutton)) { 
+        if (isset($fromform->submitbutton)) {
             redirect("$CFG->wwwroot/mod/$module->name/view.php?id=$fromform->coursemodule");
         } else {
             redirect("$CFG->wwwroot/course/view.php?id=$course->id");
diff --git a/group/enrol_form.php b/group/enrol_form.php
new file mode 100644
index 0000000..5d6d33c
--- /dev/null
+++ b/group/enrol_form.php
@@ -0,0 +1,37 @@
+<?php // $Id: enrol_form.php,v 1.16.2.3 2008/01/14 17:55:43 ethem Exp $
+
+require_once($CFG->libdir.'/formslib.php');
+
+class enrol_authorize_form extends moodleform
+{
+    function definition()
+    {
+        global $CFG, $USER;
+        global $frm_data;
+
+        $mform =& $this->_form;
+        $course = $this->_customdata['course'];
+
+        $mform->addElement('hidden', 'move', $frm_data->move);
+        $mform->setType('id', PARAM_INT);
+        $mform->addElement('hidden', 'courseid', $frm_data->courseid);
+        $mform->setType('id', PARAM_INT);
+
+        $mform->addElement('passwordunmask', 'enrolmentkey', get_string('input_enrolmentkey', 'group'), 'size="20"');
+        $mform->setType('enrolmentkey', PARAM_ALPHANUM);
+        $mform->setDefault('enrolmentkey', '');
+
+        $this->add_action_buttons(false, get_string('send_enrolmentkey', 'group'));
+    }
+
+    function validation($data, $files)
+    {
+        global $CFG;
+        $errors = parent::validation($data, $files);
+
+
+        return $errors;
+    }
+
+}
+?>
diff --git a/group/group_form.php b/group/group_form.php
index 4d7b6c4..6ce1009 100644
--- a/group/group_form.php
+++ b/group/group_form.php
@@ -22,6 +22,12 @@ class group_form extends moodleform {
         $mform->setHelpButton('enrolmentkey', array('groupenrolmentkey', get_string('enrolmentkey', 'group')), true);
         $mform->setType('enrolmentkey', PARAM_RAW);
 
+        $mform->addElement('text','maxuser', get_string('groupmaxuser', 'group'),'maxlength="3" size="10"');
+        $mform->addRule('maxuser', get_string('required'), 'required', null, 'client');
+        $mform->setType('maxuser', PARAM_NUMBER);
+
+        $mform->addElement('date_time_selector', 'timeclose', get_string('groupenrolclose', 'group'), array('optional'=>true));
+
         $maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
 
         if (!empty($CFG->gdversion) and $maxbytes) {
diff --git a/lang/en_utf8/assignment.php b/lang/en_utf8/assignment.php
index 39a0889..78932e7 100644
--- a/lang/en_utf8/assignment.php
+++ b/lang/en_utf8/assignment.php
@@ -139,4 +139,15 @@ $string['viewfeedback'] = 'View assignment grades and feedback';
 $string['viewsubmissions'] = 'View $a submitted assignments';
 $string['yoursubmission'] = 'Your submission';
 
+//Group assignments
+$string['typeuploadsinglegroup'] = 'Group assignment - Upload a file';
+$string['wholeclass'] = 'Whole course';
+$string['helpuploadsinglegroup'] = '<p>This type of assignment allows each participant to upload a single file, of any type.</p> <p>This might be a Word processor document, or an image, a zipped web site, or anything you ask them to submit.</p> <p>The submission of this user is also submitted for all the members of the group this user belongs to. If no groups are defined for the course, the whole class is considered as one group.</p>';
+$string['gradingstyle'] = 'Art der Bewertung';
+$string['emailteachermailgroup'] = 'The $a->groupname $a->groupmembers have updated their assignment submission for \'$a->assignment\' It is available here: $a->url';
+$string['emailteachermailhtmlgroup'] = 'The $a->groupname $a->groupmembers has updated their assignment submission for <i>\'$a->assignment\'</i><br /><br /> It is <a href=\"$a->url\">available on the web site</a>.';
+$string['gruopconstallation'] = 'The following group constellation will be applied to this Groupassignment<br /><br />';
+$string['manage_groups'] = 'Manage groups';
+$string['duplicate_members'] = 'The following users a in more than one selected groups: $a <br /> This is not allowed.';
+$string['select_groups']='Select which groups should be implied in the assignment';
 ?>
diff --git a/lang/en_utf8/group.php b/lang/en_utf8/group.php
index c1b6658..a37a4f7 100644
--- a/lang/en_utf8/group.php
+++ b/lang/en_utf8/group.php
@@ -140,4 +140,21 @@ $string['groupsgroupings'] = 'Groups &amp; groupings';
 $string['groupingsonly'] = 'Groupings only';
 $string['groupsonly'] = 'Groups only';
 
-?>
\ No newline at end of file
+// Group assignments
+$string['groupmaxuser'] = 'Maximum Group members allowed';
+$string['groupcountsingle'] = 'member is already in this group. Showing names is disabled by Teacher';
+$string['groupcountplural'] = 'members are already in this group. Showing names is disabled by Teacher';
+$string['groupisfull'] = 'This Group is full';
+$string['movemetothisgroup'] = 'Enrol me in this Group';
+$string['groupmy2'] = 'You are enroled in this Group <a href="$a">Leave</a>';
+$string['groupenrolclose'] = 'Deadline for students to select their group';
+$string['maxgroupmembers'] = 'Maximum members allowed:';
+$string['timeclose'] = 'You can join or leave this group until:';
+$string['timelocked'] = 'This Group is locked';
+$string['input_enrolmentkey'] = 'Enrolment Key required:';
+$string['send_enrolmentkey'] = 'Enrol me';
+$string['wrong_key'] = 'Invalid enrolment key';
+
+
+
+?>
diff --git a/mod/assignment/db/upgrade.php b/mod/assignment/db/upgrade.php
index c417885..94c3ffe 100644
--- a/mod/assignment/db/upgrade.php
+++ b/mod/assignment/db/upgrade.php
@@ -59,6 +59,130 @@ function xmldb_assignment_upgrade($oldversion=0) {
         $db->debug = true;
     }
 
+    if ($result && $oldversion < 2010030501) {
+
+        // create the groups_members_assignment table
+        $table = new XMLDBTable('groups_members_assignment');
+
+        $field = new XMLDBField('id');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
+        $table->addField($field);
+
+        $field = new XMLDBField('groupid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('userid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('assignmentid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('timeadded');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $key = new XMLDBKey('primary');
+        $key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKey($key);
+
+        $index = new XMLDBIndex('groumemb_gro');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('groupid'));
+        $table->addIndex($index);
+
+        $index = new XMLDBIndex('groumemb_use');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
+        $table->addIndex($index);
+
+        $index = new XMLDBIndex('groumemb_ass');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('assignmentid'));
+        $table->addIndex($index);
+
+        $result = $result && create_table($table);
+
+        // Create table groups_Assignment
+        $table = new XMLDBTable('groups_assignment');
+
+        $field = new XMLDBField('id');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
+        $table->addField($field);
+
+        $field = new XMLDBField('courseid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('assignmentid');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('name');
+        $field->setAttributes(XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('description');
+        $field->setAttributes(XMLDB_TYPE_TEXT);
+        $table->addField($field);
+
+        $field = new XMLDBField('enrolmentkey');
+        $field->setAttributes(XMLDB_TYPE_CHAR, 50, null, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('picture');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('hidepicture');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('maxuser');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('timecreated');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('timemodified');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $field = new XMLDBField('timeclose');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL);
+        $table->addField($field);
+
+        $key = new XMLDBKey('primary');
+        $key->setAttributes(XMLDB_KEY_PRIMARY, array('id'));
+        $table->addKey($key);
+
+        $index = new XMLDBIndex('grouassig_cou');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('courseid'));
+        $table->addIndex($index);
+
+        $index = new XMLDBIndex('grouassig_ass');
+        $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('assignmentid'));
+        $table->addIndex($index);
+
+        $result = $result && create_table($table);
+
+        // Alter the groups table to hold max number of users and time to close self assignments
+        $table = new XMLDBTable('groups');
+
+        $field = new XMLDBField('maxuser');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
+        $table->addField($field);
+
+        $result = $result && add_field($table, $field);
+
+        $field = new XMLDBField('timeclose');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
+        $table->addField($field);
+
+        $result = $result && add_field($table, $field);
+    }
+
     return $result;
 }
 
diff --git a/mod/assignment/groups-summary.html b/mod/assignment/groups-summary.html
new file mode 100644
index 0000000..09c5d42
--- /dev/null
+++ b/mod/assignment/groups-summary.html
@@ -0,0 +1,28 @@
+<table width=100%>
+    <tr>
+        <td colspan=2><b><?php echo get_string('group','group').' '.$t->name ?></b></td>
+    </tr>
+    <tr>
+        <td vAlign="top" colspan=2>
+        <b><?php print_string('members','group') ?>:</b>
+        <?php
+        if($t->users) {
+            $countusers = count($t->users);
+            if($this->course->groupmode == SEPARATEGROUPS) {
+                if($countusers == 1) { $str_users=get_string("groupcountsingle","group"); } else { $str_users=get_string("groupcountplural","group"); }
+                echo $countusers." ".$str_users;
+            } else {
+                foreach ($t->users as $user) {
+                    echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$t->courseid\">$user->fullname</a>";
+                    $countusers--;
+                    if ($countusers) {
+                        echo ', ';
+                    }
+                }
+            }
+        }
+        ?>
+        </td>
+    </tr>
+</table>
+<br />
diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php
index 376a024..7929df3 100644
--- a/mod/assignment/mod_form.php
+++ b/mod/assignment/mod_form.php
@@ -4,9 +4,14 @@ require_once ($CFG->dirroot.'/course/moodleform_mod.php');
 class mod_assignment_mod_form extends moodleform_mod {
 
     function definition() {
-        global $CFG;
+        global $CFG, $USER;
         $mform =& $this->_form;
 
+        $course = optional_param('course', 0);
+        if (!$course) {
+            $course = $this->_cm->course;
+        }
+
         // this hack is needed for different settings of each subtype
         if (!empty($this->_instance)) {
             if($ass = get_record('assignment', 'id', (int)$this->_instance)) {
@@ -26,6 +31,45 @@ class mod_assignment_mod_form extends moodleform_mod {
         $assignmentclass = 'assignment_'.$type;
         $assignmentinstance = new $assignmentclass();
 
+        if(!isset($mform->update) AND $type == "uploadsinglegroup") {
+            $mform->addElement('header', 'groups', get_string('select_groups','assignment'));
+
+            $mform->groupdata = get_groups($course);
+
+            $strgroupmemberssee = get_string('groupmemberssee');
+
+            if(is_array($mform->groupdata)) {
+                foreach ($mform->groupdata as $group) {
+                    $usergroup = false;
+                    $t = $group;
+                    $names = array();
+                    $t->description = format_text($group->description);
+                    $nameslist = '';
+                    $ynoptions = '';
+                    if ($t->users = get_group_users($group->id, 'u.lastname ASC')) {
+                        foreach ($t->users as $key => $user) {
+                            $names[] = fullname($user);
+                            if ($user->id == $USER->id) {
+                                $names[] = '<b>'.fullname($user).'</b>';
+                                $usergroup = true;
+                            }
+
+                        }
+                        $nameslist=implode(", ", $names);
+                    }
+                    $mform->addElement('checkbox', 'groupid_'.$group->id, '<b>'.get_string("group","group").' '.$group->name.':</b> '.$nameslist, $ynoptions);
+                    $mform->setDefault('preventlate', 0);
+
+                    $t->linkfullprofile->url = "group.php?id=$course&group=$group->id";
+                    $t->linkfullprofile->text = $strgroupmemberssee;
+
+                    #include($CFG->dirroot.'/mod/assignment/groups-summary.html');
+                }
+            } else {
+                error("No Groups defined",$CFG->wwwroot.'/group/index.php?id='.$course);
+            }
+        }
+
 //-------------------------------------------------------------------------------
         $mform->addElement('header', 'general', get_string('general', 'form'));
 
@@ -64,7 +108,7 @@ class mod_assignment_mod_form extends moodleform_mod {
         // hack to support pluggable assignment type titles
         if ($typetitle === '[[type'.$type.']]') {
             $typetitle  = get_string('type'.$type, 'assignment_'.$type);
-        } 
+        }
 
         $mform->addElement('header', 'typedesc', $typetitle);
 
@@ -82,4 +126,4 @@ class mod_assignment_mod_form extends moodleform_mod {
 
 
 }
-?>
\ No newline at end of file
+?>
diff --git a/mod/assignment/type/uploadsinglegroup/assignment.class.php b/mod/assignment/type/uploadsinglegroup/assignment.class.php
new file mode 100644
index 0000000..a0fee57
--- /dev/null
+++ b/mod/assignment/type/uploadsinglegroup/assignment.class.php
@@ -0,0 +1,943 @@
+<?php // $Id: assignment.class.php,v 1.8.2.5 2005/07/12 19:14:23 skodak Exp $
+
+/**
+ * Extend the base assignment class for assignments where you upload a single file
+ * and where the assignment submissions are based on groups:
+ * a)  If there are groups set up in the course, use them as a basis
+ * b)  If there are no groups set up in the course, the whole class is considered as a group
+ * The grading can be done either by individuals, or by groups
+ *
+ */
+
+class assignment_uploadsinglegroup extends assignment_base {
+
+    function assignment_uploadsinglegroup($cmid=0) {
+        parent::assignment_base($cmid);
+    }
+
+    /**
+     * Returns a link with info about the state of the assignment submissions
+     *
+     * This is used by view_header to put this link at the top right of the page.
+     * For teachers it gives the number of submitted assignments with a link
+     * For students it gives the time of their submission.
+     * This will be suitable for most assignment types.
+     * @param bool $allgroup print all groups info if user can access all groups, suitable for index.php
+     * @return string
+     */
+    function submittedlink($allgroups=false) {
+        global $USER;
+
+        $submitted = '';
+        $i=0;
+        if ($groups = groups_get_all_groups_assignment($this->course->id,$this->assignment->id)) {
+            foreach($groups as $group) {
+                $members=get_group_users_assignment($group->id,$this->assignment->id);
+                foreach($members as $member) {
+                    if($this->count_user_files($member->id) > 0) {
+                        $i++;    // Submission found
+                        break;
+                    }
+                }
+            }
+        }
+        if($i == 0) {
+            $submitted='<a href="submissions.php?id='.$this->cm->id.'">'.get_string('noattempts', 'assignment').'</a>';
+        } else {
+            $submitted='<a href="submissions.php?id='.$this->cm->id.'">'.get_string('viewsubmissions', 'assignment', $i).'</a>';
+        }
+        return $submitted;
+    }
+
+    function view() {
+
+        global $USER,$CFG;
+
+        $context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
+        require_capability('mod/assignment:view', $context);
+
+        add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
+
+        $navigation = build_navigation('', $this->cm);
+
+        print_header($this->pagetitle, $this->course->fullname, $navigation, '', '',
+                true, update_module_button($this->cm->id, $this->course->id, $this->strassignment),
+                navmenu($this->course, $this->cm));
+
+        echo '<div class="reportlink">'.$this->submittedlink().'</div>';
+        echo '<div class="clearer"></div>';
+
+        print_simple_box_start('center','100%');
+
+        $strgroupmemberssee = get_string('groupmemberssee');
+
+        // Display group constellation for group-assignments
+        $user_is_in_a_group=false;
+        if ($groups = groups_get_all_groups_assignment($this->course->id,$this->assignment->id)) {
+            foreach ($groups as $group) {
+                $shown=false;
+                $usergroup = 0;
+                $t = $group;
+                $t->description = $group->description;
+                if (!$group->hidepicture) {
+                    if ($group->picture) {  // Print custom group picture
+                        require_once($CFG->libdir.'/filelib.php');
+                        $grouppictureurl = get_file_url($group->id.'/f2.jpg', null, 'usergroup');
+                        $t->picture = '<img class="grouppicture" src="'.$grouppictureurl.'"'.
+                            ' style="width:35px;height:35px;" alt="'.s(get_string('group').' '.$group->name).'" title="'.s($group->name).'"/>';
+                    } else {
+                        $t->picture = '<img class="grouppicture" src="'.$CFG->wwwroot.'/theme/'.$CFG->theme.'/pix/g/f2.png"'.
+                            ' style="width:35px;height:35px;" alt="'.s(get_string('group').' '.$group->name).'" title="'.s($group->name).'"/>';
+                    }
+                }
+                if ($t->users = get_group_users_assignment($group->id, $this->assignment->id, 'u.lastname ASC')) {
+                    foreach ($t->users as $key => $user) {
+                        $t->users[$key]->fullname = fullname($user);
+                        if ($user->id == $USER->id) {
+                            $t->users[$key]->fullname = '<b>'.fullname($user).'</b>';
+                            $usergroup = 1;
+                            $this->user_is_in_a_group=true;
+                        }
+                    }
+                }
+                $t->linkfullprofile->url = "group.php?id={$this->cm->course}&group={$group->id}";
+                $t->linkfullprofile->text = $strgroupmemberssee;
+
+                // Check whether this group should be shown
+                if($this->cm->groupmode != $this->course->groupmode && $this->course->groupmodeforce == 0) {
+                    if($this->cm->groupmode == 1 AND $usergroup == 1) {
+                        include($CFG->dirroot.'/mod/assignment/groups-summary.html');
+                        $shown=true;
+                    } elseif($this->cm->groupmode != 1) {
+                        include($CFG->dirroot.'/mod/assignment/groups-summary.html');
+                        $shown=true;
+                    } else {}
+                } else {
+                    if($this->course->groupmode == 1 AND $usergroup == 1) {
+                        include($CFG->dirroot.'/mod/assignment/groups-summary.html');
+                        $shown=true;
+                    } elseif($this->course->groupmode != 1) {
+                        include($CFG->dirroot.'/mod/assignment/groups-summary.html');
+                        $shown=true;
+                    } else {}
+                }
+                // Show group to users who are allowed to grade the assignment
+                if(has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $this->cm->id)) AND $shown!=true) {
+                    include($CFG->dirroot.'/mod/assignment/groups-summary.html');
+                }
+            }
+        }
+        if (!$this->assignment->timeavailable && !$this->assignment->timedue) {
+            return;
+        }
+
+        print_simple_box_start('center');
+        print_string('description','assignment');
+        echo ":";
+        $formatoptions = new stdClass;
+        $formatoptions->noclean = true;
+        echo format_text($this->assignment->description, $this->assignment->format, $formatoptions);
+        print_simple_box_end();
+
+        // hochgeladene Files ausgeben und wenn vorhanden Feedback
+        $filecount = $this->count_user_files($USER->id);
+        if ($submission = $this->get_submission()) {
+            if ($submission->timemarked) {
+                $this->view_feedback();
+            }
+            if ($filecount > 0) {
+                print_simple_box(get_string('submittedfiles','assignment').':<br /><br />'.$this->print_user_files($USER->id, true), 'center');
+            }
+        }
+
+        // Upload Form anzeigen
+        if (has_capability('mod/assignment:submit', $context)  && $this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
+            if (isset($this->user_is_in_a_group) && $this->user_is_in_a_group == true) {
+                $this->view_upload_form();
+            }
+        }
+
+        // Daten anzeigen
+        print_simple_box_start('center', '', '', 0, 'generalbox', 'dates');
+        echo '<table>';
+        if ($this->assignment->timeavailable) {
+            echo '<tr><td class="c0">'.get_string('availabledate','assignment').':</td>';
+            echo '    <td class="c1">'.userdate($this->assignment->timeavailable).'</td></tr>';
+        }
+        if ($this->assignment->timedue) {
+            echo '<tr><td class="c0">'.get_string('duedate','assignment').':</td>';
+            echo '    <td class="c1">'.userdate($this->assignment->timedue).'</td></tr>';
+        }
+        echo '</table>';
+        print_simple_box_end();
+
+        print_simple_box_end();
+
+        $this->view_footer();
+    }
+
+    function display_submission() {
+        global $CFG, $USER;
+
+        $context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
+        require_capability('mod/assignment:grade', $context);
+
+        $groupid = required_param('groupid', PARAM_NUMBER);
+
+        if (!$group = get_record('groups_assignment', 'id', $groupid)) {
+            error('No such group!');
+        }
+
+        $members=get_group_users_assignment($groupid,$this->assignment->id);
+        foreach($members as $member) {
+            // Take first member to check against (if he is allowed to submit assignments)
+            $filecount = $this->count_user_files($member->id);
+            if(has_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id), $member->id)) {
+                $submission=$this->get_submission($member->id);
+                break;
+            }
+        }
+        if(!$submission) { // No Submission has been found (no member uploaded something yet), create an empty submission for each capable member
+            foreach($members as $member) {
+                if(has_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id), $member->id)) {
+                    // this user could create a submission, create submission
+                    $submission = $this->get_submission($member->id, true);
+                }
+            }
+        }
+
+        if (!$submission) {
+            error('An error occured, script is broken');
+        }
+
+        print_header(get_string('feedback', 'assignment').':'.$group->name.':'.format_string($this->assignment->name));
+
+        echo '<table cellspacing="0" class="feedback" >';
+
+        echo '<tr>';
+        echo '<td width="35" valign="top" class="picture user">';
+        print_group_picture($group, $this->course->id, false, false, false);
+        echo '</td>';
+        echo '<td class="topic">';
+        echo '<div class="from">';
+        echo $group->name . ":<br/>";
+        foreach($members as $member) {
+            echo $member->firstname .' '. $member->lastname . ", ";
+        }
+        //    echo '<div class="fullname">'.fullname($user, true).'</div>';
+        if ($submission->timemodified) {
+            echo '<div class="time">'.userdate($submission->timemodified).
+                $this->display_lateness($submission->timemodified).'</div>';
+        } else {
+            echo '<div class="time">'.
+                $this->display_lateness(time()).'</div>';
+        }
+        echo '</div>';
+        $this->print_user_files($member->id);
+        echo '</td>';
+        echo '</tr>';
+
+        echo '<tr>';
+        echo '<td width="35" valign="top" class="picture teacher">';
+        if ($submission->teacher) {
+            $teacher = get_record('user', 'id', $submission->teacher);
+        } else {
+            global $USER;
+            $teacher = $USER;
+        }
+        print_user_picture($USER->id, $this->course->id, $USER->picture);
+        echo '</td>';
+        echo '<td class="content">';
+
+        echo '<form action="submissions.php" method="post">';
+        echo '<input type="hidden" name="groupid" value="'.$groupid.'">';
+        echo '<input type="hidden" name="id" value="'.$this->cm->id.'">';
+        echo '<input type="hidden" name="mode" value="grade">';
+        if (!$submission->grade and !$submission->timemarked) {
+            $submission->grade = -1;   // Hack to stop zero being selected on the menu below (so it shows 'no grade')
+        }
+        if ($submission->timemarked) {
+            $grader=get_record("user","id",$submission->teacher);
+            echo '<div class="from">';
+            echo '<div class="fullname">'.fullname($grader, true).'</div>';
+            echo '<div class="time">'.userdate($submission->timemarked).'</div>';
+            echo '</div>';
+        }
+        echo '<div class="grade">'.get_string('grade').':';
+        choose_from_menu(make_grades_menu($this->assignment->grade), 'grade',
+                $submission->grade, get_string('nograde'));
+        echo '</div>';
+        echo '<div class="clearer"></div>';
+        echo '<br />';
+        print_textarea($this->usehtmleditor, 12, 58, 0, 0, 'comment', $submission->submissioncomment, $this->course->id);
+
+        if ($this->usehtmleditor) {
+            echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
+        } else {
+            echo '<div align="right" class="format">';
+            choose_from_menu(format_text_menu(), "format", $submission->format, "");
+            helpbutton("textformat", get_string("helpformatting"));
+            echo '</div>';
+        }
+
+        echo '<div class="buttons" align="center">';
+        echo '<input type="submit" name="submit" value="'.get_string('savechanges').'" />';
+        echo '<input type="submit" name="cancel" value="'.get_string('cancel').'" />';
+        echo '</div>';
+
+        echo '</form>';
+
+        echo '</td></tr>';
+        echo '</table>';
+
+
+        if ($this->usehtmleditor) {
+            use_html_editor();
+        }
+
+        print_footer('none');
+
+    }
+
+    function print_student_answer() {
+        // This is needet because its beeing called by submissions() -> update_main_listing()
+        return true;
+    }
+
+    function display_submissions() {
+        global $CFG, $db;
+
+        add_to_log($this->course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->assignment->id, $this->assignment->id, $this->cm->id);
+
+        print_header_simple(format_string($this->assignment->name,true), "",
+                           '<a href="index.php?id='.$this->course->id.'">'.
+                           $this->strassignments.
+                           '</a> -> <a href="view.php?a='.$this->assignment->id.'">'.
+                           format_string($this->assignment->name,true).'</a> -> '. $this->strsubmissions,
+                           '', '', true,
+                           update_module_button($this->cm->id, $this->course->id, $this->strassignment),
+                           navmenu($this->course, $this->cm));
+
+        $tablecolumns = array('groupname',  'grade', 'comment', 'timemodified', 'timemarked', 'status');
+        $tableheaders = array('Group name', get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified').' ('.$this->course->student.')', get_string('lastmodified').' ('.$this->course->teacher.')', get_string('status'));
+
+        require_once($CFG->libdir.'/tablelib.php');
+        $table = new flexible_table('mod-assignment-submissions');
+
+        $table->define_columns($tablecolumns);
+        $table->define_headers($tableheaders);
+        $table->define_baseurl($CFG->wwwroot.'/mod/assignment/submissions.php?id='.$this->cm->id);
+
+        $table->sortable(false);
+        $table->collapsible(false);
+        $table->initialbars(true);
+
+        $table->column_class('groupname', 'groupname');
+        $table->column_class('grade', 'grade');
+        $table->column_class('comment', 'comment');
+        $table->column_class('timemodified', 'timemodified');
+        $table->column_class('timemarked', 'timemarked');
+        $table->column_class('status', 'status');
+
+        $table->set_attribute('cellspacing', '0');
+        $table->set_attribute('id', 'attempts');
+        $table->set_attribute('class', 'submissions');
+        $table->set_attribute('width', '90%');
+        $table->set_attribute('align', 'center');
+
+        // Start working -- this is necessary as soon as the niceties are over
+        $table->setup();
+
+        // Display groups who supplied a submission
+        $groups=groups_get_all_groups_assignment($this->course->id,$this->assignment->id);
+        // Look which groups have submissted something
+        foreach($groups as $group) {
+            $members=get_group_users_assignment($group->id,$this->assignment->id);
+            foreach($members as $member) {
+                // Take first member to check against (if he is allowed to submit assignments)
+                $filecount = $this->count_user_files($member->id);
+                if(has_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id), $member->id)) {
+                    $submission=$this->get_submission($member->id);
+
+                    $buttontext = (!$submission OR $submission->grade == -1) ? get_string('grade') :  get_string('update');
+                    $button = button_to_popup_window('/mod/assignment/submissions.php?id='.$this->cm->id.'&amp;groupid='.$group->id.'&amp;mode=single',
+                            'grade'.$group->id, $buttontext, 450, 700, $buttontext, 'none', true, 'button'.$member->id);
+
+                    if(!$submission OR $submission->grade == -1) {
+                        $studmod = '';
+                        if($submission) {
+                            $studmod=userdate($submission->timemodified).$this->print_user_files($member->id,true);
+                        }
+                        $row = array($group->name, "", "", $studmod, "", $button);
+                    } else {
+                        $row = array($group->name, $this->display_grade($submission->grade), $submission->submissioncomment, userdate($submission->timemodified).$this->print_user_files($member->id,true), userdate( $submission->timemarked), $button);
+                    }
+
+                    $table->add_data($row);
+                    break;
+                }
+            }
+        }
+
+        echo "<br /><br />";
+        $table->print_html();
+        print_footer($this->course);
+
+        /*
+        if ($this->assignment->var2 == 1) {
+            // We are grading individuals
+            parent::display_submissions();
+        } else {
+            // We are grading groups (the default)
+            $teacherattempts = true; // Temporary measure
+
+            $page    = optional_param('page', 0);
+            $perpage = optional_param('perpage', 10);
+
+            $strsaveallfeedback = get_string('saveallfeedback', 'assignment');
+
+            // Some shortcuts to make the code read better
+
+            $course     = $this->course;
+            $assignment = $this->assignment;
+            $cm         = $this->cm;
+
+            add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id='.$this->assignment->id, $this->assignment->id, $this->cm->id);
+
+            print_header_simple(format_string($this->assignment->name,true), "", '<a href="index.php?id='.$course->id.'">'.$this->strassignments.'</a> -> <a href="view.php?a='.$this->assignment->id.'">'.format_string($this->assignment->name,true).'</a> -> '. $this->strsubmissions, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));
+
+
+            //        $tablecolumns = array('picture', 'groupname', 'fullname', 'grade', 'comment', 'timemodified', 'timemarked', 'status');
+            //        $tableheaders = array('', 'Group name', get_string('fullname'), get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified').' ('.$course->student.')', get_string('lastmodified').' ('.$course->teacher.')', get_string('status'));
+
+            $tablecolumns = array('groupname',  'grade', 'comment', 'timemodified', 'timemarked', 'status');
+            $tableheaders = array('Group name', get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified').' ('.$course->student.')', get_string('lastmodified').' ('.$course->teacher.')', get_string('status'));
+
+            require_once($CFG->libdir.'/tablelib.php');
+            $table = new flexible_table('mod-assignment-submissions');
+
+            $table->define_columns($tablecolumns);
+            $table->define_headers($tableheaders);
+            $table->define_baseurl($CFG->wwwroot.'/mod/assignment/submissions.php?id='.$this->cm->id);
+
+            $table->sortable(true);
+            $table->collapsible(true);
+            $table->initialbars(true);
+
+            //        $table->column_suppress('picture');
+            //      $table->column_suppress('fullname');
+
+            //        $table->column_class('picture', 'picture');
+            $table->column_class('groupname', 'groupname');
+            //        $table->column_class('fullname', 'fullname');
+            $table->column_class('grade', 'grade');
+            $table->column_class('comment', 'comment');
+            $table->column_class('timemodified', 'timemodified');
+            $table->column_class('timemarked', 'timemarked');
+            $table->column_class('status', 'status');
+
+            $table->set_attribute('cellspacing', '0');
+            $table->set_attribute('id', 'attempts');
+            $table->set_attribute('class', 'submissions');
+            $table->set_attribute('width', '90%');
+            $table->set_attribute('align', 'center');
+
+            // Start working -- this is necessary as soon as the niceties are over
+            $table->setup();
+
+            // Are there any groups defined ?
+            $groups = groups_get_all_groups_assignment($course->id,$this->assignment->id);
+            if ($groups) {
+            $users = array();
+            foreach ($groups as $group) {
+            $groupstoshow[] = $group->id;
+            $userstoadd = get_group_users_assignment($group->id,$this->assignment->id);
+            if ($userstoadd ) {
+            $users = array_merge($users,$userstoadd);
+            }
+        } else {
+            // Grade the whole class in one pass
+            $groupstoshow = array(0);
+            $users = get_course_students($course->id);
+        }
+
+        if (empty($users)) {
+            print_heading(get_string('noattempts','assignment'));
+            return true;
+        }
+
+        // Construct the SQL
+        if ($where = $table->get_sql_where()) {
+            $where .= ' AND ';
+        }
+
+        if ($sort = $table->get_sql_sort()) {
+            $sortparts = explode(',', $sort);
+            $newsort   = array();
+            foreach ($sortparts as $sortpart) {
+                $sortpart = trim($sortpart);
+                $newsort[] = $sortpart;
+            }
+            $sort = ' ORDER BY '.implode(', ', $newsort);
+        }
+
+        $select = 'SELECT u.id, u.id, u.firstname, u.lastname, u.picture, s.id AS submissionid, s.grade, s.comment, s.timemodified, s.timemarked, ((s.timemarked > 0) AND (s.timemarked >= s.timemodified)) AS status ';
+        $sql = 'FROM '.$CFG->prefix.'user u '.
+            'LEFT JOIN '.$CFG->prefix.'assignment_submissions s ON u.id = s.userid AND s.assignment = '.$this->assignment->id.' '.
+            'WHERE '.$where.'u.id IN ('.implode(',', array_keys($users)).') ';
+
+        foreach ($groupstoshow as $gid) {
+            if ($gid == 0) {
+                $keys = array_keys($users);
+                $firstuser = $keys[0];
+                // the whole class, select just the first user
+                $select = 'SELECT \''.get_string('wholeclass', 'assignment').'\' as groupname, u.id, u.id, u.firstname, u.lastname, u.picture, s.id AS submissionid, s.grade, s.submissioncomment, s.timemodified, s.timemarked, ((s.timemarked > 0) AND (s.timemarked >= s.timemodified)) AS status ';
+                $sql = 'FROM '.$CFG->prefix.'user u '.
+                    'LEFT JOIN '.$CFG->prefix.'assignment_submissions s ON u.id = s.userid AND s.assignment = '.$this->assignment->id.' '.
+                    'WHERE '.$where.'u.id = '. $firstuser;
+                $sql2 = $select.$sql;
+            } else {
+                // by groups, select the groups...
+                $sql2 ="
+                    SELECT
+                    g.name AS groupname, gm.groupid, u.id, u.firstname, u.lastname, u.picture, s.id AS submissionid, s.grade, s.timemodified, s.timemarked, ((s.timemarked > 0) AND (s.timemarked >= s.timemodified)) AS status, s.submissioncomment
+                    FROM {$CFG->prefix}groups_assignment g, {$CFG->prefix}user u
+                    LEFT JOIN ({$CFG->prefix}assignment_submissions s, {$CFG->prefix}groups_members_assignment gm)
+                    ON u.id = s.userid AND u.id = gm.userid AND gm.groupid = $gid AND s.assignment = ".$this->assignment->id." AND gm.assignmentid=".$this->assignment->id."
+                    WHERE g.id=$gid AND gm.groupid = $gid
+                    GROUP BY gm.groupid
+                    ORDER BY s.grade DESC";
+            }
+
+            if ($groups)
+                $table->pagesize($perpage, count($groupstoshow));
+            else
+                $table->pagesize($perpage, count($users));
+
+            if($table->get_page_start() !== '' && $table->get_page_size() !== '') {
+                $limit = ' '.sql_paging_limit($table->get_page_start(), $table->get_page_size());
+            }
+            else {
+                $limit = '';
+            }
+
+            $strupdate = get_string('update');
+            $strgrade  = get_string('grade');
+            $grademenu = make_grades_menu($this->assignment->grade);
+
+            if (($ausers = get_records_sql($sql2.$sort.$limit)) !== false) {
+                //if (($ausers = get_records_sql($select.$sql.$sort.$limit)) !== false) {
+
+                foreach ($ausers as $auser) {
+                    //          $picture = print_user_picture($auser->id, $course->id, $auser->picture, false, true);
+
+                    if (!empty($auser->submissionid)) {
+                        if ($auser->timemodified > 0) {
+                            $studentmodified = '<div id="ts'.$auser->id.'">'.userdate($auser->timemodified).'</div>';
+                        } else {
+                            $studentmodified = '<div id="ts'.$auser->id.'">&nbsp;</div>';
+                        }
+                        if ($auser->timemarked > 0) {
+                            $teachermodified = '<div id="tt'.$auser->id.'">'.userdate($auser->timemarked).'</div>';
+                            $grade = '<div id="g'.$auser->id.'">'.$this->display_grade($auser->grade).'</div>';
+                        } else {
+                            $teachermodified = '<div id="tt'.$auser->id.'">&nbsp;</div>';
+                            $grade = '<div id="g'.$auser->id.'"></div>';
+                        }
+
+                        $comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($auser->submissioncomment), 15).'</div>';
+
+                    } else {
+                        $studentmodified = '<div id="ts'.$auser->id.'">&nbsp;</div>';
+                        $teachermodified = '<div id="tt'.$auser->id.'">&nbsp;</div>';
+                        $status          = '<div id="st'.$auser->id.'"></div>';
+                        $grade           = '<div id="g'.$auser->id.'">&nbsp;</div>';
+                        $comment         = '<div id="com'.$auser->id.'">&nbsp;</div>';
+                    }
+
+                    if ($auser->status === NULL) {
+                        $auser->status = 0;
+                    }
+
+                    $buttontext = ($auser->status == 1) ? $strupdate : $strgrade;
+
+                    $button = button_to_popup_window ('/mod/assignment/submissions.php?id='.$this->cm->id.'&amp;userid='.$auser->id.'&amp;mode=single',
+                            'grade'.$auser->id, $buttontext, 450, 700, $buttontext, 'none', true, 'button'.$auser->id);
+
+                    $status  = '<div id="up'.$auser->id.'" class="s'.$auser->status.'">'.$button.'</div>';
+
+                    //          $row = array($picture, $auser->groupname, fullname($auser), $grade, $comment, $studentmodified, $teachermodified, $status);
+                    $row = array($auser->groupname, $grade, $comment, $studentmodified, $teachermodified, $status);
+                    $table->add_data($row);
+                }
+           // }
+        }
+        $table->print_html();
+        print_footer($this->course);
+        }
+        */
+    }
+
+    function view_upload_form() {
+        global $CFG;
+        $struploadafile = get_string("uploadafile");
+        $strmaxsize = get_string("maxsize", "", display_size($this->assignment->maxbytes));
+
+        echo '<center>';
+        echo '<form enctype="multipart/form-data" method="post" '.
+            "action=\"$CFG->wwwroot/mod/assignment/upload.php\">";
+        echo "<p>$struploadafile ($strmaxsize)</p>";
+        echo '<input type="hidden" name="id" value="'.$this->cm->id.'" />';
+        require_once($CFG->libdir.'/uploadlib.php');
+        upload_print_form_fragment(1,array('newfile'),false,null,0,$this->assignment->maxbytes,false);
+        echo '<input type="submit" name="save" value="'.get_string('uploadthisfile').'" />';
+        echo '</form>';
+        echo '</center>';
+    }
+
+    function upload() {
+
+        global $CFG, $USER;
+
+        require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
+
+        $this->view_header(get_string('upload'));
+
+        $filecount = $this->count_user_files($USER->id);
+        $submission = $this->get_submission($USER->id);
+
+        if ($this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
+            if ($submission = $this->get_submission($USER->id)) {
+                if (($submission->grade != -1) and !$this->assignment->resubmit) {
+                    error(get_string('alreadygraded', 'assignment'),'view.php?id='.$this->cm->id);
+                }
+            }
+            // Proceed with uploading
+            require_once($CFG->dirroot.'/lib/uploadlib.php');
+
+            $group = get_record_sql("SELECT groupid
+                                       FROM {$CFG->prefix}groups_members_assignment
+                                      WHERE userid={$USER->id}
+                                        AND assignmentid={$this->assignment->id}");
+            $members = get_group_users_assignment($group->groupid,$this->assignment->id);
+
+            // upload file for $USER
+            $um = new upload_manager('newfile',true,false,$this->course,false,$this->assignment->maxbytes);
+            if (!$um->process_file_uploads($this->file_area_name($USER->id))) {
+                error('Error saving file for '.$USER->lastname.' on server');
+            }
+
+            $newfile_name = $um->get_new_filename();
+            $original_filename = $CFG->dataroot .  "/" .$this->file_area_name($USER->id).  "/".  $newfile_name;
+
+            $success_member_names=array();
+            foreach($members as $member) {
+                // Copy file to each groupmember exept $USER
+                $this->file_area($member->id);
+                $dir = $CFG->dataroot . "/" .$this->file_area_name($member->id);
+                $target_filename =  $dir . "/". basename($newfile_name);
+                if ($original_filename != $target_filename) { // do not copy a file onto itself (onto $USER)
+
+                    // delete other/old files from $dir
+                    // this is a singlefile assignment ...
+                    $dh  = opendir($dir);
+                    $files = array();
+                    while (false !== ($filename = readdir($dh))) {
+                        $files[] = $filename;
+                    }
+                    foreach($files as $f) {
+                        if ($f != '.' && $f != '..') {
+                            unlink($dir . "/" . $f);
+                        }
+                    }
+                    // copy the originally submitted file to the group member's file areas
+                    if (!copy($original_filename, $target_filename)) {
+                        notify("Failed to copy to user " . $member->lastname);
+                    }
+                }
+
+                // Update Submission
+                $submission = $this->get_submission($member->id,true);
+
+                $submission->timemodified = time();
+                $submission->numfiles     = 1;
+                $submission->submissioncomment = addslashes($submission->submissioncomment);
+                update_record("assignment_submissions", $submission);
+                $success_member_names[] = $member->firstname . " " . $member->lastname;
+                add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
+            }
+
+        } else {
+            error(get_string('uploaderror', 'assignment'),'view.php?id='.$this->cm->id);
+        }
+
+        print_heading(get_string('uploadedfile','group') . "<br/> ". join($success_member_names,", "));
+
+        print_continue('view.php?id='.$this->cm->id);
+        $this->view_footer();
+    }
+
+
+    function email_teachers($submission) {
+        /*
+        /// Alerts teachers by email of new or changed assignments that need grading
+        global $CFG;
+
+        if (empty($this->assignment->emailteachers)) {          // No need to do anything
+        return;
+        }
+
+        $user = get_record('user', 'id', $submission->userid);
+
+        if (groupmode($this->course, $this->cm) == SEPARATEGROUPS) {   // Separate groups are being used
+        if (!$group = user_group($this->course->id, $user->id)) {             // Try to find a group
+        $group->id = 0;                                             // Not in a group, never mind
+        }
+        $teachers = get_group_teachers($this->course->id, $group->id);        // Works even if not in group
+        } else {
+        $teachers = get_course_teachers($this->course->id);
+        }
+
+        if ($teachers) {
+
+        $strassignments = get_string('modulenameplural', 'assignment');
+        $strassignment  = get_string('modulename', 'assignment');
+        $strsubmitted  = get_string('submitted', 'assignment');
+
+        foreach ($teachers as $teacher) {
+        unset($info);
+        $info->assignment = format_string($this->assignment->name,true);
+        $info->url = $CFG->wwwroot.'/mod/assignment/submissions.php?id='.$this->cm->id;
+
+        $groups = get_groups($this->course->id);
+        if ($groups) {
+
+        // See which group this user belongs to
+        $group = get_record_sql("
+        SELECT gma.groupid, ga.name FROM {$CFG->prefix}groups_members_assignment gma
+        JOIN {$CFG->prefix}groups_assignment ga
+        ON gma.groupid = ga.id
+        WHERE gma.userid={$user->id} AND gma.assignmentid={$this->assignment->id} AND ga.assignmentid={$this->assignment->id}
+        ");
+        $groupid = $group->groupid;
+        $info->groupname = 'Group '. $group->name;
+
+        // do a member's string
+        $members = get_group_students($groupid);
+        $names = array();
+        foreach($members as $member) {
+        $names[] = $member->firstname . ' ' . $member->lastname;
+        }
+        $info->groupmembers = '('. join(',',$names) .')';
+        } else {
+        // If no groups are defined in the course, the whole class is a course.
+        $info->groupmembers = '';
+        $info->groupname = get_string('wholeclass', 'assignment');
+        }
+
+        $postsubject = $strsubmitted.': '.$info->groupname.' -> '.$this->assignment->name;
+        $posttext = $this->email_teachers_text($info);
+        $posthtml = ($teacher->mailformat == 1) ? $this->email_teachers_html($info) : '';
+
+        @email_to_user($teacher, $user, $postsubject, $posttext, $posthtml);  // If it fails, oh well, too bad.
+        }
+        }
+         */
+    }
+
+    function email_teachers_text($info) {
+
+        /* $info is like:
+           $info->username = fullname($user);
+           $info->assignment = format_string($this->assignment->name,true);
+           $info->url = $CFG->wwwroot.'/mod/assignment/submissions.php?id='.$this->cm->id;
+
+           with
+
+           $info->groupname = 'Whole Class';
+           $info->groupmembers = '';
+
+           or
+
+           $info->groupname = 'Group test 1';
+           $info->groupmembers = 'John Doe, Alice Springs, Colin Ducommun';
+
+
+
+           global $CFG;
+
+           $posttext  = $this->course->shortname.' -> '.$this->strassignments.' -> '.
+           format_string($this->assignment->name, true)."\n";
+
+           $posttext .= '---------------------------------------------------------------------'."\n";
+           $posttext .= get_string("emailteachermailgroup", "assignment", $info)."\n";
+           $posttext .= '---------------------------------------------------------------------'."\n";
+           return $posttext;
+         */
+    }
+
+
+    function email_teachers_html($info) {
+
+        /* $info is like:
+           $info->username = fullname($user);
+           $info->assignment = format_string($this->assignment->name,true);
+           $info->url = $CFG->wwwroot.'/mod/assignment/submissions.php?id='.$this->cm->id;
+
+           with
+
+           info->groupname = 'Whole Class';
+           $info->groupmembers = '';
+
+           or
+
+           $info->groupname = 'Group test 1';
+           $info->groupmembers = 'John Doe, Alice Springs, Colin Ducommun';
+
+
+
+           global $CFG;
+           $posthtml  = '<p><font face="sans-serif">'.
+           '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$this->course->id.'">'.$this->course->shortname.'</a> ->'.
+           '<a href="'.$CFG->wwwroot.'/mod/assignment/index.php?id='.$this->course->id.'">'.$this->strassignments.'</a> ->'.
+           '<a href="'.$CFG->wwwroot.'/mod/assignment/view.php?id='.$this->cm->id.'">'.format_string($this->assignment->name,true).'</a></font></p>';
+           $posthtml .= '<hr /><font face="sans-serif">';
+           $posthtml .= '<p>'.get_string('emailteachermailhtmlgroup', 'assignment', $info).'</p>';
+           $posthtml .= '</font><hr />';
+           return $posthtml;
+         */
+    }
+
+    /*
+     *  Display and process the submissions
+     */
+    function process_feedback() {
+        global $CFG, $USER;
+
+        if (!$feedback = data_submitted()) {      // No incoming data?
+            return false;
+        }
+
+        if (!empty($feedback->cancel)) {          // User hit cancel button
+            return false;
+        }
+
+        $members = get_group_users_assignment($feedback->groupid,$this->assignment->id);
+        foreach($members as $member) {
+            if(has_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id),$member->id)) {
+                // Nur Benutzer mit mod/assignment:submit dürfen bewertet werden
+                $newsubmission = $this->get_submission($member->id,true);  // Get or make one (but should already be there)
+                $newsubmission->grade      = $feedback->grade;
+                $newsubmission->submissioncomment = $feedback->comment;
+                $newsubmission->format     = $feedback->format;
+                $newsubmission->teacher    = $USER->id;
+                $newsubmission->mailed     = 0;       // Make sure mail goes out (again, even)
+                $newsubmission->timemarked = time();
+                update_record('assignment_submissions', $newsubmission);
+                $this->update_grade($newsubmission);
+
+                add_to_log($this->course->id, 'assignment', 'update grades',
+                        'submissions.php?id='.$this->assignment->id.'&user='.$member->id, $member->id, $this->cm->id);
+            }
+        }
+        return $newsubmission;
+    }
+
+    function setup_elements(&$mform) {
+        global $CFG, $COURSE;
+
+        $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
+
+        $mform->addElement('select', 'resubmit', get_string("allowresubmit", "assignment"), $ynoptions);
+        $mform->setHelpButton('resubmit', array('resubmit', get_string('allowresubmit', 'assignment'), 'assignment'));
+        $mform->setDefault('resubmit', 0);
+
+        $mform->addElement('select', 'emailteachers', get_string("emailteachers", "assignment"), $ynoptions);
+        $mform->setHelpButton('emailteachers', array('emailteachers', get_string('emailteachers', 'assignment'), 'assignment'));
+        $mform->setDefault('emailteachers', 0);
+
+        $choices = get_max_upload_sizes($CFG->maxbytes, $COURSE->maxbytes);
+        $choices[0] = get_string('courseuploadlimit') . ' ('.display_size($COURSE->maxbytes).')';
+        $mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
+        $mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
+
+    }
+}
+
+/**
+ * Returns an array of user objects for a specified assignment
+ *
+ * @uses $CFG
+ * @param int $groupid The group in question.
+ * @param int $assignmentid The assignment in question.
+ * @param string $sort ?
+ * @param string $exceptions ?
+ * @return object
+ * @todo Finish documenting this function
+ */
+function get_group_users_assignment($groupid, $assignmentid, $sort='u.lastaccess DESC', $exceptions='', $fields='u.*') {
+    global $CFG;
+
+    if (!empty($exceptions)) {
+        $except = ' AND u.id NOT IN ('. $exceptions .') ';
+    } else {
+        $except = '';
+    }
+
+    // in postgres, you can't have things in sort that aren't in the select, so...
+    $extrafield = str_replace('ASC','',$sort);
+    $extrafield = str_replace('DESC','',$extrafield);
+    $extrafield = trim($extrafield);
+    if (!empty($extrafield)) {
+        $extrafield = ','.$extrafield;
+    }
+
+    return get_records_sql("SELECT DISTINCT $fields $extrafield
+                              FROM {$CFG->prefix}user u
+                              JOIN {$CFG->prefix}groups_members_assignment m
+                                ON (m.userid = u.id)
+                             WHERE m.groupid = '$groupid'
+                               AND m.assignmentid = $assignmentid
+                               $except
+                          ORDER BY $sort");
+}
+
+/**
+ * Gets array of all groups in a specified assignment.
+ * @param int $courseid The id of the course.
+ * @param int $assignmentid The id of the assignment.
+ * @param mixed $userid optional user id or array of ids, returns only groups of the user.
+ * @param int $groupingid optional returns only groups in the specified grouping.
+ * @return array | false Returns an array of the group objects or false if no records
+ * or an error occurred. (userid field returned if array in $userid)
+ */
+function groups_get_all_groups_assignment($courseid, $assignmentid, $userid=0, $groupingid=0, $fields='g.*') {
+    global $CFG;
+
+    // groupings are ignored when not enabled
+    if (empty($CFG->enablegroupings)) {
+        $groupingid = 0;
+    }
+
+    if (empty($userid)) {
+        $userfrom  = ", {$CFG->prefix}groups_members_assignment gm";
+        $userwhere = "AND g.id = gm.groupid AND gm.assignmentid=".$assignmentid;
+
+    } else if (is_array($userid)) {
+        $userids = implode(',', $userid);
+        $userfrom  = ", {$CFG->prefix}groups_members_assignment gm";
+        $userwhere = "AND g.id = gm.groupid AND gm.userid IN ($userids) AND gm.assignmentid=".$assignmentid;
+
+    } else {
+        $userfrom  = ", {$CFG->prefix}groups_members_assignment gm";
+        $userwhere = "AND g.id = gm.groupid AND gm.userid = '$userid' AND gm.assignmentid=".$assignmentid;
+    }
+
+    $sql = "SELECT $fields
+              FROM {$CFG->prefix}groups_assignment g $userfrom
+             WHERE g.courseid = $courseid $userwhere
+               AND g.assignmentid = $assignmentid
+          ORDER BY name ASC";
+    return get_records_sql($sql);
+}
+?>
diff --git a/mod/assignment/version.php b/mod/assignment/version.php
index dcaf4a1..f02c0a6 100644
--- a/mod/assignment/version.php
+++ b/mod/assignment/version.php
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101511;
+$module->version  = 2010030501;
 $module->requires = 2007101509;  // Requires this Moodle version
 $module->cron     = 60;
 
diff --git a/user/groups-summary.html b/user/groups-summary.html
new file mode 100644
index 0000000..e6e3d61
--- /dev/null
+++ b/user/groups-summary.html
@@ -0,0 +1,67 @@
+<table width=100%>
+    <tr>
+    <td colspan=2><b><?php echo get_string('group','group').' '.$t->name ?></b></td>
+     <tr>
+     <td vAlign="top" colspan=2>
+     <table>
+     <tr>
+     <td vAlign="top"><?php echo $t->picture ?></td>
+    <td vAlign="top"><?php echo $t->description ?></td>
+    </tr>
+    </table>
+    <b><?php print_string('members','group') ?>:</b>
+    <?php
+    if($t->users) {
+        $countusers = count($t->users);
+        if($course->groupmode == SEPARATEGROUPS) {
+            if($countusers == 1) { $str_users=get_string("groupcountsingle","group"); } else { $str_users=get_string("groupcountplural","group"); }
+            echo $countusers." ".$str_users;
+        } else {
+            foreach ($t->users as $user) {
+                echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$t->courseid\">$user->fullname</a>";
+                $countusers--;
+                if ($countusers) {
+                    echo ', ';
+                }
+            }
+        }
+    }
+    ?>
+      <hr style="border: 0px;border-top: solid 1px #DDDDDD;border-bottom: solid 1px #FFFFFF;">
+    </td>
+     </tr>
+    <tr>
+    <td>
+    <?php
+    echo "<table cellpadding=0>";
+    if($group->timeclose != 0 && $group->timeclose > time()) {
+        echo "<tr><td><img src=\"{$CFG->wwwroot}/theme/{$CFG->theme}/pix/i/lock.gif\" /></td><td> ".get_string("timeclose","group").' '.userdate($group->timeclose)."</td></tr>";
+    }
+    if($group->timeclose != 0 && $group->timeclose <= time()) {
+        echo "<tr><td><img src=\"{$CFG->wwwroot}/theme/{$CFG->theme}/pix/i/unlock.gif\" /></td><td> ".get_string("timelocked","group")."</td></tr>";
+    } else {
+        echo "<tr><td align=\"center\"><img src=\"{$CFG->wwwroot}/theme/{$CFG->theme}/pix/t/groupn.gif\" /></td><td> ".get_string("maxgroupmembers","group")." ".$group->maxuser."</td></tr>";
+    }
+    echo "</table>";
+    ?>
+    </td>
+    <td>
+    <?php
+    if (!empty($t->linkfullprofile)) {
+        ///    echo '<div style="font-size: small" align="right"><a href="'.$t->linkfullprofile->url.'">'.$t->linkfullprofile->text.'</a>...</div>';
+    }
+    if (count($t->users) < $group->maxuser AND !$usergroup) {
+        if($group->timeclose != 0 && $group->timeclose <= time()) {
+            // Group is locked
+        } else {
+            echo '<div style="font-size: small" align="right"><a href="'.$t->move->url.'">'.$t->move->text.'</a></div>';
+        }
+    } elseif (!empty($usergroup)) {
+        echo '<div style="font-size: small" align="right">'.get_string('groupmy2','group',$t->leave->url).'</div>';
+    } else {
+        echo '<div style="font-size: small" align="right">'.get_string('groupisfull','group').'</div>';
+    }
+    ?>
+    </td>
+    </tr>
+</table>
diff --git a/user/groups.php b/user/groups.php
new file mode 100644
index 0000000..b7750ba
--- /dev/null
+++ b/user/groups.php
@@ -0,0 +1,161 @@
+<?php
+
+    require_once('../config.php');
+
+    $courseid     = required_param('courseid',PARAM_INT);
+    $move         = optional_param('move','',PARAM_INT);
+    $leave         = optional_param('leave','',PARAM_INT);
+
+    $maxallowed = 20;
+
+
+    if ($courseid > 0) {
+        $course = get_record('course','id',$courseid);
+        $groups = get_groups($course->id);
+    } else {
+        error('Course id not set!');
+    }
+
+    require_login($course->id);
+
+    if ($course->groupmode == NOGROUPS) {
+        error('Group selection is disabled in this course!');
+    }
+
+    $strgroup = get_string('group');
+    $strgroups = get_string('groups');
+    $streditgroupprofile = get_string('editgroupprofile');
+    $strgroupmemberssee = get_string('groupmemberssee');
+    $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, "", $loggedinas);
+      if    ($move>0) {
+        /// we have to update these variables to make them current;
+        /// from 1.6 on we use array of groups
+        $USER->groupmember[$course->id] = array($move);
+        $groups = get_groups($course->id);
+
+
+        if (!$destination = get_record('groups', 'id', $move)) {
+            error('Incorrect group id!','groups.php?courseid='.$course->id);
+        }
+        if (count(get_group_users($move)) >= $groups[$move]->maxuser) {
+            error('You can\'t move to this group because it is full!','groups.php?courseid='.$course->id);
+        }
+        if ($course->id != $destination->courseid) {
+            error("You can't move to another courses group",'groups.php?courseid='.$course->id);
+        }
+        if ($groups[$move]->timeclose != 0 && $groups[$move]->timeclose <= time()) {
+            error("You can't join a locked group",'groups.php?courseid='.$course->id);
+        }
+
+        if($groups[$move]->enrolmentkey != "") {
+
+            $frm_data = new stdClass();
+            $frm_data->move=$move;
+            $frm_data->courseid=$course->id;
+            require_once($CFG->dirroot.'/group/enrol_form.php');
+            $frmenrol = new enrol_authorize_form('groups.php', compact('course'));
+
+            if ($frmenrol->get_data()) {
+                $group=get_record_sql("SELECT enrolmentkey FROM ".$CFG->prefix."groups WHERE id=".(int) $_POST['move']);
+                if($_POST['enrolmentkey'] != $group->enrolmentkey) {
+                    error(get_string("wrong_key","group"));
+                } else {
+                    // get array of current groups and remove the user from all of them
+                    $mygroups = (array)array_keys((array)get_groups($course->id, $USER->id));
+                    if (count($mygroups)>0) {
+                        $where = "userid = '{$USER->id}' AND ( groupid  = '".implode("' OR groupid = '", $mygroups)."' ) ";
+                        if (!delete_records_select('groups_members', $where)) {
+                            error("Could not cancel your old memberships in database");
+                        }
+                    }
+
+                    if (!add_user_to_group((int) $_POST['move'], $USER->id)) {
+                        error("Could not insert membership into database");
+                    }
+
+                }
+            } else {
+                print_simple_box_start('center', '50%');
+                $frmenrol->display();
+
+                print_simple_box_end();
+            }
+
+        } else {
+
+            if (!add_user_to_group($move, $USER->id)) {
+                error("Could not insert membership into database");
+            }
+
+        }
+
+    }
+
+    if($leave>0) {
+        $mygroup=get_record_sql("SELECT a.id, a.timeclose FROM ".$CFG->prefix."groups AS a, ".$CFG->prefix."groups_members AS b WHERE b.userid={$USER->id} AND a.courseid={$course->id} AND a.id=b.groupid AND a.id={$leave}");
+          if ($groups[$mygroup->id]->timeclose != 0 && $groups[$mygroup->id]->timeclose <= time()) {
+            error("You can't leave a locked group",'groups.php?courseid='.$course->id);
+        }
+        $where = "userid = '{$USER->id}' AND groupid  = '$leave'";
+        if (!delete_records_select('groups_members', $where)) {
+            error("Could not cancel your old memberships in database");
+        }
+    }
+
+    /// Write list of all groups
+    echo "<br />";
+
+    if (!$groups) {
+        print_heading(get_string('groupsnone'));
+    } else {
+
+        // Gebe die Gruppen  aus
+        foreach ($groups as $group) {
+            print_simple_box_start('center','75%');
+
+            $usergroup = false;
+            $t = $group;
+            $t->description = $group->description;
+            if (!$group->hidepicture) {
+                if ($group->picture) {  // Print custom group picture
+                    require_once($CFG->libdir.'/filelib.php');
+                    $grouppictureurl = get_file_url($group->id.'/f2.jpg', null, 'usergroup');
+                    $t->picture = '<img class="grouppicture" src="'.$grouppictureurl.'"'.
+                        ' style="width:35px;height:35px;" alt="'.s(get_string('group').' '.$group->name).'" title="'.s($group->name).'"/>';
+                } else {
+                    $t->picture = '<img class="grouppicture" src="'.$CFG->wwwroot.'/theme/'.$CFG->theme.'/pix/g/f2.png"'.
+                        ' style="width:35px;height:35px;" alt="'.s(get_string('group').' '.$group->name).'" title="'.s($group->name).'"/>';
+                }
+            }
+            #$t->picture = print_group_picture($group, $course->id, false, true, true);
+            if ($t->users = get_group_users($group->id, 'u.lastname ASC')) {
+                foreach ($t->users as $key => $user) {
+                    $t->users[$key]->fullname = fullname($user);
+                    if ($user->id == $USER->id) {
+                        $t->users[$key]->fullname = '<b>'.fullname($user).'</b>';
+                        $usergroup = true;
+                    }
+                }
+            }
+            $t->linkfullprofile->url = "group.php?id=$course->id&group=$group->id";
+            $t->linkfullprofile->text = $strgroupmemberssee;
+
+            // GWD link to allow students to move
+            $t->leave->url="groups.php?courseid=$course->id&leave=$group->id";
+            $t->move = '';
+            if ((count($t->users) < $group->maxuser) and !$usergroup) {
+                $t->move->url = "groups.php?courseid=$course->id&move=$group->id";
+                $t->move->text = get_string('movemetothisgroup','group');
+            }
+            include('groups-summary.html');
+
+            print_simple_box_end();
+        }
+
+    }
+
+    print_footer($course);
+    exit;
+?>
