Add tests for nextSectionid, nextSection, currentSection.
Add more POD to ResponseJSON
This commit is contained in:
parent
c60393e44a
commit
98294e4e78
2 changed files with 108 additions and 4 deletions
|
|
@ -217,21 +217,57 @@ sub startTime {
|
|||
}
|
||||
|
||||
#array of addresses in which the survey should be presented
|
||||
|
||||
=head2 surveyOrder
|
||||
|
||||
Accessor for the survey order data structure. It is a deep set of arrays, similar in
|
||||
structure to a WebGUI::Asset::Wobject::Survey::SurveyJSON address.
|
||||
|
||||
[ $sectionIndex, $questionIndex, [ $answerIndex1, $answerIndex2, ....]
|
||||
|
||||
There is one array element for every section and address in the survey.
|
||||
|
||||
If there are no questions, or no addresses, those array elements will not be present.
|
||||
|
||||
=cut
|
||||
|
||||
sub surveyOrder {
|
||||
my $self = shift;
|
||||
return $self->{surveyOrder};
|
||||
}
|
||||
|
||||
=head2 nextSectionId
|
||||
|
||||
Relative to the surveyOrder and the lastResponse index, get the index of the
|
||||
next section. Note, based on the number of questions in an section, this can
|
||||
be the same as the current section index.
|
||||
|
||||
=cut
|
||||
|
||||
sub nextSectionId {
|
||||
my $self = shift;
|
||||
return $self->surveyOrder->[ $self->lastResponse + 1 ]->[0];
|
||||
}
|
||||
|
||||
=head2 nextSection
|
||||
|
||||
Relative to the surveyOrder and the lastResponse index, gets the next section.
|
||||
Note, based on the number of questions in a section, this can be the same as
|
||||
the current section.
|
||||
|
||||
=cut
|
||||
|
||||
sub nextSection {
|
||||
my $self = shift;
|
||||
return $self->survey->section( [ $self->surveyOrder->[ $self->lastResponse + 1 ]->[0] ] );
|
||||
}
|
||||
|
||||
=head2 currentSection
|
||||
|
||||
Relative to the surveyOrder and the lastResponse index, get the current section.
|
||||
|
||||
=cut
|
||||
|
||||
sub currentSection {
|
||||
my $self = shift;
|
||||
return $self->survey->section( [ $self->surveyOrder->[ $self->lastResponse ]->[0] ] );
|
||||
|
|
@ -363,9 +399,7 @@ sub getPreviousAnswer {
|
|||
sub nextQuestions {
|
||||
my $self = shift;
|
||||
|
||||
if ( $self->lastResponse >= $#{ $self->surveyOrder } ) {
|
||||
return [];
|
||||
}
|
||||
return [] if $self->surveyEnd;
|
||||
|
||||
my $nextSectionId = $self->nextSectionId;
|
||||
|
||||
|
|
@ -400,6 +434,13 @@ sub nextQuestions {
|
|||
return $questions;
|
||||
} ## end sub nextQuestions
|
||||
|
||||
=head2 surveyEnd
|
||||
|
||||
Returns true if the current index stored in lastResponse is greater than or
|
||||
equal to the number of sections in the survey order.
|
||||
|
||||
=cut
|
||||
|
||||
sub surveyEnd {
|
||||
my $self = shift;
|
||||
return 1 if ( $self->lastResponse >= $#{ $self->surveyOrder } );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue