[LON-CAPA-cvs] cvs: loncom /enrollment Autoenroll.pl /interface lonchatfetch.pm loncommon.pm loncoursedata.pm loncoursegroups.pm loncreateuser.pm londropadd.pm longroupchat.pm lonhelper.pm lonparmset.pm lonpickcourse.pm lonpickstudent.pm lonpopulate.pm lonsimplepage.pm lonstatistics.pm portfolio.pm /lonnet/perl lonnet.pm doc/loncapafiles loncapafiles.lpml

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 18 May 2006 01:09:15 -0000


This is a MIME encoded message

--raeburn1147914555
Content-Type: text/plain

raeburn		Wed May 17 21:09:15 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonsimplepage.pm lonchatfetch.pm 
                     	loncoursegroups.pm longroupchat.pm 
                     	lonpickstudent.pm lonpickcourse.pm 
                     	lonstatistics.pm loncreateuser.pm 
                     	loncoursedata.pm lonhelper.pm londropadd.pm 
                     	lonparmset.pm lonpopulate.pm portfolio.pm 
    /loncom/lonnet/perl	lonnet.pm 
    /doc/loncapafiles	loncapafiles.lpml 
    /loncom/enrollment	Autoenroll.pl 
  Log:
  &coursegroups() and &get_group_settings() moved to longroup.pm, which contains general utility functions for asking about groups.  Also contains &group_changes() which is used to add/drop group memberships as a result of role changes, as determined by group settings for auto-add and auto-drop. 'none' and 'all' are now reserved words which may not be used as section or group names, so they can be used instead of _all and _none  when specifying auto-add and auto-drop settings for all sections or no section roles.
  
  
--raeburn1147914555
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060517210915.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.374 loncom/interface/loncommon.pm:1.375
--- loncom/interface/loncommon.pm:1.374	Wed May 17 19:25:56 2006
+++ loncom/interface/loncommon.pm	Wed May 17 21:08:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.374 2006/05/17 23:25:56 raeburn Exp $
+# $Id: loncommon.pm,v 1.375 2006/05/18 01:08:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3709,7 +3709,7 @@
 
 Inputs: 
 user's domain, user's username, course's domain,
-course's number, optional section/group.
+course's number, optional section ID.
 
 Outputs:
 role status: active, previous or future. 
@@ -3815,151 +3815,6 @@
 }
 
 ###############################################
