Skip to content

Commit

Permalink
6.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjpearson committed Nov 21, 2024
1 parent 97063bb commit 1cfc2f7
Show file tree
Hide file tree
Showing 20 changed files with 249 additions and 2,227 deletions.
14 changes: 14 additions & 0 deletions Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ public static function getRelevantChoices() {
return CareerDev::getRelevantChoices();
}

public static function getJQueryURL(): string {
$fileOrder = [
APP_PATH_DOCROOT."Resources/webpack/js/bundle.js" => APP_PATH_WEBROOT."Resources/webpack/js/bundle.js",
__DIR__."/js/jquery.min.js" => self::link("js/jquery.min.js"),
];
foreach ($fileOrder as $file => $url) {
if (file_exists($file)) {
return $url;
}
}
return "";
}

public static function getMetadataFiles($pid): array {
$files = [];
if (Application::getSetting("signup_project", $pid)) {
Expand Down Expand Up @@ -1168,6 +1181,7 @@ public static function applySecurityHeaders($pid) {
"citation_title",
"citation_pub_types",
"citation_mesh_terms",
"citation_pubmed_keywords",
"citation_journal",
"citation_volume",
"citation_issue",
Expand Down
5 changes: 4 additions & 1 deletion CareerDev.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CareerDev {
public static $passedModule = NULL;

public static function getVersion() {
return "6.17.3";
return "6.18.0";
}

public static function getLocalhostPluginPid() {
Expand Down Expand Up @@ -637,6 +637,9 @@ private static function getREDCapSignupURL() {

public static function getLink($relativeUrl, $pid = "", $withWebroot = FALSE) {
$relativeUrl = preg_replace("/^\//", "", $relativeUrl);
if ($relativeUrl == "js/jquery.min.js") {
return Application::getJQueryURL();
}
$isMentorAgreementPage = (
(
preg_match("/^mentor\//", $relativeUrl)
Expand Down
6 changes: 2 additions & 4 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<?php

namespace Vanderbilt\CareerDevLibrary;

require_once(__DIR__."/../../../redcap_connect.php");
require_once(__DIR__."/ClassLoader.php");
require_once(__DIR__."/CareerDev.php");
require_once(__DIR__."/classes/Autoload.php");
23 changes: 12 additions & 11 deletions bulkImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@
$errors = [];
list($headers, $lines, $startIdx) = readCSV($_FILES['bulk'], $title);

$metadata = Download::metadata($token, $server);
$records = Download::recordIds($token, $server);
$metadata = Download::formMetadata($token, $server, ["position_change", "custom_grant"]);
$records = Download::recordIdsByPid($pid);
$metadataFields = REDCapManagement::getFieldsFromMetadata($metadata);
$choices = REDCapManagement::getChoices($metadata);
$matchedIndices = [0];
$unmatchedLines = [];
$maxInstances = [];
$i = 0;
Expand Down Expand Up @@ -204,7 +203,7 @@ function verifyFile($fileinfo, $importFile, $expectedItems) {
}
}

function detectFirstError($fileinfo, $importFile, $expected) {
function detectFirstError(array $fileinfo, string $importFile, int $expected): string {
if (!$fileinfo) {
return "No file supplied!";
}
Expand All @@ -221,10 +220,12 @@ function detectFirstError($fileinfo, $importFile, $expected) {
$fp = fopen($filename, "r");
$firstLine = fgetcsv($fp);

$decrement = 0;
if ($firstLine[0] == "Record ID") {
array_shift($headers);
$headers[0] = "Record ID";
$expected--;
$decrement = 1;
$expected -= $decrement;
}

# sometimes Excel puts a unicode hidden character before the first element
Expand Down Expand Up @@ -254,11 +255,11 @@ function detectFirstError($fileinfo, $importFile, $expected) {
return "Line $i has ".count($line)." items! ($expected items expected.)";
}
if (preg_match("/import\.csv/", $importFile)) {
if (!inDateFormat($line[8])) {
return "The start date {$line[8]} is not in YYYY-MM-DD or MM-DD-YYYY format!";
if (!inDateFormat($line[8 - $decrement])) {
return "The start date {$line[8 - $decrement]} is not in YYYY-MM-DD or MM-DD-YYYY format!";
}
if (!inDateFormat($line[9])) {
return "The end date {$line[9]} is not in YYYY-MM-DD or MM-DD-YYYY format!";
if (!inDateFormat($line[9- $decrement])) {
return "The end date {$line[9 - $decrement]} is not in YYYY-MM-DD or MM-DD-YYYY format!";
}
}
$i++;
Expand Down Expand Up @@ -328,7 +329,7 @@ function readCSV($fileinfo, $validationType) {
$line[$startIdx + 8] = REDCapManagement::removeMoneyFormatting($line[$startIdx + 8]);
$line[$startIdx + 9] = REDCapManagement::removeMoneyFormatting($line[$startIdx + 9]);
}
array_push($lines, $line);
$lines[] = $line;
}
fclose($fp);
return [$headers, $lines, $startIdx];
Expand Down Expand Up @@ -390,7 +391,7 @@ function getRecordsFromREDCapData($redcapData) {
$records = array();
foreach ($redcapData as $row) {
if (!in_array($row['record_id'], $records)) {
array_push($records, $row['record_id']);
$records[] = $row['record_id'];
}
}
return $records;
Expand Down
2 changes: 1 addition & 1 deletion charts/publicationSubjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
foreach ($fieldsToMonitor as $field) {
if (isset($row[$field]) && ($row[$field] != "")) {
if ($field == OpenAI::CITATION_KEYWORD_FIELD) {
$fieldTerms = OpenAI::explodeKeywords($field);
$fieldTerms = OpenAI::explodeKeywords($row[$field]);
} else {
$fieldTerms = preg_split("/\s*;\s*/", $row[$field], -1, PREG_SPLIT_NO_EMPTY);
}
Expand Down
233 changes: 116 additions & 117 deletions charts/timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,137 +23,136 @@
$switches = new FeatureSwitches($token, $server, $pid);
$switchSettings = $switches->getSwitches();

?>

<?php

$records = Download::recordIds($token, $server);
$recordId = isset($_GET['record']) ? REDCapManagement::getSanitizedRecord($_GET['record'], $records) : $records[0];
$nextRecord = $records[0];
for ($i = 0; $i < count($records); $i++) {
if (($records[$i] == $recordId) && ($i + 1 < count($records))) {
$nextRecord = $records[$i + 1];
break;
}
}
if (isset($redcapData)) {
# this page is included via a require_once, so this variable might have already been downloaded
$rows = $redcapData;
} else {
$metadataFields = Download::metadataFields($token, $server);
$validPrefixes = [];
$grantPrefixes = [
"coeus_",
"coeussubmission_",
"vera_",
"verasubmission_",
"summary_",
"nih_",
"reporter_",
"custom_",
];
$pubPrefixes = [
"citation_",
"eric_",
];
if (($switchSettings["Grants"] != "Off") && !isset($_GET['noCDA'])) {
$validPrefixes = array_merge($validPrefixes, $grantPrefixes);
}
if ($switchSettings["Publications"] != "Off") {
$validPrefixes = array_merge($validPrefixes, $pubPrefixes);
}
$fieldsToDownload = ["record_id", "identifier_first_name", "identifier_middle", "identifier_last_name"];
foreach ($validPrefixes as $prefix) {
$prefixFields = DataDictionaryManagement::filterFieldsForPrefix($metadataFields, $prefix);
$fieldsToDownload = array_unique(array_merge($fieldsToDownload, $prefixFields));
}
$rows = Download::fieldsForRecords($token, $server, $fieldsToDownload, [$recordId]);
$records = Download::recordIds($token, $server);
$recordId = isset($_GET['record']) ? REDCapManagement::getSanitizedRecord($_GET['record'], $records) : $records[0];
$nextRecord = $records[0];
for ($i = 0; $i < count($records); $i++) {
if (($records[$i] == $recordId) && ($i + 1 < count($records))) {
$nextRecord = $records[$i + 1];
break;
}

$name = "";
foreach ($rows as $row) {
if ($row['redcap_repeat_instrument'] == "") {
$name = $row['identifier_first_name']." ".$row['identifier_last_name'];
break;
}
}
if (isset($redcapData)) {
# this page is included via a require_once, so this variable might have already been downloaded
$rows = $redcapData;
} else {
$metadataFields = Download::metadataFields($token, $server);
$validPrefixes = [];
$grantPrefixes = [
"coeus_",
"coeussubmission_",
"vera_",
"verasubmission_",
"summary_",
"nih_",
"reporter_",
"custom_",
];
$pubPrefixes = [
"citation_",
"eric_",
];
if (($switchSettings["Grants"] != "Off") && !isset($_GET['noCDA'])) {
$validPrefixes = array_merge($validPrefixes, $grantPrefixes);
}
if ($switchSettings["Publications"] != "Off") {
$validPrefixes = array_merge($validPrefixes, $pubPrefixes);
}
$fieldsToDownload = ["record_id", "identifier_first_name", "identifier_middle", "identifier_last_name"];
foreach ($validPrefixes as $prefix) {
$prefixFields = DataDictionaryManagement::filterFieldsForPrefix($metadataFields, $prefix);
$fieldsToDownload = array_unique(array_merge($fieldsToDownload, $prefixFields));
}
$rows = Download::fieldsForRecords($token, $server, $fieldsToDownload, [$recordId]);
}

$grantsAndPubs = [];
$maxTs = [];
$minTs = [];

$grants = new Grants($token, $server, "empty");
$grants->setRows($rows);
$grants->compileGrants();
$grants->compileGrantSubmissions();
$id = 1;
list($submissions, $submissionTimestamps) = makeSubmissionDots($grants->getGrants("submissions"), $id);
if (!empty($submissions) && !isset($_GET['awardsOnly'])) {
$classes[] = "AllWithSubmissions";
$name = "";
foreach ($rows as $row) {
if ($row['redcap_repeat_instrument'] == "") {
$name = $row['identifier_first_name']." ".$row['identifier_last_name'];
break;
}
}

foreach ($classes as $c) {
$maxTs[$c] = 0;
$minTs[$c] = time();
$grantsAndPubs[$c] = [];

if ($c == "AllWithSubmissions") {
$allTimestamps = $submissionTimestamps;
$grantsAndPubs[$c] = $submissions;

foreach ($allTimestamps as $submissionTs) {
if ($submissionTs) {
if ($maxTs[$c] < $submissionTs) {
$maxTs[$c] = $submissionTs;
}
if ($minTs[$c] > $submissionTs) {
$minTs[$c] = $submissionTs;
}
}
}
}
$grantsAndPubs = [];
$maxTs = [];
$minTs = [];

$grants = new Grants($token, $server, "empty");
$grants->setRows($rows);
$grants->compileGrants();
$grants->compileGrantSubmissions();
$id = 1;
list($submissions, $submissionTimestamps) = makeSubmissionDots($grants->getGrants("submissions"), $id);
if (!empty($submissions) && !isset($_GET['awardsOnly'])) {
$classes[] = "AllWithSubmissions";
}

$grantClass = CareerDev::getSetting("grant_class", $pid);
$grantAry = makeTrainingDatesBar($rows, $id, $minTs[$c], $maxTs[$c], ($grantClass == "T"));
if ($grantAry) {
$grantsAndPubs[$c][] = $grantAry;
}
if ($switchSettings["Grants"] == "Off") {
$grantType = "NONE";
} else if (in_array($c, ["All", "AllWithSubmissions"])) {
$grantType = "all";
} else if (($c == "PubsCDAs") && !isset($_GET['noCDA'])) {
$grantType = "prior";
} else if (($c == "PubsCDAs") && isset($_GET['noCDA'])) {
$grantType = "NONE";
} else if ($c == "Flagged") {
$grantType = "flagged";
} else {
throw new \Exception("Class is not set up $c");
}
if (($grantType !== "NONE") && ($grants->getCount($grantType) > 0)) {
if (isset($_GET['test'])) {
echo "grants->$grantType has ".$grants->getCount($grantType)." items<br>";
foreach ($classes as $c) {
$maxTs[$c] = 0;
$minTs[$c] = time();
$grantsAndPubs[$c] = [];

if ($c == "AllWithSubmissions") {
$allTimestamps = $submissionTimestamps;
$grantsAndPubs[$c] = $submissions;

foreach ($allTimestamps as $submissionTs) {
if ($submissionTs) {
if ($maxTs[$c] < $submissionTs) {
$maxTs[$c] = $submissionTs;
}
if ($minTs[$c] > $submissionTs) {
$minTs[$c] = $submissionTs;
}
}
$grantBars = makeGrantBars($grants->getGrants($grantType), $id, $minTs[$c], $maxTs[$c]);
$grantsAndPubs[$c] = array_merge($grantsAndPubs[$c], $grantBars);
}
}

if (($c == "PubsCDAs") && ($switchSettings["Publications"] != "Off")) {
$pubDots = makePubDots($rows, $token, $server, $id, $minTs[$c], $maxTs[$c]);
$grantsAndPubs[$c] = array_merge($grantsAndPubs[$c], $pubDots);
$grantClass = CareerDev::getSetting("grant_class", $pid);
$grantAry = makeTrainingDatesBar($rows, $id, $minTs[$c], $maxTs[$c], ($grantClass == "T"));
if ($grantAry) {
$grantsAndPubs[$c][] = $grantAry;
}
if ($switchSettings["Grants"] == "Off") {
$grantType = "NONE";
} else if (in_array($c, ["All", "AllWithSubmissions"])) {
$grantType = "all";
} else if (($c == "PubsCDAs") && !isset($_GET['noCDA'])) {
$grantType = "prior";
} else if (($c == "PubsCDAs") && isset($_GET['noCDA'])) {
$grantType = "NONE";
} else if ($c == "Flagged") {
$grantType = "flagged";
} else {
throw new \Exception("Class is not set up $c");
}
if (isset($_GET['test'])) {
echo "$c has grantType $grantType and ".$grants->getCount($grantType)." grants<br>";
}
if (($grantType !== "NONE") && ($grants->getCount($grantType) > 0)) {
if (isset($_GET['test'])) {
echo "grants->$grantType has ".$grants->getCount($grantType)." items<br>";
}
$grantBars = makeGrantBars($grants->getGrants($grantType), $id, $minTs[$c], $maxTs[$c]);
$grantsAndPubs[$c] = array_merge($grantsAndPubs[$c], $grantBars);
}

$currTs = time();
if ($maxTs[$c] < $currTs) {
$maxTs[$c] = $currTs;
}
if (($c == "PubsCDAs") && ($switchSettings["Publications"] != "Off")) {
$pubDots = makePubDots($rows, $token, $server, $id, $minTs[$c], $maxTs[$c]);
$grantsAndPubs[$c] = array_merge($grantsAndPubs[$c], $pubDots);
}

$spacing = ($maxTs[$c] + 90 * 24 * 3600 - $minTs[$c]) / 6;
$maxTs[$c] += $spacing;
$minTs[$c] -= $spacing;
$currTs = time();
if ($maxTs[$c] < $currTs) {
$maxTs[$c] = $currTs;
}

$spacing = ($maxTs[$c] + 90 * 24 * 3600 - $minTs[$c]) / 6;
$maxTs[$c] += $spacing;
$minTs[$c] -= $spacing;
}

?>
<script src="<?= Application::link("/charts/vis.min.js") ?>"></script>
<link href="<?= Application::link("charts/vis.min.css") ?>" rel="stylesheet" type="text/css" />
Expand Down
Binary file modified css/images/ui-icons_444444_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified css/images/ui-icons_555555_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified css/images/ui-icons_777620_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified css/images/ui-icons_777777_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified css/images/ui-icons_cc0000_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified css/images/ui-icons_ffffff_256x240.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1cfc2f7

Please sign in to comment.