1 |
296 |
ahitrov |
<%args> |
2 |
|
|
|
3 |
|
|
$name => undef |
4 |
|
|
$SETS => undef |
5 |
|
|
|
6 |
|
|
</%args> |
7 |
|
|
<%init> |
8 |
|
|
|
9 |
|
|
return undef if (! ref($SETS)); |
10 |
|
|
return undef if (! $name); |
11 |
|
|
|
12 |
|
|
my $FIELDS = {}; |
13 |
|
|
while (my ($element,$value)=each %{$SETS}) { |
14 |
|
|
if ($element =~ /^${name}_question_amount$/) { |
15 |
|
|
$FIELDS->{question_amount}=$value; |
16 |
|
|
} elsif ($element =~ /^${name}_question(\d+)_right$/) { |
17 |
|
|
$FIELDS->{questions}->[$1]->{right}=$value; |
18 |
|
|
} elsif ($element =~ /^${name}_total$/) { |
19 |
|
|
$FIELDS->{total}=$value; |
20 |
|
|
} elsif ($element =~ /^${name}_question(\d+)_(question|amount|range|scale_answer)$/) { |
21 |
|
|
$FIELDS->{questions}->[$1]->{$2}=$value; |
22 |
|
|
} elsif ($element =~ /^${name}_question(\d+)_allow_multi$/) { |
23 |
|
|
$FIELDS->{questions}->[$1]->{allow_multi}=$value; |
24 |
|
|
} elsif ($element =~ /^${name}_question(\d+)_answer(\d+)_choice$/) { |
25 |
|
|
$FIELDS->{questions}->[$1]->{choices}->[$2]->{choice}=$value; |
26 |
|
|
} elsif ($element =~ /^${name}_question(\d+)_answer(\d+)_votes$/) { |
27 |
|
|
$FIELDS->{questions}->[$1]->{choices}->[$2]->{votes}=$value; |
28 |
|
|
} elsif ($element =~ /^${name}_question(\d+)_answer(\d+)_random$/) { |
29 |
|
|
$FIELDS->{questions}->[$1]->{choices}->[$2]->{random}=$value; |
30 |
|
|
} elsif ($element =~ /^${name}_freefields_amount$/) { |
31 |
|
|
$FIELDS->{freefields_amount}=$value; |
32 |
|
|
} elsif ($element =~ /^${name}_freefield(\d+)$/) { |
33 |
|
|
$FIELDS->{freefields}->[$1]=$value; |
34 |
|
|
} |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
|
38 |
|
|
{ |
39 |
|
|
local $Data::Dumper::Indent = 0; |
40 |
|
|
return Data::Dumper::Dumper($FIELDS); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
</%init> |