MDL-66828 mod_forum: Display notification on grade save
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 3 Oct 2019 03:35:21 +0000 (11:35 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Wed, 30 Oct 2019 02:23:41 +0000 (10:23 +0800)
Part of MDL-66074

mod/forum/amd/build/local/grades/grader.min.js
mod/forum/amd/build/local/grades/grader.min.js.map
mod/forum/amd/src/local/grades/grader.js
mod/forum/lang/en/forum.php

index b2cfa92..5ee007b 100644 (file)
Binary files a/mod/forum/amd/build/local/grades/grader.min.js and b/mod/forum/amd/build/local/grades/grader.min.js differ
index a79da72..ce4ed19 100644 (file)
Binary files a/mod/forum/amd/build/local/grades/grader.min.js.map and b/mod/forum/amd/build/local/grades/grader.min.js.map differ
index 33b2b75..2697509 100644 (file)
@@ -27,6 +27,8 @@ import Selectors from './local/grader/selectors';
 import * as UserPicker from './local/grader/user_picker';
 import {createLayout as createFullScreenWindow} from 'mod_forum/local/layout/fullscreen';
 import getGradingPanelFunctions from './local/grader/gradingpanel';
+import {add as addToast} from 'core/toast';
+import {get_string as getString} from 'core/str';
 
 const templateNames = {
     grader: {
@@ -78,9 +80,23 @@ const registerEventListeners = (graderLayout) => {
     });
 };
 
+/**
+ * Get the function used to save a user grade.
+ *
+ * @param {Element} root The contaienr
+ * @param {Function} setGradeForUser The function that will be called.
+ * @return {Function}
+ */
 const getSaveUserGradeFunction = (root, setGradeForUser) => {
-    return user => {
-        return setGradeForUser(user.id, root.querySelector(Selectors.regions.gradingPanel));
+    return async user => {
+        try {
+            const result = await setGradeForUser(user.id, root.querySelector(Selectors.regions.gradingPanel));
+            addToast(await getString('grades:gradesavedfor', 'mod_forum', user));
+
+            return result;
+        } catch (error) {
+            throw error;
+        }
     };
 };
 
index 29789c6..8d0a946 100644 (file)
@@ -727,6 +727,7 @@ $string['gradeforwholeforum'] = 'Grade for forum: {$a->str_long_grade}';
 $string['gradeforwholeforumhidden'] = 'Grade for forum hidden';
 $string['gradeitemnameforwholeforum'] = 'Whole forum grade for {$a->name}';
 $string['gradeitemnameforrating'] = 'Rating grade for {$a->name}';
+$string['grades:gradesavedfor'] = 'Grade saved for {$a->fullname}';
 
 // Deprecated since Moodle 3.8.
 $string['cannotdeletediscussioninsinglediscussion'] = 'You cannot delete the first post in a single discussion';