View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
04996Bug reportsImport/Exportpublic2011-03-10 12:28
Reporteryohann Assigned Tolemeur  
PriorityhighSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.91RC4 
Fixed in Version1.91RC5 
Summary04996: Conditions based on Token attributes are exported in xml but aren't imported
Description

condition based on token:attribute_1 == constant aren't imported, export give the fallowing:
<row>
<cid><![CDATA[215]]></cid>
<qid><![CDATA[56]]></qid>
<scenario><![CDATA[1]]></scenario>
<cqid><![CDATA[0]]></cqid>
<cfieldname><![CDATA[{TOKEN:ATTRIBUTE_1}]]></cfieldname>
<method><![CDATA[==]]></method>
<value><![CDATA[Auto-Répondant]]></value>
</row>
but once imported, the condition dispear

Steps To Reproduce

create a condition based on token:attribute
export survey
check lss file : the condition is here
import lss file : the condition isn't here anymore

TagsNo tags attached.
Attached Files
import_function.patch (2,023 bytes)   
--- import_functions.php.orig	2011-03-03 16:05:27.801926002 +0100
+++ import_functions.php	2011-03-03 16:34:45.301926002 +0100
@@ -1404,7 +1404,7 @@
                 $insertdata[(string)$key]=(string)$value;
             }
             // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
-            if (isset($aQIDReplacements[$insertdata['qid']]))
+            if (isset($aQIDReplacements[$insertdata['qid']]) )
             {
                 $insertdata['qid']=$aQIDReplacements[$insertdata['qid']]; // remap the qid
             }
@@ -1412,11 +1412,18 @@
             if (isset($aQIDReplacements[$insertdata['cqid']]))
             {
                 $insertdata['cqid']=$aQIDReplacements[$insertdata['cqid']]; // remap the qid
+                list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
+            }
+            elseif (strpos($insertdata['cfieldname'], 'TOKEN:ATTRIBUTE_') !== false)  // condition is valid but based on token attribute instead of previous question
+            {
+              // this is a bit dirty but i don't want to move to much of existing code so i do the sstuff here and then continue
+              $query=$connect->GetInsertSQL($tablename,$insertdata);
+              $result=$connect->Execute($query) or safe_die ($clang->gT("Error").": Failed to insert data<br />\$query<br />\n".$connect->ErrorMsg());
+              $results['conditions']++;
+              continue;
             }
             else continue; // a problem with this answer record -> don't consider
 
-            list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
-
             // replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
             if (!isset($aGIDReplacements[$oldcgid]))
                 continue;
import_function.patch (2,023 bytes)   
import_functions.patch (2,065 bytes)   
--- import_functions.php.orig	2011-03-03 16:05:27.801926002 +0100
+++ import_functions.php	2011-03-04 14:41:24.633098003 +0100
@@ -1404,7 +1404,7 @@
                 $insertdata[(string)$key]=(string)$value;
             }
             // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
-            if (isset($aQIDReplacements[$insertdata['qid']]))
+            if (isset($aQIDReplacements[$insertdata['qid']]) )
             {
                 $insertdata['qid']=$aQIDReplacements[$insertdata['qid']]; // remap the qid
             }
@@ -1412,11 +1412,19 @@
             if (isset($aQIDReplacements[$insertdata['cqid']]))
             {
                 $insertdata['cqid']=$aQIDReplacements[$insertdata['cqid']]; // remap the qid
+                list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
+            }
+            elseif (strpos($insertdata['cfieldname'], 'TOKEN:ATTRIBUTE_') !== false)  // condition is valid but based on token attribute instead of previous question
+            {
+              // this is a bit dirty but i don't want to move to much of existing code so i do the sstuff here and then continue
+              unset($insertdata["cid"]);
+              $query=$connect->GetInsertSQL($tablename,$insertdata);
+              $result=$connect->Execute($query) or safe_die ($clang->gT("Error").": Failed to insert data<br />\$query<br />\n".$connect->ErrorMsg());
+              $results['conditions']++;
+              continue;
             }
             else continue; // a problem with this answer record -> don't consider
 
-            list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
-
             // replace the gid for the new one in the cfieldname(if there is no new gid in the $aGIDReplacements array it means that this condition is orphan -> error, skip this record)
             if (!isset($aGIDReplacements[$oldcgid]))
                 continue;
import_functions.patch (2,065 bytes)   
Bug heat8
Complete LimeSurvey version number (& build)9716
I will donate to the project if issue is resolvedNo
Browserfirefox
Database type & version145
Server OS (if known)Linux (Ubuntu)
Webserver software & version (if known)apache2
PHP Version5.3.3-1ubuntu9.3 with Suhosin-Patch (cli) (built: Jan 12 2011 16:08:14)

Users monitoring this issue

limech

Activities

yohann

yohann

2011-03-03 16:45

reporter   ~14312

here is a patch (a bit dirty but works for me)

if cqid is 0 it doesn't just skip the condition, but instead look for "TOKEN_ATTRIBUTE" in cfiedname, if there is a string like that we insert conditions data and increment condition counter before we continue

yohann

yohann

2011-03-07 15:52

reporter   ~14317

Sorry about the first patch, i forgot to unsed cid so it works the first time, but fail once the id of condidion exists, the second patch is better (one line more which unset cid before insert condition in database)

lemeur

lemeur

2011-03-07 18:35

developer   ~14321

Fixed in rev 9851 and 9852.
Thx for the detailed anaylis of the pb.

c_schmitz

c_schmitz

2011-03-10 12:28

administrator   ~14379

1.91RC5 released.

Issue History

Date Modified Username Field Change
2011-03-03 15:59 yohann New Issue
2011-03-03 16:45 yohann Note Added: 14312
2011-03-03 16:45 yohann File Added: import_function.patch
2011-03-03 17:23 limech Issue Monitored: limech
2011-03-07 15:49 yohann Issue Monitored: yohann
2011-03-07 15:50 yohann File Added: import_functions.patch
2011-03-07 15:52 yohann Note Added: 14317
2011-03-07 15:53 yohann Issue End Monitor: yohann
2011-03-07 16:55 Mazi Assigned To => lemeur
2011-03-07 16:55 Mazi Status new => assigned
2011-03-07 18:35 lemeur Note Added: 14321
2011-03-07 18:35 lemeur Status assigned => resolved
2011-03-07 18:35 lemeur Fixed in Version => 1.91RC5
2011-03-07 18:35 lemeur Resolution open => fixed
2011-03-10 12:28 c_schmitz Note Added: 14379
2011-03-10 12:28 c_schmitz Status resolved => closed
2021-08-02 19:28 guest Bug heat 6 => 8