X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmo-score;h=4fce9e44be5f9aa32e21c6a344c5d05b88b692bd;hb=9306a593e097b30b55196f0fb7dd7c189389a0d3;hp=e04c47b0737866c62f463caf377b633b42ebaba4;hpb=29d9c3f9dd179269ed7f0a11738bb17548e26fdf;p=eval.git diff --git a/bin/mo-score b/bin/mo-score index e04c47b..4fce9e4 100755 --- a/bin/mo-score +++ b/bin/mo-score @@ -15,6 +15,8 @@ while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) { } @ARGV || die $usage; +@tasks = @ARGV; + print STDERR "Scanning contestants... "; open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants"; while () { @@ -60,6 +62,7 @@ foreach $u (keys %users) { $ttest = $1; $tpts = $2; $trem = $3; + $ttest =~ s/[^0-9]//g; $known_tests{$t}{$ttest} = 1; $results{$u}{$t}{$ttest} = $tpts; $remarks{$u}{$t}{$ttest} = $trem; @@ -182,19 +185,24 @@ if ($debug) { print '', "\n"; print "Rank list\n"; print "

Rank list

\n"; - print "\n"; - $hdr = 1; - foreach $r (@table) { - print "", join('',map { - if ($hdr) { $_ = ""; + + foreach $r (@table[1..($#table - 1)]) { + &printHtmlRow(@{$r}[@perm]); } + + print ""; + &printHtmlRow(@{$table[$#table]}[@perm]); + print "
$_"; } - else { $_ = " 14 ? " width=150" : "") . ">$_"; } - } @$r), "\n"; - $hdr = 0; + + my @perm; + &printHtmlHeader(\@perm); + print "
\n"; - print "

Error codes

\n"; + if ($detail) { + print "

Error codes

\n"; + } print "\n"; } elsif ($tex) { print "\\error{TeX output not supported yet!}\n"; @@ -203,3 +211,63 @@ if ($debug) { print "\n"; foreach $r (sort keys %error_codes) { print "$r: $error_codes{$r}\n"; } } + + +sub printHtmlRow { + print "", join('',map { + if ($hdr) { $_ = "$_"; } + else { $_ = " 14 ? " width=150" : "") . ">$_"; } + } @_), "\n"; +} + + +sub printHtmlHeader { + + my ($perm) = @_; + + my $colspec = ""; + my $hdr1; + my $hdr2; + + @$perm = (0, 1, 2); + my $p = 3; + + if ($detail) { + $hdr1 = "RankUserName"; + for my $task (@tasks) { + + my $nSub = scalar(keys %{$known_tests{$task}}); + + $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"; + + for my $task (@tasks) { + push @$perm, $p++; + $hdr1 .= "$task"; + } + $hdr1 .= "Total"; + $colspec .= ""; + } + + push @$perm, $p++; + + print "\n"; + print "$colspec\n"; + print "$hdr1\n"; + print "$hdr2\n" if $detail; + +}