Skip to content

Commit

Permalink
Fixed issue #11361: progress bar counts hidden questions
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jun 9, 2016
1 parent 5e59fd9 commit 93d30e4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions application/helpers/frontend_helper.php
Expand Up @@ -1238,6 +1238,19 @@ function buildsurveysession($surveyid,$preview=false)
." AND {{questions}}.parent_qid=0\n";
$totalquestions = Yii::app()->db->createCommand($sQuery)->queryScalar();

// We can't count the non-hidden questions doing a join on previous query, because if a question is not hidden, it can have no "hidden" attribute
$sQuery = "SELECT count(*)\n"
." FROM {{questions}} \n"
." JOIN {{question_attributes}} ON {{question_attributes}}.qid = {{questions}}.qid"
." WHERE {{questions}}.sid=".$surveyid."\n"
." AND {{question_attributes}}.attribute='hidden'"
." AND {{question_attributes}}.value=1"
." AND {{questions}}.language='".App()->getLanguage()."'\n"
." AND {{questions}}.parent_qid=0\n";
$totalHiddenQuestions = Yii::app()->db->createCommand($sQuery)->queryScalar();

$totalquestions = $totalquestions - $totalHiddenQuestions;

$sQuery= "select count(*) from {{groups}}
left join {{questions}} on {{groups}}.gid={{questions}}.gid
where {{groups}}.sid={$surveyid} and qid is null";
Expand Down

0 comments on commit 93d30e4

Please sign in to comment.