Skip to content

Commit

Permalink
Fixed issue #5508: $printanswershonorsconditions settings doesn't wor…
Browse files Browse the repository at this point in the history
…k - all questions are shown in Print Answers page

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@11336 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Nov 8, 2011
1 parent b3c7790 commit 7a1c2eb
Show file tree
Hide file tree
Showing 3 changed files with 1,124 additions and 1,109 deletions.
81 changes: 77 additions & 4 deletions common_functions.php
Expand Up @@ -7582,15 +7582,26 @@ function aGetFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonor
if ($oldgid !== $fname['gid'])
{
$oldgid = $fname['gid'];
$aResultTable['gid_'.$fname['gid']]=array($fname['group_name']);
if (!$bHonorConditions || checkgroupfordisplay($fname['gid']))
{
$aResultTable['gid_'.$fname['gid']]=array($fname['group_name']);
}
}
}
if (isset($fname['qid']) && !empty($fname['qid']))
{
if ($bHonorConditions)
{
$isQuestionVisible=checkquestionfordisplay($fname['qid'],null);
}
else
{
$isQuestionVisible=true;
}
if ($oldqid !== $fname['qid'])
{
$oldqid = $fname['qid'];
if (($bHonorConditions && checkquestionfordisplay($fname['qid'],null)) || !$bHonorConditions)
if ($isQuestionVisible)
{
if (isset($fname['subquestion']) || isset($fname['subquestion1']) || isset($fname['subquestion2']))
{
Expand Down Expand Up @@ -7625,9 +7636,12 @@ function aGetFullResponseTable($iSurveyID, $iResponseID, $sLanguageCode, $bHonor

if (isset($fname['subquestion2']))
$subquestion .= "[{$fname['subquestion2']}]";
if ($isQuestionVisible)
{
$answer=getextendedanswer($fname['fieldname'], $idrow[$fname['fieldname']]);
$aResultTable[$fname['fieldname']]=array('',$subquestion,$answer);
}

$answer=getextendedanswer($fname['fieldname'], $idrow[$fname['fieldname']]);
$aResultTable[$fname['fieldname']]=array('',$subquestion,$answer);
}
return $aResultTable;
}
Expand Down Expand Up @@ -7809,4 +7823,63 @@ function fixSubquestions()
}


function checkgroupfordisplay($gid)
{
//This function checks all the questions in a group to see if they have
//conditions, and if the do - to see if the conditions are met.
//If none of the questions in the group are set to display, then
//the function will return false, to indicate that the whole group
//should not display at all.
global $dbprefix, $connect;
$countQuestionsInThisGroup=0;
$countConditionalQuestionsInThisGroup=0;
foreach ($_SESSION['fieldarray'] as $ia) //Run through all the questions

{
if ($ia[5] == $gid) //If the question is in the group we are checking:

{
// Check if this question is hidden
$qidattributes=getQuestionAttributes($ia[0]);
if ($qidattributes!==false && $qidattributes['hidden']==0)
{
$countQuestionsInThisGroup++;
if ($ia[7] == "Y") //This question is conditional

{
$countConditionalQuestionsInThisGroup++;
$QuestionsWithConditions[]=$ia; //Create an array containing all the conditional questions
}
}
}
}
if ($countQuestionsInThisGroup===0)
{
return false;
}
elseif ($countQuestionsInThisGroup != $countConditionalQuestionsInThisGroup || !isset($QuestionsWithConditions) )
{
//One of the questions in this group is NOT conditional, therefore
//the group MUST be displayed
return true;
}
else
{
//All of the questions in this group are conditional. Now we must
//check every question, to see if the condition for each has been met.
//If 1 or more have their conditions met, then the group should
//be displayed.
foreach ($QuestionsWithConditions as $cc)
{
if (checkquestionfordisplay($cc[0], $gid) === true)
{
return true;
}
}
//Since we made it this far, there mustn't have been any conditions met.
//Therefore the group should not be displayed.
return false;
}
}

// Closing PHP tag intentionally omitted - yes, it is okay
58 changes: 0 additions & 58 deletions index.php
Expand Up @@ -1173,64 +1173,6 @@ function makelanguagechanger()
}


function checkgroupfordisplay($gid)
{
//This function checks all the questions in a group to see if they have
//conditions, and if the do - to see if the conditions are met.
//If none of the questions in the group are set to display, then
//the function will return false, to indicate that the whole group
//should not display at all.
global $dbprefix, $connect;
$countQuestionsInThisGroup=0;
$countConditionalQuestionsInThisGroup=0;
foreach ($_SESSION['fieldarray'] as $ia) //Run through all the questions

{
if ($ia[5] == $gid) //If the question is in the group we are checking:

{
// Check if this question is hidden
$qidattributes=getQuestionAttributes($ia[0]);
if ($qidattributes!==false && $qidattributes['hidden']==0)
{
$countQuestionsInThisGroup++;
if ($ia[7] == "Y") //This question is conditional

{
$countConditionalQuestionsInThisGroup++;
$QuestionsWithConditions[]=$ia; //Create an array containing all the conditional questions
}
}
}
}
if ($countQuestionsInThisGroup===0)
{
return false;
}
elseif ($countQuestionsInThisGroup != $countConditionalQuestionsInThisGroup || !isset($QuestionsWithConditions) )
{
//One of the questions in this group is NOT conditional, therefore
//the group MUST be displayed
return true;
}
else
{
//All of the questions in this group are conditional. Now we must
//check every question, to see if the condition for each has been met.
//If 1 or more have their conditions met, then the group should
//be displayed.
foreach ($QuestionsWithConditions as $cc)
{
if (checkquestionfordisplay($cc[0], $gid) === true)
{
return true;
}
}
//Since we made it this far, there mustn't have been any conditions met.
//Therefore the group should not be displayed.
return false;
}
}

function checkconfield($value)
{
Expand Down

0 comments on commit 7a1c2eb

Please sign in to comment.