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
|
|
@ -1073,6 +1073,7 @@ sub www_loadQuestions {
|
||||||
$section->{wasRestarted} = $wasRestarted;
|
$section->{wasRestarted} = $wasRestarted;
|
||||||
|
|
||||||
my $text = $self->prepareShowSurveyTemplate( $section, \@questions );
|
my $text = $self->prepareShowSurveyTemplate( $section, \@questions );
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1697,4 +1698,31 @@ sub loadTempReportTable {
|
||||||
return 1;
|
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;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,9 @@ sub recordResponses {
|
||||||
my $section = $self->nextResponseSection();
|
my $section = $self->nextResponseSection();
|
||||||
my @questions = $self->nextQuestions();
|
my @questions = $self->nextQuestions();
|
||||||
|
|
||||||
|
#GOTO jumps in the Survey. Order of precedence is Answer, Question, then Section.
|
||||||
|
my ($goto, $gotoExpression);
|
||||||
|
|
||||||
# Handle terminal Section..
|
# Handle terminal Section..
|
||||||
my $terminalUrl;
|
my $terminalUrl;
|
||||||
my $sTerminal = 0;
|
my $sTerminal = 0;
|
||||||
|
|
@ -476,6 +479,15 @@ sub recordResponses {
|
||||||
$sTerminal = 1;
|
$sTerminal = 1;
|
||||||
$terminalUrl = $section->{terminalUrl};
|
$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..
|
# Handle empty Section..
|
||||||
if ( !@questions ) {
|
if ( !@questions ) {
|
||||||
|
|
@ -487,7 +499,6 @@ sub recordResponses {
|
||||||
# Process Questions in Section..
|
# Process Questions in Section..
|
||||||
my $terminal = 0;
|
my $terminal = 0;
|
||||||
my $allRequiredQsAnswered = 1;
|
my $allRequiredQsAnswered = 1;
|
||||||
my ($goto, $gotoExpression);
|
|
||||||
for my $question (@questions) {
|
for my $question (@questions) {
|
||||||
my $aAnswered = 0;
|
my $aAnswered = 0;
|
||||||
|
|
||||||
|
|
@ -496,6 +507,14 @@ sub recordResponses {
|
||||||
$terminal = 1;
|
$terminal = 1;
|
||||||
$terminalUrl = $question->{terminalUrl};
|
$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
|
# Record Question comment
|
||||||
$self->responses->{ $question->{id} }->{comment} = $responses->{ $question->{id} . 'comment' };
|
$self->responses->{ $question->{id} }->{comment} = $responses->{ $question->{id} . 'comment' };
|
||||||
|
|
@ -896,7 +915,6 @@ sub nextQuestions {
|
||||||
my $section = $self->nextResponseSection();
|
my $section = $self->nextResponseSection();
|
||||||
my $sectionIndex = $self->nextResponseSectionIndex;
|
my $sectionIndex = $self->nextResponseSectionIndex;
|
||||||
my $questionsPerPage = $self->survey->section( [ $self->nextResponseSectionIndex ] )->{questionsPerPage};
|
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
|
# Get all of the existing question responses (so that we can do Section and Question [[var]] replacements
|
||||||
my $recordedResponses = $self->recordedResponses();
|
my $recordedResponses = $self->recordedResponses();
|
||||||
|
|
||||||
|
|
@ -907,6 +925,7 @@ sub nextQuestions {
|
||||||
my @questions;
|
my @questions;
|
||||||
for my $i (1 .. $questionsPerPage ) {
|
for my $i (1 .. $questionsPerPage ) {
|
||||||
my $address = $self->surveyOrder->[ $self->lastResponse + $i ];
|
my $address = $self->surveyOrder->[ $self->lastResponse + $i ];
|
||||||
|
last if(! defined $address);
|
||||||
my ($sIndex, $qIndex) = (sIndex($address), qIndex($address));
|
my ($sIndex, $qIndex) = (sIndex($address), qIndex($address));
|
||||||
|
|
||||||
# Skip if this is a Section without a Question
|
# 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 {
|
sub surveyEnd {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
return 1 if ( $self->lastResponse >= $#{ $self->surveyOrder } );
|
return 1 if ( $self->lastResponse >= $#{ $self->surveyOrder } );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -852,6 +852,7 @@ sub newSection {
|
||||||
terminal => 0,
|
terminal => 0,
|
||||||
terminalUrl => q{},
|
terminalUrl => q{},
|
||||||
goto => q{},
|
goto => q{},
|
||||||
|
gotoExpression => q{},
|
||||||
timeLimit => 0,
|
timeLimit => 0,
|
||||||
type => 'section',
|
type => 'section',
|
||||||
questions => [],
|
questions => [],
|
||||||
|
|
@ -881,6 +882,8 @@ sub newQuestion {
|
||||||
textInButton => 0,
|
textInButton => 0,
|
||||||
type => 'question',
|
type => 'question',
|
||||||
answers => [],
|
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 qs = params.questions;
|
||||||
var s = params.section;
|
var s = params.section;
|
||||||
sliders = [];
|
sliders = [];
|
||||||
|
console.log("Can are farking at least get here?");
|
||||||
|
|
||||||
//What to show and where
|
//What to show and where
|
||||||
document.getElementById('survey').innerHTML = params.html;
|
document.getElementById('survey').innerHTML = params.html;
|
||||||
|
console.log("How about farking here");
|
||||||
//var te = document.createElement('span');
|
//var te = document.createElement('span');
|
||||||
//te.innerHTML = "<input type=button id=testB name='Reload Page' value='Reload Page'>";
|
//te.innerHTML = "<input type=button id=testB name='Reload Page' value='Reload Page'>";
|
||||||
//document.getElementById('survey').appendChild(te);
|
//document.getElementById('survey').appendChild(te);
|
||||||
|
|
@ -333,7 +335,7 @@ if (typeof Survey === "undefined") {
|
||||||
if (lastSection !== s.id || s.everyPageText === '1') {
|
if (lastSection !== s.id || s.everyPageText === '1') {
|
||||||
document.getElementById('headertext').style.display = 'block';
|
document.getElementById('headertext').style.display = 'block';
|
||||||
}
|
}
|
||||||
|
console.log(s.questionsOnSectionPage + " wtf");
|
||||||
if (lastSection !== s.id && s.questionsOnSectionPage !== '1') {
|
if (lastSection !== s.id && s.questionsOnSectionPage !== '1') {
|
||||||
var span = document.createElement("div");
|
var span = document.createElement("div");
|
||||||
span.innerHTML = "<input type=button id='showQuestionsButton' value='Continue'>";
|
span.innerHTML = "<input type=button id='showQuestionsButton' value='Continue'>";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue