| 1 | efrain | 1 | @core @core_grades @javascript
 | 
        
           |  |  | 2 | Feature: We can enter in grades and view reports from the gradebook
 | 
        
           |  |  | 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.
 | 
        
           |  |  | 6 |   I need to enable grade weightings and check that they are displayed correctly.
 | 
        
           |  |  | 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 | Student | 1 | student1@example.com |
 | 
        
           |  |  | 16 |     And the following "course enrolments" exist:
 | 
        
           |  |  | 17 |       | user | course | role |
 | 
        
           |  |  | 18 |       | teacher1 | C1 | editingteacher |
 | 
        
           |  |  | 19 |       | student1 | C1 | student |
 | 
        
           |  |  | 20 |     And the following "activities" exist:
 | 
        
           |  |  | 21 |       | activity   | name                   | course | idnumber | assignsubmission_onlinetext_enabled |
 | 
        
           |  |  | 22 |       | assign     | Test assignment name 1 | C1     | assign1  | 1                                   |
 | 
        
           |  |  | 23 |       | assign     | Test assignment name 2 | C1     | assign2  | 1                                   |
 | 
        
           |  |  | 24 |     And I log in as "admin"
 | 
        
           |  |  | 25 |     And I set the following administration settings values:
 | 
        
           |  |  | 26 |       | grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
 | 
        
           |  |  | 27 |     And I am on the "Test assignment name 1" "assign activity" page logged in as student1
 | 
        
           |  |  | 28 |     When I press "Add submission"
 | 
        
           |  |  | 29 |     And I set the following fields to these values:
 | 
        
           |  |  | 30 |       | Online text | This is a submission for assignment 1 |
 | 
        
           |  |  | 31 |     And I press "Save changes"
 | 
        
           |  |  | 32 |     And I press "Submit assignment"
 | 
        
           |  |  | 33 |     And I press "Continue"
 | 
        
           |  |  | 34 |     Then I should see "Submitted for grading"
 | 
        
           |  |  | 35 |     And I am on the "Test assignment name 2" "assign activity" page
 | 
        
           |  |  | 36 |     When I press "Add submission"
 | 
        
           |  |  | 37 |     And I set the following fields to these values:
 | 
        
           |  |  | 38 |       | Online text | This is a submission for assignment 2 |
 | 
        
           |  |  | 39 |     And I press "Save changes"
 | 
        
           |  |  | 40 |     And I press "Submit assignment"
 | 
        
           |  |  | 41 |     And I press "Continue"
 | 
        
           |  |  | 42 |     Then I should see "Submitted for grading"
 | 
        
           |  |  | 43 |     And I am on the "Course 1" "grades > Grader report > View" page logged in as "teacher1"
 | 
        
           |  |  | 44 |     And I turn editing mode on
 | 
        
           |  |  | 45 |     And I give the grade "80.00" to the user "Student 1" for the grade item "Test assignment name 1"
 | 
        
           |  |  | 46 |     And I give the grade "90.00" to the user "Student 1" for the grade item "Test assignment name 2"
 | 
        
           |  |  | 47 |     And I press "Save changes"
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |   Scenario: Grade a grade item and ensure the results display correctly in the gradebook
 | 
        
           |  |  | 50 |     When I navigate to "View > User report" in the course gradebook
 | 
        
           |  |  | 51 |     And the "Gradebook navigation menu" select menu should contain "Grader report"
 | 
        
           |  |  | 52 |     And I set the field "Search users" to "Student"
 | 
        
           |  |  | 53 |     And "View all results (1)" "list_item" should exist
 | 
        
           |  |  | 54 |     And I click on "View all results (1)" "option_role"
 | 
        
           |  |  | 55 |     And I log out
 | 
        
           |  |  | 56 |     And I log in as "student1"
 | 
        
           |  |  | 57 |     And I follow "Grades" in the user menu
 | 
        
           |  |  | 58 |     And I click on "Course 1" "link" in the "region-main" "region"
 | 
        
           |  |  | 59 |     Then the following should exist in the "user-grade" table:
 | 
        
           |  |  | 60 |       | Grade item | Grade | Range | Percentage |
 | 
        
           |  |  | 61 |       | Test assignment name 1 | 80.00 | 0–100 | 80.00 % |
 | 
        
           |  |  | 62 |       | Test assignment name 2 | 90.00 | 0–100 | 90.00 % |
 | 
        
           |  |  | 63 |       | Course total | 170.00 | 0–200 | 85.00 % |
 | 
        
           |  |  | 64 |     And the following should not exist in the "user-grade" table:
 | 
        
           |  |  | 65 |       | Grade item | Grade | Range | Percentage |
 | 
        
           |  |  | 66 |       | Course total | 90.00 | 0–100 | 90.00 % |
 | 
        
           |  |  | 67 |     And I follow "Grades" in the user menu
 | 
        
           |  |  | 68 |     And "Course 1" row "Grade" column of "overview-grade" table should contain "170.00"
 | 
        
           |  |  | 69 |     And "Course 1" row "Grade" column of "overview-grade" table should not contain "90.00"
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |   Scenario: We can add a weighting to a grade item and it is displayed properly in the user report
 | 
        
           |  |  | 72 |     When I navigate to "Setup > Gradebook setup" in the course gradebook
 | 
        
           |  |  | 73 |     And I set the following settings for grade item "Course 1" of type "course" on "setup" page:
 | 
        
           |  |  | 74 |       | Aggregation | Weighted mean of grades |
 | 
        
           |  |  | 75 |     And I set the field "Extra credit value for Test assignment name" to "0.72"
 | 
        
           |  |  | 76 |     And I press "Save changes"
 | 
        
           |  |  | 77 |     And I navigate to "Setup > Course grade settings" in the course gradebook
 | 
        
           |  |  | 78 |     And I set the following fields to these values:
 | 
        
           |  |  | 79 |       | Show weightings | Show |
 | 
        
           |  |  | 80 |     And I press "Save changes"
 | 
        
           |  |  | 81 |     And I log out
 | 
        
           |  |  | 82 |     And I log in as "student1"
 | 
        
           |  |  | 83 |     And I follow "Grades" in the user menu
 | 
        
           |  |  | 84 |     And I click on "Course 1" "link" in the "region-main" "region"
 | 
        
           |  |  | 85 |     Then the following should exist in the "user-grade" table:
 | 
        
           |  |  | 86 |       | Grade item             | Calculated weight | Grade | Range | Percentage |
 | 
        
           |  |  | 87 |       | Test assignment name 1 | 41.86 %           | 80.00 | 0–100 | 80.00 %    |
 | 
        
           |  |  | 88 |       | Test assignment name 2 | 58.14 %           | 90.00 | 0–100 | 90.00 %    |
 | 
        
           |  |  | 89 |       | Course total           | -                 | 85.81 | 0–100 | 85.81 %    |
 | 
        
           |  |  | 90 |     And the following should not exist in the "user-grade" table:
 | 
        
           |  |  | 91 |       | Grade item | Calculated weight | Percentage |
 | 
        
           |  |  | 92 |       | Test assignment name 1 | 0.72% | 0.72% |
 | 
        
           |  |  | 93 |       | Test assignment name 2 | 1.00% | 1.00% |
 | 
        
           |  |  | 94 |       | Course total | 1.00% | 1.00% |
 |