Commit 57ec8656 authored by Robert Ricci's avatar Robert Ricci

Keep track of commits for each score

parent 9a495498
......@@ -17,6 +17,13 @@ my %weights = (
labs => 0.3125
);
my @lettergrades = (
['A', 0.95], ['A-', 0.90],
['B+', 0.85], ['B', 0.80], ['B-', 0.75],
['C+', 0.70], ['C', 0.65], ['C-', 0.60],
['D+', 0.55], ['D', 0.50], ['E', 0.00],
);
my $threshold = 0.05;
my @students = `list-students`;
......@@ -24,6 +31,7 @@ chomp @students;
sub get_grade_for($$);
sub sum_pairs(@);
sub get_lettergrade($);
my %scores;
my @allstudents;
......@@ -33,10 +41,10 @@ foreach my $student (@students) {
foreach my $type (keys %assignments) {
$scores{$student}{$type} = {};
foreach my $hw (keys %{$assignments{$type}}) {
my ($score, $possible) = get_grade_for($student,$hw);
my ($score, $possible, $hash) = get_grade_for($student,$hw);
my $weight = $assignments{$type}{$hw};
$scores{$student}{$type}{$hw} =
[$score * $weight, $possible *$weight];
[$score * $weight, $possible *$weight, $hash];
}
my ($typetotal, $typepossible) =
sum_pairs(values $scores{$student}{$type});
......@@ -75,6 +83,7 @@ foreach my $student (sort keys %scores) {
printf "\t%13s: % 6.2f%%\n", "RAW TOTAL", $studenttotal*100;
my $adjusted = $studenttotal / $topscore;
printf "\t%13s: % 6.2f%%\n", "ADJ. TOTAL", $adjusted*100;
printf "\t%13s: %s\n", "GRADE", get_lettergrade($adjusted);
}
sub get_grade_for($$) {
......@@ -82,7 +91,9 @@ sub get_grade_for($$) {
my $branch = "$hw-graded-$student";
if (`git show -s --format=%s $branch` =~ /^\s*Total score: (\d+(\.\d+)?)\s*\/\s*(\d+)/) {
my ($score, $possible) = ($1,$3);
return ($score, $possible);
my $hash = `git rev-parse --short $branch`;
chomp $hash;
return ($score, $possible, $hash);
} else {
die "No score for student $student\n";
}
......@@ -97,3 +108,12 @@ sub sum_pairs(@) {
}
return ($total, $possible);
}
sub get_lettergrade($) {
my ($score) = (@_);
my $idx = 0;
while ($lettergrades[$idx][1] > $score) {
$idx++;
}
return $lettergrades[$idx][0];
}
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