6 $usage = "Usage: mo-score2004 [--tex] task1 task2 ...";
7 while (($arg = $ARGV[0]) =~ /^--([a-z]+)$/) {
10 if (!eval "defined $var") { die $usage; }
13 @ARGV >= $praxis || die $usage;
15 print STDERR "Scanning contestants... ";
16 open (CT, "bin/mo-get-users --full |") || die "Cannot get list of contestants";
20 ($u eq "somebody") && next;
24 print STDERR 0+keys %users, "\n";
26 print STDERR "Scanning teoretical results... ";
27 if (open (EX, "teorie.txt")) {
30 (/^$/ || /^#/) && next;
31 @a = split /\ *\t\ */;
33 defined $users{$u} || die "Unknown user $u";
34 $names{$u} = shift @a;
35 $forms{$u} = shift @a;
36 $addresses{$u} = "{". (shift @a) ."}";
38 while (@a) { $tasks{$u}{$i} = shift @a;$i++; }
42 } else {die "none\n";}
44 print STDERR "Scanning task results... ";
45 $need_tasks = join("|", @ARGV);
46 foreach $u (keys %users) {
47 opendir (D, "testing/$u") or next;
48 foreach $t (readdir(D)) {
50 $t =~ /$need_tasks/ || next;
53 for (my $t_num2=0;$t_num2<@ARGV;$t_num2++) {if ($t eq $ARGV[$t_num2]) {$t_num=$t_num2;}}
56 $tt = "testing/$u/$t/points";
58 print STDERR "$u/$t ";
59 open (X, $tt) || die "Unable to open $tt";
62 /^\S+ (-?\d+)/ || die "Parse error: $_";
63 $tasks{$u}{$t_num} += $1;
71 print STDERR "Creating table template... ";
72 @body = ('','$names{$u}','$forms{$u}','$addresses{$u}');
73 for ($a=0;$a<$theory+$praxis;$a++) {push @body,"\$tasks{\$u}{$a}";}
76 print STDERR "Filling in results... ";
78 foreach $u (keys %users) {
82 foreach my $c (@body) {
83 $c =~ s/\$(\d+)/\$\$row[$1]/g;
85 push @$row, (defined $x ? $x : '-');
87 if ((defined $x) && ($x>0)) {$row_sum+=$x;}
96 print STDERR "Sorting... ";
97 $sortcol = @{$table[0]} - 1;
101 $p = $$b[$sortcol] <=> $$a[$sortcol];
102 ($an = $$a[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
103 ($bn = $$b[$namecol]) =~ s/(\S+)\s+(\S+)/$2 $1/;
104 $p ? $p : ($an cmp $bn);
107 while ($i < @table) {
109 while ($i < @table && ${$table[$i]}[$sortcol] == ${$table[$j]}[$sortcol]) {
113 ${table[$j]}[0] = "$i.";
115 ${table[$j]}[0] = $j+1 . ".-" . $i . ".";
118 while ($j < $i) { ${table[$j++]}[0] = $j_old+1 . ".-" . $i . "."; };
126 \font\head=csr12 scaled \magstephalf
129 \def\xit{\xxit\kern-0.1em\relax}
133 \advance\hsize by 0.2cm
134 \advance\hoffset by 1cm
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 \enspace&#\hfil\enspace & #\hfil & \quad #\hfil&
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"; }