diff --git a/lib/models/Grading/Instance.php b/lib/models/Grading/Instance.php index 901fcff39cddc05dde0ebcf5fe55d8dc180e4fe9..be82b8e1d47e1aa5e5f0b796f1a40013478d5ca8 100644 --- a/lib/models/Grading/Instance.php +++ b/lib/models/Grading/Instance.php @@ -53,4 +53,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, '.', ''); + } }