X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mop%2Feval%2Fmo-score.sh;h=9326b9aa129c7d6cba5ddbb026aa0bc2a911d21d;hb=1636b318830d64ec5c393d1a2d043f595f0342c4;hp=4dec3a11677f9106d694340be829cfb2a0c1f8fa;hpb=fc833e30d9b1315ffdeb780d5257e8e1bdafad43;p=eval.git diff --git a/mop/eval/mo-score.sh b/mop/eval/mo-score.sh index 4dec3a1..9326b9a 100755 --- a/mop/eval/mo-score.sh +++ b/mop/eval/mo-score.sh @@ -1,4 +1,5 @@ #!/usr/bin/perl +# A generator of score sheets. More ugly than it deserves. $debug = 0; $detail = 0; @@ -7,7 +8,8 @@ $tex = 0; $extras = 0; $alt = 0; $merged = 0; -$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--merged] [/] ..."; +$table = 0; +$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--table] [--merged] [/] ..."; while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) { shift @ARGV; $var = "\$$1"; @@ -16,6 +18,12 @@ while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) { } @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 () { @@ -74,6 +82,8 @@ foreach $u (keys %users) { 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; @@ -177,7 +187,7 @@ while ($i < @table) { } else { ${table[$j]}[0] = $j+1 . ".-" . $i . "."; $j++; - while ($j < $i) { ${table[$j++]}[0] = ""; }; + while ($j < $i) { ${table[$j++]}[0] = " "; }; } } print STDERR "OK\n"; @@ -199,7 +209,7 @@ if ($debug) { my @perm; &printHtmlHeader(\@perm); print ""; - + foreach $r (@table[1..($#table - 1)]) { &printHtmlRow(@{$r}[@perm]); } @@ -218,11 +228,12 @@ if ($debug) { 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 "", join('',map { if ($hdr) { $_ = "$_"; } @@ -230,7 +241,6 @@ sub printHtmlRow { } @_), "\n"; } - sub printHtmlHeader { my ($perm) = @_; @@ -252,18 +262,18 @@ sub printHtmlHeader { $p++; map { push @$perm, $p++ } (1..$nSub); push @$perm, $p - $nSub - 1; - + $colspec .= "\n"; $colspec .= "\n"; $hdr1 .= "$task"; $hdr2 .= join("", map { "$_" } sort {$a <=> $b} keys %{$known_tests{$task}}); $hdr2 .= "Total"; } - + $hdr1 .= "Total"; - + } else { ## no detail - + $hdr1 = "RankUserName"; $extras and $p++ and push @$perm, 3 and $hdr1.="Extra" and $colspec.=""; ##Extra hack @@ -276,10 +286,12 @@ sub printHtmlHeader { } push @$perm, $p++; - + print "\n"; print "$colspec\n"; print "$hdr1\n"; print "$hdr2\n" if $detail; - + } + +close STDOUT;