From 84ff2a9b07b8765d1c1887d8ff9567e795de5ea7 Mon Sep 17 00:00:00 2001 From: Jason Cleeland Date: Thu, 3 Apr 2003 14:06:39 +0000 Subject: [PATCH] Added fixes to ensure mandatory questions didn't muck up when the last question of the survey, or the first question of a group with a group description. Also removed from multiple option with comments titles. git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@188 b72ed6b6-b9f8-46b5-92b4-906544132732 --- index.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/index.php b/index.php index 19cb726b380..007dcad137c 100644 --- a/index.php +++ b/index.php @@ -79,20 +79,29 @@ if ($multi) { $myfields = explode("|", $lastfield); + $multimandatory="N"; for ($i=1; $i<=$multi; $i++) { $mylist = "fvalue$i"; $arrayno = $i-1; $_SESSION[$myfields[$arrayno]] = $_POST[$mylist]; //echo "$mylist: " . $_POST[$mylist] . " (session: " . $myfields[$arrayno] . ")
"; + if ($_POST[$mylist]) {$multimandatory="Y";} //if there are any answers, set this to true } $mylist = substr($mylist, 0, strlen($mylist)-1); } //This section handles the question number that will be answered - moving backwards and forwards as required -if ($_POST['mandatory'] == "Y" && (!$_POST['fvalue'] || $_POST['fvalue'] == " ")) //if the last question was mandatory but there is no data +if ($_POST['mandatory'] == "Y" && (!$_POST['fvalue'] || $_POST['fvalue'] == " ") && !$multimandatory) //if the last question was mandatory but there is no data { //Repeat last question until an answer is shown + if ($move == " last ") {$move = " next >> ";} //avoids going to submit if last question isn't answered + $repeatmandatory="Y"; //avoids repeating group description if this is the first question of a group + } +elseif ($_POST['mandatory'] == "Y" && $multi && $multimandatory != "Y") + { + if ($move == " last ") {$move = " next >> ";} + $repeatmandatory="Y"; //avoids repeating group description if this is the first question of a group } else { @@ -626,7 +635,7 @@ } //if (($currentgroupname != $lastgroupname) && ($move != " << prev ")) - if ($_SESSION['fieldarray'][$t][5] != $_SESSION['fieldarray'][$v][5] && $newgroup != "yes" && $groupdescription && $move != " << prev ") + if ($_SESSION['fieldarray'][$t][5] != $_SESSION['fieldarray'][$v][5] && $newgroup != "yes" && $groupdescription && $move != " << prev " && !$repeatmandatory) { $presentinggroupdescription = "yes"; echo "\t
\n"; @@ -682,7 +691,8 @@ if ($_SESSION['fieldarray'][$t][6] == "Y") //question is mandatory: inform participant { echo "\t\t\t\n"; - if ($_POST['mandatory'] == "Y" && ($_POST['fvalue']==" " || !$_POST['fvalue'])) //If we are repeating a question because it wasn't answered, tell the participant why + //if ($_POST['mandatory'] == "Y" && ($_POST['fvalue']==" " || !$_POST['fvalue'])) //If we are repeating a question because it wasn't answered, tell the participant why + if ($repeatmandatory) { echo "\t\t\t
This is required information\n"; } @@ -790,8 +800,11 @@ elseif ($ansrow['default'] == "Y") {echo " checked"; $defexists = "Y";} echo " />{$ansrow['answer']}
\n"; } - if (!$_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\tNo answer\n";} - elseif ($_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\tNo answer\n";} + if ($_SESSION['fieldarray'][$t][6] != "Y") + { + if (!$_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\tNo answer\n";} + elseif ($_SESSION[$fname] && !$defexists) {echo "\t\t\t\t\t\tNo answer\n";} + } echo "\t\t\t\t\t\n"; $fname2 = $fname."comment"; if ($anscount > 8) {$tarows = $anscount/1.2;} else {$tarows = 4;} @@ -868,7 +881,7 @@ echo "\t\t\t\t\t\t\t\t$setfont\n"; echo "\t\t\t\t\t\t\t\t\t{$ansrow['answer']}\n"; + echo " />{$ansrow['answer']}\n"; echo "\t\t\t\t\t\t\t\t\n"; $fn++; echo "\t\t\t\t\t\t\t\t\n"; @@ -886,12 +899,12 @@ $anscount = $anscount + 2; echo "\t\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\t\t$setfont\n"; - echo "\t\t\t\t\t\t\t\t\tOther: \n"; echo "\t\t\t\t\t\t\t\t\n"; $fn++; - echo "\t\t\t\t\t\t\t\t\n"; + echo "\t\t\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\t\t\n"; echo "\t\t\t\t\t\t\t\n";