diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index 2fd56f028..2407bd95d 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -674,6 +674,9 @@ sub www_loadQuestions { if ( !$responseId ) { return $self->surveyEnd(); } + if($self->response->hasTimedOut()){ + return $self->surveyEnd(); + } return $self->surveyEnd() if ( $self->response->surveyEnd() ); @@ -700,7 +703,7 @@ sub surveyEnd { "Survey_response", "Survey_responseId", { Survey_responseId => $responseId, - endDate => WebGUI::DateTime->now->toDatabase, + endDate => time(),#WebGUI::DateTime->now->toDatabase, isComplete => 1 } ); @@ -880,6 +883,7 @@ sub getResponseId { } if ( $haveTaken < $allowedTakes ) { + my $time = time(); $responseId = $self->session->db->setRow( "Survey_response", "Survey_responseId", { @@ -887,8 +891,8 @@ sub getResponseId { userId => $id, ipAddress => $ip, username => $self->session->user->username, - startDate => WebGUI::DateTime->now->toDatabase, - endDate => WebGUI::DateTime->now->toDatabase, + startDate => $time,#WebGUI::DateTime->now->toDatabase, + endDate => 0,#WebGUI::DateTime->now->toDatabase, assetId => $self->getId(), anonId => $anonId } @@ -896,7 +900,10 @@ sub getResponseId { $self->loadBothJSON($responseId); $self->response->createSurveyOrder(); $self->{responseId} = $responseId; + $self->response->{startTime} = $time; + $self->response->{timeLimit} = $self->get("timeLimit"); $self->saveResponseJSON(); + } ## end if ( $haveTaken < $allowedTakes) else { } @@ -1035,7 +1042,7 @@ sub loadTempReportTable { sub log { my $self = shift; - $self->session->log->debug(shift); + $self->session->log->error(shift); } 1; diff --git a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm index 8d3e28f41..18c285f93 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm @@ -86,6 +86,14 @@ sub freeze { return encode_json( \%temp ); } +#Hash the survey timed out? + +sub hasTimedOut{ + my $self=shift; + return 1 if($self->{startTime} + ($self->{timeLimit} * 60) < time()); + return 0; +} + #the index of the last surveyOrder entry shown sub lastResponse { my $self = shift;