From: Mathew May Date: Tue, 5 Nov 2019 02:45:07 +0000 (+0800) Subject: MDL-66958 gradingform_rubric: Only save on form change X-Git-Tag: v3.8.0-beta~12^2~5 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=9769ba08b3b6c1bb47888bf19842b093606d9901 MDL-66958 gradingform_rubric: Only save on form change --- diff --git a/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js b/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js index b3a2eeae770..b4c76ecad85 100644 Binary files a/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js and b/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js differ diff --git a/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js.map b/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js.map index 8611812e7c4..427dec3fad0 100644 Binary files a/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js.map and b/grade/grading/form/rubric/amd/build/grades/grader/gradingpanel.min.js.map differ diff --git a/grade/grading/form/rubric/amd/src/grades/grader/gradingpanel.js b/grade/grading/form/rubric/amd/src/grades/grader/gradingpanel.js index 52307f5778a..2b34c1ef3d5 100644 --- a/grade/grading/form/rubric/amd/src/grades/grader/gradingpanel.js +++ b/grade/grading/form/rubric/amd/src/grades/grader/gradingpanel.js @@ -24,6 +24,7 @@ import {call as fetchMany} from 'core/ajax'; import {normaliseResult} from 'core_grades/grades/grader/gradingpanel/normalise'; +import {compareData} from 'core_grades/grades/grader/gradingpanel/comparison'; // Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send() @@ -65,14 +66,18 @@ export const fetchCurrentGrade = (component, contextid, itemname, gradeduserid) export const storeCurrentGrade = async(component, contextid, itemname, gradeduserid, rootNode) => { const form = rootNode.querySelector('form'); - return normaliseResult(await fetchMany([{ - methodname: `gradingform_rubric_grader_gradingpanel_store`, - args: { - component, - contextid, - itemname, - gradeduserid, - formdata: jQuery(form).serialize(), - }, - }])[0]); + if (compareData(form) === true) { + return normaliseResult(await fetchMany([{ + methodname: `gradingform_rubric_grader_gradingpanel_store`, + args: { + component, + contextid, + itemname, + gradeduserid, + formdata: jQuery(form).serialize(), + }, + }])[0]); + } else { + return ''; + } }; diff --git a/grade/grading/form/rubric/classes/grades/grader/gradingpanel/external/fetch.php b/grade/grading/form/rubric/classes/grades/grader/gradingpanel/external/fetch.php index c60f421d826..6cf05b73f89 100644 --- a/grade/grading/form/rubric/classes/grades/grader/gradingpanel/external/fetch.php +++ b/grade/grading/form/rubric/classes/grades/grader/gradingpanel/external/fetch.php @@ -159,7 +159,7 @@ class fetch extends external_api { $criterion = []; if ($definition->rubric_criteria) { // Iterate over the defined criterion in the rubric and map out what we need to render each item. - $criterion = array_map(function($criterion) use ($definitionid, $fillings, $context) { + $criterion = array_map(function($criterion) use ($definitionid, $fillings, $context, $hasgrade) { // The general structure we'll be returning, we still need to get the remark (if any) and the levels associated. $result = [ 'id' => $criterion['id'], @@ -213,8 +213,8 @@ class fetch extends external_api { 'id' => null, 'criterionid' => $criterion['id'], 'score' => '-', - 'definition' => 'Not set', - 'checked' => null, + 'definition' => get_string('notset', 'gradingform_rubric'), + 'checked' => !$hasgrade, ]; // Consult the grade filling to see if a level has been selected and if it is the current level. if (array_key_exists('levelid', $filling) && $filling['levelid'] == 0) { diff --git a/grade/grading/form/rubric/lang/en/gradingform_rubric.php b/grade/grading/form/rubric/lang/en/gradingform_rubric.php index 6e2d29973ff..85f3c6bc8e2 100644 --- a/grade/grading/form/rubric/lang/en/gradingform_rubric.php +++ b/grade/grading/form/rubric/lang/en/gradingform_rubric.php @@ -57,6 +57,7 @@ $string['lockzeropoints'] = 'Calculate grade based on the rubric having a minimu $string['lockzeropoints_help'] = 'This setting only applies if the sum of the minimum number of points for each criterion is greater than 0. If ticked, the minimum achievable grade for the rubric will be greater than 0. If unticked, the minimum possible score for the rubric will be mapped to the minimum grade available for the activity (which is 0 unless a scale is used).'; $string['name'] = 'Name'; $string['needregrademessage'] = 'The rubric definition was changed after this student had been graded. The student can not see this rubric until you check the rubric and update the grade.'; +$string['notset'] = 'Not set'; $string['pluginname'] = 'Rubric'; $string['pointsvalue'] = '{$a} points'; $string['previewrubric'] = 'Preview rubric'; diff --git a/grade/grading/form/rubric/templates/grades/grader/gradingpanel.mustache b/grade/grading/form/rubric/templates/grades/grader/gradingpanel.mustache index a3d31cbda0d..5164b5954fd 100644 --- a/grade/grading/form/rubric/templates/grades/grader/gradingpanel.mustache +++ b/grade/grading/form/rubric/templates/grades/grader/gradingpanel.mustache @@ -124,4 +124,4 @@ require(['core/auto_rows'], function(AutoRows) { AutoRows.init(document.getElementById('gradingform_rubric-{{uniqid}}')); }); -{{/js}} \ No newline at end of file +{{/js}}