From b3fee3dc214d2a7b776b8d50505b9763a8104c63 Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Tue, 25 Nov 2025 14:52:17 -0500 Subject: [PATCH 1/4] [timepoint_list] Add language to timepoint_list Add the language of a session to timepoint_list, so that the user knows what language to expect the instrument data to be in. --- .../php/timepoint_list.class.inc | 3 +++ .../templates/menu_timepoint_list.tpl | 4 +++ php/libraries/Language.php | 21 ++++++++++++++++ php/libraries/TimePoint.class.inc | 25 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 php/libraries/Language.php diff --git a/modules/timepoint_list/php/timepoint_list.class.inc b/modules/timepoint_list/php/timepoint_list.class.inc index 6edfa0d2b0e..844b3ee82fa 100644 --- a/modules/timepoint_list/php/timepoint_list.class.inc +++ b/modules/timepoint_list/php/timepoint_list.class.inc @@ -230,6 +230,9 @@ class Timepoint_List extends \NDB_Menu = $timePoint->$getDateMethod(); } } + + $this->tpl_data['timePoints'][$x]['language'] + = $timePoint->getLanguage(); $x++; } // end list diff --git a/modules/timepoint_list/templates/menu_timepoint_list.tpl b/modules/timepoint_list/templates/menu_timepoint_list.tpl index 869b3b0e346..af55e861441 100644 --- a/modules/timepoint_list/templates/menu_timepoint_list.tpl +++ b/modules/timepoint_list/templates/menu_timepoint_list.tpl @@ -76,6 +76,7 @@ {dgettext("timepoint_list", "BVL QC")} {dgettext("timepoint_list", "BVL Exclusion")} {dgettext("timepoint_list", "Registered By")} + {dgettext("loris", "Language")} @@ -154,6 +155,9 @@ {$timePoints[timepoint].Real_name} + + {$timePoints[timepoint].language->label} + {sectionelse} {dgettext("timepoint_list", "You do not have access to any timepoints registered for this candidate.")} diff --git a/php/libraries/Language.php b/php/libraries/Language.php new file mode 100644 index 00000000000..58d05ff80e8 --- /dev/null +++ b/php/libraries/Language.php @@ -0,0 +1,21 @@ +getCenterID(), $centers); return $projMatch && $centerMatch; } + + /** + * Get the language for this timepoint. + * + * @return \Language + */ + public function getLanguage() : \Language { + $db = NDB_Factory::singleton()->database(); + + $vals = $db->pselectRow( + "SELECT language_label, language_code + FROM language l + JOIN session s ON (l.language_id=s.languageID) + WHERE s.ID=:sid", + ['sid' => $this->getSessionID()] + ); + + if ($vals === null) { + return new \Language("Unknown", "en_CA"); + } + return new \Language( + label: $vals['language_label'], + code: $vals['language_code'] + ); + } } From 56c01ae7c0a73f5d5c4181cd03ae8fc56522771c Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Tue, 25 Nov 2025 15:44:36 -0500 Subject: [PATCH 2/4] Update test --- .../timepoint_list/test/TimepointListIntegrationTest.php | 1 + php/libraries/Language.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/timepoint_list/test/TimepointListIntegrationTest.php b/modules/timepoint_list/test/TimepointListIntegrationTest.php index 894927060a2..ec1723a83db 100644 --- a/modules/timepoint_list/test/TimepointListIntegrationTest.php +++ b/modules/timepoint_list/test/TimepointListIntegrationTest.php @@ -41,6 +41,7 @@ class TimepointListIntegrationTest extends LorisIntegrationTestWithCandidate '', '', '', + 'Unknown', ]; /** diff --git a/php/libraries/Language.php b/php/libraries/Language.php index 58d05ff80e8..de3a019b196 100644 --- a/php/libraries/Language.php +++ b/php/libraries/Language.php @@ -3,6 +3,8 @@ /** * A Language object represents the concept of a language that has been * configured on this LORIS instance. + * + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 */ class Language { @@ -16,6 +18,7 @@ class Language */ public function __construct( public readonly string $label, - public readonly string $code - ) { } + public readonly string $code + ) { + } } From e69312d695f18ef40de146d565ab6efc7d03551c Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Tue, 25 Nov 2025 15:52:40 -0500 Subject: [PATCH 3/4] phpcs --- .../test/TimepointListIntegrationTest.php | 2 +- php/libraries/TimePoint.class.inc | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/timepoint_list/test/TimepointListIntegrationTest.php b/modules/timepoint_list/test/TimepointListIntegrationTest.php index ec1723a83db..07757815a8d 100644 --- a/modules/timepoint_list/test/TimepointListIntegrationTest.php +++ b/modules/timepoint_list/test/TimepointListIntegrationTest.php @@ -41,7 +41,7 @@ class TimepointListIntegrationTest extends LorisIntegrationTestWithCandidate '', '', '', - 'Unknown', + 'Unknown', ]; /** diff --git a/php/libraries/TimePoint.class.inc b/php/libraries/TimePoint.class.inc index d6dcaefe0fd..5f396f2f635 100644 --- a/php/libraries/TimePoint.class.inc +++ b/php/libraries/TimePoint.class.inc @@ -1392,21 +1392,22 @@ class TimePoint implements \LORIS\StudyEntities\AccessibleResource, * * @return \Language */ - public function getLanguage() : \Language { + public function getLanguage() : \Language + { $db = NDB_Factory::singleton()->database(); - $vals = $db->pselectRow( + $vals = $db->pselectRow( "SELECT language_label, language_code FROM language l JOIN session s ON (l.language_id=s.languageID) - WHERE s.ID=:sid", - ['sid' => $this->getSessionID()] - ); + WHERE s.ID=:sid", + ['sid' => $this->getSessionID()], + ); - if ($vals === null) { + if ($vals === null) { return new \Language("Unknown", "en_CA"); - } - return new \Language( + } + return new \Language( label: $vals['language_label'], code: $vals['language_code'] ); From 8f1df481f47656702e59daa8f56899cf984824d3 Mon Sep 17 00:00:00 2001 From: Dave MacFarlane Date: Fri, 28 Nov 2025 13:25:50 -0500 Subject: [PATCH 4/4] phan? --- php/libraries/Language.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/php/libraries/Language.php b/php/libraries/Language.php index de3a019b196..584376cb95d 100644 --- a/php/libraries/Language.php +++ b/php/libraries/Language.php @@ -11,10 +11,8 @@ class Language /** * Construct a Language object * - * @param public readonly string $label The display label for the language - * @param public readonly string $code The language code for the language. - * - * @return \Language + * @param string $label The display label for the language + * @param string $code The language code for the language. */ public function __construct( public readonly string $label,