Bulk Course Upload tool question

Bulk Course Upload tool question

by Jason Hollowell -
Number of replies: 118
Picture of Particularly helpful Moodlers
Hello,

I'm struggling to get the Bulk Course Upload (and teacher enroll) tool working and have a question and plea for help.

I've managed to add a little code to get most of it working (see this thread) but am having trouble with the teacher enroll option.

I'm basically a novice when it comes to PHP & MySQL. I understand, a little, the structure of the database and have been poking around and trying to sort out how, or where, the value indicating what courses a user is enrolled in and what level of user he/she is enrolled as. In other words, if I have course "A" and want to look at the database and see who teaches course "A", where would I be able to find this information?

Knowing this probably won't help me but it was the route I was/am taking in order to try and figure out why the "enroll teachers" portion of the Bulk Course creation tool isn't working for me.

I'm running 1.8.4+ on PHP 5.2 (Ubuntu on my server). Not sure if 1.9 supports bulk course creation or not but I've got my 1.8.4+ fairly customized and the academic year starts on April 1st here in Japan so I'd rather not go through the excitement of upgrading right now.

If anyone knows what I'm talking about smile any advice or pointers that you can give would be greatly appreciated.

Jason
Average of ratings: -
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Jeff Church -
Hi Jason,
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.
In reply to Jeff Church

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Jeff,

Thanks a million! smile 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
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Steve Taylor -

After a little trial and error, I realized that the teacher1_account field fails if you don't also include a teacher1_role field.

In reply to Jeff Church

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Jeff,

I just tried this (couldn't wait to get to work smile 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 smile

Jason
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Jeff,

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
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Jeff Church -
Just got to work and saw your post glad it is working for you. Sorry I should have put the role name stuff in the email. I did the same thing one time so I know it is an easy mistake.
In reply to Jeff Church

Re: Bulk Course Upload tool question

by Séverin Terrier -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Sure, it would have been better to have "teacher" (for "full" teacher), and "noneditingteacher" wink
In reply to Séverin Terrier

Re: Bulk Course Upload tool question

by Larry Elchuck -
I encourage this change to "teacher" (for "full" teacher), and "noneditingteacher" as well.

larry
In reply to Larry Elchuck

Re: Bulk Course Upload tool question

by Jeff Church -
Thats easy to fix change the short name of your roles. wink
In reply to Jeff Church

Re: Bulk Course Upload tool question

by Graham Paull -

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

In reply to Graham Paull

Re: Bulk Course Upload tool question

by Bob Puffer -

where are the commas? CSV = Comma Separated Values

In reply to Bob Puffer

Re: Bulk Course Upload tool question

by Graham Paull -

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.

In reply to Graham Paull

Re: Bulk Course Upload tool question

by Guillermo Madero -

Hi Graham,

I don't think there is an "editingteacher" field; shouldn't it be "teacher_role"?

In reply to Jeff Church

Re: Bulk Course Upload tool question

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
This is really helpful Jeff. I've added it to the Modules and Plugins Database at http://moodle.org/mod/data/view.php?d=13&rid=1536
In reply to Jon Bolton

Re: Bulk Course Upload tool question

by Marc Grober -
Note Robert Russo's comment about also having a tool. Is this the same code base? A different effort altogether? Should there be one M&P page for the whole enchilada or separate pages? The reason I am pushing is that I see some wonderful stuff get buried in layers and layers of forum discussion..... I understand from the discussion that the download utility is now also working in 1.9??

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.
In reply to Marc Grober

Re: Bulk Course Upload tool question

by Jeff Church -
My preference is if Robert's code works let us drop back to one tool (his). A student programmer wrote this for us. She is still working for us but you know how that goes. We are moving to 1.9 this summer so we will be updating the code at that point and I will post the new code. However, we are running with Banner integration using Eric's wonderful Banner/Luminis Message Broker mod so the need for course creation is very low. Our WebCT license runs out on Nov 29th so all of our faculty have to be on Moodle at that point. I see just a few more months of needing to build development courses in bulk then we will not really need this tool. I guess what I am saying is I would rather have someone that has a long term need for this tool maintain it.
In reply to Marc Grober

Re: Bulk Course Upload tool question

by noemi flores -

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.

In reply to noemi flores

Re: Bulk Course Upload tool question

by Marc Grober -
I believe the discussion I saw on Jeff's tool suggests that the teacher accounts have to already exist. You can use the bulk user upload feature already in Moodle to upload your teachers. Once your teachers are uploaded you can use the bulk course upload (see the note from Jon in this thread about where he stashed it under Modules and plugins or the zip file that Jeff posted earlier. Info on doing bulk user uploads can be fund in the docs. Do not identify the course you are associating the teachers with in the user upload. That will be handled in the course upload.
In reply to Marc Grober

Re: Bulk Course Upload tool question

by Michael Street -
"Note Robert Russo's comment about also having a tool.
<snip>"

I have looked around, but haven't been able to find either his comment, or his code. Is there a different version of this too floating around somewhere?

BTW, thanks very much for posting this tool. This is fantastic and will save us a bunch of time.

In reply to Michael Street

Re: Bulk Course Upload and Deletion Summary

by Marc Grober -
A bit of a recap..... If I got anything wrong, please advise. And perhaps someone would like to add something to the Moodle Docs regarding the current state of affairs in these regards??

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 zip.gif 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
In reply to Marc Grober

Re: Bulk Course Upload and Deletion Summary

by Jeff Church -
Marc thanks for the summary I think you got everything right on. Our programmers created a bulk course creation and a bulk course deletion tool. I will post the zip files for these with this post.

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.
In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by A. T. Wyatt -
Hi, Jeff!

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
In reply to A. T. Wyatt

Re: Bulk Course Upload and Deletion Summary

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
ATW - Thanks for the good suggestion. I would be happy to work with Jeff on getting his code into CONTRIB. Just let me know how I can be of help. Peace - Anthony
In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by Bruce Webster -
I'd like to have the 1.9.x version! Where can I find it?
In reply to Bruce Webster

Re: Bulk Course Upload and Deletion Summary

by Marc Grober -
Bruce,

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?
In reply to Marc Grober

Re: Bulk Course Upload and Deletion Summary

by Jeff Church -
Here is the delete course that works in 1.7 and 1.8. It takes a txt file with course short name. Be careful I have found with large list > 500 course that it times out the script run time. So if it hangs try upping your script run time or doing the delete in smaller batches.
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
In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by Marc Grober -
Jeff,

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
In reply to Marc Grober

Re: Bulk Course Upload and Deletion Summary

by Robert Russo -
Here is our backup and delete application.

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.
In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by Michael Street -
Any luck with testing this delete script in 1.9? Mine just shows me a blank page, with my course headers, but no content. No box asking me to upload the text file. sad

The bulk upload worked well though. Very fast. We were able to do 11K courses in short time.
In reply to Michael Street

Re: Bulk Course Upload and Deletion Summary

by noemi flores -

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.

In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by Alan Zaitchik -
Jeff,
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
In reply to Alan Zaitchik

Re: Bulk Course Upload and Deletion Summary

by Jonathan Laurin -

Hi,

Do you have a solution for this?  I need to run the script in an automated way too.

thank you

In reply to Marc Grober

Re: Bulk Course Upload and Deletion Summary

by Bruce Webster -
Thanks for that - I had searched and found. Jeff clearly lists his script as 1.8 only but this appears to be because he hasn't tested it in 1.9 rather than it not working - somebody who had tried it listed it as working. It's still no good for me yet as we use Postgres - maybe when I have some time I'll convert it.
In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by Sean Abachi -

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 

In reply to Sean Abachi

Re: Bulk Course Upload and Deletion Summary

by Laura Laura -

Hello Sean, I am having the same problem as well. I need to use special characters (á, ó, ñ....)

Have you find out the solution?

Thanks!

 

Laura

In reply to Laura Laura

Re: Bulk Course Upload and Deletion Summary

by Pedro Lopes -

Hello Laura,

I am having the same problem.

Have you find out the solution?

Thanks!

 

Pedro

In reply to Jeff Church

Re: Bulk Course Upload and Deletion Summary

by John Jackson -

Is there a version of the upload tools available for version 1.9 plz ?

regards,

John J

In reply to Jon Bolton

Re: Bulk Course Upload tool question

by Marc Grober -
Jon,

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 ;=}


