[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm loncreateuser.pm lonuserutils.pm

raeburn raeburn at source.lon-capa.org
Mon Aug 20 21:50:34 EDT 2012


raeburn		Tue Aug 21 01:50:34 2012 EDT

  Modified files:              
    /loncom/interface	loncommon.pm loncreateuser.pm lonuserutils.pm 
  Log:
  - Checkboxes so user can choose what user information to include in user listings.
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1092 loncom/interface/loncommon.pm:1.1093
--- loncom/interface/loncommon.pm:1.1092	Tue Aug 14 15:45:06 2012
+++ loncom/interface/loncommon.pm	Tue Aug 21 01:50:33 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1092 2012/08/14 15:45:06 raeburn Exp $
+# $Id: loncommon.pm,v 1.1093 2012/08/21 01:50:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -888,10 +888,14 @@
 function checkAll(field) {
     if (field.length > 0) {
         for (i = 0; i < field.length; i++) {
-            field[i].checked = true ;
+            if (!field[i].disabled) { 
+                field[i].checked = true;
+            }
         }
     } else {
-        field.checked = true
+        if (!field.disabled) { 
+            field.checked = true;
+        }
     }
 }
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.363 loncom/interface/loncreateuser.pm:1.364
--- loncom/interface/loncreateuser.pm:1.363	Fri Aug 17 22:43:31 2012
+++ loncom/interface/loncreateuser.pm	Tue Aug 21 01:50:33 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.363 2012/08/17 22:43:31 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.364 2012/08/21 01:50:33 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4380,6 +4380,7 @@
                      bread_crumbs_component => $bread_crumbs_component};
             my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
             my $formname = 'studentform';
+            my $hidecall = "hide_searching();";
             if (($context eq 'domain') && (($env{'form.roletype'} eq 'course') ||
                 ($env{'form.roletype'} eq 'community'))) {
                 if ($env{'form.roletype'} eq 'course') {
@@ -4396,16 +4397,22 @@
                                    );
                     $jscript = &Apache::lonhtmlcommon::set_form_elements(\%elements);
                 }
-                $jscript .= &verify_user_display();
+                $jscript .= &verify_user_display($context)."\n".
+                            &Apache::loncommon::check_uncheck_jscript();
                 my $js = &add_script($jscript).$cb_jscript;
                 my $loadcode = 
                     &Apache::lonuserutils::course_selector_loadcode($formname);
                 if ($loadcode ne '') {
-                    $args->{add_entries} = {onload => $loadcode};
+                    $args->{add_entries} = {onload => "$loadcode;$hidecall"};
+                } else {
+                    $args->{add_entries} = {onload => $hidecall};
                 }
                 $r->print(&header($js,$args));
             } else {
-                $r->print(&header(&add_script(&verify_user_display()),$args));
+                $args->{add_entries} = {onload => $hidecall};
+                $jscript = &verify_user_display($context).
+                           &Apache::loncommon::check_uncheck_jscript(); 
+                $r->print(&header(&add_script($jscript),$args));
             }
             &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
                          $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
