Skip to content

Commit

Permalink
MOD: Allows editing existing question attributes, and also reloads "e…
Browse files Browse the repository at this point in the history
…dit question" page when attributes are added/deleted or modified.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@1191 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Sep 16, 2004
1 parent 6997041 commit 6537a71
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion admin/admin.php
Expand Up @@ -131,7 +131,7 @@
$action == "copynewquestion" || $action == "insertnewgroup" ||
$action == "insertnewquestion" || $action == "updatesurvey" || $action=="updategroup" ||
$action=="updatequestion" || $action == "modanswer" || $action == "renumberquestions" ||
$action == "delattribute" || $action == "addattribute")
$action == "delattribute" || $action == "addattribute" || $action == "editattribute")
{
include("database.php");
}
Expand Down
11 changes: 11 additions & 0 deletions admin/database.php
Expand Up @@ -56,6 +56,17 @@
$result = mysql_query($query) or die("Error<br />$query<br />".mysql_error());
}
}
elseif ($action == "editattribute")
{
if (isset($_POST['attribute_value']) && $_POST['attribute_value'])
{
$query = "UPDATE {$dbprefix}question_attributes
SET value='".$_POST['attribute_value']."'
WHERE qaid=".$_POST['qaid']."
AND qid=".$_POST['qid'];
$result = mysql_query($query) or die("Error<br />$query<br />".mysql_error());
}
}
elseif ($action == "insertnewgroup")
{
if (!$_POST['group_name'])
Expand Down
26 changes: 18 additions & 8 deletions admin/html.php
Expand Up @@ -1177,7 +1177,7 @@
}
}

if ($action == "editquestion")
if ($action == "editquestion" || $action == "editattribute" || $action == "delattribute" || $action == "addattribute")
{
$eqquery = "SELECT * FROM {$dbprefix}questions WHERE sid=$sid AND gid=$gid AND qid=$qid";
$eqresult = mysql_query($eqquery);
Expand Down Expand Up @@ -1312,15 +1312,26 @@
<td colspan='2' align='center'>
<table class='outlinetable' cellspacing='0' width='90%'>
<tr>
<th colspan='3'>{$setfont}Existing Attributes</font></th>
<th colspan='4'>{$setfont}"._QL_QUESTIONATTRIBUTES."</font></th>
</tr>\n";
foreach ($qidattributes as $qa)
{
$editquestion .= "<tr><td align='right' width='50%'>"
.$qa['attribute']."</td><td>"
.$qa['value']."</td><form action='$scriptname' method='post'><td width='5%'>"
."<input type='submit' $btstyle value='"
._DELETE."'></td>"
.$qa['attribute']."</td>
<form action='$scriptname' method='post'>
<td align='center'><input type='text' name='attribute_value' size='5' $slstyle value='"
.$qa['value']."' /></td>
<td width='5%'><input type='submit' $btstyle value='"
._AL_SAVE."' /></td>
<input type='hidden' name='action' value='editattribute'>\n
<input type='hidden' name='sid' value='$sid'>\n
<input type='hidden' name='gid' value='$gid'>\n
<input type='hidden' name='qid' value='$qid'>\n
<input type='hidden' name='qaid' value='".$qa['qaid']."'>\n
</form>
<form action='$scriptname' method='post'><td width='5%'>
<input type='submit' $btstyle value='"
._DELETE."' /></td>"
. "\t<input type='hidden' name='action' value='delattribute'>\n"
. "\t<input type='hidden' name='sid' value='$sid'>\n"
. "\t<input type='hidden' name='qid' value='$qid'>\n"
Expand All @@ -1329,8 +1340,7 @@
. "</form></tr>";
}
$editquestion .= "\t\t\t </table></td></tr><tr id='QTattributes'><form action='$scriptname' method='post'>
<td align='right'>{$setfont}<b>"._QL_QUESTIONATTRIBUTES."</b></font></td>
<td nowrap><select id='QTlist' name='attribute_name' $slstyle>
<td nowrap colspan='2' align='center'><select id='QTlist' name='attribute_name' $slstyle>
</select>
<input type='text' id='QTtext' size='6' name='attribute_value' $slstyle>
<input type='submit' value='"._ADD."' $btstyle></td>
Expand Down
2 changes: 1 addition & 1 deletion admin/lang/english/messages.php
Expand Up @@ -174,7 +174,7 @@
define("_QL_OTHER", "Other:");
define("_QL_LABELSET", "Label Set:");
define("_QL_COPYANS", "Copy Answers?"); //New in 0.98rc3
define("_QL_QUESTIONATTRIBUTES", "Attributes:"); //New in 0.99dev01
define("_QL_QUESTIONATTRIBUTES", "Question Attributes:"); //New in 0.99dev01
//answers
define("_AL_CODE", "Code");
define("_AL_ANSWER", "Answer");
Expand Down

0 comments on commit 6537a71

Please sign in to comment.