--- loncom/interface/lonquickgrades.pm 2011/05/25 01:12:01 1.92 +++ loncom/interface/lonquickgrades.pm 2011/05/27 19:32:10 1.94 @@ -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.94 2011/05/27 19:32:10 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -478,6 +478,33 @@ sub outputCategories { # foreach (keys(%data)) { # $r->print("\n
".$_.'='.$data{$_}); # } +# my @debugarray=('5:1','4:3','1:1','5:5','6:7'); +# $r->print("Array: ".join(',',@debugarray).'
'); +# $r->print("0,0,0: ".join(',',&drop(0,0,0,@debugarray)).'
'); +# $r->print("1,0,0: ".join(',',&drop(1,0,0,@debugarray)).'
'); +# $r->print("0,1,0: ".join(',',&drop(0,1,0,@debugarray)).'
'); +# $r->print("1,1,0: ".join(',',&drop(1,1,0,@debugarray)).'
'); +# +# $r->print("0,0,2: ".join(',',&drop(0,0,2,@debugarray)).'
'); +# $r->print("1,0,2: ".join(',',&drop(1,0,2,@debugarray)).'
'); +# $r->print("0,1,2: ".join(',',&drop(0,1,2,@debugarray)).'
'); +# $r->print("1,1,2: ".join(',',&drop(1,1,2,@debugarray)).'
'); +# +# $r->print("0,0,4: ".join(',',&drop(0,0,4,@debugarray)).'
'); +# $r->print("1,0,4: ".join(',',&drop(1,0,4,@debugarray)).'
'); +# $r->print("0,1,4: ".join(',',&drop(0,1,4,@debugarray)).'
'); +# $r->print("1,1,4: ".join(',',&drop(1,1,4,@debugarray)).'
'); +# +# $r->print("0,0,5: ".join(',',&drop(0,0,5,@debugarray)).'
'); +# $r->print("1,0,5: ".join(',',&drop(1,0,5,@debugarray)).'
'); +# $r->print("0,1,5: ".join(',',&drop(0,1,5,@debugarray)).'
'); +# $r->print("1,1,5: ".join(',',&drop(1,1,5,@debugarray)).'
'); +# +# $r->print("0,0,7: ".join(',',&drop(0,0,7,@debugarray)).'
'); +# $r->print("1,0,7: ".join(',',&drop(1,0,7,@debugarray)).'
'); +# $r->print("0,1,7: ".join(',',&drop(0,1,7,@debugarray)).'
'); +# $r->print("1,1,7: ".join(',',&drop(1,1,7,@debugarray)).'
'); + } # @@ -718,16 +745,21 @@ ENDMOVE } } } 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(''); } } +# Re-adjust total points if force total + if ($categories{$id.'_totaltype'} eq 'typein') { + $totalpossible=1.*$categories{$id.'_total'}; + } + if ($output) { $r->print(''); if ($cangrade) { $r->print('
'.&new_calc_rule_form($id)); } @@ -775,7 +807,8 @@ ENDMOVE # sub drop { - my ($high,$percent,@individual)=@_; + my ($high,$percent,$n,@individual)=@_; +# Sort assignments by points or percent my @newindividual=sort { my ($pa,$ca)=split(/\:/,$a); my ($pb,$cb)=split(/\:/,$b); @@ -789,8 +822,25 @@ sub drop { $ca<=>$cb; } } @individual; +# Drop the ones we don't want + if ($#newindividual>=$n) { + if ($high) { + splice(@newindividual,$#newindividual+1-$n,$n); + } else { + splice(@newindividual,0,$n); + } + } else { + @newindividual=(); + } +# Re-calculate how many points possible and achieved + my $newpossible=0; my $newcorrect=0; - return ($newcorrect,@newindividual); + for my $score (@newindividual) { + my ($thispossible,$thiscorrect)=(split(/\:/,$score)); + $newpossible+=$thispossible; + $newcorrect+=$thiscorrect; + } + return ($newpossible,$newcorrect,@newindividual); } # # Bottom line with grades