MDL-86912 assign: Prevent admin submitting unless enrolled as student

This commit is contained in:
Sara Arjona
2025-10-20 09:46:02 +02:00
parent 7e42e0d54c
commit 03344e4435
2 changed files with 18 additions and 2 deletions
+4 -2
View File
@@ -6440,8 +6440,10 @@ class assign {
}
if ($userid == $graderid) {
if ($this->submissions_open($userid) &&
has_capability('mod/assign:submit', $this->context, $graderid)) {
if (
$this->submissions_open($userid)
&& has_capability('mod/assign:submit', $this->context, $graderid, false)
) {
// User can edit their own submission.
return true;
} else {
@@ -125,3 +125,17 @@ Feature: Assignments settings can be changed
And I am on the "Test assignment name" Activity page logged in as student3
Then "Add a new attempt" "button" should exist
And "Add a new attempt based on previous submission" "button" should exist
Scenario: Admin cannot add submission if not enrolled as student
When I am on the "Test assignment name" Activity page logged in as admin
Then I should not see "Add submission"
And the following "course enrolments" exist:
| user | course | role |
| admin | C1 | teacher |
And I am on the "Test assignment name" Activity page logged in as admin
And I should not see "Add submission"
But the following "course enrolments" exist:
| user | course | role |
| admin | C1 | student |
And I am on the "Test assignment name" Activity page logged in as admin
And I should see "Add submission"