@@ -4541,14 +4548,68 @@
 }
 
 sub verify_user_display {
+    my ($context) = @_;
+    my $photos;
+    if (($context eq 'course') && $env{'request.course.id'}) {
+        $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
+    }
     my $output = <<"END";
 
+function hide_searching() {
+    if (document.getElementById('searching')) {
+        document.getElementById('searching').style.display = 'none';
+    }
+    return;
+}
+
 function display_update() {
     document.studentform.action.value = 'listusers';
     document.studentform.phase.value = 'display';
     document.studentform.submit();
 }
 
+function updateCols(caller) {
+    var context = '$context';
+    var photos = '$photos';
+    if (caller == 'Status') {
+        if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+            document.getElementById('showcolstatus').checked = true;
+            document.getElementById('showcolstatus').disabled = '';
+            document.getElementById('showcolstart').checked = true;
+            document.getElementById('showcolend').checked = true;
+        } else {
+            document.getElementById('showcolstatus').checked = false;
+            document.getElementById('showcolstatus').disabled = 'disabled';
+            document.getElementById('showcolstart').checked = false;
+            document.getElementById('showcolend').checked = false;
+        }
+    }
+    if (caller == 'output') {
+        if (photos == 1) {
+            if (document.getElementById('showcolphoto')) {
+                var photoitem = document.getElementById('showcolphoto');
+                if (document.studentform.output.options[document.studentform.output.selectedIndex].value == 'html') {
+                    photoitem.checked = true;
+                    photoitem.disabled = '';
+                } else {
+                    photoitem.checked = false;
+                    photoitem.disabled = 'disabled';
+                }
+            }
+        }
+    }
+    if (caller == 'showrole') {
+        if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') {
+            document.getElementById('showcolrole').checked = true;
+            document.getElementById('showcolrole').disabled = '';
+        } else {
+            document.getElementById('showcolrole').checked = false;
+            document.getElementById('showcolrole').disabled = 'disabled';
+        }
+    }
+    return;
+}
+
 END
     return $output;
 
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.139 loncom/interface/lonuserutils.pm:1.140
--- loncom/interface/lonuserutils.pm:1.139	Sun Aug 19 00:18:16 2012
+++ loncom/interface/lonuserutils.pm	Tue Aug 21 01:50:34 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.139 2012/08/19 00:18:16 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.140 2012/08/21 01:50:34 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1444,8 +1444,9 @@
     if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) {
         $env{'form.Status'} = 'Active';
     }
+    my $onchange = "javascript:updateCols('Status');";
     my $status_select = &Apache::lonhtmlcommon::StatusOptions
