Skip to content

Commit

Permalink
Split "List" type question into two - "List (radio)" or "List (dropdo…
Browse files Browse the repository at this point in the history
…wn)". List (radio) is the default, and earlier surveys using the "List" type question will default to the List (radio) type question. Further files to modify.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@1138 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Aug 25, 2004
1 parent f636e7e commit 5480cad
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 63 deletions.
14 changes: 7 additions & 7 deletions admin/html.php
Expand Up @@ -590,7 +590,7 @@
. _Q_CONDITIONS_BT."' border='0' hspace='0' align='left' name='SetQuestionConditions' "
. "onClick=\"window.open('".$homeurl."/conditions.php?sid=$sid&qid=$qid', 'conditions', 'menubar=no, location=no, status=no, height=475, width=560, scrollbars=yes, resizable=yes, left=50, top=50')\">\n"
. "\t\t\t\t\t<img src='$imagefiles/seperator.gif' alt='|' border='0' hspace='0' align='left'>\n";
if ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "M" || $qrrow['type'] == "Q" || $qrrow['type']=="A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "E" || $qrrow['type'] == "F" || $qrrow['type'] == "H" || $qrrow['type'] == "P" || $qrrow['type'] == "R")
if ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "!" || $qrrow['type'] == "!" || $qrrow['type'] == "M" || $qrrow['type'] == "Q" || $qrrow['type']=="A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "E" || $qrrow['type'] == "F" || $qrrow['type'] == "H" || $qrrow['type'] == "P" || $qrrow['type'] == "R")
{
$questionsummary .= "\t\t\t\t\t<input type='image' src='$imagefiles/answers.gif' title='"
. _Q_ANSWERS_BT."' border='0' hspace='0' align='left' name='ViewAnswers' "
Expand Down Expand Up @@ -640,7 +640,7 @@
. "onClick=\"window.open('labels.php?lid={$qrrow['lid']}', '_blank')\">\n";
}
$questionsummary .="</font></td></tr>\n";
if ($qct == 0 && ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "M" || $qrrow['type'] == "Q" || $qrrow['type'] == "A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "E" || $qrrow['type'] == "P" || $qrrow['type'] == "R" || $qrrow['type'] == "F" ||$qrrow['type'] == "H"))
if ($qct == 0 && ($qrrow['type'] == "O" || $qrrow['type'] == "L" || $qrrow['type'] == "!" || $qrrow['type'] == "M" || $qrrow['type'] == "Q" || $qrrow['type'] == "A" || $qrrow['type'] == "B" || $qrrow['type'] == "C" || $qrrow['type'] == "E" || $qrrow['type'] == "P" || $qrrow['type'] == "R" || $qrrow['type'] == "F" ||$qrrow['type'] == "H"))
{
$questionsummary .= "\t\t<tr $qshowstyle id='surveydetails35'><td></td><td>"
. "<font face='verdana' size='1' color='green'>"
Expand Down Expand Up @@ -706,7 +706,7 @@
if ($cdrow['sortorder'] || $cdrow['sortorder'] == "0") {$position=$cdrow['sortorder'];}
$vasummary .= "\t<tr><form action='".$scriptname."' method='post'>\n";
$vasummary .= "\t\t<td align='center'>";
if (($activated == "Y" && $qtype == "L") || ($activated == "N"))
if (($activated == "Y" && ($qtype == "L" || $qtype == "!")) || ($activated == "N"))
{
$vasummary .="<input name='code' type='text' $btstyle value=\"{$cdrow['code']}\" maxlength='5' size='5' "
."onKeyPress=\"return goodchars(event,'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ_-')\""
Expand All @@ -722,7 +722,7 @@
. "type='text' $btstyle value=\"{$cdrow['answer']}\" size='50'></td>\n"
. "\t\t<input name='sortorder' type='hidden' $btstyle value=\"$position\">"
. "\t\t<td align='center'>";
if (($activated == "Y" && $qtype == "L") || ($activated == "N"))
if (($activated == "Y" && ($qtype == "L" || $qtype =="!")) || ($activated == "N"))
{
$vasummary .= "\t\t\t<select name='default' $btstyle>\n"
. "\t\t\t\t<option value='Y'";
Expand All @@ -738,7 +738,7 @@
$vasummary .= "$setfont<font size='1'>{$cdrow['default_value']}"
. "<input type='hidden' name='default' value='{$cdrow['default_value']}'>";
}
if (($activated == "Y" && $qtype == "L") || ($activated == "N"))
if (($activated == "Y" && ($qtype == "L" || $qtype == "!")) || ($activated == "N"))
{
$vasummary .= "\t\t<td align='center'>\n"
. "\t\t\t<input name='ansaction' $btstyle type='submit' value='"._AL_SAVE."'>"
Expand Down Expand Up @@ -767,7 +767,7 @@
. "\t</form></tr>\n";
$position++;
}
if (($activated == "Y" && $qtype == "L") || ($activated == "N"))
if (($activated == "Y" && ($qtype == "L" || $qtype == "!")) || ($activated == "N"))
{
$position=sprintf("%05d", $position);
$vasummary .= "\t<tr><form action='".$scriptname."' method='post'>\n"
Expand Down Expand Up @@ -1631,7 +1631,7 @@ function questionjavascript($type)
. "<!--\n"
. "function OtherSelection(QuestionType)\n"
. "\t{\n"
. "\tif (QuestionType == 'M' || QuestionType == 'P' || QuestionType == 'L')\n"
. "\tif (QuestionType == 'M' || QuestionType == 'P' || QuestionType == 'L' || QuestionType == '!')\n"
. "\t\t{\n"
. "\t\tdocument.getElementById('OtherSelection').style.display = '';\n"
. "\t\tdocument.getElementById('LabelSets').style.display = 'none';\n"
Expand Down
3 changes: 2 additions & 1 deletion admin/lang/chinese/messages.php
Expand Up @@ -215,7 +215,8 @@
define("_5PT", "5 項式選擇");
define("_DATE", "日期");
define("_GENDER", "性別");
define("_LIST", "列表");
define("_LIST", "列表 (Radio)"); //Changed with 0.99dev01
define("_LIST_DROPDOWN", "列表 (Dropdown)"); //New with 0.99dev01
define("_LISTWC", "列表附上評語功能");
define("_MULTO", "多項選擇");
define("_MULTOC", "多項選擇附上評語功能");
Expand Down
3 changes: 2 additions & 1 deletion admin/lang/english/messages.php
Expand Up @@ -215,7 +215,8 @@
define("_5PT", "5 Point Choice");
define("_DATE", "Date");
define("_GENDER", "Gender");
define("_LIST", "List");
define("_LIST", "List (Radio)"); //Changed with 0.99dev01
define("_LIST_DROPDOWN", "List (Dropdown)"); //New with 0.99dev01
define("_LISTWC", "List With Comment");
define("_MULTO", "Multiple Options");
define("_MULTOC", "Multiple Options with Comments");
Expand Down
3 changes: 2 additions & 1 deletion admin/lang/french/messages.php
Expand Up @@ -252,7 +252,8 @@
define("_5PT", "Alignement de 5 Boutons Radio");
define("_DATE", "Date");
define("_GENDER", "Genre");
define("_LIST", "Liste (Bouton Radio)");
define("_LIST", "Liste (Radio)"); //Changed with 0.99dev01
define("_LIST_DROPDOWN", "Liste (Dropdown)"); //New with 0.99dev01
define("_LISTWC", "Liste déroulante avec Commentaire");
define("_MULTO", "Case à Cocher");
define("_MULTOC", "Case à Cocher avec Commentaires");
Expand Down
3 changes: 2 additions & 1 deletion admin/lang/italian/messages.php
Expand Up @@ -215,7 +215,8 @@
define("_5PT", "Lista con 5 opzioni");
define("_DATE", "Data");
define("_GENDER", "Genere");
define("_LIST", "Lista");
define("_LIST", "Lista (Radio)"); //Changed with 0.99dev01
define("_LIST_DROPDOWN", "Lista (Dropdown)"); //New with 0.99dev01
define("_LISTWC", "Lista con commento");
define("_MULTO", "Scelta multipla");
define("_MULTOC", "Scelta multipla con commenti");
Expand Down
3 changes: 2 additions & 1 deletion admin/lang/spanish/messages.php
Expand Up @@ -222,7 +222,8 @@
define("_5PT", "Elegir entre 5 Puntos");
define("_DATE", "Fecha");
define("_GENDER", "G&eacute;nero");
define("_LIST", "Lista");
define("_LIST", "Lista (Radio)"); //Changed with 0.99dev01
define("_LIST_DROPDOWN", "Lista (Dropdown)"); //New with 0.99dev01
define("_LISTWC", "Lista con Comentarios");
define("_MULTO", "Opci&oacute;n M&uacute;ltiple");
define("_MULTOC", "Opci&oacute;n M&uacute;ltiple con Comentarios");
Expand Down
121 changes: 70 additions & 51 deletions qanda.php
Expand Up @@ -230,7 +230,15 @@ function retrieveAnswers($ia, $notanswered=null, $notvalidated=null)
$values=do_date($ia);
break;
case "L": //LIST drop-down/radio-button list
$values=do_list($ia);
$values=do_list_radio($ia);
if (count($values[1]) > 1)
{
$qtitle .= "<br />\n</b><i><font size='1'>"
. _INSTRUCTION_LIST."</font></i><b>";
}
break;
case "!": //List - dropdown
$values=do_list_dropdown($ia);
if (count($values[1]) > 1)
{
$qtitle .= "<br />\n</b><i><font size='1'>"
Expand Down Expand Up @@ -484,7 +492,7 @@ function do_date($ia)
return array($answer, $inputnames);
}

function do_list($ia)
function do_list_dropdown($ia)
{
global $dbprefix, $dropdowns, $dropdownthreshold, $lwcdropdowns;
global $shownoanswer;
Expand All @@ -496,71 +504,82 @@ function do_list($ia)
$ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] ORDER BY sortorder, answer";
$ansresult = mysql_query($ansquery) or die("Couldn't get answers<br />$ansquery<br />".mysql_error());
$anscount = mysql_num_rows($ansresult);
if (($dropdowns == "L" || !$dropdowns || $anscount > $dropdownthreshold) && $other != "Y")
while ($ansrow = mysql_fetch_array($ansresult))
{
while ($ansrow = mysql_fetch_array($ansresult))
$answer .= "\t\t\t\t\t\t<option value='{$ansrow['code']}'";
if ($_SESSION[$ia[1]] == $ansrow['code'])
{
$answer .= "\t\t\t\t\t\t<option value='{$ansrow['code']}'";
if ($_SESSION[$ia[1]] == $ansrow['code'])
{
$answer .= " selected";
}
elseif ($ansrow['default_value'] == "Y") {$answer .= " selected"; $defexists = "Y";}
$answer .= ">{$ansrow['answer']}</option>\n";
$answer .= " selected";
}
if (!$_SESSION[$ia[1]] && (!isset($defexists) || !$defexists)) {$answer = "\t\t\t\t\t\t<option value='' selected>"._PLEASECHOOSE."..</option>\n".$answer;}
if ($_SESSION[$ia[1]] && (!isset($defexists) || !$defexists) && $ia[6] != "Y" && $shownoanswer == 1) {$answer .= "\t\t\t\t\t\t<option value=' '>"._NOANSWER."</option>\n";}
$answer .= "\t\t\t\t\t</select>\n";
$answer = "\n\t\t\t\t\t<select name='$ia[1]' id='$ia[1]' onChange='checkconditions(this.value, this.name, this.type)'>\n".$answer;
elseif ($ansrow['default_value'] == "Y") {$answer .= " selected"; $defexists = "Y";}
$answer .= ">{$ansrow['answer']}</option>\n";
}
else
if (!$_SESSION[$ia[1]] && (!isset($defexists) || !$defexists)) {$answer = "\t\t\t\t\t\t<option value='' selected>"._PLEASECHOOSE."..</option>\n".$answer;}
if ($_SESSION[$ia[1]] && (!isset($defexists) || !$defexists) && $ia[6] != "Y" && $shownoanswer == 1) {$answer .= "\t\t\t\t\t\t<option value=' '>"._NOANSWER."</option>\n";}
$answer .= "\t\t\t\t\t</select>\n";
$answer = "\n\t\t\t\t\t<select name='$ia[1]' id='$ia[1]' onChange='checkconditions(this.value, this.name, this.type)'>\n".$answer;
$inputnames[]=$ia[1];
return array($answer, $inputnames);
}

function do_list_radio($ia)
{
global $dbprefix, $dropdowns, $dropdownthreshold, $lwcdropdowns;
global $shownoanswer;
$answer="";
if (isset($defexists)) {unset ($defexists);}
$query = "SELECT other FROM {$dbprefix}questions WHERE qid=".$ia[0];
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {$other = $row['other'];}
$ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$ia[0] ORDER BY sortorder, answer";
$ansresult = mysql_query($ansquery) or die("Couldn't get answers<br />$ansquery<br />".mysql_error());
$anscount = mysql_num_rows($ansresult);
$answer .= "\n\t\t\t\t\t<table class='question'>\n"
. "\t\t\t\t\t\t<tr>\n"
. "\t\t\t\t\t\t\t<td>\n";
while ($ansrow = mysql_fetch_array($ansresult))
{
$answer .= "\n\t\t\t\t\t<table class='question'>\n"
. "\t\t\t\t\t\t<tr>\n"
. "\t\t\t\t\t\t\t<td>\n";
while ($ansrow = mysql_fetch_array($ansresult))
$answer .= "\t\t\t\t\t\t\t\t <input class='radio' type='radio' value='{$ansrow['code']}' name='$ia[1]' id='$ia[1]{$ansrow['code']}'";
if ($_SESSION[$ia[1]] == $ansrow['code'])
{
$answer .= "\t\t\t\t\t\t\t\t <input class='radio' type='radio' value='{$ansrow['code']}' name='$ia[1]' id='$ia[1]{$ansrow['code']}'";
if ($_SESSION[$ia[1]] == $ansrow['code'])
{
$answer .= " checked";
}
elseif ($ansrow['default_value'] == "Y") {$answer .= " checked"; $defexists = "Y";}
$answer .= " onClick='checkconditions(this.value, this.name, this.type)' /><label for='$ia[1]{$ansrow['code']}' class='answertext'>{$ansrow['answer']}</label><br />\n";
$answer .= " checked";
}
if (isset($other) && $other=="Y")
elseif ($ansrow['default_value'] == "Y") {$answer .= " checked"; $defexists = "Y";}
$answer .= " onClick='checkconditions(this.value, this.name, this.type)' /><label for='$ia[1]{$ansrow['code']}' class='answertext'>{$ansrow['answer']}</label><br />\n";
}
if (isset($other) && $other=="Y")
{
$answer .= "\t\t\t\t\t\t\t\t <input class='radio' type='radio' value='-oth-' name='$ia[1]' id='SOTH$ia[1]'";
if ($_SESSION[$ia[1]] == "-oth-")
{
$answer .= "\t\t\t\t\t\t\t\t <input class='radio' type='radio' value='-oth-' name='$ia[1]' id='SOTH$ia[1]'";
if ($_SESSION[$ia[1]] == "-oth-")
{
$answer .= " checked";
}
$answer .= " onClick='checkconditions(this.value, this.name, this.type)' /><label for='SOTH$ia[1]' class='answertext'>"._OTHER."</label>\n";
$answer .= "<label for='$ia[1]othertext'><input type='text' class='text' id='$ia[1]othertext' name='$ia[1]other' size='20' title='"._OTHER."' ";
$thisfieldname=$ia[1]."other";
if (isset($_SESSION[$thisfieldname])) { $answer .= "value='".$_SESSION[$thisfieldname]."' ";}
$answer .= "onclick=\"javascript:document.getElementById('SOTH$ia[1]').checked=true; checkconditions(document.getElementById('SOTH$ia[1]').value, document.getElementById('SOTH$ia[1]').name, document.getElementById('SOTH$ia[1]').type)\"></label><br />\n";
$inputnames[]=$thisfieldname;
$answer .= " checked";
}
if ($ia[6] != "Y" && $shownoanswer == 1)
$answer .= " onClick='checkconditions(this.value, this.name, this.type)' /><label for='SOTH$ia[1]' class='answertext'>"._OTHER."</label>\n";
$answer .= "<label for='$ia[1]othertext'><input type='text' class='text' id='$ia[1]othertext' name='$ia[1]other' size='20' title='"._OTHER."' ";
$thisfieldname=$ia[1]."other";
if (isset($_SESSION[$thisfieldname])) { $answer .= "value='".$_SESSION[$thisfieldname]."' ";}
$answer .= "onclick=\"javascript:document.getElementById('SOTH$ia[1]').checked=true; checkconditions(document.getElementById('SOTH$ia[1]').value, document.getElementById('SOTH$ia[1]').name, document.getElementById('SOTH$ia[1]').type)\"></label><br />\n";
$inputnames[]=$thisfieldname;
}
if ($ia[6] != "Y" && $shownoanswer == 1)
{
$answer .= "\t\t\t\t\t\t <input class='radio' type='radio' name='$ia[1]' id='$ia[1]NANS' value=' ' ";
if ((!isset($defexists) || $defexists != "Y") && (!isset($_SESSION[$ia[1]]) || !$_SESSION[$ia[1]]))
{
$answer .= "\t\t\t\t\t\t <input class='radio' type='radio' name='$ia[1]' id='$ia[1]NANS' value=' ' ";
if ((!isset($defexists) || $defexists != "Y") && (!isset($_SESSION[$ia[1]]) || !$_SESSION[$ia[1]]))
{
$answer .= " checked"; //Check the "no answer" radio button if there is no default, and user hasn't answered this.
}
$answer .=" onClick='checkconditions(this.value, this.name, this.type)' />"
. "<label for='$ia[1]NANS' class='answertext'>"._NOANSWER."</label>\n";
$answer .= " checked"; //Check the "no answer" radio button if there is no default, and user hasn't answered this.
}
$answer .= "\t\t\t\t\t\t\t</td>\n"
. "\t\t\t\t\t\t</tr>\n"
. "\t\t\t\t\t\t<input type='hidden' name='java$ia[1]' id='java$ia[1]' value='{$_SESSION[$ia[1]]}'>\n"
. "\t\t\t\t\t</table>\n";
$answer .=" onClick='checkconditions(this.value, this.name, this.type)' />"
. "<label for='$ia[1]NANS' class='answertext'>"._NOANSWER."</label>\n";
}
$answer .= "\t\t\t\t\t\t\t</td>\n"
. "\t\t\t\t\t\t</tr>\n"
. "\t\t\t\t\t\t<input type='hidden' name='java$ia[1]' id='java$ia[1]' value='{$_SESSION[$ia[1]]}'>\n"
. "\t\t\t\t\t</table>\n";
$inputnames[]=$ia[1];
return array($answer, $inputnames);
}


function do_listwithcomment($ia)
{
global $maxoptionsize, $dbprefix, $dropdowns, $dropdownthreshold, $lwcdropdowns;
Expand Down

0 comments on commit 5480cad

Please sign in to comment.