Revision 296 (by ahitrov, 2013/03/26 17:59:01) Promosite (anthill) project source
<%args>

	$name => undef
	$SETS => undef

</%args>
<%init>

	return 	undef	if (! ref($SETS));
	return 	undef	if (! $name);

	my $FIELDS = {};
	while (my ($element,$value)=each %{$SETS}) {
		if ($element =~ /^${name}_question_amount$/) {
			$FIELDS->{question_amount}=$value;
		} elsif ($element =~ /^${name}_question(\d+)_right$/) {
			$FIELDS->{questions}->[$1]->{right}=$value;
		} elsif ($element =~ /^${name}_total$/) {
			$FIELDS->{total}=$value;
		} elsif ($element =~ /^${name}_question(\d+)_(question|amount|range|scale_answer)$/) {
			$FIELDS->{questions}->[$1]->{$2}=$value;
		} elsif ($element =~ /^${name}_question(\d+)_allow_multi$/) {
			$FIELDS->{questions}->[$1]->{allow_multi}=$value;
                } elsif ($element =~ /^${name}_question(\d+)_answer(\d+)_choice$/) {
			$FIELDS->{questions}->[$1]->{choices}->[$2]->{choice}=$value;
                } elsif ($element =~ /^${name}_question(\d+)_answer(\d+)_votes$/) {
			$FIELDS->{questions}->[$1]->{choices}->[$2]->{votes}=$value;
                } elsif ($element =~ /^${name}_question(\d+)_answer(\d+)_random$/) {
			$FIELDS->{questions}->[$1]->{choices}->[$2]->{random}=$value;
                } elsif ($element =~ /^${name}_freefields_amount$/) {
			$FIELDS->{freefields_amount}=$value;
		} elsif ($element =~ /^${name}_freefield(\d+)$/) {
			$FIELDS->{freefields}->[$1]=$value;
		}
	}
	

	{
		local $Data::Dumper::Indent = 0;
		return Data::Dumper::Dumper($FIELDS);
	}

</%init>