In reply to Jon Bolton

Re: Bulk Course Upload tool question

by Andrew Coile -

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

In reply to Jeff Church

Re: Bulk Course Upload tool question

by Kristy Rhea -
I have used this in 1.9 and it works great...if the account is created first, as you said....I have one question. We have LDAP authentication set up for all of our users, and thier account does not get created until they have logged into Moodle once. How do I do a bulk course upload if the accounts are not their yet. I tried to do a bulk user upload and tell it to use LDAP auth for password, however, this is not working. Any help would be great. Thanks!
In reply to Kristy Rhea

Re: Bulk Course Upload tool question

by A. T. Wyatt -
I don't remember having a problem with this. First I used upload users and put in a password of password (because it is irrelevant) and auth type of ldap. Those are two fields. That creates the user even though they haven't logged in.

Here are my notes and some example files (the example uploadusers file uses imap, but that can just be changed to ldap).

atw

In reply to Kristy Rhea

Re: Bulk Course Upload tool question

by Marc Grober -
Can you post a zip of what your csv file looks like (don't forget to x out personal info) and what error messages you saw when you uploaded the users?
In reply to Marc Grober

Re: Bulk Course Upload tool question

by Kristy Rhea -
I was able to figure this out this morning by putting xx in the password field when uploading users. It allows me to upload users and still use their LDAP password. (And they cannot log in with using xx as their password)

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

In reply to Jeff Church

Re: Bulk Course Upload tool question

by noemi flores -
Sorry if I missed this, but where do you put the course delete utility? Or how do you install it? My moodle site is hosted so I have to be very specific when I put in requests. Thanks
In reply to noemi flores

Re: Bulk Course Upload tool question

by Jeff Church -
Hi Noemi,
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.
In reply to Jeff Church

Re: Bulk Course Upload tool question

by Jeroen Kleijn -

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

In reply to Jeff Church

Re: Bulk Course Upload tool question

by Graham Smith -

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

In reply to Graham Smith

Re: Bulk Course Upload tool question

by Michael Webb -

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.

In reply to Michael Webb

Re: Bulk Course Upload tool question - Multiple Teachers

by Geoffrey Rowland -
Picture of Plugin developers
Yes, we also have the issue that on bulk course-creation we can only add one teacher to a course. It is not a complete 'show stopper' (as as long as there is one editing teacher they can easily enrol their colleagues!) and the script is incredibly useful without this ability. However, it would be neat to get it working.

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.
In reply to Geoffrey Rowland

Re: Bulk Course Upload tool question - Multiple Teachers - FIXED

by Geoffrey Rowland -
Picture of Plugin developers
Using Meld (on Linux, WinMerge does a similar job on Windows), to compare some of the many versions of the bulk course upload script, helped pinpoint and fix the bug blocking the addition of multiple teachers to a course. Just a matter of a semicolon in the wrong place.

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;
}
In reply to Jeff Church

