MDL-66958 gradingform_guide: Only save on form change
authorMathew May <mathewm@hotmail.co.nz>
Tue, 5 Nov 2019 09:42:10 +0000 (17:42 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Mon, 11 Nov 2019 03:25:17 +0000 (11:25 +0800)
grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js
grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map
grade/grading/form/guide/amd/src/grades/grader/gradingpanel.js

index 4ef79c5..7fbdf88 100644 (file)
Binary files a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js and b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js differ
index 93c1615..c3abc7b 100644 (file)
Binary files a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map and b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map differ
index 5f08608..287f104 100644 (file)
@@ -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()
 import jQuery from 'jquery';
@@ -64,14 +65,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_guide_grader_gradingpanel_store`,
-        args: {
-            component,
-            contextid,
-            itemname,
-            gradeduserid,
-            formdata: jQuery(form).serialize(),
-        },
-    }])[0]);
+    if (compareData(form) === true) {
+        return normaliseResult(await fetchMany([{
+            methodname: `gradingform_guide_grader_gradingpanel_store`,
+            args: {
+                component,
+                contextid,
+                itemname,
+                gradeduserid,
+                formdata: jQuery(form).serialize(),
+            },
+        }])[0]);
+    } else {
+        return '';
+    }
 };