4 $usage = "Usage: mo-score2004 [--tex] theoretical_tasks_nr praxis_tasks_nr task1 task2 ...";
5 while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
8 if (!eval "defined $var") { die $usage; }
11 @ARGV >=2 || die $usage;
14 @ARGV >= $praxis || die $usage;
16 print STDERR "Scanning contestants... ";
17 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
21 ($u eq "somebody") && next;
25 print STDERR 0+keys %users, "\n";
27 print STDERR "Scanning teoretical results... ";
28 if (open (EX, "teorie.txt")) {
31 (/^$/ || /^#/) && next;
32 @a = split /\ *\t\ */;
34 defined $users{$u} || die "Unknown user $u";
35 $names{$u} = shift @a;
36 $forms{$u} = shift @a;
37 $addresses{$u} = "{". (shift @a) ."}";
39 while (@a) { $tasks{$u}{$i} = shift @a;$i++; }
43 } else {die "none\n";}
45 print STDERR "Scanning task results... ";
46 $need_tasks = join("|", @ARGV);
47 foreach $u (keys %users) {
48 opendir (D, "testing/$u") or next;
49 foreach $t (readdir(D)) {
51 $t =~ /$need_tasks/ || next;
54 for (my $t_num2=0;$t_num2<@ARGV;$t_num2++) {if ($t eq $ARGV[$t_num2]) {$t_num=$t_num2;}}
57 $tt = "testing/$u/$t/points";
59 print STDERR "$u/$t ";
60 open (X, $tt) || die "Unable to open $tt";
63 /^\S+ (-?\d+)/ || die "Parse error: $_";
64 $tasks{$u}{$t_num} += $1;
72 print STDERR "Creating table template... ";
73 @body = ('','$names{$u}','$forms{$u}','$addresses{$u}');
74 for ($a=0;$a<$theory+$praxis;$a++) {push @body,"\$tasks{\$u}{$a}";}
77 print STDERR "Filling in results... ";
79 foreach $u (keys %users) {
83 foreach my $c (@body) {
84 $c =~ s/\$(\d+)/\$\$row[$1]/g;
86 push @$row, (defined $x ? $x : '-');
88 if ((defined $x) && ($x>0)) {$row_sum+=$x;}
97 print STDERR "Sorting... ";
98 $sortcol = @{$table[0]} - 1;
102 $p = $$b[$sortcol] <=> $$a[$sortcol];
103 ($an = $$a[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
104 ($bn = $$b[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
105 $p ? $p : ($an cmp $bn);
108 while ($i < @table) {
110 while ($i < @table && ${$table[$i]}[$sortcol] == ${$table[$j]}[$sortcol]) {
114 ${table[$j]}[0] = "$i.";
116 ${table[$j]}[0] = $j+1 . ".-" . $i . ".";
119 while ($j < $i) { ${table[$j++]}[0] = $j_old+1 . ".-" . $i . "."; };
128 \font\head=csr12 scaled \magstephalf
131 \def\xit{\xxit\kern-0.1em\relax}
136 \centerline{\head Výsledková listina celostátního kola 53. roèníku MO kategorie P}
138 \centerline{\hexx 31. bøezna -- 3. dubna 2004 v Pøerovì}
145 \centerline{\vbox{\halign{%
146 #\hfil &~~#\hfil &\quad #\hfil &~~#\hfil&\quad
153 \noalign{\bigskip\bigskip\hbox{\xit Vítìzové}\bigskip}
154 %\noalign{\bigskip\bigskip\hbox{\xit Úspì¹ní øe¹itelé}\bigskip}
155 %\noalign{\bigskip\bigskip\hbox{\xit Ostatní úèastníci}\bigskip}
157 foreach $r (@table) { print join('&',@$r), "\\cr\n";}
171 foreach $r (@table) { print join("\t",@$r), "\n"; }