diff --git a/mod/assign/gradingtable.php b/mod/assign/gradingtable.php
index <HASH>..<HASH> 100644
--- a/mod/assign/gradingtable.php
+++ b/mod/assign/gradingtable.php
@@ -373,7 +373,7 @@ class assign_grading_table extends table_sql implements renderable {
     function col_timemarked(stdClass $row) {
         $o = '-';
 
-        if ($row->timemarked) {
+        if ($row->timemarked && $row->grade !== NULL && $row->grade >= 0) {
             $o = userdate($row->timemarked);
         }
 
diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php
index <HASH>..<HASH> 100644
--- a/mod/assign/locallib.php
+++ b/mod/assign/locallib.php
@@ -2121,7 +2121,9 @@ class assign {
         // trying to match those array keys in grade update function in gradelib.php
         // with keys in th database table assign_grades
         // starting around line 262
-        $gradebookgrade['rawgrade'] = $grade->grade;
+        if ($grade->grade >= 0) {
+            $gradebookgrade['rawgrade'] = $grade->grade;
+        }
         $gradebookgrade['userid'] = $grade->userid;
         $gradebookgrade['usermodified'] = $grade->grader;
         $gradebookgrade['datesubmitted'] = NULL;
MDL-<I>: Prevent locking an assignment submission from putting a grade of 0 in the gradebook