Hide not subscribed courses to a users group

Hide not subscribed courses to a users group

wót Francesco Viali -
Anzahl Antworten: 10

Hi,

I have to hide to some users (added to a specific group "external") all courses they are not subscribed to (I manually subscribe these users to their courses).

All other users not belonging to this group "external" can instead view all courses and self-enroll.
Thanks


Is it possibile ?

Moodle 3.8.2


Many thanks in advance.


Als Antwort auf Francesco Viali

Re: Hide not subscribed courses to a users group

wót Randy Thornton -
Nutzerbild von Documentation writers
Francesco,

Yes, this is possible if you have Moodle 3.8 or later. There is a specific permission you can set that will allow or prohibit users from seeing any courses other than the courses they are already enrolled in.

Information on how to set this up is located here https://docs.moodle.org/310/en/Course_list_viewer_role.
Als Antwort auf Randy Thornton

Ri: Re: Hide not subscribed courses to a users group

wót Francesco Viali -
Hi, thanks.
I can't find a way to assign this permission (disallow the permission to see non subscriber course) only to users users s ubsbsi specific group...
Als Antwort auf Francesco Viali

Re: Ri: Re: Hide not subscribed courses to a users group

wót Randy Thornton -
Nutzerbild von Documentation writers
Francesco,

By "group" do you mean what Moodle calls a cohort?

If so, there is no way to do that directly. Moodle does not currently have the ability to assign users in cohorts or groups like that to roles. A role can only be assigned to an individual. So, you must assign those users the new role individually in the Assign system roles tool.

That will work if the list is small.

If you have a lot of users, hundreds or thousands to add, you could also do this using the User upload tool with a csv file to assign a system role in bulk. How to do that is explained here: https://docs.moodle.org/310/en/Upload_users#Set_system_roles. If you already have a list of the users in that group in a spreadsheet file, then you could do it that way.


Anhang screenshot_9238.jpg
Als Antwort auf Randy Thornton

Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Francesco Viali -
Thanks for your reply.
I read the documentation you linked.
If I understand all what I should do is:
1. edit default authenticated role and disable capability moodle/category:viewcourselist
2. create new system role with this capability allowed.
3. add users allowed to show course list to the new role

This is not what I was looking for because I have many users that HAVE to show all courses and many more users for the future: I have to give all existing users and all new users the new created role

There is no way to:
- do not edit the default authenticated role (so as default all existing and new users can show all course)
- create a new role that overrides capability moodle/category:viewcourselist ? It would be easy to assign to this role only the few users that have not to see all courses.

Thanks
Als Antwort auf Francesco Viali

Re: Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Randy Thornton -
Nutzerbild von Documentation writers
Francesco,

Yes, there is a way to do what you need.

1) Leave the Authenticated user as is with the ability to see the course list permission allowed
2) Create a new system level role with only one permission: set the capability moodle/category:viewcourselist to Prohibit.
3) Add the users from your group to this new system level role.

This is the inverse situation of that scenario on the documentation page. With this new role you will continue to allow users by default to see the full list of available courses, but a select group can not and will only see their enrolled courses.
Als Antwort auf Randy Thornton

Ri: Re: Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Francesco Viali -
Thanks,
I have some problem in understanding where to do that.
I try explaining better:
I'm creating role in Home/ Site administration/ Users/ Permissions/ Define roles
Role archetype: none
In: View list of courses you are not enrolled in (moodle/category:viewcourselist) I can only "allow" this permission, there is no way to "Prohibit"..
Als Antwort auf Francesco Viali

Re: Ri: Re: Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Randy Thornton -
Nutzerbild von Documentation writers
Francesco,

You are in the right place. To see the other permissions besides Allow, you have to first click the "Show Advanced" button, which is right above the "Filter" area. Then it will show you all the permission options, as in the attached screenshot.


Anhang screenshot_9354.jpg
Als Antwort auf Randy Thornton

Ri: Re: Ri: Re: Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Francesco Viali -
Great! found it! lächelnd
Another question...
Do you think there is any way (maybe with a plugin) to automatically assign users to a specific (newly created) system level role based on authentication method or based on a field in user profile?
Als Antwort auf Francesco Viali

Re: Ri: Re: Ri: Re: Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Randy Thornton -
Nutzerbild von Documentation writers
Francesco,

I can think of two alternatives.

1) You can do this in bulk using the User upload to assign a system role to many users at once, https://docs.moodle.org/310/en/Upload_users#Set_system_roles. but it is not automatic, real time, it is just an easy way of doing many users at one time. So, if you have them all in a list of spreadsheet, that is easy.

2) If you need a real time way to do it, there is no one plugin to do this, but you might be able to get real time assignments using two plugins:

Step 1) Assign a user to a Cohort based on a Profile field: https://moodle.org/plugins/local_profilecohort. This is a very good plugin, I have used it on many sites.

Step 2) Assign that Cohort to a System role: https://moodle.org/plugins/local_cohortrole I have never used this plugin, but it is up to date with Moodle 3.10. It looks easy to use.


So, in that case you go from Profile field value -> Cohort -> System role. I have never done this myself, but it certainly should work lächelnd


Als Antwort auf Randy Thornton

Re: Ri: Re: Ri: Re: Ri: Re: Ri: Re: Hide not subscribed courses to a users group

wót Randy Thornton -
Nutzerbild von Documentation writers
This works actually. I set up a test with those two plugins and it assigned the users to the System role based on a custom profile field.