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.
$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;
/** @var string $name The name of the input */
public $name = 'exclude';
+ /** @var bool $locked Is the input locked? */
+ public $locked = FALSE;
+
/**
* Is it 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
*
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
);
}