--- db/prgsrc/db.cgi 2002/11/10 16:10:53 1.78
+++ db/prgsrc/db.cgi 2003/01/12 11:17:23 1.83
@@ -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;
}
@@ -1041,6 +1052,8 @@ sub PrintField {
$value =~ s/^\s+/
/mg;
$value =~ s/^\|([^\n]*)/
$1<\/pre>/mg; $value =~ s/\s+-+\s+/ /mg; + $value =~ s/(http:\/\/\S+[^\s\)\(\,\.])/$1<\/a>/g if $header !~ /^Авто/; +# $value =~ s/(http:\/\/(?:\w+.)+[\w\\\~]+(\?[^\s.]+)?)/$1<\/a>/g if $header !~ /^Авто/; # $value =~ s/(\s)"/$1/mg; # $value =~ s/^"//mg; # $value =~ s/"//mg; @@ -1060,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"}) . " " . @@ -1078,23 +1091,23 @@ return "" if $fname=~/mgp0203/; } - $output.= ""; - - $output .= - &PrintField("Вопрос $qnum", $Question{'Question'}, $text); + $output.= "" unless $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); - if ($Question{'Authors'}) { + if ($Question{'Authors'} ) { my $q=$Question{'Authors'}; ###АВТОРА!! my $sth=$dbh->prepare("select Authors.Id,Name, Surname, Nicks from Authors, A2Q where Authors.Id=Author And Question=$Id"); $sth->execute; my ($AuthorId,$Name, $Surname,$other,$Nicks); - + if (!$text) { while ((($AuthorId,$Name, $Surname,$Nicks)=$sth->fetchrow),$AuthorId) { my ($firstletter)=$Name=~m/^./g; @@ -1115,7 +1128,7 @@ return "" if $fname=~/mgp0203/; } $q=~s/($sha)/a({href=>url."?qofauthor=$AuthorId"},$1)/ei; } - + } $output .= &PrintField("Автор(ы)", $q, $text); } @@ -1157,11 +1170,13 @@ EOTT } + $output.="" } + $output=~s/\(pic: ([^\)]*)\)//g unless $text; $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p - if $answer; + if $answer>0 && !$text; return $output; }