Skip to content

Commit

Permalink
fix data export
Browse files Browse the repository at this point in the history
  • Loading branch information
smartinkc committed Sep 11, 2018
1 parent 0264bee commit 24b6a25
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Multilingual.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function redcap_every_page_top($project_id){
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php"), file_get_contents($this->getModulePath() . 'js/multilingual_setup.js'))) . '</script>';
}
elseif(strpos($_SERVER['REQUEST_URI'], 'DataExport/index.php') !== false){
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php"), file_get_contents($this->getModulePath() . 'js/multilingual_export.js'))) . '</script>';
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true), file_get_contents($this->getModulePath() . 'js/multilingual_export.js'))) . '</script>';
}
}

Expand Down Expand Up @@ -148,7 +148,7 @@ public function getTranslations($data, $projectSettings){

//$misc = explode("@", $row['misc']);
$misc = str_getcsv($row['misc'], '@');
$response['test'] = $misc;
//$response['test'] = $misc;

$response['all'][$row['field_name']] = $misc;
foreach($misc AS $key => $value){
Expand Down
14 changes: 9 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<?php
namespace CMH\Multilingual;

use ExternalModules\AbstractExternalModule;
use ExternalModules\ExternalModules;

$data = @$_POST['data'];

if(isset($data) && $data != ''){
$data = json_decode($data, true);

switch($data['todo']){
case 1:
\CMH\Multilingual\Multilingual::getTranslations($data, $module->getProjectSettings());
$module->getTranslations($data, $module->getProjectSettings());
break;
case 2:
\CMH\Multilingual\Multilingual::getAnswers($data);
$module->getAnswers($data);
break;
case 3:
$tmp = new \CMH\Multilingual\Multilingual();
$tmp->getSettings($data);
$module->getSettings($data);
break;
default:
exit;
}
}
elseif($_GET['todo'] == 2){
\CMH\Multilingual\Multilingual::exportData($_GET['pid'], $_GET['lang']);
$module->exportData($_GET['pid'], $_GET['lang']);
}

else{
Expand Down
12 changes: 7 additions & 5 deletions js/multilingual_survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,11 +498,13 @@
}

//set languages variable to current language
$('[name="' + settings['languages_variable']['value'] + '"] option').each(function(){
if($(this).text() == lang){
$(this).prop('selected', true);
}
});
if(settings['languages_variable'] && settings['languages_variable']['value']){
$('[name="' + settings['languages_variable']['value'] + '"] option').each(function(){
if($(this).text() == lang){
$(this).prop('selected', true);
}
});
}

getTranslations();
}
Expand Down

0 comments on commit 24b6a25

Please sign in to comment.