Diff for /loncom/interface/statistics/lonproblemstatistics.pm between versions 1.26 and 1.27

version 1.26, 2002/08/14 17:45:19 version 1.27, 2002/08/14 20:42:49
Line 80  sub InitializeProblemStatistics { Line 80  sub InitializeProblemStatistics {
         }          }
     }      }
   
 #    my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);  
     my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?      my $lastStatus = (defined($cache{'StatisticsLastStatus'})) ?
                      $cache{'StatisticsLastStatus'} : 'Nothing';                       $cache{'StatisticsLastStatus'} : 'Nothing';
     my $whichStudents = join(':::',sort(@$students));      my $whichStudents = join(':::',sort(@$students));
Line 149  sub BuildProblemStatisticsPage { Line 148  sub BuildProblemStatisticsPage {
   
     my @Header = ("Homework Sets Order","#Stdnts","Tries","Mod",      my @Header = ("Homework Sets Order","#Stdnts","Tries","Mod",
                   "Mean","#YES","#yes","%Wrng","DoDiff",                    "Mean","#YES","#yes","%Wrng","DoDiff",
                   "S.D.","Skew.","D.F.1st","D.F.2nd","Disc.");                    "S.D.","Skew.","D.F.1st","D.F.2nd");
     my $color=&setbgcolor(0);      my $color=&setbgcolor(0);
     my %cache;      my %cache;
   
Line 158  sub BuildProblemStatisticsPage { Line 157  sub BuildProblemStatisticsPage {
         return;          return;
     }      }
     my $Ptr = '';      my $Ptr = '';
     $Ptr .= '<table border="0"><tbody>';      $Ptr .= '<table border="0" cellspacing="5"><tbody>';
     $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";      $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";
     $Ptr .= '<td align="left">';      $Ptr .= '<td align="left">';
     $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics',      $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics',
Line 269  sub CreateProblemStatisticsTableHeading Line 268  sub CreateProblemStatisticsTableHeading
     $Str .= '<tr>'."\n";      $Str .= '<tr>'."\n";
     $Str .= '<th bgcolor="#ffffe6">P#</th>'."\n";      $Str .= '<th bgcolor="#ffffe6">P#</th>'."\n";
     foreach(@$headings) {      foreach(@$headings) {
  $Str .= '<th bgcolor="#ffffe6">'.'<a href="/adm/statistics?reportSelected=';   $Str .= '<th bgcolor="#ffffe6">';
           $Str .= '<a href="/adm/statistics?reportSelected=';
         $Str .= &Apache::lonnet::escape('Problem Statistics');          $Str .= &Apache::lonnet::escape('Problem Statistics');
         $Str .= '&ProblemStatisticsSort=';          $Str .= '&ProblemStatisticsSort=';
         $Str .= &Apache::lonnet::escape($_).'">'.$_.'</a>&nbsp</th>'."\n";          $Str .= &Apache::lonnet::escape($_).'">'.$_.'</a>&nbsp</th>'."\n";
Line 283  sub BuildStatisticsTable { Line 283  sub BuildStatisticsTable {
     my ($cache,$displayFormat,$sortProblems,$orderedProblems,$headings,      my ($cache,$displayFormat,$sortProblems,$orderedProblems,$headings,
         $r,$color)=@_;          $r,$color)=@_;
   
 #6666666  
 #    my $file="/home/httpd/perl/tmp/183d.txt";  
 #    open(OUT, ">$file");  
 #6666666  
 ##     &Apache::lonstatistics::Create_PrgWin($r);  
 ##777777  
 ##    my (%Activity) = &LoadActivityLog();  
 ##    $r->print('<script>popwin.document.popremain.remaining.value="'.  
 ##              'Loading Discussion...";</script>');  
 ##    my ($doDiffFile) = &LoadDoDiffFile();  
   
 ##777777  
 ##    $Str .= &Classify($discriminantFactor, $students);  
   
     my $count = 1;      my $count = 1;
     my $currentSequence = -1;      my $currentSequence = -1;
     foreach(@$orderedProblems) {      foreach(@$orderedProblems) {
Line 332  sub BuildStatisticsTable { Line 318  sub BuildStatisticsTable {
         my $ref = '<a href="'.$cache->{$problem.':source'}.          my $ref = '<a href="'.$cache->{$problem.':source'}.
                   '" target="_blank">'.$cache->{$problem.':title'}.'</a>';                    '" target="_blank">'.$cache->{$problem.':title'}.'</a>';
         my $title = $cache->{$problem.':title'};          my $title = $cache->{$problem.':title'};
           if($part != 0) {
               $title .= ' Part '.$part;
           }
         my $source = $cache->{$problem.':source'};          my $source = $cache->{$problem.':source'};
         my $tableData = join('&', $ref, $title, $source,          my $tableData = join('&', $ref, $title, $source,
                        $cache->{$_.':studentCount'},                         $cache->{$_.':studentCount'},
                        $cache->{$_.':totalTries'},                         $cache->{$_.':totalTries'},
                        $cache->{$_.':maxTries'},                         $cache->{$_.':maxTries'},
                        sprintf("%.2f", $cache->{$_.':mean'}),                         $cache->{$_.':mean'},
                        $cache->{$_.':correct'},                         $cache->{$_.':correct'},
                        $cache->{$_.':correctByOverride'},                         $cache->{$_.':correctByOverride'},
                        sprintf("%.1f", $cache->{$_.':percentWrong'}),                         $cache->{$_.':percentWrong'},
                        sprintf("%.2f", $cache->{$_.':degreeOfDifficulty'}),                         $cache->{$_.':degreeOfDifficulty'},
                        sprintf("%.1f", $cache->{$_.':standardDeviation'}),                         $cache->{$_.':standardDeviation'},
                        sprintf("%.1f", $cache->{$_.':skewness'}),                         $cache->{$_.':skewness'},
                        sprintf("%.2f", $cache->{$_.':discriminationFactor1'}),                         $cache->{$_.':discriminationFactor1'},
                        sprintf("%.2f", $cache->{$_.':discriminationFactor2'}),                         $cache->{$_.':discriminationFactor2'});
                        0); # 0 is for discussion, need to figure out  
   
         &TableRow($displayFormat,$tableData,$count,$r,$color);          &TableRow($displayFormat,$tableData,$count,$r,$color);
   
Line 358  sub BuildStatisticsTable { Line 346  sub BuildStatisticsTable {
     } else {      } else {
         $r->print('<br>');          $r->print('<br>');
     }      }
 #6666666  
 #    $r->print('<br>'.$out.'&'.$DoD);  
 #            print (OUT $out.'@'.$DoD.'&');  
 #6666666  
   
 #6666666  
 #    close( OUT );  
 #666666  
     return;      return;
 }  }
   
 sub TableRow {  sub TableRow {
     my ($displayFormat,$Str,$RealIdx,$r,$color)=@_;      my ($displayFormat,$Str,$RealIdx,$r,$color)=@_;
     my($ref,$title,$source,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,      my($ref,$title,$source,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
        $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str);         $Wrng,$DoD,$SD,$Sk,$_D1,$_D2)=split(/\&/,$Str);
     my $Ptr;      my $Ptr;
     if($displayFormat eq 'Display CSV Format') {      if($displayFormat eq 'Display CSV Format') {
         $Ptr='"'.$RealIdx.'",'."\n".          $Ptr='"'.$RealIdx.'",'."\n".
Line 390  sub TableRow { Line 371  sub TableRow {
              '"'.$Sk.'",'."\n".               '"'.$Sk.'",'."\n".
              '"'.$_D1.'",'."\n".               '"'.$_D1.'",'."\n".
              '"'.$_D2.'"'."\n".               '"'.$_D2.'"'."\n".
              '"'.$DiscNo.'"'."\n".  
              "<br>\n";               "<br>\n";
   
         $r->print("\n".$Ptr);          $r->print("\n".$Ptr);
Line 409  sub TableRow { Line 389  sub TableRow {
              '<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'."\n".               '<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'."\n".
              '<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'."\n".               '<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'."\n".
              '<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'."\n".               '<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'."\n".
      '<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n".       '<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n";
              '<td bgcolor='.$color->{"yellow"}.'> '.$DiscNo.'</td>'."\n";  
         $r->print($Ptr.'</tr>'."\n");          $r->print($Ptr.'</tr>'."\n");
     }      }
   
Line 443  sub ProblemStatisticsButtons { Line 422  sub ProblemStatisticsButtons {
   
     my $Ptr = '<tr><td></td><td align="left">';      my $Ptr = '<tr><td></td><td align="left">';
     $Ptr .= '<input type="submit" name="DoDiffGraph" ';      $Ptr .= '<input type="submit" name="DoDiffGraph" ';
     $Ptr .= 'value="DoDiff Graph" />'."\n";      $Ptr .= 'value="Degree of Difficulty" />'."\n";
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $Ptr .= '</td><td align="left">';
     $Ptr .= '<input type="submit" name="PercentWrongGraph" ';      $Ptr .= '<input type="submit" name="PercentWrongGraph" ';
     $Ptr .= 'value="%Wrong Graph" />'."\n";      $Ptr .= 'value="Percent Wrong" />'."\n";
     $Ptr .= '</td></tr><tr><td></td><td>'."\n";      $Ptr .= '</td></tr><tr><td></td><td>'."\n";
     $Ptr .= '<input type="submit" name="SortProblems" ';      $Ptr .= '<input type="submit" name="SortProblems" ';
     if($sortProblems eq 'Sort All Problems') {      if($sortProblems eq 'Sort All Problems') {
Line 454  sub ProblemStatisticsButtons { Line 433  sub ProblemStatisticsButtons {
     } else {      } else {
         $Ptr .= 'value="Sort All Problems" />'."\n";          $Ptr .= 'value="Sort All Problems" />'."\n";
     }      }
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $Ptr .= '</td><td align="left">';
     $Ptr .= '<input type="submit" name="DisplayLegend" ';      $Ptr .= '<input type="submit" name="DisplayLegend" ';
     if($displayLegend eq 'Show Legend') {      if($displayLegend eq 'Show Legend') {
         $Ptr .= 'value="Hide Legend" />'."\n";          $Ptr .= 'value="Hide Legend" />'."\n";
     } else {      } else {
         $Ptr .= 'value="Show Legend" />'."\n";          $Ptr .= 'value="Show Legend" />'."\n";
     }      }
     $Ptr .= '&nbsp;&nbsp;&nbsp;';      $Ptr .= '</td><td align="left">';
     $Ptr .= '<input type="submit" name="DisplayCSVFormat" ';      $Ptr .= '<input type="submit" name="DisplayCSVFormat" ';
     if($displayFormat eq 'Display CSV Format') {      if($displayFormat eq 'Display CSV Format') {
         $Ptr .= 'value="Display Table Format" />'."\n";          $Ptr .= 'value="Display Table Format" />'."\n";
Line 529  sub ProblemStatisticsLegend { Line 508  sub ProblemStatisticsLegend {
     return $Ptr;      return $Ptr;
 }  }
   
 #------- Processing upperlist and lowerlist according to each problem  
   
 sub ExtractStudentData {  sub ExtractStudentData {
     my ($cache, $students)=@_;      my ($cache, $students)=@_;
   
 #$Apache::lonxml::debug=1;  
 #&Apache::lonhomework::showhash(%$cache);  
 #$Apache::lonxml::debug=0;  
   
     my @problemList=();      my @problemList=();
     my %problemData;      my %problemData;
     foreach my $sequence (split(':', $cache->{'orderedSequences'})) {      foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
Line 584  sub ExtractStudentData { Line 557  sub ExtractStudentData {
                     }                      }
                 }                  }
   
                   my $studentTriesJoined = join(':::', @studentTries);
                 $problemData{$id.':sequenceTitle'} =                   $problemData{$id.':sequenceTitle'} = 
                     $cache->{$sequence.':title'};                      $cache->{$sequence.':title'};
                 $problemData{$id.':studentCount'} = $studentCount;                  $problemData{$id.':studentCount'} = $studentCount;
                 $problemData{$id.':totalTries'} = $totalTries;                  $problemData{$id.':totalTries'} = $totalTries;
                 $problemData{$id.':studentTries'} = \@studentTries;                  $problemData{$id.':studentTries'} = $studentTriesJoined;
                 $problemData{$id.':totalAwarded'} = $totalAwarded;                  $problemData{$id.':totalAwarded'} = $totalAwarded;
                 $problemData{$id.':correct'} = $correct;                  $problemData{$id.':correct'} = $correct;
                 $problemData{$id.':correctByOverride'} = $correctByOverride;                  $problemData{$id.':correctByOverride'} = $correctByOverride;
Line 627  sub ExtractStudentData { Line 601  sub ExtractStudentData {
     $problemData{'studentsLowerListCriterion2'}=join(':::', @lowerStudents2);      $problemData{'studentsLowerListCriterion2'}=join(':::', @lowerStudents2);
   
     $problemData{'problemList'} = join(':::', @problemList);      $problemData{'problemList'} = join(':::', @problemList);
 #                $Discussed=0;  
 #                if($Discuss->{"$name:$problem"}) {  
 #    $TotDiscuss++;  
 #                    $Discussed=1;  
 #                }  
   
     return \%problemData;      return \%problemData;
 }  }
Line 668  sub SortProblems { Line 637  sub SortProblems {
     elsif($sortBy eq "DoDiff")  { $data = ':degreeOfDifficulty'; }      elsif($sortBy eq "DoDiff")  { $data = ':degreeOfDifficulty'; }
     elsif($sortBy eq "S.D.")    { $data = ':standardDeviation'; }      elsif($sortBy eq "S.D.")    { $data = ':standardDeviation'; }
     elsif($sortBy eq "Skew.")   { $data = ':skewness'; }      elsif($sortBy eq "Skew.")   { $data = ':skewness'; }
     elsif($sortBy eq "D.F.1st") { $data = ':discriminantFactor1'; }      elsif($sortBy eq "D.F.1st") { $data = ':discriminationFactor1'; }
     elsif($sortBy eq "D.F.2nd") { $data = ':discriminantFactor2'; }      elsif($sortBy eq "D.F.2nd") { $data = ':discriminationFactor2'; }
     elsif($sortBy eq "Disc.")   { $data = ''; }  
     else                        { return \@problems; }      else                        { return \@problems; }
   
     my %temp;      my %temp;
       my @sequenceList=();
     foreach(@problems) {      foreach(@problems) {
         my ($sequence) = split(':', $_);          my ($sequence) = split(':', $_);
         $temp{$_} = $sequence;  
           my @array=();
           my $tempArray;
           if(defined($temp{$sequence})) {
               $tempArray = $temp{$sequence};
           } else {
               push(@sequenceList, $sequence);
               $tempArray = \@array;
               $temp{$sequence} = $tempArray;
           }
   
           push(@$tempArray, $_);
     }      }
   
     my @orderedProblems;      my @orderedProblems;
     if($sortProblems eq "Sort Within Sequence") {      if($sortProblems eq "Sort Within Sequence") {
         @orderedProblems =           foreach(keys(%temp)) {
             sort { $temp{$a} cmp $temp{$b} ||              my $tempArray = $temp{$_};
                    $problemData->{$a.$data} <=> $problemData->{$b.$data} }              my @tempOrder =
         @problems;                  sort { $problemData->{$a.$data} <=> $problemData->{$b.$data} }
               @$tempArray;
               $temp{$_} = \@tempOrder;
           }
           foreach(@sequenceList) {
               my $tempArray = $temp{$_};
               @orderedProblems = (@orderedProblems, @$tempArray);
           }
     } else {      } else {
         @orderedProblems =           @orderedProblems = 
             sort { $problemData->{$a.$data} <=> $problemData->{$b.$data} }              sort { $problemData->{$a.$data} <=> $problemData->{$b.$data} }
Line 704  sub CalculateStatistics { Line 691  sub CalculateStatistics {
     my @problems = split(':::', $data->{'problemList'});      my @problems = split(':::', $data->{'problemList'});
     foreach(@problems) {      foreach(@problems) {
         # Mean          # Mean
         $data->{$_.':mean'} = ($data->{$_.':studentCount'}) ?           my $mean = ($data->{$_.':studentCount'}) ? 
             ($data->{$_.':totalTries'} / $data->{$_.':studentCount'}) : 0;              ($data->{$_.':totalTries'} / $data->{$_.':studentCount'}) : 0;
           $data->{$_.':mean'} = sprintf("%.2f", $mean);
   
         # %Wrong          # %Wrong
         $data->{$_.':percentWrong'} = ($data->{$_.':studentCount'}) ?          my $pw = ($data->{$_.':studentCount'}) ?
             (($data->{$_.':wrong'} / $data->{$_.':studentCount'}) * 100.0) :               (($data->{$_.':wrong'} / $data->{$_.':studentCount'}) * 100.0) : 
             100.0;              100.0;
           $data->{$_.':percentWrong'} = sprintf("%.1f", $pw);
   
         # Degree of Difficulty          # Degree of Difficulty
         $data->{$_.':degreeOfDifficulty'} = ($data->{$_.':totalTries'}) ?          my $dod = ($data->{$_.':totalTries'}) ?
             (1 - (($data->{$_.':correct'} + $data->{$_.':correctByOverride'}) /              (1 - (($data->{$_.':correct'} + $data->{$_.':correctByOverride'}) /
                   $data->{$_.':totalTries'})) : 0;                    $data->{$_.':totalTries'})) : 0;
   
           $data->{$_.':degreeOfDifficulty'} = sprintf("%.2f", $dod);
   
         # Factor in mean          # Factor in mean
         my $studentTries = $data->{$_.':studentTries'};          my @studentTries = split(':::', $data->{$_.':studentTries'});
         foreach(my $index=0; $index < scalar(@$studentTries); $index++) {          foreach(my $index=0; $index < scalar(@studentTries); $index++) {
             $studentTries->[$index] -= $data->{$_.':mean'};              $studentTries[$index] -= $mean;
         }          }
         my $sumSquared = 0;          my $sumSquared = 0;
         my $sumCubed = 0;          my $sumCubed = 0;
         foreach(@$studentTries) {          foreach(@studentTries) {
             my $squared = ($_ * $_);              my $squared = ($_ * $_);
             my $cubed = ($squared * $_);              my $cubed = ($squared * $_);
             $sumSquared += $squared;              $sumSquared += $squared;
Line 732  sub CalculateStatistics { Line 723  sub CalculateStatistics {
         }          }
   
         # Standard deviation          # Standard deviation
         $data->{$_.':standardDeviation'} = ($data->{$_.':studentCount'} - 1) ?          my $standardDeviation;
             ((sqrt($sumSquared)) / ($data->{$_.':studentCount'} - 1)) : 0;          if($data->{$_.':studentCount'} - 1 > 0) {
               $standardDeviation = (sqrt($sumSquared)) / 
                                    ($data->{$_.':studentCount'} - 1);
           } else {
               $standardDeviation =  0.0;
           }
           $data->{$_.':standardDeviation'} = sprintf("%.1f", $standardDeviation);
   
         # Skewness          # Skewness
         my $standardDeviation = $data->{$_.':standardDeviation'};          my $skew;
         $data->{$_.':skewness'} = ($data->{$_.':standardDeviation'}) ?          if($standardDeviation > 0.0999 && $data->{$_.':studentCount'} > 0) {
             (((sqrt($sumSquared)) / $data->{$_.':studentCount'}) /               $skew = (((sqrt($sumSquared)) / $data->{$_.':studentCount'}) / 
              ($standardDeviation * $standardDeviation * $standardDeviation)) :                       ($standardDeviation * 
              0;                        $standardDeviation * 
                         $standardDeviation));
           } else {
               $skew = 0.0;
           }
   
           $data->{$_.':skewness'} = sprintf("%.1f", $skew);
   
         # Discrimination Factor 1          # Discrimination Factor 1
         my ($sequence, $problem, $part) = split(':', $_);          my ($sequence, $problem, $part) = split(':', $_);
Line 760  sub CalculateStatistics { Line 763  sub CalculateStatistics {
         }          }
         $lower1Sum = (scalar(@lower1)) ? ($lower1Sum/(scalar(@lower1))) : 0;          $lower1Sum = (scalar(@lower1)) ? ($lower1Sum/(scalar(@lower1))) : 0;
   
         $data->{$_.':discriminationFactor1'} = $upper1Sum - $lower1Sum;          my $df1 = $upper1Sum - $lower1Sum;
           $data->{$_.':discriminationFactor1'} = sprintf("%.2f", $df1);
   
         # Discrimination Factor 2          # Discrimination Factor 2
         my @upper2 = split(':::', $data->{'studentsUpperListCriterion2'});          my @upper2 = split(':::', $data->{'studentsUpperListCriterion2'});
Line 778  sub CalculateStatistics { Line 782  sub CalculateStatistics {
         }          }
         $lower2Sum = (scalar(@lower2)) ? ($lower2Sum/(scalar(@lower2))) : 0;          $lower2Sum = (scalar(@lower2)) ? ($lower2Sum/(scalar(@lower2))) : 0;
   
         $data->{$_.':discriminationFactor2'} = $upper2Sum - $lower2Sum;          my $df2 = $upper2Sum - $lower2Sum;
           $data->{$_.':discriminationFactor2'} = sprintf("%.2f", $df2);
     }      }
   
     return;      return;

Removed from v.1.26  
changed lines
  Added in v.1.27


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