Improved handling of Survey restart

This commit is contained in:
Patrick Donelan 2009-05-13 02:10:34 +00:00
parent 1d6831d055
commit 6815cd76aa
4 changed files with 39 additions and 53 deletions

View file

@ -76,17 +76,23 @@ sub new {
# Create skeleton object..
my $self = {
# First define core members..
_survey => $survey,
_session => $survey->session,
_response => {
# Response hash defaults..
responses => {},
lastResponse => -1,
questionsAnswered => 0,
startTime => time(),
surveyOrder => undef,
tags => {},
# And then jsonData overrides
%{$jsonData},
}
};
bless $self, $class;
# Initialise response data
$self->resetResponse($jsonData);
return $self;
}
#----------------------------------------------------------------------------
@ -1363,37 +1369,6 @@ sub returnResponseForReporting {
#-------------------------------------------------------------------
=head2 resetResponse ( [$data] )
Resets all response data (e.g. for when you want to restart a survey)
=head3 data (optional)
Extra data to apply over the defaults
=cut
sub resetResponse {
my $self = shift;
my $data = shift || {};
$self->{_response} = {
# Response hash defaults..
responses => {},
lastResponse => -1,
questionsAnswered => 0,
startTime => time(),
surveyOrder => undef,
tags => {},
# And then allow overrides
%{$data},
};
}
#-------------------------------------------------------------------
=head2 response
Accessor for the Perl hash containing Response data