X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=mop%2Feval%2Fmo-score.sh;h=9d0a200ec13f29e72669b848d1bce8ffa5dc2dad;hb=32a38f82fff9cf1098f68a2b9ada9f9e0f98fdd6;hp=4dec3a11677f9106d694340be829cfb2a0c1f8fa;hpb=fc833e30d9b1315ffdeb780d5257e8e1bdafad43;p=eval.git diff --git a/mop/eval/mo-score.sh b/mop/eval/mo-score.sh index 4dec3a1..9d0a200 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 () { @@ -199,7 +207,7 @@ if ($debug) { my @perm; &printHtmlHeader(\@perm); print ""; - + foreach $r (@table[1..($#table - 1)]) { &printHtmlRow(@{$r}[@perm]); } @@ -218,11 +226,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 +239,6 @@ sub printHtmlRow { } @_), "\n"; } - sub printHtmlHeader { my ($perm) = @_; @@ -252,18 +260,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 +284,10 @@ sub printHtmlHeader { } push @$perm, $p++; - + print "\n"; print "$colspec\n"; print "$hdr1\n"; print "$hdr2\n" if $detail; - + }