Hide course categories/courses from certain users

Hide course categories/courses from certain users

by Quintin Seegers -
Number of replies: 18

Hi,

We use Moodle 3.1 to run courses for clients as well as internal staff training. We have created 5 user profile fields: one to identify internal staff and four used for clients to identify which product(s) they have.

Our courses are broken down into the following Course Categories:

  • General - These courses are available to all site users
  • Product A - This category and its courses should only available to clients with user profile field Product A selected.
  • Product B - This category and its courses should only available to clients with user profile field Product B selected.
  • Product C - This category and its courses should only available to clients with user profile field Product C selected.
  • Product D - This category and its courses should only available to clients with user profile field Product D selected.
  • Internal  - This category and its courses should only be available to internal staff

We can manage our Internal category as we've hidden it and set up a new role (based off the default student role) and changed it so only users on this role can see hidden categories/courses.

Our problem is with the client courses.

I initially tried using access restrictions, but that is only within the course content, where as we want to hide the course as a whole.

I have tried using cohorts, but that isn't working for us as we don't want to automatically enroll users into the courses and they can still see all the categories and and courses.

I tried using groups, but that only applies to the specific course the groups are set up against, rather than across the site.

Is there anyway to achieve this? Our site is hosted with vanilla Moodle with a custom theme. We don't have the option to add plugins or change any of the Moodle source files, so we need to be able to achieve this with existing functionality via the user interface.

Any input from the community is much appreciated.

Quintin

Average of ratings: -
In reply to Quintin Seegers

Re: Hide course categories/courses from certain users

by RTR Admin -

You need to configure group settings to properly accomplish this. Place each person in a group that will be able to see the same content, enable groups on the course, and then configure the group setting for each item.

In reply to RTR Admin

Re: Hide course categories/courses from certain users

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers

RTR, that won't work at all for this scenario as groups only exist in a course. The OP is asking for different courses/categories to be visible to certain people. It is not possible in the standard Moodle.

Quintin, I know you've said you can't use Plugins or change code. Have a look at http://www.iomad.org/ though, it's a fork if Moodle that will do exactly what you require.

In reply to Jon Bolton

Re: Hide course categories/courses from certain users

by Moamen ElMasry -

Hi, 
I've been facing the same problem. is there any solution (Plugin) for this issue!

Thanks in advance.

In reply to Quintin Seegers

Re: Hide course categories/courses from certain users

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

It is not possible in standard Moodle to hide course categories. If you look at any Moodle site which doesn't have forced login then if you go to THEMOODLESITE.com/course/index.php then you can see all the categories - see for example http://school.demo.moodle.net/course/index.php

So although there are workarounds to make it harder to find them, if your clients know the URL they will still be able to see other categories, even though they will not be able to enter the courses in them.

Average of ratings: Useful (1)
In reply to Quintin Seegers

Re: Hide course categories/courses from certain users

by Super Admin -

Hi Quintin,

--

First, hide all categories from everyone while logged in as an Admin.

Dashboard / ► Site administration / ► Courses / ► Manage courses and categories.

By default doing this step will mean; Non-editing teacherTeacherCourse creator and  Manager will still be able to see hidden courses.

--

Now create roles for each group; General, Product A, Product B, Product C, Product D and Internal. It's easier simply cloning the Student role for these. 

Dashboard / ► Site administration / ► Users / ► Permissions / ► Define roles

--

Now head back to; Dashboard / ► Site administration / ► Courses / ► Manage courses and categories.

Click on the Gear Icon on your chosen category you want a group to have access to and go to Permissions.

Scroll down to where the setting;

View hidden courses

moodle/course:viewhiddencourses

Now add the specific role you desire to have access to the category's contents while it remains hidden from everyone else even those students enrolled to the course apart from the; Non-editing teacher,  Teacher,  Course creator and Manager.

--

Remember to enroll each roles student's in the courses before they can see it. smile

--

I hope this helps. I had your exact need and this thread helped me to narrow down what not to bother trying so I thought to give back smile





Average of ratings: Useful (8)
In reply to Super Admin

Re: Hide course categories/courses from certain users

by Andrea Rappa -
Thank you very much for your help.
It's all clear but I'd like to be able to view the category and the sub-categories of membership. I tried to add a specific role to

moodle/category:viewhiddencategories
but it does not work.
I can see the courses I am enrolled with a specific role but not the categories on the homepage of the site.

