MDL-50483 gradereport_user: fix the fatal error of no enrolled users
authorJinu Abraham <jinu.abraham@blackboard.com>
Mon, 31 Aug 2015 05:18:31 +0000 (14:48 +0930)
committerSimey Lameze <simey@moodle.com>
Mon, 19 Oct 2015 00:58:34 +0000 (08:58 +0800)
grade/report/user/index.php
grade/report/user/tests/behat/view_usereport.feature [new file with mode: 0644]

index 3136c56..b1023e9 100644 (file)
@@ -167,6 +167,10 @@ if (has_capability('moodle/grade:viewall', $context)) { //Teachers will see all
 }
 
 // Trigger report viewed event.
 }
 
 // Trigger report viewed event.
-$report->viewed();
+if (isset($report)) {
+    $report->viewed();
+} else {
+    echo $OUTPUT->notification(get_string('nostudentsyet'));
+}
 
 echo $OUTPUT->footer();
 
 echo $OUTPUT->footer();
diff --git a/grade/report/user/tests/behat/view_usereport.feature b/grade/report/user/tests/behat/view_usereport.feature
new file mode 100644 (file)
index 0000000..b9c7d11
--- /dev/null
@@ -0,0 +1,20 @@
+@core @core_grades @gradereport_user
+Feature: We can use the user report
+  As a user
+  I browse to the User report
+
+  Background:
+    Given the following "courses" exist:
+      | fullname | shortname | category |
+      | Course 1 | C1 | 0 |
+
+    Scenario: Verify we can view a user grade report with no users enrolled.
+    Given I log in as "admin"
+    And I am on site homepage
+    And I follow "Course 1"
+    And I navigate to "Grades" node in "Course administration"
+    And I select "User report" from the "Grade report" singleselect
+    And I press "Go"
+    And I select "All users (0)" from the "Select all or one user" singleselect
+    And I click on "Go" "button" in the "#choosegradeuser" "css_element"
+    Then I should see "No students enrolled in this course yet"