Skip to content

Commit

Permalink
sortorder fixes
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@1963 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
David Olivier committed Aug 18, 2006
1 parent bb6b450 commit afd5f9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion admin/assessments.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function getGroups($surveyid) {
$query = "SELECT gid, group_name
FROM {$dbprefix}groups
WHERE sid=$surveyid
ORDER BY sortorder";
ORDER BY group_order";
$result = db_execute_assoc($query) or die("Error getting groups<br />$query<br />".$connect->ErrorMsg());
$output=array();
while($row=$result->FetchRow()) {
Expand Down
11 changes: 8 additions & 3 deletions admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ function db_quote($str)
$_POST = array_map('db_quote', $_POST);

if (!isset($_POST['lid']) || $_POST['lid'] == '') {$_POST['lid']="0";}
$query = "INSERT INTO {$dbprefix}questions (sid, gid, type, title, question, preg, help, other, mandatory, lid)"
$query = "INSERT INTO {$dbprefix}questions (sid, gid, type, title, question, preg, help, other, mandatory, lid, question_order)"
." VALUES ('{$_POST['sid']}', '{$_POST['gid']}', '{$_POST['type']}', '{$_POST['title']}',"
." '{$_POST['question']}', '{$_POST['preg']}', '{$_POST['help']}', '{$_POST['other']}', '{$_POST['mandatory']}', '{$_POST['lid']}')";
." '{$_POST['question']}', '{$_POST['preg']}', '{$_POST['help']}', '{$_POST['other']}', '{$_POST['mandatory']}', '{$_POST['lid']}', '99999')";
$result = $connect->Execute($query);
if (!$result)
{
Expand All @@ -220,6 +220,7 @@ function db_quote($str)
$query = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC LIMIT 1"; //get last question id
$result=db_execute_assoc($query);
while ($row=$result->FetchRow()) {$qid = $row['qid'];}
fixsortorderQuestions($qid);
}
if (isset($_POST['attribute_value']) && $_POST['attribute_value'])
{
Expand Down Expand Up @@ -256,7 +257,7 @@ function db_quote($str)
}
//echo "GROUP: ".$grow['group_name']."<br />";
$usql="UPDATE {$dbprefix}questions\n"
."SET title='".str_pad($question_number, 4, "0", STR_PAD_LEFT)."'\n"
."SET question_order='".str_pad($question_number, 4, "0", STR_PAD_LEFT)."'\n"
."WHERE qid=".$grow['qid'];
//echo "[$sql]";
$uresult=$connect->Execute($usql) or die("Error: ".htmlspecialchars($connect->ErrorMsg()));
Expand Down Expand Up @@ -395,6 +396,9 @@ function db_quote($str)
}
else
{
$result = db_execute_assoc("SELECT gid FROM ".db_table_name('questions')." WHERE qid='{$qid}'");
$row=$result->FetchRow();
$gid = $row['gid'];
//see if there are any conditions/attributes/answers for this question, and delete them now as well
$cquery = "DELETE FROM {$dbprefix}conditions WHERE qid=$qid";
$cresult = $connect->Execute($cquery);
Expand All @@ -404,6 +408,7 @@ function db_quote($str)
$cresult = $connect->Execute($cquery);
$query = "DELETE FROM {$dbprefix}questions WHERE qid=$qid";
$result = $connect->Execute($query);
fixsortorderQuestions(0,$gid);
if ($result)
{
$qid="";
Expand Down
2 changes: 1 addition & 1 deletion admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
//FIND OUT HOW MANY FIELDS WILL BE NEEDED - FOR 255 COLUMN LIMIT
$query=" SELECT other, {$dbprefix}questions.type, {$dbprefix}questions.gid, {$dbprefix}questions.qid FROM {$dbprefix}questions, {$dbprefix}groups "
." where {$dbprefix}questions.gid={$dbprefix}groups.gid and {$dbprefix}groups.sid=$surveyid"
." order by {$dbprefix}groups.sortorder, {$dbprefix}questions.title";
." order by {$dbprefix}groups.group_order, {$dbprefix}questions.title";
$result=db_execute_assoc($query) or die("Couldn't count fields<br />$query<br />".htmlspecialchars($connect->ErrorMsg()));
while ($rows = $result->FetchRow())
{
Expand Down

0 comments on commit afd5f9d

Please sign in to comment.