Diff for /loncom/interface/statistics/lonstudentsubmissions.pm between versions 1.64 and 1.65

version 1.64, 2011/11/18 21:08:22 version 1.65, 2011/11/21 20:12:36
Line 35  use Apache::loncoursedata(); Line 35  use Apache::loncoursedata();
 use Apache::lonstatistics;  use Apache::lonstatistics;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonstathelpers;  use Apache::lonstathelpers;
   use Apache::lonmsgdisplay();
 use HTML::Entities();  use HTML::Entities();
 use Time::Local();  use Time::Local();
 use Spreadsheet::WriteExcel();  use Spreadsheet::WriteExcel();
Line 324  sub prepare_html_output { Line 325  sub prepare_html_output {
     my @extra_resp_headers = &get_extra_response_headers($show_named);      my @extra_resp_headers = &get_extra_response_headers($show_named);
     #      #
     # Create the table header      # Create the table header
     my @student_columns;      my @student_columns = &get_student_columns($show_named);
     if ($show_named) {  
         @student_columns = @Apache::lonstatistics::SelectedStudentData;  
         if (grep(/^all$/,@student_columns)) {  
             @student_columns = qw(fullname username domain id section status groups comments);  
         }  
     } else {  
         @student_columns = ('username');  
     }  
     #  
     my %headers;      my %headers;
     my $student_column_count = scalar(@student_columns);      my $student_column_count = scalar(@student_columns);
     $headers{'problem'} = qq{<th colspan="$student_column_count">\&nbsp;</th>};      $headers{'problem'} = qq{<th colspan="$student_column_count">\&nbsp;</th>};
     foreach (@student_columns) {      foreach my $field (@student_columns) {
         $headers{'student'}.= '<th>'.ucfirst($_).'</th>';          $headers{'student'}.= '<th>'.ucfirst($field).'</th>';
     }      }
     #      #
     # we put the headers into the %headers hash      # we put the headers into the %headers hash
     my $total_col = scalar(@student_columns);      my $total_col = $student_column_count;
     my $nonempty_part_headers = 0;      my $nonempty_part_headers = 0;
     #      #
     my %problem_analysis;      my %problem_analysis;
Line 839  sub prepare_excel_output { Line 831  sub prepare_excel_output {
     $worksheet->write($partid_row,0,'Part ID',$format->{'bold'});      $worksheet->write($partid_row,0,'Part ID',$format->{'bold'});
     $worksheet->write($respid_row,0,'Response ID',$format->{'bold'});      $worksheet->write($respid_row,0,'Response ID',$format->{'bold'});
     # Student headers      # Student headers
     my @StudentColumns;      my @StudentColumns = &get_student_columns($show_named);
     if ($show_named) {      foreach my $field (@StudentColumns) {
         @StudentColumns = qw(username domain id section);          $worksheet->write($header_row,$cols_output++,ucfirst($field),
     } else {  
          @StudentColumns = qw(username);  
     }  
     foreach (@StudentColumns) {  
         $worksheet->write($header_row,$cols_output++,ucfirst($_),  
                           $format->{'bold'});                            $format->{'bold'});
     }      }
     # Problem headers      # Problem headers
Line 956  sub prepare_excel_output { Line 943  sub prepare_excel_output {
             my $cols = 0;              my $cols = 0;
             foreach my $field (@StudentColumns) {              foreach my $field (@StudentColumns) {
                 if ($show_named) {                  if ($show_named) {
                     $worksheet->write($row,$cols++,                      my $value = $student->{$field};
                                       $student->{$field});                      if ($field eq 'comments') {
                           $value = &Apache::lonmsgdisplay::retrieve_instructor_comments
                                    ($student->{'username'},$student->{'domain'});
                       }
                       $worksheet->write($row,$cols++,$value);
                 } else {                  } else {
                     $worksheet->write($row,$cols++,                      $worksheet->write($row,$cols++,
                                       &mt('Anonymized'));                                        &mt('Anonymized'));
Line 1106  sub prepare_csv_output { Line 1097  sub prepare_csv_output {
     my @extra_resp_headers = &get_extra_response_headers($show_named);      my @extra_resp_headers = &get_extra_response_headers($show_named);
     #      #
     # Create the table header      # Create the table header
     my @student_columns = ('username','domain','id','section');      my @student_columns = &get_student_columns($show_named);
     if ($show_named) {  
         @student_columns = qw(username domain id section);  
     } else {  
         @student_columns = qw(username);  
     }  
     my $student_column_count = scalar(@student_columns);      my $student_column_count = scalar(@student_columns);
     #      #
     my %headers;      my %headers;
Line 1124  sub prepare_csv_output { Line 1110  sub prepare_csv_output {
     # we put the headers into the %headers hash      # we put the headers into the %headers hash
     my %problem_analysis;      my %problem_analysis;
     my %start_col;      my %start_col;
     my $max_column = scalar(@student_columns);      my $max_column = $student_column_count;
     foreach my $prob (@$problems) {      foreach my $prob (@$problems) {
         my $symb = $prob->symb();          my $symb = $prob->symb();
         my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);          my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
Line 1215  sub prepare_csv_output { Line 1201  sub prepare_csv_output {
         foreach my $row (@rows) {          foreach my $row (@rows) {
             my $student_row_data = '';              my $student_row_data = '';
             if ($show_named) {              if ($show_named) {
                 $student_row_data = '"'.join('","',                  foreach my $field (@student_columns) {
                                         map { $student->{$_}; }                      my $value = $student->{$field};
                                         @student_columns).'"';                      if ($field eq 'comments') {
                           $value = &Apache::lonmsgdisplay::retrieve_instructor_comments
                                    ($student->{'username'},$student->{'domain'});
                       }
                       $student_row_data .= '"'.&Apache::loncommon::csv_translate($value).'",';
                   }
                   $student_row_data =~ s/,$//;
             } else {              } else {
                 $student_row_data = '"'.&mt('Anonymized').'"';                  $student_row_data = '"'.&mt('Anonymized').'"';
             }              }
Line 1364  sub CreateInterface { Line 1356  sub CreateInterface {
     return $Str;      return $Str;
 }  }
   
   sub get_student_columns {
       my ($show_named) = @_; 
       my @student_columns;
       if ($show_named) {
           @student_columns = @Apache::lonstatistics::SelectedStudentData;
           if (grep(/^all$/,@student_columns)) {
               @student_columns = qw(fullname username domain id section status groups comments);
           }
       } else {
           @student_columns = ('username');
       }
       return @student_columns;
   } 
   
 1;  1;
   
 __END__  __END__

Removed from v.1.64  
changed lines
  Added in v.1.65


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>