53 |
# this is usename in database |
# this is usename in database |
54 |
my $db_user="dpavlin"; |
my $db_user="dpavlin"; |
55 |
|
|
56 |
|
# This option allows users to fill poll without using invitation URL. |
57 |
|
# That also means it's unpossible for them to return to exiting poll |
58 |
|
# because they don't have thair own unique ID. Howver, it enables simple |
59 |
|
# polls to be conducted by just publishing URL to them. |
60 |
|
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 { |
207 |
# dump sql structure |
# dump sql structure |
208 |
|
|
209 |
open(SQL,">$poll/$poll.sql") || die "$poll.sql: $!"; |
open(SQL,">$poll/$poll.sql") || die "$poll.sql: $!"; |
210 |
|
print SQL "drop database ".$prefix.$poll.";\n"; |
211 |
|
print SQL "create database ".$prefix.$poll.";\n"; |
212 |
|
print SQL "\\connect ".$prefix.$poll.";\n"; |
213 |
print SQL "create table poslani ( member_id int4 not null, unesen timestamp default now() );\n"; |
print SQL "create table poslani ( member_id int4 not null, unesen timestamp default now() );\n"; |
214 |
print SQL "create table $poll (do_stranice text default null, ",join(",\n",@sql_create),");\n"; |
print SQL "create table $poll (do_stranice text default null, ",join(",\n",@sql_create),");\n"; |
215 |
close(SQL); |
close(SQL); |
225 |
$common_php =~ s/##PREFIX##/$prefix/g; |
$common_php =~ s/##PREFIX##/$prefix/g; |
226 |
my $members_db = $prefix."members"; |
my $members_db = $prefix."members"; |
227 |
$common_php =~ s/##MEMBERS_DB##/$members_db/g; |
$common_php =~ s/##MEMBERS_DB##/$members_db/g; |
228 |
|
$common_php =~ s/##WITHOUT_INVITATION##/$without_invitation/g; |
229 |
|
|
230 |
print PHP $common_php; |
print PHP $common_php; |
231 |
close(PHP); |
close(PHP); |
246 |
|
|
247 |
# return unique name of pitanje |
# return unique name of pitanje |
248 |
sub new_pit { |
sub new_pit { |
249 |
my $out="p".$pitanje_nr.$p_suffix; |
my $out="p".$pitanje_nr; |
250 |
|
$out .= "_".$p_suffix if ($p_suffix); |
251 |
$curr_suffix=$p_suffix; |
$curr_suffix=$p_suffix; |
252 |
$p_suffix++; |
$p_suffix++; |
253 |
return $out; |
return $out; |
610 |
if (defined $text) { |
if (defined $text) { |
611 |
chomp $text; |
chomp $text; |
612 |
$text=~s/^\s*//g; |
$text=~s/^\s*//g; |
613 |
$text=~s/^[\d\.\s]+//g; |
$text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers); |
614 |
$text=~s/\s*$//g; |
$text=~s/\s*$//g; |
615 |
push @dropdown_data,x($text) if ($text ne ""); |
push @dropdown_data,x($text) if ($text ne ""); |
616 |
} else { |
} else { |
678 |
if (defined $text) { |
if (defined $text) { |
679 |
chomp $text; |
chomp $text; |
680 |
$text=~s/^\s*//g; |
$text=~s/^\s*//g; |
681 |
$text=~s/^[\d\.\s]+//g; |
$text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers); |
682 |
$text=~s/\s*$//g; |
$text=~s/\s*$//g; |
683 |
push @radiobuttons_data,x($text) if ($text ne ""); |
push @radiobuttons_data,x($text) if ($text ne ""); |
684 |
} else { |
} else { |
723 |
if (defined $text) { |
if (defined $text) { |
724 |
chomp $text; |
chomp $text; |
725 |
$text=~s/^\s*//g; |
$text=~s/^\s*//g; |
726 |
$text=~s/^[\d\.\s]+//g; |
$text=~s/^[\d\.\s]+//g if ($remove_nrs_in_answers); |
727 |
$text=~s/\s*$//g; |
$text=~s/\s*$//g; |
728 |
push @checkboxes_data,x($text) if ($text ne ""); |
push @checkboxes_data,x($text) if ($text ne ""); |
729 |
} else { |
} else { |
761 |
} |
} |
762 |
} |
} |
763 |
|
|
764 |
|
print "\n\nTo create database for poll $poll use:\n\n"; |
765 |
|
print "\$ psql template1 < $poll/$poll.sql\n\n"; |
766 |
|
print "THIS WILL DISTROY ALL DATA IN EXISTING DATABASE ".$prefix.$poll." !!\n"; |
767 |
|
|
768 |
# read configuration data |
# read configuration data |
769 |
# |
# |
770 |
# FIX: write actually this :-) |
# FIX: write actually this :-) |
776 |
my ($xp, $text) = @_; |
my ($xp, $text) = @_; |
777 |
$db_user=x($attref->{db_user}); |
$db_user=x($attref->{db_user}); |
778 |
$prefix=x($attref->{prefix}); |
$prefix=x($attref->{prefix}); |
779 |
|
$without_invitation=x($attref->{without_invitation}) && |
780 |
|
print "Pool is without need for unique ID (and invitation URLs).\n"; |
781 |
|
$remove_nrs_in_answers=x($attref->{$remove_nrs_in_answers}) && |
782 |
|
print "Numbers before answers will be removed.\n"; |
783 |
} |
} |
784 |
} |
} |
785 |
|
|