--- loncom/interface/statistics/lonstudentsubmissions.pm	2005/02/23 01:21:46	1.34
+++ loncom/interface/statistics/lonstudentsubmissions.pm	2005/03/17 18:50:06	1.39
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentsubmissions.pm,v 1.34 2005/02/23 01:21:46 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.39 2005/03/17 18:50:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -110,6 +110,9 @@ sub BuildStudentSubmissionsPage {
             push(@Problems,$resource);
         }
         # 
+        $r->print('<h4>'.
+                  &Apache::lonstatistics::section_and_enrollment_description().
+                  '</h4>');
         if (! scalar(@Problems) || ! defined($Problems[0])) {
             $r->print('resource is undefined');
         } else {
@@ -118,9 +121,7 @@ sub BuildStudentSubmissionsPage {
                 $r->print('<h1>'.$resource->title.'</h1>');
                 $r->print('<h3>'.$resource->src.'</h3>');
                 if ($ENV{'form.renderprob'} eq 'true') {
-                    $r->print(
-                              &Apache::lonstathelpers::render_resource({src => $resource->src})
-                              );
+                    $r->print(&Apache::lonstathelpers::render_resource($resource));
                     $r->rflush();
                 }
             }
@@ -217,7 +218,7 @@ sub prepare_html_output {
     my @extra_resp_headers = &get_extra_response_headers();
     #
     # Create the table header
-    my @student_columns = ('username','domain','id');
+    my @student_columns = ('username','domain','id','section');
     #
     my %headers;
     my $student_column_count = scalar(@student_columns);
@@ -267,6 +268,9 @@ sub prepare_html_output {
                 if ($partid =~/^\d+$/) {
                     $tmpname = $prob->part_display($partid);
                 }
+                if ($tmpname !~ /^part/) {
+                    $tmpname = 'Part '.$tmpname;
+                }
                 $headers{'part'} .= qq{<th colspan="$part_span">$tmpname</th>};
                 $nonempty_part_headers = 1;
             } else {
@@ -550,6 +554,8 @@ sub html_non_essay_results {
                     $option = $submission{$header};
                 }
                 push(@values,&HTML::Entities::encode($option));
+            } elsif ($original_header eq 'Time') {
+                push(@values,&Apache::lonlocal::locallocaltime($response->{$original_header}));
             } else {
                 # A normal column
                 push(@values,$response->{$original_header});
@@ -622,22 +628,9 @@ sub prepare_excel_output {
     $r->rflush();
     #
     # Create the excel spreadsheet
-    my $filename = '/prtspool/'.
-        $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.
-        time.'_'.rand(1000000000).'.xls';
-    my $workbook  = Spreadsheet::WriteExcel->new('/home/httpd'.$filename);
-    if (! defined($workbook)) {
-        $r->log_error("Error creating excel spreadsheet $filename: $!");
-        $r->print('<p>'.&mt("Unable to create new Excel file.  ".
-                            "This error has been logged.  ".
-                            "Please alert your LON-CAPA administrator").
-                  '</p>');
-        return undef;
-    }
-    #
-    $workbook->set_tempdir('/home/httpd/perl/tmp');
-    #
-    my $format = &Apache::loncommon::define_excel_formats($workbook);
+    my ($workbook,$filename,$format) = 
+        &Apache::loncommon::create_workbook($r);
+    return if (! defined($workbook));
     my $worksheet  = $workbook->addworksheet('Student Submission Data');
     #
     # Add headers to the worksheet
@@ -655,7 +648,7 @@ sub prepare_excel_output {
     $worksheet->write($partid_row,0,'Part ID',$format->{'bold'});
     $worksheet->write($respid_row,0,'Response ID',$format->{'bold'});
     # Student headers
-    my @StudentColumns = ('username','domain','id');
+    my @StudentColumns = ('username','domain','id','section');
     foreach (@StudentColumns) {
         $worksheet->write($header_row,$cols_output++,ucfirst($_),
                           $format->{'bold'});
@@ -899,7 +892,7 @@ sub prepare_csv_output {
     my @extra_resp_headers = &get_extra_response_headers();
     #
     # Create the table header
-    my @student_columns = ('username','domain','id');
+    my @student_columns = ('username','domain','id','section');
     #
     my %headers;
     push(@{$headers{'student'}},@student_columns);
@@ -1093,7 +1086,7 @@ sub CreateInterface {
     }
     $prob_status_checkbox .= 'value="true" />';
     #
-    $Str .= '<td align="right" halign="top">'.
+    $Str .= '<td align="right" valign="top">'.
         '<label><b>'.
         &mt('Show problem [_1]',$prob_checkbox).'</b></label><br />'.
         '<label><b>'.