push-allgrades 565 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/usr/bin/perl -w

use strict;

# Dumb check to make it harder to run this by accident
die "Usage: $0 [-y] <hw>\n" unless ((scalar(@ARGV) == 1) || (scalar(@ARGV) == 2));

my $hw;
my $dryrun;
if (scalar(@ARGV) == 1) {
    $hw = $ARGV[0];
    $dryrun = 1;
} else { 
    $hw = $ARGV[1];
    $dryrun = 0;
}

if ($dryrun) {
    print "## NOTE: Dry run, use '-y' to actually push!\n"
}
foreach my $student (`list-students`) {
    chomp $student;
    my $command = "push-grade $hw $student";
    print "$command\n";
    if (!$dryrun) {
        system "$command";
    }
}