|
| 1 | + |
| 2 | +@core_grades @app @core @javascript @test |
| 3 | +Feature: We don't show hidden grades for users without the 'moodle/grade:viewhidden' capability on user report |
| 4 | + In order to show user report in secure way |
| 5 | + As a teacher without the 'moodle/grade:viewhidden' capability |
| 6 | + I should not see hidden grades in the user report |
| 7 | + |
| 8 | + Background: |
| 9 | + Given the following "courses" exist: |
| 10 | + | fullname | shortname | format | |
| 11 | + | Course 1 | C1 | topics | |
| 12 | + And the following "users" exist: |
| 13 | + | username | firstname | lastname | email | |
| 14 | + | teacher1 | Teacher | 1 | teacher1@example.com | |
| 15 | + | student1 | Student1 | 1 | student1@example.com | |
| 16 | + | student2 | Student2 | 2 | student2@example.com | |
| 17 | + And the following "course enrolments" exist: |
| 18 | + | user | course | role | |
| 19 | + | teacher1 | C1 | editingteacher | |
| 20 | + | student1 | C1 | student | |
| 21 | + | student2 | C1 | student | |
| 22 | + And the following "activities" exist: |
| 23 | + | activity | course | section | name | intro | assignsubmission_onlinetext_enabled | submissiondrafts | |
| 24 | + | assign | C1 | 1 | Test assignment name 1 | Submit your online text | 1 | 0 | |
| 25 | + | assign | C1 | 1 | Test assignment name 2 | submit your online text | 1 | 0 | |
| 26 | + | assign | C1 | 1 | Test assignment name 3 | submit your online text | 1 | 0 | |
| 27 | + # Hidden manual grade item. |
| 28 | + And the following "grade items" exist: |
| 29 | + | itemname | grademin | grademax | course | hidden | |
| 30 | + | Manual grade | 20 | 40 | C1 | 1 | |
| 31 | + And the following "grade grades" exist: |
| 32 | + | gradeitem | user | grade | |
| 33 | + | Test assignment name 1 | student1 | 80 | |
| 34 | + | Test assignment name 1 | student2 | 70 | |
| 35 | + | Test assignment name 2 | student1 | 90 | |
| 36 | + | Test assignment name 2 | student2 | 60 | |
| 37 | + | Test assignment name 3 | student1 | 10 | |
| 38 | + | Test assignment name 3 | student2 | 50 | |
| 39 | + | Manual grade | student1 | 30 | |
| 40 | + | Manual grade | student2 | 40 | |
| 41 | + And I log in as "admin" |
| 42 | + # Need to show hidden items in order to check hidden grades. Also lets show totals if they contain hidden items. |
| 43 | + And the following config values are set as admin: |
| 44 | + | grade_report_user_showhiddenitems | 2 | |
| 45 | + | grade_report_user_showtotalsifcontainhidden | 2 | |
| 46 | + And I am on "Course 1" course homepage with editing mode on |
| 47 | + # Hide assignment 2 activity. |
| 48 | + And I open "Test assignment name 2" actions menu |
| 49 | + And I choose "Hide" in the open action menu |
| 50 | + And I navigate to "View > Grader report" in the course gradebook |
| 51 | + # Hide grade. |
| 52 | + And I click on grade menu "Test assignment name 1" for user "student1" |
| 53 | + And I choose "Hide" in the open action menu |
| 54 | + # Hide assignment 3 grade item. |
| 55 | + And I set the following settings for grade item "Test assignment name 3" of type "gradeitem" on "grader" page: |
| 56 | + | Hidden | 1 | |
| 57 | + |
| 58 | + Scenario: View user report containing hidden activities or grade items or grades with capabilities with student view |
| 59 | + Given I entered the course "Course 1" as "teacher1" in the app |
| 60 | + When I press "Grades" in the app |
| 61 | + And I press "Student1 1" in the app |
| 62 | + |
| 63 | + # Student View. |
| 64 | + And I should find "-" within "Test assignment name 1" "tr" in the app |
| 65 | + And I should find "-" within "Test assignment name 3" "tr" in the app |
| 66 | + And I should find "-" within "Manual grade" "tr" in the app |
| 67 | + And I should find "210" within "Course total" "tr" in the app |
| 68 | + And I should not find "Test assignment name 2" in the app |
| 69 | + |
| 70 | + And I go back in the app |
| 71 | + And I press "Student2 2" in the app |
| 72 | + And I should find "70" within "Test assignment name 1" "tr" in the app |
| 73 | + And I should find "-" within "Test assignment name 3" "tr" in the app |
| 74 | + And I should find "-" within "Manual grade" "tr" in the app |
| 75 | + And I should find "220" within "Course total" "tr" in the app |
| 76 | + And I should not find "Test assignment name 2" in the app |
| 77 | + |
| 78 | + Scenario: View user report containing hidden activities or grade items or grades without capabilities with student view |
| 79 | + Given the following "role capability" exists: |
| 80 | + | role | editingteacher | |
| 81 | + | moodle/grade:viewhidden | prohibit | |
| 82 | + And I entered the course "Course 1" as "teacher1" in the app |
| 83 | + When I press "Grades" in the app |
| 84 | + And I press "Student2 2" in the app |
| 85 | + |
| 86 | + And I should find "-" within "Test assignment name 1" "tr" in the app |
| 87 | + And I should find "-" within "Test assignment name 3" "tr" in the app |
| 88 | + And I should find "-" within "Manual grade" "tr" in the app |
| 89 | + And I should find "210" within "Course total" "tr" in the app |
| 90 | + And I should not find "Test assignment name 2" in the app |
| 91 | + |
| 92 | + And I go back in the app |
| 93 | + And I press "Student1 1" in the app |
| 94 | + |
| 95 | + And I should find "-" within "Test assignment name 1" "tr" in the app |
| 96 | + And I should find "-" within "Test assignment name 3" "tr" in the app |
| 97 | + And I should find "-" within "Manual grade" "tr" in the app |
| 98 | + And I should find "210" within "Course total" "tr" in the app |
| 99 | + And I should not find "Test assignment name 2" in the app |
0 commit comments