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

www www@source.lon-capa.org
Fri, 27 May 2011 19:32:10 -0000


www		Fri May 27 19:32:10 2011 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Recalculate total points unless given by instructor
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.93 loncom/interface/lonquickgrades.pm:1.94
--- loncom/interface/lonquickgrades.pm:1.93	Thu May 26 18:02:22 2011
+++ loncom/interface/lonquickgrades.pm	Fri May 27 19:32:10 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.93 2011/05/26 18:02:22 www Exp $
+# $Id: lonquickgrades.pm,v 1.94 2011/05/27 19:32:10 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -745,16 +745,21 @@
                 }
             }
         } elsif ($code eq 'droplow') {
-            ($totalcorrect,@individual)=&drop(0,0,$value,@individual);
+            ($totalpossible,$totalcorrect,@individual)=&drop(0,0,$value,@individual);
         } elsif ($code eq 'drophigh') {
-            ($totalcorrect,@individual)=&drop(1,0,$value,@individual);
+            ($totalpossible,$totalcorrect,@individual)=&drop(1,0,$value,@individual);
         } elsif ($code eq 'droplowperc') {
-            ($totalcorrect,@individual)=&drop(0,1,$value,@individual);
+            ($totalpossible,$totalcorrect,@individual)=&drop(0,1,$value,@individual);
         } elsif ($code eq 'drophighperc') {
-            ($totalcorrect,@individual)=&drop(1,1,$value,@individual);
+            ($totalpossible,$totalcorrect,@individual)=&drop(1,1,$value,@individual);
         }
         if ($output) { $r->print('</li>'); }
     }
+# Re-adjust total points if force total
+    if ($categories{$id.'_totaltype'} eq 'typein') {
+       $totalpossible=1.*$categories{$id.'_total'};
+    }
+
     if ($output) { 
         $r->print('</ul>'); 
         if ($cangrade) { $r->print('<br />'.&new_calc_rule_form($id)); }
@@ -803,6 +808,7 @@
 
 sub drop {
     my ($high,$percent,$n,@individual)=@_;
+# Sort assignments by points or percent
     my @newindividual=sort {
         my ($pa,$ca)=split(/\:/,$a);
         my ($pb,$cb)=split(/\:/,$b);
@@ -816,6 +822,7 @@
             $ca<=>$cb;
         }
     } @individual;
+# Drop the ones we don't want
     if ($#newindividual>=$n) {
         if ($high) {
            splice(@newindividual,$#newindividual+1-$n,$n);
@@ -825,11 +832,15 @@
     } else {
         @newindividual=();
     }
+# Re-calculate how many points possible and achieved
+    my $newpossible=0;
     my $newcorrect=0;
     for my $score (@newindividual) {
-        $newcorrect+=(split(/\:/,$score))[1];
+        my ($thispossible,$thiscorrect)=(split(/\:/,$score));
+        $newpossible+=$thispossible;
+        $newcorrect+=$thiscorrect;
     }
-    return ($newcorrect,@newindividual);
+    return ($newpossible,$newcorrect,@newindividual);
 } 
 #
 # Bottom line with grades