Skip to content

Commit

Permalink
Mod for new array question type (Increase/Same/Decrease)
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@360 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Jun 16, 2003
1 parent 3d6cbbd commit 832080f
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 15 deletions.
8 changes: 4 additions & 4 deletions admin/activate.php
Expand Up @@ -42,9 +42,9 @@
// # "O" -> LIST WITH COMMENT
// # "M" -> MULTIPLE OPTIONS
// # "P" -> MULTIPLE OPTIONS WITH COMMENTS
// # "A", "B", "C" -> Various Array Types
// # "A", "B", "C", "E" -> Various Array Types
// # "R" -> RANKING
$chkquery = "SELECT qid, question FROM questions WHERE sid={$_GET['sid']} AND type IN ('L', 'O', 'M', 'P', 'A', 'B', 'C', 'R')";
$chkquery = "SELECT qid, question FROM questions WHERE sid={$_GET['sid']} AND type IN ('L', 'O', 'M', 'P', 'A', 'B', 'C', 'E', 'R')";
$chkresult = mysql_query($chkquery) or die ("Couldn't get list of questions<br />$chkquery<br />".mysql_error());
while ($chkrow = mysql_fetch_array($chkresult))
{
Expand Down Expand Up @@ -196,7 +196,7 @@
//echo "<br /><br />$aquery<br /><br />\n";
while ($arow=mysql_fetch_array($aresult))
{
if ($arow['type'] != "M" && $arow['type'] != "A" && $arow['type'] != "B" && $arow['type'] !="C" &&$arow['type'] !="P" && $arow['type'] != "R")
if ($arow['type'] != "M" && $arow['type'] != "A" && $arow['type'] != "B" && $arow['type'] !="C" && $arow['type'] != "E" && $arow['type'] !="P" && $arow['type'] != "R")
{
$createsurvey .= " {$arow['sid']}X{$arow['gid']}X{$arow['qid']}";
switch($arow['type'])
Expand Down Expand Up @@ -230,7 +230,7 @@
break;
}
}
elseif ($arow['type'] == "M" || $arow['type'] == "A" || $arow['type'] == "B" || $arow['type'] == "C" || $arow['type'] == "P")
elseif ($arow['type'] == "M" || $arow['type'] == "A" || $arow['type'] == "B" || $arow['type'] == "C" || $arow['type'] == "E" || $arow['type'] == "P")
{
//MULTI ENTRY
$abquery = "SELECT answers.*, questions.other FROM answers, questions WHERE answers.qid=questions.qid AND sid={$_GET['sid']} AND questions.qid={$arow['qid']} ORDER BY answers.answer";
Expand Down
4 changes: 2 additions & 2 deletions admin/browse.php
Expand Up @@ -140,7 +140,7 @@
$field = "{$fnrow['sid']}X{$fnrow['gid']}X{$fnrow['qid']}";
$ftitle = "Grp{$fnrow['gid']}Qst{$fnrow['title']}";
$fquestion = $fnrow['question'];
if ($fnrow['type'] == "M" || $fnrow['type'] == "A" || $fnrow['type'] == "B" || $fnrow['type'] == "C" || $fnrow['type'] == "P")
if ($fnrow['type'] == "M" || $fnrow['type'] == "A" || $fnrow['type'] == "B" || $fnrow['type'] == "C" || $fnrow['type'] == "E" || $fnrow['type'] == "P")
{
$fnrquery = "SELECT * FROM answers WHERE qid={$fnrow['qid']} ORDER BY answer";
$fnrresult = mysql_query($fnrquery);
Expand Down Expand Up @@ -263,7 +263,7 @@

foreach ($fnrows as $fnrow)
{
if ($fnrow['type'] != "M" && $fnrow['type'] != "A" && $fnrow['type'] != "B" && $fnrow['type'] != "C" && $fnrow['type'] != "P" && $fnrow['type'] != "O" && $fnrow['type'] != "R")
if ($fnrow['type'] != "M" && $fnrow['type'] != "A" && $fnrow['type'] != "B" && $fnrow['type'] != "C" && $fnrow['type'] != "E" && $fnrow['type'] != "P" && $fnrow['type'] != "O" && $fnrow['type'] != "R")
{
$field = "{$fnrow['sid']}X{$fnrow['gid']}X{$fnrow['qid']}";
$ftitle = "Grp{$fnrow['gid']}Qst{$fnrow['title']}";
Expand Down
54 changes: 49 additions & 5 deletions admin/dataentry.php
Expand Up @@ -71,7 +71,7 @@

while ($irow = mysql_fetch_array($iresult))
{
if ($irow['type'] != "M" && $irow['type'] != "A" && $irow['type'] != "B" && $irow['type'] != "C" && $irow['type'] != "P" && $irow['type'] != "O" && $irow['type'] != "R")
if ($irow['type'] != "M" && $irow['type'] != "A" && $irow['type'] != "B" && $irow['type'] != "C" && $irow['type'] != "E" && $irow['type'] != "P" && $irow['type'] != "O" && $irow['type'] != "R")
{
$fieldname = "{$irow['sid']}X{$irow['gid']}X{$irow['qid']}";
$col_name .= "$fieldname, \n";
Expand Down Expand Up @@ -256,7 +256,7 @@
$field = "{$fnrow['sid']}X{$fnrow['gid']}X{$fnrow['qid']}";
$ftitle = "Grp{$fnrow['gid']}Qst{$fnrow['title']}";
$fquestion = $fnrow['question'];
if ($fnrow['type'] == "M" || $fnrow['type'] == "A" || $fnrow['type'] == "B" || $fnrow['type'] == "C" || $fnrow['type'] == "P")
if ($fnrow['type'] == "M" || $fnrow['type'] == "A" || $fnrow['type'] == "B" || $fnrow['type'] == "C" || $fnrow['type'] == "E" || $fnrow['type'] == "P")
{
$fnrquery = "SELECT * FROM answers WHERE qid={$fnrow['qid']} ORDER BY answer";
$fnrresult = mysql_query($fnrquery);
Expand Down Expand Up @@ -326,7 +326,7 @@
echo "\t<tr>\n";
echo "\t\t<td bgcolor='#EEEEEE' valign='top' align='right' width='20%'>$setfont";
echo "<b>\n";
if ($fnames[$i][3] != "A" && $fnames[$i][3] != "B" && $fnames[$i][3]!="C" && $fnames[$i][3]!="P" && $fnames[$i][3] != "M")
if ($fnames[$i][3] != "A" && $fnames[$i][3] != "B" && $fnames[$i][3]!="C" && $fnames[$i][3] != "E" && $fnames[$i][3]!="P" && $fnames[$i][3] != "M")
{
echo "\t\t\t{$fnames[$i][2]}\n";
}
Expand Down Expand Up @@ -701,6 +701,30 @@
$i--;
echo "</table>\n";
break;
case "E": //ARRAY (Increase/Same/Decrease) radio-buttons
echo "<table>\n";
while ($fnames[$i][3] == "C")
{
$fieldn = substr($fnames[$i][0], 0, strlen($fnames[$i]));
echo "\t<tr>\n";
echo "\t\t<td align='right'>$setfont{$fnames[$i][6]}</td>\n";
echo "\t\t<td>$setfont\n";
echo "\t\t\t<input type='radio' name='{$fnames[$i][0]}' value='I'";
if ($idrow[$fnames[$i][0]] == "Y") {echo " checked";}
echo " />Increase&nbsp;\n";
echo "\t\t\t<input type='radio' name='{$fnames[$i][0]}' value='S'";
if ($idrow[$fnames[$i][0]] == "U") {echo " checked";}
echo " />Same&nbsp\n";
echo "\t\t\t<input type='radio' name='{$fnames[$i][0]}' value='D'";
if ($idrow[$fnames[$i][0]] == "N") {echo " checked";}
echo " />Decrease&nbsp;\n";
echo "\t\t</td>\n";
echo "\t</tr>\n";
$i++;
}
$i--;
echo "</table>\n";
break;
default: //This really only applies to tokens for non-private surveys
echo "\t\t\t<input type='text' name='{$fnames[$i][0]}' value='";
echo $idrow[$fnames[$i][0]] . "'>\n";
Expand Down Expand Up @@ -740,7 +764,7 @@

while ($irow = mysql_fetch_array($iresult))
{
if ($irow['type'] != "M" && $irow['type'] != "P" && $irow['type'] != "A" && $irow['type'] != "B" && $irow['type'] != "C" && $irow['type'] != "O" && $irow['type'] != "R")
if ($irow['type'] != "M" && $irow['type'] != "P" && $irow['type'] != "A" && $irow['type'] != "B" && $irow['type'] != "C" && $irow['type'] != "E" && $irow['type'] != "O" && $irow['type'] != "R")
{
$fieldname = "{$irow['sid']}X{$irow['gid']}X{$irow['qid']}";
if (get_magic_quotes_gpc())
Expand Down Expand Up @@ -1318,7 +1342,7 @@
echo "</table>\n";
break;
case "C": //ARRAY (YES/UNCERTAIN/NO) radio-buttons
$meaquery = "SELECT * FROM answers WHERE qid={$deqrow['qid']} ORDER BY answers";
$meaquery = "SELECT * FROM answers WHERE qid={$deqrow['qid']} ORDER BY answer";
$mearesult=mysql_query($meaquery);
echo "<table>\n";
while ($mearow = mysql_fetch_array($mearesult))
Expand Down Expand Up @@ -1346,6 +1370,26 @@
}
echo "</table>\n";
break;
case "E": //ARRAY (YES/UNCERTAIN/NO) radio-buttons
$meaquery = "SELECT * FROM answers WHERE qid={$deqrow['qid']} ORDER BY answer";
$mearesult=mysql_query($meaquery) or die ("Couldn't get answers, Type \"E\"<br />$meaquery<br />".mysql_error());
echo "<table>\n";
while ($mearow = mysql_fetch_array($mearesult))
{
echo "\t<tr>\n";
echo "\t\t<td align='right'>$setfont{$mearow['answer']}</td>\n";
echo "\t\t<td>\n";
echo "\t\t\t<select name='$fieldname{$mearow['code']}'>\n";
echo "\t\t\t\t<option value=''>Please choose..</option>\n";
echo "\t\t\t\t<option value='I'>Increase</option>\n";
echo "\t\t\t\t<option value='S'>Same</option>\n";
echo "\t\t\t\t<option value='D'>Decrease</option>\n";
echo "\t\t\t</select>\n";
echo "\t\t</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
break;
}
//echo " [$sid"."X"."$gid"."X"."$qid]";
echo "\t\t</td>\n";
Expand Down
1 change: 1 addition & 0 deletions admin/export.php
Expand Up @@ -252,6 +252,7 @@
case "A":
case "B":
case "C":
case "E":
$lq = "SELECT * FROM answers WHERE qid=$fqid AND code= '$faid'";
$lr = mysql_query($lq);
while ($lrow=mysql_fetch_array($lr, MYSQL_ASSOC))
Expand Down
4 changes: 2 additions & 2 deletions admin/html.php
Expand Up @@ -179,7 +179,7 @@
$qrq = "SELECT * FROM answers WHERE qid=$qid ORDER BY answer";
$qrr = mysql_query($qrq);
$qct = mysql_num_rows($qrr);
if ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "M" || $qrrow['type'] == "A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "P" || $qrrow['type'] == "R")
if ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "M" || $qrrow['type'] == "A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "E" || $qrrow['type'] == "P" || $qrrow['type'] == "R")
{
$questionsummary .= "\t<tr><td align='right' valign='top'>$setfont<b>Answers:</b></font></td>\n";
$questionsummary .= "\t<td>\n\t\t<select $slstyle name='answer' onChange=\"window.open(this.options[this.selectedIndex].value,'_top')\">\n";
Expand All @@ -195,7 +195,7 @@
$questionsummary .= "\t<tr><td colspan='2' align='right'>\n";
$questionsummary .= "\t\t<input type='submit' $btstyle value='Set Conditions' onClick=\"window.open('conditions.php?sid=$sid&qid=$qid', 'conditions', 'menubar=no, location=no, status=no, height=350, width=560, scrollbars=yes, resizable=yes')\">\n";
$questionsummary .= "\t\t<input type='submit' $btstyle value='Edit Question' onClick=\"window.open('$scriptname?action=editquestion&sid=$sid&gid=$gid&qid=$qid', '_top')\">\n";
if ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "M" || $qrrow['type']=="A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "P" || $qrrow['type'] == "R")
if ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "M" || $qrrow['type']=="A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "E" || $qrrow['type'] == "P" || $qrrow['type'] == "R")
{
if (($activated == "Y" && $qrrow['type'] == "L") || ($activated == "N"))
{
Expand Down
53 changes: 51 additions & 2 deletions admin/statistics.php
Expand Up @@ -90,7 +90,7 @@
if ($counter == 4) {echo "\t\t\t\t</tr>\n\t\t\t\t<tr>"; $counter=0;}
$myfield = "{$sid}X{$flt[1]}X{$flt[0]}";
//headings
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C" && $flt[2] != "T" && $flt[2] != "S" && $flt[2] != "D" && $flt[2] != "R") //Have to make an exception for these types!
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C" && $flt[2] != "E" && $flt[2] != "T" && $flt[2] != "S" && $flt[2] != "D" && $flt[2] != "R") //Have to make an exception for these types!
{
echo "\t\t\t\t<td align='center'>";
echo "$setfont<b>$flt[3]&nbsp;"; //Heading (Question No)
Expand Down Expand Up @@ -270,6 +270,40 @@
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$counter=0;
break;
case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$query = "SELECT code, answer FROM answers WHERE qid='$flt[0][]'";
$result = mysql_query($query) or die ("Couldn't get answers!<br />$query<br />".mysql_error());
$counter2=0;
while ($row=mysql_fetch_row($result))
{
$myfield2 = $myfield . "$row[0]";
echo "<!-- $myfield2 -- $_POST[$myfield2] -->\n";
if ($counter2 == 4) {echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n"; $counter=0;}
echo "\t\t\t\t<td align='center'>$setfont<B>$flt[3] ($row[0])"; //heading
echo "<input type='radio' name='summary' value='$myfield2'";
if ($_POST['summary'] == "$myfield2") {echo " CHECKED";}
echo ">&nbsp;";
echo "<img src='speaker.jpg' align='bottom' alt=\"$flt[5] [$row[1]]\" onClick=\"alert('QUESTION: $flt[5] [$row[1]]')\">";
echo "<br />\n";

echo "\t\t\t\t<select name='{$sid}X{$flt[1]}X{$flt[0]}{$row[0]}[]' multiple $slstyle2>\n";
echo "\t\t\t\t\t<option value='I'";
if (is_array($_POST[$myfield2]) && in_array("I", $_POST[$myfield2])) {echo " selected";}
echo ">Increase</option>\n";
echo "\t\t\t\t\t<option value='S'";
if (is_array($_POST[$myfield2]) && in_array("S", $_POST[$myfield2])) {echo " selected";}
echo ">Same</option>\n";
echo "\t\t\t\t\t<option value='D'";
if (is_array($_POST[$myfield2]) && in_array("D", $_POST[$myfield2])) {echo " selected";}
echo ">Decrease</option>\n";
echo "\t\t\t\t</select>\n\t\t\t\t</td>\n";
$counter2++;
$allfields[]=$myfield2;
}
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$counter=0;
break;
case "R": //RANKING
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$query = "SELECT code, answer FROM answers WHERE qid='$flt[0]' ORDER BY code";
Expand Down Expand Up @@ -319,7 +353,7 @@
}
break;
}
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C" && $flt[2] != "T" && $flt[2] != "S" && $flt[2] != "D" && $flt[2] != "R") //Have to make an exception for these types!
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C" && $flt[2] != "E" && $flt[2] != "T" && $flt[2] != "S" && $flt[2] != "D" && $flt[2] != "R") //Have to make an exception for these types!
{
echo "\n\t\t\t\t</td>\n";
}
Expand Down Expand Up @@ -707,6 +741,21 @@
$qquestion .= "<br />\n[".$atext."]";
$qtitle .= "($qanswer)";
break;
case "E": //Array of Yes/No/Uncertain
$qanswer=substr($qqid, strlen($qiqid), strlen($qqid));
$qquery = "SELECT code, answer FROM answers WHERE qid='$qiqid' AND code='$qanswer' ORDER BY CODE";
//echo $qquery; //debugging line
$qresult=mysql_query($qquery) or die ("Couldn't get answer details<br />$qquery<br />".mysql_error());
while ($qrow=mysql_fetch_row($qresult))
{
$alist[]=array("I", "Increase");
$alist[]=array("S", "Same");
$alist[]=array("D", "Decrease");
$atext=$qrow[1];
}
$qquestion .= "<br />\n[".$atext."]";
$qtitle .= "($qanswer)";
break;
case "G": //Gender
$alist[]=array("F", "Female");
$alist[]=array("M", "Male");
Expand Down

0 comments on commit 832080f

Please sign in to comment.