diff --git a/course/grades.php b/course/grades.php
index 487cad90402..ad030201619 100644
--- a/course/grades.php
+++ b/course/grades.php
@@ -35,20 +35,26 @@
$currentgroup = false;
}
- if ($currentgroup) {
- $students = get_group_students($currentgroup, "u.lastname ASC");
- } else {
- $students = get_course_students($course->id, "u.lastname ASC");
- }
-
/// Get a list of all students
- if (!$students) {
- print_header("$course->shortname: $strgrades", "$course->fullname",
- "wwwroot/course/view.php?id=$course->id\">$course->shortname
+ if ($currentgroup) {
+ if (!$students = get_group_students($currentgroup, "u.lastname ASC")) {
+ print_header("$course->shortname: $strgrades", "$course->fullname",
+ "wwwroot/course/view.php?id=$course->id\">$course->shortname
-> $strgrades");
- print_heading(get_string("nostudentsyet"));
- print_footer($course);
- exit;
+ setup_and_print_groups($course, $groupmode, "grades.php?id=$course->id");
+ notice(get_string("nostudentsingroup"), "$CFG->wwwroot/course/view.php?id=$course->id");
+ print_footer();
+ exit;
+ }
+ } else {
+ if (!$students = get_course_students($course->id, "u.lastname ASC")) {
+ print_header("$course->shortname: $strgrades", "$course->fullname",
+ "wwwroot/course/view.php?id=$course->id\">$course->shortname
+ -> $strgrades");
+ notice(get_string("nostudentsyet"), "$CFG->wwwroot/course/view.php?id=$course->id");
+ print_footer();
+ exit;
+ }
}
foreach ($students as $student) {
diff --git a/lang/en/moodle.php b/lang/en/moodle.php
index 59924340554..171d1f1bf26 100644
--- a/lang/en/moodle.php
+++ b/lang/en/moodle.php
@@ -763,6 +763,7 @@ $string['normal'] = 'Normal';
$string['normalfilter'] = 'Normal search';
$string['nostudentsfound'] = 'No $a found';
$string['nostudentsyet'] = 'No students enrolled in this course yet';
+$string['nostudentsingroup'] = 'There are no students in this group yet';
$string['nosuchemail'] = 'No such email address';
$string['notavailable'] = 'Not available';
$string['noteachersyet'] = 'No teachers in this course yet';