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

www www@source.lon-capa.org
Wed, 25 May 2011 01:12:01 -0000


www		Wed May 25 01:12:01 2011 EDT

  Modified files:              
    /loncom/interface	lonquickgrades.pm 
  Log:
  Saving my work: drop assignment rules
  
  
Index: loncom/interface/lonquickgrades.pm
diff -u loncom/interface/lonquickgrades.pm:1.91 loncom/interface/lonquickgrades.pm:1.92
--- loncom/interface/lonquickgrades.pm:1.91	Tue May 24 23:44:33 2011
+++ loncom/interface/lonquickgrades.pm	Wed May 25 01:12:01 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Quick Student Grades Display
 #
-# $Id: lonquickgrades.pm,v 1.91 2011/05/24 23:44:33 www Exp $
+# $Id: lonquickgrades.pm,v 1.92 2011/05/25 01:12:01 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -664,10 +664,10 @@
     }
     if ($output) {
        $r->print('</ul>');
-       $r->print('<p>'.&mt('Total raw points: [_1]/[_2]',$totalcorrect,$totalpossible).'</p>'); 
        if ($cangrade) {
            $r->print('<br />'.&Apache::loncommon::selectresource_link('quickform','addcont_'.$id,&mt('Add Problem or Folder')).'<br />');
        }
+       $r->print('<p>'.&mt('Total raw points: [_1]/[_2]',$totalcorrect,$totalpossible).'</p>');
        $r->print('</td>'); 
     }
 # Total
@@ -697,7 +697,6 @@
 
 
 # Calculation
-    my $actualtotal=$totalcorrect;
     if ($output) { $r->print('<td><ul>'); }
     foreach my $calcrule (split(/\,/,$categories{$id.'_calculations'})) {
         if ($output) { $r->print('<li>'); }
@@ -708,29 +707,34 @@
         }
         if ($code eq 'capabove') {
             if ($totalpossible>0) {
-                if ($actualtotal/$totalpossible>$value/100.) {
-                    $actualtotal=$totalpossible*$value/100.;
+                if ($totalcorrect/$totalpossible>$value/100.) {
+                    $totalcorrect=$totalpossible*$value/100.;
                 }
             }
         } elsif ($code eq 'capbelow') {
             if ($totalpossible>0) {
-                if ($actualtotal/$totalpossible<$value/100.) {
-                    $actualtotal=$totalpossible*$value/100.;
+                if ($totalcorrect/$totalpossible<$value/100.) {
+                    $totalcorrect=$totalpossible*$value/100.;
                 }
             }
+        } elsif ($code eq 'droplow') {
+            ($totalcorrect,@individual)=&drop(0,0,$value,@individual);
+        } elsif ($code eq 'drophigh') {
+            ($totalcorrect,@individual)=&drop(1,0,$value,@individual);
+        } elsif ($code eq 'droplowperc') {
+            ($totalcorrect,@individual)=&drop(0,1,$value,@individual);
+        } elsif ($code eq 'drophighperc') {
+            ($totalcorrect,@individual)=&drop(1,1,$value,@individual);
         }
         if ($output) { $r->print('</li>'); }
     }
     if ($output) { 
-       $r->print('</ul>'); 
-       $r->print('<p>'.&mt('Calculated points: [_1]/[_2]',$actualtotal,$totalpossible).'</p>');
+        $r->print('</ul>'); 
+        if ($cangrade) { $r->print('<br />'.&new_calc_rule_form($id)); }
+        $r->print('<p>'.&mt('Calculated points: [_1]/[_2]',$totalcorrect,$totalpossible).'</p>');
+        $r->print('</td>'); 
     }
 
-    if ($cangrade) {
-        if ($output) { $r->print('<br />'.&new_calc_rule_form($id)); }
-    }
-    if ($output) { $r->print('</td>'); }
-
 # Weight
     if ($cangrade) {
        if ($output) { 
@@ -767,6 +771,28 @@
 }
 
 #
+# Drop folders and problems
+#
+
+sub drop {
+    my ($high,$percent,@individual)=@_;
+    my @newindividual=sort {
+        my ($pa,$ca)=split(/\:/,$a);
+        my ($pb,$cb)=split(/\:/,$b);
+        if ($percent) {
+            my $perca=0;
+            if ($pa>0) { $perca=$ca/$pa; }
+            my $percb=0;
+            if ($pb>0) { $percb=$cb/$pb; }
+            $perca<=>$percb;
+        } else {
+            $ca<=>$cb;
+        }
+    } @individual;
+    my $newcorrect=0;
+    return ($newcorrect,@newindividual);
+} 
+#
 # Bottom line with grades
 #