Can you give me some help, please?

Thank you

In reply to Andrea Rappa

Re: Hide course categories/courses from certain users

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Sounds like your home page and navigation settings need changed - go to site admin/front page settings and also site admin/appearance/navigation - there are settings there that will allow you to show categories...

In reply to Emma Richardson

Re: Hide course categories/courses from certain users

by Andrea Rappa -
Good morning, thanks for the directions. I edited admin / front page settings but the course categories are not visible. I have also tried to modify the permissions on viewhiddencategories but nothing to do. a.
In reply to Andrea Rappa

Re: Hide course categories/courses from certain users

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Can you share screenshots?  Of your front page, your front page settings and your navigation settings please...

In reply to Super Admin

Re: Hide course categories/courses from certain users

by Gitte Bendixen -

Hi,

this could be one solution, but is it not possible to use cohorts for this - like setting category to cohort (with the desired members) and then just let only the categories that the user have cohort for be visible?

Best regards,

Gitte

In reply to Super Admin

Re: Hide course categories/courses from certain users

by Debbie Thompson -
I'm following your steps above and the job roles I added to moodle are grayed out when I try to add them to the category. Can you tell me how to fix this? 
I've tried hiding the category, adding permissions to the job role, and unhiding the category and adding the permissions for the job role. still doesn't work.
Attachment category allow role.png
In reply to Debbie Thompson

Re: Hide course categories/courses from certain users

by Chris Swinney -
Hey Debbie,

FWIW, we do this nicely in Moodle v3.7. The Role you create can exist in multiple contexts. When applying a role to a category, the role itself must be allowed to exist in the Category context.

Navigate to: Site administration -> Users -> Permissions ->Define roles -> <your custom role>

Then edit the role and ensure that it exists in the "Category context"

Set context for role

Check out the instructions at https://docs.moodle.org/37/en/Course_list_viewer_role, although I found this did not give the full information I required as I need to add the newly created role to the "moodle/category:viewcourselist" permission for the category (and remove the default "Guest" and "Authenticated user"). FWIW, I created a post and answered it at https://moodle.org/mod/forum/discuss.php?d=393527

Average of ratings: Useful (3)
In reply to Chris Swinney

Re: Hide course categories/courses from certain users

by Debbie Thompson -

Thank you, I will take a look at this. If the category is hidden, should the course be hidden?

In reply to Debbie Thompson

Re: Hide course categories/courses from certain users

by Chris Swinney -

@debbie, fwiw, you do not need to hide categories if you use this method. The permissions on the category allow users within the relevant role to view the catagory or otherwise. 

Average of ratings: Useful (2)
In reply to Chris Swinney

Re: Hide course categories/courses from certain users

by Alex B -
Hi Chris,

Thanks for this.
I seen that category:viewcourselist is available in Moodle 3.7+
I have a Moodle 3.6... and doesn't have this category, unfortunately.
I've done some workarounds, and that is the one with the hiding, what Debbie was saying. Yet, sometimes in Site Administration works to allow role in the permissions, sometimes it doesn't.
But, the concern is, that through the Search functionality, the users from let's say Product A can still see all the courses from any other Product (B,C,D..). Even though if they are not enrolled and they cannot enroll, they can still see the courses in the search results, which is not too good.

I was thinking maybe upgrading to the latest version of Moodle would help now that I seen this category:viewcourselist .

One question please - for Moodle 3.7 or 3.8, when you use this category:viewcourselist for a specific user role, I understood that you can show only specific categories of courses as you assign them. But when you are logged in with a user from Product A and you click on the Search field from the front page and you type in let's say "a" for search, will the search results display only the courses that contain the letter 'a' from the Product A category? Or will it display all the courses from other categories too, those that the user is not enrolled in?

Is this something that someone could test in their Moodle please?
At my end, to upgrade to later versions of Moodle, I need to upgrade my PHP as well on the server (version 7.1.0 is required and you are running 7.0.33.14.18.04.1.1). and not sure of the implications, if I want to revert back to Moodle 3.6 if it will still work and so on...

Many thanks
Alex
In reply to Alex B

Re: Hide course categories/courses from certain users

by Alex B -
I managed to upgrade to Moodle 3.8.2 and it works ok that functionality, much easier to do things.... And in Moodle 3.8.2 the search works just fine, it won't show anymore the courses that are not supposed to be seen anymore, just the courses from the categories where an user is assigned to. Yay.