Fixed SurveyJSON->questions which was short-changing getGotoTargets

This commit is contained in:
Patrick Donelan 2009-04-02 05:55:23 +00:00
parent 57dae409c7
commit c1ac5b9761
2 changed files with 34 additions and 5 deletions

View file

@ -1339,9 +1339,9 @@ sub session {
Returns a reference to all the questions from a particular section.
=head3 $address
=head3 $address (optional)
See L<"Address Parameter">.
See L<"Address Parameter">. If not defined, returns all questions.
=cut
@ -1349,7 +1349,13 @@ sub questions {
my $self = shift;
my ($address) = validate_pos(@_, { type => ARRAYREF, optional => 1});
return $self->sections->[ $address->[0] ]->{questions};
if ($address) {
return $self->sections->[ $address->[0] ]->{questions};
} else {
my $questions;
push @$questions, @{$_->{questions} || []} for @{$self->sections};
return $questions;
}
}
=head2 question ($address)