Diff for /loncom/interface/statistics/lonstudentsubmissions.pm between versions 1.39 and 1.40

version 1.39, 2005/03/17 18:50:06 version 1.40, 2005/04/07 06:56:24
Line 27 Line 27
 package Apache::lonstudentsubmissions;  package Apache::lonstudentsubmissions;
   
 use strict;  use strict;
 use Apache::lonnet();  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonhtmlcommon();  use Apache::lonhtmlcommon();
 use Apache::loncoursedata();  use Apache::loncoursedata();
Line 71  sub BuildStudentSubmissionsPage { Line 71  sub BuildStudentSubmissionsPage {
                                    '<h3>'.&mt('Loading student data').'</h3>');                                     '<h3>'.&mt('Loading student data').'</h3>');
     $r->rflush();      $r->rflush();
     #      #
     if (exists($ENV{'form.problemchoice'}) &&       if (exists($env{'form.problemchoice'}) && 
         ! exists($ENV{'form.SelectAnother'})) {          ! exists($env{'form.SelectAnother'})) {
         foreach my $button (@SubmitButtons) {          foreach my $button (@SubmitButtons) {
             if ($button->{'name'} eq 'break') {              if ($button->{'name'} eq 'break') {
                 $r->print("<br />\n");                  $r->print("<br />\n");
Line 120  sub BuildStudentSubmissionsPage { Line 120  sub BuildStudentSubmissionsPage {
                 my $resource = $Problems[0];                  my $resource = $Problems[0];
                 $r->print('<h1>'.$resource->title.'</h1>');                  $r->print('<h1>'.$resource->title.'</h1>');
                 $r->print('<h3>'.$resource->src.'</h3>');                  $r->print('<h3>'.$resource->src.'</h3>');
                 if ($ENV{'form.renderprob'} eq 'true') {                  if ($env{'form.renderprob'} eq 'true') {
                     $r->print(&Apache::lonstathelpers::render_resource($resource));                      $r->print(&Apache::lonstathelpers::render_resource($resource));
                     $r->rflush();                      $r->rflush();
                 }                  }
             }              }
             if ($ENV{'form.output'} eq 'excel') {              if ($env{'form.output'} eq 'excel') {
                 &prepare_excel_output($r,\@Problems,\@Students);                  &prepare_excel_output($r,\@Problems,\@Students);
             } elsif ($ENV{'form.output'} eq 'csv') {              } elsif ($env{'form.output'} eq 'csv') {
                 &prepare_csv_output($r,\@Problems,\@Students);                  &prepare_csv_output($r,\@Problems,\@Students);
             } else {              } else {
                 &prepare_html_output($r,\@Problems,\@Students);                  &prepare_html_output($r,\@Problems,\@Students);
Line 154  sub BuildStudentSubmissionsPage { Line 154  sub BuildStudentSubmissionsPage {
 ##  ##
 sub get_extra_response_headers {  sub get_extra_response_headers {
     my @extra_resp_headers;      my @extra_resp_headers;
     if ($ENV{'form.correctans'} eq 'true') {      if ($env{'form.correctans'} eq 'true') {
         push(@extra_resp_headers,'Correct');          push(@extra_resp_headers,'Correct');
     }       } 
     if ($ENV{'form.prob_status'} eq 'true') {      if ($env{'form.prob_status'} eq 'true') {
         push(@extra_resp_headers,'Award Detail');           push(@extra_resp_headers,'Award Detail'); 
         push(@extra_resp_headers,'Time');          push(@extra_resp_headers,'Time');
         push(@extra_resp_headers,'Attempt');          push(@extra_resp_headers,'Attempt');
Line 350  sub prepare_html_output { Line 350  sub prepare_html_output {
                         $maxrow = scalar(@$results);                          $maxrow = scalar(@$results);
                     }                      }
                     for (my $j=scalar(@$results)-1;$j>=0;$j--) {                      for (my $j=scalar(@$results)-1;$j>=0;$j--) {
                         if ($ENV{'form.all_sub'} ne 'true') {                          if ($env{'form.all_sub'} ne 'true') {
                             next if ($j ne scalar(@$results)-1);                              next if ($j ne scalar(@$results)-1);
                         }                          }
                         my $response = &hashify_response($results->[$j],                          my $response = &hashify_response($results->[$j],
Line 430  sub prepare_html_output { Line 430  sub prepare_html_output {
 sub hashify_response {  sub hashify_response {
     my ($response,$prob,$student,$partid,$respid) =@_;      my ($response,$prob,$student,$partid,$respid) =@_;
     my $resp_hash = {};      my $resp_hash = {};
     if ($ENV{'form.correctans'} eq 'true') {      if ($env{'form.correctans'} eq 'true') {
         $resp_hash->{'Correct'} =           $resp_hash->{'Correct'} = 
             &Apache::lonstathelpers::get_student_answer              &Apache::lonstathelpers::get_student_answer
             ($prob,$student->{'username'},$student->{'domain'},              ($prob,$student->{'username'},$student->{'domain'},
Line 636  sub prepare_excel_output { Line 636  sub prepare_excel_output {
     # Add headers to the worksheet      # Add headers to the worksheet
     my $rows_output = 0;      my $rows_output = 0;
     $worksheet->write($rows_output++,0,      $worksheet->write($rows_output++,0,
                     $ENV{'course.'.$ENV{'request.course.id'}.'.description'},                      $env{'course.'.$env{'request.course.id'}.'.description'},
                       $format->{'h1'});                        $format->{'h1'});
     $rows_output++;      $rows_output++;
     my $cols_output = 0;      my $cols_output = 0;
Line 725  sub prepare_excel_output { Line 725  sub prepare_excel_output {
                     my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid};                      my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid};
                     for (my $j=scalar(@$results)-1;$j>=0;$j--) {                      for (my $j=scalar(@$results)-1;$j>=0;$j--) {
                         $cols_output = $response_start_col;                          $cols_output = $response_start_col;
                         if ($ENV{'form.all_sub'} ne 'true') {                          if ($env{'form.all_sub'} ne 'true') {
                             next if ($j ne scalar(@$results)-1);                              next if ($j ne scalar(@$results)-1);
                         }                          }
                         my $response = &hashify_response($results->[$j],                          my $response = &hashify_response($results->[$j],
Line 878  sub prepare_csv_output { Line 878  sub prepare_csv_output {
     # Open a file      # Open a file
     my $outputfile;      my $outputfile;
     my $filename = '/prtspool/'.      my $filename = '/prtspool/'.
         $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'.          $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
             time.'_'.rand(1000000000).'.csv';              time.'_'.rand(1000000000).'.csv';
     unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {      unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
         $r->log_error("Couldn't open $filename for output $!");          $r->log_error("Couldn't open $filename for output $!");
Line 960  sub prepare_csv_output { Line 960  sub prepare_csv_output {
                         $results = [];                          $results = [];
                     }                      }
                     for (my $j=0; $j<scalar(@$results);$j++) {                      for (my $j=0; $j<scalar(@$results);$j++) {
                         if ($ENV{'form.all_sub'} ne 'true') {                          if ($env{'form.all_sub'} ne 'true') {
                             next if ($j != 0);                              next if ($j != 0);
                         }                          }
                         my $idx = scalar(@$results) - $j - 1;                          my $idx = scalar(@$results) - $j - 1;
Line 1029  sub CreateInterface { Line 1029  sub CreateInterface {
     my $output_selector = $/.'<select name="output">'.$/;      my $output_selector = $/.'<select name="output">'.$/;
     foreach ('HTML','Excel','CSV') {      foreach ('HTML','Excel','CSV') {
         $output_selector .= '    <option value="'.lc($_).'"';          $output_selector .= '    <option value="'.lc($_).'"';
         if ($ENV{'form.output'} eq lc($_)) {          if ($env{'form.output'} eq lc($_)) {
             $output_selector .= ' selected ';              $output_selector .= ' selected ';
         }          }
         $output_selector .='>'.&mt($_).'</option>'.$/;          $output_selector .='>'.&mt($_).'</option>'.$/;
Line 1058  sub CreateInterface { Line 1058  sub CreateInterface {
     #      #
     # Render problem checkbox      # Render problem checkbox
     my $prob_checkbox = '<input type="checkbox" name="renderprob" ';      my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
     if (exists($ENV{'form.renderprob'}) && $ENV{'form.renderprob'} eq 'true') {      if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
         $prob_checkbox .= 'checked ';          $prob_checkbox .= 'checked ';
     }      }
     $prob_checkbox .= 'value="true" />';      $prob_checkbox .= 'value="true" />';
     #      #
     # Compute correct answers checkbox      # Compute correct answers checkbox
     my $ans_checkbox = '<input type="checkbox" name="correctans" ';      my $ans_checkbox = '<input type="checkbox" name="correctans" ';
     if (exists($ENV{'form.correctans'}) && $ENV{'form.correctans'} eq 'true') {      if (exists($env{'form.correctans'}) && $env{'form.correctans'} eq 'true') {
         $ans_checkbox .= 'checked ';          $ans_checkbox .= 'checked ';
     }      }
     $ans_checkbox .= 'value="true" />';      $ans_checkbox .= 'value="true" />';
     #      #
     # Show all submissions checkbox      # Show all submissions checkbox
     my $all_sub_checkbox = '<input type="checkbox" name="all_sub" ';      my $all_sub_checkbox = '<input type="checkbox" name="all_sub" ';
     if (exists($ENV{'form.all_sub'}) &&       if (exists($env{'form.all_sub'}) && 
         $ENV{'form.all_sub'} eq 'true') {          $env{'form.all_sub'} eq 'true') {
         $all_sub_checkbox .= 'checked ';          $all_sub_checkbox .= 'checked ';
     }      }
     $all_sub_checkbox.= 'value="true" />';      $all_sub_checkbox.= 'value="true" />';
     #      #
     # problem status checkbox      # problem status checkbox
     my $prob_status_checkbox = '<input type="checkbox" name="prob_status" ';      my $prob_status_checkbox = '<input type="checkbox" name="prob_status" ';
     if (exists($ENV{'form.prob_status'}) &&       if (exists($env{'form.prob_status'}) && 
         $ENV{'form.prob_status'} eq 'true') {          $env{'form.prob_status'} eq 'true') {
         $prob_status_checkbox .= 'checked ';          $prob_status_checkbox .= 'checked ';
     }      }
     $prob_status_checkbox .= 'value="true" />';      $prob_status_checkbox .= 'value="true" />';

Removed from v.1.39  
changed lines
  Added in v.1.40


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