Diff for /loncom/interface/statistics/lonproblemstatistics.pm between versions 1.21 and 1.22

version 1.21, 2002/08/13 13:57:25 version 1.22, 2002/08/13 15:01:07
Line 627  sub Discriminant { Line 627  sub Discriminant {
 # ------------------------------------------- Prepare data for Graphical chart  # ------------------------------------------- Prepare data for Graphical chart
   
 sub BuildGraphicChart {  sub BuildGraphicChart {
     my ($ylab,$r,$cacheDB)=@_;      my ($graph,$cacheDB,$courseDescription,$r)=@_;
     my %cache;      my %cache;
     my $Col;      my $max = 0;
     my $data='';  
     my $count = 0;  
     my $Max = 0;  
   
     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {      unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
         return '<html><body>Unable to tie database.</body></html>';          return '<html><body>Unable to tie database.</body></html>';
     }      }
         
     my $p_count = $cache{'ProblemCount'};      my @problems = split(':::', $cache{'problemList'});
       my @values = ();
     for ( my $k=0; $k<$p_count;$k++) {      foreach (@problems) {
         my @Temp=split(/\:/,$cache{'GraphGif:'.$k});          my $data = 0;
         my $inf = $Temp[$Col];           if($graph eq 'DoDiffGraph') {
  if ( $Max < $inf ) {$Max = $inf;}              $data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
       $data .= $inf.',';          } else {
         $count++;              $data = sprintf("%.1f", $cache{$_.':percentWrong'}),
           }
           if($max < $data) {
               $max = $data;
           }
           push(@values, $data);
     }      }
     untie(%cache);      untie(%cache);
 #    $r->print("<br>count=$p_count >>data= $data");  
   
     if ( $Max > 1 ) {       my $sendValues = join(',', @values);
  $Max += (10 - $Max % 10);  #    my $sendCount = $#values;
       $Max = int($Max);      my $sendCount = scalar(@values);
     } else { $Max = 1; }  
       my $title = '';
     my $cid=$ENV{'request.course.id'};      if($graph eq 'DoDiffGraph') {
    $title = 'Degree-of-Difficulty';
     if ( $ylab eq 'DoDiff Graph' ) {  
  $ylab = 'Degree-of-Difficulty';  
  $Col = 0;  
     } else {      } else {
  $ylab = 'Wrong-Percentage';   $title = 'Wrong-Percentage';
  $Col = 1;  
     }      }
     my $Course = $ENV{'course.'.$cid.'.description'};      my @GData = ($courseDescription, 'Problems', $title, $max, $sendCount, 
     $Course =~ s/\ /"_"/eg;                   $sendValues);
     my $GData=$Course.'&'.'Problems#'.'&'.$ylab.'&'.  
       $Max.'&'.$count.'&'.$data;  
   
     $r->print('<IMG src="/cgi-bin/graph.gif?'.$GData.'" />');      $r->print('</form>'."\n");
       $r->print('<IMG src="/cgi-bin/graph.gif?'.(join('&', @GData)).'" border="1" />');
       $r->print('<form>'."\n");
   
     return;      return;
 }  }

Removed from v.1.21  
changed lines
  Added in v.1.22


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