diff --git a/mod/assign/gradingtable.php b/mod/assign/gradingtable.php index 82d3edff58b94..5aa1dbd245d0f 100644 --- a/mod/assign/gradingtable.php +++ b/mod/assign/gradingtable.php @@ -302,14 +302,8 @@ public function __construct(assign $assignment, if (!empty($markerfilter)) { if ($markerfilter == ASSIGN_MARKER_FILTER_NO_MARKER) { $where .= ' AND (uf.allocatedmarker IS NULL OR uf.allocatedmarker = 0)'; - } else { - $where .= ' AND uf.allocatedmarker = :markerid'; - $params['markerid'] = $markerfilter; } } - } else { // Only show users allocated to this marker. - $where .= ' AND uf.allocatedmarker = :markerid'; - $params['markerid'] = $USER->id; } } diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 6fa5f6bce8be9..e28217b3fe54b 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1783,7 +1783,7 @@ public function list_participants_with_filter_status_and_group($currentgroup) { * @return array List of user records */ public function list_participants($currentgroup, $idsonly) { - global $DB; + global $DB, $USER; if (empty($currentgroup)) { $currentgroup = 0; @@ -1797,6 +1797,7 @@ public function list_participants($currentgroup, $idsonly) { $fields = 'u.*'; $orderby = 'u.lastname, u.firstname, u.id'; $additionaljoins = ''; + $additionalfilters = ''; $instance = $this->get_instance(); if (!empty($instance->blindmarking)) { $additionaljoins .= " LEFT JOIN {assign_user_mapping} um @@ -1818,11 +1819,26 @@ public function list_participants($currentgroup, $idsonly) { $orderby = "COALESCE(s.timecreated, " . time() . ") ASC, COALESCE(s.id, " . PHP_INT_MAX . ") ASC, um.id ASC"; } + if ($instance->markingworkflow && + $instance->markingallocation && + !has_capability('mod/assign:manageallocations', $this->get_context())) { + + $additionaljoins .= ' LEFT JOIN {assign_user_flags} uf + ON u.id = uf.userid + AND uf.assignment = :assignmentid3'; + + $params['assignmentid3'] = (int) $instance->id; + + $additionalfilters .= ' AND uf.allocatedmarker = :markerid'; + $params['markerid'] = $USER->id; + } + $sql = "SELECT $fields FROM {user} u JOIN ($esql) je ON je.id = u.id $additionaljoins WHERE u.deleted = 0 + $additionalfilters ORDER BY $orderby"; $users = $DB->get_records_sql($sql, $params); diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index 01ad095e10c02..8ec2f967dfce6 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -2174,15 +2174,18 @@ public function test_markerallocation() { // Check the allocated marker can view the submission. $this->setUser($this->teachers[0]); - $gradingtable = new assign_grading_table($assign, 100, '', 0, true); - $output = $assign->get_renderer()->render($gradingtable); - $this->assertEquals(true, strpos($output, $this->students[0]->lastname)); + $users = $assign->list_participants(0, true); + $user = reset($users); + $this->assertEquals($this->students[0]->id, $user->id); + + $cm = get_coursemodule_from_instance('assign', $assign->get_instance()->id); + $context = context_module::instance($cm->id); + $assign = new testable_assign($context, $cm, $this->course); // Check that other teachers can't view this submission. $this->setUser($this->teachers[1]); - $gradingtable = new assign_grading_table($assign, 100, '', 0, true); - $output = $assign->get_renderer()->render($gradingtable); - $this->assertNotEquals(true, strpos($output, $this->students[0]->lastname)); + $users = $assign->list_participants(0, true); + $this->assertEquals(0, count($users)); } /**