Skip to content

Commit

Permalink
MOD: Added question_attributes option to "copy question", refined lay…
Browse files Browse the repository at this point in the history
…out of question attributes in editquestion

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@1193 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Sep 17, 2004
1 parent e9f29f2 commit 4598377
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
26 changes: 20 additions & 6 deletions admin/database.php
Expand Up @@ -303,18 +303,16 @@
if (!isset($_POST['lid'])) {$_POST['lid']="";}
$query = "INSERT INTO {$dbprefix}questions (qid, sid, gid, type, title, question, help, other, mandatory, lid) VALUES ('', '{$_POST['sid']}', '{$_POST['gid']}', '{$_POST['type']}', '{$_POST['title']}', '{$_POST['question']}', '{$_POST['help']}', '{$_POST['other']}', '{$_POST['mandatory']}', '{$_POST['lid']}')";
$result = mysql_query($query);
$newqid = mysql_insert_id();
if (!$result)
{
echo "<script type=\"text/javascript\">\n<!--\n alert(\""._DB_FAIL_NEWQUESTION."\\n".mysql_error()."\")\n //-->\n</script>\n";
}
if (returnglobal('copyanswers') == "Y")
{
$q2 = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC LIMIT 1";
$r2 = mysql_query($q2);
while ($qr2 = mysql_fetch_array($r2)) {$newqid = $qr2['qid'];}
$q1 = "SELECT * FROM {$dbprefix}answers WHERE qid='"
$q1 = "SELECT * FROM {$dbprefix}answers WHERE qid="
. returnglobal('oldqid')
. "' ORDER BY code";
. " ORDER BY code";
$r1 = mysql_query($q1);
while ($qr1 = mysql_fetch_array($r1))
{
Expand All @@ -324,7 +322,23 @@
. "'{$qr1['sortorder']}')";
$ir1 = mysql_query($i1);
}
}
}
if (returnglobal('copyattributes') == "Y")
{
$q1 = "SELECT * FROM {$dbprefix}question_attributes
WHERE qid=".returnglobal('oldqid')."
ORDER BY qaid";
$r1 = mysql_query($q1);
while($qr1 = mysql_fetch_array($r1))
{
$i1 = "INSERT INTO {$dbprefix}question_attributes
(qid, attribute, value)
VALUES ('$newqid',
'{$qr1['attribute']}',
'{$qr1['value']}')";
$ir1 = mysql_query($i1);
} // while
}
}

elseif ($action == "delquestion")
Expand Down
45 changes: 23 additions & 22 deletions admin/html.php
Expand Up @@ -1073,6 +1073,7 @@
{
$eqquery = "SELECT * FROM {$dbprefix}questions WHERE sid=$sid AND gid=$gid AND qid=$qid";
$eqresult = mysql_query($eqquery);
$qattributes=questionAttributes();
while ($eqrow = mysql_fetch_array($eqresult))
{
$editquestion = "<table width='100%' border='0'>\n"
Expand Down Expand Up @@ -1160,14 +1161,19 @@
. "\t\t</font></td>\n"
. "\t</tr>\n";

$editquestion .= questionjavascript($eqrow['type']);
$editquestion .= questionjavascript($eqrow['type'], $qattributes);

$editquestion .= "\t<tr>\n"
. "\t\t<td align='right'>$setfont<b>"._QL_COPYANS."</b></font></td>\n"
. "\t\t<td>$setfont<input type='checkbox' checked name='copyanswers' value='Y' />"
. "</font></td>\n"
. "\t</tr>\n"
. "\t<tr>\n"
. "\t\t<td align='right'>$setfont<b>"._QL_COPYATT."</b></font></td>\n"
. "\t\t<td>$setfont<input type='checkbox' checked name='copyattributes' value='Y' />"
. "</font></td>\n"
. "\t</tr>\n"
. "\t<tr>\n"
. "\t\t<td colspan='2' align='center'><input type='submit' $btstyle value='"._COPYQ."'></td>\n"
. "\t\t<input type='hidden' name='action' value='copynewquestion'>\n"
. "\t\t<input type='hidden' name='sid' value='$sid' />\n"
Expand Down Expand Up @@ -1294,7 +1300,7 @@
$editquestion .= " />\n"
. "\t\t</font></td>\n"
. "\t</tr>\n";
$qattributes=questionAttributes();
$qattributes=questionAttributes();

$editquestion .= "\t<tr>\n"
. "\t\t<td colspan='2' align='center'>"
Expand All @@ -1307,13 +1313,22 @@
}

$qidattributes=getQuestionAttributes($qid);
$editquestion .= "<td valign='top' width='35%'><table width='100%' border='0' cellspacing='0'>
$editquestion .= "\t\t\t<td valign='top' width='35%'><table width='100%' border='0' cellspacing='0'>
<tr>
<td colspan='2' align='center'>
<table class='outlinetable' cellspacing='0' width='90%'>
<tr>
<table class='outlinetable' cellspacing='0' width='90%'><tr id='QTattributes'><form action='$scriptname' method='post'>
<tr>
<th colspan='4'>{$setfont}"._QL_QUESTIONATTRIBUTES."</font></th>
</tr>\n";
</tr>
<tr><th colspan='4' height='5'></th></tr>
<th colspan=2 nowrap align='right'><select id='QTlist' name='attribute_name' $slstyle>
</select></th><th><input type='text' id='QTtext' size='6' name='attribute_value' $slstyle></th>
<th><input type='submit' value='"._ADD."' $btstyle></th>
<input type='hidden' name='action' value='addattribute'>
<input type='hidden' name='sid' value='$sid'>
<input type='hidden' name='qid' value='$qid'>
<input type='hidden' name='gid' value='$gid'></form></tr>
<tr><th colspan='4' height='10'></th></tr>\n";
foreach ($qidattributes as $qa)
{
$editquestion .= "<tr><td align='right' width='50%'>"
Expand All @@ -1339,22 +1354,8 @@
. "\t<input type='hidden' name='qaid' value='".$qa['qaid']."'>\n"
. "</form></tr>";
}
$editquestion .= "\t\t\t </table></td></tr><tr id='QTattributes'><form action='$scriptname' method='post'>
<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>
<input type='hidden' name='action' value='addattribute'>
<input type='hidden' name='sid' value='$sid'>
<input type='hidden' name='qid' value='$qid'>
<input type='hidden' name='gid' value='$gid'>
</tr>
<tr>
<td colspan='2' align='center'>
</td></form>
</tr>
</table></td></tr></table>\n";
$editquestion .= "\t\t\t </table>";
$editquestion .= "</td></tr></table>\n";
$editquestion .= questionjavascript($eqrow['type'], $qattributes);
}

Expand Down
1 change: 1 addition & 0 deletions admin/lang/english/messages.php
Expand Up @@ -175,6 +175,7 @@
define("_QL_LABELSET", "Label Set:");
define("_QL_COPYANS", "Copy Answers?"); //New in 0.98rc3
define("_QL_QUESTIONATTRIBUTES", "Question Attributes:"); //New in 0.99dev01
define("_QL_COPYATT", "Copy Attributes?"); //New in 0.99dev01
//answers
define("_AL_CODE", "Code");
define("_AL_ANSWER", "Answer");
Expand Down

0 comments on commit 4598377

Please sign in to comment.