diff --git a/public/mod/assign/classes/output/actionmenu.php b/public/mod/assign/classes/output/actionmenu.php index 967ff651c06..cbcacc4da59 100644 --- a/public/mod/assign/classes/output/actionmenu.php +++ b/public/mod/assign/classes/output/actionmenu.php @@ -60,10 +60,9 @@ class actionmenu implements templatable, renderable { if ($this->markingworkflow) { $gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'marker']); $return['marklink'] = $gradelink->out(false); - } else { - $gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grader']); - $return['gradelink'] = $gradelink->out(false); } + $gradelink = new moodle_url('/mod/assign/view.php', ['id' => $this->cmid, 'action' => 'grader']); + $return['gradelink'] = $gradelink->out(false); } return $return; diff --git a/public/mod/assign/classes/output/grading_actionmenu.php b/public/mod/assign/classes/output/grading_actionmenu.php index b2fdda1f8d9..f4cfcd5a4fd 100644 --- a/public/mod/assign/classes/output/grading_actionmenu.php +++ b/public/mod/assign/classes/output/grading_actionmenu.php @@ -96,7 +96,7 @@ class grading_actionmenu implements templatable, renderable { * @return array Data to render. */ public function export_for_template(\renderer_base $output): array { - global $PAGE; + global $PAGE, $USER; $course = $this->assign->get_course(); $cm = get_coursemodule_from_id('assign', $this->cmid); @@ -188,6 +188,18 @@ class grading_actionmenu implements templatable, renderable { $data['graderurl'] = $url->out(false); } + $markingworkflow = property_exists($this->assign->get_instance(), 'markingworkflow') && + $this->assign->get_instance()->markingworkflow == '1' && + $this->assign->is_user_allocated_marker($USER->id); + + if ($markingworkflow) { + $url = new moodle_url('/mod/assign/view.php', [ + 'id' => $this->assign->get_course_module()->id, + 'action' => 'marker', + ]); + $data['markerurl'] = $url->out(false); + } + $gradingmanager = get_grading_manager($this->assign->get_context(), 'mod_assign', 'submissions'); $controller = $gradingmanager->get_active_controller(); $showquickgrading = empty($controller) && $this->assign->can_grade(); diff --git a/public/mod/assign/classes/output/renderer.php b/public/mod/assign/classes/output/renderer.php index 56e8286af4d..ae0e06f19be 100644 --- a/public/mod/assign/classes/output/renderer.php +++ b/public/mod/assign/classes/output/renderer.php @@ -296,7 +296,7 @@ class renderer extends \plugin_renderer_base { public function render_assign_grading_summary(\assign_grading_summary $summary) { // Create a table for the data. $o = ''; - $o .= $this->output->container_start('gradingsummary'); + $o .= $this->output->container_start('gradingsummary container-fluid'); $o .= $this->output->heading(get_string('gradingsummary', 'assign'), 3); if (isset($summary->cm)) { diff --git a/public/mod/assign/lang/en/assign.php b/public/mod/assign/lang/en/assign.php index 4cb61e1efc2..d015e20e3fc 100644 --- a/public/mod/assign/lang/en/assign.php +++ b/public/mod/assign/lang/en/assign.php @@ -386,6 +386,7 @@ $string['locksubmissions'] = 'Lock submissions'; $string['manageassignfeedbackplugins'] = 'Manage assignment feedback plugins'; $string['manageassignsubmissionplugins'] = 'Manage assignment submission plugins'; $string['markactions'] = 'Mark actions'; +$string['markallocatedsubmissions'] = 'Mark allocated submissions'; $string['markerallocations'] = 'Marker allocations'; $string['marker'] = 'Marker'; $string['markercount'] = 'Markers'; diff --git a/public/mod/assign/locallib.php b/public/mod/assign/locallib.php index 87abc10b28c..5884b47d601 100644 --- a/public/mod/assign/locallib.php +++ b/public/mod/assign/locallib.php @@ -6317,7 +6317,8 @@ class assign { if ($this->can_view_grades()) { $markingworkflow = property_exists($this->get_instance(), 'markingworkflow') && - $this->get_instance()->markingworkflow == '1'; + $this->get_instance()->markingworkflow == '1' && + $this->is_user_allocated_marker($USER->id); $actionbuttons = new \mod_assign\output\actionmenu($this->get_course_module()->id, $markingworkflow); $o .= $this->get_renderer()->submission_actionmenu($actionbuttons); @@ -10565,20 +10566,27 @@ class assign { } /** - * Check if a given user is allocated as a marker for a given student on this assignment. + * Check if a user is an allocated marker on this assignment. + * + * Providing a student ID will check the user is allocated to that student too. * * @param int $userid The ID of the user we are checking to see if they are a marker. - * @param int $studentid The ID of the student. + * @param int|null $studentid The ID of the student (optional). * @return bool */ - public function is_user_allocated_marker(int $userid, int $studentid): bool { + public function is_user_allocated_marker(int $userid, ?int $studentid = null): bool { global $DB; - $record = $DB->count_records('assign_allocated_marker', [ + $params = [ 'assignment' => $this->get_instance()->id, - 'student' => $studentid, 'marker' => $userid, - ]); + ]; + + if (!empty($studentid)) { + $params['student'] = $studentid; + } + + $record = $DB->count_records('assign_allocated_marker', $params); return ($record > 0); } diff --git a/public/mod/assign/templates/grading_actionmenu.mustache b/public/mod/assign/templates/grading_actionmenu.mustache index 8ab5bcb76ba..20207a6d1f2 100644 --- a/public/mod/assign/templates/grading_actionmenu.mustache +++ b/public/mod/assign/templates/grading_actionmenu.mustache @@ -55,6 +55,7 @@ "extrafiltersdropdown": "
", "pagereset": "http://moodle.local/mod/assign/view.php?id=2&action=grading&group=0", "graderurl": "http://moodle.local/mod/assign/view.php?id=2&action=grader", + "markerurl": "http://moodle.local/mod/assign/view.php?id=2&action=marker", "quickgrading": { "baseurl": "http://moodle.local/mod/assign/view.php?id=2&action=grading", "enabled": true @@ -114,10 +115,15 @@ {{/pagereset}} + {{#markerurl}} + + {{/markerurl}} {{#graderurl}} - + {{/graderurl}} diff --git a/public/mod/assign/templates/submission_actionmenu.mustache b/public/mod/assign/templates/submission_actionmenu.mustache index f77fcd98478..da65dbc345d 100644 --- a/public/mod/assign/templates/submission_actionmenu.mustache +++ b/public/mod/assign/templates/submission_actionmenu.mustache @@ -34,15 +34,15 @@ }} diff --git a/public/mod/assign/tests/behat/allocate_markers.feature b/public/mod/assign/tests/behat/allocate_markers.feature index 2048376ffef..f250623b43d 100644 --- a/public/mod/assign/tests/behat/allocate_markers.feature +++ b/public/mod/assign/tests/behat/allocate_markers.feature @@ -93,3 +93,21 @@ Feature: Allocate markers to student submissions | Marker 2 | | Teacher One | | Teacher One | + + Scenario: Only allocated markers see the mark button + Given I am on the "A1" "assign activity" page logged in as teacher1 + And I should not see "Mark allocated submissions" in the ".tertiary-navigation" "css_element" + And I should see "Grade" in the ".tertiary-navigation" "css_element" + And I navigate to "Submissions" in current page administration + And I should not see "Mark allocated submissions" in the ".tertiary-navigation" "css_element" + And I should see "Grade" in the ".tertiary-navigation" "css_element" + And I set the field "selectall" to "1" + And I click on "Allocate marker" "button" in the "sticky-footer" "region" + And I click on "Allocate marker" "button" in the ".modal-footer" "css_element" + And I select "Teacher One" from the "Allocated marker 1" singleselect + When I press "Save changes" + Then I should see "Mark allocated submissions" in the ".tertiary-navigation" "css_element" + And I should see "Grade" in the ".tertiary-navigation" "css_element" + And I am on the "A1" "assign activity" page + And I should see "Mark allocated submissions" in the ".tertiary-navigation" "css_element" + And I should see "Grade" in the ".tertiary-navigation" "css_element"