From afd45fd90e176528dc5a44b3d8dfdee4b5beb3db Mon Sep 17 00:00:00 2001 From: Ilya Tregubov Date: Tue, 1 Nov 2022 11:11:27 +0300 Subject: [PATCH] MDL-75455 gradereport_singleview: Readd Behat tests for bulk insert. Part of: MDL-75423 --- .../tests/behat/bulk_insert_grades.feature | 247 ++++++++++-------- .../singleview/tests/behat/singleview.feature | 61 +++-- 2 files changed, 173 insertions(+), 135 deletions(-) diff --git a/grade/report/singleview/tests/behat/bulk_insert_grades.feature b/grade/report/singleview/tests/behat/bulk_insert_grades.feature index 8a7384e47b6..638e7bf743b 100644 --- a/grade/report/singleview/tests/behat/bulk_insert_grades.feature +++ b/grade/report/singleview/tests/behat/bulk_insert_grades.feature @@ -1,107 +1,140 @@ -#@core @core_grades @gradereport_singleview @javascript -#Feature: We can bulk insert grades for students in a course -# As a teacher -# In order to quickly grade items -# I can bulk insert values for all or empty grades. -# -# Background: -# Given the following "courses" exist: -# | fullname | shortname | category | -# | Course 1 | C1 | 0 | -# And the following "users" exist: -# | username | firstname | lastname | email | idnumber | alternatename | -# | teacher1 | Teacher | 1 | teacher1@example.com | t1 | fred | -# | student1 | Student | 1 | student1@example.com | s1 | james | -# | student2 | Student | 2 | student1@example.com | s2 | holly | -# | student3 | Student | 3 | student1@example.com | s3 | anna | -# | student4 | Student | 4 | student1@example.com | s4 | zac | -# And the following "course enrolments" exist: -# | user | course | role | -# | teacher1 | C1 | editingteacher | -# | student1 | C1 | student | -# | student2 | C1 | student | -# | student3 | C1 | student | -# | student4 | C1 | student | -# And the following "activities" exist: -# | activity | course | idnumber | name | intro | -# | assign | C1 | a1 | Test assignment one | Submit something! | -# | assign | C1 | a2 | Test assignment two | Submit something! | -# | assign | C1 | a3 | Test assignment three | Submit something! | -# | assign | C1 | a4 | Test assignment four | Submit nothing! | -# -# Scenario: I can bulk insert grades and check their override flags for grade view. -# Given I am on the "Test assignment one" "assign activity" page logged in as teacher1 -# And I follow "View all submissions" -# And I click on "Grade" "link" in the "Student 1" "table_row" -# And I set the following fields to these values: -# | Grade out of 100 | 50 | -# And I press "Save changes" -# And I am on "Course 1" course homepage -# And I navigate to "View > Grader report" in the course gradebook -# And I follow "Single view for Test assignment one" -# Then the field "Grade for Student 1" matches value "50.00" -# And the field "Override for Student 1" matches value "0" -# And I set the field "Perform bulk insert" to "1" -# And I set the field "Insert value" to "1.0" -# And I press "Save" -# And the field "Grade for Student 1" matches value "50.00" -# And the field "Override for Student 1" matches value "0" -# And the field "Grade for Student 2" matches value "1.00" -# And the field "Override for Student 2" matches value "1" -# And the field "Grade for Student 3" matches value "1.00" -# And the field "Override for Student 3" matches value "1" -# And the field "Grade for Student 4" matches value "1.00" -# And the field "Override for Student 4" matches value "1" -# And I set the field "For" to "All grades" -# And I set the field "Perform bulk insert" to "1" -# And I set the field "Insert value" to "2.0" -# And I press "Save" -# And the field "Grade for Student 1" matches value "2.00" -# And the field "Override for Student 1" matches value "1" -# And the field "Grade for Student 2" matches value "2.00" -# And the field "Override for Student 2" matches value "1" -# And the field "Grade for Student 3" matches value "2.00" -# And the field "Override for Student 3" matches value "1" -# And the field "Grade for Student 4" matches value "2.00" -# And the field "Override for Student 4" matches value "1" -# -# Scenario: I can bulk insert grades and check their override flags for user view. -# Given I am on the "Test assignment two" "assign activity" page logged in as teacher1 -# And I follow "View all submissions" -# And I click on "Grade" "link" in the "Student 1" "table_row" -# And I set the following fields to these values: -# | Grade out of 100 | 50 | -# And I press "Save changes" -# And I am on "Course 1" course homepage -# And I navigate to "View > Grader report" in the course gradebook -# # And I click on "input[title='Dock Navigation block']" "css_element" -# # And I click on "input[title='Dock Administration block']" "css_element" -# And I follow "Single view for Test assignment two" -# And I select "Student 1" from the "Select user..." singleselect -# Then the field "Grade for Test assignment two" matches value "50.00" -# And the field "Override for Test assignment two" matches value "0" -# And I set the field "For" to "Empty grades" -# And I set the field "Perform bulk insert" to "1" -# And I set the field "Insert value" to "1.0" -# And I press "Save" -# And the field "Grade for Test assignment two" matches value "50.00" -# And the field "Override for Test assignment two" matches value "0" -# And the field "Grade for Test assignment one" matches value "1.00" -# And the field "Override for Test assignment one" matches value "1" -# And the field "Grade for Test assignment three" matches value "1.00" -# And the field "Override for Test assignment three" matches value "1" -# And the field "Grade for Test assignment four" matches value "1.00" -# And the field "Override for Test assignment four" matches value "1" -# -# Scenario: I can not update grades if the value is out of bounds. -# Given I am on the "Course 1" course page logged in as teacher1 -# And I navigate to "View > Grader report" in the course gradebook -# And I follow "Single view for Test assignment one" -# And I set the field "Perform bulk insert" to "1" -# When I set the field "Insert value" to "-1" -# And I press "Save" -# Then I should see "The grade entered for Test assignment one for Student 1 is less than the minimum allowed" -# And I should see "The grade entered for Test assignment one for Student 2 is less than the minimum allowed" -# And I should see "The grade entered for Test assignment one for Student 3 is less than the minimum allowed" -# And I should see "The grade entered for Test assignment one for Student 4 is less than the minimum allowed" -# And I should see "Grades were set for 0 items" +@core @core_grades @gradereport_singleview @javascript +Feature: We can bulk insert grades for students in a course + As a teacher + In order to quickly grade items + I can bulk insert values for all or empty grades. + + Background: + Given the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "users" exist: + | username | firstname | lastname | email | idnumber | alternatename | + | teacher1 | Teacher | 1 | teacher1@example.com | t1 | fred | + | student1 | Student | 1 | student1@example.com | s1 | james | + | student2 | Student | 2 | student1@example.com | s2 | holly | + | student3 | Student | 3 | student1@example.com | s3 | anna | + | student4 | Student | 4 | student1@example.com | s4 | zac | + And the following "course enrolments" exist: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + | student2 | C1 | student | + | student3 | C1 | student | + | student4 | C1 | student | + And the following "activities" exist: + | activity | course | idnumber | name | intro | + | assign | C1 | a1 | Test assignment one | Submit something! | + | assign | C1 | a2 | Test assignment two | Submit something! | + | assign | C1 | a3 | Test assignment three | Submit something! | + | assign | C1 | a4 | Test assignment four | Submit nothing! | + + Scenario: I can not save bulk insert until I fill required form elements + Given I am on the "Test assignment one" "assign activity" page logged in as teacher1 + And I am on "Course 1" course homepage with editing mode on + And I navigate to "View > Grader report" in the course gradebook + And I follow "Single view for Test assignment one" + And I click on "Actions" "link" + When I click on "Bulk insert" "link" + And the "Empty grades" "radio" should be disabled + And the "All grades" "radio" should be disabled + And the "Insert value modal" "field" should be disabled + And the "[data-action=save]" "css_element" should be disabled + And I click on "I understand that my unsaved data might be lost" "checkbox" + And the "Empty grades" "radio" should be enabled + And the "All grades" "radio" should be enabled + And the "Insert value modal" "field" should be enabled + And the "[data-action=save]" "css_element" should be disabled + And I click on "Empty grades" "radio" + And the "Empty grades" "radio" should be enabled + And the "All grades" "radio" should be enabled + And the "Insert value modal" "field" should be enabled + And the "[data-action=save]" "css_element" should be enabled + + Scenario: I can bulk insert grades and check their override flags for grade view. + Given I am on the "Test assignment one" "assign activity" page logged in as teacher1 + And I follow "View all submissions" + And I click on "Grade" "link" in the "Student 1" "table_row" + And I set the following fields to these values: + | Grade out of 100 | 50 | + And I press "Save changes" + And I am on "Course 1" course homepage with editing mode on + And I navigate to "View > Grader report" in the course gradebook + And I follow "Single view for Test assignment one" + Then the field "Grade for Student 1" matches value "50.00" + And the field "Override for Student 1" matches value "0" + And I click on "Actions" "link" + And I click on "Bulk insert" "link" + And I click on "I understand that my unsaved data might be lost" "checkbox" + And I click on "Empty grades" "radio" + And I set the field "Insert value modal" to "1.0" + And I click on "Save" "button" in the ".modal-dialog" "css_element" + And the field "Grade for Student 1" matches value "50.00" + And the field "Override for Student 1" matches value "0" + And the field "Grade for Student 2" matches value "1.00" + And the field "Override for Student 2" matches value "1" + And the field "Grade for Student 3" matches value "1.00" + And the field "Override for Student 3" matches value "1" + And the field "Grade for Student 4" matches value "1.00" + And the field "Override for Student 4" matches value "1" + + And I click on "Actions" "link" + And I click on "Bulk insert" "link" + And I click on "I understand that my unsaved data might be lost" "checkbox" + And I click on "All grades" "radio" + And I set the field "Insert value modal" to "2.0" + And I click on "Save" "button" in the ".modal-dialog" "css_element" + And the field "Grade for Student 1" matches value "2.00" + And the field "Override for Student 1" matches value "1" + And the field "Grade for Student 2" matches value "2.00" + And the field "Override for Student 2" matches value "1" + And the field "Grade for Student 3" matches value "2.00" + And the field "Override for Student 3" matches value "1" + And the field "Grade for Student 4" matches value "2.00" + And the field "Override for Student 4" matches value "1" + + Scenario: I can bulk insert grades and check their override flags for user view. + Given I am on the "Test assignment two" "assign activity" page logged in as teacher1 + And I follow "View all submissions" + And I click on "Grade" "link" in the "Student 1" "table_row" + And I set the following fields to these values: + | Grade out of 100 | 50 | + And I press "Save changes" + And I am on "Course 1" course homepage with editing mode on + And I navigate to "View > Grader report" in the course gradebook + # And I click on "input[title='Dock Navigation block']" "css_element" + # And I click on "input[title='Dock Administration block']" "css_element" + And I follow "Single view for Student 1" + Then the field "Grade for Test assignment two" matches value "50.00" + And the field "Override for Test assignment two" matches value "0" + And I click on "Actions" "link" + And I click on "Bulk insert" "link" + And I click on "I understand that my unsaved data might be lost" "checkbox" + And I click on "Empty grades" "radio" + And I set the field "Insert value modal" to "1.0" + And I click on "Save" "button" in the ".modal-dialog" "css_element" + And the field "Grade for Test assignment two" matches value "50.00" + And the field "Override for Test assignment two" matches value "0" + And the field "Grade for Test assignment one" matches value "1.00" + And the field "Override for Test assignment one" matches value "1" + And the field "Grade for Test assignment three" matches value "1.00" + And the field "Override for Test assignment three" matches value "1" + And the field "Grade for Test assignment four" matches value "1.00" + And the field "Override for Test assignment four" matches value "1" + + Scenario: I can not update grades if the value is out of bounds. + Given I am on the "Course 1" course page logged in as teacher1 + And I turn editing mode on + And I navigate to "View > Grader report" in the course gradebook + And I follow "Single view for Test assignment one" + And I click on "Actions" "link" + And I click on "Bulk insert" "link" + And I click on "I understand that my unsaved data might be lost" "checkbox" + And I click on "Empty grades" "radio" + And I set the field "Insert value modal" to "-1" + And I click on "Save" "button" in the ".modal-dialog" "css_element" + Then I should see "The grade entered for Test assignment one for Student 1 is less than the minimum allowed" + And I should see "The grade entered for Test assignment one for Student 2 is less than the minimum allowed" + And I should see "The grade entered for Test assignment one for Student 3 is less than the minimum allowed" + And I should see "The grade entered for Test assignment one for Student 4 is less than the minimum allowed" + And I should see "Grades were set for 0 items" diff --git a/grade/report/singleview/tests/behat/singleview.feature b/grade/report/singleview/tests/behat/singleview.feature index 90689d4fe17..71c75167f14 100644 --- a/grade/report/singleview/tests/behat/singleview.feature +++ b/grade/report/singleview/tests/behat/singleview.feature @@ -112,32 +112,38 @@ Feature: We can use Single view And I follow "Single view for Ann, Jill, Grainne, Beauchamp" Then I should see "Gronya,Beecham" -# Scenario: I can bulk update grades. -# Given I follow "Single view for Ann, Jill, Grainne, Beauchamp" -# Then I should see "Gronya,Beecham" -# When I set the field "For" to "All grades" -# And I set the field "Insert value" to "1.0" -# And I set the field "Perform bulk insert" to "1" -# And I press "Save" -# Then I should see "Grades were set for 6 items" -# -# Scenario: I can bulk update grades with custom decimal separator -# Given the following "language customisations" exist: -# | component | stringid | value | -# | core_langconfig | decsep | # | -# And I follow "Single view for Ann, Jill, Grainne, Beauchamp" -# And I should see "Gronya,Beecham" -# When I set the field "For" to "All grades" -# And I set the field "Insert value" to "1#25" -# And I set the field "Perform bulk insert" to "1" -# And I press "Save" -# Then I should see "Grades were set for 6 items" -# # Custome scale, cast to int -# And the field "Grade for new grade item 1" matches value "Disappointing" -# # Value grade, float with custom decsep. -# And the field "Grade for Test assignment one" matches value "1#25" -# # Numerical scale, cast to int, showing as float with custom decsep. -# And the field "Grade for Test grade item" matches value "1#00" + Scenario: I can bulk update grades. + Given I follow "Single view for Ann, Jill, Grainne, Beauchamp" + And I should see "Gronya,Beecham" + When I turn editing mode on + And I click on "Actions" "link" + And I click on "Bulk insert" "link" + And I click on "I understand that my unsaved data might be lost" "checkbox" + And I click on "All grades" "radio" + And I set the field "Insert value modal" to "1.0" + And I click on "Save" "button" in the ".modal-dialog" "css_element" + Then I should see "Grades were set for 6 items" + + Scenario: I can bulk update grades with custom decimal separator + Given the following "language customisations" exist: + | component | stringid | value | + | core_langconfig | decsep | # | + And I follow "Single view for Ann, Jill, Grainne, Beauchamp" + And I should see "Gronya,Beecham" + When I turn editing mode on + And I click on "Actions" "link" + And I click on "Bulk insert" "link" + And I click on "I understand that my unsaved data might be lost" "checkbox" + And I click on "All grades" "radio" + And I set the field "Insert value modal" to "1#25" + And I click on "Save" "button" in the ".modal-dialog" "css_element" + Then I should see "Grades were set for 6 items" + # Custome scale, cast to int + And the field "Grade for new grade item 1" matches value "Disappointing" + # Value grade, float with custom decsep. + And the field "Grade for Test assignment one" matches value "1#25" + # Numerical scale, cast to int, showing as float with custom decsep. + And the field "Grade for Test grade item" matches value "1#00" Scenario: Navigation works in the Single view. Given I follow "Single view for Ann, Jill, Grainne, Beauchamp" @@ -154,8 +160,7 @@ Feature: We can use Single view And I follow "Test assignment four" Then I should see "Test assignment four" - Scenario: Activities are clickable only when - it has a valid activity page. + Scenario: Activities are clickable only when it has a valid activity page. Given I follow "Single view for Ann, Jill, Grainne, Beauchamp" And "new grade item 1" "link" should not exist in the "//tbody//tr[position()=1]//td[position()=2]" "xpath_element" Then "Category total" "link" should not exist in the "//tbody//tr[position()=2]//td[position()=2]" "xpath_element"