un-enroll a user from a course

un-enroll a user from a course

by Daniel Quesada -
Number of replies: 11

Hi to everybody. Can I un-enroll a user from a course using a flat file (CSV extension)??

Thanks very much

Average of ratings: -
In reply to Daniel Quesada

Re: un-enroll a user from a course

by JP Bosman -
I have the same question and need. Anybody figured out how to un-enroll students using a .csv file?
In reply to JP Bosman

Re: un-enroll a user from a course

by Patrick Pollet -
Hello,


According to the french translation of the documentation http://docs.moodle.org/fr/enrol/flatfile, (could not find it in the english version), the first column of enrolments.txt file contains the operation that could be "add" of "del".
So to unenrol, just provide a .csv file as below :
#operation,role,userid,courseid
del, student, 8, CF101
del, student, 17, CF101

HTH
In reply to Patrick Pollet

Re: un-enroll a user from a course

by JP Bosman -

Thank you Patrick for the tip.

I tried it in the Upload Users page but it returned a message saying it does not support #operation. I am working on Moodle 1.8 - will that make a difference?

Maybe I am uploading at the wrong place?

In reply to JP Bosman

Re: un-enroll a user from a course

by Patrick Pollet -
This is not the proper way.

You have to go to admin, Courses , Enrolments and activate the "flatfile" method.
Then by pressing Edit you can tune the file location an others options . Default location & name for the file to be processed is $CFG->dataroot/1/enrolments.txt

So you must :
1) copy your file there
2) change ownership to your apache user (important)
One easy solution as an admin is to upload your file in server's common files (Administration, Server, Site files) . It should go right into the proper place with the proper rights .


3) let the Moodle cron do the job.


It will erase the enrolments.txt file afterward, so keep a copy somewhere.

If you can read french, the documentation is at
http://docs.moodle.org/fr/Inscription_par_fichier_plat
I could not find an english version in Moodle's docs ;-((

Cheers.
In reply to Patrick Pollet

Re: un-enroll a user from a course

by JP Bosman -

Thanks again Patrick!

The Cron is now finding the flatfile (enrolment.txt) but now it does not execute because there is an issue with the userid field. The error message looks like this:

Flatfile enrol cron found file: /usr/www/users/skillshb/moodledata/1/enrolments
.txt

1: del student 4 High School Program :Unknown user idnumber in field 3 - ignoring line

The enrolment.txt file contains a test "student" that I enrolled and now want to unenrol as to test the process before doing it with real and a lot of students. I checked in the mdl_user file in the database to look up the student's userid - the only field I could find was "id" and she was "3" so I put that in. I do not have any idnumber field in my course and now I do not know where to look for the userid that the cron wants to find in the mdl_user table.

Any ideas? Thanks a million!

In reply to JP Bosman

Re: un-enroll a user from a course

by JP Bosman -

OK - it is working now:

In the example:
operation,role,userid,courseid
del, student, 8, CF101
del, student, 17, CF101
* "userid" refers to the idnumber field in the mdl_user table.
* "courseid" refers to the idnumber field in the mdl_course table.

In my test, the user I wanted to unenroll did not have an idnumber and the course also did not have an idnumber. I manually inserted the idnumbers in the relevant tables in the MSQL database and voilla when I ran the cron, the user miraculously dissapeared!

Thanks again for the help Patrick.

In reply to JP Bosman

Re: un-enroll a user from a course

by Patrick Pollet -
Hamdullillah or maybe HamdulliMoodle wink

If I understood well, the enrol flatfile plugin is meant to sync Moodle with external information systems , so both student ID and course ID refer to Moodle's idnumber database field, that are relevant to the external system and are not used elsewhere by Moodle. Moodle stores yours idnumbers when enrolling students and later on relies on your values to unenrol them.

Somebody fluent in english really has to update Moodle's docs on this really useful plugin !

Cheers

In reply to Patrick Pollet

Re: un-enroll a user from a course

by Séverin Terrier -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Patrick : you just have to click on the "English" link in the "Autres langues" bloc wink
In reply to Patrick Pollet

Re: un-enroll a user from a course

by Gordon Brooks -

Patrick,

I want to load a csv file with the student and then in 4 week uneroll them also using a csv file. 

How can I make this work?

Thank you,

Gordon

In reply to Patrick Pollet

Re: un-enroll a user from a course

by Mark Ellis -

Is there a fieldname that will unenrol a student from a course?  It just seem logical that if you can add a course in the CSV file by having the heading: course1, that there should be some way to put in an unenrol tag.  I know it would make my life much easier if I could copy the same CSV file info for enrolling courses and paste them in another for unenrolling. 

Any luck?