]> mj.ucw.cz Git - eval.git/commitdiff
Lots of minor improvements.
authorMartin Mares <mj@ucw.cz>
Fri, 8 Jun 2001 15:25:46 +0000 (15:25 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 8 Jun 2001 15:25:46 +0000 (15:25 +0000)
bin/mo-score

index f609fc31065582815d2a4799cfe2d4e512378396..1c2c012cdc44781909a1965b475dc709db09176b 100755 (executable)
@@ -4,7 +4,9 @@ $debug = 0;
 $detail = 0;
 $html = 0;
 $tex = 0;
-$usage = "Usage: mo-score [--detail] [--html] [--tex] <task1> <task2> ...";
+$extras = 0;
+$alt = 0;
+$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] <task1> <task2> ...";
 while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
        shift @ARGV;
        $var = "\$$1";
@@ -18,24 +20,41 @@ open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
 while (<CT>) {
        chomp;
        ($u,$f) = split /\t/;
+       ($u eq "somebody") && next;
        $users{$u}=$f;
 }
 close CT;
 print STDERR 0+keys %users, "\n";
 
+print STDERR "Scanning exceptions... ";
+if ($extras && open (EX, "exceptions")) {
+       while (<EX>) {
+               chomp;
+               (/^$/ || /^#/) && next;
+               @a = split /\s+/;
+               $u = shift @a;
+               defined $users{$u} || die "Unknown user $u";
+               while (@a) { $extra{$u} += shift @a; }
+       }
+       close EX;
+       print STDERR "OK\n";
+} else { print STDERR "none\n"; }
+
 print STDERR "Scanning task results... ";
+$need_tasks = join("|", @ARGV);
 foreach $u (keys %users) {
        opendir (D, "testing/$u") or next;
        foreach $t (readdir(D)) {
                $t =~ /^\./ && next;
+               $t =~ /$need_tasks/ || next;
                $known_tasks{$t} = 1;
-               $tt = "testing/$u/$t/points";
+               $tt = "testing/$u/$t/points" . ($alt ? ".alt" : "");
                -f $tt || next;
                print STDERR "$u/$t ";
                open (X, $tt) || die "Unable to open $tt";
                while (<X>) {
                        chomp;
-                       /^(\d+) (\d+)(.*)/ || die "Parse error: $_";
+                       /^(\S+) (-?\d+)\s*(.*)/ || die "Parse error: $_";
                        $ttest = $1;
                        $tpts = $2;
                        $trem = $3;
@@ -44,11 +63,14 @@ foreach $u (keys %users) {
                        $remarks{$u}{$t}{$ttest} = $trem;
                        $cmt = $tpts;
                        if ($tpts == 0) {
-                               $msg = $3;
-                               if ($msg =~ /^Compile /) { $cmt = "CE"; }
-                               elsif ($msg =~ /^Time limit exceeded/) { $cmt = "TO"; }
-                               elsif ($msg =~ /^Exited with error /) { $cmt = "RE"; }
-                               elsif ($msg =~ /^Caught fatal signal /) { $cmt = "SG"; }
+                               if ($trem =~ /^Compile /) { $cmt = "CE"; }
+                               elsif ($trem =~ /^Time limit exceeded/) { $cmt = "TO"; }
+                               elsif ($trem =~ /^Exited with error /) { $cmt = "RE"; }
+                               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 =~ /^Wrong answer/) { $cmt = "WA"; }
                        }
                        $comment{$u}{$t}{$ttest} = $cmt;
                        $total{$u}{$t} += $tpts;
@@ -64,10 +86,17 @@ print STDERR "Creating table template... ";
 @body = ('','$u','$users{$u}');
 @bodysums = ();
 @footer = ('"Total"','','');
+if (keys %extra) {
+       push @header, "Extra";
+       push @body, '$extra{$u}';
+       $col = 0+@footer;
+       push @bodysums, $col;
+       push @footer, "sum($col)";
+}
 foreach $t (@ARGV) {
        defined $known_tasks{$t} || die "Unknown task $t";
-       push @header, "$t";
-       push @body, "\$total{\$u}{'$t'}";
+       push @header, substr($t, 0, 4);
+       push @body, "(\$xx = \$total{\$u}{'$t'}) > 0 ? \$xx : 0";
        $col = 0+@footer;
        push @footer, "sum($col)";
        push @bodysums, $col;
@@ -123,7 +152,7 @@ while ($i < @table) {
        if ($i == $j+1) {
                ${table[$j]}[0] = "$i.";
        } else {
-               ${table[$j]}[0] = $j+1 . ".--" . $i . ".";
+               ${table[$j]}[0] = $j+1 . ".-" . $i . ".";
                $j++;
                while ($j < $i) { ${table[$j++]}[0] = ""; };
        }
@@ -148,7 +177,7 @@ if ($debug) {
        foreach $r (@table) {
                print "<TR>", join('',map {
                        if ($hdr) { $_ = "<TH>$_"; }
-                       else { $_ = "<TD align=" . (/^[0-9-]+$/ ? "right" : "left") . ">$_"; }
+                       else { $_ = "<TD align=" . (/^[0-9A-Z-]+$/ ? "right" : "left") . (length($_) > 14 ? " width=150" : "") . ">$_"; }
                } @$r), "\n";
                $hdr = 0;
        }