/[wopi]/make_poll.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /make_poll.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by dpavlin, Thu Oct 23 22:13:30 2003 UTC revision 1.17 by dpavlin, Sat Nov 8 01:08:44 2003 UTC
# Line 23  my @Modes = qw(object pass skip); Line 23  my @Modes = qw(object pass skip);
23  my $poll;  my $poll;
24  my $dowarn = 1;  my $dowarn = 1;
25    
26  my $question_nr = 0;            # curr. question  my $q_type = "q";               # q=question, u=unnumbered question
27    my %question_nr;                # curr. question numbers
28  my $question_tag = "";          # originalni oblik broja questions  my $question_tag = "";          # originalni oblik broja questions
29  my $page_nr = 1;                # prvo question na strani  my $page_nr = 1;                # prvo question na strani
30    
# Line 101  my %html = ( Line 102  my %html = (
102    
103  );  );
104    
105    # name of database colums
106    # for questions
107    my $q_db_col = "q";
108    # for unnumbered questions
109    my $u_db_col = "u";
110    
111    
112  #------------------------------------------------------------------  #------------------------------------------------------------------
113    
114  sub suck_file {  sub suck_file {
# Line 281  rename "$poll/01.php","$poll/index.php" Line 289  rename "$poll/01.php","$poll/index.php"
289    
290  # return unique name of question  # return unique name of question
291  sub new_que {  sub new_que {
292          my $out="p".$question_nr;          my $out=$q_type.( $question_nr{$q_type} || 0 );
293          $out .= "_".$p_suffix if ($p_suffix);          $out .= "_".$p_suffix if ($p_suffix);
294          $curr_suffix=$p_suffix;          $curr_suffix=$p_suffix;
295          $p_suffix++;          $p_suffix++;
# Line 290  sub new_que { Line 298  sub new_que {
298    
299  # current question  # current question
300  sub curr_que {  sub curr_que {
301          return "p".$question_nr.$curr_suffix;          return $q_type.( $question_nr{$q_type} || 0 ).$curr_suffix;
302  }  }
303    
304  #----------------------------------------------------------  #----------------------------------------------------------
# Line 524  sub nr { Line 532  sub nr {
532                          chomp $text;                          chomp $text;
533                          $question_tag .= x($text);                          $question_tag .= x($text);
534                  } else {                  } else {
535                          $question_nr = $question_tag;                          $question_nr{$q_type} = $question_tag;
536                          $question_nr =~ s/[^0-9a-zA-Z]//g;                          $question_nr{$q_type} =~ s/[^0-9a-zA-Z]//g;
537                          print "$question_nr ";                          print "$question_nr{$q_type} ";
538                  }                  }
539                  $p_suffix="";                  $p_suffix="";
540          };          };
# Line 542  sub que { Line 550  sub que {
550    
551          my ($xp, $el, $attref, $ncref) = @_;          my ($xp, $el, $attref, $ncref) = @_;
552    
553            my $nonum = x($attref->{unnumbered});
554            if ($nonum) {
555                    $q_type = $u_db_col;    # unnumbered questions
556            } else {
557                    $q_type = $q_db_col;
558            }
559    
560            $question_nr{$q_type}++;
561    
562          $body.=$html{'que_before'} if ($html{'que_before'});          $body.=$html{'que_before'} if ($html{'que_before'});
563    
564          $$ncref = sub {          $$ncref = sub {
# Line 674  sub radiobuttons_tab { Line 691  sub radiobuttons_tab {
691          $$ncref = sub {          $$ncref = sub {
692                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
693                  if (! defined $text) {                  if (! defined $text) {
694                          my $nr=$attref->{nr};                          my $nr=$attref->{nr} || die "need <radiobuttons_tab nr=\"999\"> for number of buttons";
695                            # shownumbers="before|after"
696                            my $shownumbers=lc(x($attref->{shownumbers})) || 'no';
697                          my $p=new_que();                          my $p=new_que();
698                          for (my $i=1; $i<=$nr; $i++) {                          for (my $i=1; $i<=$nr; $i++) {
699                                  $body.="<td><input type=radio name=$p value=$i></td> ";                                  $body.="<td>";
700                                    $body.=$i if ($shownumbers eq "before");
701                                    $body.="<input type=radio name=$p value=$i>";
702                                    $body.=$i if ($shownumbers eq "after");
703                                    $body.="</td> ";
704                          }                          }
705                          push @sql_create,"$p int4";                          push @sql_create,"$p int4";
706                          push @sql_update,"$p=\$$p";                          push @sql_update,"$p=\$$p";
# Line 863  sub config { Line 886  sub config {
886                                  $html{$file} = suck_file($include_files{$file});                                  $html{$file} = suck_file($include_files{$file});
887                          }                          }
888                  }                  }
889                    $q_db_col=x($attref->{q_db_col}) || 'q';
890                    $u_db_col=x($attref->{u_db_col}) || 'u';
891    
892          }          }
893  }  }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.26