--- db/prgsrc/db.cgi 2004/01/10 22:52:20 1.128 +++ db/prgsrc/db.cgi 2004/02/08 00:35:29 1.129 @@ -974,9 +974,11 @@ sub PrintRandom { my %q; my $answer=$razd?0:1; my @answers; +#my $t=time; my (@Questions) = &Get12Random($dbh, $type, $num); - my ($output, $i) = ('', 0); + my ($output, $i) = ('', 0); +#$output.="time=".(time-$t).p; if ($text) { $output .= " $num случайных вопросов.\n\n"; } else { @@ -1479,7 +1481,8 @@ sub Get12Random { srand; my $where=0; my $r=int (rand(10000)); - + my $w1=$r<5000? "QuestionId<5000 ":"QuestionId>=5000"; + $w1=1 if $type!~/Ч/; foreach (split '', $type) { $where.= " OR (Type ='$_') OR (Type ='$_Д') "; @@ -1489,7 +1492,7 @@ sub Get12Random { # $q="select QuestionId, QuestionId/$r-floor(QuestionId/$r) as val # from Questions where $where order by val limit $num"; # Когда на куличках появится mysql >=3.23 надо заменить на order by rand(); - $q="select QuestionId from Questions where $where order by rand() limit $num"; + $q="select QuestionId from Questions where ($w1) AND ($where) order by rand() limit $num"; $sth=$dbh->prepare($q);