MDL-42167 Update workshop assessment record only when really changed
authorMatteo Scaramuccia <moodle@matteoscaramuccia.com>
Sun, 6 Oct 2013 12:13:31 +0000 (14:13 +0200)
committerDavid Mudrák <david@moodle.com>
Thu, 10 Oct 2013 08:07:53 +0000 (10:07 +0200)
Under certain conditions there is nothing to actually update here. The
$DB->update_record() would throw an exception here.

mod/workshop/assessment.php
mod/workshop/exassessment.php

index 437be6a..d120d12 100644 (file)
@@ -191,7 +191,10 @@ if (is_null($assessment->grade) and !$assessmenteditable) {
         if (isset($data->weight) and $cansetassessmentweight) {
             $coredata->weight = $data->weight;
         }
-        $DB->update_record('workshop_assessments', $coredata);
+        // Update the assessment data if there is something other than just the 'id'.
+        if (count((array)$coredata) > 1 ) {
+            $DB->update_record('workshop_assessments', $coredata);
+        }
 
         // And finally redirect the user's browser.
         if (!is_null($rawgrade) and isset($data->saveandclose)) {
index 32b5485..4515de2 100644 (file)
@@ -126,7 +126,10 @@ if ($mform->is_cancelled()) {
         // Remember the last one who edited the reference assessment.
         $coredata->reviewerid = $USER->id;
     }
-    $DB->update_record('workshop_assessments', $coredata);
+    // Update the assessment data if there is something other than just the 'id'.
+    if (count((array)$coredata) > 1 ) {
+        $DB->update_record('workshop_assessments', $coredata);
+    }
 
     if (!is_null($rawgrade) and isset($data->saveandclose)) {
         if ($canmanage) {