Hiding Dashboard Blocks based on roles

Hiding Dashboard Blocks based on roles

by Nanda Yuvaraj -
Number of replies: 15

Hi,

I have few blocks for teachers and few blocks for students.

I want to have specific dashboards for both of them,

I tried assigning students  to that block, then taking away view rights for that blocks from students. But its still showing in Student account.

Can you please help me on how to prevent a student account to view a specific block.

I want to accounts permissions and removed view block capability. which makes the dashboard empty.Please help me.

Average of ratings: -
In reply to Nanda Yuvaraj

Re: Hiding Dashboard Blocks based on roles

by C Behan -

Hi Nanda,


Did you ever achieve this?


Thanks

catherine

In reply to C Behan

Re: Hiding Dashboard Blocks based on roles

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

He's no longer enrolled so I don't think you're going to get an answer

In reply to Howard Miller

Re: Hiding Dashboard Blocks based on roles

by C Behan -

Thanks Howard sad

In answer to my own question, I don't think it's possible. I had hoped a variation of this or this would work but it doesn't for the dashboard sadly.

It's pity because the new Course Overview block isn't good for teachers or admins who have access to many courses.

Catherine


Average of ratings: Useful (1)
In reply to C Behan

Re: Hiding Dashboard Blocks based on roles

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

HI - Since the dashboard is not in the context of a course, removing the "student" or "teacher" view capability will work here. Instead, you need to make a Mask!

Basically: You'll make a new role that is applied at the block= level. It wont' have to have any permissions set (just 3 removed). Then place all of your teachers in it and on your Dashboard set up page / reset the dashboard, and then you're all set.


Create Mask

1. Site Admin - Users - Permissions - Define Roles 

2. Click Add a New Role

3. Choose 'No Role' as the arch type

4. Give it a name (ie. Dashboard Mask)

5. Check off  "Block" context

6. Leave everything else as "not set" and scroll down to the bottom of the page where you see the "Block" section: 

     Change the following three permissions to "Prohibit": 

     "Edit a Block's settings"

     "View Block"

     "Manage Blocks on a Page"     

8. Click save changes. 


Apply the Mask

1. Site Admin - Appearance - Default Dashboard page

2. Click "Blocks Editing On"

3. In the Course Overview Block, click the Cog and select "Assign Roles"

4. You'll see your Daskboard Mask listed and a '0' - click on "Dashboard Mask"

5. Add all of your staff to it (you will just have to maintain this as you get new staff members)

7. Navigate back to Site Admin - Appearance - Default Dashboard page

8. Click "Reset Dashboard for all users"


This works for me on Moodle 3.4




Average of ratings: Useful (1)
In reply to John Provasnik

Re: Hiding Dashboard Blocks based on roles

by C Behan -

Hi John,


Thank you for taking the time to reply and for the detailed instruction. However, it's still not working for me - and I'm thinking now there could be a bug given the contradictions in the attached screenshots.

Screenshots are from a local Moodle install with a user called 'staff staff' who has been assigned the role.

  • If I check the permissions for the user, 'View Block' is set to no. Yes
  • However if I actually log in as that user, they see the block. No

Is it possible that there is another setting/step you didn't mention?

Attachment dashboard.png
Attachment permissions_in_block.png
Attachment rolepermissions.png
In reply to John Provasnik

Re: Hiding Dashboard Blocks based on roles

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

Hi - I meant to say this works for me on moodle 3.1.4 (with the old course overview block). I am upgrading to 3.4 this week and will try this method there and see what I can come up with. 

In reply to John Provasnik

Re: Hiding Dashboard Blocks based on roles

by C Behan -

Thanks John Yes

In reply to C Behan

Re: Hiding Dashboard Blocks based on roles

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

Hi - I just did the steps on 3.4 with the new overview block and it does work for me as described above. 

I did not change any other permissions:

 


and my Permission overview is identical to your image: 




