diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f6bb7baee..c20af44c9 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -16,6 +16,7 @@ - added #10145: Global Head Tags in Settings - added packing to templates, snippets, and head tags. - added #9289: Extending the "Request Approval For Version Tag" activity by reversing the test (Bernd Kalbfuß-Zimmermann) + - added: Survey sections now have logical section type, which is never shown to the user, only used for silently checking gotos. 7.7.4 - rfe: Extend DateTime for Week-Nrs (#9151) diff --git a/docs/upgrades/packages-7.7.5/root_import_survey_default-section-edit.wgpkg b/docs/upgrades/packages-7.7.5/root_import_survey_default-section-edit.wgpkg index 050d44919..78e7b4bc7 100644 Binary files a/docs/upgrades/packages-7.7.5/root_import_survey_default-section-edit.wgpkg and b/docs/upgrades/packages-7.7.5/root_import_survey_default-section-edit.wgpkg differ diff --git a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm index e49864ed2..5c7318bab 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/ResponseJSON.pm @@ -439,6 +439,7 @@ sub recordResponses { # We want to record responses against the "next" response section and questions, since these are # the items that have just been displayed to the user. my $section = $self->nextResponseSection(); + my @questions = $self->nextQuestions(); #GOTO jumps in the Survey. Order of precedence is Answer, Question, then Section. @@ -461,7 +462,7 @@ sub recordResponses { } # Handle empty Section.. - if ( !@questions ) { + if ( !@questions and !$section->{logical}) { # No questions to process, so increment lastResponse and return $self->lastResponse( $self->nextResponse ); return [ $sTerminal, $terminalUrl ]; @@ -556,13 +557,18 @@ sub recordResponses { # If all required responses were given, proceed onwards! if ($allRequiredQsAnswered) { - # Move the lastResponse index to the last question answered $self->lastResponse( $self->lastResponse + @questions ); # Do any requested branching.. $self->processGoto($goto) if ( defined $goto ); ## no critic $self->processGotoExpression($gotoExpression) if ( defined $gotoExpression ); ## no critic + + # Handle next logic Section.. + my $section = $self->nextResponseSection(); + if($section and $section->{logical}){ + return $self->recordResponses({}); + } } else { # Required responses were missing, so we don't let the Survey terminate diff --git a/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm b/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm index 6be417749..e9e999df3 100644 --- a/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm +++ b/lib/WebGUI/Asset/Wobject/Survey/SurveyJSON.pm @@ -882,6 +882,7 @@ sub newSection { questionsPerPage => 5, questionsOnSectionPage => 1, randomizeQuestions => 0, + logical => 0, everyPageTitle => 1, everyPageText => 1, terminal => 0, @@ -1222,6 +1223,9 @@ sub validateSurvey{ push @messages, "Section $sNum variable name $var is re-used in $count other place(s)."; } } + if($section->{logical} and @{$self->questions([$s])} > 0){ + push @messages, "Section $sNum is a logical section with questions. Those questions will never be shown."; + } #step through each question validating it. my $questions = $self->questions([$s]); diff --git a/lib/WebGUI/i18n/English/Asset_Survey.pm b/lib/WebGUI/i18n/English/Asset_Survey.pm index 43ee95126..73b945579 100644 --- a/lib/WebGUI/i18n/English/Asset_Survey.pm +++ b/lib/WebGUI/i18n/English/Asset_Survey.pm @@ -39,6 +39,14 @@ our $I18N = { message => q|Continue|, lastUpdated => 1224686319 }, + 'logical section' => { + message => q|Logical Section|, + lastUpdated => 1224686319 + }, + 'logical section help' => { + message => q|A logical section, or its questions, are never shown. They are used to silently execute jump commands.|, + lastUpdated => 1224686319 + }, 'add section' => { message => q|Add Section|, lastUpdated => 1224686319