Blocks: HTML (per role)

Maintained by Picture of Valery Fremaux Valery Fremaux
Allows distinct roles to get differetn content within an HTML bloc at the same layout location.
Mary Cooch
Mary Cooch
Sunday, 4 September 2016, 9:28 PM
General comments

The HTML  per role block provides a simple solution to an oft-requested issue in Moodle: the possibility of displaying different messages to different roles in a Moodle course. A typical course might include editing teachers, non-editing teachers, students and even possibly moderators or supervisors with either the standard manager role or a custom role. Keeping the course tidy while displaying separate instructions to different people can prove tricky, involving hidden labels and complex restrict access conditions. This plugin solves the problem in a very straightforward way by simply presenting the teacher in charge of course editing with a standard HTML block but different text boxes for the different roles. Once the block has been added, the message changes according to who is viewing the block. As it's based on the standard HTML block, it is also possible to display more than one block in the course if several messages are required, with text, images and hyperlinks where needed.

The page HTML per role block provides basic but adequate documentation for the plugin.

Something to bear in mind if you are thinking of privacy is that anyone who can add this block can see or edit the messages of a higher role to themselves. So for example, an editing teacher can access the block and view any instructions set for someone with a manager role. This is not a problem as long as all parties are aware of the situation.

Using the block couldn't be simpler: an administrator can install it directly from Site administration>Plugins>Install plugins and then a course editor can select HTML per role block from the Add block dropdown when the editing is turned on.

The interface is fairly intuitive, although it's important to be aware of the role contexts and also, should certain users have more than one role in a course, which message you wish to be displayed for them in the block. There is a box to type a message for all roles (if desired) and for  each standard role there is a text box into which the message/instructions are typed:

If your Moodle site has a custom role, it's useful to note that a box for the custom role will also appear here.

Once the details have been saved, a different message appears for the different roles. If a certain role has not been given a particular message then they wil not see anything apart from the 'Block content for all' message, if used.

Below for example is what a non-editing teacher sees once the above block has been saved:

non-editing teacher view of block

And here is what a student sees in the same block:

student view

Based as it is on the standard HTML block, this custom block also works well in RTL languages such as Hebrew.

The  block is one of many contributed to the community by experienced developer Valéry Frémaux of  French Moodle Partner Edunao. As such we can expect it to be well designed and well maintained.