So, I'm not sure why it's not working on your end - yes other permissions could be at play...


But 1 thing did happen now that I'm using this "Mask" idea on 3.4's new overview block - when I log in as that user, they get an exemption thrown (something that didnt happen on the old block on 3.1), so I'm not sure how to get around that just yet:



In reply to John Provasnik

Re: Hiding Dashboard Blocks based on roles

by Ron Meske -
Picture of Particularly helpful Moodlers

Hello,


I am currently running module 3.6 and am having a problem hiding a block on the dashboard from a role.  

1. I created a new role.  

2. In the block on the dashboard that I want to hide, I edited the permissions and for the role I created I set all View Block to Prohibit.

3. I then added the users that I want to hide this block from and added them to the role I created.


When I log in as one of the users, they still see the block.  Is this intentional?


Ron

In reply to Ron Meske

Re: Hiding Dashboard Blocks based on roles

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

Yes since users can only be a student within a course. On the dashboard, everyone is an authenticated user. To limit the block from view by certain users, those users need to be part of a role that is available at the site context (such as the authenticated user and manager). 

I have made a "staff" role that has mostly no permissions but is set to the site context and I have added all my teachers to this role. This allows me to control what my staff see at site pages (like the dashboard or front page). 

Therefore, I start with not allowing any user to see certain blocks site wide and then if I want staff to see it, i that role to the block's view permission. 


Which block are you attempting to limit view from your students on the dashboard?

Wish I could control block visibility by cohort!

Average of ratings: Useful (2)
In reply to John Provasnik

Re: Hiding Dashboard Blocks based on roles

by Ron Meske -
Picture of Particularly helpful Moodlers

Thank you for the reply.

I am trying to hide the Courses block from a small set of but allow them to use the My Courses block.  For all other users I want them to see the Courses block.  If the My Courses block showed Categories, I wouldn't need the Courses block.

Steps I took:

  1. Created a role based on none, called "No Courses".  I did not modify any permissions as there was not a specific permission for viewing the courses block.  I set the context of the role to Block & System.  
  2. I tried assigning a user at the System level to the Role.
  3. I added the "Courses" block to the Default Dashboard page.
  4. I set Permissions for the Courses block to Prohibit for the new role "No Courses" for 
    1. Add new courses block
    2. Edit a block settings
    3. View block
  5. Then I Checked permissions for the user and it did correctly show that they were prohibited for the 3 permissions above.
When signing in as the user I was still able to see the Courses block, so I tried assigning the user to the "No Courses" role at the block level as well and even moved the "No Courses" role from the bottom of the list to above "Authenticated user"  and even tried moving it to the top.  This user can still see the Courses block.

Thinking that perhaps this was related to the Courses block being in the "Content area" I moved it to the right column and Reset the Dashboard for all users.  The user can still see the Courses block.

Could there be a bug in the Courses block that it is not checking block:view permission?



Average of ratings: Useful (1)
In reply to Ron Meske

Re: Hiding Dashboard Blocks based on roles

by Ron Meske -
Picture of Particularly helpful Moodlers

Thought I would check one more time before reporting this as a bug.  Is this behavior intentional or should what I am trying to do be possible?


Thanks!

Ron 

In reply to Ron Meske

Re: Hiding Dashboard Blocks based on roles

by John Provasnik -
Picture of Particularly helpful Moodlers Picture of Testers

Just checking that you did the same for the authenticated user role, as all system users also are authenticated users.

In reply to John Provasnik

Re: Hiding Dashboard Blocks based on roles

by Ron Meske -
Picture of Particularly helpful Moodlers

Not sure what you mean by "...did the same for the authenticated user role...".  I want all authenticated users, except those assigned the "No courses" role to see the courses block.  This is much simpler and easier to maintain then deny all authenticated users and then assigning the majority of users to a role that allows them to see the course block.

What it looks like is that permissions for the authenticated user role over-ride all other roles.