Skip to content

Commit

Permalink
Further clarification between multiple option types and other multipl…
Browse files Browse the repository at this point in the history
…e answer questions. Also now does not import conditions that don't have a matching qid.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@930 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Feb 22, 2004
1 parent 644a949 commit 26ee8dc
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions admin/importsurvey.php
Expand Up @@ -299,7 +299,6 @@
}
}
}

// DO GROUPS, QUESTIONS FOR GROUPS, THEN ANSWERS FOR QUESTIONS IN A NESTED FORMAT!
if ($grouparray) {
foreach ($grouparray as $ga) {
Expand Down Expand Up @@ -359,6 +358,7 @@
}
}
$newrank=0;
$substitutions[]=array($oldsid, $oldgid, $oldqid, $newsid, $newgid, $newqid);
//NOW DO NESTED ANSWERS FOR THIS QID
if ($answerarray) {
foreach ($answerarray as $aa) {
Expand Down Expand Up @@ -430,13 +430,11 @@
"newfieldname"=>$newsid."X".$newgid."X".$newqid."comment");
}
}
$substitutions[]=array($oldsid, $oldgid, $oldqid, $newsid, $newgid, $newqid);
} else {
$fieldnames[]=array("oldcfieldname"=>$oldsid."X".$oldgid."X".$oldqid,
"newcfieldname"=>$newsid."X".$newgid."X".$newqid,
"oldfieldname"=>$oldsid."X".$oldgid."X".$oldqid,
"newfieldname"=>$newsid."X".$newgid."X".$newqid);
$substitutions[]=array($oldsid, $oldgid, $oldqid, $newsid, $newgid, $newqid);
}
}
}
Expand All @@ -445,7 +443,6 @@
}
//We've built two arrays along the way - one containing the old SID, GID and QIDs - and their NEW equivalents
//and one containing the old 'extended fieldname' and its new equivalent. These are needed to import conditions.

if (isset($conditionsarray) && $conditionsarray) {//ONLY DO THIS IF THERE ARE CONDITIONS!
foreach ($conditionsarray as $car) {
$fieldorders=convertToArray($car, "`, `", "(`", "`)");
Expand All @@ -455,22 +452,37 @@
$oldqid=$fieldcontents[array_search("qid", $fieldorders)];
$oldcfieldname=$fieldcontents[array_search("cfieldname", $fieldorders)];
$oldcqid=$fieldcontents[array_search("cqid", $fieldorders)];
$thisvalue=$fieldcontents[array_search("value", $fieldorders)];
foreach ($substitutions as $subs) {
if ($oldqid==$subs[2]) {$newqid=$subs[5];}
if ($oldcqid==$subs[2]) {$newcqid=$subs[5];}
}
foreach($fieldnames as $fns) {
if ($oldcfieldname==$fns['oldcfieldname']) {$newcfieldname=$fns['newcfieldname'];}
//if the $fns['oldcfieldname'] is not the same as $fns['oldfieldname'] then this is a multiple type question
if ($fns['oldcfieldname'] == $fns['oldfieldname']) { //The normal method - non multiples
if ($oldcfieldname==$fns['oldcfieldname']) {
$newcfieldname=$fns['newcfieldname'];
}
} else {
if ($oldcfieldname == $fns['oldcfieldname'] && $oldcfieldname.$thisvalue == $fns['oldfieldname']) {
$newcfieldname=$fns['newcfieldname'];
}
}
}
if (!isset($newcfieldname)) {$newcfieldname="";}
$newfieldcontents[array_search("cid", $fieldorders)]="";
$newfieldcontents[array_search("qid", $fieldorders)]=$newqid;
$newfieldcontents[array_search("cfieldname", $fieldorders)]=$newcfieldname;
$newfieldcontents[array_search("cqid", $fieldorders)]=$newcqid;
$newvalues="('".implode("', '", $newfieldcontents)."')";
$insert=str_replace("('".implode("', '", $fieldcontents)."')", $newvalues, $car);
$insert=str_replace("INTO conditions", "INTO {$dbprefix}conditions", $insert);
$result=mysql_query($insert) or die ("Couldn't insert condition<br />$insert<br />".mysql_error());
if (isset($newcqid)) {
$newfieldcontents[array_search("cqid", $fieldorders)]=$newcqid;
$newvalues="('".implode("', '", $newfieldcontents)."')";
$insert=str_replace("('".implode("', '", $fieldcontents)."')", $newvalues, $car);
$insert=str_replace("INTO conditions", "INTO {$dbprefix}conditions", $insert);
$result=mysql_query($insert) or die ("Couldn't insert condition<br />$insert<br />".mysql_error());
} else {
echo "<font size=1>Condition for $oldqid skipped ($oldcqid does not exist)</font><br />";
}
unset($newcqid);
}
}

Expand Down

0 comments on commit 26ee8dc

Please sign in to comment.