Skip to content

Commit

Permalink
Fixed issue #4996: Conditions based on Token attributes are exported …
Browse files Browse the repository at this point in the history
…in xml but aren't imported. (Bug kindly analysed by yohann)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@9851 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Thibault Le Meur committed Mar 7, 2011
1 parent 27ab7c2 commit ae9f359
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions admin/import_functions.php
Expand Up @@ -1409,30 +1409,39 @@ function XMLImportSurvey($sFullFilepath,$sXMLdata=NULL,$sNewSurveyName=NULL,$iDe
$insertdata['qid']=$aQIDReplacements[$insertdata['qid']]; // remap the qid
}
else continue; // a problem with this answer record -> don't consider
if (isset($aQIDReplacements[$insertdata['cqid']]))
if ($insertdata['cqid'] != 0)
{
$insertdata['cqid']=$aQIDReplacements[$insertdata['cqid']]; // remap the qid
}
else continue; // a problem with this answer record -> don't consider

list($oldcsid, $oldcgid, $oldqidanscode) = explode("X",$insertdata["cfieldname"],3);
if (isset($aQIDReplacements[$insertdata['cqid']]))
{
$insertdata['cqid']=$aQIDReplacements[$insertdata['cqid']]; // remap the qid
}
else continue; // a problem with this answer record -> don't consider

// 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;
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;
}

unset($insertdata["cid"]);

// recreate the cfieldname with the new IDs
if (preg_match("/^\+/",$oldcsid))
if ($insertdata['cqid'] != 0)
{
$newcfieldname = '+'.$newsid . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] .substr($oldqidanscode,strlen($oldqid));
if (preg_match("/^\+/",$oldcsid))
{
$newcfieldname = '+'.$newsid . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] .substr($oldqidanscode,strlen($oldqid));
}
else
{
$newcfieldname = $newsid . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] .substr($oldqidanscode,strlen($oldqid));
}
}
else
{
$newcfieldname = $newsid . "X" . $aGIDReplacements[$oldcgid] . "X" . $insertdata["cqid"] .substr($oldqidanscode,strlen($oldqid));
{ // The cfieldname is a not a previous question cfield but a {XXXX} replacement field
$newcfieldname = $insertdata["cfieldname"];
}

$insertdata["cfieldname"] = $newcfieldname;
if (trim($insertdata["method"])=='')
{
Expand Down

0 comments on commit ae9f359

Please sign in to comment.