Skip to content

Commit

Permalink
-Fixed more bugs in im- and export of questions and groups
Browse files Browse the repository at this point in the history
-Fixed sortorder bug when moving a question from one group to another

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/phpsurveyor@2579 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Mar 14, 2007
1 parent 5ed6ed5 commit 85e5851
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 39 deletions.
20 changes: 14 additions & 6 deletions admin/database.php
Expand Up @@ -325,9 +325,11 @@ function get_max_order($gid)

elseif ($action == "updatequestion" && $actsurrows['define_questions'])
{
$cqquery = "SELECT type FROM ".db_table_name('questions')." WHERE qid={$_POST['qid']}";
$cqquery = "SELECT type, gid FROM ".db_table_name('questions')." WHERE qid={$_POST['qid']}";
$cqresult=db_execute_assoc($cqquery) or die ("Couldn't get question type to check for change<br />".htmlspecialchars($cqquery)."<br />".htmlspecialchars($connect->ErrorMsg()));
while ($cqr=$cqresult->FetchRow()) {$oldtype=$cqr['type'];}
$cqr=$cqresult->FetchRow();
$oldtype=$cqr['type'];
$oldgid=$cqr['gid'];

$keepanswers = "0";

Expand Down Expand Up @@ -364,12 +366,13 @@ function get_max_order($gid)
foreach ($questlangs as $qlang)
{
if (isset($qlang) && $qlang != "")
{
$uqquery = "UPDATE {$dbprefix}questions "
{ // ToDo: Sanitize the POST variables !
$uqquery = "UPDATE ".db_table_name('questions')
. "SET type='{$_POST['type']}', title='{$_POST['title']}', "
. "question='{$_POST['question_'.$qlang]}', preg='{$_POST['preg']}', help='{$_POST['help_'.$qlang]}', "
. "gid='{$_POST['gid']}', other='{$_POST['other']}', "
. "mandatory='{$_POST['mandatory']}'";
if ($oldgid!=$_POST['gid']) {$uqquery .=', question_order=9999 '; } // set it to a very high value so fixsortorder puts it always after the last question in the new group
if (isset($_POST['lid']) && trim($_POST['lid'])!="")
{
$uqquery.=", lid='{$_POST['lid']}' ";
Expand All @@ -382,10 +385,15 @@ function get_max_order($gid)
}
}
}

// if the group has changed then fix the sortorder of old and new group
if ($oldgid!=$_POST['gid'])
{
fixsortorderQuestions(0,$oldgid);
fixsortorderQuestions(0,$_POST['gid']);
}
if ($keepanswers == "0")
{
$query = "DELETE FROM {$dbprefix}answers WHERE qid={$_POST['qid']}";
$query = "DELETE FROM ".db_table_name('answers')." WHERE qid={$_POST['qid']}";
$result = $connect->Execute($query) or die("Error: ".htmlspecialchars($connect->ErrorMsg()));
if (!$result)
{
Expand Down
4 changes: 2 additions & 2 deletions admin/dumpquestion.php
Expand Up @@ -116,11 +116,11 @@ function BuildOutput($Query)
$adump = BuildCSVFromQuery($aquery);

//3: Labelsets Table
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.lid, label_name FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type='F' AND qid=$qid";
$lsquery = "SELECT DISTINCT {$dbprefix}labelsets.* FROM {$dbprefix}labelsets, {$dbprefix}questions WHERE {$dbprefix}labelsets.lid={$dbprefix}questions.lid AND type='F' AND qid=$qid";
$lsdump = BuildCSVFromQuery($lsquery);

//4: Labels Table
$lquery = "SELECT DISTINCT {$dbprefix}labels.lid, {$dbprefix}labels.code, {$dbprefix}labels.title, {$dbprefix}labels.sortorder FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type in ('F', 'H', 'Z', 'W') AND qid=$qid";
$lquery = "SELECT DISTINCT {$dbprefix}labels.* FROM {$dbprefix}labels, {$dbprefix}questions WHERE {$dbprefix}labels.lid={$dbprefix}questions.lid AND type in ('F', 'H', 'Z', 'W') AND qid=$qid";
$ldump = BuildCSVFromQuery($lquery);

//5: Question Attributes
Expand Down
14 changes: 10 additions & 4 deletions admin/importgroup.php
Expand Up @@ -341,12 +341,18 @@



$gid=$grouprowdata['gid'];
$oldgid=$grouprowdata['gid'];
$oldsid=$grouprowdata['sid'];
unset($grouprowdata['gid']);
$grouprowdata['sid']=$newsid;
$oldgid=$gid;


// find tou the maximum group order and use this grouporder+1 to assign it to the new group
$qmaxgo = "select max(group_order) as maxgo from ".db_table_name('groups')." where sid=$newsid";
$gres = db_execute_assoc($qmaxgo) or die ("<strong>".$clang->gT("Error")."</strong> Failed to find out maximum group order value<br />\n$qmaxqo<br />\n".$connect->ErrorMsg()."</body>\n</html>");
$grow=$gres->FetchRow();
$grouprowdata["group_order"]= $grow['maxgo']+1;

// Everything set - now insert it
$newvalues=array_values($grouprowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$ginsert = "insert INTO {$dbprefix}groups (".implode(',',array_keys($grouprowdata)).") VALUES (".implode(',',$newvalues).")";
Expand All @@ -367,7 +373,7 @@
if ($currentqid==$questionrowdata['qid']) {$newquestion=false;}

$thisgid=$questionrowdata['gid'];
if ($thisgid == $gid) {
if ($thisgid == $oldgid) {
$qid = $questionrowdata['qid'];
// Remove qid field
if ($newquestion) {unset($questionrowdata['qid']);}
Expand Down
2 changes: 1 addition & 1 deletion admin/importquestion.php
Expand Up @@ -39,7 +39,7 @@

// A FILE TO IMPORT A DUMPED question FILE, AND CREATE A NEW SURVEY

$importquestion = "<br /><table width='100%' align='center'><tr><td>\n";
$importquestion = "<br /><table width='100%' align='center'><tr><td>\n"
."<table width='350' align='center' style='border: 1px solid #555555' cellpadding='1' cellspacing='0'>\n"
."\t<tr bgcolor='#555555'><td colspan='2' height='4'><font size='1' face='verdana' color='white'><strong>"
.$clang->gT("Import Question")."</strong></td></tr>\n"
Expand Down
61 changes: 35 additions & 26 deletions docs/release_notes_and_upgrade_instructions.txt
Expand Up @@ -20,12 +20,12 @@ http://docs.phpsurveyor.org

HOW TO UPGRADE from all earlier versions of PHPSurveyor (<1.08)
-------------------------------------------------------
We are sorry but you can't upgrade from versions <= 1.0.8. Serious!
We are sorry but you can't upgrade from versions <= 1.0.8. Seriously!
The database structure has changed that much it wouldn't be feasible.

Upgrades from 1.45a are done automatically if there are any and you are entering the admin for the first time.

However you can import old surveys from version 1.0 when you create a new survey in this new version.
However, you can import old surveys from version 1.0 when you create a new survey in this new version.

Just do a new installation as described on http://docs.phpsurveyor.org.

Expand All @@ -35,31 +35,40 @@ Just do a new installation as described on http://docs.phpsurveyor.org.
Thank you to everyone who helped with this new release!


Changes from 1.45a to 1.46b
-Added captcha feature to prevent automatic registering (machaven)
-Fixed PHP 4 compatibility - it runs now on PHP4 again.
-Fixed bug #648: [Survey at Runtime] Bypass mandatory question (c_schmitz)
-Fixed bug #676: [Survey at Runtime] Only Answers of first two groups saved in database (c_schmitz)
-Fixed bug #673: [Survey at Runtime] Error when: Testing Survey --> Exit --> Restart this Survey (machaven)
-Fixed bug #672: [Import / Export] Label set administration - Export/Import (c_schmitz)
-Fixed bug #597: [Import / Export] SPSS export (machaven)
-Fixed bug #493: [Import / Export] SPSS buggy (need change) (machaven)
-Fixed bug #669: [Survey at Runtime] Questions not displayed when survey is Group by Group and condition question is in a previous group (c_schmitz)
-Fixed bug #671: [Installation] new Installation: failure common.php on line 3122 (c_schmitz)
-Fixed bug #670: [Import / Export] Import survey v1.00 in v1.45 fails (c_schmitz)
-Fixed bug #667: [Survey at Runtime] Error when editing responses via direct link from e-mail (lemeur)
-Fixed bug #668: [Survey at Runtime] Invalid query created when only questions in group are conditional (c_schmitz)
-Fixed bug #604: [Survey Design] Shading of Array Flexible Labels (by Column) not working correctly when you have an odd number of answers (c_schmitz)
-Fixed bug #545: [Survey Design] Using default (c_schmitz)
-Fixed bug #643: [Statistics] Huge text Counts are not being calculated (machaven)
-Fixed bug #589: [Survey Design] Change from list to radio deletes answers (c_schmitz)
-Fixed bug #579: [Data Entry (non public)] Answer not saved (machaven)
-Fixed bug #612: [Survey at Runtime] Wrong database table name used in admin/dataentry.php (c_schmitz)
... and numerous small changes and bug fixes by lemeur, ferrisoxide, b00z00, machaven and c_schmitz


Changes from 1.0 to 1.45a

Changes from 1.46b to 1.47b - Release Date: 2007/03/14


- Fixed Export button target in statistics (lemeur)
- SPSS export updated (machaven)
- Reworked the token import to being more stable (machaven)
- Reworked the Excel import to be OpenOffice.org compatible
- MySQL now correctly handles utf-8 chars (Please re-install to fix this) (machaven & c_schmitz)
- Added a setting to config.php to manage the maximum session time (c_schmitz)
- Added a proper error message when taking a survey and the session is timing out for any reason (c_schmitz)
- Fixed bug #689: [Security] Memory size error (machaven)
- Fixed bug #703: [Survey at Runtime] Another infamous single quote issue in labels (lemeur)
- Fixed bug #575: [Import / Export] Export to Excel: Umlaute (c_schmitz)
- Fixed bug #632: [Import / Export] Exporting to MS Word - fields and answers not matched up (c_schmitz)
- Fixed bug #656: [Assessments] Assessments don't work properly; HTML source code shows wrong calculation results (c_schmitz)
- Fixed bug #690: [Statistics] Firefox-Problem: No "Show Statistic"-Button and some questions are not displayed (c_schmitz)
- Fixed bug #678: [Statistics] Filter in Statistic-Screens displays Questions without Order (lemeur)
- Fixed bug #636: [Survey at Runtime] Session Time-out Issues (c_schmitz)
- Fixed bug #688: [Survey Design] Labelset administration wrong import type shown (c_schmitz)
- Fixed bug #685: [Installation] Installation in existing MySQL DB (c_schmitz)
- Fixed bug #680: [Translation] Language Switch type question doesn't totally swicth (c_schmitz)
- Fixed bug #683: [Survey Design] Import of groups (c_schmitz)
- Fixed bug #684: [Survey Design] Import of groups (c_schmitz)


... and numerous small changes, translations and bug fixes by gasper_koren, lemeur, ferrisoxide, b00z00, machaven and c_schmitz





Changes from 1.0 to 1.46b - Release Date: 2007/03/03
- Added captcha feature to prevent automatic registering (machaven)
- Import tokens from LDAP queries (tlemeur)
- Added support for Microsoft SQL Server database (ferrisoxide)
- Improved multi-db support (ferrisoxide)
Expand Down

0 comments on commit 85e5851

Please sign in to comment.