-        ($env{'form.Status'});
+        ($env{'form.Status'},undef,undef,$onchange);
 
     if ($env{'form.showrole'} eq '') {
         if ($context eq 'course') {
@@ -1478,12 +1479,12 @@
     $r->print('<form name="studentform" method="post" action="/adm/createuser">'."\n".
               '<input type="hidden" name="action" value="'.
               $env{'form.action'}.'" />');
-    $r->print("<p>\n");
+    $r->print('<div>'."\n");
     if ($env{'form.action'} ne 'modifystudent') {
         my %lt=&Apache::lonlocal::texthash('csv' => "CSV",
                                            'excel' => "Excel",
                                            'html'  => 'HTML');
-        my $output_selector = '<select size="1" name="output" >';
+        my $output_selector = '<select size="1" name="output" onchange="javascript:updateCols('."'output'".');" >';
         foreach my $outputformat ('html','csv','excel') {
             my $option = '<option value="'.$outputformat.'"';
             if ($outputformat eq $env{'form.output'}) {
@@ -1493,13 +1494,13 @@
             $output_selector .= "\n".$option;
         }
         $output_selector .= '</select>';
-        $r->print('<label><span class="LC_nobreak">'
+        $r->print('<span class="LC_nobreak">'
                  .&mt('Output Format: [_1]',$output_selector)
-                 .'</span></label>'.(' 'x3));
+                 .'</span>'.(' 'x3));
     }
-    $r->print('<label><span class="LC_nobreak">'
+    $r->print('<span class="LC_nobreak">'
              .&mt('User Status: [_1]',$status_select)
-             .'</span></label>'.(' 'x3)."\n");
+             .'</span>'.(' 'x3)."\n");
     my $roleselected = '';
     if ($env{'form.showrole'} eq 'Any') {
        $roleselected = ' selected="selected"'; 
@@ -1510,20 +1511,25 @@
         ($cnum,$cdom) = &get_course_identity();
         $r->print(&section_group_filter($cnum,$cdom));
     }
+    $r->print('</div><div class="LC_left_float">'.
+              &column_checkboxes($context,$mode,$formname).
+              '</div><br clear="all" />');
     if ($env{'form.phase'} eq '') {
-        $r->print('<br /><br />'.&list_submit_button(&mt('Display List of Users')).
-                  "\n</p>\n".
+        $r->print(&list_submit_button(&mt('Display List of Users'))."\n".
                   '<input type="hidden" name="phase" value="" /></form>');
         return;
     }
     if (!(($context eq 'domain') && 
           (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {
-        $r->print(
-            "\n</p>\n"
-           .'<p>'
-           .&list_submit_button(&mt('Update Display'))
-           ."</p>\n"
-        );
+        $r->print(&list_submit_button(&mt('Update Display'))."\n");
+    }
+
+    my @cols = &infocolumns($context,$mode);  
+    if (!@cols) {
+         $r->print('<hr /><span class="LC_warning">'.
+                   &mt('No user information selected for display.').'</span>'.
+                   '<input type="hidden" name="phase" value="display" /></form>'."\n");
+         return;
     }
     my ($indexhash,$keylist) = &make_keylist_array();
     my (%userlist,%userinfo,$clearcoursepick);
@@ -1565,7 +1571,7 @@
             $r->print('<hr />'.&mt('Searching').' ...<br /> <br />');
         }
     } else {
-        $r->print('<hr />'.&mt('Searching').' ...<br /> <br />');
+        $r->print('<hr /><div id="searching">'.&mt('Searching').' ...</div>');
     }
     $r->rflush();
     if ($context eq 'course') {
@@ -1719,6 +1725,7 @@
     }
     $r->print('<input type="hidden" name="phase" value="'.
               $env{'form.phase'}.'" /></form>');
+    return;
 }
 
 sub role_filter {
@@ -1731,11 +1738,11 @@
     my ($role_select);
     if ($context eq 'domain') {
         $role_select = &domain_roles_select();
-        $output = '<label><span class="LC_nobreak">'
+        $output = '<span class="LC_nobreak">'
                  .&mt('Role Type: [_1]',$role_select)
-                 .'</span></label>';
+                 .'</span>';
     } else {
-        $role_select = '<select name="showrole">'."\n".
+        $role_select = '<select name="showrole" onchange="javascript:updateCols('."'showrole'".');">'."\n".
                        '<option value="Any" '.$roleselected.'>'.
                        &mt('Any role').'</option>';
         my ($roletype,$crstype);
@@ -1762,9 +1769,9 @@
             $role_select .= '<option value="'.$role.'"'.$roleselected.'>'.$plrole.'</option>';
         }
         $role_select .= '</select>';
-        $output = '<label><span class="LC_nobreak">'
+        $output = '<span class="LC_nobreak">'
                  .&mt('Role: [_1]',$role_select)
-                 .'</span></label> ';
+                 .'</span>';
     }
     return $output;
 }
@@ -1827,11 +1834,167 @@
     return $output;
 }
 
+sub infocolumns {
+    my ($context,$mode) = @_;
+    my @cols;
+    if (($mode eq 'pickauthor') || ($mode eq 'autoenroll')) {
+        @cols = &get_cols_array($context,$mode);
+    } else {
+        my @posscols = &get_cols_array($context,$mode);
+        if ($env{'form.phase'} ne '') {
+            my @checkedcols = &Apache::loncommon::get_env_multiple('form.showcol');
+            foreach my $col (@checkedcols) {
+                if (grep(/^$col$/, at posscols)) {
+                    push(@cols,$col);
+                }
+            }
+        } else {
+            @cols = @posscols;
+        }
+    }
+    return @cols;
+}
+
+sub get_cols_array {
+    my ($context,$mode) = @_;
+    my @cols;
+    if ($mode eq 'pickauthor') {
+        @cols = ('username','fullname','status','email');
+    } else {
+        @cols = ('username','domain','id','fullname');
+        if ($context eq 'course') {
+            push(@cols,'section');
+        }
+        push(@cols,('start','end','role'));
+        if ($context eq 'domain') {
+            push (@cols,'extent');
+        }
+        unless (($mode eq 'autoenroll') && ($env{'form.Status'} ne 'Any')) {
+            push(@cols,'status');
+        }
+        if ($context eq 'course') {
+            push(@cols,'groups');
+        }
+        push(@cols,'email');
+        if (($context eq 'course') && ($mode ne 'autoenroll')) {
+            push(@cols,'lastlogin','clicker');
+        }
+        if (($context eq 'course') && ($mode ne 'autoenroll') &&
+            ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) {
+            push(@cols,'photos');
+        }
+    }
+    return @cols;
+}
+
+sub column_checkboxes {
+    my ($context,$mode,$formname) = @_;
+    my @cols = &get_cols_array($context,$mode);
+    my @showncols = &Apache::loncommon::get_env_multiple('form.showcol');
+    my (%disabledchk,%unchecked);
+    if ($env{'form.phase'} eq '') {
+        $disabledchk{'status'} = 1;
+        if ($context eq 'course') {
+            $disabledchk{'role'} = 1;
+            $unchecked{'photo'} = 1;
+        }
+        $unchecked{'clicker'} = 1;
+        $unchecked{'start'} = 1;
+        $unchecked{'end'} = 1;
+    } else {
+        if ($env{'form.Status'} ne 'Any') {
+            $disabledchk{'status'} = 1;
+        }
+        if ($env{'form.showrole'} ne 'Any') {
+            $disabledchk{'role'} = 1; 
+        }
+    }
+    my $numposs = scalar(@cols);
+    my $numinrow = 8;
+    my %lt = &get_column_names($context);
+    my $output = '<fieldset><legend>'.&mt('Information to show').'</legend>'."\n".'<span class="LC_nobreak">'.
+                 '<input type="button" onclick="javascript:checkAll(document.'.$formname.'.showcol);" value="'.&mt('check all').'" />'.
+                 (' 'x3).
+                 '<input type="button" onclick="javascript:uncheckAll(document.'.$formname.'.showcol);" value="'.&mt('uncheck all').'" />'.
+                 '</span><table>';
+    
+    for (my $i=0; $i<$numposs; $i++) {
+        my $rem = $i%($numinrow);
+        if ($rem == 0) {
+            if ($i > 0) {
+                $output .= '</tr>';
+            }
+            $output .= '<tr>';
+        }
+        my $checked;
+        if ($env{'form.phase'} eq '') {
+            $checked = ' checked="checked"';
+            if ($unchecked{$cols[$i]}) { 
+               $checked = '';
+            }
+            if ($disabledchk{$cols[$i]}) {
+                $checked = ' disabled="disabled"';
+            }
+        } elsif (grep(/^\Q$cols[$i]\E$/, at showncols)) {
+            $checked = ' checked="checked"';
+        } elsif ($disabledchk{$cols[$i]}) {
+            $checked = ' disabled="disabled"';
+        }
+        if ($i == $numposs-1) {
+            my $colsleft = $numinrow-$rem;
+            if ($colsleft > 1) {
+                $output .= '<td colspan="'.$colsleft.'">';
+            } else {
+                $output .= '<td>';
+            }
+        } else {
+            $output .= '<td>';
+        }
+        $output .= '<label><input id="showcol'.$cols[$i].'" type="checkbox" name="showcol" value="'.$cols[$i].'"'.$checked.' />'.
+                   $lt{$cols[$i]}.'</label></td>';
+
+    }
+    $output .= '</tr></table></fieldset>';
+    return $output;
+}
+
 sub list_submit_button {
     my ($text) = @_;
     return '<input type="button" name="updatedisplay" value="'.$text.'" onclick="javascript:display_update()" />';
 }
 
+sub get_column_names {
+    my ($context) = @_;
+    my %lt = &Apache::lonlocal::texthash(
+        'username'   => "username",
+        'domain'     => "domain",
+        'id'         => 'ID',
+        'fullname'   => "name",
+        'section'    => "section",
+        'groups'     => "active groups",
+        'start'      => "start date",
+        'end'        => "end date",
+        'status'     => "status",
+        'role'       => "role",
+        'type'       => "enroll type/action",
+        'email'      => "e-mail address",
+        'photo'      => "photo",
+        'lastlogin'  => "last login",
+        'extent'     => "extent",
+        'ca'         => "check all",
+        'ua'         => "uncheck all",
+        'clicker'    => "clicker-ID",
+    );
+    if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
+        $lt{'extent'} = &mt('Course(s): description, section(s), status');
+    } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
+        $lt{'extent'} = &mt('Communities: description, section(s), status');
+    } elsif ($context eq 'author') {
+        $lt{'extent'} = &mt('Author');
+    }
+    return %lt;
+}
+
 sub gather_userinfo {
     my ($context,$format,$userlist,$indexhash,$userinfo,$rolehash,$permission) = @_;
     my $viewablesec;
@@ -2195,7 +2358,7 @@
         $sortby = 'username';
     }
     my $setting = $env{'form.roletype'};
