Assign global roles using CSV upload

Assign global roles using CSV upload

by Brigitte Baquero -
Number of replies: 7
Hi.

Is there any way of uploading a new person and assigning a global role using a CSV file?
Average of ratings: -
In reply to Brigitte Baquero

Re: Assign global roles using CSV upload

by Teresa Gibbison -
I would also like the answer to this question...

The main Moodle page/site is technically a course so I attempted to upload users to my Moodle site with a specific role I added the Site Shortname to the course1 field, eg.

username, firstname, lastname, roleid, course1
user2, User, Name, 8, Moodle

RoleID 9 is a custom role I have created... this did not work, has anyone had success with this??

Many thanks
Teresa
In reply to Teresa Gibbison

Re: Assign global roles using CSV upload

by John Isner -
username, firstname, lastname, role1, course1
joe, Joe, Blow, foo, Moodle Demonstration
fred, Fred, Fish, foo, Moodle Demonstration

I just tried uploading the above file on demo.moodle.org (running Moodle 1.9) and it worked just fine. You must use the short name of the Front page course (look in the Site administration -> Front page -> Front page settings). Also, if you don't include passwords and e-mail addresses in the file, you will be prompted to give some defaults during the upload. The name "foo" is the short name of a role I created for this experiment.

In reply to John Isner

Re: Assign global roles using CSV upload

by Brian Pool -
Good point...upload uses short names instead of courseid...I changed my uploaduses.php file to make this change, as well as creating groups on the fly for all the courses during the upload.

I redo the upload weekly to catch schedule changes and new students.
In reply to John Isner

Re: Assign global roles using CSV upload

by Geof Duncan -
John,

Just because a user is given front page course rights does not necessarily mean these are SYSTEM rights. The user does have those rights within the front page, but, does not have them anywhere else.

I don't think this is quite the solution... but, I think it's close. It would seem as though we should be able to upload given the correct context, but, I don't think that the csv file is set up to upload anything else other than course permissions.

It would seem that if we could do a different upload or specify the CONTEXT somewhere in the file this would accomplish what we're hoping to do. So long as this process works on a course level it breaks this possibility I think.

At least this is what I think according to http://docs.moodle.org/en/index.php?title=Assign_roles&redirect=no. Anyone else have a better understanding than this???

-Geof
In reply to Geof Duncan

Re: Assign global roles using CSV upload

by John Isner -
Just because a user is given front page course rights does not necessarily mean these are SYSTEM rights

That's right, but I was responding to Teresa, who wanted to upload a students to her front page course, not the original poster.

I don't think that the csv file is set up to upload anything else other than course permissions

I agree, except that I would say "roles" rather than permissions.

It would probably be easy to modify the "Upload users" code to allow role assignments in contexts other than course. The context would be specified using two parameters: (1) a context TYPE and (2) an INSTANCE. For example, this forum ("General problems") would be specified by the integer pair (70,50) since it is a MODULE context (integer code 70) with instance id 50.

I think something like this has already been done for assigning the Parent role in the user context, but I haven't followed those discussions.

Anyway, I really like this idea. I think it would be quite a useful enhancement to upload users. I encourage you to add it to the tracker as an enhancement for 2.0, then let us know about it so we can vote.
In reply to Teresa Gibbison

Re: Assign global roles using CSV upload

by Chad Outten -
fyi - the 'role' field in the .csv file needs to be titled 'type'. if you want to correlate a role assignment to a given course > type1 for course1, type2 for course2 etc.