From 996531e7f17f1df2c31cc176587d042700954425 Mon Sep 17 00:00:00 2001 From: Matteo Scaramuccia Date: Sun, 6 Oct 2013 14:13:31 +0200 Subject: [PATCH] MDL-42167 Update workshop assessment record only when really changed Under certain conditions there is nothing to actually update here. The $DB->update_record() would throw an exception here. --- mod/workshop/assessment.php | 5 ++++- mod/workshop/exassessment.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mod/workshop/assessment.php b/mod/workshop/assessment.php index 437be6ade68..d120d12b29f 100644 --- a/mod/workshop/assessment.php +++ b/mod/workshop/assessment.php @@ -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)) { diff --git a/mod/workshop/exassessment.php b/mod/workshop/exassessment.php index 32b548509eb..4515de22041 100644 --- a/mod/workshop/exassessment.php +++ b/mod/workshop/exassessment.php @@ -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) { -- 2.43.0