Commit 9a495498 authored by Robert Ricci's avatar Robert Ricci

Normalize to top grade

parent 9a1cf008
......@@ -17,6 +17,7 @@ my %weights = (
labs => 0.3125
);
my $threshold = 0.05;
my @students = `list-students`;
chomp @students;
......@@ -25,8 +26,10 @@ sub get_grade_for($$);
sub sum_pairs(@);
my %scores;
my @allstudents;
foreach my $student (@students) {
$scores{$student} = {};
my @studentscores = ();
foreach my $type (keys %assignments) {
$scores{$student}{$type} = {};
foreach my $hw (keys %{$assignments{$type}}) {
......@@ -35,9 +38,27 @@ foreach my $student (@students) {
$scores{$student}{$type}{$hw} =
[$score * $weight, $possible *$weight];
}
my ($typetotal, $typepossible) =
sum_pairs(values $scores{$student}{$type});
my $pct = $typetotal / $typepossible;
my $weight = $weights{$type};
push @studentscores, $pct * $weight;
}
my $studenttotal = reduce { $a + $b } @studentscores;
push @allstudents, $studenttotal;
}
@allstudents = sort {$b <=> $a} @allstudents;
my $topscore;
if ($allstudents[0] > $allstudents[1] + $threshold) {
$topscore = $allstudents[1];
} else {
$topscore = $allstudents[0];
}
print "Top score is $topscore\n";
foreach my $student (sort keys %scores) {
print "##### $student\n";
my @studentscores = ();
......@@ -51,7 +72,9 @@ foreach my $student (sort keys %scores) {
push @studentscores, $pct * $weight;
}
my $studenttotal = reduce { $a + $b } @studentscores;
printf "\t%13s: %04.2f%%\n", "RAW TOTAL", $studenttotal*100;
printf "\t%13s: % 6.2f%%\n", "RAW TOTAL", $studenttotal*100;
my $adjusted = $studenttotal / $topscore;
printf "\t%13s: % 6.2f%%\n", "ADJ. TOTAL", $adjusted*100;
}
sub get_grade_for($$) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment