From 41fae46617f678d201e1704b341816f022b03da1 Mon Sep 17 00:00:00 2001 From: regisoc Date: Sun, 17 Nov 2024 17:11:12 -0500 Subject: [PATCH] redcap - phan --- .../redcapconfigurationparser.class.inc | 13 ++++++++----- .../redcapnotificationhandler.class.inc | 2 +- modules/redcap/php/redcaphttpclient.class.inc | 12 ++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/redcap/php/configurations/redcapconfigurationparser.class.inc b/modules/redcap/php/configurations/redcapconfigurationparser.class.inc index 318cd18c2fa..2a275859778 100644 --- a/modules/redcap/php/configurations/redcapconfigurationparser.class.inc +++ b/modules/redcap/php/configurations/redcapconfigurationparser.class.inc @@ -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." ); @@ -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 diff --git a/modules/redcap/php/notifications/redcapnotificationhandler.class.inc b/modules/redcap/php/notifications/redcapnotificationhandler.class.inc index 9bf81d8fb7a..c725f9736dd 100644 --- a/modules/redcap/php/notifications/redcapnotificationhandler.class.inc +++ b/modules/redcap/php/notifications/redcapnotificationhandler.class.inc @@ -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 diff --git a/modules/redcap/php/redcaphttpclient.class.inc b/modules/redcap/php/redcaphttpclient.class.inc index 326de8f6680..c2d4afdc4c2 100644 --- a/modules/redcap/php/redcaphttpclient.class.inc +++ b/modules/redcap/php/redcaphttpclient.class.inc @@ -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); }