To anyone who wishes to use the Bulk Course Upload tool with Moodle 2.0. I am attaching a version that has been modified to make it work with 2.0. It works much like the version for 1.9 with some limitations. They are as follows:
1. The tool can no longer enrol teachers at the time of course creation. The process of enrolling a teacher in a course now involves several tables in the db in Moodle 2.0 and I wasn't able to make the necessary changes in the script. I have simply commented out the old portion if anyone wants to work with it. I did get it modified so that it inserts the correct information into mdl_role_assignments. The problem is that one other table needs to be modified for users to actually appear as enrolled teachers in a course.
2. Several of the fields that could be specified in 1.9 have been removed because they either no longer exist in the same table in 2.0 or because the insert wasn't working and I couldn't figure it out One example is adding topic heading to each week or section in a course.
3. There is a need to connect manually to the database. The values should be entered at the top of the script on line 78.
4. The script retains the insert functions from the 1.9 version but should, at some point, be upgraded to use the Moodle core functions. I was unable to do this due to my limited skills. Anyone who wants to work on this is welcome.
5. There are at least two other small 'bugs' that do not affect the functionality. One is an offset error and the other is a context error when attempting to output the header. I commented out the header output to get around that error and the offset error does not affect the functionality, as far as I can tell, and is only visible with debugging turned on....so I ignored it for now.
I think those are all of the issues/limitations. Othewise it does work in that it creates all of the courses fed to it through a cvs file and is thus a nice way to create a bunch of courses in a short amount of time. If you need to assign teachers, you can use the Upload Users tool (Site Administration -> Users -> Accounts -> Upload Users) to enroll teachers in courses. You can use the shortname from the file you used to create the courses. This adds one extra step but is still a fairly easy process compared to adding teachers one at a time. Of course, using the external database enrolment plugin is probaby a better option if you can set it up...
Experiment with this is a test environment to make sure it works as desired before you try it out on your production server.
This works well to create the courses. Thankyou. [I also have used this tool previosuly in 1.8 & 1.9, and now am setting up a totally new Moodle 2.0. I use the tool to initially bulk create the school's courses and then upload users to enrol all into the correct subjects.]
With Moodle 2.0, individually created courses automatically enable the enrol option to "manual". The bulk upload tool does not set an enrolment option/plugin. Hence no enrolments can be added until this is set, and the students are not enrolled into these courses when the upload user is used to try to set enrolments.
To allow enrolments you have to go to each course and enable the manual enrolments option before uploading users. Not a good option if there are a large number of courses!
There seems to be a database table mdl_enrol that contains the necessary record to enable the enrolments. This needs a recored created for each course to allow "manual" enrolments at the same time as the course is created. [I have fixed the problem on my system by importing matching records to the table, but this is obviously not a recommended solution!]
I have added the code to create the entry in the enrol table. This enables manual enrolment option only, and makes the default role "student".
Without this the course cannot enrol anyone - which may explain the problems of enrolling teachers at the time the course is created.
I am sure that someone can reorganise the piece of code I addes to a more appropriate placement in the module, and continue work on the teacher enrolment options! Thanks again for this tool!
Is there an example of the CSV file that needs to be created? I would like to start using this script, but am not sure what the CSV needs to look like.
Attaching temeplate for your reference.
First row is a header row which contanis filed names.
First column is for custome field created in user profile. All custome profile filed should have field name starting with profile_field_<customefieldname>.
Write me if any doubt.
Excellent! Thank you very much.
Also, has anyone had any luck finding a way to import course templates using a script? I have a course template set up and would like to restore it into each new course that is created.
Good job with the script it, is what we are looking for. Works with version 2
We dont need the teacher enrolments but I had a look at your code and I think you need to add an entry in *user_enrolments table as well as the entry in the enrol table, which was added in v1.3.2.
Kathryn and Thomas,
Thanks for your contributions here. I've been away for this for some time. Live in Japan and things have been crazy here so Moodle has taken a major back seat for a while. I'm curious to take a look at the fix contributed by Kathryn but not sure when I'll get the time to do it. It sounds like it now works as I would have hoped so that's a wonderful jump forward.
I'll see if I can plug away at it again in the next week or two.
I wanna test your upload file uploadcourseV1.3.2.php into
my new moodle version 2.4. my question is in where is i must put your file ?
And after that what should i do ?