/[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.9 by dpavlin, Wed Sep 24 20:35:48 2003 UTC revision 1.13 by dpavlin, Tue Oct 21 15:15:08 2003 UTC
# Line 59  my $db_user="dpavlin"; Line 59  my $db_user="dpavlin";
59  # polls to be conducted by just publishing URL to them.  # polls to be conducted by just publishing URL to them.
60  my $without_invitation=0;  my $without_invitation=0;
61    
62    # This will remove numbers before answers. That enables you to have
63    # answers written like:
64    # 1.1 red
65    # 1.2 black
66    # and users will see just "red" and "black"
67    my $remove_nrs_in_answers=0;
68    
69  #------------------------------------------------------------------  #------------------------------------------------------------------
70    
71  sub suck_file {  sub suck_file {
# Line 597  sub dropdown { Line 604  sub dropdown {
604    
605          my @dropdown_data;          my @dropdown_data;
606    
607            my $default_value = x($attref->{default_value}) || 'null';
608            my $default_text = x($attref->{default_text}) || '-';
609    
610          $$ncref = sub {          $$ncref = sub {
611                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
612    
613                  if (defined $text) {                  if (defined $text) {
614                          chomp $text;                          chomp $text;
615                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
616                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers);
617                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
618                          push @dropdown_data,x($text) if ($text ne "");                          push @dropdown_data,x($text) if ($text ne "");
619                  } else {                  } else {
# Line 611  sub dropdown { Line 621  sub dropdown {
621                          my $id=1;                          my $id=1;
622                          my $p=new_pit();                          my $p=new_pit();
623                          $body.="<select name=$p >\n";                          $body.="<select name=$p >\n";
624                          $body.="<option value=null>-</option>\n";                          $body.="<option value=\"$default_value\">$default_text</option>\n";
625                          foreach $opt (@dropdown_data) {                          foreach $opt (@dropdown_data) {
626                                  if (defined($opt) && $opt ne "") {                                  if (defined($opt) && $opt ne "") {
627                                          $body.="<option value=$id>$opt</option>\n";                                          $body.="<option value=$id>$opt</option>\n";
# Line 671  sub radiobuttons { Line 681  sub radiobuttons {
681                  if (defined $text) {                  if (defined $text) {
682                          chomp $text;                          chomp $text;
683                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
684                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers);
685                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
686                          push @radiobuttons_data,x($text) if ($text ne "");                          push @radiobuttons_data,x($text) if ($text ne "");
687                  } else {                  } else {
# Line 716  sub checkboxes { Line 726  sub checkboxes {
726                  if (defined $text) {                  if (defined $text) {
727                          chomp $text;                          chomp $text;
728                          $text=~s/^\s*//g;                          $text=~s/^\s*//g;
729                          $text=~s/^[\d\.\s]+//g;                          $text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers);
730                          $text=~s/\s*$//g;                          $text=~s/\s*$//g;
731                          push @checkboxes_data,x($text) if ($text ne "");                          push @checkboxes_data,x($text) if ($text ne "");
732                  } else {                  } else {
# Line 754  sub checkboxes { Line 764  sub checkboxes {
764          }          }
765  }  }
766    
767    sub html {
768            package main;
769    
770            my ($xp, $el, $attref, $ncref) = @_;
771    
772            $body.="<p>";
773    
774            $$ncref = sub {
775                    my ($xp, $text) = @_;
776    
777                    if (defined $text) {
778                            $body.=x($text);
779                    } else {
780                            $body.="</p>";
781                    }
782            }
783    }
784    
785  print "\n\nTo create database for poll $poll use:\n\n";  print "\n\nTo create database for poll $poll use:\n\n";
786  print "\$ psql template1 < $poll/$poll.sql\n\n";  print "\$ psql template1 < $poll/$poll.sql\n\n";
787  print "THIS WILL DISTROY ALL DATA IN EXISTING DATABASE ".$prefix.$poll." !!\n";  print "THIS WILL DISTROY ALL DATA IN EXISTING DATABASE ".$prefix.$poll." !!\n";
# Line 769  sub config { Line 797  sub config {
797                  my ($xp, $text) = @_;                  my ($xp, $text) = @_;
798                  $db_user=x($attref->{db_user});                  $db_user=x($attref->{db_user});
799                  $prefix=x($attref->{prefix});                  $prefix=x($attref->{prefix});
800                  $without_invitation=x($attref->{without_invitation});                  $without_invitation=x($attref->{without_invitation}) &&
801                            print "Pool is without need for unique ID (and invitation URLs).\n";
802                    $remove_nrs_in_answers=x($attref->{$remove_nrs_in_answers}) &&
803                            print "Numbers before answers will be removed.\n";
804          }          }
805  }  }
806    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.26