#!/usr/bin/perl
+# A generator of score sheets. More ugly than it deserves.
$debug = 0;
$detail = 0;
$extras = 0;
$alt = 0;
$merged = 0;
-$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--merged] [<directory>/]<task> ...";
+$table = 0;
+$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--table] [--merged] [<directory>/]<task> ...";
while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
shift @ARGV;
$var = "\$$1";
}
@ARGV || die $usage;
+$print_key = 1;
+if ($table) {
+ open STDOUT, "|column -t -s'\t'" or die;
+ $print_key = 0;
+}
+
print STDERR "Scanning contestants... ";
open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
while (<CT>) {
elsif ($trem =~ /^Caught fatal signal /) { $cmt = "SG"; }
elsif ($trem =~ /^([A-Za-z])\S*\s+([A-Za-z])/) {
($cmt = "$1$2") =~ tr/a-z/A-Z/;
+ } elsif ($trem =~ /^([A-Za-z]{2})/) {
+ ($cmt = $1) =~ tr/a-z/A-Z/;
}
if (!defined $messages{$trem}) {
$messages{$trem} = $cmt;
} else {
${table[$j]}[0] = $j+1 . ".-" . $i . ".";
$j++;
- while ($j < $i) { ${table[$j++]}[0] = ""; };
+ while ($j < $i) { ${table[$j++]}[0] = " "; };
}
}
print STDERR "OK\n";
my @perm;
&printHtmlHeader(\@perm);
print "<tbody>";
-
+
foreach $r (@table[1..($#table - 1)]) {
&printHtmlRow(@{$r}[@perm]);
}
print "\\error{TeX output not supported yet!}\n";
} else {
foreach $r (@table) { print join("\t",@$r), "\n"; }
- print "\n";
- foreach $r (sort keys %error_codes) { print "$r: $error_codes{$r}\n"; }
+ if ($print_key) {
+ print "\n";
+ foreach $r (sort keys %error_codes) { print "$r: $error_codes{$r}\n"; }
+ }
}
-
sub printHtmlRow {
print "<TR>", join('',map {
if ($hdr) { $_ = "<TH>$_"; }
} @_), "\n";
}
-
sub printHtmlHeader {
my ($perm) = @_;
$p++;
map { push @$perm, $p++ } (1..$nSub);
push @$perm, $p - $nSub - 1;
-
+
$colspec .= "<colgroup span='" . $nSub . "'>\n";
$colspec .= "<colgroup span='1'>\n";
$hdr1 .= "<th colspan='" . ($nSub + 1) . "' style='border-bottom:1px solid black;'>$task";
$hdr2 .= join("", map { "<th>$_" } sort {$a <=> $b} keys %{$known_tests{$task}});
$hdr2 .= "<th>Total";
}
-
+
$hdr1 .= "<th rowspan='2'>Total";
-
+
} else { ## no detail
-
+
$hdr1 = "<th>Rank<th>User<th>Name";
$extras and $p++ and push @$perm, 3 and $hdr1.="<th>Extra" and $colspec.="<colgroup span=1>"; ##Extra hack
}
push @$perm, $p++;
-
+
print "<TABLE rules=groups frame=all border='1' cellpadding='2'>\n";
print "$colspec<colgroup span='1'>\n";
print "<tr>$hdr1</tr>\n";
print "<tr>$hdr2</tr>\n" if $detail;
-
+
}
+
+close STDOUT;