Skip to content

Commit

Permalink
redcap - phan
Browse files Browse the repository at this point in the history
  • Loading branch information
regisoc committed Nov 17, 2024
1 parent c647fea commit 41fae46
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ class RedcapConfigurationParser
}

// multiple instances
$instances = [];
$instances = null;
if (array_key_exists(0, $redcap['instance'])) {
$instances = $redcap['instance'];
} else if (array_key_exists('url', $redcap['instance'])) {
// only one instances
$instances = [$redcap['instance']];
} else {
}

if (is_null($instances)) {
throw new \LorisException(
"[redcap][init] wrong REDCap instance structure in configuration."
);
Expand All @@ -206,18 +208,19 @@ class RedcapConfigurationParser
}

// multiple projects
$projects = [];
$projects = null;
if (array_key_exists(0, $instance['project'])) {
$projects = $instance['project'];
} else if (array_key_exists('projectID', $instance['project'])) {
// only one projects
$projects = [$instance['project']];
} else {
}

if (is_null($projects)) {
throw new \LorisException(
"[redcap][init] wrong REDCap configuration:"
." no projects for instance '$name'."
);

}

// add instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class RedcapNotificationHandler
}

// add the timestamp_stop in the values based on the last timestamp
if (!is_null($instrument_values['timestamp'])
if (isset($instrument_values['timestamp'])
&& !empty($instrument_values['timestamp'])
) {
// rename var to uniformize with other LORIS instruments
Expand Down
12 changes: 8 additions & 4 deletions modules/redcap/php/redcaphttpclient.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,16 @@ class REDCapHTTPClient

// data to send
$data = [
'content' => 'surveyLink',
'instrument' => $instrument,
'event' => $event,
'record' => $recordId,
'content' => 'surveyLink',
'instrument' => $instrument,
'event' => $event,
'record' => $recordId,
];

if (!is_null($repeatInstance)) {
$data['repeat_instance'] = $repeatInstance;
}

// send request
return $this->_sendRequest($data);
}
Expand Down

0 comments on commit 41fae46

Please sign in to comment.