Re: Bulk Course Upload tool question

by alison fordham -
I have managed to bulk upload courses to my moodle 1.9. If I create a template course style with specific blocks how can I ensure all courses I bulk upload replicate that template?
In reply to alison fordham

Re: Bulk Course Upload tool question

by Sean Dagony-Clark -
I'm curious about this as well. I've figured out that the template field wants the shortname of another course. However, providing a correct shortname in this field seems to do nothing -- as far as I can tell, the new course is set up without any characteristics of the named "template" course.

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?
In reply to Jeff Church

Re: Bulk Course Upload tool question

by Johnny Zephyr -
Hi

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



In reply to Johnny Zephyr

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Johnny,

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+ smile
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Johnny Zephyr -
Hi Jason

Thanks for the input. Do you know if it also updates existing course details?

Thanks.
In reply to Johnny Zephyr

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Johnny,

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. smile

At any rate, as it stands right now, the Bulk Course upload tool will not update courses.

Jason
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Chris Collman -
Picture of Documentation writers
Hi,
Very interesting. Bulk course upload is something my site administrator could be interested in. So I added a page in MoodleDocs called Bulk course upload. I can see that this could also work with flat file enrolments.

The page is not long because I have not tried it by the numbers yet. I suspect there is more which should be added about enrolments plugins, authentication and such. I borrow pieces from this discussion and stole some sample data from ATW.

Great discussion. Best Chris
In reply to Chris Collman

Re: Bulk Course Upload tool question

by Marc Grober -
Ahhhhh, I was wondering when this might come up.....
Anytime you are fiddling docs for something listed in M&P Chris, please check out the M&P page to see if there is a Documentation link.

I can tell you that as far the uploads feature there was an issue with identifying editingteacher that was addressed in the forum discussion, but I don't know if that was addressed in the final package's demo csv file.

I did post to Anthiny about the possibility of putting the bulk upload and download course utilities in the same package with the same M&P page, but I don't think I heard back on that (Chad Parmentier posted some fixes to some work that folks helping Jeff CHurch worked up for bulk delete).
In reply to Marc Grober

Re: Bulk Course Upload tool question

by Chris Collman -
Picture of Documentation writers
Hi Marc,
As usual, I am with you 100% on that one. I try to avoid creating pages in MoodleDocs as one of my best practices. I usually do it when 1) a page matures to the point when there is entirely too much information on it and 2) I know something about the subject. This was sort of an exception for me.

Did my bald head miss something? I did not see a documentation link on the Bulk Course Upload Tool page in M&P, nor did a quick search of MoodleDocs lead me to a page that dealt with anything with that title. I thought the other Bulk course contributions were for pre 1.8, so I ignored them in my KISS draft. I fondly hope others will put in the links and fill in the details that my initial draft left out. I have no problem with that MoodleDoc page being deleted if the information is located elsewhere. Pretty sure we are still on the same page.

Last time I really stepped out in front as a Newbie was when I created what is now Development:Activity Locking.

Best Chris

In reply to Chris Collman

Re: Bulk Course Upload tool question

by Marc Grober -
I am not saying there is a doc page link from all M&P pages, but that its important to make sure that there is appropriate collaboration.... for example, check on who the maintainer is for an M&P item - documentation may have been included in the package but never implemented in the docs....

Wth respect to the bulk upload tool, that is something that could be falling through the cracks in that I don't know if anyone has really committed to maintain it.... I think Jeff was waffling about that I think because he didn't write the code, but I look at "maintainer" as more of a clearing house in some respects.....

Anthony I am sure will have more to say on the matter....
In reply to Marc Grober

Re: Bulk Course Upload tool question

by Chris Collman -
Picture of Documentation writers
I do apologize to anyone who I might have offended by creating a page in MoodleDocs.

Thank you Marc for pointing that out to me. I have noticed a few M&P pages with no MoodleDoc discussion links. Which is fine.

Sometimes I am a little bit pushy (private enterprise, garment manufacturing background). From my perspective, Anthony or anyone else for that matter can edit things in MoodleDocs. You know more about M&P but I thought the "owner" could choose to send the documentation to an external page or choose not to put up any links.

In any case, when I do step out where there is some doubt, I do like to give a heads up in the appropriate forum. I know I have run into pages that have been up for months and contained mis information, in part because nobody in the appropriate forum knew they existed !

Best to all Chris


In reply to Chris Collman

Re: Bulk Course Upload tool question

by John Isner -
Chris,
I think the wiki article is premature.

The article points to Jeff Church's Bulk Course Upload Tool. But there is also a Modules and Plugins entry for Rory Alford's Bulk Course and Category Creation Tool. Both are unsupported.

There is an issue in the tracker, MDL-13114 "Include bulk course create and remove with Moodle through the use of CSV files"

A.T. Wyatt commented on that issue "I think this is sorely needed in the standard instance."

I think we all agree with that! But why MDL-13114 has only 4 votes is beyond me.

Anyway, I would wait to document it until it is a standard feature, or until someone steps up to support it.

In reply to John Isner

Re: Bulk Course Upload tool question

by A. T. Wyatt -
Ha! Well, I put a call for votes on twitter. Maybe we might see one or two more come in. I would vote multiple times if I could. . .

atw
In reply to Chris Collman

Re: Bulk Course Upload tool question

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Chris - My goal is to encourage folks who provide contributed code to take advantage of the various tools that are available to help share, maintain, and document code. Folks are certainly free to link to documentation wherever they find it most convenient for them to put it. Similarly with downloads and filing bug reports. If they have other tools and resources that they prefer to use that is certainly fine. I simply want folks to know what Moodle has to offer (CVS, downloads, docs, forums, and tracker) so that they are familiar with the tools typically used by developers to work with Moodle code. So the intent is not to limit what folks do (although I do believe there are advantages to having things consolidated and done in a consistent) but rather to invite folks to use the tools available. Does that help clarify things? I'll need to come back a re-read this thread to see what the major questions are but feel free to highlight for me any points that might need a little clarification. Peace - Anthony
In reply to Anthony Borrow

Re: Bulk Course Upload tool question

by Vaduvoiu Tiberiu -
hi, i don't know if this is the right place to post questions about the tool but I will write it here. I was wondering if anyone could tell me what the fields: teacher,teachers, student,students refer to.
If I leave those fields empty I get an error when uploading. If I write anything in them, I see no difference. What exactly do those fields refer to?

P.S. Looking at the example csv file that came along with the module, I thought maybe it's role renaming but after a test, I saw that it wasn't.
In reply to Vaduvoiu Tiberiu

Re: Bulk Course Upload tool question

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I think these fields are just historic. Before the days of configurable roles, these were used to rename certain roles in certain courses. Actually, I wonder why those columns are still there at all? Anyway, you can probably put anything you like there, but 'Teacher', 'Teachers', 'Student', 'Students' would be a sensible choice.
In reply to Vaduvoiu Tiberiu

Re: Bulk Course Upload tool question

by A. T. Wyatt -
Greetings, Vaduvoiu!

I agree with Tim. The fields for "teacher, teachers, student, students" is not about roles so much as about the language used to describe those rules. In the "old days" we had the ability to make the word "professor" appear in the course rather than the word "teacher" by putting information in this field.

When I create portfolios, I do change this information to "Owner, owners, visitor, visitors", for example.

Mark Pearson has created a wonderful description of all the fields. I don't know if it is still on one of his servers, but I used it in a presentation last summer. You can find a copy here:

http://moodle.metrotech.org/mod/resource/view.php?inpopup=true&id=969

Maybe it will help.

atw


In reply to Chris Collman

Re: Bulk Course Upload tool question

by Michael Penney -
Hi Chris, you can add the 'Course Management' block, which enables bulk creation of courses with content (modules, blocks, etc.) and csv file metadata, as well as bulk course deletion.

http://moodle.org/mod/data/view.php?d=13&rid=1839&filter=1
Attachment block_iface.png
In reply to Michael Penney

Re: Bulk Course Upload tool question

by Deleted user -
The uploadcourse.php file generates the following DEBUG notice:
print_header() was sent a string as 3rd (Administration -> Upload Courses) parameter. This is deprecated in favour of an array built by build_navigation(). Please upgrade your code.
  • line 2387 of lib/weblib.php: call to debugging()
  • line 591 of admin/uploadcourse.php: call to print_header()

This can fixed by changing this code around line 578:
/// Print the header
print_header("$site->shortname: $struploadcourses", $site->fullname,
"<a href=\"index.php\">$stradministration</a> -> struploadcourses");

To this:
/// Print the header
$linktext1 = $stradministration;
$url_1 = 'index.php';
$linktext2 = $struploadcourses;
$url_2 = '';
$str_extra_links = array(
array('name' => $linktext1, 'link' => $url_1, 'type' => 'misc'),
array('name' => $linktext2, 'link' => $url_2, 'type' => 'misc')
);
$str_navigation = build_navigation($str_extra_links);
print_header($SITE->shortname, $SITE->fullname, $str_navigation);
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Nicholas McJetters -
I've noticed the bulk upload tool only supports shortnames of up to 15 characters but the shortname field can actually hold 100 characters. Is this because a long time Moodle only support 15 characters and the script just needs to be updated?
In reply to Nicholas McJetters

