Skip to content

Commit b3fee3d

Browse files
author
Dave MacFarlane
committed
[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.
1 parent 6dcc7c3 commit b3fee3d

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-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>

php/libraries/Language.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
class Language
8+
{
9+
/**
10+
* Construct a Language object
11+
*
12+
* @param public readonly string $label The display label for the language
13+
* @param public readonly string $code The language code for the language.
14+
*
15+
* @return \Language
16+
*/
17+
public function __construct(
18+
public readonly string $label,
19+
public readonly string $code
20+
) { }
21+
}

php/libraries/TimePoint.class.inc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,5 +1386,30 @@ 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+
$db = NDB_Factory::singleton()->database();
1397+
1398+
$vals = $db->pselectRow(
1399+
"SELECT language_label, language_code
1400+
FROM language l
1401+
JOIN session s ON (l.language_id=s.languageID)
1402+
WHERE s.ID=:sid",
1403+
['sid' => $this->getSessionID()]
1404+
);
1405+
1406+
if ($vals === null) {
1407+
return new \Language("Unknown", "en_CA");
1408+
}
1409+
return new \Language(
1410+
label: $vals['language_label'],
1411+
code: $vals['language_code']
1412+
);
1413+
}
13891414
}
13901415

0 commit comments

Comments
 (0)