diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 4e7c7ec1fde..f361ebb5f6d 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -1823,8 +1823,7 @@ function assign_check_updates_since(cm_info $cm, $from, $filter = array()) { * Is the event visible? * * This is used to determine global visibility of an event in all places throughout Moodle. For example, - * the ASSIGN_EVENT_TYPE_GRADINGDUE event will not be shown to students on their calendar, and - * ASSIGN_EVENT_TYPE_DUE events will not be shown to teachers. + * the ASSIGN_EVENT_TYPE_GRADINGDUE event will not be shown to students on their calendar. * * @param calendar_event $event * @return bool Returns true if the event is visible to the current user, false otherwise. @@ -1842,7 +1841,7 @@ function mod_assign_core_calendar_is_event_visible(calendar_event $event) { if ($event->eventtype == ASSIGN_EVENT_TYPE_GRADINGDUE) { return $assign->can_grade(); } else { - return !$assign->can_grade() && $assign->can_view_submission($USER->id); + return true; } } @@ -1887,6 +1886,14 @@ function mod_assign_core_calendar_provide_event_action(calendar_event $event, return null; } + $participant = $assign->get_participant($USER->id); + + if (!$participant) { + // If the user is not a participant in the assignment then they have + // no action to take. This will filter out the events for teachers. + return null; + } + // The user has not yet submitted anything. Show the addsubmission link. $name = get_string('addsubmission', 'assign'); $url = new \moodle_url('/mod/assign/view.php', [ diff --git a/mod/assign/tests/lib_test.php b/mod/assign/tests/lib_test.php index abcfc000885..06ea6264e15 100644 --- a/mod/assign/tests/lib_test.php +++ b/mod/assign/tests/lib_test.php @@ -108,7 +108,7 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase { $this->setAdminUser(); $courses = $DB->get_records('course', array('id' => $this->course->id)); // Past assignments should not show up. - $pastassign = $this->create_instance(array('duedate' => time(), + $pastassign = $this->create_instance(array('duedate' => time() - 370001, 'cutoffdate' => time() - 370000, 'nosubmissions' => 0, 'assignsubmission_onlinetext_enabled' => 1)); @@ -413,8 +413,8 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase { // Set the user to a teacher. $this->setUser($this->editingteachers[0]); - // The teacher should not care about the due date event. - $this->assertFalse(mod_assign_core_calendar_is_event_visible($event)); + // The teacher should see the due date event. + $this->assertTrue(mod_assign_core_calendar_is_event_visible($event)); } public function test_assign_core_calendar_is_event_visible_duedate_event_as_student() { @@ -483,12 +483,8 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase { // Decorate action event. $actionevent = mod_assign_core_calendar_provide_event_action($event, $factory); - // Confirm the event was decorated. - $this->assertInstanceOf('\core_calendar\local\event\value_objects\action', $actionevent); - $this->assertEquals(get_string('addsubmission', 'assign'), $actionevent->get_name()); - $this->assertInstanceOf('moodle_url', $actionevent->get_url()); - $this->assertEquals(1, $actionevent->get_item_count()); - $this->assertFalse($actionevent->is_actionable()); + // The teacher should not have an action for a due date event. + $this->assertNull($actionevent); } public function test_assign_core_calendar_provide_event_action_duedate_as_student() {