From 76c69069dd8117db06100135b570696178308250 Mon Sep 17 00:00:00 2001 From: "Scott J. Pearson" Date: Fri, 19 Feb 2021 13:03:39 -0600 Subject: [PATCH] 2.31.1 --- CareerDev.php | 23 +++- FlightTrackerExternalModule.php | 6 +- classes/Citation.php | 8 +- classes/Cohorts.php | 4 + classes/Crons.php | 18 ++- classes/Download.php | 24 +++- classes/Grant.php | 27 ++++ classes/NameMatcher.php | 15 ++- classes/Publications.php | 150 +++++++++++++++-------- classes/REDCapManagement.php | 77 +++++++++--- classes/Upload.php | 103 ++++++++++++---- cohorts/duplicate.php | 176 +++++++++++++++++++++++++++ cronLoad.php | 10 +- drivers/2m_updateExPORTER.php | 155 +++++++++++++++-------- drivers/2n_updateReporters.php | 82 +++++++++---- drivers/2q_refreshCohortProjects.php | 36 ++++++ mentor/index.php | 8 ++ mentor/index_complete.php | 7 ++ mentor/index_menteeview.php | 9 ++ mentor/index_mentorview.php | 6 + profile.php | 8 +- small_base.php | 35 +----- 22 files changed, 772 insertions(+), 215 deletions(-) create mode 100644 cohorts/duplicate.php create mode 100644 drivers/2q_refreshCohortProjects.php diff --git a/CareerDev.php b/CareerDev.php index 94be4e52..4385f637 100644 --- a/CareerDev.php +++ b/CareerDev.php @@ -10,7 +10,7 @@ class CareerDev { public static $passedModule = NULL; public static function getVersion() { - return "2.31.0"; + return "2.31.1"; } public static function getLockFile($pid) { @@ -555,6 +555,27 @@ public static function isTestGroup($pid) { return (SERVER_NAME == "redcap.vanderbilt.edu") && in_array($pid, [105963, 101785]); } + public static function duplicateAllSettings($srcPid, $destPid, $defaultSettings = []) { + if ($srcPid && $destPid) { + self::setPid($srcPid); + $module = self::getModule(); + $srcSettings = $module->getProjectSettings($srcPid); + $destSettings = $defaultSettings; + foreach ($srcSettings as $setting => $value) { + if (!$destSettings[$setting] && $value) { + $destSettings[$setting] = $value; + } + } + + foreach ($destSettings as $setting => $value) { + self::saveSetting($setting, $value, $destPid); + } + self::log("Copied ".count($destSettings)." settings from $srcPid to $destPid"); + } else { + throw new \Exception("Could not find source PID $srcPid or destination PID $destPid"); + } + } + public static function getMenu($menuName) { global $pid; $r = self::getREDCapDir(); diff --git a/FlightTrackerExternalModule.php b/FlightTrackerExternalModule.php index 7d4f07c2..9e81f957 100755 --- a/FlightTrackerExternalModule.php +++ b/FlightTrackerExternalModule.php @@ -530,7 +530,7 @@ private function copyFormData(&$completes, &$pidsUpdated, $forms, $sourceInfo, $ } function cron() { - \System::increaseMaxExecTime(14400); // 4 hours + \System::increaseMaxExecTime(28800); // 8 hours $this->setupApplication(); $pids = $this->framework->getProjectsWithModuleEnabled(); @@ -555,10 +555,11 @@ function cron() { $server = $this->getProjectSetting("server", $pid); $tokenName = $this->getProjectSetting("tokenName", $pid); $adminEmail = $this->getProjectSetting("admin_email", $pid); + $turnOffSet = $this->getProjectSetting("turn_off", $pid); $GLOBALS['namesForMatch'] = array(); CareerDev::setPid($pid); CareerDev::log("Using $tokenName $adminEmail", $pid); - if ($token && $server) { + if ($token && $server && !$turnOffSet) { # only have token and server in initialized projects $mgr = new CronManager($token, $server, $pid); if ($this->getProjectSetting("run_tonight", $pid)) { @@ -573,6 +574,7 @@ function cron() { CareerDev::log($this->getName().": cron run complete for pid $pid", $pid); } } + REDCapManagement::cleanupDirectory(APP_PATH_TEMP, "/RePORTER_PRJ/"); } function setupApplication() { diff --git a/classes/Citation.php b/classes/Citation.php index 99cb0cb4..dded70b2 100644 --- a/classes/Citation.php +++ b/classes/Citation.php @@ -247,11 +247,15 @@ public function toHTML($citationClass) { } public function hasAuthor($name) { - list($firstName, $lastName) = NameMatcher::splitName($name); + list($firstName, $lastName) = NameMatcher::splitName($name, 2, isset($_GET['test'])); if ($lastName) { $authorList = $this->getAuthorList(); foreach ($authorList as $author) { + list($currFirstName, $currLastName) = NameMatcher::splitName($author, 2, isset($_GET['test'])); list($currFirstName, $currLastName) = NameMatcher::splitName($author); + if (isset($_GET['test'])) { + Application::log("Comparing $firstName $lastName against $currFirstName $currLastName"); + } if (NameMatcher::matchByInitials($currLastName, $currFirstName, $lastName, $firstName)) { return TRUE; } @@ -283,7 +287,7 @@ private function isAuthorIdx($pos, $name) { } $author = $authorList[$idx]; list($authorFirstName, $authorLastName) = NameMatcher::splitName($author); - if (NameMatcher::matchByInitials($authorFirstName, $authorLastName, $lastName, $firstName)) { + if (NameMatcher::matchByInitials($authorLastName, $authorFirstName, $lastName, $firstName)) { return TRUE; } return FALSE; diff --git a/classes/Cohorts.php b/classes/Cohorts.php index 91aac963..4b6298bb 100644 --- a/classes/Cohorts.php +++ b/classes/Cohorts.php @@ -23,6 +23,10 @@ public function __construct($token, $server, $moduleOrMetadata) { $this->configs = $this->getConfigs(); } + public function makeCohortsSelect($defaultCohort, $onchangeJS = "", $displayAllOption = FALSE) { + return $this->makeCohortSelect($defaultCohort, $onchangeJS, $displayAllOption); + } + public function makeCohortSelect($defaultCohort, $onchangeJS = "", $displayAllOption = FALSE) { $html = "

" + echo "

"; + echo ""; +} else { + echo "

Select a Cohort

"; + $link = CareerDev::link("cohorts/duplicate.php"); + echo "
"; + echo "

".$cohorts->makeCohortSelect("")."

"; + echo "

"; + echo "
"; +} diff --git a/cronLoad.php b/cronLoad.php index 16f1c418..e54ceff4 100644 --- a/cronLoad.php +++ b/cronLoad.php @@ -26,11 +26,8 @@ function loadCrons(&$manager, $specialOnly = FALSE, $token = "", $server = "") { $has = checkMetadataForFields($token, $server); $pid = CareerDev::getPid(); - if ($pid == 126829) { - $manager->addCron("drivers/2m_updateExPORTER.php", "updateExPORTER", "2021-02-10"); - $manager->addCron("drivers/2n_updateReporters.php", "updateReporter", "2021-02-10"); - } $manager->addCron("drivers/2m_updateExPORTER.php", "updateExPORTER", "Monday"); + $manager->addCron("drivers/2m_updateExPORTER.php", "updateExPORTER", "2021-02-17"); $manager->addCron("drivers/2n_updateReporters.php", "updateReporter", "Tuesday"); if ($has['coeus']) { // $manager->addCron("drivers/2o_updateCoeus.php", "processCoeus", "Thursday"); @@ -65,6 +62,11 @@ function loadCrons(&$manager, $specialOnly = FALSE, $token = "", $server = "") { if ($has['vfrs']) { $manager->addCron("drivers/11_vfrs.php", "updateVFRS", "Thursday"); } + + # Research in Medicine -> Projects for Divisions + if (CareerDev::isVanderbilt() && in_array($pid, [126297])) { + $manager->addCron("drivers/2q_refreshCohortProjects.php", "copyAllCohortProjects", "Saturday"); + } } echo $manager->getNumberOfCrons()." crons loaded\n"; } diff --git a/drivers/2m_updateExPORTER.php b/drivers/2m_updateExPORTER.php index e8f48779..e20f2169 100644 --- a/drivers/2m_updateExPORTER.php +++ b/drivers/2m_updateExPORTER.php @@ -68,16 +68,6 @@ function getExPORTERInstance($recordId, $redcapData, $upload, $uploadLine) { } function downloadURLAndUnzip($file) { - $baseName = preg_replace("/\.zip/", "", basename($file)); - $regex = "/".$baseName."/"; - if ($files = REDCapManagement::regexInDirectory($regex, APP_PATH_TEMP)) { - foreach ($files as $candidateFile) { - if (preg_match("/\.csv$/", $candidateFile)) { - return REDCapManagement::copyTempFileToTimestamp(APP_PATH_TEMP.$candidateFile, 4 * 3600); - } - } - } - CareerDev::log("Downloading $file..."); $url = "https://exporter.nih.gov/CSVs/final/".$file; @@ -154,45 +144,57 @@ function updateAbstracts($token, $server, $pid) { $records = Download::recordIds($token, $server); $files = []; $abstractFiles = []; - $lifespanOfFileInHours = 4; + $lifespanOfFileInHours = 12; # find relevant zips # download relevent zips into APP_PATH_TEMP # unzip zip files for ($year = 1985; $year <= date("Y"); $year++) { $url = "RePORTER_PRJ_C_FY".$year.".zip"; - $origFile = downloadURLAndUnzip($url); - if ($origFile) { - $file = REDCapManagement::copyTempFileToTimestamp($origFile, $lifespanOfFileInHours * 3600); + if ($file = searchForFileWithTimestamp($url)) { $files[$file] = $year; - unlink($origFile); + } else { + $origFile = downloadURLAndUnzip($url); + if ($origFile) { + $file = REDCapManagement::copyTempFileToTimestamp($origFile, $lifespanOfFileInHours * 3600); + $files[$file] = $year; + } } $abstractURL = "RePORTER_PRJABS_C_FY".$year.".zip"; - $origAbstractFile = downloadURLAndUnzip($abstractURL); - if ($origAbstractFile) { - $abstractFile = REDCapManagement::copyTempFileToTimestamp($origAbstractFile, $lifespanOfFileInHours * 3600); + if ($abstractFile = searchForFileWithTimestamp($abstractURL)) { $abstractFiles[$file] = $abstractFile; - unlink($origAbstractFile); + } else { + $origAbstractFile = downloadURLAndUnzip($abstractURL); + if ($origAbstractFile) { + $abstractFile = REDCapManagement::copyTempFileToTimestamp($origAbstractFile, $lifespanOfFileInHours * 3600); + $abstractFiles[$file] = $abstractFile; + } } } for ($year = date("Y") - 1; $year <= date("Y") + 1; $year++) { for ($week = 1; $week <= 53; $week++) { $weekWithLeading0s = sprintf('%03d', $week); $url = "RePORTER_PRJ_C_FY".$year."_".$weekWithLeading0s.".zip"; - $origFile = downloadURLAndUnzip($url); - if ($origFile) { - $file = REDCapManagement::copyTempFileToTimestamp($origFile, $lifespanOfFileInHours * 3600); + if ($file = searchForFileWithTimestamp($url)) { $files[$file] = $year; - unlink($origFile); + } else { + $origFile = downloadURLAndUnzip($url); + if ($origFile) { + $file = REDCapManagement::copyTempFileToTimestamp($origFile, $lifespanOfFileInHours * 3600); + $files[$file] = $year; + } } $abstractURL = "RePORTER_PRJABS_C_FY".$year."_".$weekWithLeading0s.".zip"; - $origAbstractFile = downloadURLAndUnzip($abstractURL); - if ($origAbstractFile) { - $abstractFile = REDCapManagement::copyTempFileToTimestamp($origAbstractFile, $lifespanOfFileInHours * 3600); + if ($abstractFile = searchForFileWithTimestamp($url)) { $abstractFiles[$file] = $abstractFile; - unlink($origAbstractFile); + } else { + $origAbstractFile = downloadURLAndUnzip($abstractURL); + if ($origAbstractFile) { + $abstractFile = REDCapManagement::copyTempFileToTimestamp($origAbstractFile, $lifespanOfFileInHours * 3600); + $abstractFiles[$file] = $abstractFile; + } } } } @@ -207,37 +209,53 @@ function updateExPORTER($token, $server, $pid, $records) { # find relevant zips # download relevent zips into APP_PATH_TEMP # unzip zip files - $lifespanOfFileInHours = 4; + $lifespanOfFileInHours = 12; for ($year = 1985; $year <= date("Y"); $year++) { $url = "RePORTER_PRJ_C_FY".$year.".zip"; - $file = downloadURLAndUnzip($url); - if ($file) { - $file = REDCapManagement::copyTempFileToTimestamp($file, $lifespanOfFileInHours * 3600); - $files[$file] = $year; - } + if ($file = searchForFileWithTimestamp($url)) { + $files[$file] = $year; + } else { + $file = downloadURLAndUnzip($url); + if ($file) { + $file = REDCapManagement::copyTempFileToTimestamp($file, $lifespanOfFileInHours * 3600); + $files[$file] = $year; + } + } $abstractURL = "RePORTER_PRJABS_C_FY".$year.".zip"; - $abstractFile = downloadURLAndUnzip($abstractURL); - if ($abstractFile) { - $abstractFile = REDCapManagement::copyTempFileToTimestamp($abstractFile, $lifespanOfFileInHours * 3600); + if ($abstractFile = searchForFileWithTimestamp($abstractURL)) { $abstractFiles[$file] = $abstractFile; + } else { + $abstractFile = downloadURLAndUnzip($abstractURL); + if ($abstractFile) { + $abstractFile = REDCapManagement::copyTempFileToTimestamp($abstractFile, $lifespanOfFileInHours * 3600); + $abstractFiles[$file] = $abstractFile; + } } } for ($year = date("Y") - 1; $year <= date("Y") + 1; $year++) { for ($week = 1; $week <= 53; $week++) { $weekWithLeading0s = sprintf('%03d', $week); $url = "RePORTER_PRJ_C_FY".$year."_".$weekWithLeading0s.".zip"; - $file = downloadURLAndUnzip($url); - if ($file) { - $file = REDCapManagement::copyTempFileToTimestamp($file, $lifespanOfFileInHours * 3600); - $files[$file] = $year; - } + if ($file = searchForFileWithTimestamp($url)) { + $files[$file] = $year; + } else { + $file = downloadURLAndUnzip($url); + if ($file) { + $file = REDCapManagement::copyTempFileToTimestamp($file, $lifespanOfFileInHours * 3600); + $files[$file] = $year; + } + } $abstractURL = "RePORTER_PRJABS_C_FY".$year."_".$weekWithLeading0s.".zip"; - $abstractFile = downloadURLAndUnzip($abstractURL); - if ($abstractFile) { - $abstractFile = REDCapManagement::copyTempFileToTimestamp($abstractFile, $lifespanOfFileInHours * 3600); + if ($abstractFile = searchForFileWithTimestamp($abstractURL)) { $abstractFiles[$file] = $abstractFile; + } else { + $abstractFile = downloadURLAndUnzip($abstractURL); + if ($abstractFile) { + $abstractFile = REDCapManagement::copyTempFileToTimestamp($abstractFile, $lifespanOfFileInHours * 3600); + $abstractFiles[$file] = $abstractFile; + } } } } @@ -289,7 +307,6 @@ function updateExPORTER($token, $server, $pid, $records) { fwrite($fp2, $line); } fclose($fp); - unlink($file); fclose($fp2); $fp2 = fopen($file2, "r"); @@ -401,7 +418,6 @@ function updateExPORTER($token, $server, $pid, $records) { CareerDev::log("Inspected $i lines"); echo "Inspected $i lines\n"; fclose($fp2); - unlink($file2); } # add newUploads to uploads @@ -444,15 +460,54 @@ function updateExPORTER($token, $server, $pid, $records) { // $mssg = "NIH Exporter run\n\n".count($upload)." rows\n".$output."\n\n"; // \REDCap::email($adminEmail, "no-reply@vanderbilt.edu", "CareerDev NIH Exporter", $mssg); - foreach ($abstractFiles as $projectFile => $abstractFile) { - unlink($abstractFile); - } - REDCapManagement::deduplicateByKey($token, $server, $pid, $records, "exporter_application_id", "exporter", "exporter"); CareerDev::saveCurrentDate("Last NIH ExPORTER Download", $pid); } +function getSuffix($file) { + $nodes = preg_split("/\./", $file); + return $nodes[count($nodes) - 1]; +} + +function searchForFileWithTimestamp($filename) { + $suffix = getSuffix($filename); + $fileWithoutSuffix = preg_replace("/\.$suffix$/", "", $filename); + $fileRegex = "/$fileWithoutSuffix/"; + $dir = APP_PATH_TEMP; + $files = REDCapManagement::regexInDirectory($fileRegex, $dir); + $foundFiles = []; + foreach ($files as $file) { + $fileSuffix = getSuffix($file); + if ($suffix == $fileSuffix) { + $foundFiles[] = $file; + } + } + $oneHour = 3600; + $minTimestamp = date("YmdHis", time() + $oneHour); + if (count($foundFiles) == 1) { + $file = $foundFiles[0]; + $ts = REDCapManagement::getTimestampOfFile($file); + if ($ts > $minTimestamp) { + return $dir.$foundFiles[0]; + } + } else if (count($foundFiles) > 1) { + $maxTimestamp = 0; + $maxFile = ""; + foreach ($foundFiles as $file) { + $ts = REDCapManagement::getTimestampOfFile($file); + if (($ts >= $maxTimestamp) && ($ts > $minTimestamp)) { + $maxTimestamp = $ts; + $maxFile = $file; + } + } + if ($maxFile) { + return $dir.$maxFile; + } + } + return FALSE; +} + function readAbstracts($file) { $data = []; if (file_exists($file)) { diff --git a/drivers/2n_updateReporters.php b/drivers/2n_updateReporters.php index bea922ab..e191803a 100644 --- a/drivers/2n_updateReporters.php +++ b/drivers/2n_updateReporters.php @@ -51,7 +51,9 @@ function isNewItem($oldReporters, $item, $recordId) { function updateReporter($token, $server, $pid, $recordIds) { # clear out old data - CareerDev::log("Clearing out old data"); + if (isset($_GET['test'])) { + CareerDev::log("Clearing out old data"); + } $oldReporters = array(); $redcapRows = array(); $uploadRows = array(); @@ -102,7 +104,7 @@ function updateReporter($token, $server, $pid, $recordIds) { } } } - if ($firstName && $lastName && !in_array($firstName." ".$lastName, $listOfNames)) { + if ($firstName && $lastName && !in_array(strtoupper($firstName." ".$lastName), $listOfNames)) { $listOfNames[] = strtoupper($firstName." ".$lastName); } @@ -119,7 +121,9 @@ function updateReporter($token, $server, $pid, $recordIds) { } } $institutions = REDCapManagement::explodeInstitutions($institutions); - Application::log("Institutions: ".REDCapManagement::json_encode_with_spaces($institutions)); + if (isset($_GET['test'])) { + Application::log("Institutions: ".REDCapManagement::json_encode_with_spaces($institutions)); + } $included = array(); foreach ($listOfNames as $myName) { @@ -136,19 +140,36 @@ function updateReporter($token, $server, $pid, $recordIds) { $url = "https://api.federalreporter.nih.gov".$query."&offset=".($max + 1); list($resp, $output) = REDCapManagement::downloadURL($url); $myData = json_decode($output, true); - if ($myData && $myData['items']) { - foreach ($myData['items'] as $item) { - $currData[] = $item; - } - $max = $myData['offset'] + $myData['limit'] - 1; - // echo "Checking {$myData['totalCount']} (".count($myData['items'])." here) and ".($myData['offset'] - 1 + $myData['limit'])."\n"; - usleep(400000); // up to 3 per second - } else { - $myData = array("totalCount" => 0, "limit" => 0, "offset" => 0); - } - CareerDev::log($myName." (".$lastName.") $try: Checking {$myData['totalCount']} and {$myData['offset']} and {$myData['limit']}"); - } while (($myData['totalCount'] > $myData['limit'] + $myData['offset']) || (($myData['offset'] == 0) && ($try < $maxTries))); - CareerDev::log("{$row['record_id']}: $lastName currData ".count($currData)); + $currDataChanged = FALSE; + if ($myData) { + if (isset($myData['items'])) { + foreach ($myData['items'] as $item) { + $currData[] = $item; + $currDataChanged = TRUE; + } + // echo "Checking {$myData['totalCount']} (".count($myData['items'])." here) and ".($myData['offset'] - 1 + $myData['limit'])."\n"; + } + if (isset($myData['offset']) && isset($myData['limit'])) { + $max = $myData['offset'] + $myData['limit'] - 1; + } else { + $myData = FALSE; + } + if (!$currDataChanged) { + # protect from infinite loops + $try++; + } + usleep(400000); // up to 3 per second + } else { + $myData = FALSE; + $try++; + } + if (isset($_GET['test'])) { + Application::log($myName . " (" . $lastName . ") $try: Checking {$myData['totalCount']} and {$myData['offset']} and {$myData['limit']}"); + } + } while (!$myData || (count($currData) < $myData['totalCount']) && ($try <= 5)); + if (isset($_GET['test'])) { + CareerDev::log("{$row['record_id']}: $lastName currData ".count($currData)); + } # dissect current data; must have first name to include $pis = array(); @@ -182,14 +203,19 @@ function updateReporter($token, $server, $pid, $recordIds) { $myFirstName = preg_replace("/^\(/", "", $myFirstName); $myFirstName = preg_replace("/\)$/", "", $myFirstName); if (preg_match("/".strtoupper($myFirstName)."/", $itemFirstName) && (preg_match("/$institution/i", $item['orgName']))) { - Application::log("Possible match $itemFirstName and $institution vs. '{$item['orgName']}'"); + if (isset($_GET['test'])) { + Application::log("Possible match $itemFirstName and $institution vs. '{$item['orgName']}'"); + } if (in_array($institution, $helperInstitutions)) { - Application::log("Helper institution ($institution)?"); + if (isset($_GET['test'])) { + Application::log("Helper institution ($institution)?"); + } $proceed = FALSE; - Application::log("Helper institution inspecting cities: ".json_encode(CareerDev::getCities())." vs. '".$item['orgCity']."'"); + if (isset($_GET['test'])) { + Application::log("Helper institution inspecting cities: ".json_encode(CareerDev::getCities())." vs. '".$item['orgCity']."'"); + } foreach (CareerDev::getCities() as $city) { if (preg_match("/".$city."/i", $item['orgCity'])) { - Application::log("Matched city"); $proceed = TRUE; } } @@ -201,7 +227,9 @@ function updateReporter($token, $server, $pid, $recordIds) { } } if ($proceed) { - CareerDev::log("Including $itemFirstName {$item['orgName']}"); + if (isset($_GET['test'])) { + CareerDev::log("Including $itemFirstName {$item['orgName']}"); + } $included[] = $item; $found = true; break; @@ -220,7 +248,9 @@ function updateReporter($token, $server, $pid, $recordIds) { } } } - CareerDev::log("{$row['record_id']}: $firstName $lastName included ".count($included)); + if (isset($_GET['test'])) { + CareerDev::log("{$row['record_id']}: $firstName $lastName included ".count($included)); + } // echo "itemNames: ".json_encode($pis)."\n"; } @@ -257,7 +287,9 @@ function updateReporter($token, $server, $pid, $recordIds) { $notUpload[] = $item; } } - CareerDev::log($row['record_id']." ".count($upload)." rows to upload; skipped ".count($notUpload)." rows from original of ".getReporterCount($oldReporters, $row['record_id'])); + if (isset($_GET['test'])) { + CareerDev::log($row['record_id']." ".count($upload)." rows to upload; skipped ".count($notUpload)." rows from original of ".getReporterCount($oldReporters, $row['record_id'])); + } foreach ($upload as $uploadRow) { if (!isset($uploadRows[$uploadRow['record_id']])) { @@ -270,7 +302,9 @@ function updateReporter($token, $server, $pid, $recordIds) { if (!empty($upload)) { $feedback = Upload::rows($upload, $token, $server); $output = json_encode($feedback); - CareerDev::log("Upload $firstName $lastName ({$row['record_id']}): ".$output); + if (isset($_GET['test'])) { + CareerDev::log("Upload $firstName $lastName ({$row['record_id']}): ".$output); + } } } diff --git a/drivers/2q_refreshCohortProjects.php b/drivers/2q_refreshCohortProjects.php new file mode 100644 index 00000000..aa988b46 --- /dev/null +++ b/drivers/2q_refreshCohortProjects.php @@ -0,0 +1,36 @@ +getCohortNames(); + + $module = CareerDev::getModule(); + $pids = $module->framework->getProjectsWithModuleEnabled(); + foreach ($cohortNames as $cohort) { + foreach ($pids as $destPid) { + $tokenName = CareerDev::getSetting("tokenName", $destPid); + if ($tokenName == $cohort) { + $destToken = CareerDev::getSetting("token", $destPid); + CareerDev::log("Copying project to cohort $cohort. From pid $pid, to pid $destPid"); + \Vanderbilt\FlightTrackerExternalModule\copyEntireProject($token, $destToken, $server, $metadata, $cohort); + } + } + } +} diff --git a/mentor/index.php b/mentor/index.php index 9ceefb2d..2dfcdf6c 100644 --- a/mentor/index.php +++ b/mentor/index.php @@ -34,6 +34,7 @@ } $metadata = Download::metadata($token, $server); +$allMetadataForms = REDCapManagement::getFormsFromMetadata($metadata); $metadata = filterMetadata($metadata, FALSE); $metadataFields = REDCapManagement::getFieldsFromMetadata($metadata); @@ -202,6 +203,13 @@ ?> + + When done, please provide feedback on the Mentoring Agreement"; + } + ?> diff --git a/mentor/index_complete.php b/mentor/index_complete.php index dfd0032c..2efdbd31 100644 --- a/mentor/index_complete.php +++ b/mentor/index_complete.php @@ -42,6 +42,7 @@ list($firstName, $lastName) = getNameFromREDCap($username, $token, $server); $userids = Download::userids($token, $server); $metadata = Download::metadata($token, $server); +$allMetadataForms = REDCapManagement::getFormsFromMetadata($metadata); $metadata = filterMetadata($metadata); $metadataFields = REDCapManagement::getFieldsFromMetadata($metadata); $notesFields = getNotesFields($metadataFields); @@ -144,6 +145,12 @@ ?> + When done, please provide feedback on the Mentoring Agreement"; + } + ?> diff --git a/mentor/index_menteeview.php b/mentor/index_menteeview.php index 76fdb756..f3fcbe9a 100644 --- a/mentor/index_menteeview.php +++ b/mentor/index_menteeview.php @@ -45,6 +45,7 @@ } $metadata = Download::metadata($token, $server); +$allMetadataForms = REDCapManagement::getFormsFromMetadata($metadata); $metadata = filterMetadata($metadata); $metadataFields = REDCapManagement::getFieldsFromMetadata($metadata); $choices = REDCapManagement::getChoices($metadata); @@ -287,6 +288,14 @@ function() { ?> + + + When done, please provide feedback on the Mentoring Agreement"; + } + ?> diff --git a/mentor/index_mentorview.php b/mentor/index_mentorview.php index a8b4e125..e13e1eba 100644 --- a/mentor/index_mentorview.php +++ b/mentor/index_mentorview.php @@ -48,6 +48,7 @@ $menteeName = $names[$menteeRecordId]; $metadata = Download::metadata($token, $server); +$allMetadataForms = REDCapManagement::getFormsFromMetadata($metadata); $metadata = filterMetadata($metadata); $metadataFields = REDCapManagement::getFieldsFromMetadata($metadata); $choices = REDCapManagement::getChoices($metadata); @@ -211,6 +212,11 @@ $htmlRows[] = ""; echo implode("\n", $htmlRows)."\n"; + if (in_array("mentoring_agreement_evaluations", $allMetadataForms)) { + $link = \REDCap::getSurveyLink($menteeRecordId, "mentoring_agreement_evaluations"); + echo "

When done, please provide feedback on the Mentoring Agreement

"; + } + ?>