MDL-78673 grade: Switch test to use generators

This commit is contained in:
Andrew Nicols 2023-07-07 11:06:49 +08:00
parent 23c2c5d08e
commit 43d00eaeba
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 22 additions and 23 deletions

View File

@ -20,35 +20,24 @@ Feature: Average grades are displayed in the gradebook
| student1 | C1 | student |
| student2 | C1 | student |
| student3 | C1 | student |
And the following "grade item" exists:
| course | C1 |
| itemname | Manual item 1 |
And the following "grade grades" exist:
| gradeitem | user | grade |
| Manual item 1 | student1 | 50.00 |
| Manual item 1 | student2 | 50.00 |
| Manual item 1 | student3 | 50.00 |
And the following "course enrolments" exist:
| user | course | role | status |
| student2 | C1 | student | suspended |
# Enable averages
And I am on the "Course 1" "grades > course grade settings" page logged in as "admin"
And I set the following fields to these values:
| Show average | Show |
And I press "Save changes"
# Add a manual grade item
And I am on the "Course 1" "grades > gradebook setup" page
And I press "Add grade item"
And I set the following fields to these values:
| Item name | Manual item 1 |
And I press "Save changes"
# Give all student the same grade for the manual grade item
And I am on the "Course 1" "grades > grader > View" page
And I turn editing mode on
And I give the grade "50.00" to the user "Student 1" for the grade item "Manual item 1"
And I give the grade "50.00" to the user "Student 2" for the grade item "Manual item 1"
And I give the grade "50.00" to the user "Student 3" for the grade item "Manual item 1"
And I press "Save changes"
And I turn editing mode off
# Suspend a user
And I am on the "Course 1" "enrolled users" page
And I click on "Edit enrolment" "link" in the "Student 2" "table_row"
And I set the following fields to these values:
| Status | Suspended |
And I press "Save changes"
Scenario: Grade a grade item and ensure the results display correctly in the gradebook
# Check the admin grade table
Given I am on the "Course 1" "grades > Grader report > View" page logged in as "admin"

View File

@ -613,6 +613,16 @@ class behat_core_generator extends behat_generator_base {
if (!isset($data['status'])) {
$data['status'] = null;
} else {
$status = strtolower($data['status']);
switch ($status) {
case 'active':
$data['status'] = ENROL_USER_ACTIVE;
break;
case 'suspended':
$data['status'] = ENROL_USER_SUSPENDED;
break;
}
}
// If the provided course shortname is the site shortname we consider it a system role assign.