Revision: 3124
http://limesurvey.svn.sourceforge.net/limesurvey/?rev=3124&view=rev
Author: leochaton
Date: 2007-07-26 09:59:11 -0700 (Thu, 26 Jul 2007)
Log Message:
-----------
Fix: 0001109: Importing suvey fails
-The importing is not case sensitive, but gives a warning if the question type is lowercase.
-If the type is not in the getqtypelist a warning is issued and the question is not imported.
-The importing summary shows the actual number of questions imported.
I'm not sure about the messages, please try it with the survey file in the bug report to verify. Thanks.
Modified Paths:
--------------
source/limesurvey/admin/importsurvey.php
Modified: source/limesurvey/admin/importsurvey.php
===================================================================
--- source/limesurvey/admin/importsurvey.php 2007-07-25 21:31:58 UTC (rev 3123)
+++ source/limesurvey/admin/importsurvey.php 2007-07-26 16:59:11 UTC (rev 3124)
@@ -34,6 +34,7 @@
#############################################################
*/
//Ensure script is not run directly, avoid path disclosure
+//importsurvey.php should be called from cmdline_importsurvey.php or http_importsurvey.php, they set the $importingfrom variable
if (!isset($importingfrom)) {die ("Cannot run this script directly");}
$handle = fopen($the_full_file_path, "r");
@@ -651,6 +652,9 @@
}
}
+$importwarning = ""; // used to save the warnings while processing questions
+$qtypes = getqtypelist("" ,"array");
+
// DO GROUPS, QUESTIONS FOR GROUPS, THEN ANSWERS FOR QUESTIONS IN A NESTED FORMAT!
if (isset($grouparray) && $grouparray) {
$count=0;
@@ -718,16 +722,32 @@
if ($count==0) {$count++; continue;}
}
else
- {
- $qafieldorders=convertToArray($qa, "`, `", "(`", "`)");
- $qacfieldcontents=convertToArray($qa, "', '", "('", "')");
- }
- $questionrowdata=array_combine($qafieldorders,$qacfieldcontents);
+ {
+ $qafieldorders=convertToArray($qa, "`, `", "(`", "`)");
+ $qacfieldcontents=convertToArray($qa, "', '", "('", "')");
+ }
+ $questionrowdata=array_combine($qafieldorders,$qacfieldcontents);
$questionrowdata=array_map('convertCsvreturn2return', $questionrowdata);
if ($currentqid=='' || ($currentqid!=$questionrowdata['qid'])) {$currentqid=$questionrowdata['qid'];$newquestion=true;}
else
- if ($currentqid==$questionrowdata['qid']) {$newquestion=false;}
+ if ($currentqid==$questionrowdata['qid']) {$newquestion=false;}
+ if (!array_key_exists($questionrowdata["type"], $qtypes))
+ {
+ $questionrowdata["type"] = strtoupper($questionrowdata["type"]);
+ if (!array_key_exists($questionrowdata["type"], $qtypes))
+ {
+ $importwarning .= "<li>" . $clang->gT("Question") . " \"{$questionrowdata["title"]} - {$questionrowdata["question"]}\" " . $clang->gT("was NOT imported, because the question type is not know") . "</li>";
+ $countquestions--;
+ continue;
+ }
+ else // the upper case worked well
+ {
+ $importwarning .= "<li>" . $clang->gT("Question") . " \"{$questionrowdata["title"]} - {$questionrowdata["question"]}\" " . $clang->gT("was imported, but the type was set to \"" . $qtypes[$questionrowdata["type"]] . "\", because is the closest one") . "</li>";
+ }
+ }
+
+
$thisgid=$questionrowdata['gid'];
if ($thisgid == $gid) {
$qid = $questionrowdata['qid'];
@@ -1023,6 +1043,7 @@
$importsurvey .= "\t<li>".$clang->gT("Assessments").": $countassessments</li>\n</ul>\n";
$importsurvey .= "<strong>".$clang->gT("Import of Survey is completed.")."</strong><br />\n";
+ if ($importwarning != "") $importsurvey .= "<br><strong>".$clang->gT("Warnings").":</strong><br><ul style=\"text-align:left;\">" . $importwarning . "</ul><br>\n";
$importsurvey .= "</td></tr></table><br />\n";
unlink($the_full_file_path);
unset ($surveyid); // Crazy but necessary because else the html script will search for user rights
@@ -1045,6 +1066,8 @@
echo $clang->gT("Assessments").": $countassessments\n\n";
echo $clang->gT("Import of Survey is completed.")."\n";
+ if ($importwarning != "") echo "\n".$clang->gT("Warnings").":\n" . $importwarning . "\n";
+
}
function convertToArray($stringtoconvert, $seperator, $start, $end)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|