http://awyatt.edublogs.org/2008/01/22/moodle-portfolio-using-uploa

image by LadyHawke365
I was delighted when I found that there really was a script that allows you to use a csv file to create a set of courses on Moodle. This is something that I think should be part of the moodle core. Fortunately, a solution exists–contributed and tweaked by several kind souls in the forums at moodle.org. While additional batch tools maybe available in later moodle versions, 1.8.x does not include them. The solution I present here is good for moodle 1.8.x (I have done it on 1.8.1 and 1.8.4 WIMP and LAMP).
When setting up our pilot portfolio instance, I needed to be able to create some 36 student portfolios. Getting the process down now will ensure that additional portfolios can be created quickly each semester.
First you have to have the users all in the system. I created a “sandbox” course and ran uploadusers with a csv file to create the accounts and enroll all the students students into the sandbox course. This course can be deleted or hidden, as desired. Where did the information come from? I actually exported gradebook information from the appropriate courses on the main Moodle LMS for the university and dropped it into the proper columns in an excel spreadsheet. After that, I filled in the remaining fields and saved the file in csv format. (If you use excel, always check the end of the file in wordpad. It is very easy to get extra rows of empty fields if you are not careful.)
Second, you need to install uploadcourse.php (this version of the file contributed by M. Pearson at Earlham) to your moodle/admin directory.
Create a csv file with the required information to create the courses. My file looks something like this. The file is a bit tricky to make. Almost all of the fields are required to create courses, even some things you might rather skip over! Fortunately, the script is friendly and will stop immediately when it encounters a required field with no data. Do double check the maxbytes settings in the moodle system policies or calculate the correct values. This value is in bytes, not mb.
If successful, the courses will be created and each student will be assigned as the instructor for that course. For more information about the various settings and fields, please see http://moodle.org/mod/forum/discuss.php?d=30126#p339447
You can create categories with this script, but the categories are only created if at least one course exists in them. If you need to create an “empty” category, then you will want to create a placeholder course with a placeholder instructor account. I created a user called “tba” and placeholder courses which were deleted later.
The categories are created in the order of the csv file, which can be a plus if you would like to manipulate those. But if you make a mistake the category order is tedious to change afterwards.
You trigger this script manually. I haven’t figured out how to add it to the admin menu.
This process worked very well to create portfolio courses for our portfolio instance. Although it takes a couple of steps, that is much faster than creating 20 or 30 courses individually and then having to set up the course setting information and assign the instructor role.