Diff for /db/prgsrc/db.cgi between versions 1.63 and 1.69

version 1.63, 2002/05/04 03:35:36 version 1.69, 2002/06/15 02:20:23
Line 110  sub GetTourQuestions { Line 110  sub GetTourQuestions {
         my (@arr, @Questions);          my (@arr, @Questions);
   
         my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions          my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions
                 WHERE ParentId=$ParentId");                  WHERE ParentId=$ParentId order by Number");
   
         $sth->execute;          $sth->execute;
   
Line 645  sub PrintList { Line 645  sub PrintList {
   
         print "$nav".br."\n";          print "$nav".br."\n";
         for (my $i = $first; $i <= $last; $i++) {          for (my $i = $first; $i <= $last; $i++) {
                 my $output = &PrintQuestion($dbh, $$Questions[$i-1], 1, $i, 1);                  my $output = &PrintQuestion($dbh, $$Questions[$i-1], 1, 0, 1);
                 if (param('metod') eq 'rus' || param('metod') eq 'proxy')                  if (param('metod') eq 'rus' || param('metod') eq 'proxy')
                 {                  {
                      $output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi;                       $output=~s/\b($shablon)\b/\<strong\>$1\<\/strong\>/gi;
Line 821  sub PrintTournament { Line 821  sub PrintTournament {
                 }                  }
         } else {          } else {
                 my ($qnum) = GetQNum($dbh);                  my ($qnum) = GetQNum($dbh);
                 $output .= h2("Банк Вопросов: $qnum вопросов") . p . "\n";                  $output .= h2("Банк Вопросов: $qnum вопрос".&Suffix($qnum)) 
                             . p . "\n";
         }          }
   
         for ($i = 0; $i <= $#Tours; $i++) {          for ($i = 0; $i <= $#Tours; $i++) {
Line 1026  sub PrintQuestion { Line 1027  sub PrintQuestion {
         my ($dbh, $Id, $answer, $qnum, $title, $text) = @_;          my ($dbh, $Id, $answer, $qnum, $title, $text) = @_;
         my ($output, $titles) = ('', '');          my ($output, $titles) = ('', '');
         my (%Question) = &GetQuestion($dbh, $Id);          my (%Question) = &GetQuestion($dbh, $Id);
           $qnum = $Question{'Number'}
                   if ($qnum == 0);
         if (!$text) {          if (!$text) {
                 $output .= hr({width=>"50%"});                  $output .= hr({width=>"50%"});
                 if ($title) {                  if ($title) {
Line 1038  sub PrintQuestion { Line 1041  sub PrintQuestion {
                                          a({href=>url . "?tour=$fname"}, $Tournament{'Title'}, $Tournament{'PlayedAt'}));                                           a({href=>url . "?tour=$fname"}, $Tournament{'Title'}, $Tournament{'PlayedAt'}));
                         $titles .=                          $titles .=
                                 dl(dd(img({src=>"/icons/folder.open.gif"}) . " " .                                  dl(dd(img({src=>"/icons/folder.open.gif"}) . " " .
                                         a({href=>url . "?tour=$fname.$Tour{Number}"}, $Tour{'Title'})));                                          a({href=>url . "?tour=$fname.$Tour{Number}#$qnum"}, $Tour{'Title'})));
                 }                  }
                 $output .= dl(strong($titles));                  $output .= dl(strong($titles));
         }          }
   
         $qnum = $Question{'Number'}  
                 if ($qnum == 0);          $output.= "<a NAME=\"$qnum\">";
   
         $output .=          $output .=
                 &PrintField("Вопрос $qnum", $Question{'Question'}, $text);                  &PrintField("Вопрос $qnum", $Question{'Question'}, $text);
   
         if ($answer) {          if ($answer==1) {
                 $output .=                  $output .=
                         &PrintField("Ответ", $Question{'Answer'}, $text);                          &PrintField("Ответ", $Question{'Answer'}, $text);
   
Line 1095  sub PrintQuestion { Line 1098  sub PrintQuestion {
                         $output .= &PrintField("Комментарии", $Question{'Comments'}, $text);                          $output .= &PrintField("Комментарии", $Question{'Comments'}, $text);
                 }                  }
         }          }
           elsif ($answer==2) {
             my $text=$Question{'Answer'};
             $text=~s/\n/<option>/mg;
             $output.="<select><option selected>Ответ:<option>$text</select>";
             $text=$Question{'Comments'}||'';
             if ($text) {
                $text=~s/\n/<option>/mg;
                $output.="<select><option selected>Комментарий:<option>$text</select>"
             }
           } 
           elsif ($answer==3) {
           $output.=  <<EOTT
             <div align=right STYLE="cursor:hand;" OnStart="toggle(document.all.HideShow$qnum);" OnClick="toggle(document.all.HideShow$qnum);">
             <font size=-2 color=red> Показать/убрать ответ</font></div>
             <span style="display:none" id=HideShow$qnum>
   EOTT
             .&PrintField("Ответ", $Question{'Answer'}, $text);
                   if ($Question{'Authors'}) {
                           $output .= &PrintField("Автор(ы)", $Question{'Authors'}, $text);
                   }
                   if ($Question{'Sources'}) {
                           $output .= &PrintField("Источник(и)", $Question{'Sources'}, $text);
                   }
   
                   if ($Question{'Comments'}) {
                           $output .= &PrintField("Комментарии", $Question{'Comments'}, $text);
                   }
   
   
   $output.="</span>"
   
           }
 #       $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p  #       $output.=br.a({href=> url."?metod=proxy&qid=$Id"}, 'Близкие вопросы').p
 #             if $answer;  #             if $answer;
         return $output;          return $output;
Line 1651  $sstr=~s/[^йцукенгшщзхъфывапролджэячсмит Line 1686  $sstr=~s/[^йцукенгшщзхъфывапролджэячсмит
                     $tour = ($sth->fetchrow)[0];                      $tour = ($sth->fetchrow)[0];
                     $sth->finish;                      $sth->finish;
                 }                  }
                 print &PrintTournament($dbh, $tour, param('answer'));                  my $QuestionNumber=0;
                   my $qnum;
                   if ($qnum=param('qnumber')){
                     my ($sth) = $dbh->prepare("SELECT QuestionId FROM Questions
                        WHERE ParentId=$tour AND Number=$qnum");
                     $sth->execute;
                     $QuestionNumber=($sth->fetchrow)[0]||0;
                   }
                   if ($QuestionNumber) {
                     print &PrintQuestion($dbh, $QuestionNumber, param('answer')||0, $qnum, 1);
   #                                        $dbh, $Id, $answer, $qnum, $title, $text
                   } else  {
                      print &PrintTournament($dbh, $tour, param('answer'));
                   }
         }          }
         if (!$text) {          if (!$text) {
                 print &Include_virtual("../dimrub/db/footer.html");                  print &Include_virtual("../dimrub/db/footer.html");
   print <<EEE
     <SCRIPT LANGUAGE="JavaScript">
   function toggle(e) {
     if (e.style.display == "none") {
        e.style.display="";
     } else {
        e.style.display = "none";
    }
   }
   </SCRIPT>
   EEE
   ;
                 print end_html;                  print end_html;
         }          }
         $dbh->disconnect;          $dbh->disconnect;

Removed from v.1.63  
changed lines
  Added in v.1.69


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>