[LON-CAPA-cvs] cvs: loncom /interface loncoursegroups.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 21 Feb 2006 22:40:45 -0000


This is a MIME encoded message

--raeburn1140561645
Content-Type: text/plain

raeburn		Tue Feb 21 17:40:45 2006 EDT

  Modified files:              
    /loncom/interface	loncoursegroups.pm 
  Log:
  Add option to create new group when displaying groups page with "no groups" message, when user has mgr privilege.  Add togglefunc form element to the elements set by SetFormElements() on page load when returning to pick_members and change_members forms from a subsequent page, (via click in breadcrumb or the "Go to previous page" button).
  
  
--raeburn1140561645
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060221174045.txt"

Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.6 loncom/interface/loncoursegroups.pm:1.7
--- loncom/interface/loncoursegroups.pm:1.6	Tue Feb 21 13:56:00 2006
+++ loncom/interface/loncoursegroups.pm	Tue Feb 21 17:40:45 2006
@@ -145,14 +145,20 @@
                           file   => 'Files',
                           dibd   => 'Discussion Boards',
                           dius   => 'Disk Use',
-                     );  
-    $r->print('<br /><br />');
+                          nogr   => 'No groups exist.',
+                          crng   => 'Create a new group',
+                          alth   => 'Although your current role has privileges'.
+                                    ' to view any existing groups in this course,'.
+                                    ' you do not have privileges to create new'.
+                                    ' groups.',
+                     );
     if ($view_permission) {
         if (!defined($action)) {
             $action = 'view';
         }
         my %curr_groups;
         if (&Apache::loncommon::coursegroups(\%curr_groups,$cdom,$cnum)) {
+            $r->print('<br /><br />');
             $r->print(&Apache::lonhtmlcommon::start_pick_box());
             $r->print(<<"END");
       <table border="0" cellpadding="4" cellspacing="1">
@@ -251,11 +257,18 @@
             $r->print('</table>');
             $r->print(&Apache::lonhtmlcommon::end_pick_box());
         } else {
-            $r->print('No groups exist');
+            $r->print($lt{'nogr'});
+            if ($manage_permission) {
+                $r->print('<br /><br /><a href="/adm/coursegroups?action=create&refpage='.$env{'form.refpage'}.'">'.$lt{'crng'}.'</a>');
+            } else {
+                $r->print('<br /><br />'.$lt{'crng'});
+
+            }
         }
     } else {
         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)) {
                 foreach my $group (@coursegroups) {
@@ -473,6 +486,9 @@
     }
     if ($state eq 'pick_members') {
         if ((keys(%users) > 0) && (@tools > 0)) {
+            if ($granularity eq 'Yes') {
+                $elements{$action}{'pick_members'}{'togglefunc'} = 'checkbox';
+            }
             foreach my $tool (@tools) {
                 if ($granularity eq 'Yes') {
                     $elements{$action}{'pick_members'}{'user_'.$tool} = 'checkbox';
@@ -527,6 +543,9 @@
             $elements{$action}{'change_members'}{'reenable'} = 'checkbox';
         }
         if ($numusers) {
+            if ($granularity eq 'Yes') {
+                $elements{$action}{'change_members'}{'togglefunc'} = 'checkbox';
+            }
             foreach my $tool (@tools) {
                 if ($granularity eq 'Yes') {
                     $elements{$action}{'change_members'}{'user_'.$tool} = 'checkbox';
@@ -971,7 +990,8 @@
     }
     if (($action eq 'modify') &&
                 ($state eq 'change_settings' || $state eq 'change_members' ||
-                 $state eq 'change_privs') || $state eq 'add_members') {
+                 $state eq 'change_privs' || $state eq 'add_members' ||
+                 $state eq 'pick_members')) {
             $loaditems =
              'onload="javascript:setFormElements(document.'.$state.')"';
     }
@@ -1136,18 +1156,18 @@
     }
     my @allfunctions = sort(keys (%{$functions}));
     for (my $i=0; $i<$halfnum; $i++) {
-        $r->print('<td><input type="checkbox" name="tool" value="'.
+        $r->print('<td><label><input type="checkbox" name="tool" value="'.
                   $allfunctions[$i].'" />&nbsp;'.
-                   $$functions{$allfunctions[$i]}.'</td>
+                   $$functions{$allfunctions[$i]}.'</label></td>
                    <td>&nbsp;</td><td>&nbsp;</td>');
     }
     $r->print('<td><input type="button" value="check all" '.
               'onclick="javascript:checkAll(document.'.$formname.'.tool)" />'.
               '</td></tr><tr><td>&nbsp;</td>');
     for (my $j=$halfnum; $j<@allfunctions; $j++) {
-        $r->print('<td><input type="checkbox" name="tool" value="'.
+        $r->print('<td><label><input type="checkbox" name="tool" value="'.
                   $allfunctions[$j].'" />&nbsp;'.
-                  $$functions{$allfunctions[$j]}.'</td>
+                  $$functions{$allfunctions[$j]}.'</label></td>
                   <td>&nbsp;</td><td>&nbsp;</td>');
     }
     if ($remnum) {
@@ -1161,7 +1181,7 @@
       </tr>
       <tr>
        <td><b>Granularity:</b></td>
-       <td colspan="9">'.$lt{'doyo'}.'&nbsp;<input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'&nbsp;<input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No'));
+       <td colspan="9">'.$lt{'doyo'}.'&nbsp;<label><input type="radio" name="granularity" value="Yes" />'.&mt('Yes').'</label>&nbsp;<label><input type="radio" name="granularity" value="No" checked="checked" />'.&mt('No').'</label>');
     if ($action eq 'modify') {
         $r->print('&nbsp;&nbsp;('.&mt('Currently set to "[_1]"',
                                       $$stored{'granularity'}).')');
@@ -1309,7 +1329,7 @@
     my %origmembers;
     $r->print(&Apache::lonhtmlcommon::echo_form_input(
          ['origin','action','state','page','member','specificity','branch',
-          'defpriv','autorole','autoadd','autodrop','sortby'],
+          'defpriv','autorole','autoadd','autodrop','sortby','togglefunc'],
          \@regexps));
     my $earlyout = &validate_groupname($groupname,$action,$cdom,$cnum);
     $r->print('
@@ -1599,11 +1619,11 @@
             if ($granularity eq 'Yes') {
                 $r->print('<tr bgcolor="#cccccc">
  <td colspan="5">&nbsp;</td>
- <td align="center"><small><nobr><b>All:</b>&nbsp;');
+ <td align="center"><small><nobr><b>'.&mt('All:').'</b>&nbsp;');
                 foreach my $tool (@{$available}) {
-                    $r->print('<input type="checkbox" name="togglefunc" '.
-   'onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);">'.
-   '<b>'.$tool.'</b>&nbsp;&nbsp;&nbsp;');
+                    $r->print('<label><input type="checkbox" name="togglefunc" '.
+   'onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'.
+   ' value="'.$tool.'">'.'<b>'.$tool.'</b></label>&nbsp;&nbsp;&nbsp;');
                 }
                 $r->print('</nobr></small></td></tr>');
             }
@@ -1753,8 +1773,8 @@
         }
         if ($totaloptionalprivs) {
             $r->print('
-<br /><br /><nobr><input type="radio" name="specificity" value="No" '.$specific{'No'}.' />&nbsp;'.$lt{'algm'}.'</nobr><br/>
-<nobr><input type="radio" name="specificity" value="Yes" '.$specific{'Yes'}.' />&nbsp;'.$lt{'smgp'}.'</nobr>
+<br /><br /><label><nobr><input type="radio" name="specificity" value="No" '.$specific{'No'}.' />&nbsp;'.$lt{'algm'}.'</nobr></label><br/>
+<label><nobr><input type="radio" name="specificity" value="Yes" '.$specific{'Yes'}.' />&nbsp;'.$lt{'smgp'}.'</nobr></label>
   </td>
  </tr>
  <tr>
@@ -1876,7 +1896,7 @@
                     $dynamic .= '</tr>
                                  <tr bgcolor="'.$rowColor1.'">'."\n";
                 }
-                $dynamic .= '<td><input type="checkbox" name="defpriv" value="'.$priv.'" />'.$$toolprivs{$tool}{$priv}.'</td>'."\n";
+                $dynamic .= '<td><label><input type="checkbox" name="defpriv" value="'.$priv.'" />'.$$toolprivs{$tool}{$priv}.'</label></td>'."\n";
             }
         }
         if ($dynamic eq '') {
@@ -1982,8 +2002,8 @@
     my @regexps = ('user_','userpriv_');
     $r->print(&Apache::lonhtmlcommon::echo_form_input(
                          ['origin','action','state','page','expire','deletion',
-                          'reenable','activate','changepriv','sortby'],
-                          \@regexps));
+                          'reenable','activate','changepriv','sortby',
+                          'togglefunc'],\@regexps));
     my $rowimg = 1;
     my @available = ();
     my @unavailable = ();
@@ -2204,9 +2224,9 @@
  <td colspan="'.$colspan.'" align="center"><small><nobr><b>'.&mt('All:').
   '</b>&nbsp;');
                     foreach my $tool (@{$available}) {
-                        $r->print('<input type="checkbox" name="togglefunc" '.
-   'onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);">'.
-   '<b>'.$tool.'</b>&nbsp;&nbsp;&nbsp;');
+                        $r->print('<label><input type="checkbox" name="togglefunc"'.
+   ' onclick="javascript:toggleTools(document.'.$formname.'.user_'.$tool.',this);"'.
+   ' value="'.$tool.'">'.'<b>'.$tool.'</b></label>&nbsp;&nbsp;&nbsp;');
                     }
                     $r->print('</nobr></small></td></tr>');
                 }
@@ -2243,25 +2263,25 @@
                     $r->print('<tr bgcolor="'.$rowColor.'">
                                 <td><small>');
                     if ($current{$user}{changestate} eq 'reenable') {
-                        $r->print('<nobr>'. 
+                        $r->print('<nobr><label>'. 
    '<input type="checkbox" name="reenable" value="'.$user.'" />'.
-   $lt{'reen'}.'</nobr><br />');
+   $lt{'reen'}.'</label></nobr><br />');
                     } elsif ($current{$user}{changestate} eq 'expire') {
-                        $r->print('<nobr>'.
+                        $r->print('<nobr><label>'.
    '<input type="checkbox" name="expire" value="'.$user.'" />'.
-   $lt{'expi'}.'</nobr><br />');
+   $lt{'expi'}.'</label></nobr><br />');
                     } elsif ($current{$user}{changestate} eq 'activate') {
-                        $r->print('<nobr>'.
+                        $r->print('<nobr><label>'.
    '<input type="checkbox" name="activate" value="'.$user.'" />'.
-   $lt{'acti'}.'</nobr><br />');
+   $lt{'acti'}.'</label></nobr><br />');
                     }
-                    $r->print('<nobr>'.
+                    $r->print('<nobr><label>'.
    '<input type="checkbox" name="deletion" value="'.$user.'" />'.
-   $lt{'dele'}.'</nobr>');
+   $lt{'dele'}.'</label></nobr>');
                     if ($specificity eq 'Yes') {
-                        $r->print('<br /><nobr>'.
+                        $r->print('<br /><nobr><label>'.
    '<input type="checkbox" name="changepriv" value="'.$user.'" />'.$lt{'chpr'}.
-   '</nobr>');
+   '</label></nobr>');
                     }
                     $r->print('
    </td>
@@ -2274,17 +2294,17 @@
                                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
                         foreach my $tool (@{$current{$user}{currtools}}) {
                             if ($granularity eq 'Yes') {
-                                $r->print('<input type="checkbox" 
-                                       checked="checked"  
-                                       name="user_'.$tool.'" value="'.
-                                       $user.'" />');
+                                $r->print('<label><input type="checkbox" '. 
+                                       'checked="checked" '. 
+                                       'name="user_'.$tool.'" value="'.
+                                       $user.'" />'.$tool.'</label>');
                              } else {
-                               $r->print('<input type="hidden"
-                                       checked="checked"
-                                       name="user_'.$tool.'" value="'.
-                                       $user.'" />');
+                               $r->print('<input type="hidden" '.
+                                       'checked="checked" '.
+                                       'name="user_'.$tool.'" value="'.
+                                       $user.'" />'.$tool);
                              }
-                             $r->print($tool.'&nbsp;&nbsp;&nbsp;');
+                             $r->print('&nbsp;&nbsp;&nbsp;');
                         }
                         $r->print('</nobr></small></td>');
                     }
@@ -2292,10 +2312,10 @@
                         $r->print('<td align="left"><small>');
                         if ($granularity eq 'Yes') {
                             foreach my $tool (@{$current{$user}{newtools}}) {
-                                $r->print('<nobr><input type="checkbox"  
+                                $r->print('<nobr><label><input type="checkbox"  
                                           name="user_'.$tool.'" value="'.
                                           $user.'" />'.$tool.
-                                                  '</nobr>&nbsp;&nbsp;&nbsp;');
+                                          '</label></nobr>&nbsp;&nbsp;&nbsp;');
                             }
                         } else {
                             foreach my $tool (@{$current{$user}{newtools}}) {
@@ -3278,13 +3298,13 @@
                         if ($privcount == 3) {
                             $dynamic .= '</tr><tr>';
                         }
-                        $dynamic .='<td><nobr><input type="checkbox" '.
+                        $dynamic .='<td><nobr><label><input type="checkbox" '.
                                'name="userpriv_'.$priv.'" value="'.$user.'"';
                         if (grep/^\Q$priv\E$/,@{$defprivs}) {
                             $dynamic .= ' checked="checked" ';
                         }
                         $dynamic .= ' />'.$$toolprivs{$tool}{$priv}.
-                                    '</nobr></td>';
+                                    '</label></nobr></td>';
                     }
                 }
                 $r->print('<tr><td colspan="2"><nobr>'.$fixed.'</nobr></td></tr><tr>'.$dynamic.'</tr></table></td>');
@@ -3313,8 +3333,8 @@
                                                       'startdate',$starttime);
     my $endform = &Apache::lonhtmlcommon::date_setter($formname,
                                                       'enddate',$endtime);
-    my $perpetual = '<nobr><input type="checkbox" name="no_end_date" />
-                                                  no ending date</nobr>';
+    my $perpetual = '<nobr><label><input type="checkbox" name="no_end_date" />
+                                                no ending date</label></nobr>';
     my $start_table = '';
     $start_table .= "<table>\n";
     $start_table .= '<tr><td align="right">Default starting date for 

--raeburn1140561645--