-    my ($cid,$cdom,$cnum,$classgroups,$displayphotos,$displayclickers,$crstype);
+    my ($cid,$cdom,$cnum,$classgroups,$crstype);
     if ($context eq 'course') {
         $cid = $env{'request.course.id'};
         $crstype = &Apache::loncommon::course_type();
@@ -2205,14 +2368,6 @@
         if ($mode eq 'autoenroll') {
             $env{'form.showrole'} = 'st';
         } else {
-            if (! exists($env{'form.displayphotos'})) {
-                $env{'form.displayphotos'} = 'off';
-            }
-            $displayphotos = $env{'form.displayphotos'};
-            if (! exists($env{'form.displayclickers'})) {
-                $env{'form.displayclickers'} = 'off';
-            }
-            $displayclickers = $env{'form.displayclickers'};
             if ($env{'course.'.$cid.'.internal.showphoto'}) {
                 $r->print('
 <script type="text/javascript">
@@ -2228,10 +2383,6 @@
 </script>
                ');
             }
-            $r->print(<<END);
-<input type="hidden" name="displayphotos" value="$displayphotos" />
-<input type="hidden" name="displayclickers" value="$displayclickers" />
-END
         }
     } elsif ($context eq 'domain') {
         if ($setting eq 'community') {
@@ -2241,14 +2392,12 @@
         }
     }
     if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
-        my $check_uncheck_js = &Apache::loncommon::check_uncheck_jscript();
         my $date_sec_selector = &date_section_javascript($context,$setting,$statusmode);
         my $verify_action_js = &bulkaction_javascript($formname);
         $r->print(<<END);
 
 <script type="text/javascript" language="Javascript">
 // <![CDATA[
-$check_uncheck_js
 
 $verify_action_js
 
@@ -2306,75 +2455,18 @@
     $r->print(<<END);
 <input type="hidden" name="sortby" value="$sortby" />
 END
-
-    my %lt=&Apache::lonlocal::texthash(
-                       'username'   => "username",
-                       'domain'     => "domain",
-                       'id'         => 'ID',
-                       'fullname'   => "name",
-                       'section'    => "section",
-                       'groups'     => "active groups",
-                       'start'      => "start date",
-                       'end'        => "end date",
-                       'status'     => "status",
-                       'role'       => "role",
-                       'type'       => "enroll type/action",
-                       'email'      => "e-mail address",
-                       'photo'      => "photo",
-                       'lastlogin'  => "last login", 
-                       'extent'     => "extent",
+    my @cols = &infocolumns($context,$mode);
+    my %coltxt = &get_column_names($context);
+    my %acttxt = &Apache::lonlocal::texthash(
                        'pr'         => "Proceed",
-                       'ca'         => "check all",
-                       'ua'         => "uncheck all",
                        'ac'         => "Action to take for selected users",
                        'link'       => "Behavior of clickable username link for each user",
                        'aboutme'    => "Display a user's personal information page",
                        'owin'       => "Open in a new window",
                        'modify'     => "Modify a user's information",
                        'track'      => "View a user's recent activity",
-                       'clicker'    => "Clicker-ID",
                       );
-    if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
-        $lt{'extent'} = &mt('Course(s): description, section(s), status');
-    } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
-        $lt{'extent'} = &mt('Communities: description, section(s), status');
-    } elsif ($context eq 'author') {
-        $lt{'extent'} = &mt('Author'); 
-    }
-    my @cols;
-    if ($mode eq 'pickauthor') {
-        @cols = ('username','fullname','status','email');
-    } else {
-        @cols = ('username','domain','id','fullname');
-        if ($context eq 'course') {
-            push(@cols,'section');
-        }
-        if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course')
-                              && ($env{'form.roletype'} eq 'community'))) { 
-            push(@cols,('start','end'));
-        }
-        if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') {
-            push(@cols,'role');
-        }
-        if ($context eq 'domain' && ($env{'form.roletype'} eq 'author' ||
-                                    $env{'form.roletype'} eq 'course' ||
-                                    $env{'form.roletype'} eq 'community')) {
-            push (@cols,'extent');
-        }
-        if (($statusmode eq 'Any') && 
-            (!($context eq 'domain' && (($env{'form.roletype'} eq 'course')
-             || ($env{'form.roletype'} eq 'community'))))) {
-            push(@cols,'status');
-        }
-        if ($context eq 'course') {
-            push(@cols,'groups');
-        }
-        push(@cols,'email');
-        if ($context eq 'course') {
-            push(@cols,'lastlogin');
-        }
-    }
-
+    my %lt = (%coltxt,%acttxt);
     my $rolefilter = $env{'form.showrole'};
     if ($env{'form.showrole'} eq 'cr') {
         $rolefilter = &mt('custom');  
@@ -2385,7 +2477,7 @@
     if ($mode ne 'autoenroll') {
         $results_description = &results_header_row($rolefilter,$statusmode,
                                                    $context,$permission,$mode,$crstype);
-        $r->print('<b>'.$results_description.'</b><br /><br />');
+        $r->print('<b>'.$results_description.'</b><br clear="all" />');
     }
     my ($output,$actionselect,%canchange,%canchangesec);
     if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
@@ -2481,7 +2573,7 @@
             }
             $output .= '</td><td valign="top"  style="border-left: 1px solid;"><span class="LC_nobreak"><input type="checkbox" name="userwin" value="1"'.$checkwin.' />'.$lt{'owin'}.'</span></td></tr></table></fieldset></div>';
         }
