5 min read

Capabilities and Permissions

So far, we have given users existing roles in different Moodle contexts. In the following few pages, we want to have a look at the inside of a role that is called capabilities and permissions. Once we have understood them, we will be able to modify existing roles and create entirely new custom ones.

Role Definitions

Existing roles are accessed via Users | Permissions | Define Roles in the Site Administration block. The screen that will be shown is similar to the familiar roles assignment screen, but has a very different purpose:

Roles and Permissions in Moodle Administration-part2

When you click on a role name, its composition is shown. Each role contains a unique Name, a unique Short name (used when uploading users), and an optional Description.

Roles and Permissions in Moodle Administration-part2

The Legacy role type has been introduced for backward compatibility, to allow old legacy code that has not been fully ported to work with the new system comprising new roles and capabilities. It is expected that this facility will disappear in the future (this might be for some time since a lot of core code depends on it), and should be ignored in due course unless you are working with legacy code or third-party add-ons.

In addition to these four fields, each role consists of a large number of capabilities. Currently, Moodle’s roles system contains approximately 200 capabilities. A capability is a description of a particular Moodle feature (for example) to grade assignments or to edit a Wiki page. Each capability represents a permissible Moodle action:

Roles and Permissions in Moodle Administration-part2

Permission is a capability and its value, taken together. So each row of the table in the screen shot represents permission. The left column is the capability name and the radio buttons specify the value. So now permission has a description, a unique name, a value, and up to four associated risks.

The description, for example, Approve course creation provides a short explanation of the capability. On clicking, the description or the online Moodle documentation is opened in a separate browser. The name, for instance moodle /site: approvecourse, follows a strict naming convention that identifies the capability in the overall role system: level/type: function. The level states to which part of Moodle the capability belongs (such as moodle, mod, block, gradereport, or enroll). The type is the class of the capability and the function identifies the actual functionality.

The permission of each capability has to have one of the four values:

Permission

Description

Not Set

By default, all permissions for a new role are set to this value. The value in the context where it will be assigned will be inherited from the parent-context. To determine what this value is, Moodle searches upward through each context, until it ‘finds’ an explicit value (Allow, Prevent or Prohibit) for this capability, i.e. the search terminates when an explicit permission is found. For example, if a role is assigned to a user in a Course context, and a capability has a value of ‘Not set,’ then the actual permission will be whatever the user has at the category level, or, failing to find an explicit permission at the category level, at the site level. If no explicit permission is found, then the value in the current context becomes Prevent.

Allow

To grant permission for a capability choose Allow. It applies in the context in which the role will be assigned and all contexts which are below it (children, grand-children, etc). For example, when assigned in the course context, students will be able to start new discussions in all forums in that course, unless some forum contains an override or a new assignment with a Prevent or Prohibit value for this capability.

Prevent

To remove permission for a capability choose Prevent. If it has been granted in a higher context (no matter at what level), it will be overridden. The value can be overridden again in a lower context.

Prohibit

This is the same as Prevent, but the value cannot be overridden again in a lower context. The value is rarely needed, but useful when an admin wants to prohibit a user from certain functionality throughout the entire site, in which case the capability is set to Prohibit and then assigned in the site context.

 

Principally, permissions at lower contexts override permissions at higher contexts. The exception is “Prohibit”, which by definition cannot be overridden at lower levels.

Resolving Permission Conflicts

There is a possibility of conflict if two users are assigned the same role in the same context, where one role allows a capability and the other prevents it. In this case, Moodle will look upwards in higher contexts for a decider. This does not apply to Guest accounts, where “Prevent” will be used by default.

For example, a user has two roles in the Course context, one that allows functionality and one that prevents it. In this case, Moodle checks the Category and the System contexts respectively, looking for another defined permission. If none is found, then the permission is set to “Prevent”.

Permission Risks

Additionally, Moodle displays the risks associated with each capability, that is, the risks that each capability can potentially raise. They can be any combination of the following four risk types:

Risk

Icon

Description

Configuration

Roles and Permissions in Moodle Administration-part2

Users can change site configuration and behavior.

XSS

Roles and Permissions in Moodle Administration-part2

Users can add files and texts that allow cross-site scripting (potentially malicious scripts which are embedded in web pages and executed on the user’s computer).

Privacy

Roles and Permissions in Moodle Administration-part2

Users can gain access to private information of other users.

Spam

Roles and Permissions in Moodle Administration-part2

Users can send spam to site users or others.

Risks are only displayed. It is not possible to change these settings, since they only act as warnings. When you click on a risk icon, the “Risks” documentation page is opened in a separate browser window.

Moodle’s default roles have been designed with the following capability risks in mind:

LEAVE A REPLY

Please enter your comment!
Please enter your name here