aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Grading
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models/Grading')
-rw-r--r--lib/models/Grading/Instance.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/models/Grading/Instance.php b/lib/models/Grading/Instance.php
index 14ab25a..7f362d3 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, '.', '');
+ }
}