Diff for /loncom/interface/statistics/lonproblemanalysis.pm between versions 1.80 and 1.82

version 1.80, 2004/03/16 16:30:31 version 1.82, 2004/03/22 17:25:27
Line 160  sub BuildProblemAnalysisPage { Line 160  sub BuildProblemAnalysisPage {
                                        $ProblemData,                                         $ProblemData,
                                        \@Students);                                         \@Students);
             } elsif ($current_problem->{'resptype'} eq 'numerical') {              } elsif ($current_problem->{'resptype'} eq 'numerical') {
                     &NumericalResponseAnalysis($r,$current_problem,                  ## 
                                                $ProblemData,\@Students);                  ## analyze all responses of a problem at once
                   my $res = $current_problem->{'resource'};
                   foreach my $partid (@{$res->{'parts'}}) {
                       $current_problem->{'part'} = $partid;
                       foreach my $respid (@{$res->{'partdata'}->{$partid}->{'ResponseIds'}}) {
                           $current_problem->{'respid'}=$respid;
                           &NumericalResponseAnalysis($r,$current_problem,
                                                      $ProblemData,\@Students);
                       }
                   }
             } else {              } else {
                 $r->print('<h2>This analysis is not supported</h2>');                  $r->print('<h2>This analysis is not supported</h2>');
             }              }
