--- db/prgsrc/db.cgi 2004/03/17 10:26:31 1.132 +++ db/prgsrc/db.cgi 2004/09/05 14:57:05 1.136 @@ -3,6 +3,7 @@ use DBI; use CGI ':all'; #use strict; +my @softfields=("От Олега Степанова"); use Time::Local; my $proxyredirect=1; use POSIX qw(locale_h); @@ -48,7 +49,7 @@ if ($^O =~ /win/i) { my $usehtml=$opt_z||0; $usehtml=1; -$usehtml=0 if $url=~/zaba/; +$usehtml=0 if $url=~/zaba/ || $url=~/localhost/; my $usewas=0; my $cashednumber=500; @@ -92,8 +93,8 @@ POSIX::setlocale( &POSIX::LC_ALL, $thisl if ((uc 'а') ne 'А') {print STDERR "Koi8-r locale not installed!\n"}; -my %fieldname= (0,'Question', 1, 'Answer', 2, 'Comments', 3, 'Authors', 4, 'Sources'); -my %rusfieldname=('Question','Вопрос', 'Answer', 'Ответ', +my %fieldname= (0,'Question', 1, 'Answer', 2, 'PassCriteria', 3, 'Comments', 4, 'Authors', 5, 'Sources'); +my %rusfieldname=('Question','Вопрос', 'Answer', 'Ответ', 'PassCriteria','Зачёт', 'Comments', 'Комментарии', 'Authors', 'Автор', 'Sources', 'Источник','old','Старый','rus','Новый', 'chgk', 'ЧГК', 'brain', 'Брейн-ринг','game', 'Своя игра', @@ -206,12 +207,12 @@ sub GetTournament { sub fetchquestion { my ($sth,$q,$WithTour)=@_; if ($WithTour) { - ($$q{'QuestionId'}, $$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},$$q{'Sources'}, + ($$q{'QuestionId'}, $$q{'Question'},$$q{'Answer'},$$q{'PassCriteria'},$$q{'Comments'},$$q{'Authors'},$$q{'Sources'}, $$q{'Number'}, $$q{'Title'}, $$q{'TourTitle'}, $$q{'FileName'},$$q{'PlayedAt'},$$q{'TourNumber'}) = $sth->fetchrow; } else { - ($$q{'QuestionId'}, $$q{'Question'},$$q{'Answer'},$$q{'Comments'},$$q{'Authors'},$$q{'Sources'}, + ($$q{'QuestionId'}, $$q{'Question'},$$q{'Answer'},$$q{'PassCriteria'},$$q{'Comments'},$$q{'Authors'},$$q{'Sources'}, $$q{'Number'})= $sth->fetchrow; } @@ -233,13 +234,13 @@ sub SelectQuestions { my $query; if ($WithTour) { - $query="SELECT QuestionId, Questions.Question, Answer, Comments, Authors, Sources, + $query="SELECT QuestionId, Questions.Question, Answer, PassCriteria, Comments, Authors, Sources, Questions.Number , t2.Title, t1.Title, t2.FileName, t2.PlayedAt,t1.Number from Questions,Tournaments as t1, Tournaments as t2 WHERE $where"; } else { - $query="SELECT QuestionId, Questions.Question, Answer, Comments, Authors, Sources, + $query="SELECT QuestionId, Questions.Question, Answer, PassCriteria, Comments, Authors, Sources, Questions.Number from Questions WHERE $where"; } @@ -357,11 +358,11 @@ sub printform my $sstr=param('sstr'); my @df=keys %searchin; my %checked; - $checked{lc $_}="" foreach ('Question','Answer','Comments','Authors','Sources','old','rus', + $checked{lc $_}="" foreach ('Question','Answer','PassCriteria','Comments','Authors','Sources','old','rus', 'chgk','brain','igp','game','ehruditka','beskrylka'); @df=('Question', 'Answer') unless @df; $checked{lc $_}="checked" foreach @df; - my $fields=checkbox_group('searchin',['Question','Answer','Comments','Authors','Sources'], [@df], + my $fields=checkbox_group('searchin',['Question','Answer','PassCriteria','Comments','Authors','Sources'], [@df], 'false',\%rusfieldname); @df=param('type'); @df=('chgk','brain','igp','game','ehruditka','beskrylka') unless @df; @@ -387,7 +388,7 @@ action="/znatoki/cgi-bin/db.cgi"> -
Вариант поиска: - + Простой (старый)  "Что? Где? Когда?" @@ -405,11 +406,11 @@ action="/znatoki/cgi-bin/db.cgi">  "Бескрылка"
Расширенный (с учетом грамматики, в вопросах всех типов) + Расширенный (с учетом грамматики, в вопросах всех типов)
Искать: - + Все слова Любое слово @@ -421,6 +422,8 @@ action="/znatoki/cgi-bin/db.cgi"> Ответ
+Зачёт
+
Комментарии
Автор
@@ -616,7 +619,12 @@ $sstr=~tr/йцукенгшщзхъфывапролджэячсмить #Ищем пересечение или объединение списков вопросов (значений %tasksof) foreach $sf (keys %tasksof) { - $count{$_}++ foreach keys %{$tasksof{$sf}}; + foreach (keys %{$tasksof{$sf}}) + { + next if $forbidden{$_}; + $count{$_}++ + } + } @tasks= ($all ? (grep {$count{$_}==$kvo} keys %count) : keys %count) ; @@ -704,13 +712,13 @@ sub Search { ###Simple and advanced query processing. Added by R7 if ($metod eq 'simple' || $metod eq 'advanced') { - foreach (qw/Question Answer Sources Authors Comments/) { + foreach (qw/Question Answer PassCriteria Sources Authors Comments/) { if (param($_)) { push @fields, $_; } } - @fields=(qw/Question Answer Sources Authors Comments/) unless scalar @fields; + @fields=(qw/Question Answer PassCriteria Sources Authors Comments/) unless scalar @fields; my $fields=join ",", @fields; my $q=new Text::Query($sstr, -parse => 'Text::Query::'. @@ -728,7 +736,6 @@ sub Search { ###### { -# foreach (qw/Question Answer Sources Authors Comments/) { foreach (param('searchin')) { # if (param($_)) { push @fields, "IFNULL($_, '')"; @@ -1312,6 +1319,11 @@ sub PrintField { if ($text) { $value =~ s/<[\/\w]*?>//sg; } else { + if ($header=~/Комментар/) + { + $value=~s/^\s*$_[\.:]/p."\n".strong("$_").":"/me foreach @softfields; + } + $value =~ s/^\s+/
    /mg; $value =~ s/(\s+)-+(\s+)/$1–$2/mg; $value =~ s/\s+\–/ \–/mg @@ -1324,7 +1336,10 @@ sub PrintField { # $value =~ s/"/”/mg; } - + if ($value=~/^\s*()?\s*"50%"}) if $answer>=0; if ($title) { - my $fname=$Question{'FileName'}; + $fname=$Question{'FileName'}; $fname=~s/\.txt//; $titles .= dd(img({src=>"/icons/folder.open.gif"}) . " " . @@ -1378,6 +1394,10 @@ sub PrintQuestion { if ($answer==1|| $answer==-1) { $output .= &PrintField("Ответ", $Question{'Answer'}, $text); + if ($Question{'PassCriteria'} ) { + $output .= + &PrintField("Зачёт", $Question{'PassCriteria'}, $text); + } if ($Question{'Authors'} ) { my $q=$Question{'Authors'}; @@ -1446,6 +1466,10 @@ EOTT if ($Question{'Authors'}) { $output .= &PrintField("Автор(ы)", $Question{'Authors'}, $text); } + if ($Question{'PassCriteria'}) { + $output .= &PrintField("Зачёт", $Question{'PassCriteria'}, $text); + } + if ($Question{'Sources'}) { $output .= &PrintField("Источник(и)", $Question{'Sources'}, $text); } @@ -1461,7 +1485,9 @@ $output.="" } $output=~s/\(pic: ([^\)]*)\)/

/g unless $text; $paramtour||=param("tour"); - my $qid=$paramtour ? ($paramtour.".$Question{'Number'}" ): ''; + $fname=$fname.".$Question{'TourNumber'}" if $fname && $Question{'TourNumber'}; +$fname||=param('tour'); + my $qid=$fname ? ($fname.".$Question{'Number'}" ): ''; $output.=br.a({href=> $url."?metod=proxy& qid=$qid"}, 'Близкие вопросы').p @@ -1688,7 +1714,7 @@ sub PrintQOfAuthor $suffix = 'я'; } $Output.= printform; - $Output.= p({align=>"center"}, "Автор ".strong("$name $surname. ") + $Output.= p({align=>"center"}, "Автор ".strong("$name $surname ") . " : $hits попадани$suffix."); @@ -1887,6 +1913,7 @@ sub WriteFile { { print OUT "Вопрос $q:\n".$Question{$tour}[$q]{'Question'}."\n\n"; print OUT "Ответ:\n".$Question{$tour}[$q]{'Answer'}."\n\n"; + print OUT "Зачёт:\n".$Question{$tour}[$q]{'PassCriteria'}."\n\n"; print OUT "Автор:\n".$Question{$tour}[$q]{'Authors'}."\n\n" if !$tourauthor && !$eqauthor && $Question{$tour}[$q]{'Authors'}; print OUT "Комментарий:\n".$Question{$tour}[$q]{'Comments'}."\n\n" @@ -2097,6 +2124,7 @@ th {font-size: x-small; font-family : sa } + if (param('rand')) { my ($type, $qnum) = ('', 12); $type.=$TypeName{$_} foreach param('type');