-                                                                                  
-=pod
-                                                                                  
-=item coursegroups
-
-Retrieve information about groups in a course,
-
-Input:
-1. Optional course domain
-2. Optional course number
-3. Optional group name
-
-Course domain and number will be taken from user's
-environment if not supplied. Optional group name will'
-be passed to lonnet::get_coursegroups() as a regexp to
-use in the call to the dump function.
-
-Output
-Returns hash of groups in the course (subject to the
-optional group name filter). In the hash, the keys are
-group names, and their corresponding values
-are scalars containing group information in XML. This
-can be sent to &get_group_settings() to be parsed.
-
-Side effects:
-None.
-=cut 
-
-###############################################
-
-sub coursegroups {
-    my ($cdom,$cnum,$group) = @_;
-    if (!defined($cdom) || !defined($cnum)) {
-        my $cid =  $env{'request.course.id'};
-
-	return if (!defined($cid));
-
-        $cdom = $env{'course.'.$cid.'.domain'};
-        $cnum = $env{'course.'.$cid.'.num'};
-    }
-    my %curr_groups = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group);
-    my ($tmp) = keys(%curr_groups);
-    if ($tmp=~/^(con_lost|no_such_host|error: [^2] )/) {
-	undef(%curr_groups);
-	&logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.$cdom);
-    } elsif ($tmp=~/^error: 2 /) {
-	undef(%curr_groups);
-    }
-    return %curr_groups;
-}
-
-###############################################
-
-=pod
-
-=item get_group_settings
-
-Uses TokeParser to extract group information from the
-XML used to describe course groups.
-
-Input:
-Scalar containing XML  - as retrieved from &coursegroups().
-
-Output:
-Hash containing group information as key=values for (a), and
-hash of hashes for (b)
-
-Keys (in two categories):
-(a) groupname, creator, creation, modified, startdate,enddate.
-Corresponding values are name of the group, creator of the group
-(username:domain), UNIX time for date group was created, and
-settings were last modified, and default start and end access
-times for group members.
-
-(b) functions returned in hash of hashes.
-Outer hash key is functions.
-Inner hash keys are chat,discussion,email,files,homepage,roster.
-Corresponding values are either on or off, depending on
-whether this type of functionality is available for the group.
-
-=cut
-                                                                                 
-###############################################
-
-sub get_group_settings {
-    my ($groupinfo)=@_;
-    my $parser=HTML::TokeParser->new(\$groupinfo);
-    my $token;
-    my $tool = '';
-    my $role = '';
-    my %content=();
-    while ($token=$parser->get_token) {
-        if ($token->[0] eq 'S')  {
-            my $entry=$token->[1];
-            if ($entry eq 'functions' || $entry eq 'autosec') {
-                %{$content{$entry}} = ();
-                $tool = $entry;
-            } elsif ($entry eq 'role') {
-                if ($tool eq 'autosec') {
-                    $role = $token->[2]{id};
-                    @{$content{$tool}{$role}} = ();
-                }
-            } else {
-                my $value=$parser->get_text('/'.$entry);
-                if ($entry eq 'name') {
-                    if ($tool eq 'functions') {
-                        my $function = $token->[2]{id};
-                        $content{$tool}{$function} = $value;
-                    }
-                } elsif ($entry eq 'groupname') {
-                    $content{$entry}=&unescape($value);
-                } elsif (($entry eq 'roles') || ($entry eq 'types') ||
-                         ($entry eq 'sectionpick') || ($entry eq 'defpriv')) {
-                    push(@{$content{$entry}},$value);
-                } elsif ($entry eq 'section') {
-                    if ($tool eq 'autosec'  && $role ne '') {
-                        push(@{$content{$tool}{$role}},$value);
-                    }
-                } else {
-                    $content{$entry}=$value;
-                }
-            }
-        } elsif ($token->[0] eq 'E') {
-            if ($token->[1] eq 'functions' || $token->[1] eq 'autosec') {
-                $tool = '';
-            } elsif ($token->[1] eq 'role') {
-                $role = '';
-            }
-
-        }
-    }
-    return %content;
-}
-
-sub check_group_access {
-    my ($group) = @_;
-    my $access = 1;
-    my $now = time;
-    my ($start,$end) = split(/\./,$env{'user.role.gr/'.$env{'request.course,id'}.'/'.$group});
-    if (($end!=0) && ($end<$now)) { $access = 0; }
-    if (($start!=0) && ($start>$now)) { $access=0; }
-    return $access;
-}
-
-###############################################
 
 =pod
                                                                                 
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.39 loncom/interface/lonsimplepage.pm:1.40
--- loncom/interface/lonsimplepage.pm:1.39	Tue May  9 10:38:10 2006
+++ loncom/interface/lonsimplepage.pm	Wed May 17 21:08:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.39 2006/05/09 14:38:10 albertel Exp $
+# $Id: lonsimplepage.pm,v 1.40 2006/05/18 01:08:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,6 +37,7 @@
 use Apache::lonlocal;
 use Apache::lonprintout;
 use Apache::lonxml;
+use Apache::longroup;
 
 sub handler {
     my $r = shift;
@@ -76,7 +77,7 @@
 	    return OK;
         }
         %groupinfo = 
