Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pbchase committed Oct 9, 2020
2 parents 7b908a0 + 16c80b1 commit be3ae04
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 58 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log
All notable changes to the Auto-Populate Fields project will be documented in this file.


## [2.6.0] - 2020-10-09
### Changed
- Upgrade test_project to enable surveys (Kyle Chesney)
- Explicitly check that field to hide is present in a form prevents bug on multipage forms in surveys. (Kyle Chesney)

### Added
- Add support for Surveys (Kyle Chesney)


## [2.5.2] - 2020-08-21
### Changed
- Added a element check to prevent attempting to hide nonexistent elements (James Pence)
Expand Down
18 changes: 17 additions & 1 deletion ExternalModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* ExternalModule class for Auto Populate Fields.
*/
class ExternalModule extends AbstractExternalModule {
private $survey_APF_fields = [];

/**
* @inheritdoc
Expand All @@ -30,7 +31,7 @@ function redcap_every_page_top($project_id) {
if (PAGE == 'Design/online_designer.php') {
$this->includeJs('js/helper.js');
}
elseif ( (PAGE == 'DataEntry/index.php' || PAGE == 'surveys/index.php') && !empty($_GET['id'])) {
elseif ( (PAGE == 'DataEntry/index.php' || PAGE == 'surveys/index.php') && !empty($_GET['id']) ) {
if (!$this->currentFormHasData()) {
$this->setDefaultValues();
}
Expand All @@ -41,6 +42,20 @@ function redcap_every_page_top($project_id) {
}
}

function redcap_survey_page_top($project_id) {
if ( !$this->getProjectSetting('use_in_survey') ) return;
global $elements;
// set the action_tag_class as it would be in the DataEntry context
foreach( $elements as &$element) {
$i = array_search($element['name'], $this->survey_APF_fields);
if ( $i !== false ) {
$element['action_tag_class'] = '@DEFAULT';
unset($this->survey_APF_fields[$i]);
if ( empty($this->survey_APF_fields) ) break;
}
}
}

/**
* Extends @DEFAULT action tag.
*
Expand Down Expand Up @@ -229,6 +244,7 @@ function setDefaultValues() {
// The first non empty default value wins!
$misc = $this->overrideActionTag('@DEFAULT', $default_value, $misc);
$aux_metadata[$field_name]['misc'] = $misc;
array_push($this->survey_APF_fields, $field_name);

break;
}
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.0
6 changes: 6 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"permissions": [
"redcap_every_page_top",
"redcap_survey_page_top",
"redcap_module_system_enable",
"redcap_module_system_change_version"
],
Expand All @@ -28,6 +29,11 @@
}
],
"project-settings": [
{
"key": "use_in_survey",
"name": "Enable Auto Populate Fields on survey pages",
"type": "checkbox"
},
{
"key": "chronological_previous_event",
"name": "Enable chronological previous event detection (useful when the events are not necessarily arranged in a chronological order)",
Expand Down
Loading

0 comments on commit be3ae04

Please sign in to comment.