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

Add up scores and print them in two separate passes

In preparation for normalizing to the top student
parent ba147572
......@@ -26,9 +26,7 @@ sub sum_pairs(@);
my %scores;
foreach my $student (@students) {
print "##### $student\n";
$scores{$student} = {};
my @studentscores = ();
foreach my $type (keys %assignments) {
$scores{$student}{$type} = {};
foreach my $hw (keys %{$assignments{$type}}) {
......@@ -37,6 +35,13 @@ foreach my $student (@students) {
$scores{$student}{$type}{$hw} =
[$score * $weight, $possible *$weight];
}
}
}
foreach my $student (sort keys %scores) {
print "##### $student\n";
my @studentscores = ();
foreach my $type (sort keys $scores{$student}) {
my ($typetotal, $typepossible) =
sum_pairs(values $scores{$student}{$type});
my $pct = $typetotal / $typepossible;
......@@ -46,7 +51,7 @@ foreach my $student (@students) {
push @studentscores, $pct * $weight;
}
my $studenttotal = reduce { $a + $b } @studentscores;
printf "\t%13s: %04.2f%%\n", "TOTAL", $studenttotal*100;
printf "\t%13s: %04.2f%%\n", "RAW TOTAL", $studenttotal*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