Skip to content

Commit

Permalink
New function checkgroupfordisplay($gid) which checks the current grou…
Browse files Browse the repository at this point in the history
…p to determine if it should or should not be displayed (returns true for "display" and false for "don't display")

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@970 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Mar 29, 2004
1 parent 0d042cd commit 0459aca
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions index.php
Expand Up @@ -338,6 +338,59 @@ function makegraph($thisstep, $total)
return $graph;
}

function checkgroupfordisplay($gid)
{
global $dbprefix;
// $grouparrayno=$_SESSION['step']-1;
// $gid=$_SESSION['grouplist'][$grouparrayno][0];
// $groupname=$_SESSION['grouplist'][$grouparrayno][1];
// $groupdescription=$_SESSION['grouplist'][$grouparrayno][2];
$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:
{
$countQuestionsInThisGroup++;
if ($ia[7] == "Y") //This question is conditional
{
$countConditionalQuestionsInThisGroup++;
$checkConditions[]=$ia; //Create an array containing all the conditional questions
}
}
}
if ($countQuestionsInThisGroup != $countConditionalQuestionsInThisGroup)
{
unset($checkConditions); // We can safely delete this because it won't be needed.
return true;
}
else
{
$conditionsToMeet=count($checkConditions);
$totalConditionsMet=0;
foreach ($checkConditions as $cc)
{
$query = "SELECT * FROM {$dbprefix}conditions WHERE qid=$cc[0] ORDER BY cqid";
$result = mysql_query($query) or die("Couldn't check conditions<br />$query<br />".mysql_error());
while($row=mysql_fetch_array($result))
{
if ($_SESSION[$row['cfieldname']] == $row['value'])
{
$totalConditionsMet++;
}
} // while
}
if ($totalConditionsMet > 0)
{
return true;
}
else
{
return false;
}
}
}

function checkconfield($value)
{
global $dbprefix;
Expand Down

0 comments on commit 0459aca

Please sign in to comment.