MDL-52132 qbehaviour_manualgraded: no change when comment is left blank
authorShamim Rezaie <shamim@moodle.com>
Thu, 24 Jan 2019 07:14:16 +0000 (18:14 +1100)
committerJake Dallimore <jake@moodle.com>
Thu, 24 Jan 2019 08:20:01 +0000 (16:20 +0800)
question/behaviour/behaviourbase.php

index b321cf2..b7f7fc1 100644 (file)
@@ -392,7 +392,9 @@ abstract class question_behaviour {
         $previouscomment = $this->qa->get_last_behaviour_var('comment');
         $newcomment = $pendingstep->get_behaviour_var('comment');
 
-        if ($previouscomment != $newcomment) {
+        // When the teacher leaves the comment empty, $previouscomment is an empty string but $newcomment is null,
+        // therefore they are not equal to each other. That's why checking if $previouscomment != $newcomment is not enough.
+        if (($previouscomment != $newcomment) && !(is_null($previouscomment) && html_is_blank($newcomment))) {
             // The comment has changed.
             return false;
         }