Skip to content

Commit 97f87c2

Browse files
committed
api config setting
1 parent 8a3e896 commit 97f87c2

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Multilingual.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
class Multilingual extends AbstractExternalModule
99
{
1010
function redcap_survey_page($project_id, $record, $instrument){
11-
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, 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_survey.js')))) . '</script>';
11+
$api_endpoint = $this->getProjectSetting('use-api-endpoint', $project_id);
12+
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true, ($api_endpoint == true ? true : false)), file_get_contents($this->getModulePath() . 'js/multilingual_survey.js')))) . '</script>';
1213
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css') . '">';
1314
}
1415

1516
function redcap_survey_complete($project_id, $record, $instrument){
16-
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_survey_complete.js'))) . '</script>';
17+
$api_endpoint = $this->getProjectSetting('use-api-endpoint', $project_id);
18+
echo '<script type="text/javascript">' . str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true, ($api_endpoint == true ? true : false)), file_get_contents($this->getModulePath() . 'js/multilingual_survey_complete.js'))) . '</script>';
1719
}
1820

1921
function redcap_data_entry_form($project_id, $record, $instrument){
@@ -22,6 +24,8 @@ function redcap_data_entry_form($project_id, $record, $instrument){
2224
}
2325

2426
function redcap_every_page_top($project_id){
27+
$api_endpoint = $this->getProjectSetting('use-api-endpoint', $project_id);
28+
2529
if(strpos($_SERVER['REQUEST_URI'], 'online_designer.php') !== false && isset($_GET['page'])){
2630
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css') . '">';
2731
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_setup.js'))) . '</script>';
@@ -30,8 +34,8 @@ function redcap_every_page_top($project_id){
3034
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>';
3135
}
3236
elseif($_GET['__return'] == 1){
33-
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, 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_survey_return.js')))) . '</script>';
34-
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css') . '">';
37+
echo '<script type="text/javascript">' . str_replace('APP_PATH_IMAGES', APP_PATH_IMAGES, str_replace('REDCAP_LANGUAGE_VARIABLE', $this->languageVariable($project_id), str_replace('REDCAP_AJAX_URL', $this->getUrl("index.php", true, ($api_endpoint == true ? true : false)), file_get_contents($this->getModulePath() . 'js/multilingual_survey_return.js')))) . '</script>';
38+
echo '<link rel="stylesheet" type="text/css" href="' . $this->getUrl('css/multilingual.css', true, ($api_endpoint == true ? true : false)) . '">';
3539
}
3640
}
3741

config.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
"no-auth-pages": [
4545
"index"
4646
],
47+
48+
"system-settings": [
49+
{
50+
"key": "use-api-endpoint",
51+
"name": "<b>Use API endpoint for public surveys</b>",
52+
"type": "checkbox"
53+
}
54+
],
4755

4856
"project-settings": [
4957
{

0 commit comments

Comments
 (0)