Uploading users to custom roles

Re: Uploading users to custom roles

by Federica Marra -
Number of replies: 13

Hello everybody!

Has this issue been solved by someone? Is it possible to add the uploaded users to a system role?

In my situation: we are uploading lists of about 12/15 people each time so we are looking for:

1) a possibility to label or to keep this users separated by the other students (so we can have an easy overview of them)

2) quick solution for multiple users and not manually add each of them by a system role.

I was thinking about adding them at the "front page course" and create a role inside it, what do you think about this solution?

In reply to Federica Marra

Re: Uploading users to custom roles

by Federica Marra -

None with suggestions for this? 

In reply to Federica Marra

Re: Uploading users to custom roles

by Stephen Parry -

I suspect that if you assign front page role it will not restrict the users in all the ways you might want, e.g. you cannot disable user profile or password editing this way. I am not sure why the csv import does not allow system role assignment; it should. I think a backend hack (running some SQL against the database) may provide a solution, if you have some way of distinguishing reliably between the users you want in each role. I will have a look....

In reply to Federica Marra

Re: Uploading users to custom roles

by Ravi Alamuri -

Hello


Could you not use cohorts for this? If all you need is to separate the group of student / enrolments then cohorts should work  


Ravi

In reply to Ravi Alamuri

Re: Uploading users to custom roles

by Stephen Parry -
But how do you then assign different system level permissions to the students in those cohorts?
In reply to Stephen Parry

Re: Uploading users to custom roles

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

You can't.  The thing is that system roles are not designed to have a lot of people assigned to them.  Can you not just adjust the student role and the authenticated user role to get the desired effect?

The only way that I can think of to mass add users to a system role would be to do it directly in the database.

Average of ratings: Useful (1)
In reply to Stephen Parry

Re: Uploading users to custom roles

by Ravi Alamuri -
My apologies. I guess I didn't read that part. I was simply addressing the OP's point 1 - labeling or tagging certain group of students for easier maintenance. 


From Moodle's documentation - 

  • If you really feel your Moodle needs to have teachers or students assigned in the system context, go to the teacher/student role in Administration > Site administration > Users > Permissions > Define roles and check the "system" box. Then search for and allow the capability moodle/course:view


I would look into creating a new system role inheriting permissions from an existing role and then modifying the CSV Upload script to read for an additional column which has the System role ID (the one I just created) and then calling a function like assign_role_to_user.

In reply to Ravi Alamuri

Re: Uploading users to custom roles

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

If we are talking about labelling or tagging users for easier searching/maintenance, perhaps you could explore making custom User profile fields ?

In reply to Mary Cooch

Re: Uploading users to custom roles

by Ravi Alamuri -

Hello Mary,


Possibly. I am not sure what the OP intends to do but if it's assigning special roles, I am guessing neither profile fields nor cohorts would be the right answer.


Ravi

In reply to Ravi Alamuri

Re: Uploading users to custom roles

by Federica Marra -

Wow, thanks to all for your answers! 
I think it is a common problem that you cannot assign system roles through the csv file.

However for my issue (more labeling than assign capabilities to the uploaded users) could work well the cohort option. I though that as for the system roles, also the cohorts were course related.

I don't need to label the users in a course level and we like that our teachers enroll their students themselves. As administrator I only create the new users with the uploading procedure, that's why I was looking to the possibility to give a system role (without capabilities) to the new users.

Hope it is clear. smile 

In reply to Federica Marra

Re: Uploading users to custom roles

by Ravi Alamuri -

Hello Federica,

Cohorts can be site wide as per the documentation https://docs.moodle.org/28/en/Cohorts

However I am not sure how you would assign capabilities to a certain cohort since cohorts have nothing to do with capabilities. That said I remember there being an earlier debate with regards to assigning Site Wide roles to specific cohorts based on MDL-36951

Regards


Ravi

In reply to Federica Marra

Re: Uploading users to custom roles

by Ravi Alamuri -

Hello,

Just wanted to add - 


I went through the issue I mentioned earlier and if you follow through the discussion, there is a link to this plugin https://moodle.org/plugins/view.php?plugin=local_cohortrole . Would using Cohorts in conjunction with this plugin resolve your issue?


Ravi

In reply to Ravi Alamuri

Re: Uploading users to custom roles

by Stephen Parry -
FYI I have posted a patch on tracker MDL-15187 to add system role functionality to the CSV upload. If it gets accepted, we will then have a solution the Grant Beever's original 2008 post.
In reply to Stephen Parry

Re: Uploading users to custom roles

by Federica Marra -

Great Stephen, I think this it not my need (because cohorts on the csv file to upload are site wide cohorts and I needed this kind of "labeling/grouping system") but all of you that answered to my post are interested in this. I guess this is a common cr for the developer.

And many thanks also to Ravi for the plugin, indeed a smart solution.