[LON-CAPA-cvs] cvs: loncom /interface lonchatfetch.pm loncommon.pm loncoursedata.pm loncoursegroups.pm loncreateuser.pm longroupchat.pm lonhelper.pm lonparmset.pm lonpickcourse.pm lonpickstudent.pm lonsimplepage.pm lonstatistics.pm portfolio.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 09 May 2006 14:38:12 -0000


This is a MIME encoded message

--albertel1147185492
Content-Type: text/plain

albertel		Tue May  9 10:38:12 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonchatfetch.pm loncoursedata.pm 
                     	loncoursegroups.pm loncreateuser.pm 
                     	longroupchat.pm lonhelper.pm lonparmset.pm 
                     	lonpickcourse.pm lonpickstudent.pm 
                     	lonsimplepage.pm lonstatistics.pm portfolio.pm 
  Log:
  - changing loncommon::coursegroups to be easier to use
  
  
--albertel1147185492
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060509103812.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.364 loncom/interface/loncommon.pm:1.365
--- loncom/interface/loncommon.pm:1.364	Mon May  8 18:34:00 2006
+++ loncom/interface/loncommon.pm	Tue May  9 10:38:09 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.364 2006/05/08 22:34:00 albertel Exp $
+# $Id: loncommon.pm,v 1.365 2006/05/09 14:38:09 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3820,25 +3820,24 @@
 ###############################################
 
 sub coursegroups {
-    my ($curr_groups,$cdom,$cnum,$group) = @_;
-    my $numgroups;
+    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'};
     }
-    %{$curr_groups} = &Apache::lonnet::get_coursegroups($cdom,$cnum,$group);
-    my ($tmp) = keys(%{$curr_groups});
-    if ($tmp=~/^error:/) {
-        unless ($tmp eq 'error: 2 tie(GDBM) Failed while attempting dump') {
-            &logthis('Error retrieving groups: '.$tmp.' in '.$cnum.':'.
-                                                                   $cdom);
-        }
-        $numgroups = 0;
-    } else {
-        $numgroups = keys(%{$curr_groups});
+    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 $numgroups;
+    return %curr_groups;
 }
 
 ###############################################
Index: loncom/interface/lonchatfetch.pm
diff -u loncom/interface/lonchatfetch.pm:1.22 loncom/interface/lonchatfetch.pm:1.23
--- loncom/interface/lonchatfetch.pm:1.22	Wed Mar 29 16:16:18 2006
+++ loncom/interface/lonchatfetch.pm	Tue May  9 10:38:09 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Chat Fetching
 #
-# $Id: lonchatfetch.pm,v 1.22 2006/03/29 21:16:18 albertel Exp $
+# $Id: lonchatfetch.pm,v 1.23 2006/05/09 14:38:09 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -48,10 +48,8 @@
 				       $group) ) {
             return HTTP_NOT_ACCEPTABLE;
         }
