From f714ce1219d901f99713c7799bc280546155f80f Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Thu, 7 May 2015 13:37:01 +0200 Subject: [PATCH] Fixed issue #9618: System error when starting a survey having an empty question group --- application/helpers/frontend_helper.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/application/helpers/frontend_helper.php b/application/helpers/frontend_helper.php index f92426649a8..0e7cbdc69a5 100644 --- a/application/helpers/frontend_helper.php +++ b/application/helpers/frontend_helper.php @@ -1203,6 +1203,12 @@ function buildsurveysession($surveyid,$preview=false) $totalquestions = Yii::app()->db->createCommand($sQuery)->queryScalar(); + $sQuery= "select count(*) from {{groups}} + left join {{questions}} on {{groups}}.gid={{questions}}.gid + where qid is null"; + $iTotalGroupsWithoutQuestions = Yii::app()->db->createCommand($sQuery)->queryScalar(); + + // Fix totalquestions by substracting Test Display questions $iNumberofQuestions=dbExecuteAssoc("SELECT count(*)\n" ." FROM {{questions}}" @@ -1232,7 +1238,7 @@ function buildsurveysession($surveyid,$preview=false) } - if ($totalquestions == 0) //break out and crash if there are no questions! + if ($totalquestions == 0 || $iTotalGroupsWithoutQuestions==0) //break out and crash if there are no questions! { sendCacheHeaders(); doHeader(); @@ -1242,7 +1248,15 @@ function buildsurveysession($surveyid,$preview=false) echo templatereplace(file_get_contents($sTemplatePath."survey.pstpl"),array(),$redata,'frontend_helper[1915]'); echo "\t
\n" ."\t

\n" - ."\t".gT("This survey does not yet have any questions and cannot be tested or completed.")."

\n" + ."\t".gT("This survey cannot be tested or completed for the following reason(s):")."
\n"; + echo "

" ."\t".sprintf(gT("For further information please contact %s"), $thissurvey['adminname']) ." (" ."{$thissurvey['adminemail']})

\n"