Skip to content

Commit

Permalink
New feature: Preserve response IDs when importing archived responses
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Nov 13, 2018
1 parent 4fd7187 commit c882d82
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions application/controllers/admin/dataentry.php
Expand Up @@ -271,6 +271,12 @@ public function import($surveyid)
'label' => gT('Import timings (if exist)')
);

$aData['settings']['preserveIDs'] = array(
'type' => 'checkbox',
'label' => gT('Preserve response IDs')
);


//Get the menubar
$aData['display']['menu_bars']['browse'] = gT("Quick statistics");
$survey = Survey::model()->findByPk($iSurveyId);
Expand Down Expand Up @@ -316,6 +322,10 @@ public function import($surveyid)
// Using plugindynamic model because I dont trust surveydynamic.
$targetResponse = new PluginDynamic("{{survey_$iSurveyId}}");

if (isset($_POST['preserveIDs']) && $_POST['preserveIDs'] == 1) {
$targetResponse->id=$sourceResponse->id;
}

foreach ($fieldMap as $sourceField => $targetField) {
$targetResponse[$targetField] = $sourceResponse[$sourceField];
}
Expand Down Expand Up @@ -378,7 +388,7 @@ protected function tableList($tables)
{
$list = array();
if (empty($tables)) {
$list['none'] = gT('No old responses found.');
$list['none'] = gT('No old responses found.','unescaped');
}

foreach ($tables as $table) {
Expand Down Expand Up @@ -2022,4 +2032,4 @@ protected function _renderWrappedTemplate($sAction = 'dataentry', $aViewUrls = a
parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData, $sRenderFile);
}

}
}

1 comment on commit c882d82

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great !

Please sign in to comment.