Skip to content

Commit

Permalink
fix to enable import of answers from a different installation/version…
Browse files Browse the repository at this point in the history
… of LS
  • Loading branch information
alex committed Oct 2, 2013
1 parent bf6234b commit 4d7e209
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions application/helpers/admin/import_helper.php
Expand Up @@ -4195,6 +4195,36 @@ function CSVImportResponses($sFullFilepath,$iSurveyId,$aOptions=array())
if(in_array($sLemFieldName,$aCsvHeader)){
$aKeyForFieldNames[$sFieldName]=array_search($sLemFieldName,$aCsvHeader);
}
// as fallback just map questions in order of apperance
else
{
// find out where the answer data columns start in CSV
if( ! isset($csv_ans_start_index))
{
foreach($aCsvHeader as $i=>$name)
{
if(preg_match('/^\d+X\d+X\d+/', $name))
{
$ans_start_index = $i;
break;
}
}
}
// find out where the answer data columns start in destination table
if( ! isset($table_ans_start_index))
{
foreach($aRealFieldNames as $i=>$name)
{
if(preg_match('/^\d+X\d+X\d+/', $name))
{
$table_start_index = $i;
break;
}
}
}
// map answers in order
$aKeyForFieldNames[$sFieldName] = (array_search($sFieldName,$aRealFieldNames)-$table_ans_start_index) + $csv_ans_start_index;
}
}
}

Expand Down

0 comments on commit 4d7e209

Please sign in to comment.