]> mj.ucw.cz Git - moe.git/blob - bin/mo-score
Partial.
[moe.git] / bin / mo-score
1 #!/usr/bin/perl
2
3 # Syntax: mo-score <expr> ...  (one expr per column)
4 # where <expr> is ["title":]<perl-expression> containing
5 #       $user           short user name
6 #       $full           full user name
7 #       $<number>       value in specified column
8 #       $<task>         total number of points for this task or failure indicator
9 #       $<task>:<test>  number of points per specified test
10
11 print "Scanning contestants... ";
12 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
13 while (<CT>) {
14         chomp;
15         ($u,$f) = split /\t/;
16         $users{$u}=$f;
17 }
18 close CT;
19 print 0+keys %users, "\n";
20
21 print "Scanning task results... ";
22 foreach $u (keys %users) {
23         opendir (D, "testing/$u") or next;
24         foreach $t (readdir(D)) {
25                 $t =~ /^\./ && next;
26                 $tt = "testing/$u/$t/points";
27                 -f $tt || next;
28                 print "$u/$t ";
29                 open (X, $tt) || die "Unable to open $tt";
30                 while (<X>) {
31                         chomp;
32                         /^(\d+) (\d+)(.*)/ || die "Parse error: $_";
33                         $ttest = $1;
34                         $tpts = $2;
35                         $trem = $3;
36                         $results{$u}{$t}{$ttest} = $tpts;
37                         $remarks{$u}{$t}{$ttest} = $trem;
38                         $cmt = "";
39                         if ($tpts == 0) {
40                                 $msg = $3;
41                                 if $msg =~ /^Compile / { $cmt = "CE"; }
42                                 elif $msg =~ /^Time limit exceeded/ { $cmt = "TO"; }
43                                 elif $msg =~ /^Exited with error / { $cmt = "RE"; }
44                                 elif $msg =~ /^Caught fatal signal / { $cmt = "SG"; }
45                         }
46                         $comment{$u}{$t}{$ttest} = $cmt;
47                 }
48                 close X;
49         }
50         closedir D;
51 }
52 print "OK\n";