$string['notteachererror'] = 'You must be a teacher to use this feature.';
$string['notenrolled'] = 'You are currently not enrolled in any courses.';
$string['nousersloaded'] = 'No users loaded';
+$string['nouserstograde'] = 'No users to grade';
$string['numberofgrades'] = 'Number of grades';
$string['onascaleof'] = 'on a scale of {$a->grademin} to {$a->grademax}';
$string['operations'] = 'Operations';
import {createLayout as createFullScreenWindow} from 'mod_forum/local/layout/fullscreen';
import getGradingPanelFunctions from './local/grader/gradingpanel';
import {add as addToast} from 'core/toast';
+import {addNotification} from 'core/notification';
import {get_string as getString} from 'core/str';
import {failedUpdate} from 'core_grades/grades/grader/gradingpanel/normalise';
import {addIconToContainerWithPromise} from 'core/loadingicon';
// We need all of these functions to be executed in series, if one step runs before another the interface
// will not work.
+
+ // We need this promise to resolve separately so that we can avoid loading the whole interface if there are no users.
+ const userList = await getListOfUsers();
+ if (!userList.length) {
+ addNotification({
+ message: await getString('nouserstograde', 'core_grades'),
+ type: "error",
+ });
+ return;
+ }
+
+ // Now that we have confirmed there are at least some users let's boot up the grader interface.
const [
graderLayout,
{html, js},
- userList,
] = await Promise.all([
createFullScreenWindow({
fullscreen: false,
drawer: {show: true},
defaultsendnotifications: sendStudentNotifications,
}),
- getListOfUsers(),
]);
+
const graderContainer = graderLayout.getContainer();
const saveGradeFunction = getSaveUserGradeFunction(graderContainer, setGradeForUser);