'); }
}
+# 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)); }
- $r->print('
'); }
if ($cangrade) {
if ($output) {
$r->print('');
}
- } else {
- if ($output) {
- if ($categories{$id.'_displayachieved'} eq 'percent') {
- $r->print(&mt('percent'));
- } else {
- $r->print(&mt('points'));
+ }
+ if ($output) {
+ $r->print('
');
+ if ($type eq 'percent') {
+ my $perc='---';
+ if ($totalpossible) {
+ $perc=100.*$totalcorrect/$totalpossible;
}
+ $r->print(&mt('[_1] percent',&numberout($perc)));
+ } else {
+ $r->print(&mt('[_1]/[_2] points',&numberout($totalcorrect),&numberout($totalpossible)));
}
+ $r->print('
');
}
if ($output) { $r->print('
'); }
- return ($value,$weight);
+ return ($totalcorrect,$totalpossible,$type,$weight);
}
#
@@ -775,7 +810,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,22 +825,46 @@ 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
#
sub bottom_line_category {
- my ($r,$cangrade,$sum,$total)=@_;
+ my ($r,$cangrade,$perc)=@_;
$r->print(&Apache::loncommon::start_data_table_row());
if ($cangrade) {
$r->print('