summaryrefslogtreecommitdiffstats
path: root/modules-available/exams
diff options
context:
space:
mode:
authorSimon Rettberg2023-11-14 14:47:55 +0100
committerSimon Rettberg2023-11-14 14:47:55 +0100
commit06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch)
tree7e5493b102074672d8cfd8fe1a61e49f080edbe8 /modules-available/exams
parentUpdate phpstorm config (diff)
downloadslx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.gz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.xz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.zip
Add function param/return types, fix a lot more phpstorm complaints
Diffstat (limited to 'modules-available/exams')
-rw-r--r--modules-available/exams/baseconfig/getconfig.inc.php13
-rw-r--r--modules-available/exams/inc/exams.inc.php9
-rw-r--r--modules-available/exams/page.inc.php20
3 files changed, 23 insertions, 19 deletions
diff --git a/modules-available/exams/baseconfig/getconfig.inc.php b/modules-available/exams/baseconfig/getconfig.inc.php
index 120bdbff..748149ad 100644
--- a/modules-available/exams/baseconfig/getconfig.inc.php
+++ b/modules-available/exams/baseconfig/getconfig.inc.php
@@ -1,14 +1,17 @@
<?php
-$foofoo = function($machineUuid) {
+/** @var ?string $uuid */
+/** @var ?string $ip */
+
+if ($uuid !== null) {
// Leave clients in any runmode alone
$res = Database::queryFirst('SELECT machineuuid FROM runmode WHERE machineuuid = :uuid',
- array('uuid' => $machineUuid), true);
+ array('uuid' => $uuid), true);
if (is_array($res))
return;
// Check if exam mode should apply
$locations = ConfigHolder::get('SLX_LOCATIONS');
- if ($locations === false) {
+ if ($locations === null) {
$locationIds = [];
} else {
$locationIds = explode(' ', $locations);
@@ -26,6 +29,4 @@ $foofoo = function($machineUuid) {
// No saver
ConfigHolder::add('SLX_SCREEN_SAVER_TIMEOUT', '0', 1000);
}
-};
-
-$foofoo($uuid); \ No newline at end of file
+} \ No newline at end of file
diff --git a/modules-available/exams/inc/exams.inc.php b/modules-available/exams/inc/exams.inc.php
index da4dec85..86dc6d89 100644
--- a/modules-available/exams/inc/exams.inc.php
+++ b/modules-available/exams/inc/exams.inc.php
@@ -4,14 +4,11 @@ class Exams
{
/**
- * @param int[] of location ids. must bot be an associative array.
- * @return: bool true iff for any of the given location ids an exam is scheduled.
+ * @param int[] $locationIds of location ids. must be an associative array.
+ * @return bool true iff for any of the given location ids an exam is scheduled.
**/
- public static function isInExamMode($locationIds, &$lectureId = false, &$autoLogin = false)
+ public static function isInExamMode(array $locationIds, &$lectureId = false, &$autoLogin = false): bool
{
- if (!is_array($locationIds)) {
- $locationIds = array($locationIds);
- }
if (empty($locationIds)) {
$locationIds[] = 0;
}
diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php
index 458ae5b1..d229b883 100644
--- a/modules-available/exams/page.inc.php
+++ b/modules-available/exams/page.inc.php
@@ -103,7 +103,7 @@ class Page_Exams extends Page
}
// returns true if user is allowed to edit the exam
- protected function userCanEditExam($examid = NULL)
+ protected function userCanEditExam(string $examid = NULL): bool
{
if (in_array(0, $this->userEditLocations)) // Trivial case -- don't query if global perms
return true;
@@ -118,9 +118,12 @@ class Page_Exams extends Page
return true;
}
- // checks if user is allowed to save an exam with all the locations
- // needs information if it's add (second para = true) or edit (second para = false)
- protected function userCanEditLocation($locationids) {
+ /**
+ * checks if user is allowed to save an exam with all the locations
+ * needs information if it's add (second para = true) or edit (second para = false)
+ */
+ protected function userCanEditLocation(array $locationids): bool
+ {
return empty(array_diff($locationids, $this->userEditLocations));
}
@@ -213,7 +216,10 @@ class Page_Exams extends Page
return json_encode($out);
}
- protected function makeExamsForTemplate()
+ /**
+ * @return array{exams: array, decollapse: bool}
+ */
+ protected function makeExamsForTemplate(): array
{
$out = [];
$now = time();
@@ -248,7 +254,7 @@ class Page_Exams extends Page
return ['exams' => $out, 'decollapse' => $hasCollapsed];
}
- protected function makeLectureExamList()
+ protected function makeLectureExamList(): array
{
$out = [];
$now = time();
@@ -288,7 +294,7 @@ class Page_Exams extends Page
] + $source;
}
- private function isDateSane($time)
+ private function isDateSane(int $time): bool
{
return ($time >= strtotime('-10 years') && $time <= strtotime('+10 years'));
}