-        my %curr_groups;
-        my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
-							 $cnum,$group);
-        if ($numgroups) {
+        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum,$group);
+        if (%curr_groups) {
             my %group_info = 
 		&Apache::loncommon::get_group_settings($curr_groups{$group});
             $grouptitle = 
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.168 loncom/interface/loncoursedata.pm:1.169
--- loncom/interface/loncoursedata.pm:1.168	Fri May  5 17:35:31 2006
+++ loncom/interface/loncoursedata.pm	Tue May  9 10:38:09 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.168 2006/05/05 21:35:31 raeburn Exp $
+# $Id: loncoursedata.pm,v 1.169 2006/05/09 14:38:09 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -965,9 +965,8 @@
     my $dbh = &Apache::lonmysql::get_dbh();
     my $cdom = $env{'course.'.$courseid.'.domain'};
     my $cnum = $env{'course.'.$courseid.'.num'};
-    my %curr_groups;
-    my $numgrps = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum);
-    return if (!$numgrps);
+    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+    return if (!%curr_groups);
     my $request = 'INSERT IGNORE INTO '.$groupnames_table.
                   '(groupname) VALUES ';
     foreach my $groupname (sort(keys(%curr_groups)),'none') {
@@ -3152,11 +3151,10 @@
     my (%classgroups,%studentgroups);
     my $now = time;
     my $access_end = $env{'course.'.$cid.'.default_enrollment_end_date'};
-    my (%curr_groups,%groupmemberhash);
-    my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
-                                                     $cnum);
-    if ($numgroups) {
-        %groupmemberhash = &Apache::lonnet::get_group_membership($cdom,$cnum);
+    my %curr_groups =&Apache::loncommon::coursegroups($cdom,$cnum);
+    if (%curr_groups) {
+        my %groupmemberhash = 
+	    &Apache::lonnet::get_group_membership($cdom,$cnum);
         foreach my $student (keys(%{$classlist})) {
             %{$classgroups{$student}} = ();
             my $hasgroup = 0;
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.14 loncom/interface/loncoursegroups.pm:1.15
--- loncom/interface/loncoursegroups.pm:1.14	Mon May  1 15:37:33 2006
+++ loncom/interface/loncoursegroups.pm	Tue May  9 10:38:09 2006
@@ -37,7 +37,7 @@
 
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
-                                                                                
+
     if ($r->header_only) {
         return OK;
     }
@@ -154,8 +154,8 @@
         if (!defined($action)) {
             $action = 'view';
         }
-        my %curr_groups;
-        if (&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum)) {
+        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+        if (%curr_groups) {
             $r->print('<br /><br />');
             $r->print(&Apache::lonhtmlcommon::start_pick_box());
             $r->print(<<"END");
@@ -267,8 +267,8 @@
         my @coursegroups = split(/:/,$env{'request.course.groups'});
         if (@coursegroups > 0) {
             $r->print('<br /><br />');
-            my %curr_groups;
-            if (&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum)) {
+            my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+            if (%curr_groups) {
                 foreach my $group (@coursegroups) {
                     my %group_info =  &Apache::loncommon::get_group_settings(
                                         $curr_groups{$group});
@@ -688,7 +688,7 @@
     document.$state.sortby.value = caller;
     document.$state.submit();
 } 
-                                                                                      
+
 |;
     $jscript .= &Apache::lonhtmlcommon::set_form_elements(
                            \%{$elements{$action}{$state}},\%stored);
@@ -808,55 +808,55 @@
 
 sub retrieve_settings {
     my ($cdom,$cnum,$groupname) = @_;
-    my %groupinfo;
+    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum,$groupname);
+
+    return if (!%curr_groups);
+
+    my %groupinfo = 
+	&Apache::loncommon::get_group_settings($curr_groups{$groupname});
+
     my %stored;
-    my %curr_groups;
-    my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
-                                                             $cnum,$groupname);
-    if ($numgroups > 0) {
-        %groupinfo = &Apache::loncommon::get_group_settings(
-                                                     $curr_groups{$groupname});
-        $stored{'description'} = &Apache::lonnet::unescape(
-                                                    $groupinfo{'description'});
-        $stored{'startdate'} = $groupinfo{'startdate'};
-        $stored{'enddate'} = $groupinfo{'enddate'};
-        if ($stored{'enddate'} == 0) {
-            $stored{'no_end_date'} = 1;
-        }
-        $stored{'granularity'} = $groupinfo{'granularity'};
-        $stored{'specificity'} = $groupinfo{'specificity'};
-        $stored{'creation'} = $groupinfo{'creation'};
-        $stored{'creator'} = $groupinfo{'creator'};
-
-        foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
-            if ($groupinfo{functions}{$tool} eq 'on') {
-                push(@{$stored{tool}},$tool);
-            }
-        }
-        foreach my $role (@{$groupinfo{'roles'}}) {
-            push(@{$stored{roles}},$role);
-        }
-        foreach my $type (@{$groupinfo{'types'}}) {
-            push(@{$stored{types}},$type);
-        }
-        foreach my $section (@{$groupinfo{'sectionpick'}}) {
-            push(@{$stored{sectionpick}},$section);
-        }
-        foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
-            push(@{$stored{defpriv}},$defpriv);
-        }
-        $stored{'autoadd'} = $groupinfo{'autoadd'};
-        $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);
-                }
-            }
-        }
+
+    $stored{'description'} = 
+	&Apache::lonnet::unescape($groupinfo{'description'});
+    $stored{'startdate'} = $groupinfo{'startdate'};
+    $stored{'enddate'} = $groupinfo{'enddate'};
+    if ($stored{'enddate'} == 0) {
+	$stored{'no_end_date'} = 1;
+    }
+    $stored{'granularity'} = $groupinfo{'granularity'};
+    $stored{'specificity'} = $groupinfo{'specificity'};
+    $stored{'creation'} = $groupinfo{'creation'};
+    $stored{'creator'} = $groupinfo{'creator'};
+
+    foreach my $tool (sort(keys(%{$groupinfo{'functions'}}))) {
+	if ($groupinfo{functions}{$tool} eq 'on') {
+	    push(@{$stored{tool}},$tool);
+	}
+    }
+    foreach my $role (@{$groupinfo{'roles'}}) {
+	push(@{$stored{roles}},$role);
+    }
+    foreach my $type (@{$groupinfo{'types'}}) {
+	push(@{$stored{types}},$type);
+    }
+    foreach my $section (@{$groupinfo{'sectionpick'}}) {
+	push(@{$stored{sectionpick}},$section);
+    }
+    foreach my $defpriv (@{$groupinfo{'defpriv'}}) {
+	push(@{$stored{defpriv}},$defpriv);
+    }
+    $stored{'autoadd'} = $groupinfo{'autoadd'};
+    $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);
+	    }
+	}
     }
     return %stored;
 }
