Skip to content

Commit 0290587

Browse files
authored
[timepoint_list] Add language to timepoint_list (#10153)
Add the language of a session to timepoint_list, so that the user knows what language to expect the instrument data to be in.
1 parent 780a7ee commit 0290587

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

modules/timepoint_list/php/timepoint_list.class.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ class Timepoint_List extends \NDB_Menu
230230
= $timePoint->$getDateMethod();
231231
}
232232
}
233+
234+
$this->tpl_data['timePoints'][$x]['language']
235+
= $timePoint->getLanguage();
233236
$x++;
234237
} // end list
235238

modules/timepoint_list/templates/menu_timepoint_list.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
<th>{dgettext("timepoint_list", "BVL QC")}</th>
7777
<th>{dgettext("timepoint_list", "BVL Exclusion")}</th>
7878
<th>{dgettext("timepoint_list", "Registered By")}</th>
79+
<th>{dgettext("loris", "Language")}</th>
7980
</tr>
8081
</thead>
8182
<tbody>
@@ -154,6 +155,9 @@
154155
<td>
155156
{$timePoints[timepoint].Real_name}
156157
</td>
158+
<td>
159+
{$timePoints[timepoint].language->label}
160+
</td>
157161
</tr>
158162
{sectionelse}
159163
<tr><td colspan="10">{dgettext("timepoint_list", "You do not have access to any timepoints registered for this candidate.")}</td></tr>

modules/timepoint_list/test/TimepointListIntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class TimepointListIntegrationTest extends LorisIntegrationTestWithCandidate
4141
'',
4242
'',
4343
'',
44+
'Unknown',
4445
];
4546

4647
/**

php/libraries/Language.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
3+
/**
4+
* A Language object represents the concept of a language that has been
5+
* configured on this LORIS instance.
6+
*
7+
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
8+
*/
9+
class Language
10+
{
11+
/**
12+
* Construct a Language object
13+
*
14+
* @param string $label The display label for the language
15+
* @param string $code The language code for the language.
16+
*/
17+
public function __construct(
18+
public readonly string $label,
19+
public readonly string $code
20+
) {
21+
}
22+
}

php/libraries/TimePoint.class.inc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,5 +1386,31 @@ class TimePoint implements \LORIS\StudyEntities\AccessibleResource,
13861386
$centerMatch = in_array($this->getCenterID(), $centers);
13871387
return $projMatch && $centerMatch;
13881388
}
1389+
1390+
/**
1391+
* Get the language for this timepoint.
1392+
*
1393+
* @return \Language
1394+
*/
1395+
public function getLanguage() : \Language
1396+
{
1397+
$db = NDB_Factory::singleton()->database();
1398+
1399+
$vals = $db->pselectRow(
1400+
"SELECT language_label, language_code
1401+
FROM language l
1402+
JOIN session s ON (l.language_id=s.languageID)
1403+
WHERE s.ID=:sid",
1404+
['sid' => $this->getSessionID()],
1405+
);
1406+
1407+
if ($vals === null) {
1408+
return new \Language("Unknown", "en_CA");
1409+
}
1410+
return new \Language(
1411+
label: $vals['language_label'],
1412+
code: $vals['language_code']
1413+
);
1414+
}
13891415
}
13901416

0 commit comments

Comments
 (0)