Diff for /loncom/interface/statistics/lonproblemstatistics.pm between versions 1.24 and 1.25

version 1.24, 2002/08/14 13:13:37 version 1.25, 2002/08/14 16:18:55
Line 56  sub BuildProblemStatisticsPage { Line 56  sub BuildProblemStatisticsPage {
         return;          return;
     }      }
   
       # Remove students who don't have the proper section.
       my @sectionsSelected = split(':',$cache{'sectionsSelected'});
       for(my $studentIndex=((scalar @$students)-1); $studentIndex>=0;
           $studentIndex--) {
           my $value = $cache{$students->[$studentIndex].':section'};
           my $found = 0;
           foreach (@sectionsSelected) {
               if($_ eq 'none') {
                   if($value eq '' || !defined($value) || $value eq ' ') {
                       $found = 1;
                       last;
                   }
               } else {
                   if($value eq $_) {
                       $found = 1;
                       last;
                   }
               }
           }
           if($found == 0) {
               splice(@$students, $studentIndex, 1);
           }
       }
   
     my $Ptr = '';      my $Ptr = '';
     $Ptr .= '<table border="0"><tbody>';      $Ptr .= '<table border="0"><tbody>';
     $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";      $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";
Line 70  sub BuildProblemStatisticsPage { Line 94  sub BuildProblemStatisticsPage {
                                             'ProblemStatistics',                                              'ProblemStatistics',
                                             'Statistics');                                              'Statistics');
     $Ptr .= '</td></tr>'."\n";      $Ptr .= '</td></tr>'."\n";
       $Ptr .= '<tr><td align="right"><b>Select Sections</b>';
       $Ptr .= '</td>'."\n";
       $Ptr .= '<td align="left">'."\n";
       my @sections = split(':',$cache{'sectionList'});
       $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
                                                             \@sectionsSelected,
                                                             'Statistics');
       $Ptr .= '</td></tr>'."\n";
     $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'},       $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'}, 
                                       $cache{'DisplayLegend'});                                        $cache{'DisplayLegend'});
     $Ptr .= '</table>';      $Ptr .= '</table>';
