Added goto to sections and questions. Order of precedence is answer, question, then section.
This commit is contained in:
parent
31341e5701
commit
0db9be4512
6 changed files with 58 additions and 5 deletions
|
|
@ -1065,7 +1065,7 @@ sub www_loadQuestions {
|
|||
|
||||
my @questions;
|
||||
eval { @questions = $self->responseJSON->nextQuestions(); };
|
||||
|
||||
|
||||
my $section = $self->responseJSON->nextResponseSection();
|
||||
|
||||
#return $self->prepareShowSurveyTemplate($section,$questions);
|
||||
|
|
@ -1073,6 +1073,7 @@ sub www_loadQuestions {
|
|||
$section->{wasRestarted} = $wasRestarted;
|
||||
|
||||
my $text = $self->prepareShowSurveyTemplate( $section, \@questions );
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
|
@ -1697,4 +1698,31 @@ sub loadTempReportTable {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editDefaultQuestions
|
||||
|
||||
Allows a user to edit the *site wide* default multiple choice questions displayed when adding questions to a survey.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editDefaultQuestions{
|
||||
my $self = shift;
|
||||
my $warning = shift;
|
||||
my $session = $self->session;
|
||||
my ($output);
|
||||
my $bundleId = $session->form->process("bundleId");
|
||||
|
||||
if($bundleId eq 'new'){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if($warning){$output .= "$warning";}
|
||||
# $output .= $tabForm->print;
|
||||
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -469,6 +469,9 @@ sub recordResponses {
|
|||
my $section = $self->nextResponseSection();
|
||||
my @questions = $self->nextQuestions();
|
||||
|
||||
#GOTO jumps in the Survey. Order of precedence is Answer, Question, then Section.
|
||||
my ($goto, $gotoExpression);
|
||||
|
||||
# Handle terminal Section..
|
||||
my $terminalUrl;
|
||||
my $sTerminal = 0;
|
||||
|
|
@ -476,6 +479,15 @@ sub recordResponses {
|
|||
$sTerminal = 1;
|
||||
$terminalUrl = $section->{terminalUrl};
|
||||
}
|
||||
# ..and also gotos..
|
||||
elsif ( $section->{goto} =~ /\w/ ) {
|
||||
$goto = $section->{goto};
|
||||
}
|
||||
# .. and also gotoExpressions..
|
||||
elsif ( $section->{gotoExpression} =~ /\w/ ) {
|
||||
$gotoExpression = $section->{gotoExpression};
|
||||
}
|
||||
|
||||
|
||||
# Handle empty Section..
|
||||
if ( !@questions ) {
|
||||
|
|
@ -487,7 +499,6 @@ sub recordResponses {
|
|||
# Process Questions in Section..
|
||||
my $terminal = 0;
|
||||
my $allRequiredQsAnswered = 1;
|
||||
my ($goto, $gotoExpression);
|
||||
for my $question (@questions) {
|
||||
my $aAnswered = 0;
|
||||
|
||||
|
|
@ -496,6 +507,14 @@ sub recordResponses {
|
|||
$terminal = 1;
|
||||
$terminalUrl = $question->{terminalUrl};
|
||||
}
|
||||
# ..and also gotos..
|
||||
elsif ( $question->{goto} =~ /\w/ ) {
|
||||
$goto = $question->{goto};
|
||||
}
|
||||
# .. and also gotoExpressions..
|
||||
elsif ( $question->{gotoExpression} =~ /\w/ ) {
|
||||
$gotoExpression = $question->{gotoExpression};
|
||||
}
|
||||
|
||||
# Record Question comment
|
||||
$self->responses->{ $question->{id} }->{comment} = $responses->{ $question->{id} . 'comment' };
|
||||
|
|
@ -896,7 +915,6 @@ sub nextQuestions {
|
|||
my $section = $self->nextResponseSection();
|
||||
my $sectionIndex = $self->nextResponseSectionIndex;
|
||||
my $questionsPerPage = $self->survey->section( [ $self->nextResponseSectionIndex ] )->{questionsPerPage};
|
||||
|
||||
# Get all of the existing question responses (so that we can do Section and Question [[var]] replacements
|
||||
my $recordedResponses = $self->recordedResponses();
|
||||
|
||||
|
|
@ -907,6 +925,7 @@ sub nextQuestions {
|
|||
my @questions;
|
||||
for my $i (1 .. $questionsPerPage ) {
|
||||
my $address = $self->surveyOrder->[ $self->lastResponse + $i ];
|
||||
last if(! defined $address);
|
||||
my ($sIndex, $qIndex) = (sIndex($address), qIndex($address));
|
||||
|
||||
# Skip if this is a Section without a Question
|
||||
|
|
@ -1009,6 +1028,7 @@ equal to the number of sections in the survey order.
|
|||
|
||||
sub surveyEnd {
|
||||
my $self = shift;
|
||||
|
||||
return 1 if ( $self->lastResponse >= $#{ $self->surveyOrder } );
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -852,6 +852,7 @@ sub newSection {
|
|||
terminal => 0,
|
||||
terminalUrl => q{},
|
||||
goto => q{},
|
||||
gotoExpression => q{},
|
||||
timeLimit => 0,
|
||||
type => 'section',
|
||||
questions => [],
|
||||
|
|
@ -881,6 +882,8 @@ sub newQuestion {
|
|||
textInButton => 0,
|
||||
type => 'question',
|
||||
answers => [],
|
||||
goto => q{},
|
||||
gotoExpression => q{},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
root_import_survey_default-question-edit.wgpkg
Normal file
BIN
root_import_survey_default-question-edit.wgpkg
Normal file
Binary file not shown.
BIN
root_import_survey_default-section-edit.wgpkg
Normal file
BIN
root_import_survey_default-section-edit.wgpkg
Normal file
Binary file not shown.
|
|
@ -318,9 +318,11 @@ if (typeof Survey === "undefined") {
|
|||
var qs = params.questions;
|
||||
var s = params.section;
|
||||
sliders = [];
|
||||
console.log("Can are farking at least get here?");
|
||||
|
||||
//What to show and where
|
||||
document.getElementById('survey').innerHTML = params.html;
|
||||
console.log("How about farking here");
|
||||
//var te = document.createElement('span');
|
||||
//te.innerHTML = "<input type=button id=testB name='Reload Page' value='Reload Page'>";
|
||||
//document.getElementById('survey').appendChild(te);
|
||||
|
|
@ -333,7 +335,7 @@ if (typeof Survey === "undefined") {
|
|||
if (lastSection !== s.id || s.everyPageText === '1') {
|
||||
document.getElementById('headertext').style.display = 'block';
|
||||
}
|
||||
|
||||
console.log(s.questionsOnSectionPage + " wtf");
|
||||
if (lastSection !== s.id && s.questionsOnSectionPage !== '1') {
|
||||
var span = document.createElement("div");
|
||||
span.innerHTML = "<input type=button id='showQuestionsButton' value='Continue'>";
|
||||
|
|
@ -500,4 +502,4 @@ if (typeof Survey === "undefined") {
|
|||
YAHOO.util.Event.onDOMReady(function(){
|
||||
// Survey.Comm.setUrl('/' + document.getElementById('assetPath').value);
|
||||
Survey.Comm.callServer('', 'loadQuestions');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue