MDL-88270 mod_assign: Show marking button to allocated users only
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"extrafiltersdropdown": "<div class='dropdown extrafilters'></div>",
|
||||
"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 @@
|
||||
</div>
|
||||
<div class="navitem-divider"></div>
|
||||
{{/pagereset}}
|
||||
{{#markerurl}}
|
||||
<div class="navitem ms-sm-auto align-self-center">
|
||||
<a class="btn btn-primary text-nowrap" href="{{markerurl}}">{{#str}}markallocatedsubmissions, mod_assign{{/str}}</a>
|
||||
</div>
|
||||
{{/markerurl}}
|
||||
{{#graderurl}}
|
||||
<div class="navitem ms-sm-auto align-self-center">
|
||||
<a class="btn btn-primary" href="{{graderurl}}">{{#str}}gradeverb, core{{/str}}</a>
|
||||
</div>
|
||||
<div class="navitem {{^markerurl}}ms-sm-auto{{/markerurl}} align-self-center">
|
||||
<a class="btn btn-primary" href="{{graderurl}}">{{#str}}gradeverb, core{{/str}}</a>
|
||||
</div>
|
||||
{{/graderurl}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -34,15 +34,15 @@
|
||||
}}
|
||||
<div class="container-fluid tertiary-navigation">
|
||||
<div class="d-flex">
|
||||
{{#marklink}}
|
||||
<div class="navitem">
|
||||
<a class="btn btn-primary text-nowrap" href="{{marklink}}">{{#str}}markallocatedsubmissions, mod_assign{{/str}}</a>
|
||||
</div>
|
||||
{{/marklink}}
|
||||
{{#gradelink}}
|
||||
<div class="navitem">
|
||||
<a class="btn btn-primary" href="{{gradelink}}">{{#str}}gradeverb, core{{/str}}</a>
|
||||
</div>
|
||||
{{/gradelink}}
|
||||
{{#marklink}}
|
||||
<div class="navitem">
|
||||
<a class="btn btn-primary" href="{{marklink}}">{{#str}}markverb, mod_assign{{/str}}</a>
|
||||
</div>
|
||||
{{/marklink}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user