diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 2c2413416a6..8db3cbba94a 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -1613,6 +1613,14 @@ function mod_assign_core_calendar_provide_event_action(calendar_event $event, return null; } + $instance = $assign->get_instance(); + if ($instance->teamsubmission && !$instance->requireallteammemberssubmit) { + $groupsubmission = $assign->get_group_submission($userid, 0, false); + if ($groupsubmission && $groupsubmission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { + return null; + } + } + $participant = $assign->get_participant($userid); if (!$participant) { diff --git a/mod/assign/tests/behat/group_submission.feature b/mod/assign/tests/behat/group_submission.feature index 40e42beabb0..a82fb507780 100644 --- a/mod/assign/tests/behat/group_submission.feature +++ b/mod/assign/tests/behat/group_submission.feature @@ -28,6 +28,47 @@ Feature: Group assignment submissions | name | course | idnumber | | Group 1 | C1 | G1 | + @javascript + Scenario: Confirm that group submissions are removed from the timeline + Given the following "activity" exists: + | activity | assign | + | course | C1 | + | name | Test assignment name | + | assignsubmission_onlinetext_enabled | 1 | + | teamsubmission | 1 | + | duedate | ##tomorrow## | + | requiresubmissionstatement | 1 | + And the following "group members" exist: + | user | group | + | student1 | G1 | + | student2 | G1 | + # Student1 checks the assignment is visible in the timeline + When I am on the "Homepage" page logged in as student1 + Then I should see "Test assignment name" in the "Timeline" "block" + # Student2 checks the assignment is visible in the timeline + And I am on the "Homepage" page logged in as student2 + And I should see "Test assignment name" in the "Timeline" "block" + # Student2 submits the assignment + And I am on the "Test assignment name" Activity page + And I press "Add submission" + And I set the field "Online text" to "Assignment submission text" + And I press "Save changes" + And I should see "Draft (not submitted)" in the "Submission status" "table_row" + And I press "Submit assignment" + And I should see "This submission is the work of my group, except where we have acknowledged the use of the works of other people." + And I press "Continue" + And I should see "Confirm submission" + And I should see "- Required" + And I set the field "submissionstatement" to "1" + And I press "Continue" + And I should see "Submitted for grading" in the "Submission status" "table_row" + # Student2 checks the timeline again + And I am on the "Homepage" page + And I should not see "Test assignment name" in the "Timeline" "block" + # Student1 checks the timeline again + And I am on the "Homepage" page logged in as student1 + And I should not see "Test assignment name" in the "Timeline" "block" + @javascript Scenario: Switch between group modes Given the following "activity" exists: diff --git a/mod/assign/tests/lib_test.php b/mod/assign/tests/lib_test.php index 5fad64323d4..0b97b37df0e 100644 --- a/mod/assign/tests/lib_test.php +++ b/mod/assign/tests/lib_test.php @@ -520,6 +520,69 @@ class lib_test extends \advanced_testcase { $this->assertTrue($actionevent->is_actionable()); } + /** + * Test group submissions. + * @covers \assign::mod_assign_core_calendar_provide_event_action + */ + public function test_assign_core_calendar_provide_event_action_duedate_for_group_assignment(): void { + $this->resetAfterTest(); + $course = $this->getDataGenerator()->create_course(); + $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher'); + $student1 = $this->getDataGenerator()->create_and_enrol($course, 'student'); + $student2 = $this->getDataGenerator()->create_and_enrol($course, 'student'); + $group = $this->getDataGenerator()->create_group([ + 'courseid' => $course->id, + ]); + groups_add_member($group->id, $student1->id); + groups_add_member($group->id, $student2->id); + + $assign = $this->create_instance($course, [ + 'assignsubmission_onlinetext_enabled' => 1, + 'requiresubmissionstatement' => 1, + 'teamsubmission' => 1, + 'completion' => 0, + 'completionsubmit' => 1, + ]); + + // Create a calendar event. + $this->setAdminUser(); + $event = $this->create_action_event($course, $assign, ASSIGN_EVENT_TYPE_DUE); + $this->setUser(); + + $factory = new \core_calendar\action_factory(); + $actionevent1 = mod_assign_core_calendar_provide_event_action($event, $factory, $student1->id); + $actionevent2 = mod_assign_core_calendar_provide_event_action($event, $factory, $student2->id); + + // Confirm the events were decorated. + $this->assertInstanceOf('\core_calendar\local\event\value_objects\action', $actionevent1); + $this->assertEquals(get_string('addsubmission', 'assign'), $actionevent1->get_name()); + $this->assertInstanceOf('moodle_url', $actionevent1->get_url()); + $this->assertEquals(1, $actionevent1->get_item_count()); + $this->assertTrue($actionevent1->is_actionable()); + + $this->assertInstanceOf('\core_calendar\local\event\value_objects\action', $actionevent2); + $this->assertEquals(get_string('addsubmission', 'assign'), $actionevent2->get_name()); + $this->assertInstanceOf('moodle_url', $actionevent2->get_url()); + $this->assertEquals(1, $actionevent2->get_item_count()); + $this->assertTrue($actionevent2->is_actionable()); + + // Submit as the student. + $this->add_submission($student1, $assign); + $this->submit_for_grading($student1, $assign, ['submissionstatement' => 'Hello, world!']); + + // Create a new calendar event. + $this->setAdminUser(); + $event = $this->create_action_event($course, $assign, ASSIGN_EVENT_TYPE_DUE); + $this->setUser(); + + // Confirm there were no events to action. + $actionevent1 = mod_assign_core_calendar_provide_event_action($event, $factory, $student1->id); + $this->assertNull($actionevent1); + + $actionevent2 = mod_assign_core_calendar_provide_event_action($event, $factory, $student2->id); + $this->assertNull($actionevent2); + } + public function test_assign_core_calendar_provide_event_action_gradingduedate_as_teacher() { $this->resetAfterTest(); $course = $this->getDataGenerator()->create_course();