--- loncom/interface/statistics/lonstudentsubmissions.pm	2008/10/30 17:45:25	1.50
+++ loncom/interface/statistics/lonstudentsubmissions.pm	2010/04/12 16:28:22	1.59
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentsubmissions.pm,v 1.50 2008/10/30 17:45:25 bisitz Exp $
+# $Id: lonstudentsubmissions.pm,v 1.59 2010/04/12 16:28:22 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -225,7 +225,12 @@ sub prepare_html_output {
     my @extra_resp_headers = &get_extra_response_headers();
     #
     # Create the table header
-    my @student_columns = ('username','domain','id','section');
+    my @student_columns = @Apache::lonstatistics::SelectedStudentData;
+    foreach (@student_columns) {
+        if($_ eq 'all') {
+            @student_columns = ('fullname','username','domain','id','section','status','groups','comments');
+        }
+    }
     #
     my %headers;
     my $student_column_count = scalar(@student_columns);
@@ -265,9 +270,10 @@ sub prepare_html_output {
                     $headers{'response'} .=
                         '<th colspan="'.scalar(@headers).'">'.
                         &mt('Response [_1]',$responses->[$i]).'</th>';
-                    $headers{'student'}.= '<th>'.join('</th><th><nobr>',
+                    $headers{'student'}.= '<th><span class="LC_nobreak">'.
+                                          join('</span></th><th><span class="LC_nobreak">',
                                                       @headers).
-                                                          '</nobr></th>';
+                                                          '</span></th>';
                 }
             }
             if ($part_span == 0) {
@@ -284,7 +290,7 @@ sub prepare_html_output {
                 $headers{'part'} .= qq{<th colspan="$part_span">$tmpname</th>};
                 $nonempty_part_headers = 1;
             } else {
-                $headers{'part'} .= qq{<th colspan="$part_span">&nbsp</th>};
+                $headers{'part'} .= qq{<th colspan="$part_span">&nbsp;</th>};
             }
             $prob_span += $part_span;
         }
@@ -325,8 +331,16 @@ sub prepare_html_output {
         }
         last if ($c->aborted());
         foreach my $field (@student_columns) {
-            $student_row_data .= 
-                '<td valign="top">'.$student->{$field}.'</td>';
+            $student_row_data .= '<td valign="top">';
+            # handle comments like in lonstudentassessment.pm
+            if($field eq 'comments') {
+                $student_row_data .= 
+                        '<a href="/adm/'.$student->{'domain'}.'/'.
+                        $student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
+            } else {
+                $student_row_data .= $student->{$field};
+            }
+            $student_row_data .= '</td>';
         }
         #
         # Figure out what it is we need to output for this student
@@ -443,6 +457,7 @@ sub prepare_html_output {
             undef(@essays);
         }
     } # end of student loop
+    $r->print('</table>'.$/);
     return;
 }
 
@@ -501,7 +516,7 @@ sub html_essay_results {
         if (defined($respid)) {
             $id .= ' '.$respid;
         }
-        $Str .= '<nobr>'.$id.'</nobr>'.('&nbsp;'x4);
+        $Str .= '<span class="LC_nobreak">'.$id.'</span>'.('&nbsp;'x4);
     }
     #
     shift(@$headers); # Get rid of the Submission header
@@ -510,11 +525,11 @@ sub html_essay_results {
         $correct = &html_format_essay_sub($response->{'Correct'});
         shift(@$headers);
     }
-    $Str .= '<nobr>'.
+    $Str .= '<span class="LC_nobreak">'.
         join('',
              map {
                  ('&nbsp;'x4).&mt($_.': [_1]',$response->{$_});
-             } @$headers).'</nobr>';
+             } @$headers).'</span>';
     if (@$headers || ! $single_response) {
         $Str .= '<br />';
     }
