Skip to content

Commit

Permalink
Fixed issue #9618: System error when starting a survey having an empt…
Browse files Browse the repository at this point in the history
…y question group
  • Loading branch information
c-schmitz committed May 7, 2015
1 parent 85cd38c commit f714ce1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions application/helpers/frontend_helper.php
Expand Up @@ -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}}"
Expand Down Expand Up @@ -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();
Expand All @@ -1242,7 +1248,15 @@ function buildsurveysession($surveyid,$preview=false)
echo templatereplace(file_get_contents($sTemplatePath."survey.pstpl"),array(),$redata,'frontend_helper[1915]');
echo "\t<div id='wrapper'>\n"
."\t<p id='tokenmessage'>\n"
."\t".gT("This survey does not yet have any questions and cannot be tested or completed.")."<br /><br />\n"
."\t".gT("This survey cannot be tested or completed for the following reason(s):")."<br />\n";
echo "<ul>";
if ($totalquestions == 0){
echo '<li>'.gT("There are no questions in this survey.").'</li>';
}
if ($iTotalGroupsWithoutQuestions == 0){
echo '<li>'.gT("There are empty question groups in this survey - please create at least one question within a question group.").'</li>';
}
echo "</ul>"
."\t".sprintf(gT("For further information please contact %s"), $thissurvey['adminname'])
." (<a href='mailto:{$thissurvey['adminemail']}'>"
."{$thissurvey['adminemail']}</a>)<br /><br />\n"
Expand Down

1 comment on commit f714ce1

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: thinking of this, for ls3/EM reworking
Maybe EM group list can take only group with question for "step", the user can have an empty group and go to survey. No real reason, but when testing it's more easy.

Please sign in to comment.