Re: Bulk Course Upload tool question

by Jeff Church -
Hi everyone sorry I haven't posted been very busy here. We have not looked at this tool since going to 1.93 we use the Banner integration mod to build all of our courses. I don't think we even put this back on our production server. Since we build all courses (apx 5000) a semester with banner we rarely even build development courses anymore since all faculty now have a course for ever class. Yes, the 15 character limit is a hold over from 1.8.
If anyone wants to pick this project up PLEASE feel free to do so. It would make me very happy to see the code updated. I would have no regrets about it having someone else name on it (that is the wonder of open source) Since we don't use it the project has fallen off my desk.
In reply to Jeff Church

Re: Bulk Course Upload tool question

by Mohan V -

hi guys

I am getting the following error

using moodle version 1.9.2

sample csv file

fullname,shortname,category,teacher1_account,teacher1_role,timecreated,timemodified
Test2,cf333,16,moodleteacher,3,1-Apr-06,1-Apr-06

the error message as follows

Parsed 1 course(s) from CSV
An Error occured creating course with ShortName CF103
Created 0 course(s) out of 1
1 course(s) failed due to errors
Re-Sorted courses
ANALYZE Database Tables OK
OPTIMIZE Database Tables OK
Total Execution Time: 0.28 s

thank you

mo

In reply to Mohan V

Re: Bulk Course Upload tool question

by coupeau charles -
Hello Mohan,

I have the same problem. I upload my file with 95 courses, only one course is created with 94 messages An Error occured creating course with ShortName XXXX.

Did you resolve your problem?

thx.
Charles

In reply to coupeau charles

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Charles,

You've probably already checked but just in case, is there any chance you have duplicate shortnames? I encountered this error a few years back and I can't remember what the cause was but it seems like it had something to do with duplicate or already existing names...?

Jason
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by coupeau charles -
Hello Jason,

I try the solution, the problem come from an index type 'UNIQUE' champ category and sortorder (table mdl_course).

I change to an index type 'INDEX' champ 'category'. It's ok now.

Thx,
Charles.
In reply to Jeff Church

Re: Bulk Course Upload tool question

by falguni Dharodiya -

Hey Jeff,

We are also running Banner and we already have module, which loads courses from Banner to Blackboard. Now as we want to migrate to Moodle. Can you please tell me more about Banner integration.

We are running Moodle 1.9 on Windows Server 2003. And we are usign SWL Server instead of MySQL.

Thank you very much.....

In reply to falguni Dharodiya

Re: Bulk Course Upload tool question

by Peter Lai -
He is referring to the Luminis Message Broker: http://moodle.org/mod/data/view.php?d=13&rid=849

You could use it, but we don't use that.

We constructed a bunch of materialized views in Banner then externally cache that data in our local db and use Moodle's External Database for enrollment management.

Alternatively, if you get ODBC working in PHP, you can probably hack the External Database (or write in a support for ODBC for this module), then suck it down from your Banner materialized view(s).

Also, you are replying to a 1 year old thread...
In reply to Peter Lai

Re: Bulk Course Upload tool question

by Dawn Sajn -
I want to download the plugin but the "Download latest version" link leads me to this forum.
Thanks!
In reply to Dawn Sajn

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Dawn & everyone else,

I've posted a message in the Tracker (MDL-13114) attempting to revitalize discussion on this there and have also attached the 'newest' version of the tool there. I made the changes referred to here in this thread by Geoffrey (i.e. fixed the multiple teacher enrollment issue) as well as added the ability to specify which enrollment plugin the course will use. The plugin options need to be increased and I'll work on that soon. Would like to get this back in Modules and Plugins first and then have it maintained (or maintain it smile ) that way via CVS first though.

Jason

P.S. The version posted in the tracker (mentioned above) works through 1.9.8+ as far as I can tell.
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Nicolas Papaconstantinou -
Hi, Jason,

Very glad you've picked up this tool's development. I've been tasked with investigating it, and have managed to get the sample CSV file to work in a test install of Moodle 1.9, though I had to delete two or three fields to make it happen - the Teacher enrolment, which seems an obvious one, but also the template.

This is going to sound like a really basic question, but I'm assuming the "template" field refers to course templates from which Moodle courses can be built, but at the moment my institution uses a different workaround for this, and I need a bit of guidance on where/what exactly the "template" field is pointing at.

Can you point me to any documentation that might help explain this, or give me a nudge in the right direction? It's probably really simple, but because we don't use that functionality, I have no idea what it means. If it is what I think it is, it might prove invaluable as part of the project I'm currently working on.

Thankyou in advance for your time!
In reply to Nicolas Papaconstantinou

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Nicolas,

First, I'm not really a programmer so I don't think I can say that I'll be managing the development. I've inquired about being given permission to maintain it in the Modules and Plugins area and will do my best to keep it up to date with my limited php skills and probably lots of inquiries to others who have more knowledge than me smile

As for the "template" field, I was just looking into that the other day and don't quite have my head around it myself. I understand that the field is supposed to allow you to designate a course by entering its shortname that will then be used as a template for the creation of the new course.

I poked around in the code a bit trying to figure out what it is attempting to do as I cannot get it to function correctly. I think I understood the logic but I couldn't figure out why it wasn't working. I'll continue to work on it and see if I can make any progress.

I did look at the Moodle database and couldn't find the field (template) in any of the tables associated with courses so I'm assuming it is a field used solely by the Bulk Course upload tool. I see that there are several inquires about the function and undoubtedly many people that would be able to use the feature, including my school, so I'll keep plugging away and see what I can figure out. smile

Jason

P.S. Did you have to delete the "teacher enrolment" field because the teacher accounts are not yet created on your site? Also, just out of curiosity, what other fields did you have to remove?
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Nicolas Papaconstantinou -
Thanks for the quick reply, Jason. So, phew, we're ALL just muddling through, then? I thought I'd really missed a trick with the "template" field.

If you've understood it correctly, it sounds like it won't be dissimilar to the way we already create new units manually - we have a couple of different ideally laid-out course backups set up as "templates", and create new courses by restoring from them.

If this IS the case, and the tool creates from pre-existing courses, rather than a seperate Moodle "template" function, perhaps what the script is looking for is actually a zip/back-up, rather than an unpacked and ready course? (I have no idea how that would work, but thinking laterally it seems like a possible option!)

As an aside, my supervisor has suggested the possibility of using differently designated config files to generate different course layouts - possibly to distinguish the different faculties - and I'm wondering if a) whether having more than one config file is an option, and b) whether that's a viable alternative to the template question? (He isn't here right now, so I've no way of running this paragraph by him for coherence.)

As to your PS: I had to delete the "teacher1 account", yup, for the reason you stated. I also deleted "teacher1 role", for tidiness sake, and "template". And that was it, actually.

My thinking is, lecturer enrolments might be better handled as part of a seperate process that we'll probably be running, anyway!
In reply to Nicolas Papaconstantinou

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Nicolas,

I've just been testing the Bulk Course upload tool a little with the 'template' field and can confirm that it does not use backed up versions of courses as templates. It is actually pulling directly from courses that are unpacked and "ready".

Also, I've just realized that the 'template' function does work to some degree. It does create block instances on the new course from the course set as the template course. I've been staring at the code for a while now and the little light in my head hasn't come on yet smile but it seems like it should be doing more than just creating blocks as I see more information there...

As for the use of different config files, I'm sorry but I'm not following that line of thinking very well. As far as I know, the information that determines what a course looks like is primarily stored in the mdl_course table (as well as in other tables such as mdl_block_instance, mdl_course_sections, mdl_course_modules, etc.). The script appears to be looking for the short name of the course specified as the template course and then pulling information from that row in the mdl_course table and inserting it into the row for the new course. It doesn't seem to be succeeding in inserting all of the information though. I'll keep toying with it and see if I can figure out why. I feel like it's a small issue but that is nothing more than a hunch so I could be wrong. smile

Jason
In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Martin Burrow -

Hi, can anyone help.

I cant get this script to work.

It only creates the first course in the list and then fails. If i rerun it, it creates the next course in the list and then fails, and so on. There are no claches with course names. CSV must be OK because it is getting parsed OK. We are running 1.9.2

Thanks,

Martin

Test file text

category, cost, enrollable, expirynotify, expirythreshold, format, fullname, groupmode, groupmodeforce, guest, idnumber, lang, metacourse, newsitems, notifystudents, numsections, password, shortname, showgrades, showreports, summary, theme, visible
1,,1,1,1,topics,apbongo1,2,1,0,apbongo1,,0,3,1,5,,apbongo1,1,1,apbongo1,,0
1,,1,1,1,topics,apbongo2,2,1,0,apbongo2,,0,3,1,5,,apbongo2,1,1,apbongo2,,0
1,,1,1,1,topics,apbongo3,2,1,0,apbongo3,,0,3,1,5,,apbongo3,1,1,apbongo3,,0

Error text

Parsed 3 course(s) from CSV
An Error occured creating course with ShortName apbongo2
An Error occured creating course with ShortName apbongo3
Created 1 course(s) out of 3
2 course(s) failed due to errors
Re-Sorted courses
ANALYZE Database Tables OK
OPTIMIZE Database Tables OK
Total Execution Time: 0.41 s
In reply to Martin Burrow

Re: Bulk Course Upload tool question

by Martin Burrow -
Just to let people know, adding a sortorder solved my problem.
In reply to Martin Burrow

Re: Bulk Course Upload tool question

by Paul Creedy -

I'm looking to bulk upload 1000+ courses and looking for an appropriate tool.

I've been following the forums but it seems there isn't a concensus as to what tool to use, plus there are bugs and issues popping up.

What I'd like to do is upload the courses into categories specified in the csv file, bassing the courses on a template (or existing course). Each course in the csv could possibly have a different template course.  I'd also need to be able to create courses without a tutor because courses are created first then tutors assigned to them afterwards.

Could someone point me in the right direction for a stable tool to use?

In reply to Paul Creedy

Re: Bulk Course Upload tool question

by Stefan Bäumer -
Hello,

I can make the uploaded course a meta-course. Fine.

But can I also define that course(es) that my new created meta-course inherits users from?

STefan
In reply to Stefan Bäumer

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Stefan,

I just checked the Bulk Course Upload tool code and, while I'm not a skilled programmer, I don't see anywhere in the code where the tool is written to allow you to specify the child courses.

Being able to specify the child courses however, would be a wonderful addition to the tool. The child courses would either already have to exist or have to be created prior to the meta course creation but it seems, in theory, that it would be possible. I'm afraid however, that my php skills are not advanced enough to be able to add this functionality.

If I can get this tool added to Modules and Plugins I will certainly add it to the list of desired features.

Jason

In reply to Paul Creedy

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Paul,

I think the Bulk Course upload tool, provided here in this forum, will enable you to accomplish everything you want to do.

Note however, that use of the template course only allows you to "pull" some very basic information from the template course. It will duplicate the blocks that appear in the template course and, if I remember correctly, the custom headings addded to center blocks but it won't create activities that exist in the template course. I don't know if this is by design or a bug.

At any rate, almost all of what you have inquired about here is possible via the Bulk Course Upload tool. I am using the one posted on May 11th 2008 by Jeff Church and it still works for me. I've updated it a little and that version can be found in the Tracker under MDL-13114.

Still working on trying to get this in Modules and Plugins. For now, the version in the Tracker should work for you.

Jason

In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by yush yuen -

I made some modification to the original file posted here and it worked on my 2.0 site. The lines that I edited are tagged with //YUSH HACK:

I have to completely commented out the page_block features... don't have time to figure that out.

In reply to yush yuen

Re: Bulk Course Upload tool question

by Jason Hardy -

I am working in Moodle 2.0. I have no programming experience but can follow simple instructions. I downloaded your patch for the upload course for 2.0 which has gotten me further than any previous versions. However I am now getting the following error once I try to upload my .csv file.

 

Coding error detected, it must be fixed by a programmer: Invalid state passed to moodle_page::set_state. We are in state 2 and state 1 was requested.

 

Also at the top of the page I have this showing:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\MoodleServer\xampp\htdocs\moodle\admin\uploadcourse.php on line 73

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\MoodleServer\xampp\htdocs\moodle\admin\uploadcourse.php on line 74

Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in C:\MoodleServer\xampp\htdocs\moodle\admin\uploadcourse.php on line 74

In reply to Jason Hardy

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Jason,

I've been away from this for a bit and just revisted today to find, to my dismay, that the Bulk Course Upload tool is not functioning and hasn't been updated for 2.0 sad

I'm not much of a programmer but enjoy hacking and poking around in the code. I will look at this and see if I can get it to work but I'm sure there are many others out there that are more capable than me. I'm currently having the same trouble (less the Warnings) using the hacked version posted here. If I have any success I'll post back here immediately.

Jason

In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Hello everyone,

I've been working with getting this working for 2.0 for the past few days and have made some significant progress. I'm attaching a copy of what I have so far but stress that it is a work in progress. The "Invalid State Passed" error has something to do with how the script attempts to print the header. I couldn't figure it out and wasn't worried about the esthetics so I commented it out for now.

The subsequent problems, which were much more critical from a functional perspective, were related to differences in how the database is organized under 2.0 as opposed to 1.9. Several fields that were in the course table in 1.9 have been moved to other tables for 2.0. One function affected by this is the ability to assign teachers at the time of course creation. I have disabled the feature for now. It is the next thing however, that I intend to work on so hopefully I can have it functioning in the next couple of days.

The display windwo in the current (test) script shows fields that I think should all work when using a csv file to create courses. With debugging on an Undefined Offset notice appears but does not affect the creation of courses. It should be fixed but is beyond my skill and doesn't affect the functionality at this point so I've ignored it sad

If anyone has any advice or is willing to brush this up, I would be most appreciative. If not, I will continue to hack away and hopefully get this back to a state where it can also enroll teachers into the courses as they are created.

Jason

P.S. Remember to enter your own database info in the first line (mysql_connect) and uncomment the line so the script can connect to your database. This should also be rectified in a future version.

In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Hello everyone,

I've been working on this for a few days and am making progress but I'm not stuck with the teacher enroll feature. The code involved, that is giving me problems, is as follows:

$roleid;

if (!$context = get_context_instance(CONTEXT_COURSE, $instanceid)) {
return -6;
}

if (isset($course['teachers_enrol']) && (count($course['teachers_enrol'])>0)) { // Any teachers specified?
foreach($course['teachers_enrol'] as $dteacherno => $dteacherdata) {
if (isset($dteacherdata['_account'])) {
if ($dcomma==true) {
$dteachers.=',';
} else {
$dcomma=true;
}
if(!($mysqlresource5 = mysql_query('SELECT `id` FROM `'.$CFG->prefix.'role` WHERE `shortname`=\''.$dteacherdata['_role'].'\';')) ) {
return -5;
}
if(!mysql_num_rows($mysqlresource5)) {
return -5;
}
$row = mysql_fetch_row($mysqlresource5);
//YUSH HACK: the 'enrol' field is gone for 2.0
//YUSH HACK: you need to lose the ; at the end for multiple value sets                   
$dteachers.='('.$row[0].','.$context->id.','.$dteacherdata['_account'].','.$course['timecreated'].',0);';
}
}


if ($dteachers!='') {
$dteachers .= ";";

if (!($mysqlresource4=mysql_query('INSERT INTO `'.$CFG->prefix.'role_assignments` (`roleid`,`contextid`,`userid`,`timemodified`,`modifierid`) VALUES '.$dteachers))) // from original

return -4;
}
}      

return 1;
}

Right now, when I run the script, all of the courses are created and I get an error stating that the value for the course id is empty and thus the teacher enroll fails. I've worked with the

if (!$context = get_context_instance(CONTEXT_COURSE, $instanceid)

a little but haven't been able to get past this. Does anyone have any ideas? The instanceid (or maybe it should be course->id?) comes from mdl_context and is the id associated with context 50 and the course id in question. The problem is that it isn't being retrieved....?

Jason

In reply to Jason Hollowell

Bulk Course Upload tool for Moodle 2.0

by Jason Hollowell -
Picture of Particularly helpful Moodlers

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 sad 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. smile

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.

Jason

Average of ratings: Useful (1)
In reply to Jason Hollowell

Re: Bulk Course Upload tool for Moodle 2.0

by Kathryn Duncan -

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!] 

Kathryn

In reply to Jason Hollowell

Re: Bulk Course Upload tool for Moodle 2.0

by Kathryn Duncan -

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!

Kathryn

In reply to Kathryn Duncan

Re: Bulk Course Upload tool for Moodle 2.0

by Rick Cook -

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.

In reply to Rick Cook

Re: Bulk Course Upload tool for Moodle 2.0

by Girish Chawla -

Hi Rick,

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.

Regards,

Girish

 

In reply to Girish Chawla

Re: Bulk Course Upload tool for Moodle 2.0

by Rick Cook -

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.

In reply to Jason Hollowell

Re: Bulk Course Upload tool for Moodle 2.0

by Thomas Brown -

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.

In reply to Thomas Brown

Re: Bulk Course Upload tool for Moodle 2.0

by Jason Hollowell -
Picture of Particularly helpful Moodlers

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.

Thanks

Jason

In reply to Jason Hollowell

Re: Bulk Course Upload tool for Moodle 2.0

by vancool black -

Hello Mr.Jason,

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 ?

Thanks.

In reply to yush yuen

Re: Bulk Course Upload tool question

by desmond shun -

Hi,

Does this tool support bulk SCORM upload for each of the course. I couldn't find that. I have plenty of scorm courses which needs to be uploaded to moodle. I could create category, courses using the CSV in moodle 2.0 but how do I add the SCORM courses by creating a column in CSV which specifies the scorm.zip file available in repository.

Has anybody worked on this?

In reply to desmond shun

Re: Bulk Course Upload tool question

by Jeffrey Silverman -

Moodle does not consider SCORMs "courses". Moodle considers them "activities" -- i.e. more like quizzes, assignments, or forums than entire courses. (This is a common lexical confusion that I run into all the time.) Point being, this tool does not work for "activities" and as such will not work for SCORMs.

Repeat, SCORM = activity. Not "course".

I hope that helps explain.

In reply to Jason Hollowell

Special characters

by Laura Laura -

Hello,

The code works fine with English characters, but does not work if the names of courses are non-English (for example: á, ó, ñ....).

I don't know php...

If someone knows the solution I would be very thankful!

Thanks!

Laura

In reply to Laura Laura

Re: Special characters

by Laura Laura -

Here the solution: When you save as csv:

Select: Juego de caracteres: Unicode (UTF-8)

 

Unicode (UTF-8)!!!

In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Steve Taylor -

Can this tool-- or any other-- be used to make bulk changles to course settings? I'd like to rename a bunch of courses.

In reply to Jason Hollowell

Re: Bulk Course Upload tool question

by Steve Taylor -

I ran into a problem assigning teachers. Apparently the script does a search of usernames to match known users to the teacher1_account field, but in several cases, one person's username matched a portion of another's username, e.g., "kane" and "jekane." (I know, we have inconsistent standards for username!)

 

Anyway, the script aborts because it finds two possible matches. Is there a way around this?

In reply to Steve Taylor

Re: Bulk Course Upload tool question

by Jason Hollowell -
Picture of Particularly helpful Moodlers

Steve,

I'm afraid that as it stands now the only thing you can do is adjust your usernames to avoid the 'overlap'. There should be a way to improve the search function so that is looks for an absolute string instead of one contained within another but I'm afraid I don't know what it is. I've wanted to work on this for quite some time but am too busy at the moment (and not really skilled enough sad ) to even give it a shot.

Jason

P.S. Also, I don't think you can use this to make changs such as renaming as it attempts to make a new course and if the course already exists I'm pretty sure it stops for that course and moves to the next one. Can't remember for sure but I think that's how it runs.