Line 85  sub BuildProblemStatisticsPage { Line 117  sub BuildProblemStatisticsPage {
     my $color=&setbgcolor(0);      my $color=&setbgcolor(0);
   
 #    my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);  #    my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);
 #    my ($upper, $lower) = &Discriminant(\%discriminant,$r);      my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?
     if(!defined($cache{'StatisticsCached'})) {                       $cache{'StatisticsLastStatus'} : 'Nothing';
       my $whichStudents = join(':::',sort(@$students));
       if(!defined($cache{'StatisticsCached'}) || 
          $lastStatus ne $cache{'Status'} ||
          $whichStudents ne $cache{'StatisticsWhichStudents'}) {
         if(defined($cache{'StatisticsCached'})) {          if(defined($cache{'StatisticsCached'})) {
             untie(%cache);              untie(%cache);
             unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {              unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT(),0640)) {
Line 127  sub BuildProblemStatisticsPage { Line 163  sub BuildProblemStatisticsPage {
         }          }
         $cache{'StatisticsKeys'} = join(':::', keys(%$problemData));          $cache{'StatisticsKeys'} = join(':::', keys(%$problemData));
         $cache{'StatisticsCached'} = 'true';          $cache{'StatisticsCached'} = 'true';
           $cache{'StatisticsLastStatus'} = $cache{'Status'};
           $cache{'StatisticsWhichStudents'} = $whichStudents;
         untie(%cache);          untie(%cache);
   
         unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {          unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
Line 134  sub BuildProblemStatisticsPage { Line 172  sub BuildProblemStatisticsPage {
             return;              return;
         }          }
     }      }
   
     my $orderedProblems = &SortProblems(\%cache,       my $orderedProblems = &SortProblems(\%cache, 
                                         $cache{'ProblemStatisticsSort'},                                          $cache{'ProblemStatisticsSort'},
                                         $cache{'ProblemStatisticsAscend'});                                          $cache{'ProblemStatisticsAscend'});
Line 170  sub BuildGraphicChart { Line 209  sub BuildGraphicChart {
     untie(%cache);      untie(%cache);
   
     my $sendValues = join(',', @values);      my $sendValues = join(',', @values);
 #    my $sendCount = $#values;  
     my $sendCount = scalar(@values);      my $sendCount = scalar(@values);
   
     my $title = '';      my $title = '';
Line 236  sub BuildStatisticsTable { Line 274  sub BuildStatisticsTable {
     my $count = 1;      my $count = 1;
     foreach(@$orderedProblems) {      foreach(@$orderedProblems) {
         my ($sequence,$problem,$part)=split(':', $_);          my ($sequence,$problem,$part)=split(':', $_);
         if($cache->{'ProblemStatisticsMaps'} ne 'All Maps'  &&          if($cache->{'StatisticsMaps'} ne 'All Maps'  &&
            $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {             $cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) {
             next;              next;
         }          }
   
Line 261  sub BuildStatisticsTable { Line 299  sub BuildStatisticsTable {
                        sprintf("%.2f", $cache->{$_.':discriminationFactor2'}),                         sprintf("%.2f", $cache->{$_.':discriminationFactor2'}),
                        0); # 0 is for discussion, need to figure out                         0); # 0 is for discussion, need to figure out
   
 #6666666  
 #    $r->print('<br>'.$out.'&'.$DoD);  
 #            print (OUT $out.'@'.$DoD.'&');  
 #6666666  
   
 #check with Gerd  
 #        $urlres=~/^(\w+)\/(\w+)/;  
 #        if ($StdNo) {  
 #            &Apache::lonnet::put('nohist_resevaldata',\%storestats,  
 #                                 $1,$2);  
 #        }  
 #-------------------------------- Row of statistical table  
         &TableRow($displayFormat,$tableData,$count,$r,$color);          &TableRow($displayFormat,$tableData,$count,$r,$color);
         $count++;          $count++;
     }      }
Line 281  sub BuildStatisticsTable { Line 307  sub BuildStatisticsTable {
     }      }
     $r->print('</td></tr></table>');      $r->print('</td></tr></table>');
 #6666666  #6666666
   #    $r->print('<br>'.$out.'&'.$DoD);
   #            print (OUT $out.'@'.$DoD.'&');
   #6666666
   
   #6666666
 #    close( OUT );  #    close( OUT );
 #666666  #666666
     return;      return;
Line 647  sub CalculateStatistics { Line 678  sub CalculateStatistics {
         foreach my $name (@upper1) {          foreach my $name (@upper1) {
             $upper1Sum += $cache->{"$name:$problem:$part:awarded"};              $upper1Sum += $cache->{"$name:$problem:$part:awarded"};
         }          }
         $upper1Sum /= (scalar(@upper1)) ? (scalar(@upper1)) : 0;          $upper1Sum = (scalar(@upper1)) ? ($upper1Sum/(scalar(@upper1))) : 0;
   
         my $lower1Sum=0;          my $lower1Sum=0;
         foreach my $name (@lower1) {          foreach my $name (@lower1) {
             $lower1Sum += $cache->{"$name:$problem:$part:awarded"};              $lower1Sum += $cache->{"$name:$problem:$part:awarded"};
         }          }
         $lower1Sum /= (scalar(@lower1)) ? (scalar(@lower1)) : 0;          $lower1Sum = (scalar(@lower1)) ? ($lower1Sum/(scalar(@lower1))) : 0;
   
         $data->{$_.':discriminationFactor1'} = $upper1Sum - $lower1Sum;          $data->{$_.':discriminationFactor1'} = $upper1Sum - $lower1Sum;
   
Line 665  sub CalculateStatistics { Line 696  sub CalculateStatistics {
         foreach my $name (@upper2) {          foreach my $name (@upper2) {
             $upper2Sum += $cache->{"$name:$problem:$part:awarded"};              $upper2Sum += $cache->{"$name:$problem:$part:awarded"};
         }          }
         $upper2Sum /= (scalar(@upper2)) ? (scalar(@upper2)) : 0;          $upper2Sum = (scalar(@upper2)) ? ($upper2Sum/(scalar(@upper2))) : 0;
   
         my $lower2Sum=0;          my $lower2Sum=0;
         foreach my $name (@lower2) {          foreach my $name (@lower2) {
             $lower2Sum += $cache->{"$name:$problem:$part:awarded"};              $lower2Sum += $cache->{"$name:$problem:$part:awarded"};
         }          }
         $lower2Sum /= (scalar(@lower2)) ? (scalar(@lower2)) : 0;          $lower2Sum = (scalar(@lower2)) ? ($lower2Sum/(scalar(@lower2))) : 0;
   
         $data->{$_.':discriminationFactor2'} = $upper2Sum - $lower2Sum;          $data->{$_.':discriminationFactor2'} = $upper2Sum - $lower2Sum;
     }      }

Removed from v.1.24  
changed lines
  Added in v.1.25


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