Diff for /loncom/interface/statistics/lonstudentassessment.pm between versions 1.105 and 1.114

version 1.105, 2004/09/23 17:48:00 version 1.114, 2005/02/25 19:48:01
Line 56  use Apache::loncommon(); Line 56  use Apache::loncommon();
 use Apache::loncoursedata;  use Apache::loncoursedata;
 use Apache::lonnet; # for logging porpoises  use Apache::lonnet; # for logging porpoises
 use Apache::lonlocal;  use Apache::lonlocal;
   use Time::HiRes;
 use Spreadsheet::WriteExcel;  use Spreadsheet::WriteExcel;
 use Spreadsheet::WriteExcel::Utility();  use Spreadsheet::WriteExcel::Utility();
   
Line 176  sub BuildStudentAssessmentPage { Line 177  sub BuildStudentAssessmentPage {
     my $initialize     = \&html_initialize;      my $initialize     = \&html_initialize;
     my $output_student = \&html_outputstudent;      my $output_student = \&html_outputstudent;
     my $finish         = \&html_finish;      my $finish         = \&html_finish;
       &Apache::lonnet::logthis('got here! 1');
     #      #
     if ($output_mode eq 'excel') {      if ($output_mode eq 'excel') {
         $initialize     = \&excel_initialize;          $initialize     = \&excel_initialize;
Line 187  sub BuildStudentAssessmentPage { Line 189  sub BuildStudentAssessmentPage {
         $finish         = \&csv_finish;          $finish         = \&csv_finish;
     }      }
     #      #
       &Apache::lonnet::logthis('got here! 2');
     if($c->aborted()) {  return ; }      if($c->aborted()) {  return ; }
     #      #
     # Determine which students we want to look at      # Determine which students we want to look at
Line 211  sub BuildStudentAssessmentPage { Line 214  sub BuildStudentAssessmentPage {
     #      #
     # Call the initialize routine selected above      # Call the initialize routine selected above
     $initialize->($r);      $initialize->($r);
       &Apache::lonnet::logthis('got here! 3');
     foreach my $student (@Students) {      foreach my $student (@Students) {
         if($c->aborted()) {           if($c->aborted()) { 
             $finish->($r);              $finish->($r);
Line 327  sub CreateInterface { Line 331  sub CreateInterface {
     $Str .= '<tr><td align="center">'."\n";      $Str .= '<tr><td align="center">'."\n";
     $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);      $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
     $Str .= '</td><td align="center">';      $Str .= '</td><td align="center">';
     my $only_seq_with_assessments = sub {   
         my $s=shift;  
         if ($s->{'num_assess'} < 1) {   
             return 0;  
         } else {   
             return 1;  
         }  
     };  
     $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',      $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',
                                                       5,undef);                                                        5,undef);
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
     $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);      $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
     $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,      $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
                                               $only_seq_with_assessments);  
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
     $Str .= &CreateAndParseOutputSelector();      $Str .= &CreateAndParseOutputSelector();
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
Line 357  sub CreateInterface { Line 352  sub CreateInterface {
     $Str .= '<input type="submit" name="ClearCache" value="'.      $Str .= '<input type="submit" name="ClearCache" value="'.
         &mt('Clear Caches').'" />';          &mt('Clear Caches').'" />';
     $Str .= '&nbsp;'x5;      $Str .= '&nbsp;'x5;
       $Str .= 
           &mt('Status[_1]',
               '<input type="text" name="stats_status" size="60" value="" />');
     $Str .= '<br />';      $Str .= '<br />';
     return $Str;      return $Str;
 }  }
Line 516  my @OutputDataOptions = Line 514  my @OutputDataOptions =
        maximum_row => 0,         maximum_row => 0,
        shortdesc => 'Number of Tries before success on each Problem Part',         shortdesc => 'Number of Tries before success on each Problem Part',
        longdesc =>'The number of tries before success on each problem part.',         longdesc =>'The number of tries before success on each problem part.',
          non_html_notes => 'negative values indicate an incorrect problem',
        },         },
      { name  =>'Parts Correct',       { name  =>'Parts Correct',
        base  =>'tries',         base  =>'tries',
Line 609  Return a line of the chart for a student Line 608  Return a line of the chart for a student
     my %prog_state;   # progress state used by loncommon PrgWin routines      my %prog_state;   # progress state used by loncommon PrgWin routines
     my $total_sum_width;      my $total_sum_width;
   
       my %width; # Holds sequence width information
       my @sequences;
       my $navmap; # Have to keep this around since weakref is a bit zealous
   
 sub html_initialize {  sub html_initialize {
     my ($r) = @_;      my ($r) = @_;
     #      #
Line 616  sub html_initialize { Line 619  sub html_initialize {
     $count = 0;      $count = 0;
     $nodata_count = 0;      $nodata_count = 0;
     undef(%prog_state);      undef(%prog_state);
       undef(%width);
       undef($navmap);
       undef(@sequences);
       &Apache::lonnet::logthis('called html_initialize');
     #      #
     $r->print("<h3>".$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.      $r->print("<h3>".$ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
               "&nbsp;&nbsp;".localtime(time)."</h3>");                "&nbsp;&nbsp;".localtime(time)."</h3>");
       #
     if ($chosen_output->{'base'} !~ /^final table/) {      if ($chosen_output->{'base'} !~ /^final table/) {
         $r->print("<h3>".$chosen_output->{'shortdesc'}."</h3>");                  $r->print("<h3>".$chosen_output->{'shortdesc'}."</h3>");        
     }      }
Line 635  sub html_initialize { Line 642  sub html_initialize {
     #      #
     # Compute the column widths and output the sequence titles      # Compute the column widths and output the sequence titles
     my $total_count;      my $total_count;
     foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()){      ($navmap,@sequences) = 
         #          &Apache::lonstatistics::selected_sequences_with_assessments();
         # Comptue column widths      if (! ref($navmap)) {
         $sequence->{'width_sum'} = 0;          # Unable to get data, so bail out
           $r->print("<h3>".
                     &mt('Unable to retrieve course information.').
                     '</h3>');
       }
       #
       # Compute sequence widths
       my $starttime = Time::HiRes::time;
       foreach my $seq (@sequences) {
           my $symb = $seq->symb;
           my $title = $seq->compTitle;
           $width{$symb}->{'width_sum'} = 0;
           # Compute width of sum
         if ($chosen_output->{'sequence_sum'}) {          if ($chosen_output->{'sequence_sum'}) {
             if ($chosen_output->{'every_problem'}) {              if ($chosen_output->{'every_problem'}) {
                 # Use 1 digit for a space                  # Use 1 digit for a space
                 $sequence->{'width_sum'} += 1;                              $width{$symb}->{'width_sum'} += 1;            
             }              }
     $total_count += $sequence->{'num_assess_parts'};      $total_count += $width{$symb}->{'num_assess_parts'};
             # Use 3 digits for the sum              # Use 3 digits for the sum
             $sequence->{'width_sum'} += 3;              $width{$symb}->{'width_sum'} += 3;
         }          }
           # Compute width of maximum
         if ($chosen_output->{'sequence_max'}) {          if ($chosen_output->{'sequence_max'}) {
             if ($sequence->{'width_sum'}>0) {              if ($width{$symb}->{'width_sum'}>0) {
                 # One digit for the '/'                  # One digit for the '/'
                 $sequence->{'width_sum'} +=1;                  $width{$symb}->{'width_sum'} +=1;
             }              }
             # Use 3 digits for the total              # Use 3 digits for the total
             $sequence->{'width_sum'}+=3;              $width{$symb}->{'width_sum'}+=3;
         }          }
  #   #
         if ($chosen_output->{'every_problem'}) {          if ($chosen_output->{'every_problem'}) {
             # one problem per digit              # one problem per digit
             $sequence->{'width_problem'} = $sequence->{'num_assess_parts'};              $width{$symb}->{'width_parts'}=0;
               $starttime = Time::HiRes::time;
               my @resources = 
                   $navmap->retrieveResources($seq,sub { shift->is_problem(); },
                                              0,0,0);
               $starttime = Time::HiRes::time;
               foreach my $res (@resources) {
                   my @parts = @{$res->parts};
                   $width{$symb}->{'width_parts'} += scalar(@parts);
               } 
               &Apache::lonnet::logthis('2elapsed:'.(Time::HiRes::time-$starttime));            $width{$symb}->{'width_problem'} += 
                   $width{$symb}->{'width_parts'};
         } else {          } else {
             $sequence->{'width_problem'} = 0;              $width{$symb}->{'width_problem'} = 0;
         }          }
         $sequence->{'width_total'} = $sequence->{'width_problem'} +           $width{$symb}->{'width_total'} = $width{$symb}->{'width_problem'} + 
                                      $sequence->{'width_sum'};                                       $width{$symb}->{'width_sum'};
         if ($sequence->{'width_total'} < length(&HTML::Entities::decode($sequence->{'title'}))) {          if ($width{$symb}->{'width_total'} < length(&HTML::Entities::decode($title))) {
             $sequence->{'width_total'} = length(&HTML::Entities::decode($sequence->{'title'}));              $width{$symb}->{'width_total'} = length(&HTML::Entities::decode($title));
         }          }
         #          #
         # Output the sequence titles          # Output the sequence titles
         $Str .=           $Str .= $title.(' 'x($width{$symb}->{'width_total'}-
             $sequence->{'title'}.' 'x($sequence->{'width_total'}-                              length($title)
                                       length($sequence->{'title'})                              )).$padding;
                                       ).$padding;  
     }      }
     $total_sum_width = length($total_count)+1;      $total_sum_width = length($total_count)+1;
     $Str .= "    total</pre>\n";      $Str .= "    total</pre>\n";
Line 686  sub html_initialize { Line 716  sub html_initialize {
 sub html_outputstudent {  sub html_outputstudent {
     my ($r,$student) = @_;      my ($r,$student) = @_;
     my $Str = '';      my $Str = '';
       return if (! defined($navmap));
     #      #
     if($count++ % 5 == 0 && $count > 0) {      if($count++ % 5 == 0 && $count > 0) {
         $r->print("</pre><pre>");          $r->print("</pre><pre>");
Line 721  sub html_outputstudent { Line 752  sub html_outputstudent {
     # By sequence build up the data      # By sequence build up the data
     my $studentstats;      my $studentstats;
     my $PerformanceStr = '';      my $PerformanceStr = '';
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {      foreach my $seq (@sequences) {
           &Apache::lonnet::logthis('computing student data for '.$seq->compTitle);
         my ($performance,$performance_length,$score,$seq_max,$rawdata);          my ($performance,$performance_length,$score,$seq_max,$rawdata);
         if ($chosen_output->{'tries'}) {          if ($chosen_output->{'tries'}) {
             ($performance,$performance_length,$score,$seq_max,$rawdata) =              ($performance,$performance_length,$score,$seq_max,$rawdata) =
                 &StudentTriesOnSequence($student,\%StudentsData,                  &student_tries_on_sequence($student,\%StudentsData,
                                         $seq,$show_links);                                             $navmap,$seq,$show_links);
         } else {          } else {
             ($performance,$performance_length,$score,$seq_max,$rawdata) =              ($performance,$performance_length,$score,$seq_max,$rawdata) =
                 &StudentPerformanceOnSequence($student,\%StudentsData,                  &student_performance_on_sequence($student,\%StudentsData,
                                               $seq,$show_links);                                                   $navmap,$seq,$show_links);
         }          }
         my $ratio='';          my $ratio='';
         if ($chosen_output->{'every_problem'}) {          if ($chosen_output->{'every_problem'}) {
Line 752  sub html_outputstudent { Line 784  sub html_outputstudent {
             $performance = '';              $performance = '';
     $performance_length=0;      $performance_length=0;
         }          }
         $performance .= ' 'x($seq->{'width_total'}-$performance_length-$seq->{'width_sum'}).          $performance .= ' 'x($width{$seq->symb}->{'width_total'} -
                                $performance_length -
                                $width{$seq->symb}->{'width_sum'}).
             $ratio;              $ratio;
         #          #
         $Str .= $performance.$padding;          $Str .= $performance.$padding;
         #          #
         $studentstats->{$seq->{'symb'}}->{'score'}= $score;          $studentstats->{$seq->symb}->{'score'}= $score;
         $studentstats->{$seq->{'symb'}}->{'max'}  = $seq_max;          $studentstats->{$seq->symb}->{'max'}  = $seq_max;
     }      }
     #      #
     # Total it up and store the statistics info.      # Total it up and store the statistics info.
Line 790  sub html_outputstudent { Line 824  sub html_outputstudent {
   
 sub html_finish {  sub html_finish {
     my ($r) = @_;      my ($r) = @_;
       return if (! defined($navmap));
     #      #
     # Check for suppressed output and close the progress window if so      # Check for suppressed output and close the progress window if so
     $r->print("</pre>\n");       $r->print("</pre>\n"); 
Line 801  sub html_finish { Line 836  sub html_finish {
         }          }
     }      }
     $r->rflush();      $r->rflush();
       undef($navmap);
     return;      return;
 }  }
   
Line 812  sub StudentAverageTotal { Line 848  sub StudentAverageTotal {
         '<th>'.&mt('Average').'</th>'.          '<th>'.&mt('Average').'</th>'.
         '<th>'.&mt('Maximum').'</th>'.          '<th>'.&mt('Maximum').'</th>'.
         '</tr>'.$/;          '</tr>'.$/;
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {      foreach my $seq (@sequences) {
           my $symb = $seq->symb;
         my $ave;          my $ave;
         my $num_students = $Statistics->{$seq->{'symb'}}->{'num_students'};          my $num_students = $Statistics->{$symb}->{'num_students'};
         if ($num_students > 0) {          if ($num_students > 0) {
             $ave = int(100*              $ave = int(100*
                        ($Statistics->{$seq->{'symb'}}->{'score'}/$num_students)                         ($Statistics->{$symb}->{'score'}/$num_students)
                        )/100;                         )/100;
         } else {          } else {
             $ave = 0;              $ave = 0;
         }          }
         my $max = $Statistics->{$seq->{'symb'}}->{'max'};          my $max = $Statistics->{$symb}->{'max'};
         $ave = sprintf("%.2f",$ave);          $ave = sprintf("%.2f",$ave);
         $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.          $Str .= '<tr><td>'.$seq->compTitle.'</td>'.
             '<td align="right">'.$ave.'&nbsp;</td>'.              '<td align="right">'.$ave.'&nbsp;</td>'.
             '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";              '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";
     }      }
Line 851  sub SingleStudentTotal { Line 888  sub SingleStudentTotal {
     my $total = 0;      my $total = 0;
     my $total_max = 0;      my $total_max = 0;
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {      foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
         my $value = $Statistics->{$seq->{'symb'}}->{'score'};          my $value = $Statistics->{$seq->symb}->{'score'};
         my $max = $Statistics->{$seq->{'symb'}}->{'max'};          my $max = $Statistics->{$seq->symb}->{'max'};
         $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.          $Str .= '<tr><td>'.&HTML::Entities::encode($seq->compTitle).'</td>'.
             '<td align="right">'.$value.'</td>'.              '<td align="right">'.$value.'</td>'.
                 '<td align="right">'.$max.'</td></tr>'."\n";                  '<td align="right">'.$max.'</td></tr>'."\n";
         $total += $value;          $total += $value;
Line 951  sub excel_initialize { Line 988  sub excel_initialize {
     # Determine rows       # Determine rows 
     my $header_row = $rows_output++;      my $header_row = $rows_output++;
     my $description_row = $rows_output++;      my $description_row = $rows_output++;
       my $notes_row = $rows_output++;
     $rows_output++;        # blank row      $rows_output++;        # blank row
     my $summary_header_row;      my $summary_header_row;
     if ($chosen_output->{'summary_table'}) {      if ($chosen_output->{'summary_table'}) {
Line 1025  sub excel_initialize { Line 1063  sub excel_initialize {
     $cols_output = 0;      $cols_output = 0;
     $excel_sheet->write($description_row,$cols_output++,      $excel_sheet->write($description_row,$cols_output++,
                         $chosen_output->{'shortdesc'},                          $chosen_output->{'shortdesc'},
                         $format->{'h3'});                          $format->{'b'});
       #
       $cols_output = 0;
       $excel_sheet->write($notes_row,$cols_output++,
                           $chosen_output->{'non_html_notes'},
                           $format->{'i'});
       
     ##############################################      ##############################################
     # Output headings for the raw data      # Output headings for the raw data
     ##############################################      ##############################################
Line 1064  sub excel_initialize { Line 1108  sub excel_initialize {
                                             $cols_output++,                                              $cols_output++,
                                             $res->{'title'}.' part '.$part,                                              $res->{'title'}.' part '.$part,
                                             $format->{'bold'});                                              $format->{'bold'});
                           $count++;
                     }                      }
                 } else {                  } else {
                     $excel_sheet->write($resource_name_row,                      $excel_sheet->write($resource_name_row,
                                         $cols_output++,                                          $cols_output++,
                                         $res->{'title'},$format->{'bold'});                                          $res->{'title'},$format->{'bold'});
                       $count++;
                 }                  }
                 $count++;  
             }              }
         }          }
         # Determine ending cell          # Determine ending cell
Line 1192  sub excel_initialize { Line 1237  sub excel_initialize {
             #              #
             if ($chosen_output->{'sequence_sum'} &&               if ($chosen_output->{'sequence_sum'} && 
                 $chosen_output->{'every_problem'}) {                  $chosen_output->{'every_problem'}) {
                 my %replaceCells;   my %replaceCells=
                 $replaceCells{$seq->{'Excel:startcell'}} =       ('^'.$seq->{'Excel:startcell'}.':'.
                     &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell           $seq->{'Excel:endcell'}.'$' =>
                     ($maximum_data_row,$seq->{'Excel:startcol'});       &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$seq->{'Excel:startcol'}).':'.
                 $replaceCells{$seq->{'Excel:endcell'}} =        &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$seq->{'Excel:endcol'}));
                     &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell  
                     ($maximum_data_row,$seq->{'Excel:endcol'});  
                 $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,                  $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
                                              $seq->{'Excel:sum'},undef,                                               $seq->{'Excel:sum'},undef,
                                              %replaceCells);       %replaceCells);
   
             } elsif ($chosen_output->{'sequence_sum'}) {              } elsif ($chosen_output->{'sequence_sum'}) {
                 $excel_sheet->write($maximum_data_row,$cols_output++,$max);                  $excel_sheet->write($maximum_data_row,$cols_output++,$max);
             }              }
Line 1218  sub excel_initialize { Line 1262  sub excel_initialize {
         if ($chosen_output->{'grand_maximum'}) {          if ($chosen_output->{'grand_maximum'}) {
             $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,              $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
                                          $maximum_formula,undef,                                           $maximum_formula,undef,
                                          %total_cell_translation);                                           %maximum_cell_translation);
         }          }
     } # End of MAXIMUM row output  if ($chosen_output->{'maximum_row'}) {      } # End of MAXIMUM row output  if ($chosen_output->{'maximum_row'}) {
     $rows_output = $first_data_row;      $rows_output = $first_data_row;
Line 1290  sub excel_initialize { Line 1334  sub excel_initialize {
     # Initialize progress window      # Initialize progress window
     %prog_state=&Apache::lonhtmlcommon::Create_PrgWin      %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
         ($r,'Excel File Compilation Status',          ($r,'Excel File Compilation Status',
          'Excel File Compilation Progress', $studentcount);           'Excel File Compilation Progress', $studentcount,
            'inline',undef,'Statistics','stats_status');
     #      #
     &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,      &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
                                           'Processing first student');                                            'Processing first student');
Line 1333  sub excel_outputstudent { Line 1378  sub excel_outputstudent {
         $total_cell_translation{$seq->{'Excel:scorecell'}} =           $total_cell_translation{$seq->{'Excel:scorecell'}} = 
             &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell              &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
                         ($rows_output,$seq->{'Excel:scorecol'});                          ($rows_output,$seq->{'Excel:scorecol'});
           # and maximum cell
           $maximum_cell_translation{$seq->{'Excel:maxcell'}} = 
               &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
               ($rows_output,$seq->{'Excel:maxcol'});
         #          #
         my ($performance,$performance_length,$score,$seq_max,$rawdata);          my ($performance,$performance_length,$score,$seq_max,$rawdata);
         if ($chosen_output->{'tries'} || $chosen_output->{'correct'}){          if ($chosen_output->{'tries'} || $chosen_output->{'correct'}){
Line 1366  sub excel_outputstudent { Line 1415  sub excel_outputstudent {
         if ($chosen_output->{'sequence_sum'} &&           if ($chosen_output->{'sequence_sum'} && 
             $chosen_output->{'every_problem'}) {              $chosen_output->{'every_problem'}) {
             # Write a formula for the sum of this sequence              # Write a formula for the sum of this sequence
             my %replaceCells;              my %replaceCells=
             $replaceCells{$seq->{'Excel:startcell'}} =    ('^'.$seq->{'Excel:startcell'}.':'.$seq->{'Excel:endcell'}.'$'
                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell   => 
                             ($rows_output,$seq->{'Excel:startcol'});   &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$seq->{'Excel:startcol'}).':'.
             $replaceCells{$seq->{'Excel:endcell'}} =    &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$seq->{'Excel:endcol'})
                 &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell   );
                             ($rows_output,$seq->{'Excel:endcol'});              # The undef is for the format    
             # The undef is for the format      $excel_sheet->repeat_formula($rows_output,$cols_output++,
             if (scalar(keys(%replaceCells)) == 1) {   $seq->{'Excel:sum'},undef,
                 $excel_sheet->repeat_formula($rows_output,$cols_output++,   %replaceCells);
                                              $seq->{'Excel:sum'},undef,  
                                              %replaceCells,%replaceCells);  
             } else {  
                 $excel_sheet->repeat_formula($rows_output,$cols_output++,  
                                              $seq->{'Excel:sum'},undef,  
                                              %replaceCells);  
             }  
         } elsif ($chosen_output->{'sequence_sum'}) {          } elsif ($chosen_output->{'sequence_sum'}) {
             if ($score eq ' ') {              if ($score eq ' ') {
                 $cols_output++;                  $cols_output++;
Line 1403  sub excel_outputstudent { Line 1445  sub excel_outputstudent {
     if ($chosen_output->{'grand_maximum'}) {      if ($chosen_output->{'grand_maximum'}) {
         $excel_sheet->repeat_formula($rows_output,$cols_output++,          $excel_sheet->repeat_formula($rows_output,$cols_output++,
                                      $maximum_formula,undef,                                       $maximum_formula,undef,
                                      %total_cell_translation);                                       %maximum_cell_translation);
     }      }
     #      #
     # Bookkeeping      # Bookkeeping
Line 1487  END Line 1529  END
     my $studentcount = scalar(@Apache::lonstatistics::Students);      my $studentcount = scalar(@Apache::lonstatistics::Students);
     %prog_state=&Apache::lonhtmlcommon::Create_PrgWin      %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
         ($r,'CSV File Compilation Status',          ($r,'CSV File Compilation Status',
          'CSV File Compilation Progress', $studentcount);           'CSV File Compilation Progress', $studentcount,
            'inline',undef,'Statistics','stats_status');
     #      #
     # Open a file      # Open a file
     $filename = '/prtspool/'.      $filename = '/prtspool/'.
Line 1506  END Line 1549  END
     print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.      print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.
         '"'.&Apache::loncommon::csv_translate(scalar(localtime(time))).'"'.          '"'.&Apache::loncommon::csv_translate(scalar(localtime(time))).'"'.
             "\n";              "\n";
       foreach my $item ('shortdesc','non_html_notes') {
           next if (! exists($chosen_output->{$item}));
           print $outputfile 
               '"'.&Apache::loncommon::csv_translate($chosen_output->{$item}).'"'.
               "\n";
       }
     #      #
     # Print out the headings      # Print out the headings
     my $sequence_row = '';      my $sequence_row = '';
Line 1690  Inputs: Line 1739  Inputs:
   
 #######################################################  #######################################################
 #######################################################  #######################################################
 sub StudentTriesOnSequence {  sub student_tries_on_sequence {
     my ($student,$studentdata,$seq,$links) = @_;      my ($student,$studentdata,$navmap,$seq,$links) = @_;
     $links = 'no' if (! defined($links));      $links = 'no' if (! defined($links));
     my $Str = '';      my $Str = '';
     my ($sum,$max) = (0,0);      my ($sum,$max) = (0,0);
Line 1699  sub StudentTriesOnSequence { Line 1748  sub StudentTriesOnSequence {
     my @TriesData = ();      my @TriesData = ();
     my $tries;      my $tries;
     my $hasdata = 0; # flag - true if the student has any data on the sequence      my $hasdata = 0; # flag - true if the student has any data on the sequence
     foreach my $resource (@{$seq->{'contents'}}) {      my @resources = 
         next if ($resource->{'type'} ne 'assessment');          $navmap->retrieveResources($seq,sub { shift->is_problem(); },0,0,0);
         my $resource_data = $studentdata->{$resource->{'symb'}};      foreach my $resource (@resources) {
           my $resource_data = $studentdata->{$resource->symb};
         my $value = '';          my $value = '';
         foreach my $partnum (@{$resource->{'parts'}}) {          foreach my $partnum (@{$resource->parts()}) {
             $tries = undef;              $tries = undef;
             $max++;              $max++;
             $performance_length++;              $performance_length++;
Line 1763  sub StudentTriesOnSequence { Line 1813  sub StudentTriesOnSequence {
                 }                  }
             }              }
             #              #
             if (! defined($tries) || $symbol eq '.') {              if (! defined($tries)) {
                 $tries = $symbol;                  $tries = 0;
               }
               if ($status =~ /^(incorrect|ungraded)/) {
                   # Bug 3390: show '-' for tries on incorrect problems 
                   # (csv & excel only)
                   push(@TriesData,-$tries);
               } else {
                   push (@TriesData,$tries);
             }              }
             push (@TriesData,$tries);  
             #              #
             if ( ($links eq 'yes' && $symbol ne ' ') ||              if ( ($links eq 'yes' && $symbol ne ' ') ||
                  ($links eq 'all')) {                   ($links eq 'all')) {
Line 1774  sub StudentTriesOnSequence { Line 1830  sub StudentTriesOnSequence {
                     &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1');                      &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1');
                 }                  }
                 $symbol = '<a href="/adm/grades'.                  $symbol = '<a href="/adm/grades'.
                     '?symb='.&Apache::lonnet::escape($resource->{'symb'}).                      '?symb='.&Apache::lonnet::escape($resource->symb).
                         '&student='.$student->{'username'}.                          '&student='.$student->{'username'}.
                             '&userdom='.$student->{'domain'}.                              '&userdom='.$student->{'domain'}.
                                 '&command=submission">'.$symbol.'</a>';                                  '&command=submission">'.$symbol.'</a>';
Line 1783  sub StudentTriesOnSequence { Line 1839  sub StudentTriesOnSequence {
         }          }
         $Str .= $value;          $Str .= $value;
     }      }
     if ($seq->{'randompick'}) {      if ($seq->randompick()) {
         $max = $seq->{'randompick'};          $max = $seq->randompick();
     }      }
     if (! $hasdata && $sum == 0) {      if (! $hasdata && $sum == 0) {
         $sum = ' ';          $sum = ' ';
Line 1817  Inputs: Line 1873  Inputs:
   
 #######################################################  #######################################################
 #######################################################  #######################################################
 sub StudentPerformanceOnSequence {  sub student_performance_on_sequence {
     my ($student,$studentdata,$seq,$links) = @_;      my ($student,$studentdata,$navmap,$seq,$links) = @_;
     $links = 'no' if (! defined($links));      $links = 'no' if (! defined($links));
     my $Str = ''; # final result string      my $Str = ''; # final result string
     my ($score,$max) = (0,0);      my ($score,$max) = (0,0);
Line 1827  sub StudentPerformanceOnSequence { Line 1883  sub StudentPerformanceOnSequence {
     my @ScoreData = ();      my @ScoreData = ();
     my $partscore;      my $partscore;
     my $hasdata = 0; # flag, 0 if there were no submissions on the sequence      my $hasdata = 0; # flag, 0 if there were no submissions on the sequence
     foreach my $resource (@{$seq->{'contents'}}) {      my @resources = 
         next if ($resource->{'type'} ne 'assessment');          $navmap->retrieveResources($seq,sub { shift->is_problem(); },0,0,0);
         my $resource_data = $studentdata->{$resource->{'symb'}};      foreach my $resource (@resources) {
         foreach my $part (@{$resource->{'parts'}}) {          my $symb = $resource->symb;
           my $resource_data = $studentdata->{$symb};
           foreach my $part (@{$resource->parts()}) {
             $partscore = undef;              $partscore = undef;
             my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',              my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
                                               $resource->{'symb'},                                                $symb,
                                               $student->{'domain'},                                                $student->{'domain'},
                                               $student->{'username'},                                                $student->{'username'},
                                               $student->{'section'});                                                $student->{'section'});
Line 1871  sub StudentPerformanceOnSequence { Line 1929  sub StudentPerformanceOnSequence {
                     $max -= $weight; # Do not count 'excused' problems.                      $max -= $weight; # Do not count 'excused' problems.
                 }                  }
                 $hasdata = 1;                  $hasdata = 1;
             } else {              } elsif (!exists($resource_data->{'resource.'.$part.'.awarded'})){
                 # Unsolved.  Did they try?                  # Unsolved.  Did they try?
                 if (exists($resource_data->{'resource.'.$part.'.tries'})){                  if (exists($resource_data->{'resource.'.$part.'.tries'})){
                     $symbol = '.';                      $symbol = '.';
Line 1888  sub StudentPerformanceOnSequence { Line 1946  sub StudentPerformanceOnSequence {
             #              #
             if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {              if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {
                 $symbol = '<a href="/adm/grades'.                  $symbol = '<a href="/adm/grades'.
                     '?symb='.&Apache::lonnet::escape($resource->{'symb'}).                      '?symb='.&Apache::lonnet::escape($symb).
                     '&student='.$student->{'username'}.                      '&student='.$student->{'username'}.
                     '&userdom='.$student->{'domain'}.                      '&userdom='.$student->{'domain'}.
                     '&command=submission">'.$symbol.'</a>';                      '&command=submission">'.$symbol.'</a>';

Removed from v.1.105  
changed lines
  Added in v.1.114


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