From 3b7a18f2e5881c8a738f9cd23037bf4c7efd0448 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Wed, 21 Nov 2012 09:19:45 +0800 Subject: [PATCH] MDL-36167: Assignment quickgrading fix when there is no grade (ensure feedback still saves) This patch modifies the previous on by Luke Tucker so that the lastmodified hidden field is always added to the quickgrading form even if there is no grade for the assignment. This ensures that the lastmodified checks still work (to prevent teachers overwriting each others feedback) and feedback is saved when there is no grade. --- mod/assign/locallib.php | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 6d80290191767..bf618e8c83926 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1022,6 +1022,8 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) { static $scalegrades = array(); + $o = ''; + if ($this->get_instance()->grade >= 0) { // Normal number if ($editing && $this->get_instance()->grade > 0) { @@ -1030,17 +1032,20 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) { } else { $displaygrade = format_float($grade); } - $o = ''; - $o .= ''; + $o .= ''; + $o .= ''; $o .= ' / ' . format_float($this->get_instance()->grade,2); $o .= ''; return $o; } else { + $o .= ''; if ($grade == -1 || $grade === null) { - return '-'; + $o .= '-'; + return $o; } else { - return format_float(($grade),2) .' / '. format_float($this->get_instance()->grade,2); + $o .= format_float(($grade),2) .' / '. format_float($this->get_instance()->grade,2); + return $o; } } @@ -1050,11 +1055,12 @@ public function display_grade($grade, $editing, $userid=0, $modified=0) { if ($scale = $DB->get_record('scale', array('id'=>-($this->get_instance()->grade)))) { $this->cache['scale'] = make_menu_from_list($scale->scale); } else { - return '-'; + $o .= '-'; + return $o; } } if ($editing) { - $o = ''; + $o .= ''; $o .= '