mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-60058 assign: stop teacher from seeing due date event on dashboard
Thanks to Damyon Wiese for the patch.
This commit is contained in:
parent
028fa14436
commit
7ec6d873e1
@ -1886,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', [
|
||||
|
@ -2036,9 +2036,13 @@ class assign {
|
||||
* @return null|stdClass user record
|
||||
*/
|
||||
public function get_participant($userid) {
|
||||
global $DB;
|
||||
global $DB, $USER;
|
||||
|
||||
$participant = $DB->get_record('user', array('id' => $userid));
|
||||
if ($userid == $USER->id) {
|
||||
$participant = clone ($USER);
|
||||
} else {
|
||||
$participant = $DB->get_record('user', array('id' => $userid));
|
||||
}
|
||||
if (!$participant) {
|
||||
return null;
|
||||
}
|
||||
@ -5719,11 +5723,15 @@ class assign {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($userid == $graderid &&
|
||||
$this->submissions_open($userid) &&
|
||||
has_capability('mod/assign:submit', $this->context, $graderid)) {
|
||||
// User can edit their own submission.
|
||||
return true;
|
||||
if ($userid == $graderid) {
|
||||
if ($this->submissions_open($userid) &&
|
||||
has_capability('mod/assign:submit', $this->context, $graderid)) {
|
||||
// User can edit their own submission.
|
||||
return true;
|
||||
} else {
|
||||
// We need to return here because editothersubmission should never apply to a users own submission.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_capability('mod/assign:editothersubmission', $this->context, $graderid)) {
|
||||
|
@ -486,12 +486,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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user