diff --git a/mod/assign/override_form.php b/mod/assign/override_form.php index 33f2e0ee8d0..ab732b5e74d 100644 --- a/mod/assign/override_form.php +++ b/mod/assign/override_form.php @@ -40,7 +40,7 @@ class assign_override_form extends moodleform { /** @var object course module object. */ protected $cm; - /** @var object the assign settings object. */ + /** @var assign the assign settings object. */ protected $assign; /** @var context the assign context. */ @@ -229,8 +229,10 @@ class assign_override_form extends moodleform { } } + // Determine users from which we will calculate maximum extension due date (those from current group plus selected user). $users = $DB->get_fieldset_select('groups_members', 'userid', 'groupid = ?', array($this->groupid)); - array_push($users, $this->userid); + array_push($users, $userid); + $extensionmax = 0; foreach ($users as $value) { $extension = $DB->get_record('assign_user_flags', array('assignment' => $assigninstance->id, diff --git a/mod/assign/tests/behat/assign_user_override.feature b/mod/assign/tests/behat/assign_user_override.feature index 1602cad4bb3..b07c85eeb78 100644 --- a/mod/assign/tests/behat/assign_user_override.feature +++ b/mod/assign/tests/behat/assign_user_override.feature @@ -82,6 +82,30 @@ Feature: Assign user override And I am on the "Test assignment name" Activity page logged in as student1 And the activity date in "Test assignment name" should contain "Due: Wednesday, 1 January 2020, 8:00" + @javascript + Scenario: Ensure an overridden due date is before any extension date + Given I am on the "Test assignment name" Activity page logged in as teacher1 + When I navigate to "Settings" in current page administration + And I set the field "Due date" to "##1 Jan 2000 08:00##" + And I press "Save and display" + And I navigate to "Submissions" in current page administration + And I open the action menu in "Student1" "table_row" + And I follow "Grant extension" + And I set the field "Extension due date" to "##3 Jan 2000 08:00##" + And I press "Save changes" + And I navigate to "Overrides" in current page administration + And I press "Add user override" + And I set the following fields to these values: + | Override user | Student1 | + | Due date | ##4 Jan 2000 08:00## | + And I press "Save" + Then I should see "Extension date must be after the due date" + And I set the field "Due date" to "##2 Jan 2000 08:00##" + And I press "Save" + And the following should exist in the "generaltable" table: + | User | Overrides | -3- | + | Sam1 Student1 | Due date | Sunday, 2 January 2000, 8:00 | + @javascript Scenario: Allow a user to have a different cut off date Given I am on the "Test assignment name" Activity page logged in as teacher1