Skip to content

Commit

Permalink
Fixed moving previous/group description when last question in previou…
Browse files Browse the repository at this point in the history
…s group is conditional and not displaying. Moved checking if the group has changed to function (checkIfNewGroup).

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@973 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Mar 30, 2004
1 parent 9151c87 commit c61e2bb
Showing 1 changed file with 40 additions and 26 deletions.
66 changes: 40 additions & 26 deletions question.php
Expand Up @@ -643,34 +643,11 @@
else {$currentquestion=$_SESSION['step']-1;}
$ia=$_SESSION['fieldarray'][$currentquestion];

foreach ($_SESSION['grouplist'] as $gl)
{
if ($gl[0] == $ia[5])
{
$gid=$gl[0];
$groupname=$gl[1];
$groupdescription=$gl[2];
if (isset($_POST['lastgroupname']) && $_POST['lastgroupname'] != $groupname && $groupdescription)
{
$newgroup = "Y";
}
else
{
$newgroup = "N";
}
if (!isset($_POST['lastgroupname'])) {$newgroup="Y";}
}
}

if ($newgroup == "Y" && $_POST['move'] == " << "._PREV." " && (isset($_POST['grpdesc']) && $_POST['grpdesc']=="Y")) //a small trick to manage moving backwards from a group description
{
$currentquestion++;
$ia=$_SESSION['fieldarray'][$currentquestion];
$_SESSION['step']++;
}
list($newgroup, $gid, $groupname, $groupdescription, $gl)=checkIfNewGroup($ia);

// MANAGE CONDITIONAL QUESTIONS
$conditionforthisquestion=$ia[7];
$questionsSkipped=0;
while ($conditionforthisquestion == "Y") //IF CONDITIONAL, CHECK IF CONDITIONS ARE MET
{
$cquery="SELECT distinct cqid FROM {$dbprefix}conditions WHERE qid={$ia[0]}";
Expand Down Expand Up @@ -712,10 +689,14 @@
else
{
//matches have not been found in ALL distinct cqids. The question WILL NOT be displayed
$questionsSkipped++;
if (returnglobal('move') == " "._NEXT." >> ")
{
$currentquestion++;
$ia=$_SESSION['fieldarray'][$currentquestion];
if(isset($_SESSION['fieldarray'][$currentquestion]))
{
$ia=$_SESSION['fieldarray'][$currentquestion];
}
$_SESSION['step']++;
foreach ($_SESSION['grouplist'] as $gl)
{
Expand Down Expand Up @@ -746,6 +727,16 @@
}
}

if ($questionsSkipped == 0 && $newgroup == "Y" && $_POST['move'] == " << "._PREV." " && (isset($_POST['grpdesc']) && $_POST['grpdesc']=="Y")) //a small trick to manage moving backwards from a group description
{
//This does not work properly in all instances.
$currentquestion++;
$ia=$_SESSION['fieldarray'][$currentquestion];
$_SESSION['step']++;
}

list($newgroup, $gid, $groupname, $groupdescription, $gl)=checkIfNewGroup($ia);

include("qanda.php");

$percentcomplete = makegraph($_SESSION['step'], $_SESSION['totalsteps']);
Expand Down Expand Up @@ -983,4 +974,27 @@ function last()
echo "\n<input type='hidden' name='token' value='$token'>\n";
echo "\n</form>\n</html>";
}

function checkIfNewGroup($ia)
{
foreach ($_SESSION['grouplist'] as $gl)
{
if ($gl[0] == $ia[5])
{
$gid=$gl[0];
$groupname=$gl[1];
$groupdescription=$gl[2];
if (isset($_POST['lastgroupname']) && $_POST['lastgroupname'] != $groupname && $groupdescription)
{
$newgroup = "Y";
}
else
{
$newgroup = "N";
}
if (!isset($_POST['lastgroupname'])) {$newgroup="Y";}
}
}
return array($newgroup, $gid, $groupname, $groupdescription, $gl);
}
?>

0 comments on commit c61e2bb

Please sign in to comment.