Skip to content

Commit dcabee7

Browse files
author
m-tanabe
committed
Add isEnabledEppn function
1 parent 6e6c482 commit dcabee7

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

caliper/app/Caliper/Traits/Util.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,7 @@ protected function getUser(string $id): ?User
3333

3434
public function getAnonymizedUsername(User $actor): string
3535
{
36-
$eppnValue = env('DB_EPPN');
37-
if (is_bool($eppnValue) && $eppnValue) {
38-
$enableEppn = true;
39-
} elseif (is_string($eppnValue) && $eppnValue == 'true') {
40-
$enableEppn = true;
41-
} else {
42-
$enableEppn = false;
43-
}
44-
if ($enableEppn) {
36+
if ($this->isEnabledEppn()) {
4537
$username = ($actor->auth === 'lti')
4638
? $actor->alternatename
4739
: $actor->username;
@@ -125,4 +117,16 @@ public function getCourseId(string $id): string
125117
{
126118
return env('APP_URL') . '/course/view.php?id=' . $id;
127119
}
120+
121+
protected function isEnabledEppn(): bool
122+
{
123+
$eppnValue = env('DB_EPPN');
124+
if (is_bool($eppnValue) && $eppnValue) {
125+
return true;
126+
} elseif (is_string($eppnValue) && $eppnValue == 'true') {
127+
return true;
128+
} else {
129+
return false;
130+
}
131+
}
128132
}

0 commit comments

Comments
 (0)