diff --git a/php/libraries/Utility.class.inc b/php/libraries/Utility.class.inc index f6beac25bab..3e88437822d 100644 --- a/php/libraries/Utility.class.inc +++ b/php/libraries/Utility.class.inc @@ -715,7 +715,9 @@ class Utility ); } elseif (!is_null($commentID)) { //get sourcefield using commentid $instrument = $DB->pselectOne( - "SELECT Test_name FROM flag WHERE CommentID = :cid", + "SELECT Test_name FROM flag + JOIN test_names ON (test_names.ID = flag.TestID) + WHERE CommentID = :cid", ['cid' => $commentID] ); $sourcefields = $DB->pselect( diff --git a/tools/data_integrity/data_deletion/delete_timepoint.php b/tools/data_integrity/data_deletion/delete_timepoint.php index 7f4abae3899..aeb9023a16b 100755 --- a/tools/data_integrity/data_deletion/delete_timepoint.php +++ b/tools/data_integrity/data_deletion/delete_timepoint.php @@ -180,7 +180,10 @@ function deleteTimepoint( echo "\n###############################################################\n"; $instruments = $DB->pselect( - 'SELECT Test_name, CommentID FROM flag WHERE SessionID=:sid', + 'SELECT Test_name, CommentID + FROM flag + JOIN test_names ON (test_names.ID = flag.TestID) + WHERE SessionID=:sid', ['sid' => $sessionID] ); diff --git a/tools/data_integrity_check.php b/tools/data_integrity_check.php index 513b356833b..730e93f3678 100644 --- a/tools/data_integrity_check.php +++ b/tools/data_integrity_check.php @@ -37,6 +37,10 @@ {$instrument} ON {$instrument}.CommentID = flag.CommentID + LEFT JOIN + test_names + ON + (test_names.ID = flag.TestID) WHERE Test_name = :instrument AND {$instrument}.CommentID IS NULL @@ -80,6 +84,10 @@ SessionID,Test_name,CommentID FROM flag + JOIN + test_names + ON + (test_names.ID = flag.TestID) WHERE ( flag.CommentID NOT LIKE 'DDE_%' AND @@ -88,10 +96,14 @@ COUNT(*) FROM flag test + JOIN + test_names + ON + (test_names.ID = flag.TestID) WHERE test.CommentID NOT LIKE 'DDE_%' AND flag.SessionID = test.SessionID AND - flag.Test_name = test.Test_name + test_names.Test_name = test.Test_name ) > 1 ) OR ( @@ -101,10 +113,14 @@ COUNT(*) FROM flag test + JOIN + test_names + ON + (test_names.ID = flag.TestID) WHERE test.CommentID LIKE 'DDE_%' AND flag.SessionID = test.SessionID AND - flag.Test_name = test.Test_name + test_names.Test_name = test.Test_name ) > 1 ) ", diff --git a/tools/fix_timepoint_date_problems.php b/tools/fix_timepoint_date_problems.php index 6567ae95a87..49178b196ab 100755 --- a/tools/fix_timepoint_date_problems.php +++ b/tools/fix_timepoint_date_problems.php @@ -428,7 +428,9 @@ function addInstrument($sessionID, $testName, $loris) // get CommentID of the newly assigned instrument $query = "SELECT CommentID FROM flag - WHERE SessionID='$sessionID' AND Test_name='$testName'"; + JOIN test_names ON (test_names.ID = flag.TestID) + WHERE SessionID='$sessionID' + AND Test_name='$testName'"; /* * add Feedback