Skip to content

Commit

Permalink
Fixed issue #15073: Cannot export data to SPSS if no participant tabl…
Browse files Browse the repository at this point in the history
…e exists
  • Loading branch information
c-schmitz committed Mar 2, 2020
1 parent f01b348 commit d1ebce2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions application/helpers/export_helper.php
Expand Up @@ -81,6 +81,7 @@ function strSplitUnicode($str, $l = 0)
function SPSSExportData($iSurveyID, $iLength, $na = '', $q = '\'', $header = false, $sLanguage = '')
{

$survey = Survey::model()->findByPk($iSurveyID);
// Build array that has to be returned
$fields = SPSSFieldMap($iSurveyID, 'V', $sLanguage);
// Now see if we have parameters for from (offset) & num (limit)
Expand All @@ -96,15 +97,17 @@ function SPSSExportData($iSurveyID, $iLength, $na = '', $q = '\'', $header = fal

foreach ($result as $row) {
// prepare the data for decryption
$oToken = Token::model($iSurveyID);
$oToken->setAttributes($row, false);
$oToken->decrypt();

$oResponse = Response::model($iSurveyID);
$oResponse->setAttributes($row, false);
$oResponse->decrypt();

$row = array_merge($oToken->attributes, $oResponse->attributes);
$row = $oResponse->attributes;

if ($survey->hasTokensTable) {
$oToken = Token::model($iSurveyID);
$oToken->setAttributes($row, false);
$oToken->decrypt();
$row = array_merge($oToken->attributes, $oResponse->attributes);
}

$rownr++;
if ($rownr == 1) {
Expand Down

0 comments on commit d1ebce2

Please sign in to comment.