-        $output .= "\n".'<div class="LC_clear_float_footer"> </div>'."\n".
+        $output .= "\n".'<br clear="all" />'."\n".
                   &Apache::loncommon::start_data_table().
                   &Apache::loncommon::start_data_table_header_row();
         if ($mode eq 'autoenroll') {
@@ -2498,42 +2590,6 @@
             $output .= "<th><a href=\"javascript:document.$formname.sortby.value='$item';document.$formname.submit();\">$lt{$item}</a></th>\n";
         }
         my %role_types = &role_type_names();
-        if ($context eq 'course' && $mode ne 'autoenroll') {
-            if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
-                # Clicker display on or off?
-                my %clicker_options = (
-                                        'on' => 'Show',
-                                        'off' => 'Hide',
-                                      );
-                my $clickerchg = 'on';
-                if ($displayclickers eq 'on') {
-                    $clickerchg = 'off';
-                }
-                $output .= '    <th>'."\n".'     '
-                        .&mt('[_1]'.$clicker_options{$clickerchg}.'[_2] clicker id'
-                            ,'<a href="javascript:document.'.$formname.'.displayclickers.value='
-                             ."'".$clickerchg."'".';document.'.$formname.'.submit();">'
-                            ,'</a>')
-                        ."\n".'    </th>'."\n";
-
-                # Photo display on or off?
-                if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
-                    my %photo_options = &Apache::lonlocal::texthash(
-                                                            'on' => 'Show',
-                                                            'off' => 'Hide',
-                                                                );
-                    my $photochg = 'on';
-                    if ($displayphotos eq 'on') {
-                        $photochg = 'off';
-                    }
-                    $output .= '    <th>'."\n".'     '.
-                '<a href="javascript:document.'.$formname.'.displayphotos.value='.
-                      "'".$photochg."'".';document.'.$formname.'.submit();">'.
-                      $photo_options{$photochg}.'</a> '.$lt{'photo'}."\n".
-                      '    </th>'."\n";
-                }
-            }
-        }
         $output .= &Apache::loncommon::end_data_table_header_row();
 # Done with the HTML header line
     } elsif ($mode eq 'csv') {
@@ -2554,14 +2610,12 @@
             $CSVfile = undef;
         }
         #