-	    &Apache::loncommon::get_group_settings($curr_groups{$marker});
+	    &Apache::longroup::get_group_settings($curr_groups{$marker});
     } else {  
         $marker=~s/\D//g;
         $namespace = 'smppage_'.$marker;
@@ -127,7 +128,7 @@
 
     if ($caller eq 'grppg') {
         if (($grp_view_permission) || 
-                           (&Apache::loncommon::check_group_access($caller))) {
+                           (&Apache::longroup::check_group_access($caller))) {
             unless(&Apache::lonnet::allowed('vgh',
                                       $env{'request.course.id'}.'/'.$marker)) {
                 &display_group_links($r,$target,$marker,'view',%groupinfo);
Index: loncom/interface/lonchatfetch.pm
diff -u loncom/interface/lonchatfetch.pm:1.23 loncom/interface/lonchatfetch.pm:1.24
--- loncom/interface/lonchatfetch.pm:1.23	Tue May  9 10:38:09 2006
+++ loncom/interface/lonchatfetch.pm	Wed May 17 21:08:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Chat Fetching
 #
-# $Id: lonchatfetch.pm,v 1.23 2006/05/09 14:38:09 albertel Exp $
+# $Id: lonchatfetch.pm,v 1.24 2006/05/18 01:08:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
 use Apache::lontexconvert;
 use Apache::loncommon;
 use Apache::lonnet;
+use Apache::longroup;
 
 sub handler {
     my $r = shift;
@@ -48,10 +49,10 @@
 				       $group) ) {
             return HTTP_NOT_ACCEPTABLE;
         }
-        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum,$group);
+        my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
         if (%curr_groups) {
             my %group_info = 
-		&Apache::loncommon::get_group_settings($curr_groups{$group});
+		&Apache::longroup::get_group_settings($curr_groups{$group});
             $grouptitle = 
 		'<b>'.&Apache::lonnet::unescape($group_info{description}).
 		'</b><br />';
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.16 loncom/interface/loncoursegroups.pm:1.17
--- loncom/interface/loncoursegroups.pm:1.16	Tue May  9 11:09:27 2006
+++ loncom/interface/loncoursegroups.pm	Wed May 17 21:08:50 2006
@@ -30,6 +30,7 @@
 use Apache::lonhtmlcommon;
 use Apache::lonlocal;
 use Apache::lonnavmaps;
+use Apache::longroup;
 use Apache::Constants qw(:common :http);
 
 sub handler {
@@ -154,7 +155,7 @@
         if (!defined($action)) {
             $action = 'view';
         }
-        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+        my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
         if (%curr_groups) {
             $r->print('<br /><br />');
             $r->print(&Apache::lonhtmlcommon::start_pick_box());
@@ -182,7 +183,7 @@
             my %Sortby = ();
             foreach my $group (sort(keys(%curr_groups))) {
                 %{$grp_info{$group}} = 
-                                  &Apache::loncommon::get_group_settings(
+                                  &Apache::longroup::get_group_settings(
                                                          $curr_groups{$group});
                 my $members_result = &group_members($cdom,$cnum,$group,
                                                     \%grp_info);
@@ -267,10 +268,10 @@
         my @coursegroups = split(/:/,$env{'request.course.groups'});
         if (@coursegroups > 0) {
             $r->print('<br /><br />');
-            my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+            my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
             if (%curr_groups) {
                 foreach my $group (@coursegroups) {
-                    my %group_info =  &Apache::loncommon::get_group_settings(
+                    my %group_info =  &Apache::longroup::get_group_settings(
                                         $curr_groups{$group});
                     my $description = &Apache::lonnet::unescape(
                                         $group_info{description});
@@ -433,7 +434,10 @@
                                    );
     if (ref($stored{'autorole'}) eq 'ARRAY') {
         foreach my $role (@{$stored{'autorole'}}) {
-            $elements{'modify'}{'change_settings'}{'sec_'.$role} = 'selectbox'; 
+            unless ($role eq 'cc') {
+                $elements{'modify'}{'change_settings'}{'sec_'.$role} = 
+                                                                   'selectbox';
+            }
         }
     }
     %{$elements{'create'}{'pick_members'}} = (
@@ -807,12 +811,12 @@
 
 sub retrieve_settings {
     my ($cdom,$cnum,$groupname) = @_;
-    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum,$groupname);
+    my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$groupname);
 
     return if (!%curr_groups);
 
     my %groupinfo = 
-	&Apache::loncommon::get_group_settings($curr_groups{$groupname});
+	&Apache::longroup::get_group_settings($curr_groups{$groupname});
 
     my %stored;
 
@@ -849,12 +853,14 @@
     $stored{'autodrop'} = $groupinfo{'autodrop'};
     if (exists($groupinfo{'autosec'})) {
 	foreach my $role (sort(keys(%{$groupinfo{'autosec'}}))) {
-	    foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
-		push (@{$stored{'sec_'.$role}},$section);
-	    }
-	    if (@{$groupinfo{'autosec'}{$role}} > 0) {
-		push(@{$stored{'autorole'}},$role);
-	    }
+            if (ref($groupinfo{'autosec'}{$role}) eq 'ARRAY') {
+	        foreach my $section (@{$groupinfo{'autosec'}{$role}}) {
+	            push (@{$stored{'sec_'.$role}},$section);
+	        }
+	        if (@{$groupinfo{'autosec'}{$role}} > 0) {
+		    push(@{$stored{'autorole'}},$role);
+	        }
+            }
 	}
     }
     return %stored;
@@ -1247,8 +1253,8 @@
     $r->print(&Apache::lonhtmlcommon::role_select_row(\@roles));
     if (@sections > 0) {
         @sections = sort {$a cmp $b} @sections;
-        unshift(@sections,'_all'); # Put 'all' at the front of the list
-        unshift(@sections,'_nosec'); # Put 'no sections' next
+        unshift(@sections,'all'); # Put 'all' at the front of the list
+        unshift(@sections,'none'); # Put 'no sections' next
         $r->print('<td>&nbsp;</td>
                    <td colspan="3" align="center" valign="top">'.
         &sections_selection(\@sections,'sectionpick').'</td>');
@@ -1269,9 +1275,9 @@
         $numvisible = @{$sections};
     }
     foreach my $sec (@{$sections}) {
-        if ($sec eq '_all') {
+        if ($sec eq 'all') {
             $section_sel .= '  <option value="'.$sec.'" />all sections'."\n";
-        } elsif ($sec eq '_nosec') {
+        } elsif ($sec eq 'none') {
             $section_sel .= '  <option value="'.$sec.'" />no section'."\n"; 
         } else {
             $section_sel .= '  <option value="'.$sec.'" />'.$sec."\n";
@@ -2588,7 +2594,9 @@
         }
         $specificity = $env{'form.specificity'};
     } else {
-        @defprivs = @{$$stored{'defpriv'}};
+        if (defined($$stored{'defpriv'})) {
+            @defprivs = @{$$stored{'defpriv'}};
+        }
         $specificity = $$stored{'specificity'};
     }
     my @showtools;
@@ -2772,7 +2780,9 @@
             @defprivs = @temp; 
         }
     } else {
-        @defprivs = @{$$stored{'defpriv'}};
+        if (defined($$stored{'defpriv'})) {
+            @defprivs = @{$$stored{'defpriv'}};
+        }
     }
 
     my $outcome;
@@ -2852,9 +2862,6 @@
         if (defined($env{'form.sec_'.$role})) {
             my @autosections=&Apache::loncommon::get_env_multiple('form.sec_'.
                                                                   $role);
-            if (grep/^_all$/,@autosections) {
-                @autosections = sort {$a cmp $b} keys(%{$sectioncount});
-            }
             $autosec .= '<role id="'.$role.'">';
             foreach my $sec (@autosections) {
                 $autosec .= '<section>'.$sec.'</section>';
@@ -3055,9 +3062,9 @@
         }
     }
     if ($roster_result eq 'ok') {
-        $r->print('<br />Group membership list updated.');
+        $r->print('<br />'.&mt('Group membership list updated.'));
     } else {
-        $r->print('<br />An error occurred while updating the group membership list -'.$roster_result.'<br />');
+        $r->print('<br />'.&mt('An error occurred while updating the group membership list -').$roster_result.'<br />');
     }
     return;
 }
@@ -3115,7 +3122,7 @@
    <td>&nbsp;</td>
    <td colspan="3">
    <nobr>'.$$lt{'auad'}.':&nbsp;
-    <input type="radio" name="autoadd" value="on" />on&nbsp;&nbsp;<input type="radio" name="autoadd" value="off" />off');
+    <input type="radio" name="autoadd" value="on" />on&nbsp;&nbsp;<input type="radio" name="autoadd" value="off" checked="checked" />off');
     if ($action eq 'modify') {
         $r->print('&nbsp;&nbsp;&nbsp;&nbsp;('.$$lt{'curr'}.' <b>'.$$lt{$add}.'</b>)');
     }
@@ -3127,7 +3134,7 @@
    <td>&nbsp;</td>
    <td colspan="3">
     <nobr>'.$$lt{'auex'}.':&nbsp;
-    <input type="radio" name="autodrop" value="on" />on&nbsp;&nbsp;<input type="radio" name="autodrop" value="off" />off');
+    <input type="radio" name="autodrop" value="on" />on&nbsp;&nbsp;<input type="radio" name="autodrop" value="off" checked="checked" />off');
     if ($action eq 'modify') {
         $r->print('&nbsp;&nbsp;&nbsp;&nbsp;('.$$lt{'curr'}.' <b>'.$$lt{$drop}.'</b>)');
     }
@@ -3150,8 +3157,8 @@
     my @sections = keys(%{$sectioncount});
     if (@sections > 0) {
         @sections = sort {$a cmp $b} @sections;
-        unshift(@sections,'_nosec'); # Put 'no sections' next
-        unshift(@sections,'_all'); # Put 'all' at the front of the list
+        unshift(@sections,'none'); # Put 'no sections' next
+        unshift(@sections,'all'); # Put 'all' at the front of the list
     }
     &topic_bar($r,$tabcol,$image,$$lt{'pirs'});
     $r->print('
@@ -3175,8 +3182,15 @@
         my $plrole=&Apache::lonnet::plaintext($role);
         my $sections_sel;
         if (@sections > 0) {
-            $sections_sel='<td>'.&sections_selection(\@sections,'sec_'.$role).
-                                                                       '</td>';
+            if ($role eq 'cc') {
+                $sections_sel = '<td align="right">'.
+                                &mt('all sections').'<input type="hidden" '. 
+                                'name="sec_cc" value="all" /></td>';
+            } else { 
+                $sections_sel='<td align="right">'.
+                              &sections_selection(\@sections,'sec_'.$role).
+                              '</td>';
+            }
         }
         if ($rowNum %2 == 1) {
             $rowColor = $rowColor1;
@@ -3209,7 +3223,7 @@
 }
 
 sub standard_roles {
-    my @roles = ('st','ep','ta','in','cc');
+    my @roles = ('cc','in','ta','ep','st');
     return @roles;
 }
 
@@ -3410,7 +3424,7 @@
 sub validate_groupname {
     my ($groupname,$action,$cdom,$cnum) = @_;
     my %sectioncount = &Apache::loncommon::get_sections($cdom,$cnum);
-    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+    my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
 
     my %lt = &Apache::lonlocal::texthash (
                       igna => 'Invalid group name',
Index: loncom/interface/longroupchat.pm
diff -u loncom/interface/longroupchat.pm:1.5 loncom/interface/longroupchat.pm:1.6
--- loncom/interface/longroupchat.pm:1.5	Tue May  9 10:38:10 2006
+++ loncom/interface/longroupchat.pm	Wed May 17 21:08:50 2006
@@ -29,6 +29,7 @@
 use Apache::lonnet;
 use Apache::loncommon;
 use Apache::lonlocal;
+use Apache::longroup;
 
 sub handler {
     my ($r) = @_;
@@ -38,10 +39,10 @@
     if (defined($group)) {
         my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
         my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
-        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum,$group);
+        my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum,$group);
         if (%curr_groups) {
             my %group_info = 
-		&Apache::loncommon::get_group_settings($curr_groups{$group});
+		&Apache::longroup::get_group_settings($curr_groups{$group});
             $grouptitle = &mt('Group Chat:').' '.
 		&Apache::lonnet::unescape($group_info{description});
         }
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.16 loncom/interface/lonpickstudent.pm:1.17
--- loncom/interface/lonpickstudent.pm:1.16	Tue May  9 10:38:10 2006
+++ loncom/interface/lonpickstudent.pm	Wed May 17 21:08:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a student from the classlist
 #
-# $Id: lonpickstudent.pm,v 1.16 2006/05/09 14:38:10 albertel Exp $
+# $Id: lonpickstudent.pm,v 1.17 2006/05/18 01:08:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::loncoursedata;
 use Apache::lonnet;
 use Apache::lonlocal;
+use Apache::longroup;
 
 sub handler {
     my $r = shift;
@@ -76,7 +77,7 @@
     my $classlist=&Apache::loncoursedata::get_classlist();
     my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum);
     my $now = time;
-    my %allgroups = &Apache::loncommon::coursegroups($cdom,$cnum);
+    my %allgroups = &Apache::longroup::coursegroups($cdom,$cnum);
 
 # --------------------------------------- There is such a user, get environment
 
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.45 loncom/interface/lonpickcourse.pm:1.46
--- loncom/interface/lonpickcourse.pm:1.45	Tue May  9 11:09:27 2006
+++ loncom/interface/lonpickcourse.pm	Wed May 17 21:08:50 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.45 2006/05/09 15:09:27 albertel Exp $
+# $Id: lonpickcourse.pm,v 1.46 2006/05/18 01:08:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -34,6 +34,7 @@
 use Apache::loncoursedata;
 use Apache::lonnet;
 use Apache::lonlocal;
+use Apache::longroup;
 
 sub handler {
     my $r = shift;
@@ -106,7 +107,7 @@
         my @sections =  (sort {$a <=> $b} keys(%sections_count));
 	$seclist = join('","',@sections);
 
-        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+        my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
 	$groupslist = join(',',sort(keys(%curr_groups)));
     }
     my $jscript;
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.134 loncom/interface/lonstatistics.pm:1.135
--- loncom/interface/lonstatistics.pm:1.134	Thu May 11 16:05:02 2006
+++ loncom/interface/lonstatistics.pm	Wed May 17 21:08:50 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.134 2006/05/11 20:05:02 raeburn Exp $
+# $Id: lonstatistics.pm,v 1.135 2006/05/18 01:08:50 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,6 +63,7 @@
 use Apache::lonhtmlcommon;
 use Apache::lonmysql;
 use Apache::lonlocal;
+use Apache::longroup;
 use Time::HiRes;
 #
 # Statistics Packages
@@ -231,7 +232,7 @@
     #
     # Get groupmembership
     my ($classgroups,$studentgroups);
-    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+    my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
     if (%curr_groups) {
         ($classgroups,$studentgroups) = 
 	    &Apache::loncoursedata::get_group_memberships($classlist,
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.116 loncom/interface/loncreateuser.pm:1.117
--- loncom/interface/loncreateuser.pm:1.116	Tue May  9 13:21:13 2006
+++ loncom/interface/loncreateuser.pm	Wed May 17 21:08:51 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.116 2006/05/09 17:21:13 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.117 2006/05/18 01:08:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -64,6 +64,7 @@
 use Apache::lonnet;
 use Apache::loncommon;
 use Apache::lonlocal;
+use Apache::longroup;
 
 my $loginscript; # piece of javascript used in two separate instances
 my $generalrule;
@@ -305,7 +306,7 @@
     my %loaditem;
 
     my $groupslist;
-    my %curr_groups = &Apache::loncommon::coursegroups();
+    my %curr_groups = &Apache::longroup::coursegroups();
     if (%curr_groups) {
         $groupslist = join('","',sort(keys(%curr_groups)));
         $groupslist = '"'.$groupslist.'"';   
@@ -1328,7 +1329,7 @@
                     $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
                 } else {
 		    my %curr_groups =
-			&Apache::loncommon::coursegroups($one,$two);
+			&Apache::longroup::coursegroups($one,$two);
                     foreach my $sec (sort {$a cmp $b} keys %sections) {
                         if (($sec eq 'none') || ($sec eq 'all') || 
                             exists($curr_groups{$sec})) {
@@ -1358,7 +1359,7 @@
                     $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
                 } else {
                     my %curr_groups = 
-			&Apache::loncommon::coursegroups($one,$two);
+			&Apache::longroup::coursegroups($one,$two);
                     my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys %sections) {
                         $sec =~ s/\W//g;
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.170 loncom/interface/loncoursedata.pm:1.171
--- loncom/interface/loncoursedata.pm:1.170	Thu May 11 16:05:03 2006
+++ loncom/interface/loncoursedata.pm	Wed May 17 21:08:51 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.170 2006/05/11 20:05:03 raeburn Exp $
+# $Id: loncoursedata.pm,v 1.171 2006/05/18 01:08:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -51,6 +51,7 @@
 use strict;
 use Apache::lonnet;
 use Apache::lonhtmlcommon;
+use Apache::longroup;
 use Time::HiRes;
 use Apache::lonmysql;
 use HTML::TokeParser;
@@ -965,7 +966,7 @@
     my $dbh = &Apache::lonmysql::get_dbh();
     my $cdom = $env{'course.'.$courseid.'.domain'};
     my $cnum = $env{'course.'.$courseid.'.num'};
-    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+    my %curr_groups = &Apache::longroup::coursegroups($cdom,$cnum);
     return if (!%curr_groups);
     my $request = 'INSERT IGNORE INTO '.$groupnames_table.
                   '(groupname) VALUES ';
@@ -3152,7 +3153,7 @@
     my (%classgroups,%studentgroups);
     my $now = time;
     my $access_end = $env{'course.'.$cid.'.default_enrollment_end_date'};
-    my %curr_groups =&Apache::loncommon::coursegroups($cdom,$cnum);
+    my %curr_groups =&Apache::longroup::coursegroups($cdom,$cnum);
     if (%curr_groups) {
         my $grpindex = scalar(@{$keylist});
         my %groupmemberhash = 
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.150 loncom/interface/lonhelper.pm:1.151
--- loncom/interface/lonhelper.pm:1.150	Tue May 16 16:45:26 2006
+++ loncom/interface/lonhelper.pm	Wed May 17 21:08:51 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.150 2006/05/16 20:45:26 albertel Exp $
+# $Id: lonhelper.pm,v 1.151 2006/05/18 01:08:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -183,6 +183,7 @@
 use Apache::lonxml;
 use Apache::lonlocal;
 use Apache::lonnet;
+use Apache::longroup;
 use Apache::lonselstudent;
 
 # Register all the tags with the helper, so the helper can 
@@ -2848,7 +2849,7 @@
     return if ($token->[2]{'onlysections'});
 
     # add in groups to the end of the list
-    my %curr_groups = &Apache::loncommon::coursegroups();
+    my %curr_groups = &Apache::longroup::coursegroups();
     foreach my $group_name (sort(keys(%curr_groups))) {
 	push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
     }
@@ -2912,7 +2913,7 @@
     # Populate the CHOICES element
     my %choices;
 
-    my %curr_groups = &Apache::loncommon::coursegroups();
+    my %curr_groups = &Apache::longroup::coursegroups();
     foreach my $group_name (sort {lc($a) cmp lc($b)} (keys(%curr_groups))) {
 	push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
     }
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.142 loncom/interface/londropadd.pm:1.143
--- loncom/interface/londropadd.pm:1.142	Thu May 11 16:09:47 2006
+++ loncom/interface/londropadd.pm	Wed May 17 21:08:51 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to drop and add students in courses 
 #
-# $Id: londropadd.pm,v 1.142 2006/05/11 20:09:47 raeburn Exp $
+# $Id: londropadd.pm,v 1.143 2006/05/18 01:08:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -39,6 +39,7 @@
 use Spreadsheet::WriteExcel;
 use Apache::lonstathelpers();
 use Apache::lonlocal;
+use Apache::longroup;
 
 ###############################################################
 ###############################################################
@@ -77,7 +78,7 @@
             } elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
                 my (undef,$end,$start)=split(/\_/,$roles{$course});
                 my $now=time;
-                # if this is an active role 
+                # if this is an active role
                 if (!($start && ($now<$start)) || !($end && ($now>$end))) {
                     my $reply=&Apache::lonnet::modifystudent
                         # dom  name  id mode pass     f     m     l     g
@@ -1936,7 +1937,7 @@
     my $cdom = $env{'course.'.$cid.'.domain'};
     my $cnum = $env{'course.'.$cid,'.num'};
     my ($classgroups) = &Apache::loncoursedata::get_group_memberships(
-                                                      $classlist,$cdom,$cnum);
+                                              $classlist,$keylist,$cdom,$cnum);
     #
     my $action = "drop";
     $r->print(<<END);
@@ -2198,7 +2199,7 @@
         my $flushc=0;
         my %student=();
         # Get information about course groups
-        my %curr_groups = &Apache::loncommon::coursegroups();
+        my %curr_groups = &Apache::longroup::coursegroups();
         # Get new classlist
         foreach (@studentdata) {
             my %entries=&Apache::loncommon::record_sep($_);
@@ -2367,7 +2368,7 @@
 
 sub section_check_js {
     my $groupslist;
-    my %curr_groups = &Apache::loncommon::coursegroups();
+    my %curr_groups = &Apache::longroup::coursegroups();
     if (%curr_groups) {
         $groupslist = join('","',sort(keys(%curr_groups)));
     }
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.306 loncom/interface/lonparmset.pm:1.307
--- loncom/interface/lonparmset.pm:1.306	Tue May 16 16:43:57 2006
+++ loncom/interface/lonparmset.pm	Wed May 17 21:08:51 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.306 2006/05/16 20:43:57 albertel Exp $
+# $Id: lonparmset.pm,v 1.307 2006/05/18 01:08:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -63,6 +63,7 @@
 use Apache::lonxml;
 use Apache::lonlocal;
 use Apache::lonnavmaps;
+use Apache::longroup;
 use Apache::lonrss;
 
 # --- Caches local to lonparmset
@@ -1125,7 +1126,7 @@
     my %sectionhash = &Apache::loncommon::get_sections();
 
     my $groups;
-    my %grouphash = &Apache::loncommon::coursegroups();
+    my %grouphash = &Apache::longroup::coursegroups();
 
     if (%sectionhash) {
         $sections=$lt{'se'}.': <select name="csec"';
@@ -1265,7 +1266,7 @@
 
 sub groupmenu {
     my ($r,$selectedgroups)=@_;
-    my %grouphash = &Apache::loncommon::coursegroups();
+    my %grouphash = &Apache::longroup::coursegroups();
     return if (!%grouphash);
 
     $r->print('<select name="Group" multiple="true" size="8" >');
Index: loncom/interface/lonpopulate.pm
diff -u loncom/interface/lonpopulate.pm:1.42 loncom/interface/lonpopulate.pm:1.43
--- loncom/interface/lonpopulate.pm:1.42	Tue May 16 17:56:14 2006
+++ loncom/interface/lonpopulate.pm	Wed May 17 21:08:51 2006
@@ -1,5 +1,5 @@
 # automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.42 2006/05/16 21:56:14 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.43 2006/05/18 01:08:51 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,6 +32,7 @@
 use Apache::lonhtmlcommon;
 use Apache::lonlocal;
 use Apache::loncoursedata;
+use Apache::longroup;
 use Apache::Constants qw(:common :http REDIRECT);
 use Time::Local;
 use LONCAPA::Enrollment;
@@ -1748,7 +1749,7 @@
     }
 
     if ($numcross > 0) {
-        my %curr_groups = &Apache::loncommon::coursegroups();
+        my %curr_groups = &Apache::longroup::coursegroups();
 	for (my $i=0; $i<$numcross; $i++) {
 	    my $xl = "newcross_".$i;
 	    my $lc_sec = "newlcsec_".$i;
@@ -2065,7 +2066,7 @@
     }
     
     if ($numsec > 0) {
-        my %curr_groups = &Apache::loncommon::coursegroups();
+        my %curr_groups = &Apache::longroup::coursegroups();
 	for (my $i=0; $i<$numsec; $i++) {
 	    my $sec = "newsec_".$i;
 	    my $lc_sec = "newlcsec_".$i;
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.98 loncom/interface/portfolio.pm:1.99
--- loncom/interface/portfolio.pm:1.98	Tue May  9 10:38:10 2006
+++ loncom/interface/portfolio.pm	Wed May 17 21:08:52 2006
@@ -30,6 +30,7 @@
 use Apache::lonfeedback;
 use Apache::lonlocal;
 use Apache::lonnet;
+use Apache::longroup;
 
 # receives a file name and path stub from username/userfiles/portfolio/
 # returns an anchor tag consisting encoding filename and currentpath
@@ -501,7 +502,6 @@
     } else {
         my $result=&Apache::lonnet::userfileupload('uploaddoc','',
 	        	 $port_path.$env{'form.currentpath'});
-        print STDERR "result was $result for $port_path.$env{'form.currentpath'}\n";
         if ($result !~ m|^/uploaded/|) {
             $r->print('<font color="red"> An errror occured ('.$result.
 	              ') while trying to upload '.&display_file().'</font><br />');
@@ -650,7 +650,7 @@
         $group =~ s/\W//g;
         if ($group) {
             ($uname,$udom) = &get_name_dom($group);
-            my %curr_groups = &Apache::loncommon::coursegroups($udom,$uname,
+            my %curr_groups = &Apache::longroup::coursegroups($udom,$uname,
 							       $group); 
             if (%curr_groups) {
                 if (($view_permission) || (&Apache::lonnet::allowed('rgf',
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.738 loncom/lonnet/perl/lonnet.pm:1.739
--- loncom/lonnet/perl/lonnet.pm:1.738	Tue May 16 14:50:55 2006
+++ loncom/lonnet/perl/lonnet.pm	Wed May 17 21:08:54 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.738 2006/05/16 18:50:55 albertel Exp $
+# $Id: lonnet.pm,v 1.739 2006/05/18 01:08:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3982,7 +3982,6 @@
     if ($result eq 'ok') {
         &devalidate_getgroups_cache($udom,$uname,$cdom,$cnum);
     }
-
     return $result;
 }
 
@@ -4125,6 +4124,8 @@
            $command.='_0_'.$start;
         }
     }
+    my $origstart = $start;
+    my $origend = $end;
 # actually delete
     if ($deleteflag) {
 	if ((&allowed('dro',$udom)) || (&allowed('dro',$url))) {
@@ -4142,6 +4143,11 @@
 # log new user role if status is ok
     if ($answer eq 'ok') {
 	&userrolelog($role,$uname,$udom,$url,$start,$end);
+# for course roles, perform group memberships changes triggered by role change.
+        unless ($role =~ /^gr/) {
+            &Apache::longroup::group_changes($udom,$uname,$url,$role,$origend,
+                                             $origstart);
+        }
     }
     return $answer;
 }
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.483 doc/loncapafiles/loncapafiles.lpml:1.484
--- doc/loncapafiles/loncapafiles.lpml:1.483	Wed May 17 18:24:50 2006
+++ doc/loncapafiles/loncapafiles.lpml	Wed May 17 21:09:03 2006
@@ -2,7 +2,7 @@
  "http://lpml.sourceforge.net/DTD/lpml.dtd">
 <!-- loncapafiles.lpml -->
 
-<!-- $Id: loncapafiles.lpml,v 1.483 2006/05/17 22:24:50 albertel Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.484 2006/05/18 01:09:03 raeburn Exp $ -->
 
 <!--
 
@@ -3906,6 +3906,15 @@
 <status>works/unverified</status>
 </file>
 <file>
+<source>loncom/interface/longroup.pm</source>
+<target dist='default'>home/httpd/lib/perl/Apache/longroup.pm</target>
+<categoryname>handler</categoryname>
+<description>
+General routines used to gather information about courses in a group, and their settings, and also to perform auto-group adds/drops when a user's role assignment changes.    
+</description>
+<status>works/unverified</status>
+</file>
+<file>
 <source>loncom/interface/lonmsg.pm</source>
 <target dist='default'>home/httpd/lib/perl/Apache/lonmsg.pm</target>
 <categoryname>handler</categoryname>
Index: loncom/enrollment/Autoenroll.pl
diff -u loncom/enrollment/Autoenroll.pl:1.19 loncom/enrollment/Autoenroll.pl:1.20
--- loncom/enrollment/Autoenroll.pl:1.19	Wed May 17 10:48:49 2006
+++ loncom/enrollment/Autoenroll.pl	Wed May 17 21:09:14 2006
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 #
 #Automated Enrollment script
-# $Id: Autoenroll.pl,v 1.19 2006/05/17 14:48:49 albertel Exp $
+# $Id: Autoenroll.pl,v 1.20 2006/05/18 01:09:14 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -33,6 +33,7 @@
     use Apache::lonnet;
     use Apache::loncoursedata;
     use Apache::lonmsg;
+    use Apache::longroup;
     use HTML::Entities;
 
 # Determine the library server's domain and hostID

--raeburn1147914555--