MDL-66958 core_grade: Only save point on form change
authorMathew May <mathewm@hotmail.co.nz>
Tue, 5 Nov 2019 09:43:20 +0000 (17:43 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Mon, 11 Nov 2019 03:25:17 +0000 (11:25 +0800)
grade/amd/build/grades/grader/gradingpanel/point.min.js
grade/amd/build/grades/grader/gradingpanel/point.min.js.map
grade/amd/src/grades/grader/gradingpanel/point.js
grade/classes/grades/grader/gradingpanel/point/external/store.php

index e7096de..3f9ab23 100644 (file)
Binary files a/grade/amd/build/grades/grader/gradingpanel/point.min.js and b/grade/amd/build/grades/grader/gradingpanel/point.min.js differ
index 7bc1669..81470f9 100644 (file)
Binary files a/grade/amd/build/grades/grader/gradingpanel/point.min.js.map and b/grade/amd/build/grades/grader/gradingpanel/point.min.js.map differ
index 5dea4db..5fc6fa1 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 import {saveGrade, fetchGrade} from './repository';
+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';
 import {invalidResult} from './normalise';
@@ -57,5 +58,9 @@ export const storeCurrentGrade = async(component, context, itemname, userId, roo
         return invalidResult;
     }
 
-    return await saveGrade('point')(component, context, itemname, userId, jQuery(form).serialize());
+    if (compareData(form) === true) {
+        return await saveGrade('point')(component, context, itemname, userId, jQuery(form).serialize());
+    } else {
+        return '';
+    }
 };
index 3649e53..bc9e989 100644 (file)
@@ -152,10 +152,11 @@ class store extends external_api {
         // Grade.
         $gradeitem->store_grade_from_formdata($gradeduser, $USER, (object) $data);
 
+        $hasgrade = $gradeitem->get_grade_status_for_user($gradeduser);
         // Fetch the updated grade back out.
         $grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
 
-        return fetch::get_fetch_data($grade);
+        return fetch::get_fetch_data($grade, $hasgrade);
     }
 
     /**