-        push @cols,'clicker';
         # Write headers and data to file
         print $CSVfile '"'.$results_description.'"'."\n"; 
         print $CSVfile '"'.join('","',map {
             &Apache::loncommon::csv_translate($lt{$_})
             } (@cols))."\"\n";
     } elsif ($mode eq 'excel') {
-        push @cols,'clicker';
         # Create the excel spreadsheet
         ($excel_workbook,$excel_filename,$format) =
             &Apache::loncommon::create_workbook($r);
@@ -2685,7 +2739,7 @@
                     }
                 }
                 if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
-                    if (($displayphotos eq 'on') && ($role eq 'st')) {
+                    if ((grep/^photo$/, at cols) && ($role eq 'st')) {
                         $userlist->{$user}->[$index{'photo'}] =
                             &Apache::lonnet::retrievestudentphoto($udom,$uname,'jpg');
                         $userlist->{$user}->[$index{'thumbnail'}] =
@@ -2829,27 +2883,28 @@
                         $showitem = $ltstatus{$in{$item}};
                     }
                     $r->print('<td>'.$showitem.'</td>'."\n");
-                } else {
-                    $r->print('<td>'.$in{$item}.'</td>'."\n");
-                }
-            }
-            if (($context eq 'course') && ($mode ne 'autoenroll')) {
-                if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
-                    if ($displayclickers eq 'on') {
-                        my $clickers =
+                } elsif ($item eq 'photo') {
+                     if (($context eq 'course') && ($mode ne 'autoenroll') && 
+                         ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) { 
+                         if ($role eq 'st') {
+                             $r->print('<td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1" alt="" /></a></td>');
+                         } else {
+                             $r->print('<td> </td>');
+                         }
+                     }
+                } elsif ($item eq 'clicker') {
+                    if (($context eq 'course') && ($mode ne 'autoenroll')) {
+                        if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
+                            my $clickers =
                    (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
-                        if ($clickers!~/\w/) { $clickers='-'; }
-                        $r->print('<td>'.$clickers.'</td>');
-                    } else {
-                        $r->print('    <td> </td>  ');
-                    }
-                    if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
-                        if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') {
-                            $r->print('    <td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1" alt="" /></a></td>');
+                            if ($clickers!~/\w/) { $clickers='-'; }
+                            $r->print('<td>'.$clickers.'</td>');
                         } else {
-                            $r->print('    <td> </td>  ');
-                        }
-                    }
+                             $r->print('<td> </td>'."\n");
+                        } 
+                    } 
+                } else {
+                    $r->print('<td>'.$in{$item}.'</td>'."\n");
                 }
             }
             $r->print(&Apache::loncommon::end_data_table_row());


More information about the LON-CAPA-cvs mailing list