@@ -1212,7 +1212,7 @@
                    previous => &mt('Previously had access'),
                    future => &mt('Will have future access'),
                    );
-                                                                                 
+
     my @roles = ('st','cc','in','ta','ep','cr');
 
     my @sections = keys(%{$sectioncount});
@@ -2308,7 +2308,7 @@
                         $r->print('<td align="left"><small>');
                         if ($granularity eq 'Yes') {
                             foreach my $tool (@{$current{$user}{newtools}}) {
-                                $r->print('<nobr><label><input type="checkbox"  
+                                $r->print('<nobr><label><input type="checkbox"
                                           name="user_'.$tool.'" value="'.
                                           $user.'" />'.$tool.
                                           '</label></nobr>&nbsp;&nbsp;&nbsp;');
@@ -2711,7 +2711,6 @@
                           '<br />');
                 &display_defprivs($r,$tabcol,$rowColor1,$rowColor2,$tools,
                             $toolprivs,\@defprivs);
-                                                                                      
             }
         } else {
             if (keys(%{$usertools}) > 0) {
@@ -2810,7 +2809,7 @@
                              'creation','modified','creator','granularity',
                              'specificity','autoadd','autodrop');
     my @mult_attributes = ('roles','types','sectionpick','defpriv');
-                                                                                    
+
     my %groupinfo = (
                      description => $esc_description,
                      startdate => $startdate,
@@ -2849,7 +2848,7 @@
     }
     my $autosec;
     my @autorole = &Apache::loncommon::get_env_multiple('form.autorole');
-                                                                                    
+
     foreach my $role (@autorole) {
         if (defined($env{'form.sec_'.$role})) {
             my @autosections=&Apache::loncommon::get_env_multiple('form.sec_'.
@@ -3413,9 +3412,8 @@
     my ($groupname,$action,$cdom,$cnum) = @_;
     my %sectioncount;
     my $numsec=&Apache::loncommon::get_sections($cdom,$cnum,\%sectioncount);
-    my %curr_groups;
-    my $numgroups=&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum);
-                                                                                         
+    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+
     my %lt = &Apache::lonlocal::texthash (
                       igna => 'Invalid group name',
                       tgne => 'The group name entered ',
@@ -3429,7 +3427,7 @@
                       thgr => '- does not correspond to the name of an existing'.  
                               ' group ',    
     );
-                                                                                         
+
     my $exitmsg = '<b>'.$lt{'igna'}.'</b><br /><br />'.$lt{'tgne'}.' "'.
                   $groupname.'" ';
     my $dupmsg = $lt{'grna'};
@@ -3445,14 +3443,12 @@
             return $earlyout;
         }
     }
-    if ($action eq 'create') {
-        if ($numgroups) {
-            if (exists($curr_groups{$groupname})) {
-                $earlyout = $exitmsg.$lt{'cnnb'}.&mt('an existing group').
-                            $lt{'inth'}.'<br />'.$lt{'grna'};
-                return $earlyout;
-            }
-        }
+    if ($action eq 'create' 
+	&& exists($curr_groups{$groupname})) {
+
+	return $exitmsg.$lt{'cnnb'}.&mt('an existing group').
+	    $lt{'inth'}.'<br />'.$lt{'grna'};
+
     } elsif ($action eq 'modify') {
         unless(exists($curr_groups{$groupname})) {
             $earlyout = &mt('Group name:').' '.$groupname.$lt{'thgr'}.$lt{'inth'};
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.113 loncom/interface/loncreateuser.pm:1.114
--- loncom/interface/loncreateuser.pm:1.113	Mon May  8 17:40:20 2006
+++ loncom/interface/loncreateuser.pm	Tue May  9 10:38:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.113 2006/05/08 21:40:20 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.114 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -302,17 +302,14 @@
     my $dc_setcourse_code = '';
     my $nondc_setsection_code = '';
     my %loaditem;
-    my (%curr_groups,$groupslist,$numgroups);
-    if (exists($env{'request.course.id'})) {
-        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-        $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
-                                                         $cnum);
-    }
-    if ($numgroups > 0) {
+
+    my $groupslist;
+    my %curr_groups = &Apache::loncommon::coursegroups();
+    if (%curr_groups) {
         $groupslist = join('","',sort(keys(%curr_groups)));
         $groupslist = '"'.$groupslist.'"';   
     }
+
     if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
         my $dcdom = $1;
         $loaditem{'onload'} = "document.cu.coursedesc.value=''";
@@ -1209,7 +1206,6 @@
         }
     }
     ##
-    my %curr_groups;
     my $now=time;
     $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
     foreach (keys (%env)) {
@@ -1310,8 +1306,8 @@
                 if ($num_sections == 0) {
                     $r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end));
                 } else {
-                    my $numgrp=&Apache::loncommon::coursegroups(\%curr_groups,
-                                                                $one,$two);
+		    my %curr_groups =
+			&Apache::loncommon::coursegroups($one,$two);
                     foreach my $sec (sort {$a cmp $b} keys %sections) {
                         if (($sec eq 'none') || ($sec eq 'all') || 
                             exists($curr_groups{$sec})) {
@@ -1340,8 +1336,8 @@
                 if ($num_sections == 0) {
                     $r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,''));
                 } else {
-                    my $numgrp=&Apache::loncommon::coursegroups(\%curr_groups,
-                                                                $one,$two);
+                    my %curr_groups = 
+			&Apache::loncommon::coursegroups($one,$two);
                     my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys %sections) {
                         $sec =~ s/\W//g;
Index: loncom/interface/longroupchat.pm
diff -u loncom/interface/longroupchat.pm:1.4 loncom/interface/longroupchat.pm:1.5
--- loncom/interface/longroupchat.pm:1.4	Thu Apr 13 16:56:54 2006
+++ loncom/interface/longroupchat.pm	Tue May  9 10:38:10 2006
@@ -38,10 +38,8 @@
     if (defined($group)) {
         my $cnum=$env{'course.'.$env{'request.course.id'}.'.num'};
         my $cdom=$env{'course.'.$env{'request.course.id'}.'.domain'};
-        my %curr_groups;
-        my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
-							 $cnum,$group);
-        if ($numgroups) {
+        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum,$group);
+        if (%curr_groups) {
             my %group_info = 
 		&Apache::loncommon::get_group_settings($curr_groups{$group});
             $grouptitle = &mt('Group Chat:').' '.
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.141 loncom/interface/lonhelper.pm:1.142
--- loncom/interface/lonhelper.pm:1.141	Mon May  8 18:01:11 2006
+++ loncom/interface/lonhelper.pm	Tue May  9 10:38:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.141 2006/05/08 22:01:11 foxr Exp $
+# $Id: lonhelper.pm,v 1.142 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3177,11 +3177,9 @@
     return if ($token->[2]{'onlysections'});
 
     # add in groups to the end of the list
-    my %curr_groups;
-    if (&Apache::loncommon::coursegroups(\%curr_groups)) {
-	foreach my $group_name (sort(keys(%curr_groups))) {
-	    push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
-	}
+    my %curr_groups = &Apache::loncommon::coursegroups();
+    foreach my $group_name (sort(keys(%curr_groups))) {
+	push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
     }
 }    
 
@@ -3243,11 +3241,9 @@
     # Populate the CHOICES element
     my %choices;
 
-    my %curr_groups;
-    if (&Apache::loncommon::coursegroups(\%curr_groups)) {
-	foreach my $group_name (sort(keys(%curr_groups))) {
-	    push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
-	}
+    my %curr_groups = &Apache::loncommon::coursegroups();
+    foreach my $group_name (sort(keys(%curr_groups))) {
+	push(@{$paramHash->{CHOICES}}, [$group_name, $group_name]);
     }
 }
 
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.298 loncom/interface/lonparmset.pm:1.299
--- loncom/interface/lonparmset.pm:1.298	Mon May  1 15:37:33 2006
+++ loncom/interface/lonparmset.pm	Tue May  9 10:38:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.298 2006/05/01 19:37:33 albertel Exp $
+# $Id: lonparmset.pm,v 1.299 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1124,14 +1124,11 @@
                  $env{'course.'.$env{'request.course.id'}.'.num'},
 					 \%sectionhash);
     my $groups;
-    my %grouphash;
-    my $numgrp = &Apache::loncommon::coursegroups(
-                 \%grouphash,
-                 $env{'course.'.$env{'request.course.id'}.'.domain'},
-                 $env{'course.'.$env{'request.course.id'}.'.num'});
+    my %grouphash = &Apache::loncommon::coursegroups();
+
     if ($numsec > 0) {
         $sections=$lt{'se'}.': <select name="csec"';
-        if ($numsec && $numgrp && $parmlev ne 'full') {
+        if (%grouphash && $parmlev ne 'full') {
             $sections .= qq| onchange="group_or_section('csec')" |;
         }
         $sections .= '>';
@@ -1142,7 +1139,7 @@
         }
         $sections.='</select>';
     }
-    if ($numsec && $numgrp && $parmlev ne 'full') {
+    if ($numsec && %grouphash && $parmlev ne 'full') {
         $sections .= '&nbsp;or&nbsp;';
         $sections .= qq|
 <script type="text/javascript">
@@ -1168,9 +1165,10 @@
 </script>
 |;
     } 
-    if ($numgrp > 0) {
+
+    if (%grouphash) {
         $groups=$lt{'gr'}.': <select name="cgroup"';
-        if ($numsec && $numgrp && $env{'form.action'} eq 'settable') {
+        if ($numsec && $env{'form.action'} eq 'settable') {
             $groups .= qq| onchange="group_or_section('cgroup')" |;
         }
         $groups .= '>';
@@ -1271,25 +1269,21 @@
 
 sub groupmenu {
     my ($r,$selectedgroups)=@_;
-    my %grouphash;
-    my $numgrp = &Apache::loncommon::coursegroups(
-                 \%grouphash,
-                 $env{'course.'.$env{'request.course.id'}.'.domain'},
-                 $env{'course.'.$env{'request.course.id'}.'.num'});
-    if ($numgrp) {
-        $r->print('<select name="Group" multiple="true" size="8" >');
-        foreach my $group (sort(keys(%grouphash))) {
-            $r->print('    <option value="'.$group.'"');
-            foreach (@{$selectedgroups}) {
-                if ($group eq $_) {
-                    $r->print(' selected');
-                    last;
-                }
-            }
-            $r->print('>'.$group."</option>\n");
-        }
-        $r->print("</select>\n");
+    my %grouphash = &Apache::loncommon::coursegroups();
+    return if (!%grouphash);
+
+    $r->print('<select name="Group" multiple="true" size="8" >');
+    foreach my $group (sort(keys(%grouphash))) {
+	$r->print('    <option value="'.$group.'"');
+	foreach (@{$selectedgroups}) {
+	    if ($group eq $_) {
+		$r->print(' selected');
+		last;
+	    }
+	}
+	$r->print('>'.$group."</option>\n");
     }
+    $r->print("</select>\n");
 }
 
 
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.43 loncom/interface/lonpickcourse.pm:1.44
--- loncom/interface/lonpickcourse.pm:1.43	Mon May  8 17:40:20 2006
+++ loncom/interface/lonpickcourse.pm	Tue May  9 10:38:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.43 2006/05/08 21:40:20 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.44 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -108,12 +108,8 @@
             @sections = (sort {$a <=> $b} keys(%sections_count));
             $seclist = join('","',@sections);
         }
-        my (%curr_groups,$numgroups);
-        $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,
-                                                         $cnum);
-        if ($numgroups > 0) {
-            $groupslist = join(',',sort(keys(%curr_groups)));
-        }
+        my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+	$groupslist = join(',',sort(keys(%curr_groups)));
     }
     my $jscript;
     my $title = 'Selecting a course';
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.15 loncom/interface/lonpickstudent.pm:1.16
--- loncom/interface/lonpickstudent.pm:1.15	Thu Mar 16 17:01:44 2006
+++ loncom/interface/lonpickstudent.pm	Tue May  9 10:38:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a student from the classlist
 #
-# $Id: lonpickstudent.pm,v 1.15 2006/03/16 22:01:44 raeburn Exp $
+# $Id: lonpickstudent.pm,v 1.16 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,8 +76,7 @@
     my $classlist=&Apache::loncoursedata::get_classlist();
     my %grouplist=&Apache::lonnet::get_group_membership($cdom,$cnum);
     my $now = time;
-    my %allgroups;
-    &Apache::loncommon::coursegroups(\%allgroups,$cdom,$cnum);
+    my %allgroups = &Apache::loncommon::coursegroups($cdom,$cnum);
 
 # --------------------------------------- There is such a user, get environment
 
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.38 loncom/interface/lonsimplepage.pm:1.39
--- loncom/interface/lonsimplepage.pm:1.38	Mon Apr 10 15:59:54 2006
+++ loncom/interface/lonsimplepage.pm	Tue May  9 10:38:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.38 2006/04/10 19:59:54 albertel Exp $
+# $Id: lonsimplepage.pm,v 1.39 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -70,8 +70,8 @@
     if ($caller eq 'grppg') {
         $marker =~ s/\W//g;
         $namespace = 'grppage_'.$marker;
-        my %curr_groups;
-        if (!&Apache::loncommon::coursegroups(\%curr_groups,$dom,$crs,$marker)) {
+        my %curr_groups = &Apache::loncommon::coursegroups($dom,$crs,$marker);
+        if (!%curr_groups) {
 	    &Apache::loncommon::simple_error_page($r,'','Invalid group name');
 	    return OK;
         }
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.132 loncom/interface/lonstatistics.pm:1.133
--- loncom/interface/lonstatistics.pm:1.132	Mon May  1 15:37:34 2006
+++ loncom/interface/lonstatistics.pm	Tue May  9 10:38:10 2006
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstatistics.pm,v 1.132 2006/05/01 19:37:34 albertel Exp $
+# $Id: lonstatistics.pm,v 1.133 2006/05/09 14:38:10 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -230,12 +230,12 @@
     $enrollment_status = $env{'form.Status'} if (exists($env{'form.Status'}));
     #
     # Get groupmembership
-    my (%curr_groups,$classgroups,$studentgroups);
-    my $numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum);
-    if ($numgroups) {
+    my ($classgroups,$studentgroups);
+    my %curr_groups = &Apache::loncommon::coursegroups($cdom,$cnum);
+    if (%curr_groups) {
         ($classgroups,$studentgroups) = 
-                     &Apache::loncoursedata::get_group_memberships($classlist,
-                                                                   $cdom,$cnum);
+	    &Apache::loncoursedata::get_group_memberships($classlist,
+							  $cdom,$cnum);
     }
     my $now = time;
 
Index: loncom/interface/portfolio.pm
diff -u loncom/interface/portfolio.pm:1.97 loncom/interface/portfolio.pm:1.98
--- loncom/interface/portfolio.pm:1.97	Sun Mar 19 17:08:38 2006
+++ loncom/interface/portfolio.pm	Tue May  9 10:38:10 2006
@@ -649,10 +649,10 @@
         $group = $env{'form.group'};
         $group =~ s/\W//g;
         if ($group) {
-            my %curr_groups = ();
             ($uname,$udom) = &get_name_dom($group);
-            if (&Apache::loncommon::coursegroups(\%curr_groups,$udom,$uname,
-                                                       $group)) {
+            my %curr_groups = &Apache::loncommon::coursegroups($udom,$uname,
+							       $group); 
+            if (%curr_groups) {
                 if (($view_permission) || (&Apache::lonnet::allowed('rgf',
                                       $env{'request.course.id'}.'/'.$group))) {
                     $portfolio_root = &get_portfolio_root($group);

--albertel1147185492--