$tex = 0;
$extras = 0;
$alt = 0;
-$split = 0;
-$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--split] <task1> <task2> ...";
+$merged = 0;
+$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--merged] [<directory>/]<task> ...";
while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
shift @ARGV;
$var = "\$$1";
}
@ARGV || die $usage;
-@tasks = @ARGV;
-
print STDERR "Scanning contestants... ";
open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
while (<CT>) {
} else { print STDERR "none\n"; }
print STDERR "Scanning task results... ";
-$need_tasks = join("|", @ARGV);
%messages = ();
%error_codes = ();
foreach $u (keys %users) {
- opendir (D, "testing/$u") or next;
- foreach $t (readdir(D)) {
- $t =~ /^\./ && next;
- $t =~ /$need_tasks/ || next;
+ foreach $task (@ARGV) {
+ my ($dir, $t) = ("testing", $task);
+ if ($task =~ m@^(.*)/([^/]*)$@) {
+ $dir = $1;
+ $t = $2;
+ }
$known_tasks{$t} = 1;
- $tt = "testing/$u/$t/points" . ($alt ? ".alt" : "");
+ $tt = "$dir/$u/$t/points" . ($alt ? ".alt" : "");
-f $tt || next;
print STDERR "$u/$t ";
open (X, $tt) || die "Unable to open $tt";
$tpts = $2;
$trem = $3;
$trem =~ s/\[.*//;
- $ttest =~ s/[^0-9]//g unless $split;
+ ($ttest_merged = $ttest) =~ s/[^0-9]//g;
+ $ttest = $ttest_merged if $merged;
$known_tests{$t}{$ttest} = 1;
$cmt = $tpts;
if ($tpts == 0 && $trem ne "OK") {
elsif ($trem =~ /^([A-Za-z])\S*\s+([A-Za-z])/) {
($cmt = "$1$2") =~ tr/a-z/A-Z/;
}
- elsif ($trem =~ /^Wrong answer/) { $cmt = "WA"; }
if (!defined $messages{$trem}) {
$messages{$trem} = $cmt;
if (!defined $error_codes{$cmt}) {
$results{$u}{$t}{$ttest} = $tpts;
$comment{$u}{$t}{$ttest} = $cmt;
}
+ if (!defined($results_merged{$u}{$t}{$ttest_merged}) || $results_merged{$u}{$t}{$ttest_merged} > $tpts) {
+ $results_merged{$u}{$t}{$ttest_merged} = $tpts;
+ }
}
close X;
}
foreach my $t (keys %known_tasks) {
$total{$u}{$t} = 0;
- foreach my $pts (values %{$results{$u}{$t}}) { $total{$u}{$t} += $pts; }
+ foreach my $pts (values %{$results_merged{$u}{$t}}) { $total{$u}{$t} += $pts; }
}
- closedir D;
}
print STDERR "OK\n";
push @bodysums, $col;
push @footer, "sum($col)";
}
-foreach $t (@ARGV) {
+@tasks = ();
+foreach $task (@ARGV) {
+ my $t = ($task =~ m@/([^/]*)$@) ? $1 : $task;
defined $known_tasks{$t} || die "Unknown task $t";
+ push @tasks, $t;
push @header, substr($t, 0, 4);
push @body, "(\$xx = \$total{\$u}{'$t'}) > 0 ? \$xx : 0";
$col = 0+@footer;
if ($detail) {
$hdr1 = "<th rowspan=2>Rank<th rowspan=2>User<th rowspan=2>Name";
+ $extras and $p++ and push @$perm, 3 and $hdr1.="<th rowspan=2>Extra" and $colspec.="<colgroup span=1>"; ##Extra hack
for my $task (@tasks) {
my $nSub = scalar(keys %{$known_tests{$task}});
} 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
for my $task (@tasks) {
push @$perm, $p++;