Improved createSurveyOrder documentation, and made perlcritic happy
This commit is contained in:
parent
6fb325699f
commit
477f014177
1 changed files with 12 additions and 11 deletions
|
|
@ -64,14 +64,14 @@ sub new {
|
||||||
_survey => $survey,
|
_survey => $survey,
|
||||||
_session => $survey->session,
|
_session => $survey->session,
|
||||||
_response => {
|
_response => {
|
||||||
|
|
||||||
# Response hash defaults..
|
# Response hash defaults..
|
||||||
responses => {},
|
responses => {},
|
||||||
lastResponse => -1,
|
lastResponse => -1,
|
||||||
questionsAnswered => 0,
|
questionsAnswered => 0,
|
||||||
startTime => time(),
|
startTime => time(),
|
||||||
surveyOrder => [],
|
surveyOrder => [],
|
||||||
|
|
||||||
# And then allow jsonData to override defaults and/or add other members
|
# And then allow jsonData to override defaults and/or add other members
|
||||||
%{$jsonData},
|
%{$jsonData},
|
||||||
},
|
},
|
||||||
|
|
@ -82,19 +82,18 @@ sub new {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 createSurveyOrder ( SurveyJSON, [address,address] )
|
=head2 createSurveyOrder
|
||||||
|
|
||||||
This creates the order for the survey which will change after every fork. The survey
|
Computes the order of Sections, Questions and Aswers for this Survey. The order is represented as
|
||||||
order is to precreate random questions and answers, which also leaves a record or what
|
an array of addresses (see L<"Address Parameter">), and is stored in the surveyOrder property.
|
||||||
the user was presented with. Forks are passed in to show where to branch the new order.
|
Questions and Answers that are set to be randomized are shuffled into a random order.
|
||||||
|
The survey order leaves a record or what the user was presented with.
|
||||||
If questions and/or answers were set to be randomized, it is handled in here.
|
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub createSurveyOrder {
|
sub createSurveyOrder {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
# Order Questions in each Section
|
# Order Questions in each Section
|
||||||
my @surveyOrder;
|
my @surveyOrder;
|
||||||
for my $sIndex ( 0 .. $self->survey->lastSectionIndex ) {
|
for my $sIndex ( 0 .. $self->survey->lastSectionIndex ) {
|
||||||
|
|
@ -110,7 +109,7 @@ sub createSurveyOrder {
|
||||||
|
|
||||||
# Order Answers in each Question
|
# Order Answers in each Question
|
||||||
for my $q (@qOrder) {
|
for my $q (@qOrder) {
|
||||||
|
|
||||||
# Randomize Answers if required..
|
# Randomize Answers if required..
|
||||||
my @aOrder;
|
my @aOrder;
|
||||||
if ( $self->survey->question( [ $sIndex, $q ] )->{randomizeAnswers} ) {
|
if ( $self->survey->question( [ $sIndex, $q ] )->{randomizeAnswers} ) {
|
||||||
|
|
@ -121,13 +120,15 @@ sub createSurveyOrder {
|
||||||
}
|
}
|
||||||
push @surveyOrder, [ $sIndex, $q, \@aOrder ];
|
push @surveyOrder, [ $sIndex, $q, \@aOrder ];
|
||||||
}
|
}
|
||||||
|
|
||||||
# If Section had no Questions, make sure it is still added to @surveyOrder
|
# If Section had no Questions, make sure it is still added to @surveyOrder
|
||||||
if ( !@qOrder ) {
|
if ( !@qOrder ) {
|
||||||
push @surveyOrder, [$sIndex];
|
push @surveyOrder, [$sIndex];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$self->response->{surveyOrder} = \@surveyOrder;
|
$self->response->{surveyOrder} = \@surveyOrder;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue