Don't know if this will help but I will attach the script we are using to bulk create courses. Just put the file in the root/admin folder and when you are logged in as admin just go to the file location root/admin/uploadcourse.php
I will attach a sample CSV file as well. The teacher account must be created before assigning it to a course. Use the teacher user name in the CSV.
I have not tested this for more than 500 courses at a time. The script may timeout if you do to many courses at once. I have only used this on 1.8.3. We are integrated with our student management system so we only use this script to create test and development courses.
Hope this helps.
I forgot this will only let you attach 1 file so I zipped both files up to attach. Also included the bulk delete courses file you may find it helpful.
Thanks a million! I will give this a try today and see if it will take care of the task for me. Actually, I hadn't been using the teacher user name in the script that I'm trying to get to work (why didn't I think of that?) so I may give that a shoot as well.
I'm going to be creating just a little over 200 courses so I should be ok.
Thanks again, I really appreciate it.
Jason
After a little trial and error, I realized that the teacher1_account field fails if you don't also include a teacher1_role field.
I just tried this (couldn't wait to get to work and everything works except for one small (I hope) issue.
The teachers do get enrolled which is a huge jump forward for me (thanks!) but they are enrolled as non-editing teachers. Can't figure out why?
Is this a function of the script or do I have something set wrong on my site? The default role for teachers in courses is teacher so I don't think that's the problem...
Any ideas?
Thanks again
Jason
Sorry, I guess I should have experimented a little more before posting that last message. I figured out what I was doing wrong.
I was using "teacher" to assign the role which is the 'short name' for Non-editing teacher. When I changed the role assignment in my csv file to "editingteacher" everything worked.
Thanks so much for providing this updated version of the Bulk Course Upload tool. I will post a message in the discussion forum for the tool and attach this update. There were several questions/problems over there that will probably be resolved with this newer version.
Jason
larry
Hi Jeff,
I cant get the teachers to enrol, here is what my CSV looks like, should this work ?
fullname | category | editingteacher | summary | shortname | idnumber |
Accounting-AileenFoster-1 | Breifne Temp | aileenfoster | Accounting-AileenFoster-1 | Accounting-AileenFoster-1 | 1@amail.ie |
Agricultural Science-Kerri AnnThornton-2 | Breifne Temp | kerriannthornton | Agricultural Science-Kerri AnnThornton-2 | Agricultural Science-Kerri AnnThornton-2 | 2@amail.ie |
Agricultural Science-Kerri AnnThornton-3 | Breifne Temp | kerriannthornton | Agricultural Science-Kerri AnnThornton-3 | Agricultural Science-Kerri AnnThornton-3 | 3@amail.ie |
Agriculture/Horticulture-EibhlinNester-5 | Breifne Temp | eibhlinnester | Agriculture/Horticulture-EibhlinNester-5 | Agriculture/Horticulture-EibhlinNester-5 | 4@amail.ie |
Thanks
where are the commas? CSV = Comma Separated Values
Hi Bob,
This is just opened in excel.
Everything works, the course uploads to the right area etc, its just the teachers arnt enroled ? here is the raw CSV.
fullname,editingteacher,category,summary,shortname,idnumber
Accounting-AileenFoster-1,aileenfoster,Breifne Temp,Accounting-AileenFoster-1,Accounting-AileenFoster-1,Acc-AF-7-LC2@amail.ie
Agricultural Science-Kerri AnnThornton-2,kerriannthornton,Breifne Temp,Agricultural Science-Kerri AnnThornton-2,Agricultural Science-Kerri AnnThornton-2,Agr-KT-55-LC2@amail.ie
Agricultural Science-Kerri AnnThornton-3,kerriannthornton,Breifne Temp,Agricultural Science-Kerri AnnThornton-3,Agricultural Science-Kerri AnnThornton-3,Agr-KT-601-LC1@amail.ie
Agriculture/Horticulture-EibhlinNester-5,eibhlinnester,Breifne Temp,Agriculture/Horticulture-EibhlinNester-5,Agriculture/Horticulture-EibhlinNester-5,Agr-EN-697-101@amail.ie
The editingteacher is the colum header, I have then added an editingteacher's username into the colum for each course, is this right ?
Any help on this would be seriously helpful.
Hi Graham,
I don't think there is an "editingteacher" field; shouldn't it be "teacher_role"?
It's a confusion caused by having 2 different upload tools with essentially the same name - editingteacher is a field in the Piers Harding upload tool that allows you to specify what the collective name is for teachers when bulk creating courses - see http://moodle.org/mod/forum/discuss.php?d=209753#p916078
Also, should the discussion link point to a new parent item in the forums so that no one gets confused as to issues/usage that predates the version in M&P?
Has Jeff agreed to maintain this? Jeff?
Thanks Jon. BTW I only see a bit of the page that the utility produces; if as I expect it was your best effort to put the most important piece there well done.
I didn't see the the download section either. I work for a large school district and we do not allow users to create their own accounts or passwords. We have several hundred courses that need to be created as well as user accounts. We do not know how other organizations handle this. We thought a bulk upload tool would be the way most people handle course/user creation.
We use 1.9 and any suggestions will be helpful.
<snip>"
BTW, thanks very much for posting this tool. This is fantastic and will save us a bunch of time.
As I understand it, there is a hack for bulk course upload that appeared here: http://moodle.org/mod/data/view.php?d=13&rid=395 that was written by Rory Allford. There was some discussion that it was a bit out of date and that Rory had his hands full and was not at present updating it.
In the midst of that discussion Jeff Church mentioned that he had some bright young programmers roll their own hack. Jeff posted an upload utility and a deletion utility named delete_course_for_1.7-1.8---v1.zip here: http://moodle.org/mod/forum/discuss.php?d=91850&parent=405748 . The upload utility (but not the deletion utility) with example (though if the example hasn't been edited to address the editingteacher issue that is a bit of a caveat) is now available in M&P here: http://moodle.org/mod/data/view.php?d=13&rid=1536
Robert Russo, in the midst of this discussion mentioned that his folks have been working on a bulk deletion tool (my error in believing based on the context that he was developing, as did Jeff's people, an upload and deletion utility. Robert's posting appears here:
http://moodle.org/mod/forum/discuss.php?d=82932&parent=426906
The bulk upload tool has a 1.7 and 1.8 version. To use it you have to create the teacher accounts before creating to courses. The role for the teacher in the csv is the role short name. So for teacher use 'editingteacher' and Non-editing teachers use 'teacher' and so on.
The bulk course delete tool uses a txt file with the course short names. One course per line.
I hope to post 1.9 versions of these soon and I hope they have helped.
On a related note our programmers have produced several add ons for Appalachian State University and we (the Instructional Technology Consultants at ASU that manage the student programers. Greg Simmons, Mary Beth McKee, and me) would like to share them. What is the best place and method to do this? These were posted by me just because someone had a problem that I happen to see.
I think you should start by contacting Anthony Borrow to get these in contrib. And then put links into the modules and plugins database. There is a place in each entry to reference discussion, download location, versioning, etc.
These are tools that many people really need, so it would be great to have them available and easy to find!
atw
What you can search the forums on the terms "bulk course upload 1.9" which will return this http://moodle.org/mod/forum/discuss.php?d=91850&parent=427786 which has a link to here http://moodle.org/mod/data/view.php?d=13&rid=1536 which states: "This has been tested and is working on both 1.8+ and 1.9+." Voila ;=}
As far as the deletion tool, Jeff or Robert, are you ready/willing to put this in the M&P library yet?
I have not tested this or the course upload in 1.9 yet. It is on my list to do as we are moving to in in a month.
Good luck
Please refresh my recollection; what did you do to get the upload script added to M&P and will you do the same for this or did someone just take care of that for you?
I did a quick test of the upload script on 1.9 and it appeared to work save that one must use editingteacher as the role, but I assumed that someone else did some testing too as the module and plugin page indicates that it works with 1.9. I wonder whether we need a QA process for M&P ;=}
Still have not seen the delete course script mentioned by Robert Russo.
Thanks
Marc
It now includes a delete only function that is populated by uploaded files.
We are adding mtrace to delete functionality as well as delete from query functionality as well. Support for mtrace is added to the delete tool, adding to backup and delete now.
Only site admins can use the block. I would love this to get into contrib Anthony.
mtrace is in our query delete and the upload delete as well.
The bulk upload worked well though. Very fast. We were able to do 11K courses in short time.
We have not been able to get it to work either. I do have another question on the bulk uploads? We have subsites on our primary site, we have been able to bulk upload successfully on the subsites and the primary site. However, the enroll feature is only working on 1 of the sites. Is there some configuration setting that needs to be set within Moodle. We have not been able to figure it out.
Do you have a version of course upload (or course delete) that could work as an independent script, say with the filename passed in? We need to run this in an automated, unattended way, whether from a cron job or through some other way without any UI.
Alan
Hi,
Do you have a solution for this? I need to run the script in an automated way too.
thank you
Dear Jeff:
Your code works fine with English characters, but does not work if the names of categories and courses are non-English, such as farsi. Is there a way to make it work with all characters?
Thanks,
Sean
Hello Sean, I am having the same problem as well. I need to use special characters (á, ó, ñ....)
Have you find out the solution?
Thanks!
Laura
Hello Laura,
I am having the same problem.
Have you find out the solution?
Thanks!
Pedro
Is this link the last version of this script that works with 1.9? bulk_course_tools.zip
Are there other ways to bulk upload courses into Moodle 1.9?
Thanks.
met.
Is there a version of the upload tools available for version 1.9 plz ?
regards,
John J
Can you add the delete utility to M&P as well.
Also wanted to ask about testing for 1.9. Has anyone really tested this extensively? I used it a couple of times with 1.9 and made some comments, but I wouldn't consider my usage anything like QA for it ;=}
Could we please have the "Discussion" and the "Download" go to two different places?
If I click a "Download" link, I (not unreasonably, in my opinion), expect to start downloading something. I don't expect to have to wade through THIRTY screenfuls of information to try to figure out which thing cited is actually the download link.
I still haven't figured out where the "uploadcourse.php" script is supposed to be posted for Version 1.9. At this point, I'll probably just write my own.
...Andrew
Here are my notes and some example files (the example uploadusers file uses imap, but that can just be changed to ldap).
atw
My CSV now looks like:
username; password; firstname; lastname
jdoe; xx; John; Doe
For some reason in using 1.9 I had to change the separator to ";" instead of using "," However, when I upload courses I have have to use ","
username;password;firstname;lastname |
"The bulk course delete tool uses a txt file with the course short names. One course per line. "
See, http://moodle.org/mod/forum/discuss.php?d=91850&parent=427997
Sorry I'm new to posting code and didn't put very good (lol any) instructions in.
The file deletecourses.php goes in root/admin/
To access the file use root/admin/deletecourses.php There is not a GUI to access it yet. So you have to navigate directly to the file in the browser.
Hi Jeff,
I installed both the upload and de deletion tool
upload works fine (had to create the category first). Is it possible to add more than 1 teacher and to add several groups with password?
A text in the upper section would be nice too (I don't mean the long course name, but more or less the same inf. printed with specific characters on top of the topics section).
Deletion tool gives only a blank screen in moodle
regards
Jeroen Kleijn
The Netherlands
Jeff,
I have been attempting to use the various uploadcourse.php utilities and your appears to be the most complete.
However, there is one issue that is causing problems.
I want to create a course using this utility that has more than one editingteacher account (as there are courses where there are more than one teacher teaching the course).
The utility works brilliantly but if extra columns are added for further teachers in addition to the colums teacher1_account & teacher1_role :-
e.g.
teacher1_account | teacher1_role | teacher2_account | teacher2_role |
teacher1 | editingteacher | teacher2 | editingteacher |
Then the utility does not add the additional teachers.
Am i mis-understanding the description of the fields in the csv file and is there a way to add more than one teaching account when the course is created?
The field descriptions from the uploadcourse.php file are shown below.
teacher[1,2,...]_account |
teacher[1,2,...]_role |
Sorry to dig this up again, but did anyone solve this?
I'm having the same issue as Graham, ie can't get the bulk upload to work with more than one teacher - it just says couldn't add teachers.
Re: Bulk Course Upload tool question - Multiple Teachers
I quick scan of the PHP code indicates it is designed to handle multiple teachers. Indeed, a CSV file including something like the following works OK in adding one teacher per course:
teacher1_account,teacher1_role,teacher2_account,teacher2_role
Fred Blogs,editingteacher,,
,,,Freda Smith,editingteacher
So, the code is capable of correctly parsing the teacher1_account,teacher1_role, teacher2_account & teacher2_role fields, just falls-over for some reason when there is actually more than one teacher.
So, it is *almost* working. Any ideas?
We are using uploadcourse.php (from the upload_course_for_1.8---v1.2 folder) on Moodle 1.9.5, PHP 5.2.10, MySQL 5.1.35 on CentOS5 Linux.
Re: Bulk Course Upload tool question - Multiple Teachers - FIXED
Starting around line 525 replace:
$row = mysql_fetch_row($mysqlresource5);
$dteachers.='('.$row[0].','.$context->id.','.$dteacherdata['_account'].','.$course['timecreated'].',0,\'manual\');'; //penultimate ; causes the problem
}
}
if ($dteachers!='') {
if (!($mysqlresource4=mysql_query('INSERT INTO `'.$CFG->prefix.'role_assignments` (`roleid`,`contextid`,`userid`,`timemodified`,`modifierid`,`enrol`) VALUES '.$dteachers)))
return -4;
}
With
$row = mysql_fetch_row($mysqlresource5);
$dteachers.='('.$row[0].','.$context->id.','.$dteacherdata['_account'].','.$course['timecreated'].',0,\'manual\')';
}
}
if ($dteachers!='') {
$dteachers.=';';
if (!($mysqlresource4=mysql_query('INSERT INTO `'.$CFG->prefix.'role_assignments` (`roleid`,`contextid`,`userid`,`timemodified`,`modifierid`,`enrol`) VALUES '.$dteachers)))
return -4;
}
This is a great feature, as it would allow us to auto-populate new courses with instructional information to the teacher, for example. Has anyone gotten it to work?
The upload script is working well for me. Is the script meant to update rows too? does it have the ability to update exiting rows? i have made changes to courses but to no avail.
with regards to the deletecourses.php - i can't get this to work at all. the file loads fine but i don't actually get a box to upload a file.
I'm running my moodle on xampp. moodle ver 1.9.8
Any help would be fab.
thanks
I think the deletecourses.php feature broke somewhere along the way as Moodle progressed. I can't get it to work either and have been meaning to try and figure out what is wrong with it but haven't had the time to sit down and give it a shot. I'll try and do that soon. I'm trying to get the Bulk Course Upload tool back on the Modules and Plugins page and will hopefully have it packaged with the delete tool when that happens.
Jason
P.S. In the meantime, if you have a need for bulk delete, you can use the bulk delete part of Backadel found a little way up in this forum (here). Some of the features of the block don't work under 1.9.8+ but I'm pretty sure the bulk delete feature is functional. There are three components of this package in the Tracker (CONTRIB-605) that may be newer, I'm not sure.
**EDIT** I just checked the deletecourses.php file found at CONTRIB-605 and it does work with 1.9.8+
Thanks for the input. Do you know if it also updates existing course details?
Thanks.
As far as I can tell, it does not update existing courses. When you try to do this you get an error
"1 course(s) were skipped (duplicate ShortName)"
I can see in the code where the check for a duplicate shortname exists and the error that is thrown if it finds a duplicate. Adding this type of capability would be difficult as I think you would have to determine what you wanted to update and what you wanted to keep. If you don't check for the duplicate shortname, I think the original course would be completely overwritten or actually there might be an error generated from the database....as you'd be trying to insert a row that has some identical data. Don't quote me on that though...I'm typing as I think.
At any rate, as it stands right now, the Bulk Course upload tool will not update courses.
Jason
Thank You it is very help full for me.