1@gradereport @gradereport_grader
2Feature: We can change what we are viewing on the grader report
3  In order to check the expected results are displayed
4  As a teacher
5  I need to assign grades and check that they display correctly in the gradebook when switching between views.
6
7  Background:
8    Given the following "courses" exist:
9      | fullname | shortname | format |
10      | Course 1 | C1 | topics |
11    And the following "users" exist:
12      | username | firstname | lastname | email |
13      | teacher1 | Teacher | 1 | teacher1@example.com |
14      | student1 | Student | 1 | student1@example.com |
15      | student2 | Student | 1 | student2@example.com |
16    And the following "course enrolments" exist:
17      | user | course | role |
18      | teacher1 | C1 | editingteacher |
19      | student1 | C1 | student |
20    And I log in as "teacher1"
21    And I am on "Course 1" course homepage with editing mode on
22    And I add a "Assignment" to section "1" and I fill the form with:
23      | Assignment name | Test assignment name 1 |
24      | Description | Submit your online text |
25      | assignsubmission_onlinetext_enabled | 1 |
26    And I add a "Assignment" to section "1" and I fill the form with:
27      | Assignment name | Test assignment name 2 |
28      | Description | Submit your online text |
29      | assignsubmission_onlinetext_enabled | 1 |
30    And I log out
31    And I am on the "Test assignment name 1" "assign activity" page logged in as student1
32    When I press "Add submission"
33    And I set the following fields to these values:
34      | Online text | This is a submission for assignment 1 |
35    And I press "Save changes"
36    Then I should see "Submitted for grading"
37    And I am on the "Test assignment name 2" "assign activity" page
38    When I press "Add submission"
39    And I set the following fields to these values:
40      | Online text | This is a submission for assignment 2 |
41    And I press "Save changes"
42    Then I should see "Submitted for grading"
43    And I log out
44    And I log in as "teacher1"
45    And I am on "Course 1" course homepage
46    And I navigate to "View > Grader report" in the course gradebook
47    And I turn editing mode on
48    And I give the grade "80.00" to the user "Student 1" for the grade item "Test assignment name 1"
49    And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment name 2"
50    And I press "Save changes"
51    And I turn editing mode off
52
53  @javascript
54  Scenario: View and minimise the grader report containing hidden activities
55    When I am on "Course 1" course homepage with editing mode on
56    And I open "Test assignment name 2" actions menu
57    And I click on "Hide" "link" in the "Test assignment name 2" activity
58    And I am on "Course 1" course homepage
59    And I navigate to "View > Grader report" in the course gradebook
60    And I should see "Test assignment name 1"
61    And I should see "Test assignment name 2"
62    And I should see "Course total"
63    And the following should exist in the "user-grades" table:
64      | -1-                | -4-       | -5-       | -6-       |
65      | Student 1          | 80        | 90        | 170       |
66    And I click on "Change to aggregates only" "link"
67    And I should not see "Test assignment name 1"
68    And I should not see "Test assignment name 2"
69    And I should see "Course total"
70    And the following should exist in the "user-grades" table:
71      | -1-                | -4-       |
72      | Student 1          | 170       |
73    And I click on "Change to grades only" "link"
74    And I should see "Test assignment name 1"
75    And I should see "Test assignment name 2"
76    And I should not see "Course total"
77    And the following should exist in the "user-grades" table:
78      | -1-                | -4-       | -5-       |
79      | Student 1          | 80        | 90        |
80
81  @javascript @skip_chrome_zerosize
82  Scenario: View and minimise the grader report containing hidden activities without the 'moodle/grade:viewhidden' capability
83    When I am on "Course 1" course homepage with editing mode on
84    And I open "Test assignment name 2" actions menu
85    And I click on "Hide" "link" in the "Test assignment name 2" activity
86    And I log out
87    And I log in as "admin"
88    And I set the following system permissions of "Teacher" role:
89      | capability | permission |
90      | moodle/grade:viewhidden | Prevent |
91    And I log out
92    And the following "course enrolments" exist:
93      | user | course | role |
94      | student2 | C1 | student |
95    And I log in as "teacher1"
96    And I am on "Course 1" course homepage
97    And I navigate to "View > Grader report" in the course gradebook
98    And I should see "Test assignment name 1"
99    And I should see "Test assignment name 2"
100    And I should see "Course total"
101    And the following should exist in the "user-grades" table:
102      | -1-                | -4-       | -5-       | -6-       |
103      | Student 1          | 80        | -         | 80        |
104    And I click on "Change to aggregates only" "link"
105    And I should not see "Test assignment name 1"
106    And I should not see "Test assignment name 2"
107    And I should see "Course total"
108    And the following should exist in the "user-grades" table:
109      | -1-                | -4-       |
110      | Student 1          | 80        |
111    And I click on "Change to grades only" "link"
112    And I should see "Test assignment name 1"
113    And I should see "Test assignment name 2"
114    And I should not see "Course total"
115    And the following should exist in the "user-grades" table:
116      | -1-                | -4-       | -5-       |
117      | Student 1          | 80        | -         |
118