Hello, I've done a fair amount of searching on the forums and surprisingly haven't found an answer for this one!
I need to be able to batch upload users automatically (without having to go to the admin user upload page). It would be just like the way you can put a file called Moodle_enroll into the moodle_data directory, and have a cron job run to have users be added to courses.
The story is that we have a data dump of users every night from another database that we want automatically sent to, for example, the moodle_data directory. A cron job will run each night, timed for after the file is uploaded that will add any new users, and then enroll them in their courses via the Moodle_enroll file (which already works great). The problem is with the adding of new users. We want this to be as automated as possible.
Thanks for any help!
Damon
Hi Damon,
You may wish to consider flat file enrolment. Please check the Upload users documentation for useful links.
You may wish to consider flat file enrolment. Please check the Upload users documentation for useful links.
This is clearly asking for database authenticacion and database enrolment. Both of them support 'syncing' from the command line, since moodle 1.6
Have a look at them.
Saludos. Iñaki.
Have a look at them.
Saludos. Iñaki.
Hello, thanks for the replies. We have enrolment working correctly already through the flatfile as I mentioned above. There's just a script that runs every week that looks for the enrolment file in the given location and automatically enrols the people listed in it. What I'm looking for is for the same thing to happen with adding new users (using a flatfile and running a script that will look for that file and add the users in it to the database). Inaki, I'll look up syncing in the docs and see if I can find something. We're actually going to upgrade to 1.6 most likely in the next couple of days, so hopefully it will be easy.
Have a good day everyone,
Damon
Have a good day everyone,
Damon
For anyone who looks at this thread with the same question, I figured out a solution that seems to work: I edited the uploaduser.php file, which is the one that runs when you want to upload users from a flatfile from inside Moodle.
First I copied the file and changed its name so I wouldn't lose the original, then commented out the lines that require logging in, session keys, etc. so it could be run from the command line. Then I hardcoded a file name and location so it wouldn't be searching for a file that was uploaded from the web page. It can be run by typing "php uploadIt.php", and as long as the flatfile I specified is in the location it should be, everything runs smoothly and the new users are added to Moodle.
This we will put into a cron job so new users are uploaded every night. Makes it so much easier than a person needing to use up time every morning when he or she comes in.
Damon
First I copied the file and changed its name so I wouldn't lose the original, then commented out the lines that require logging in, session keys, etc. so it could be run from the command line. Then I hardcoded a file name and location so it wouldn't be searching for a file that was uploaded from the web page. It can be run by typing "php uploadIt.php", and as long as the flatfile I specified is in the location it should be, everything runs smoothly and the new users are added to Moodle.
This we will put into a cron job so new users are uploaded every night. Makes it so much easier than a person needing to use up time every morning when he or she comes in.
Damon
Hi Damon
This is precisely what we are looking at doing (new users for courses get dumped into a text file overnight and then a scheduled task takes them into moodle).
Is this edited version of uploaduser.php available anywhere?
Best regards
Mike Chaplin
I'd be interested to see, and potentially use your code mods also.
Thanks
Thanks