Survey now has fully functioning time limits, can show limits to users, and can show progress
This commit is contained in:
parent
1e259df112
commit
bf7c3505d7
4 changed files with 28 additions and 6 deletions
|
|
@ -1,4 +1,5 @@
|
|||
7.6.4
|
||||
- Survey now will show progress and time limit.
|
||||
- Brand new Survey system. Make sure to export your old results as they will
|
||||
- Made it more obvious how to check out when viewing the cart.
|
||||
- Added a wait timeout parameter to the WAITING method, so that Spectre
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -39,7 +39,20 @@ sub definition {
|
|||
hoverHelp => "A Survey System",
|
||||
label => "Template ID"
|
||||
},
|
||||
timeLimit => { fieldType => 'integer',
|
||||
showProgress => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 0,
|
||||
tab => 'properties',
|
||||
label => "Show user their progress"
|
||||
},
|
||||
showTimeLimit => {
|
||||
fieldType => "yesNo",
|
||||
defaultValue => 0,
|
||||
tab => 'properties',
|
||||
label => "Show user their time remaining"
|
||||
},
|
||||
timeLimit => {
|
||||
fieldType => 'integer',
|
||||
defaultValue => 0,
|
||||
tab => 'properties',
|
||||
hoverHelp => $i18n->get('timelimit hoverHelp'),
|
||||
|
|
@ -593,7 +606,6 @@ sub www_takeSurvey {
|
|||
return $self->surveyEnd();
|
||||
}
|
||||
};
|
||||
|
||||
return $self->session->style->process($out,$self->get("styleTemplateId"));
|
||||
}
|
||||
|
||||
|
|
@ -767,6 +779,11 @@ sub prepareShowSurveyTemplate {
|
|||
}
|
||||
} ## end foreach my $q (@$questions)
|
||||
$section->{'questions'} = $questions;
|
||||
$section->{'questionsAnswered'} = $self->response->{questionsAnswered};
|
||||
$section->{'totalQuestions'} = @{$self->response->surveyOrder};
|
||||
$section->{'showProgress'} = $self->response->{showProgress};
|
||||
$section->{'showTimeLimit'} = $self->response->{showTimeLimit};
|
||||
$section->{'minutesLeft'} = int((($self->response->{startTime} + (60 * $self->response->{timeLimit})) - time())/60);
|
||||
|
||||
my $out = $self->processTemplate( $section, $self->get("surveyQuestionsId") );
|
||||
|
||||
|
|
@ -902,6 +919,8 @@ sub getResponseId {
|
|||
$self->{responseId} = $responseId;
|
||||
$self->response->{startTime} = $time;
|
||||
$self->response->{timeLimit} = $self->get("timeLimit");
|
||||
$self->response->{showProgress} = $self->get("showProgress");
|
||||
$self->response->{showTimeLimit} = $self->get("showTimeLimit");
|
||||
$self->saveResponseJSON();
|
||||
|
||||
} ## end if ( $haveTaken < $allowedTakes)
|
||||
|
|
@ -1042,7 +1061,7 @@ sub loadTempReportTable {
|
|||
|
||||
sub log {
|
||||
my $self = shift;
|
||||
$self->session->log->error(shift);
|
||||
$self->session->log->debug(shift);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -9,16 +9,17 @@ sub new {
|
|||
my $json = shift;
|
||||
my $log = shift;
|
||||
my $survey = shift;
|
||||
my $self = {};
|
||||
my $temp = decode_json($json) if defined $json;
|
||||
my $self = defined $temp ? $temp : {};
|
||||
$self->{survey} = $survey;
|
||||
$self->{log} = $log;
|
||||
my $temp = decode_json($json) if defined $json;
|
||||
$self->{surveyOrder}
|
||||
= defined $temp->{surveyOrder}
|
||||
? $temp->{surveyOrder}
|
||||
: []; #an array of question addresses, with the third member being an array of answers
|
||||
$self->{responses} = defined $temp->{responses} ? $temp->{responses} : {};
|
||||
$self->{lastResponse} = defined $temp->{lastResponse} ? $temp->{lastResponse} : -1;
|
||||
$self->{questionsAnswered} = defined $temp->{questionsAnswered} ? $temp->{questionsAnswered} : 0;
|
||||
bless( $self, $class );
|
||||
return $self;
|
||||
} ## end sub new
|
||||
|
|
@ -90,7 +91,7 @@ sub freeze {
|
|||
|
||||
sub hasTimedOut{
|
||||
my $self=shift;
|
||||
return 1 if($self->{startTime} + ($self->{timeLimit} * 60) < time());
|
||||
return 1 if($self->{startTime} + ($self->{timeLimit} * 60) < time() and $self->{timeLimit} > 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -198,6 +199,7 @@ sub recordResponses {
|
|||
} ## end if ( defined( $responses...
|
||||
} ## end for my $answer ( @{ $question...
|
||||
$qAnswered = 0 if ( !$aAnswered and $question->{required} );
|
||||
$self->{questionsAnswered}++ if($aAnswered);
|
||||
} ## end for my $question (@$questions)
|
||||
|
||||
#if all responses completed, move the lastResponse index to the last question shown
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue