From c882d826ebcf9b18a360851ae44c2e4552a5c9e3 Mon Sep 17 00:00:00 2001 From: Carsten Schmitz Date: Tue, 13 Nov 2018 12:45:29 +0100 Subject: [PATCH] New feature: Preserve response IDs when importing archived responses --- application/controllers/admin/dataentry.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/application/controllers/admin/dataentry.php b/application/controllers/admin/dataentry.php index 52ad2f79040..3e3c1144048 100644 --- a/application/controllers/admin/dataentry.php +++ b/application/controllers/admin/dataentry.php @@ -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); @@ -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]; } @@ -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) { @@ -2022,4 +2032,4 @@ protected function _renderWrappedTemplate($sAction = 'dataentry', $aViewUrls = a parent::_renderWrappedTemplate($sAction, $aViewUrls, $aData, $sRenderFile); } -} +} \ No newline at end of file