[LON-CAPA-cvs] cvs: loncom /interface lonquickgrades.pm

www www@source.lon-capa.org
Thu, 26 May 2011 18:02:22 -0000


www		Thu May 26 18:02:22 2011 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Drop score calculation completed
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.92 loncom/interface/lonquickgrades.pm:1.93
--- loncom/interface/lonquickgrades.pm:1.92	Wed May 25 01:12:01 2011
+++ loncom/interface/lonquickgrades.pm	Thu May 26 18:02:22 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.92 2011/05/25 01:12:01 www Exp $
+# $Id: lonquickgrades.pm,v 1.93 2011/05/26 18:02:22 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -478,6 +478,33 @@
 #    foreach (keys(%data)) {
 #        $r->print("\n<br />".$_.'='.$data{$_});
 #    }
+#   my @debugarray=('5:1','4:3','1:1','5:5','6:7');
+#   $r->print("Array: ".join(',',@debugarray).'<br />');
+#   $r->print("0,0,0: ".join(',',&drop(0,0,0,@debugarray)).'<br />');
+#   $r->print("1,0,0: ".join(',',&drop(1,0,0,@debugarray)).'<br />');
+#   $r->print("0,1,0: ".join(',',&drop(0,1,0,@debugarray)).'<br />');
+#   $r->print("1,1,0: ".join(',',&drop(1,1,0,@debugarray)).'<br />');
+#
+#   $r->print("0,0,2: ".join(',',&drop(0,0,2,@debugarray)).'<br />');
+#   $r->print("1,0,2: ".join(',',&drop(1,0,2,@debugarray)).'<br />');
+#   $r->print("0,1,2: ".join(',',&drop(0,1,2,@debugarray)).'<br />');
+#   $r->print("1,1,2: ".join(',',&drop(1,1,2,@debugarray)).'<br />');
+#
+#   $r->print("0,0,4: ".join(',',&drop(0,0,4,@debugarray)).'<br />');
+#   $r->print("1,0,4: ".join(',',&drop(1,0,4,@debugarray)).'<br />');
+#   $r->print("0,1,4: ".join(',',&drop(0,1,4,@debugarray)).'<br />');
+#   $r->print("1,1,4: ".join(',',&drop(1,1,4,@debugarray)).'<br />');
+#
+#   $r->print("0,0,5: ".join(',',&drop(0,0,5,@debugarray)).'<br />');
+#   $r->print("1,0,5: ".join(',',&drop(1,0,5,@debugarray)).'<br />');
+#   $r->print("0,1,5: ".join(',',&drop(0,1,5,@debugarray)).'<br />');
+#   $r->print("1,1,5: ".join(',',&drop(1,1,5,@debugarray)).'<br />');
+#
+#   $r->print("0,0,7: ".join(',',&drop(0,0,7,@debugarray)).'<br />');
+#   $r->print("1,0,7: ".join(',',&drop(1,0,7,@debugarray)).'<br />');
+#   $r->print("0,1,7: ".join(',',&drop(0,1,7,@debugarray)).'<br />');
+#   $r->print("1,1,7: ".join(',',&drop(1,1,7,@debugarray)).'<br />');
+
 }
 
 #
@@ -775,7 +802,7 @@
 #
 
 sub drop {
-    my ($high,$percent,@individual)=@_;
+    my ($high,$percent,$n,@individual)=@_;
     my @newindividual=sort {
         my ($pa,$ca)=split(/\:/,$a);
         my ($pb,$cb)=split(/\:/,$b);
@@ -789,7 +816,19 @@
             $ca<=>$cb;
         }
     } @individual;
+    if ($#newindividual>=$n) {
+        if ($high) {
+           splice(@newindividual,$#newindividual+1-$n,$n);
+        } else {
+           splice(@newindividual,0,$n);
+        }
+    } else {
+        @newindividual=();
+    }
     my $newcorrect=0;
+    for my $score (@newindividual) {
+        $newcorrect+=(split(/\:/,$score))[1];
+    }
     return ($newcorrect,@newindividual);
 } 
 #