rfe 9197: Survey timeout handling

This commit is contained in:
Yung Han Khoe 2009-01-19 12:49:20 +00:00
parent c4540a96ee
commit 6598ca8854
4 changed files with 67 additions and 13 deletions

View file

@ -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

View file

@ -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;

Binary file not shown.

View file

@ -87,4 +87,9 @@ input.mcbutton-selected{
/* By default the marker for invalid (required) fields is a red '*' */
.survey-invalid-marker {
color: #FF0000;
}
}
#restartMessage {
color: #FF0000;
}