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 { |
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 { |
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"; |
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 { |
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 { |
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"; |
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 |
|
|