Merge branch 'MDL-85135-main' of https://github.com/mihailges/moodle

This commit is contained in:
Jun Pataleta 2025-04-10 17:54:48 +08:00
commit a51fd61a8d
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
4 changed files with 113 additions and 8 deletions

View File

@ -67,6 +67,11 @@ if (!empty($override->userid)) {
if ($confirm) {
require_sesskey();
$assign->delete_override($override->id);
reorder_group_overrides($assign->get_instance()->id);
// Recalculate grades after the override is deleted.
if ($recalculate) {
$assignintance = clone $assign->get_instance();
$assignintance->cmidnumber = $assign->get_course_module()->idnumber;
@ -81,10 +86,6 @@ if ($confirm) {
}
}
$assign->delete_override($override->id);
reorder_group_overrides($assign->get_instance()->id);
redirect($cancelurl);
}

View File

@ -258,3 +258,57 @@ Feature: Assign group override
And I should see "Only visible to members/Non-Participation" in the "Override group" "select"
And I should see "Only see own membership" in the "Override group" "select"
And I should not see "Not visible" in the "Override group" "select"
@javascript
Scenario: Teachers can trigger grade penalty recalculation when modifying or deleting group overrides
Given I enable grade penalties for assignment
And the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Test assignment penalty |
| intro | Test assignment description |
| grade | 100 |
| duedate | ##tomorrow## |
| gradepenalty | 1 |
| assignsubmission_onlinetext_enabled | 1 |
| submissiondrafts | 0 |
And the following "mod_assign > submissions" exist:
| assign | user | onlinetext |
| Test assignment name | student1 | I'm the student first submission |
# Add a group override with a due date set in the future.
And I am on the "Test assignment penalty" Activity page logged in as teacher1
And I navigate to "Overrides" in current page administration
And I select "Group overrides" from the "jump" singleselect
And I press "Add group override"
And I set the following fields to these values:
| Override group | Group 1 |
| Due date | ##tomorrow +1day## |
And I press "Save"
And I change window size to "large"
And I go to "Sam1 Student1" "Test assignment penalty" activity advanced grading page
And I set the field "Grade out of 100" to "90"
And I set the field "Notify student" to "0"
And I press "Save changes"
And I follow "View all submissions"
And "Sam1 Student1" row "Grade" column of "submissions" table should contain "90.00"
And "Sam1 Student1" row "Final grade" column of "submissions" table should contain "90.00"
# Modify the group override by changing the due date to a past date.
And I navigate to "Overrides" in current page administration
And I select "Group overrides" from the "jump" singleselect
And I click on "Edit" "link" in the "Group 1" "table_row"
When I set the following fields to these values:
| Recalculate penalty | Yes |
| Due date | ##yesterday## |
And I press "Save"
And I navigate to "Submissions" in current page administration
Then "Sam1 Student1" row "Grade" column of "submissions" table should contain "90.00"
And "Sam1 Student1" row "Final grade" column of "submissions" table should contain "80.00"
# Delete the group override.
And I navigate to "Overrides" in current page administration
And I select "Group overrides" from the "jump" singleselect
And I click on "Delete" "link" in the "Group 1" "table_row"
And I click on "Recalculate penalty for user(s) in the override" "checkbox" in the "Confirm" "dialogue"
And I click on "Continue" "button" in the "Confirm" "dialogue"
And I navigate to "Submissions" in current page administration
And "Sam1 Student1" row "Grade" column of "submissions" table should contain "90.00"
And "Sam1 Student1" row "Final grade" column of "submissions" table should contain "90.00"

View File

@ -220,3 +220,53 @@ Feature: Assign user override
And "Edit" "icon" should exist in the "Sam1 Student1" "table_row"
And "copy" "icon" should exist in the "Sam1 Student1" "table_row"
And "Delete" "icon" should exist in the "Sam1 Student1" "table_row"
@javascript
Scenario: Teachers can trigger grade penalty recalculation when modifying or deleting user overrides
Given I enable grade penalties for assignment
And the following "activity" exists:
| activity | assign |
| course | C1 |
| name | Test assignment penalty |
| intro | Test assignment description |
| grade | 100 |
| duedate | ##tomorrow## |
| gradepenalty | 1 |
| assignsubmission_onlinetext_enabled | 1 |
| submissiondrafts | 0 |
And the following "mod_assign > submissions" exist:
| assign | user | onlinetext |
| Test assignment name | student1 | I'm the student first submission |
# Add a user override with a due date set in the future.
And I am on the "Test assignment penalty" Activity page logged in as teacher1
And I navigate to "Overrides > Add user override" in current page administration
And I set the following fields to these values:
| Override user | Student1 |
| Due date | ##tomorrow +1day## |
And I press "Save"
And I change window size to "large"
And I go to "Sam1 Student1" "Test assignment penalty" activity advanced grading page
And I set the field "Grade out of 100" to "90"
And I set the field "Notify student" to "0"
And I press "Save changes"
And I follow "View all submissions"
And "Sam1 Student1" row "Grade" column of "submissions" table should contain "90.00"
And "Sam1 Student1" row "Final grade" column of "submissions" table should contain "90.00"
# Modify the user override by changing the due date to a past date.
And I navigate to "Overrides" in current page administration
And I click on "Edit" "link" in the "Sam1 Student1" "table_row"
When I set the following fields to these values:
| Recalculate penalty | Yes |
| Due date | ##yesterday## |
And I press "Save"
And I navigate to "Submissions" in current page administration
Then "Sam1 Student1" row "Grade" column of "submissions" table should contain "90.00"
And "Sam1 Student1" row "Final grade" column of "submissions" table should contain "80.00"
# Delete the user override.
And I navigate to "Overrides" in current page administration
And I click on "Delete" "link" in the "Sam1 Student1" "table_row"
And I click on "Recalculate penalty for user(s) in the override" "checkbox" in the "Confirm" "dialogue"
And I click on "Continue" "button" in the "Confirm" "dialogue"
And I navigate to "Submissions" in current page administration
And "Sam1 Student1" row "Grade" column of "submissions" table should contain "90.00"
And "Sam1 Student1" row "Final grade" column of "submissions" table should contain "90.00"

View File

@ -105,19 +105,19 @@ Feature: Check that the assignment grade can be updated correctly
And I am on the "Test assignment name" Activity page logged in as teacher1
And I change window size to "large"
And I go to "Student 1" "Test assignment name" activity advanced grading page
When I set the field "Grade out of 100" to "100"
When I set the field "Grade out of 100" to "90"
And I set the field "Notify student" to "0"
And I press "Save changes"
Then the "title" attribute of ".penalty-indicator-icon" "css_element" should contain "Late penalty applied -10.00 marks"
And I follow "View all submissions"
And "Student 1" row "Grade" column of "generaltable" table should contain "100.00"
And "Student 1" row "Final grade" column of "generaltable" table should contain "90.00"
And "Student 1" row "Grade" column of "submissions" table should contain "90.00"
And "Student 1" row "Final grade" column of "submissions" table should contain "80.00"
And the "title" attribute of ".penalty-indicator-icon" "css_element" should contain "Late penalty applied -10.00 marks"
# Override the grade.
And I am on the "Course 1" "grades > Grader report > View" page
And the following should exist in the "user-grades" table:
| -1- | -2- | -3- | -4- |
| Student 1 | student10@example.com | 90 | 90 |
| Student 1 | student10@example.com | 80 | 80 |
And the "title" attribute of ".penalty-indicator-icon" "css_element" should contain "Late penalty applied -10.00 marks"
And I turn editing mode on
And I set the following fields to these values: