MDL-45715 assign: disable marking allocation if markingworkflow is not set.

This commit is contained in:
Dan Marsden 2014-05-29 19:12:00 +12:00
parent ec36fafc0f
commit 5a96486b44
2 changed files with 24 additions and 8 deletions

View File

@ -202,7 +202,8 @@ class assign_grading_table extends table_sql implements renderable {
}
}
if ($this->assignment->get_instance()->markingallocation) {
if ($this->assignment->get_instance()->markingworkflow &&
$this->assignment->get_instance()->markingallocation) {
if (has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
// Check to see if marker filter is set.
$markerfilter = (int)get_user_preferences('assign_markerfilter', '');
@ -296,7 +297,8 @@ class assign_grading_table extends table_sql implements renderable {
$headers[] = get_string('submissionteam', 'assign');
}
// Allocated marker.
if ($this->assignment->get_instance()->markingallocation &&
if ($this->assignment->get_instance()->markingworkflow &&
$this->assignment->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
// Add a column for the allocated marker.
$columns[] = 'allocatedmarker';
@ -504,7 +506,8 @@ class assign_grading_table extends table_sql implements renderable {
$name = 'quickgrade_' . $row->id . '_workflowstate';
$o .= html_writer::select($workflowstates, $name, $workflowstate, array('' => $notmarked));
// Check if this user is a marker that can't manage allocations and doesn't have the marker column added.
if ($this->assignment->get_instance()->markingallocation &&
if ($this->assignment->get_instance()->markingworkflow &&
$this->assignment->get_instance()->markingallocation &&
!has_capability('mod/assign:manageallocations', $this->assignment->get_context())) {
$name = 'quickgrade_' . $row->id . '_allocatedmarker';

View File

@ -595,6 +595,9 @@ class assign {
}
$update->markingworkflow = $formdata->markingworkflow;
$update->markingallocation = $formdata->markingallocation;
if (empty($update->markingworkflow)) { // If marking workflow is disabled, make sure allocation is disabled.
$update->markingallocation = 0;
}
$returnid = $DB->insert_record('assign', $update);
$this->instance = $DB->get_record('assign', array('id'=>$returnid), '*', MUST_EXIST);
@ -938,6 +941,9 @@ class assign {
}
$update->markingworkflow = $formdata->markingworkflow;
$update->markingallocation = $formdata->markingallocation;
if (empty($update->markingworkflow)) { // If marking workflow is disabled, make sure allocation is disabled.
$update->markingallocation = 0;
}
$result = $DB->update_record('assign', $update);
$this->instance = $DB->get_record('assign', array('id'=>$update->id), '*', MUST_EXIST);
@ -3043,7 +3049,8 @@ class assign {
$quickgrading = get_user_preferences('assign_quickgrading', false);
$showonlyactiveenrolopt = has_capability('moodle/course:viewsuspendedusers', $this->context);
$markingallocation = $this->get_instance()->markingallocation &&
$markingallocation = $this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->context);
// Get markers to use in drop lists.
$markingallocationoptions = array();
@ -3413,7 +3420,8 @@ class assign {
require_once($CFG->dirroot . '/mod/assign/gradingbatchoperationsform.php');
require_sesskey();
$markingallocation = $this->get_instance()->markingallocation &&
$markingallocation = $this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->context);
$batchformparams = array('cm'=>$this->get_course_module()->id,
@ -5059,7 +5067,8 @@ class assign {
$current->grade = floatval($current->grade);
}
$gradechanged = $gradecolpresent && $current->grade !== $modified->grade;
$markingallocationchanged = $this->get_instance()->markingallocation &&
$markingallocationchanged = $this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
($modified->allocatedmarker !== false) &&
($current->allocatedmarker != $modified->allocatedmarker);
$workflowstatechanged = $this->get_instance()->markingworkflow &&
@ -5242,7 +5251,8 @@ class assign {
$showonlyactiveenrolopt = false;
}
$markingallocation = $this->get_instance()->markingallocation &&
$markingallocation = $this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->context);
// Get markers to use in drop lists.
$markingallocationoptions = array();
@ -5818,7 +5828,10 @@ class assign {
$mform->addHelpButton('workflowstate', 'markingworkflowstate', 'assign');
}
if ($this->get_instance()->markingallocation && has_capability('mod/assign:manageallocations', $this->context)) {
if ($this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->context)) {
$markers = get_users_by_capability($this->context, 'mod/assign:grade');
$markerlist = array('' => get_string('choosemarker', 'assign'));
foreach ($markers as $marker) {