--- processmail/Attic/createtable2.pl 2004/12/08 20:48:37 1.1 +++ processmail/Attic/createtable2.pl 2005/01/24 03:14:49 1.2 @@ -1,5 +1,5 @@ #!/usr/local/bin/perl -#$Id: createtable2.pl,v 1.1 2004/12/08 20:48:37 boris Exp $ +#$Id: createtable2.pl,v 1.2 2005/01/24 03:14:49 boris Exp $ # # # @@ -8,13 +8,13 @@ use Getopt::Std; -$usage = 'createtable.pl $Revision: 1.1 $, $Date: 2004/12/08 20:48:37 $'. "\n". -"Usage: createtable.pl [-d] [-s] [-t answers_file] [-m mail_file] [-o results] \n"; +$usage = 'createtable2.pl $Revision: 1.2 $, $Date: 2005/01/24 03:14:49 $'. "\n". +"Usage: createtable2.pl [-d] [-s] [-T prelim_answers] [-M prelim_mail] [-t answers_file] [-m mail_file] [-o results] \n"; require 'parameters.pl'; require 'subroutines.pl'; -die $usage unless getopts('t:m:o:ds'); +die $usage unless getopts('t:T:m:M:o:ds'); $DEBUG=$opt_d; $SHORT=$opt_s; @@ -22,6 +22,48 @@ $SHORT=$opt_s; my %teams; my @answers; my @ratings; + +# +# ПРЕДВАРИТЕЛЬНЫЕ РЕЗУЛЬТАТЫ +# + +# Читаем старые результаты +# +if ($opt_T) +{ + die "Cannot open $opt_T\n" unless open(INFILE,$opt_T); + readhash(\@answers); + close(INFILE); +} + +# +# Читаем ответы команд +# +if ($opt_M) +{ + die "Cannot open $opt_M\n" unless open(INFILE,$opt_M) +} +else +{ + *INFILE=*STDIN; +} +readmail(\%teams); +close(INFILE); +# +# Чистим хэш %answers +# +collect_answers(\%teams,\@answers); + +# +# Вычисляем число ответов и рейтинги команд +# +find_scores(\%teams,\@answers,\@ratings); + + +# +# ОКОНЧАТЕЛЬНЫЕ РЕЗУЛЬТАТЫ +# + # # Читаем старые результаты # @@ -56,7 +98,9 @@ rate_questions(\%teams,\@answers,\@ratin # # Вычисляем число ответов и рейтинги команд # -find_scores(\%teams,\@answers,\@ratings); +find_scores(\%teams,\@answers,\@ratings,0.01); + + # # Ну а теперь печатаем саму таблицу... # @@ -77,7 +121,7 @@ for ($i=1;$i<=$MAXQUEST;$i++) printf "%3d",$i; } } -printf "%3s","О"; +printf "%6s","О"; printf "%4s","Р"; printf " КОМАНДА"; print "\n"; @@ -104,7 +148,7 @@ foreach $team (sort printf "%3s", $score; } } - printf "%3s",$teams{$team}->{score}; + printf "%6.2f",$teams{$team}->{score}; printf "%4s",$teams{$team}->{rating}; print " $team"; print "\n";