diff --git a/application/controllers/admin/surveyadmin.php b/application/controllers/admin/surveyadmin.php
index 9fa95d8d43d..357ee5d2006 100644
--- a/application/controllers/admin/surveyadmin.php
+++ b/application/controllers/admin/surveyadmin.php
@@ -941,7 +941,7 @@ public function copy()
unlink($sFullFilepath);
}
- if (isset($aImportResults['error']) && $aImportResults['error']) safeDie($aImportResults['error']);
+// if (isset($aImportResults['error']) && $aImportResults['error']) safeDie($aImportResults['error']);
if (!$aData['bFailed'])
{
diff --git a/application/helpers/admin/import_helper.php b/application/helpers/admin/import_helper.php
index f81a3bb309e..949f49a8c9e 100644
--- a/application/helpers/admin/import_helper.php
+++ b/application/helpers/admin/import_helper.php
@@ -4159,7 +4159,7 @@ function ExcelImportSurvey($sFullFilepath)
$results['error']=false;
$baselang = 'en'; // TODO set proper default
- try {
+// try {
$data = new Spreadsheet_Excel_Reader($sFullFilepath);
$adata = $data->dumptonamedarray();
@@ -4260,8 +4260,10 @@ function ExcelImportSurvey($sFullFilepath)
$baselang = $surveyinfo['language']; // the base language
}
+ $rownumber = 1;
foreach ($adata as $row)
{
+ $rownumber += 1;
$row = str_replace(chr(0xA0),' ',$row);
switch($row['class'])
{
@@ -4330,8 +4332,13 @@ function ExcelImportSurvey($sFullFilepath)
$insertdata['question_order'] = $qseq;
}
- $newqid = Questions::model()->insertRecords($insertdata) or safeDie ($clang->gT("Error").": Failed to insert question
");
+ $result = Questions::model()->insertRecords($insertdata); //or safeDie ($clang->gT("Error").": Failed to insert question
");
+ if(!$result){
+ $results['error'][] = $clang->gT("Error")." : ".$clang->gT("Could not insert question").". ".$clang->gT("Excel row number ").$rownumber." (".$qname.")";
+ break;
+ }
+ $newqid = $result;
if (!isset($qinfo[$qname]))
{
$results['questions']++;
@@ -4474,15 +4481,18 @@ function ExcelImportSurvey($sFullFilepath)
$insertdata['assessment_value'] = (isset($row['relevance']) ? $row['relevance'] : '');
$insertdata['sortorder'] = ++$aseq;
- $result = Answers::model()->insertRecords($insertdata) or safeDie("Error: Failed to insert answer
");
+ $result = Answers::model()->insertRecords($insertdata); // or safeDie("Error: Failed to insert answer
");
+ if(!$result){
+ $results['error'][] = $clang->gT("Error")." : ".$clang->gT("Could not insert answer").". ".$clang->gT("Excel row number ").$rownumber;
+ }
$results['answers']++;
break;
}
}
- }
- catch (Exception $e) {
- $results['error'] = $e->getMessage();
- }
+// }
+// catch (Exception $e) {
+// $results['error'] = $e->getMessage();
+// }
return $results;
}
\ No newline at end of file
diff --git a/application/models/Answers.php b/application/models/Answers.php
index 3678c3917fc..baf29eb5906 100644
--- a/application/models/Answers.php
+++ b/application/models/Answers.php
@@ -109,7 +109,14 @@ function insertRecords($data)
$ans = new self;
foreach ($data as $k => $v)
$ans->$k = $v;
- return $ans->save();
+ try
+ {
+ return $ans->save();
+ }
+ catch(Exception $e)
+ {
+ return false;
+ }
}
/**
diff --git a/application/models/Questions.php b/application/models/Questions.php
index 001da2311b5..b1a1f3fe4f2 100644
--- a/application/models/Questions.php
+++ b/application/models/Questions.php
@@ -208,8 +208,17 @@ function insertRecords($data)
$questions = new self;
foreach ($data as $k => $v)
$questions->$k = $v;
- if (!$questions->save()) return false;
- else return $questions->qid;
+// if (!$questions->save()) return false;
+// else return $questions->qid;
+ try
+ {
+ $questions->save();
+ return $questions->qid;
+ }
+ catch(Exception $e)
+ {
+ return false;
+ }
}
public static function deleteAllById($questionsIds)
diff --git a/application/views/admin/survey/importSurvey_view.php b/application/views/admin/survey/importSurvey_view.php
index 6d17ad76e74..b77315fc9d7 100644
--- a/application/views/admin/survey/importSurvey_view.php
+++ b/application/views/admin/survey/importSurvey_view.php
@@ -12,7 +12,16 @@