Skip to content

Commit

Permalink
Fixed issue #TSV export/import multiple with other add a other sub-qu…
Browse files Browse the repository at this point in the history
…estion

Dev: fix importing
  • Loading branch information
Shnoulle committed Feb 19, 2015
1 parent 5828e20 commit faa1ff0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions application/helpers/admin/import_helper.php
Expand Up @@ -4865,7 +4865,7 @@ function TSVImportSurvey($sFullFilePath)
$surveyinfo['active']='N';
// unset($surveyinfo['datecreated']);
$iNewSID = Survey::model()->insertNewSurvey($surveyinfo) ; //or safeDie($clang->gT("Error").": Failed to insert survey<br />");
if ($iNewSID==false)
if (!$iNewSID)
{
$results['error'] = Survey::model()->getErrors();
$results['bFailed'] = true;
Expand Down Expand Up @@ -4984,7 +4984,7 @@ function TSVImportSurvey($sFullFilePath)
$insertdata['help'] = (isset($row['help']) ? $row['help'] : '');
$insertdata['language'] = (isset($row['language']) ? $row['language'] : $baselang);
$insertdata['mandatory'] = (isset($row['mandatory']) ? $row['mandatory'] : '');
$insertdata['other'] = (isset($row['other']) ? $row['other'] : 'N');
$lastother=$insertdata['other'] = (isset($row['other']) ? $row['other'] : 'N');
$insertdata['same_default'] = (isset($row['same_default']) ? $row['same_default'] : 0);
$insertdata['parent_qid'] = 0;

Expand Down Expand Up @@ -5077,17 +5077,17 @@ function TSVImportSurvey($sFullFilePath)
$results['defaultvalues']++;
}
break;

case 'SQ':
$sqname = (isset($row['name']) ? $row['name'] : 'SQ' . $sqseq);
if ($qtype == 'O' || $qtype == '|')
{
; // these are fake rows to show naming of comment and filecount fields
}
elseif ($sqname == 'other' && ($qtype == '!' || $qtype == 'L'))
elseif ($sqname == 'other' && $lastother=="Y") // If last question have other to Y : it's not a real SQ row
{
if($qtype=="!" || $qtype=="L")
{
// only want to set default value for 'other' in these cases - not a real SQ row
// TODO - this isn't working
// only used to set default value for 'other' in these cases
if (isset($row['default']))
{
$insertdata=array();
Expand All @@ -5096,12 +5096,14 @@ function TSVImportSurvey($sFullFilePath)
$insertdata['language'] = (isset($row['language']) ? $row['language'] : $baselang);
$insertdata['defaultvalue'] = $row['default'];
$result = DefaultValue::model()->insertRecords($insertdata);
if(!$result){
if(!$result)
{
$results['importwarnings'][] = $clang->gT("Warning")." : ".$clang->gT("Failed to insert default value").". ".$clang->gT("Text file row number ").$rownumber;
break;
}
$results['defaultvalues']++;
}
}
}
else
{
Expand Down

1 comment on commit faa1ff0

@Shnoulle
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.