[LON-CAPA-cvs] cvs: modules /gerd evaluate.pl

www lon-capa-cvs@mail.lon-capa.org
Thu, 30 Mar 2006 15:12:03 -0000


www		Thu Mar 30 10:12:03 2006 EDT

  Modified files:              
    /modules/gerd	evaluate.pl 
  Log:
  Interesting ...
  
  
Index: modules/gerd/evaluate.pl
diff -u modules/gerd/evaluate.pl:1.2 modules/gerd/evaluate.pl:1.3
--- modules/gerd/evaluate.pl:1.2	Thu Mar 30 09:24:45 2006
+++ modules/gerd/evaluate.pl	Thu Mar 30 10:12:03 2006
@@ -77,7 +77,7 @@
 #
 # All information read
 # Variables between 0 and 1 for
-# discussions
+# discussion
 # fcipre
 # fcipost
 # mpexpre
@@ -88,15 +88,29 @@
 # Sample is everybody who got a grade in the course
 my @userkeys=sort keys %grade;
 
-print join(",",&hashcorrelate(\%grade,'',\%fci,'',\@userkeys));
-
+foreach my $mpexidx (1..34) {
+   print "\n$mpexidx - ";
+   print "FCI: ".join(",",&hashcorrelate(\%fci,'',\%mpex,$mpexidx,\@userkeys)).
+         " Grade: ".join(",",&hashcorrelate(\%grade,'',\%mpex,$mpexidx,\@userkeys)).' - ';
+   foreach my $number (1..8) {
+      foreach my $char ('a'..'d') {
+         my ($c,$n)=&hashcorrelate(\%discussion,$number.$char,\%mpex,$mpexidx,\@userkeys);
+         if ($c) {
+             print " $number$char: $c,$n";
+         }
+      }
+   }
+}
 exit;
 #
 # Calculate correlation between two hashes
 #
 sub hashcorrelate {
    my ($array1,$arrayidx1,$array2,$arrayidx2,$userkeys)=@_;
-   return &correlation(&buildarrays($array1,$arrayidx1,$array2,$arrayidx2,$userkeys));
+   my ($c,$n)=&correlation(&buildarrays($array1,$arrayidx1,$array2,$arrayidx2,$userkeys));
+   unless (abs($c)>0.2) { return ('',''); }
+   $c=int($c*100+0.5)/100;
+   return ($c,$n);
 }
 
 #
@@ -112,7 +126,7 @@
       if ($arrayidx1) { $firstindex.=':'.$arrayidx1; }
       my $secondindex=$user;
       if ($arrayidx2) { $secondindex.=':'.$arrayidx2; }
-      if (($$array1{$firstindex}) && ($$array2{$secondindex})) {
+      if (($$array1{$firstindex} ne '') && ($$array2{$secondindex} ne '')) {
          $index++;
          $x[$index]=$$array1{$firstindex};
          $y[$index]=$$array2{$secondindex};
@@ -143,6 +157,7 @@
        $mean_x += $delta_x / $i;
        $mean_y += $delta_y / $i;
     } 
+    if (($sum_sq_x==0) || ($sum_sq_y==0)) { return (0,$#$x); }
     my $pop_sd_x = sqrt( $sum_sq_x / $#$x );
     my $pop_sd_y = sqrt( $sum_sq_y / $#$x );
     my $cov_x_y=$sum_coproduct / $#$x;