Friday, May 1, 2015

A minimalist design approach to the Restricted Access resource as displayed on a Moodle course page.

Note the clean whitespace around the monk? Very minimalistic, Zen-like and serene if you ask me.

Below is a file resource that has its Restrict Access settings set. It is grayed-out so that the user knows it is a conditional resource, and the critieria for its access is clear to all.
The displayed text "Not available unless: Your category is hq" means that the user cannot access (read) the resource unless his Custom Profile has been set to "hq". It serves a vital purpose and is useful when a student needs to be informed that a criteria needs to be met or score needs to be attained before he or she is allowed to access that resource.

In my humble opinion, I find the conditional text as intrusive to design of the course page. It does stick out and the eye cannot avoid it. I also think that sometimes the conditional text is redundant and would be better if it were not visible. For example, in the business context, some files may be made inaccessible to a user because the user is unconfirmed. He or she is still on probation. Hence, the Moodle administrator may want the staff to not click and access the resource, but only see the resource as being there on the course page.

The purpose of this post is to show you how to remove the conditional text. At the end of this post, your home will look like this:

Looks like that famous photo of Steve Jobs in his home with minimalistic furniture.
Photo by Benjamin Stockwell. Source:
License is Creative Commons Attribution, non-commercial use.

Okay, now seriously,  At the end of this post, your screens will looks like this:

The correct Figure 1.
The Administrator/Manager/Editing Teacher's view after a file resource
has been restricted of its access. Turn Editing is set to On.

Figure 2. The Access Restrictions. So the user can only access the resource (file)
if he or she is from the Finance Department. Make sense if the file is confidential.

In the event that the user doesn't meet the condition, the resource is totally hidden from him or her.

Figure 3. Administrator/Manager/Editing Teacher's view after a file resource
has been restricted of its access. Turn Editing is Off. See the clean whitespace area around the resource?
How very Zen-like and serene!

Figure 4. A student's (Gromit's) view of the file resource,
having MET the criteria and conditions to view the resource.
He gets to access the file because he's been a good dog.

Actually, in this case, Gromit belongs to the Finance department.
Moodle knows this because Gromit's Custom Profile Field, category, has been set to "Finance".

Figure 5. A student's (Wallace's) view of the file resource, 
having MET the criteria and conditions to view the resource.
He can't access the resource because he's been pigging out on cheese secretly.
Actually, in this case, Wallace does not belong to the Finance department. 
Moodle knows this because Wallace Custom Profile Field, category, has been not set to "Finance".

Figure 6. What the administrator/Manager/Course Editing Teacher set as the restriction on the resource.
Here Moodle checks the user's Custom Profile Field, category, if it contains the word "Finance".
In the event that it doesn't contani the word "Finance", the resource is visible, but grayed-out to him or her.

Figure 7. What Wallace sees if the resource is grayed out because he does not
meet the Restricted Access conditions.

So which files to modify then to achieve this?


Firstly, comment off the half of the return get_string(...) function.


Secondly, set both array variables $string['hidden_marker']and $string['list_root_and'] to space (' ') . This 'clears' the text.

Finally, make sure you "Purge all caches" and refresh your browser's page.

Well, that's all folks! Welcome to another hack which adds more administrative burden to the Moodle Administrator because although it may help with the situation, it gives the Administrator additional details to remember before the next major Moodle version upgrade. Yup.  In the meantime, have fun!

Frankie Kam

If you like this post or site
a small donation would be nice but would last only a day,
otherwise leaving a comment (or a compliment) below will last me a month!

Ratings and Recommendations by outbrain