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: {
});
};
+/**
+ * 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;
+ }
};
};
$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';