@@ -567,7 +582,7 @@ sub html_non_essay_results {
     if ($resptype eq 'radiobutton') {
         $submission = &HTML::Entities::encode($submission,'<>&"');
         $submission =~ s/=([^=])$//;
-        $submission = '<nobr>'.$submission.'</nobr>';
+        $submission = '<span class="LC_nobreak">'.$submission.'</span>';
     }
     $response->{'Submission'} = $submission;
     #
@@ -930,11 +945,13 @@ sub prepare_csv_output {
             time.'_'.rand(1000000000).'.csv';
     unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
         $r->log_error("Couldn't open $filename for output $!");
-        $r->print('<div class="LC_error">'
-                 .&mt('Problems occurred in writing the CSV file. '
-                     .'This error has been logged. '
-                     .'Please alert your LON-CAPA administrator.')
-                 .'</div>');
+        $r->print(
+            '<p class="LC_error">'
+           .&mt('Problems occurred in writing the CSV file.')
+           .' '.&mt('This error has been logged.')
+           .' '.&mt('Please alert your LON-CAPA administrator.')
+           .'</p>'
+        );
         $outputfile = undef;
     }
     #
@@ -1080,7 +1097,7 @@ sub CreateInterface {
     foreach ('HTML','Excel','CSV') {
         $output_selector .= '    <option value="'.lc($_).'"';
         if ($env{'form.output'} eq lc($_)) {
-            $output_selector .= ' selected ';
+            $output_selector .= ' selected="selected"';
         }
         $output_selector .='>'.&mt($_).'</option>'.$/;
     } 
@@ -1089,13 +1106,13 @@ sub CreateInterface {
     ## Environment variable initialization
     my $Str = '';
     $Str .= &Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports');
-    $Str .= '<p>';
+    $Str .= '<br />';
     $Str .= &Apache::loncommon::start_data_table();
     $Str .= &Apache::loncommon::start_data_table_header_row();
     $Str .= '<th>'.&mt('Sections').'</th>';
     $Str .= '<th>'.&mt('Groups').'</th>';
+    $Str .= '<th>'.&mt('Student Data').&Apache::loncommon::help_open_topic("Chart_Student_Data").'</th>';
     $Str .= '<th>'.&mt('Access Status').'</th>';
-#    $Str .= '<th>'.&mt('Output as [_1]',$output_selector).'</th>';
     $Str .= '<th>'.&mt('Options').'</th>';
     $Str .= '<th>'.&mt('Output Format').'</th>';
     $Str .= &Apache::loncommon::end_data_table_header_row();
@@ -1109,6 +1126,10 @@ sub CreateInterface {
     $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
     $Str .= '</td>';
     #
+    $Str .= '<td align="center">'."\n";
+    $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple', 5,undef);
+    $Str .= '</td>';
+    #
     $Str .= '<td align="center">';
     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
     $Str .= '</td>';
@@ -1143,18 +1164,21 @@ sub CreateInterface {
     }
     $prob_status_checkbox .= 'value="true" />';
     #
-    $Str .= '<td align="right" valign="top">'.
-        '<label><b>'.
-        &mt('Show problem [_1]',$prob_checkbox).'</b></label><br />'.
-        '<label><b>'.
-        &mt('Show correct answers [_1]',$ans_checkbox).'</b></label><br />'.
-        '<label><b>'.
-        &mt('Show all submissions [_1]',$all_sub_checkbox).
-        '</b></label><br />'.
-        '<label><b>'.
-        &mt('Show problem grading [_1]',$prob_status_checkbox).
-        '</b></label><br />'.
-        '</td>';
+    $Str .=
+        '<td valign="top">'
+       .'<label>'
+       .$prob_checkbox.&mt('Show problem')
+       .'</label><br />'
+       .'<label>'
+       .' '.$ans_checkbox.&mt('Show correct answers')
+       .'</label><br />'
+       .'<label>'
+       .$all_sub_checkbox.&mt('Show all submissions')
+       .'</label><br />'
+       .'<label>'
+       .$prob_status_checkbox.&mt('Show problem grading')
+       .'</label>'
+       .'</td>';
     #
     $Str .= '<td align="center" valign="top">'.$output_selector.'</td>';
     #