--- db/prgsrc/db.cgi 2002/11/26 05:34:39 1.79 +++ db/prgsrc/db.cgi 2002/12/19 23:55:55 1.80 @@ -779,6 +779,8 @@ print "$query" if $printqueries; sub PrintRandom { my ($dbh, $type, $num, $text) = @_; + my $razd=param('razd'); + my $answer=$razd?0:1; my (@Questions) = &Get12Random($dbh, $type, $num); my ($output, $i) = ('', 0); @@ -793,8 +795,17 @@ sub PrintRandom { # Passing DB handler, question ID, print answer, question # number, print title, print text/html $output .= - &PrintQuestion($dbh, $Questions[$i], 1, $i + 1, 0, $text); + &PrintQuestion($dbh, $Questions[$i], $answer, $i + 1, 0, $text); } + unless ($answer ) + { + $output.=$text?"\n".('-'x 20)."\nОтветы\n~~~~~~\n\n":h2('Ответы'); + for ($i = 0; $i <= $#Questions; $i++) { + $output .= + &PrintQuestion($dbh, $Questions[$i], -1, $i + 1, 0, $text); + } + } + return $output; } @@ -1062,12 +1073,12 @@ sub PrintQuestion { $qnum = $Question{'Number'} if ($qnum == 0); if (!$text) { - $output .= hr({width=>"50%"}); + $output .= hr({width=>"50%"}) if $answer>=0; if ($title) { my (%Tour) = GetTournament($dbh, $Question{'ParentId'}); my (%Tournament) = GetTournament($dbh, $Tour{'ParentId'}); my $fname=$Tournament{'FileName'}; -return "" if $fname=~/mgp0203/; +#return "" if $fname=~/mgp0203/; $fname=~s/\.txt//; $titles .= dd(img({src=>"/icons/folder.open.gif"}) . " " . @@ -1082,10 +1093,10 @@ return "" if $fname=~/mgp0203/; $output.= "" unless $text; - $output .= - &PrintField("Вопрос $qnum", $Question{'Question'}, $text); - - if ($answer==1) { + if ($answer>=0) {$output .= + &PrintField("Вопрос $qnum", $Question{'Question'}, $text);} + else {$output .="$qnum. "} + if ($answer==1|| $answer==-1) { $output .= &PrintField("Ответ", $Question{'Answer'}, $text); @@ -1163,7 +1174,7 @@ $output.="" } $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p - if $answer && !$text; + if $answer>0 && !$text; return $output; }