diff --git a/group/copy.php b/group/copy.php
new file mode 100644
index 0000000..c325cd7
--- /dev/null
+++ b/group/copy.php
@@ -0,0 +1,108 @@
+<?php
+require_once('../config.php');
+require_once('lib.php');
+
+$courseid = required_param('id', PARAM_INT);
+$id_coursefrom = optional_param('id_coursefrom', 0, PARAM_INT);
+
+if (!$course = get_record('course', 'id',$courseid)) {
+    print_error('invalidcourse'); //'The course ID is invalid'
+}
+
+// Make sure that the user has permissions to manage groups.
+require_login($course);
+
+if ($id_coursefrom > 0) {
+    if (!$course_from = get_record('course', 'id',$courseid)) {
+        print_error('invalidcoursefrom'); //'The course ID is invalid'
+    }
+
+    $context_from = get_context_instance(CONTEXT_COURSE, $id_coursefrom);
+    require_capability('moodle/course:update', $context_from);
+
+    delete_records('groups', 'courseid', $courseid);
+
+    $sql = "INSERT into groups (courseid, name,description,enrolmentkey,picture,hidepicture,timecreated,timemodified)
+            SELECT {$courseid}, g.name,g.description,g.enrolmentkey,g.picture,g.hidepicture,g.timecreated,g.timemodified
+              FROM groups g
+             WHERE courseid = {$id_coursefrom}";
+
+    execute_sql($sql, false);
+
+    $sql = "INSERT into groups_members (groupid, userid,timeadded)
+            SELECT g2.id, gm.userid, gm.timeadded
+              FROM groups_members gm
+              JOIN groups g1
+                ON (g1.id = gm.groupid AND
+                    g1.courseid = {$id_coursefrom})
+              JOIN groups g2
+                ON (g2.name = g1.name AND
+                    g2.courseid = {$courseid})
+              JOIN context ctx
+                ON (ctx.instanceid = g2.courseid AND
+                    ctx.contextlevel = 50)
+              JOIN role_assignments ra
+                ON (ra.contextid = ctx.id AND
+                    gm.userid = ra.userid)";
+
+    execute_sql($sql, false);
+
+    redirect($CFG->wwwroot.'/group/index.php?id='.$courseid);
+}
+
+$strgroups = get_string('groups');
+$strparticipants = get_string('participants');
+
+$navlinks = array(array('name'=>$strparticipants, 'link'=>$CFG->wwwroot.'/user/index.php?id='.$courseid, 'type'=>'misc'),
+                  array('name'=>$strgroups, 'link'=>'', 'type'=>'misc'));
+$navigation = build_navigation($navlinks);
+
+/// Print header
+print_header_simple($strgroups, ': '.$strgroups, $navigation, '', '', true, '', navmenu($course));
+// Add tabs
+$currenttab = 'groups';
+require('tabs.php');
+
+print_heading(format_string($course->shortname) .' '.$strgroups, 'center', 3);
+
+$tcourseids = '';
+
+if ($teachers = get_user_capability_course('moodle/course:update')) {
+    foreach ($teachers as $teacher) {
+        if ($teacher->id != $course->id && $teacher->id != SITEID){
+            $tcourseids .= $teacher->id.',';
+        }
+    }
+}
+
+$taught_courses = array();
+if (!empty($tcourseids)) {
+    $tcourseids = substr($tcourseids,0,-1);
+    $taught_courses = get_records_list('course', 'id', $tcourseids, 'sortorder');
+}
+
+$options = array();
+foreach ($taught_courses as $tcourse) {
+    if ($tcourse->id != $course->id && $tcourse->id != SITEID){
+        $options[$tcourse->id] = format_string($tcourse->fullname);
+    }
+}
+
+echo '<form method="post" action="copy.php">',
+     '<input type="hidden" name="id" value="',$courseid,'">',
+     '<select name="id_coursefrom">';
+foreach ($options as $id => $name) {
+    echo '<option value="',$id,'">',$name,'</option>';
+}
+echo '</select>';
+
+echo '<p>Atenção, todos os grupos do curso corrente serão removidos.</p>',
+     '<p>Serão criados grupos com os mesmos nomes do curso escolhido.</p>',
+     '<p>As inscrições nos grupos só serão replicadas para os usuários inscritos no curso corrente.</p>';
+
+echo '<input type="submit">',
+     '</form>';
+
+print_footer();
+
+?>
diff --git a/group/index.php b/group/index.php
index ac7f1c2..f8ea8e4 100644
--- a/group/index.php
+++ b/group/index.php
@@ -255,10 +255,15 @@ echo '</select>'."\n";
 
 echo '<p><input type="submit" ' . $showaddmembersform_disabled . ' name="act_showaddmembersform" '
         . 'id="showaddmembersform" value="' . get_string('adduserstogroup', 'group'). '" /></p>'."\n";
+
+echo '<a href=',$CFG->wwwroot.'/group/copy.php?id=',$courseid,'>', get_string('copy_groups'), '</a>';
+
 echo '</td>'."\n";
 echo '</tr>'."\n";
 echo '</table>'."\n";
 
+
+
 //<input type="hidden" name="rand" value="om" />
 echo '</div>'."\n";
 echo '</form>'."\n";
