Skip to content

Commit

Permalink
Fixed issue #16123: TSV export does not properly export a single grou…
Browse files Browse the repository at this point in the history
…p/question/answer option etc.

Dev Hack to fix at least the single group problem as this would be most common.
  • Loading branch information
c-schmitz committed Apr 10, 2020
1 parent edc0e38 commit 5a57e49
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions application/helpers/export_helper.php
Expand Up @@ -2503,6 +2503,7 @@ function tsvSurveyExport($surveyid){
$language_data = array();
}

// Converting the XML to array has the disadvantage that if only there is one child it will not be properly nested in the array
if (!array_key_exists('surveyls_language', $language_data[0])){
$language_data[0]['surveyls_language'] = $aSurveyLanguages[0];
}
Expand Down Expand Up @@ -2563,10 +2564,24 @@ function tsvSurveyExport($surveyid){
foreach ($aSurveyLanguages as $key => $language) {
// groups data
if (array_key_exists('groups', $xmlData)){
debugbreak();
// Converting the XML to array has the disadvantage that if only there is one child it will not be properly nested in the array
if (!array_key_exists('gid', $xmlData['groups']['rows']['row'][0])){
$aSaveData=$xmlData['groups']['rows']['row'];
unset($xmlData['groups']['rows']['row']);
$xmlData['groups']['rows']['row'][0] = $aSaveData;
}

foreach($xmlData['groups']['rows']['row'] as $group){
$groups_data[$group['gid']] = $group;
}

// Converting the XML to array has the disadvantage that if only there is one child it will not be properly nested in the array
if (!array_key_exists('gid', $xmlData['group_l10ns']['rows']['row'][0])){
$aSaveData=$xmlData['group_l10ns']['rows']['row'];
unset($xmlData['group_l10ns']['rows']['row']);
$xmlData['group_l10ns']['rows']['row'][0] = $aSaveData;
}
foreach($xmlData['group_l10ns']['rows']['row'] as $group_l10ns){
$groups[$language][$group_l10ns['gid']] = array_merge($group_l10ns, $groups_data[$group_l10ns['gid']]);
}
Expand Down

0 comments on commit 5a57e49

Please sign in to comment.