X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=bin%2Fmo-score;h=4dec3a11677f9106d694340be829cfb2a0c1f8fa;hb=107b5e8dc73f0180e2b3f35f8ed031662bbc57fb;hp=e04c47b0737866c62f463caf377b633b42ebaba4;hpb=29d9c3f9dd179269ed7f0a11738bb17548e26fdf;p=moe.git diff --git a/bin/mo-score b/bin/mo-score index e04c47b..4dec3a1 100755 --- a/bin/mo-score +++ b/bin/mo-score @@ -6,7 +6,8 @@ $html = 0; $tex = 0; $extras = 0; $alt = 0; -$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] ..."; +$merged = 0; +$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--merged] [/] ..."; while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) { shift @ARGV; $var = "\$$1"; @@ -41,16 +42,17 @@ if ($extras && open (EX, "exceptions")) { } 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"; @@ -60,11 +62,12 @@ foreach $u (keys %users) { $ttest = $1; $tpts = $2; $trem = $3; + $trem =~ s/\[.*//; + ($ttest_merged = $ttest) =~ s/[^0-9]//g; + $ttest = $ttest_merged if $merged; $known_tests{$t}{$ttest} = 1; - $results{$u}{$t}{$ttest} = $tpts; - $remarks{$u}{$t}{$ttest} = $trem; $cmt = $tpts; - if ($tpts == 0) { + if ($tpts == 0 && $trem ne "OK") { if ($trem =~ /^Compile /) { $cmt = "CE"; } elsif ($trem =~ /^Time limit exceeded/) { $cmt = "TO"; } elsif ($trem =~ /^Exited with error /) { $cmt = "RE"; } @@ -72,7 +75,6 @@ foreach $u (keys %users) { 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}) { @@ -82,12 +84,20 @@ foreach $u (keys %users) { } } } - $comment{$u}{$t}{$ttest} = $cmt; - $total{$u}{$t} += $tpts; + if (!defined($results{$u}{$t}{$ttest}) || $results{$u}{$t}{$ttest} > $tpts) { + $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; } - closedir D; + foreach my $t (keys %known_tasks) { + $total{$u}{$t} = 0; + foreach my $pts (values %{$results_merged{$u}{$t}}) { $total{$u}{$t} += $pts; } + } } print STDERR "OK\n"; @@ -103,8 +113,11 @@ if (keys %extra) { 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; @@ -182,19 +195,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"; - foreach $r (sort keys %error_codes) { print "
  • $r: $error_codes{$r}\n"; } - print "
\n"; + if ($detail) { + print "

Error codes

    \n"; + foreach $r (sort keys %error_codes) { print "
  • $r: $error_codes{$r}\n"; } + print "
\n"; + } print "\n"; } elsif ($tex) { print "\\error{TeX output not supported yet!}\n"; @@ -203,3 +221,65 @@ 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"; + $extras and $p++ and push @$perm, 3 and $hdr1.="Extra" and $colspec.=""; ##Extra hack + 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"; + $extras and $p++ and push @$perm, 3 and $hdr1.="Extra" and $colspec.=""; ##Extra hack + + 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; + +}