diff --git a/lib/WebGUI/Asset/Wobject/Survey.pm b/lib/WebGUI/Asset/Wobject/Survey.pm index 601466171..fd78f56a7 100644 --- a/lib/WebGUI/Asset/Wobject/Survey.pm +++ b/lib/WebGUI/Asset/Wobject/Survey.pm @@ -57,6 +57,17 @@ sub definition { hoverHelp => $i18n->get('timelimit hoverHelp'), label => $i18n->get('timelimit') }, + doAfterTimeLimit => { + fieldType => 'selectBox', + defaultValue => 'exitUrl', + tab => 'properties', + hoverHelp => $i18n->get('do after timelimit hoverHelp'), + label => $i18n->get('do after timelimit label'), + options => { + 'exitUrl' => $i18n->get('exit url label'), + 'restartSurvey' => $i18n->get('restart survey label'), + }, + }, groupToEditSurvey => { fieldType => 'group', defaultValue => 4, @@ -738,6 +749,7 @@ sub www_view { } #------------------------------------------------------------------- + sub www_takeSurvey { my $self = shift; my %var; @@ -839,7 +851,8 @@ sub www_submitQuestions { #finds the questions to display next and builds the data structre to hold them #------------------------------------------------------------------- sub www_loadQuestions { - my $self = shift; + my $self = shift; + my $wasRestarted = shift; if ( !$self->canTakeSurvey() ) { $self->session->log->debug('canTakeSurvey false, surveyEnd'); @@ -867,7 +880,9 @@ sub www_loadQuestions { my $section = $self->response->nextSection(); #return $self->prepareShowSurveyTemplate($section,$questions); - $section->{id} = $self->response->nextSectionId(); + $section->{id} = $self->response->nextSectionId(); + $section->{wasRestarted} = $wasRestarted; + my $text = $self->prepareShowSurveyTemplate( $section, $questions ); return $text; } ## end sub www_loadQuestions @@ -911,18 +926,24 @@ sub surveyEnd { } ); } - if ( $url !~ /\w/ ) { $url = 0; } - if ( $url eq "undefined" ) { $url = 0; } - if ( !$url ) { - $url - = $self->session->db->quickScalar( - "select exitURL from Survey where assetId = ? order by revisionDate desc limit 1", - [ $self->getId() ] ); + if ($self->get('doAfterTimeLimit') eq 'restartSurvey' && $completeCode == 2){ + $self->response->startTime(time()); + undef $self->{response}; + undef $self->{responseId}; + return $self->www_loadQuestions('1'); + }else{ + if ( $url !~ /\w/ ) { $url = 0; } + if ( $url eq "undefined" ) { $url = 0; } if ( !$url ) { - $url = "/"; + $url + = $self->session->db->quickScalar( + "select exitURL from Survey where assetId = ? order by revisionDate desc limit 1", + [ $self->getId() ] ); + if ( !$url ) { + $url = "/"; + } } } - # $self->session->http->setRedirect($url); return encode_json( { "type", "forward", "url", $url } ); } ## end sub surveyEnd diff --git a/lib/WebGUI/i18n/English/Asset_Survey.pm b/lib/WebGUI/i18n/English/Asset_Survey.pm index 68a7f01a4..f54494f5f 100644 --- a/lib/WebGUI/i18n/English/Asset_Survey.pm +++ b/lib/WebGUI/i18n/English/Asset_Survey.pm @@ -247,7 +247,35 @@ our $I18N = { message => q|How many minutes the user has to finish the survey from the moment they start. 0 means unlimited time.|, lastUpdated => 1231193335, }, - + 'do after timelimit label' => { + message => q|Do After Time Limit:|, + lastUpdated => 1224686319, + context => q|label for the 'do after timelimit' field on the Properties tab of the Survey's edit screen.|, + }, + 'do after timelimit hoverHelp' => { + message => q|Select what happens after the time limit for finishing the survey has expired.|, + lastUpdated => 1231193335, + context => q|description of the 'do after timelimit' field on the Properties tab of the Survey's edit +screen|, + }, + 'exit url label' =>{ + message => q|Exit URL|, + lastUpdated => 0, + context => q|Label for the 'exit url' option of the 'do after timelimit' field on the Properties tab of the +Survey's edit screen|, + }, + 'restart survey label' =>{ + message => q|Restart Survey|, + lastUpdated => 0, + context => q|Label for the 'restart survey' option of the 'do after timelimit' field on the Properties tab of the +Survey's edit screen|, + }, + 'restart message' =>{ + message => q|The survey was restarted because the time limit for completing the survey was reached.|, + lastUpdated => 0, + context => q|The message shown to the user taking the survey when the survey is restarted after reaching +the time limit for completing the survey. This message is in the 'take survey' template.|, + }, }; 1; diff --git a/root_import_survey.wgpkg b/root_import_survey.wgpkg index 9567630b4..a91d554af 100644 Binary files a/root_import_survey.wgpkg and b/root_import_survey.wgpkg differ diff --git a/www/extras/wobject/Survey/survey.css b/www/extras/wobject/Survey/survey.css index 626b9ee58..a4a355fa7 100644 --- a/www/extras/wobject/Survey/survey.css +++ b/www/extras/wobject/Survey/survey.css @@ -87,4 +87,9 @@ input.mcbutton-selected{ /* By default the marker for invalid (required) fields is a red '*' */ .survey-invalid-marker { color: #FF0000; -} \ No newline at end of file +} + +#restartMessage { + color: #FF0000; +} +