From 9d7610060f6b6befdb11ee559447d1e3d0b01a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de> Date: Mon, 17 Jun 2024 05:58:46 +0000 Subject: [PATCH] Resolve #4283 "Gradebook: Beim Speichern einer Note wird das chdate immer aktualisiert" Closes #4283 Merge request studip/studip!3101 --- lib/models/Grading/Instance.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/models/Grading/Instance.php b/lib/models/Grading/Instance.php index 14ab25a8c4c..7f362d346e3 100644 --- a/lib/models/Grading/Instance.php +++ b/lib/models/Grading/Instance.php @@ -66,4 +66,22 @@ class Instance extends \SimpleORMap return self::findBySql('definition_id IN (?) AND user_id = ?', [$definitionIds, $user->id]); } + + /** + * setter for the rawgrade column. The database type is decimal(6,5) UNSIGNED, therefore + * the setter mimics the database behaviour to get valid results from ::isFieldDirty() + * + * @param mixed $grade + * @return string + */ + public function setRawgrade($grade = 0): string + { + if ($grade < 0) { + $grade = 0; + } + if ($grade >= 10) { + $grade = 9.99999; + } + return $this->content['rawgrade'] = number_format($grade, 5, '.', ''); + } } -- GitLab