Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lbplanner/classes/helpers/plan_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function get_access_type(int $userid, int $planid): int {
if ($field === false) {
return PLAN_ACCESS_TYPE::NONE;
} else {
return PLAN_ACCESS_TYPE::from($field);
return PLAN_ACCESS_TYPE::from((int)$field);
}
}

Expand Down
5 changes: 2 additions & 3 deletions lbplanner/classes/polyfill/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
namespace local_lbplanner\polyfill;

use ReflectionClass;
use ValueError;
use local_lbplanner\polyfill\EnumCase;

/**
Expand All @@ -38,7 +37,7 @@ class Enum {
* @param mixed $value the value to be matched
* @param bool $try whether to return null (true) or throw an error (false) if not found
* @return ?EnumCase the matching enum case or null if not found and $try==true
* @throws ValueError if not found and $try==false
* @throws \moodle_exception if not found and $try==false
*/
private static function find(mixed $value, bool $try): ?EnumCase {
foreach (static::cases() as $case) {
Expand All @@ -50,7 +49,7 @@ private static function find(mixed $value, bool $try): ?EnumCase {
if ($try) {
return null;
} else {
throw new ValueError("value {$value} cannot be represented as a value in enum ".static::class);
throw new \moodle_exception("value {$value} cannot be represented as a value in enum ".static::class);
}
}
/**
Expand Down
6 changes: 3 additions & 3 deletions lbplanner/services/plan/set_deadline.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public static function set_deadline(int $moduleid, int $deadlinestart, int $dead
throw new \moodle_exception('Access denied');
}

// If a deadline already exists.
if (!$DB->record_exists(plan_helper::DEADLINES_TABLE, ['moduleid' => $moduleid, 'planid' => $planid])) {
$deadline = $DB->get_record(plan_helper::DEADLINES_TABLE, ['moduleid' => $moduleid, 'planid' => $planid]);

if ($deadline !== false) {
// Update the existing deadline.
$deadline = $DB->get_record(plan_helper::DEADLINES_TABLE, ['moduleid' => $moduleid, 'planid' => $planid]);

$deadline->deadlinestart = $deadlinestart;
$deadline->deadlineend = $deadlineend;
Expand Down
Loading