Line 188  sub BuildProblemAnalysisPage { Line 197  sub BuildProblemAnalysisPage {
 sub NumericalResponseAnalysis {  sub NumericalResponseAnalysis {
     my ($r,$problem,$ProblemData,$Students) = @_;      my ($r,$problem,$ProblemData,$Students) = @_;
     my $c = $r->connection();      my $c = $r->connection();
     my ($resource,$respid) = ($problem->{'resource'},      my ($resource,$partid,$respid) = ($problem->{'resource'},
                               $problem->{'respid'});                                        $problem->{'part'},
     $r->print('Response '.$respid.'</br />');                                        $problem->{'respid'});
       #
       if (scalar(@{$resource->{'parts'}})>1) {
           if (@{$resource->{'partdata'}->{$partid}->{'ResponseIds'}}>1) {
               $r->print('<h3>'.
                         &mt('Part [_1], response [_2].',$partid,$respid).
                         '</h3>');
           } else { 
               $r->print('<h3>'.
                         &mt('Part [_1]',$partid,$respid).
                         '</h3>');
           }
       } elsif (@{$resource->{'partdata'}->{$partid}->{'ResponseIds'}}>1) {
           $r->print('<h3>'.&mt('Response [_1]',$respid).'</h3>');
       }
       #
     my $analysis_html;      my $analysis_html;
     my $PerformanceData =       my $PerformanceData = &Apache::loncoursedata::get_response_data
         &Apache::loncoursedata::get_response_data          (\@Apache::lonstatistics::SelectedSections,
         ($Students,$resource->{'symb'},$respid);           $Apache::lonstatistics::enrollment_status,
            $resource->{'symb'},$respid);
     if (! defined($PerformanceData) ||       if (! defined($PerformanceData) || 
         ref($PerformanceData) ne 'ARRAY' ) {          ref($PerformanceData) ne 'ARRAY' ) {
         $analysis_html = '<h2>'.          $analysis_html = '<h2>'.
Line 205  sub NumericalResponseAnalysis { Line 230  sub NumericalResponseAnalysis {
     }      }
     #      #
     # This next call causes all the waiting around that people complain about      # This next call causes all the waiting around that people complain about
     my ($max,$min) = &GetStudentAnswers($r,$problem,$Students);      my ($max,$min) = &Apache::lonstathelpers::GetStudentAnswers($r,$problem,
                                                                   $Students);
     return if ($c->aborted());      return if ($c->aborted());
     #      #
     # Collate the data      # Collate the data
Line 231  sub one_dimensional_plot { Line 257  sub one_dimensional_plot {
     # Compute data -> image scaling factors      # Compute data -> image scaling factors
     my $min = $Labels->[0];      my $min = $Labels->[0];
     my $max = $Labels->[-1];      my $max = $Labels->[-1];
       if ($max == $min) {
           $max =$min+1;
       }
     my $h_scale = ($width-10)/($max-$min);      my $h_scale = ($width-10)/($max-$min);
     #      #
     my $max_y = 0;      my $max_y = 0;
Line 293  sub line { Line 322  sub line {
     return qq{<line x1="$x1" y1="$y1" x2="$x2" y2="$y2" color="$color" thickness="$thickness" />$/};      return qq{<line x1="$x1" y1="$y1" x2="$x2" y2="$y2" color="$color" thickness="$thickness" />$/};
 }  }
   
   sub text {
       my ($x,$y,$color,$text,$font,$direction) = @_;
       if (! defined($font) || $font !~ /^(tiny|small|medium|large|giant)$/) {
           $font = 'medium';
       }
       if (! defined($direction) || $direction ne 'vertical') {
           $direction = '';
       }
       return qq{<text x="$x" y="$y" color="$color" font="$font" direction="$direction" >$text</text>};
   }
   
 sub rectangle {  sub rectangle {
     my ($x1,$y1,$x2,$y2,$color,$thickness,$filled) = @_;      my ($x1,$y1,$x2,$y2,$color,$thickness,$filled) = @_;
     return qq{<rectangle x1="$x1" y1="$y1" x2="$x2" y2="$y2" color="$color" thickness="$thickness" filled="$filled" />};      return qq{<rectangle x1="$x1" y1="$y1" x2="$x2" y2="$y2" color="$color" thickness="$thickness" filled="$filled" />};
Line 308  sub circle { Line 348  sub circle {
     return &arc($x,$y,$radius,$radius,0,360,$color,$thickness,$filled);      return &arc($x,$y,$radius,$radius,0,360,$color,$thickness,$filled);
 }  }
   
 sub GetStudentAnswers {  
     my ($r,$problem,$Students) = @_;  
     my $c = $r->connection();  
     my %Answers;  
     my ($resource,$partid,$respid) = ($problem->{'resource'},  
                                       $problem->{'part'},  
                                       $problem->{'respid'});  
     # Read in the cache (if it exists) before we start timing things.  
     &Apache::lonstathelpers::ensure_proper_cache($resource->{'symb'});  
     # Open progress window  
     my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin  
         ($r,'Student Answer Compilation Status',  
          'Student Answer Compilation Progress', scalar(@$Students));  
     $r->rflush();  
     foreach my $student (@$Students) {  
         last if ($c->aborted());  
         my $sname = $student->{'username'};  
         my $sdom = $student->{'domain'};  
         my $answer = &Apache::lonstathelpers::analyze_problem_as_student  
             ($resource,$sname,$sdom,$partid,$respid);  
         &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,  
                                                  &mt('last student'));  
         $student->{'answer'} = $answer;  
     }  
     &Apache::lonstathelpers::write_answer_cache();  
     return if ($c->aborted());  
     $r->rflush();  
     # close progress window  
     &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);  
     return;  
 }  
   
 sub build_student_data_worksheet {  sub build_student_data_worksheet {
     my ($workbook,$format) = @_;      my ($workbook,$format) = @_;
     my $rows_output = 3;      my $rows_output = 3;
Line 379  sub RadioResponseAnalysis { Line 387  sub RadioResponseAnalysis {
     my ($resource,$respid) = ($problem->{'resource'},      my ($resource,$respid) = ($problem->{'resource'},
                               $problem->{'respid'});                                $problem->{'respid'});
     my $analysis_html;      my $analysis_html;
     my $PerformanceData =       my $PerformanceData = &Apache::loncoursedata::get_response_data
         &Apache::loncoursedata::get_response_data          (\@Apache::lonstatistics::SelectedSections,
         ($Students,$resource->{'symb'},$respid);           $Apache::lonstatistics::enrollment_status,
            $resource->{'symb'},$respid);
     if (! defined($PerformanceData) ||       if (! defined($PerformanceData) || 
         ref($PerformanceData) ne 'ARRAY' ) {          ref($PerformanceData) ne 'ARRAY' ) {
         $analysis_html = '<h2>'.          $analysis_html = '<h2>'.
Line 564  sub OptionResponseAnalysis { Line 573  sub OptionResponseAnalysis {
     my ($resource,$respid) = ($problem->{'resource'},      my ($resource,$respid) = ($problem->{'resource'},
                               $problem->{'respid'});                                $problem->{'respid'});
     # Note: part data is not needed.      # Note: part data is not needed.
     my $PerformanceData =       my $PerformanceData = &Apache::loncoursedata::get_response_data
         &Apache::loncoursedata::get_response_data          (\@Apache::lonstatistics::SelectedSections,
         ($Students,$resource->{'symb'},$respid);           $Apache::lonstatistics::enrollment_status,
            $resource->{'symb'},$respid);
     if (! defined($PerformanceData) ||       if (! defined($PerformanceData) || 
         ref($PerformanceData) ne 'ARRAY' ) {          ref($PerformanceData) ne 'ARRAY' ) {
         $r->print('<h2>'.          $r->print('<h2>'.

Removed from v.1.80  
changed lines
  Added in v.1.82


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