]> mj.ucw.cz Git - moe.git/blob - mop/score/mo-score-mop.sh
d7aca2e54e616006353aa4b88a68488e3752612d
[moe.git] / mop / score / mo-score-mop.sh
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use List::Util qw(min);
5
6 @ARGV or die "Usage: mo-score-mop task1 task2 ...";
7
8 print STDERR "Scanning contestants... ";
9 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
10 my %users = ();
11 while (<CT>) {
12         chomp;
13         my ($u, $f) = split /\t/;
14         $u =~ /^mo/ or next;
15         $users{$u}=$f;
16 }
17 close CT;
18 print STDERR 0+keys %users, "\n";
19
20 print STDERR "Scanning task results... ";
21 my %tasks = ();
22 for my $u (keys %users) {
23         for my $t (@ARGV) {
24                 my $tt = "testing/$u/$t/points";
25                 -f $tt || next;
26                 print STDERR "$u/$t ";
27                 open (X, $tt) || die "Unable to open $tt";
28                 my %groups = ();
29                 while (<X>) {
30                         chomp;
31                         my ($test, $pts) = /^(\S+) (-?\d+)/ or die "Parse error: $_";
32                         my $group = $test;
33                         $group =~ s{\D}{}g;
34                         if (defined $groups{$group}) {
35                                 $groups{$group} = min($groups{$group}, $pts);
36                         } else {
37                                 $groups{$group} = $pts;
38                         }
39                 }
40                 close X;
41
42                 for my $g (keys %groups) {
43                         $tasks{$u}{$t} += $groups{$g};
44                 }
45         }
46 }
47 print STDERR "OK\n";
48
49 print STDERR "Generating output... ";
50 for my $u (sort keys %users) {
51         print join("\t", $u, $users{$u}, map { $tasks{$u}{$_} // '-' } @ARGV), "\n";
52 }
53 print STDERR "OK\n";
54