Navigation Menu

Skip to content

Commit

Permalink
Added flexible labels type to question, modified javascript to show/h…
Browse files Browse the repository at this point in the history
…ide dropdown as necessary. Moved add/edit question javascript to function, because it was repeated 3 times in 3 places.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@549 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Jul 20, 2003
1 parent 5685e95 commit 652588a
Showing 1 changed file with 98 additions and 57 deletions.
155 changes: 98 additions & 57 deletions admin/html.php
Expand Up @@ -74,15 +74,15 @@
$surveysummary .= "\t\t\t}\n";
$surveysummary .= "\t\telse if (action == \"hideq\")\n";
$surveysummary .= "\t\t\t{\n";
$surveysummary .= "\t\t\tfor (i=30; i<=34; i++)\n";
$surveysummary .= "\t\t\tfor (i=30; i<=36; i++)\n";
$surveysummary .= "\t\t\t\t{\n";
$surveysummary .= "\t\t\t\tvar name='surveydetails'+i;\n";
$surveysummary .= "\t\t\t\tdocument.getElementById(name).style.display='none';\n";
$surveysummary .= "\t\t\t\t}\n";
$surveysummary .= "\t\t\t}\n";
$surveysummary .= "\t\telse if (action == \"showq\")\n";
$surveysummary .= "\t\t\t{\n";
$surveysummary .= "\t\t\tfor (i=30; i<=34; i++)\n";
$surveysummary .= "\t\t\tfor (i=30; i<=36; i++)\n";
$surveysummary .= "\t\t\t\t{\n";
$surveysummary .= "\t\t\t\tvar name='surveydetails'+i;\n";
$surveysummary .= "\t\t\t\tdocument.getElementById(name).style.display='';\n";
Expand Down Expand Up @@ -355,13 +355,17 @@
$questionsummary .= "\t<tr $qshowstyle id='surveydetails32'><td align='right' valign='top'>$setfont<b>"._QL_HELP."</b></font></td>\n\t<td>$setfont{$qrrow['help']}</td></tr>\n";
$qtypes = getqtypelist("", "array"); //qtypes = array(type code=>type description)
$questionsummary .= "\t<tr $qshowstyle id='surveydetails33'><td align='right' valign='top'>$setfont<b>"._QL_TYPE."</b></font></td>\n\t<td>$setfont{$qtypes[$qrrow['type']]}</td></tr>\n";
if ($qct == 0 && ($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 ($qct == 0 && ($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" || $qrrow['type'] == "F"))
{
$questionsummary .= "\t\t<tr $qshowstyle id='surveydetails34'><td></td><td><font face='verdana' size='1' color='green'>WARNING: You need to Add Answers to this question <input type='image' src='./images/answers.gif' border='0' hspace='0' title='"._Q_ADDANSWERS_BT."' onClick=\"window.open('admin.php?sid=$sid&gid=$gid&qid=$qid&viewanswer=Y', '_top')\"></font></td></tr>\n";
}
if (!$qrrow['lid'] && $qrrow['type'] == "F")
{
$questionsummary .= "\t\t<tr $qshowstyle id='surveydetails35'><td></td><td><font face='verdana' size='1' color='green'>WARNING: You need to choose a Label Set for this question</font></td></tr>\n";
}
if ($qrrow['type'] == "M" or $qrrow['type'] == "P")
{
$questionsummary .= "\t<tr $qshowstyle id='surveydetails34'><td align='right' valign='top'>$setfont<b>"._QL_OTHER."</b></font></td>\n\t<td>$setfont{$qrrow['other']}</td></tr>\n";
$questionsummary .= "\t<tr $qshowstyle id='surveydetails36'><td align='right' valign='top'>$setfont<b>"._QL_OTHER."</b></font></td>\n\t<td>$setfont{$qrrow['other']}</td></tr>\n";
}
}
$questionsummary .= "</table>\n";
Expand Down Expand Up @@ -637,6 +641,22 @@
$newquestion .= "\t\t</select></td>\n";
$newquestion .= "\t</tr>\n";

$newquestion .= "\t<tr id='LabelSets' style='display: none'>\n";
$newquestion .= "\t\t<td align='right'>$setfont<b>"._QL_LABELSET."</b></font></td>\n";
$newquestion .= "\t\t<td>$setfont\n";
$newquestion .= "\t\t<select name='lid' $slstyle>\n";
$labelsets=getlabelsets();
if (count($labelsets)>0)
{
foreach ($labelsets as $lb)
{
$newquestion .= "\t\t\t<option value='{$lb[0]}'>{$lb[1]}</option>\n";
}
}
$newquestion .= "\t\t</select>\n";
$newquestion .= "\t\t</td>\n";
$newquestion .= "\t</tr>\n";

$newquestion .= "\t<tr id='OtherSelection' style='display: none'>\n";
$newquestion .= "\t\t<td align='right'>$setfont<b>"._QL_OTHER."</b></font></td>\n";
$newquestion .= "\t\t<td>$setfont\n";
Expand All @@ -653,24 +673,8 @@
$newquestion .= "\t\t</td>\n";
$newquestion .= "\t</tr>\n";

$newquestion .= "<script type='text/javascript'>\n";
$newquestion .= "<!--\n";
$newquestion .= "function OtherSelection(QuestionType)\n";
$newquestion .= "\t{\n";
$newquestion .= "\tif (QuestionType == 'M' || QuestionType == 'P')\n";
$newquestion .= "\t\t{\n";
$newquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = '';\n";
$newquestion .= "\t\t}\n";
$newquestion .= "\telse\n";
$newquestion .= "\t\t{\n";
$newquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = 'none';\n";
$newquestion .= "\t\tdocument.addnewquestion.other[1].checked = true;\n";
$newquestion .= "\t\t}\n";
$newquestion .= "\t}\n";
$newquestion .= "\tOtherSelection('{$eqrow['type']}');\n";
$newquestion .= "-->\n";
$newquestion .= "</script>\n";

$newquestion .= questionjavascript($eqrow['type']);

$newquestion .= "\t<tr>\n";
$newquestion .= "\t\t<td colspan='2' align='center'><input type='submit' $btstyle value='Add Question' /></td>\n";
$newquestion .= "\t</tr>\n";
Expand Down Expand Up @@ -722,7 +726,26 @@
$editquestion .= getqtypelist($eqrow['type']);
$editquestion .= "\t\t</select></td>\n";
$editquestion .= "\t</tr>\n";
//$editquestion .= "<TD><INPUT TYPE='TEXT' SIZE='1' NAME='type' VALUE='{$eqrow['type']}'></TD></TR>\n";

$editquestion .= "\t<tr id='LabelSets' style='display: none'>\n";
$editquestion .= "\t\t<td align='right'>$setfont<b>"._QL_LABELSET."</b></font></td>\n";
$editquestion .= "\t\t<td>$setfont\n";
$editquestion .= "\t\t<select name='lid' $slstyle>\n";
$labelsets=getlabelsets();
if (count($labelsets)>0)
{
foreach ($labelsets as $lb)
{
$editquestion .= "\t\t\t<option value='{$lb[0]}'";
if ($eqrow['usecookie'] == "Y" && $lb[0] == "Y") {echo " selected";}
elseif ($eqrow['usecookie'] != "Y" && $lb[0] == "N") {echo " selected";}
$editquestion .= ">{$lb[1]}</option>\n";
}
}
$editquestion .= "\t\t</select>\n";
$editquestion .= "\t\t</td>\n";
$editquestion .= "\t</tr>\n";

$editquestion .= "\t<tr>\n";
$editquestion .= "\t\t<td align='right'>$setfont<b>Group?</b></font></td>\n";
$editquestion .= "\t\t<td><select $slstyle name='gid'>\n";
Expand Down Expand Up @@ -754,23 +777,7 @@
$editquestion .= "\t\t</td>\n";
$editquestion .= "\t</tr>\n";

$editquestion .= "<script type='text/javascript'>\n";
$editquestion .= "<!--\n";
$editquestion .= "function OtherSelection(QuestionType)\n";
$editquestion .= "\t{\n";
$editquestion .= "\tif (QuestionType == 'M' || QuestionType == 'P')\n";
$editquestion .= "\t\t{\n";
$editquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = '';\n";
$editquestion .= "\t\t}\n";
$editquestion .= "\telse\n";
$editquestion .= "\t\t{\n";
$editquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = 'none';\n";
$editquestion .= "\t\tdocument.editquestion.other[1].checked = true;\n";
$editquestion .= "\t\t}\n";
$editquestion .= "\t}\n";
$editquestion .= "\tOtherSelection('{$eqrow['type']}');\n";
$editquestion .= "-->\n";
$editquestion .= "</script>\n";
$editquestion .= questionjavascript($eqrow['type']);

$editquestion .= "\t<tr>\n";
$editquestion .= "\t\t<td align='right'>$setfont<b>Copy answers:</b></font></td>\n";
Expand Down Expand Up @@ -931,6 +938,26 @@
$editquestion .= "\t\t</td>\n";
}
$editquestion .= "\t</tr>\n";

$editquestion .= "\t<tr id='LabelSets' style='display: none'>\n";
$editquestion .= "\t\t<td align='right'>$setfont<b>"._QL_LABELSET."</b></font></td>\n";
$editquestion .= "\t\t<td>$setfont\n";
$editquestion .= "\t\t<select name='lid' $slstyle>\n";
$labelsets=getlabelsets();
if (count($labelsets)>0)
{
foreach ($labelsets as $lb)
{
$editquestion .= "\t\t\t<option value='{$lb[0]}'";
if ($eqrow['usecookie'] == "Y" && $lb[0] == "Y") {echo " selected";}
elseif ($eqrow['usecookie'] != "Y" && $lb[0] == "N") {echo " selected";}
$editquestion .= ">{$lb[1]}</option>\n";
}
}
$editquestion .= "\t\t</select>\n";
$editquestion .= "\t\t</td>\n";
$editquestion .= "\t</tr>\n";

$editquestion .= "\t<tr>\n";
$editquestion .= "\t<td align='right'>$setfont<b>"._QL_GROUP."</b></font></td>\n";
$editquestion .= "\t\t<td><select $slstyle name='gid'>\n";
Expand Down Expand Up @@ -962,23 +989,7 @@
$editquestion .= "\t\t</td>\n";
$editquestion .= "\t</tr>\n";

$editquestion .= "<script type='text/javascript'>\n";
$editquestion .= "<!--\n";
$editquestion .= "function OtherSelection(QuestionType)\n";
$editquestion .= "\t{\n";
$editquestion .= "\tif (QuestionType == 'M' || QuestionType == 'P')\n";
$editquestion .= "\t\t{\n";
$editquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = '';\n";
$editquestion .= "\t\t}\n";
$editquestion .= "\telse\n";
$editquestion .= "\t\t{\n";
$editquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = 'none';\n";
$editquestion .= "\t\tdocument.editquestion.other[1].checked = true;\n";
$editquestion .= "\t\t}\n";
$editquestion .= "\t}\n";
$editquestion .= "\tOtherSelection('{$eqrow['type']}');\n";
$editquestion .= "-->\n";
$editquestion .= "</script>\n";
$editquestion .= questionjavascript($eqrow['type']);

$editquestion .= "\t<tr>\n";
$editquestion .= "\t\t<td colspan='2' align='center'><input type='submit' $btstyle value='Update Question'></td>\n";
Expand Down Expand Up @@ -1204,4 +1215,34 @@
$newsurvey .= "\t<input type='hidden' name='action' value='importsurvey'>\n";
$newsurvey .= "\t</tr></form>\n</table>\n";
}

function questionjavascript($type)
{
$newquestion = "<script type='text/javascript'>\n";
$newquestion .= "<!--\n";
$newquestion .= "function OtherSelection(QuestionType)\n";
$newquestion .= "\t{\n";
$newquestion .= "\tif (QuestionType == 'M' || QuestionType == 'P')\n";
$newquestion .= "\t\t{\n";
$newquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = '';\n";
$newquestion .= "\t\tdocument.getElementById('LabelSets').style.display = 'none';\n";
$newquestion .= "\t\t}\n";
$newquestion .= "\telse if (QuestionType == 'F')\n";
$newquestion .= "\t\t{\n";
$newquestion .= "\t\tdocument.getElementById('LabelSets').style.display = '';\n";
$newquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = 'none';\n";
$newquestion .= "\t\t}\n";
$newquestion .= "\telse\n";
$newquestion .= "\t\t{\n";
$newquestion .= "\t\tdocument.getElementById('LabelSets').style.display = 'none';\n";
$newquestion .= "\t\tdocument.getElementById('OtherSelection').style.display = 'none';\n";
$newquestion .= "\t\tdocument.addnewquestion.other[1].checked = true;\n";
$newquestion .= "\t\t}\n";
$newquestion .= "\t}\n";
$newquestion .= "\tOtherSelection('$type');\n";
$newquestion .= "-->\n";
$newquestion .= "</script>\n";

return $newquestion;
}
?>

0 comments on commit 652588a

Please sign in to comment.