MDL-40626 gradebook: Prevent incorrect override with multiline feedback
authorTim Lock <tim.lock@netspot.com.au>
Thu, 11 Jul 2013 08:33:34 +0000 (18:03 +0930)
committerDan Poltawski <dan@moodle.com>
Fri, 19 Jul 2013 04:00:24 +0000 (12:00 +0800)
The quick grading option doesn't allow mutliline editing.

grade/report/grader/lib.php

index 5782621..9ee5b17 100644 (file)
@@ -226,6 +226,10 @@ class grade_report_grader extends grade_report {
                         $changedgrades = true;
 
                     } else if ($datatype === 'feedback') {
+                        // If quick grading is on, feedback needs to be compared without line breaks.
+                        if ($this->get_pref('quickgrading')) {
+                            $oldvalue->feedback = preg_replace("/\r\n|\r|\n/", "", $oldvalue->feedback);
+                        }
                         if (($oldvalue->feedback === $postedvalue) or ($oldvalue->feedback === NULL and empty($postedvalue))) {
                             continue;
                         }