View Issue Details

This bug affects 1 person(s).
 14
IDProjectCategoryView StatusLast Update
04440Bug reportsSurvey editingpublic2010-07-06 12:30
Reporterlamjas Assigned Tomdekker  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.90RC1 
Fixed in Version1.90RC2 
Summary04440: Order is the opposite after importing a question group
Description

I have created two survey (A and B) in the latest release (1.90RCI).

In Survey A, I created a question group. I exported the group and imported it in Survey B.

During the import, an error occurred at the top of browser:

Warning: Invalid argument supplied for foreach() in /***/survey/admin/importgroup.php on line 1124

However, it still indicated that the import was successful. I found that the order of the questions are opposite (e.g. Q1, Q2, Q3 becomes Q3, Q2, Q1).

TagsNo tags attached.
Attached Files
importgroup.diff (1,424 bytes)   
### Eclipse Workspace Patch 1.0
#P limesurvey
Index: admin/importgroup.php
===================================================================
--- admin/importgroup.php	(revision 8860)
+++ admin/importgroup.php	(working copy)
@@ -969,14 +969,6 @@
     // then for subquestions (because we need to determine the new qids for the main questions first)
     $tablename=$dbprefix.'questions';
     $results['questions']=0;
-    $newquestionorder=$connect->GetOne("SELECT MAX(question_order) AS maxqo FROM ".db_table_name('questions')." WHERE sid=$newsid AND gid=$newgid")+1;
-    if (is_null($newquestionorder)) 
-    {
-        $newquestionorder=0;
-    }
-    else {
-        $newquestionorder++;
-    }
     foreach ($xml->questions->rows->row as $row)
     {
        $insertdata=array(); 
@@ -987,7 +979,6 @@
         $oldsid=$insertdata['sid'];
         $insertdata['sid']=$newsid;
         $insertdata['gid']=$aGIDReplacements[$insertdata['gid']];
-        $insertdata['question_order']=$newquestionorder;
         $oldqid=$insertdata['qid']; unset($insertdata['qid']); // save the old qid
 
         // now translate any links
@@ -1121,7 +1112,7 @@
     {
         $tablename=$dbprefix.'conditions';
         
-        foreach ($xml->defaultvalues->rows->row as $row)
+        foreach ($xml->conditions->rows->row as $row)
         {
            $insertdata=array(); 
             foreach ($row as $key=>$value)
importgroup.diff (1,424 bytes)   
Bug heat14
Complete LimeSurvey version number (& build)8819
I will donate to the project if issue is resolved
BrowserFirefox 3.6.3
Database type & versionMySQL 5.1.47
Server OS (if known)Linux
Webserver software & version (if known)Apache 2.2.15
PHP Version5.2.13

Relationships

has duplicate 04465 closedc_schmitz Defect 04440 recurrance after patching 
related to 04396 closedmdekker Unable to change order of groups after import 

Users monitoring this issue

dans

Activities

lamjas

lamjas

2010-06-23 08:25

reporter   ~12286

I tried to re-arrange the order, however it does not work at all.

mdekker

mdekker

2010-06-23 08:54

reporter   ~12288

Last edited: 2010-06-23 08:56

Can confirm this is an error by just looking at the code. If possible, could you change line 1124 in importgroup.php and check the results? The section reads:
<pre>
// Import conditions --------------------------------------------------------------
if(isset($xml->conditions))
{
$tablename=$dbprefix.'conditions';

    foreach ($xml->defaultvalues->rows->row as $row)

</pre>

The last row is 1124 and the defaultvalues should be changed to conditions

<pre>
// Import conditions --------------------------------------------------------------
if(isset($xml->conditions))
{
$tablename=$dbprefix.'conditions';

    foreach ($xml-><b>conditions</b>->rows->row as $row)

</pre>

mdekker

mdekker

2010-06-23 09:00

reporter   ~12289

Doesn't fix the ordering issue, but will fix the error. For the ordering you need another adjustment. I'll work on a patch and attach it here.

mdekker

mdekker

2010-06-23 09:16

reporter   ~12290

Attached a patch and fixed in svn 8865.

Issue History

Date Modified Username Field Change
2010-06-23 08:23 lamjas New Issue
2010-06-23 08:23 lamjas Status new => assigned
2010-06-23 08:23 lamjas Assigned To => user372
2010-06-23 08:25 lamjas Note Added: 12286
2010-06-23 08:54 mdekker Note Added: 12288
2010-06-23 08:55 mdekker Note Edited: 12288
2010-06-23 08:55 mdekker Note Edited: 12288
2010-06-23 08:55 mdekker Note Edited: 12288
2010-06-23 08:56 mdekker Note Edited: 12288
2010-06-23 09:00 mdekker Note Added: 12289
2010-06-23 09:02 mdekker Assigned To user372 => mdekker
2010-06-23 09:14 mdekker File Added: importgroup.diff
2010-06-23 09:16 mdekker Note Added: 12290
2010-06-23 09:16 mdekker Status assigned => resolved
2010-06-23 09:16 mdekker Fixed in Version => 1.90RC2
2010-06-23 09:16 mdekker Resolution open => fixed
2010-07-06 11:22 c_schmitz Status resolved => closed
2010-07-06 12:30 dans Issue Monitored: dans
2010-07-06 13:12 c_schmitz Relationship added has duplicate 04465
2010-07-13 01:33 Mazi Relationship added related to 04396
2010-10-25 00:17 c_schmitz Category Survey Design => Survey design
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing
2021-08-03 07:55 guest Bug heat 12 => 14