MDL-52378 Singleview: Exclude Grade Attribute Permissions
Singleview users must have Manage Grade permission to modify the Exclude grade attribute.
This commit is contained in:
committed by
Eloy Lafuente (stronk7)
parent
783e695e00
commit
3328dc32a7
@@ -329,6 +329,13 @@ abstract class screen {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the user submits Exclude grade elements without the proper
|
||||
// permissions then we should refuse to update.
|
||||
if ($matches[1] === 'exclude' && !has_capability('moodle/grade:manage', $this->context)){
|
||||
$warnings[] = get_string('nopermissions', 'error', get_string('grade:manage', 'role'));
|
||||
continue;
|
||||
}
|
||||
|
||||
$msg = $element->set($posted);
|
||||
|
||||
// Optional type.
|
||||
|
||||
@@ -141,6 +141,12 @@ abstract class tablelike extends screen {
|
||||
$html .= $this->structure->get_grade_analysis_icon($grade);
|
||||
}
|
||||
|
||||
// Singleview users without proper permissions should be presented
|
||||
// disabled checkboxes for the Exclude grade attribute.
|
||||
if ($field == 'exclude' && !has_capability('moodle/grade:manage', $this->context)){
|
||||
$html->locked=TRUE;
|
||||
}
|
||||
|
||||
$line[] = $html;
|
||||
}
|
||||
return $line;
|
||||
|
||||
@@ -40,6 +40,9 @@ class exclude extends grade_attribute_format implements be_checked {
|
||||
/** @var string $name The name of the input */
|
||||
public $name = 'exclude';
|
||||
|
||||
/** @var bool $locked Is the input locked? */
|
||||
public $locked = FALSE;
|
||||
|
||||
/**
|
||||
* Is it checked?
|
||||
*
|
||||
@@ -49,6 +52,15 @@ class exclude extends grade_attribute_format implements be_checked {
|
||||
return $this->grade->is_excluded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is it locked?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_locked() {
|
||||
return $this->locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the element used to render the UI
|
||||
*
|
||||
@@ -58,7 +70,9 @@ class exclude extends grade_attribute_format implements be_checked {
|
||||
return new checkbox_attribute(
|
||||
$this->get_name(),
|
||||
$this->get_label(),
|
||||
$this->is_checked()
|
||||
$this->is_checked(),
|
||||
// Call checkbox constructor with locked attribute, expects integer.
|
||||
$this->is_locked() ? 1 : 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user