Bulk upload users and cohorts

Bulk upload users and cohorts

by Roberto Catanuto -
Number of replies: 8

Moodle 3.9 here

Hi, I'm going to bulk upload some users by a csv file. The fields are:

usernamefirstnamelastnameemailpasswordcourse1group1cohort1

I want to add some more columns for the other courses, like: course2, group2 etc.

My question is: should I repeat the name of the cohort every time I add another course's column? The cohorts are all system wide, so all the courses have the same cohort.

Thank you for your help.

Robert

Average of ratings: -
In reply to Roberto Catanuto

Re: Bulk upload users and cohorts

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Hi Roberto,
Yes, if you are using the same named cohort in every course, you will repeat it under cohort2, cohort3, etc.
e.g. I used to teach 7th graders and had a cohort named, 7th Grade. after each coursex column, I had a corresponding cohortx column where I repeated, 7th Grade, for each student.
Average of ratings: Useful (1)
In reply to AL Rachels

Re: Bulk upload users and cohorts

by Randy Thornton -
Picture of Documentation writers
Actually, I disagree with Al on this one.

You do not need to repeat the cohort column if you are adding the user to the same cohort each time. You only need to add the user to the same cohort once. That's what this column does: it makes the user a member of the indicated cohort. Once a member, there is no point in trying to add them again.

If you add more than one column with the same cohort name for a user, the upload process will just ignore those additional ones since the user is already a member of the cohort after it processed column cohort1. It will not toss an error, it just ignores the request for adding the user again to the same cohort.

Consider this example:

username,firstname,lastname,email,cohort1,cohort2,cohort3
test,Test,User,test@example.com,CohortA,CohortA,CohortA

which attempts to add the user to the same cohort three separate times, which is not necessary. It will add the user to CohortA when it processes column cohort1 and it will ignore cohort2 and cohort3 columns since it checks to see the user is already a cohort member when it tries to add them to a cohort.

All you need is this:

username,firstname,lastname,email,cohort1
test,Test,User,test@example.com,CohortA

Or just this if you are only doing cohorts:

username,cohort1
test,CohortA

All the cohort column does is add the user as a member of the indicated cohort. It does not do any enrolments direclty: that is handled by the Cohort enrol sync process as usual when adding users manually, and it in turn handles any enrolments into any courses that the cohort is connected to an an enrolment method.





Average of ratings: Useful (3)
In reply to Randy Thornton

Re: Bulk upload users and cohorts

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Randy is right...sorry, I was doing three things at once and got sidetracked into giving the wrong answer.
In reply to AL Rachels

Re: Bulk upload users and cohorts

by Randy Thornton -
Picture of Documentation writers
I think that may be the first time! Seriously, my first thought was, "Obviously AL must be right, but that sounds funny to me..." so I had the double check on that. Upload users does get tweaked a lot from time to time, so it can do things I thought it didn't.
In reply to Randy Thornton

Re: Bulk upload users and cohorts

by Roberto Catanuto -
Thank you very much. This is what I thought too. So my scheme would be:

username,firstname,lastname,email,course1,group1,cohort1,course2,group2,course3,group3,...courseX,groupX
In reply to Roberto Catanuto

Re: Bulk upload users and cohorts

by C Behan -
Roberto,

I suspect you may be trying to do 2 different things there.
  • A csv file like: username,firstname,lastname,email,cohort1 can be used to add new users to a cohort. (If they are existing users then all you need is username, cohort1)
  • A csv file like username,firstname,lastname,email,course1,course2,course3 will manually enrol users to those courses.


  • A csv file like username,firstname,lastname,email,course1,group1,cohort1,course2,group2,course3,group3 (like you have it above) will 
  1. manually enrol the users on to those 3 courses, 
  2. put them in the respective groups and 
  3. add them to a cohort. 

It doesn't create a relationship between the cohort and those courses. (Maybe you know this.)


If you want to add users to a cohort and sync that cohort to your 3 courses, then 

  1. sync the cohort to the courses
  1. add users to the cohort
  • CSV file upload to include username, cohort1


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

Re: Bulk upload users and cohorts

by Randy Thornton -
Picture of Documentation writers
Exactly, that is well explained.

If you do add a user to a cohort that is set up to enrol into a cohort AND also enrol the user user directly to the course, you would end up with duplicate enrolments. On the Participants page you'll see two "Active" status indicators, one for each method. Usually, you want to avoid that as it could create issues. Usually, you want to do only one or the other enrolment method.
Average of ratings: Useful (3)
In reply to Randy Thornton

Re: Bulk upload users and cohorts

by Roberto Catanuto -
Now I understand better. I think this is a good solution:
username,firstname,lastname,email,cohort1
test,Test,User,test@example.com,CohortA

In fact, I use cohorts as an enrolment method and also as a groups generator. So yes, my csv file would duplicate enrolments.

Thanks