Commit b830c146 authored by Robert Ricci's avatar Robert Ricci

Some code cleanup, and show the grade we assigned

parent 08cbb39a
......@@ -4,7 +4,7 @@ use Time::Piece;
#
# Meanings of the flags at the end of the line:
# N: Not (yet) submitted
# T: TODO: submitted by grading not started
# T: TODO: submitted but grading not started
# D: Done: graded locally, and local branch matches the remote one
# I: In progress: branch exists locally, but latest commit does not look like
# it contains a final score
......@@ -16,7 +16,6 @@ use Time::Piece;
# is probably wrong
die "Usage: $0 <hw>\n" unless (scalar(@ARGV) == 1);
my ($hw) = (@ARGV);
sub get_date($);
......@@ -31,29 +30,34 @@ foreach my $remote (`git remote`) {
## Find all branches that have the right name pattern
my @branches = `git branch -a`;
foreach my $branch (@branches) {
foreach my $branch (`git branch -a`) {
chomp $branch;
## Trim whitespace and extra git crap
$branch =~ s/^[\*\s]*(.*?)\s*$/$1/;
## Local branch: we're doing grading in this one
if ($branch =~ /^([\w-]+)$/) {
## Local branch
if ($branch =~ /$hw-graded-(\w+)/) {
my $student = $1;
$students{$student}{graded} = get_date($branch);
## Check to see if we appear to be finished grading it or not
if (`git show -s --format=%s $branch` =~ /^\s*Total/) {
if (`git show -s --format=%s $branch` =~ /^\s*Total score: (\d+)\s*\/\s*(\d+)/) {
$students{$student}{'graded'} = "$1";
## R = graded, ready to push
$students{$student}{'flag'} = "R";
} else {
## I = in progress, branch exists but latest commit not a score
$students{$student}{'flag'} = "I";
}
}
} elsif ($branch =~ /^remotes\/(\w+)\/([\w-]+)/) {
## Remote branch
## Remote branch - either the student's submit branch or our final
## grade
my $student = $1;
my $remotebranch = $2;
## Student's submitted branch
if ($remotebranch eq "$hw-submit") {
$students{$student}{submitted} = get_date($branch);
} elsif ($remotebranch eq "$hw-graded") {
......@@ -66,10 +70,12 @@ foreach my $branch (@branches) {
## been pushed up
if (`git rev-parse $branch` eq
`git rev-parse $hw-graded-$student`) {
## Yes, they are the same, we've pushed it up
## Yes, they are the same, we've pushed it up - done!
$students{$student}{'flag'} = "D";
} else {
## No, they are not the same, we need to push
## No, they are not the same, something is weird - like
## we've updated the grade after pushing, or there was
## a conflict with someone else grading this too
$students{$student}{'flag'} = "X";
}
}
......@@ -91,8 +97,10 @@ foreach my $student (sort keys %students) {
$flag = $students{$student}{'flag'};
} else {
if (exists($students{$student}{submitted})) {
## T: todo, they have submitted, we have not started grading
$flag = "T";
} else {
## N: Not submitted
$flag = "N";
}
}
......@@ -105,7 +113,7 @@ foreach my $student (sort keys %students) {
$total++;
printf("%16s - %12s - %12s - %1s\n", $student, $submitted, $graded,$flag);
printf("%16s - %12s - %3s - %1s\n", $student, $submitted, $graded,$flag);
}
foreach my $flag (sort keys %flagcounts) {
......
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