]> mj.ucw.cz Git - eval.git/blobdiff - bin/mo-score
Updated the release.pm module.
[eval.git] / bin / mo-score
index 4fce9e44be5f9aa32e21c6a344c5d05b88b692bd..4dec3a11677f9106d694340be829cfb2a0c1f8fa 100755 (executable)
@@ -6,7 +6,8 @@ $html = 0;
 $tex = 0;
 $extras = 0;
 $alt = 0;
 $tex = 0;
 $extras = 0;
 $alt = 0;
-$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] <task1> <task2> ...";
+$merged = 0;
+$usage = "Usage: mo-score [--detail] [--alt] [--extras] [--html] [--tex] [--merged] [<directory>/]<task> ...";
 while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
        shift @ARGV;
        $var = "\$$1";
 while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
        shift @ARGV;
        $var = "\$$1";
@@ -15,8 +16,6 @@ while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
 }
 @ARGV || die $usage;
 
 }
 @ARGV || die $usage;
 
-@tasks = @ARGV;
-
 print STDERR "Scanning contestants... ";
 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
 while (<CT>) {
 print STDERR "Scanning contestants... ";
 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
 while (<CT>) {
@@ -43,16 +42,17 @@ if ($extras && open (EX, "exceptions")) {
 } else { print STDERR "none\n"; }
 
 print STDERR "Scanning task results... ";
 } else { print STDERR "none\n"; }
 
 print STDERR "Scanning task results... ";
-$need_tasks = join("|", @ARGV);
 %messages = ();
 %error_codes = ();
 foreach $u (keys %users) {
 %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;
                $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";
                -f $tt || next;
                print STDERR "$u/$t ";
                open (X, $tt) || die "Unable to open $tt";
@@ -62,12 +62,12 @@ foreach $u (keys %users) {
                        $ttest = $1;
                        $tpts = $2;
                        $trem = $3;
                        $ttest = $1;
                        $tpts = $2;
                        $trem = $3;
-                       $ttest =~ s/[^0-9]//g;
+                       $trem =~ s/\[.*//;
+                       ($ttest_merged = $ttest) =~ s/[^0-9]//g;
+                       $ttest = $ttest_merged if $merged;
                        $known_tests{$t}{$ttest} = 1;
                        $known_tests{$t}{$ttest} = 1;
-                       $results{$u}{$t}{$ttest} = $tpts;
-                       $remarks{$u}{$t}{$ttest} = $trem;
                        $cmt = $tpts;
                        $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"; }
                                if ($trem =~ /^Compile /) { $cmt = "CE"; }
                                elsif ($trem =~ /^Time limit exceeded/) { $cmt = "TO"; }
                                elsif ($trem =~ /^Exited with error /) { $cmt = "RE"; }
@@ -75,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 =~ /^([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}) {
                                if (!defined $messages{$trem}) {
                                        $messages{$trem} = $cmt;
                                        if (!defined $error_codes{$cmt}) {
@@ -85,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;
        }
                }
                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";
 
 }
 print STDERR "OK\n";
 
@@ -106,8 +113,11 @@ if (keys %extra) {
        push @bodysums, $col;
        push @footer, "sum($col)";
 }
        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";
        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;
        push @header, substr($t, 0, 4);
        push @body, "(\$xx = \$total{\$u}{'$t'}) > 0 ? \$xx : 0";
        $col = 0+@footer;
@@ -234,6 +244,7 @@ sub printHtmlHeader {
 
    if ($detail) {
      $hdr1 = "<th rowspan=2>Rank<th rowspan=2>User<th rowspan=2>Name";
 
    if ($detail) {
      $hdr1 = "<th rowspan=2>Rank<th rowspan=2>User<th rowspan=2>Name";
+     $extras and $p++ and push @$perm, 3 and $hdr1.="<th rowspan=2>Extra" and $colspec.="<colgroup span=1>";         ##Extra hack
      for my $task (@tasks) {
 
        my $nSub = scalar(keys %{$known_tests{$task}});
      for my $task (@tasks) {
 
        my $nSub = scalar(keys %{$known_tests{$task}});
@@ -254,6 +265,7 @@ sub printHtmlHeader {
    } else {  ## no detail
    
      $hdr1 = "<th>Rank<th>User<th>Name";
    } else {  ## no detail
    
      $hdr1 = "<th>Rank<th>User<th>Name";
+     $extras and $p++ and push @$perm, 3 and $hdr1.="<th>Extra" and $colspec.="<colgroup span=1>";                  ##Extra hack
 
      for my $task (@tasks) {
         push @$perm, $p++;
 
      for my $task (@tasks) {
         push @$perm, $p++;