Solution: Adding Multiple Resources At Once!

Solution: Adding Multiple Resources At Once!

by Richie Foreman -
Number of replies: 4
Hello there everyone. Greetings from sunny, Mesa Arizona!

I was frustrated by moodle's interface that will only let me add one resource at a time. So, I have developed some code in PHP that will add several resources at once with minimal effort. However, It does not use moodle's internal functions or any of the administrative menus. In a nutshell, it runs completely independent of moodle and just modifies the databases that are the backend for moodle. Also, this is mainly intended for an administrative user, or maybe a trusted teacher.

Why?
Most of the data that is going to go on our moodle site is a collection of word/pdf/ppt files. I tried using directory listings, but our directories aren't in a very end-user friendly naming convention. I also tried SCORMs, but I didnt really like having to click on the module in the topic (We like everything listed in the topic). Finding and naming all these files one by one with the moodle interface is an incredibly time-consuming and tedious task that I dont wish upon anyone.

Features
  • Pulls all course names and ids from moodle's db and then lists them in a nice little menu that you can select
  • Input box that lets you put in the topic id for which to add to (topic #3, etc). (The section ID is automatically computed via a database pull).
  • Dropdown menus that list all the files in the moodledata/{$courseid} folder. (I couldn't stand to type in all of those file names!)
  • A name box next to each location drop down that lets me add in the name that the end user sees for the resource.
  • Some light error checking to prevent accidental database injections.
Cons
  • I'm still working on the dropdown menu code, and I'm having trouble alphabetizing it (I think I just need to change the directory listing code to an array, but it works at the moment).
  • Only works with MySQL (I'll be honest, I dont know how any other dB's work)
  • It doesn't tie in with the moodle interface at all, and may not meet the moodle development "guidelines" they have set forth. However, it gets the task done it was developed to do.
  • Files need to be uploaded via FTP, SMB, SFTP, SCP, or a web based form to the moodledata/{$courseid} folder. I didn't plan on having the ability to upload files built in to it (why use it then, just use moodle's internal resource interface).
  • No built in security (I have plans to tie it into moodle's built in auth(this shouldn't be that hard to implement), but at the moment there is no security, I suggest .htaccess, or IP based permissions on your server).
Pros
  • Runs relatively quick. It isnt including a massive ammount of files, and there aren't any graphics/header includes/etc associated with the code.
  • The code is relatively short. At the moment the code is about 450 lines or so.
I'd like to attach the zip or tar.gz file to this post, but I'm not sure if the code is mature enough for public consumption. I've tested it extensively on our moodle site, and see no problems with it at the moment. If you'd like to take a look at my code and give it a test on your own moodle sites, just shoot me an email ( orforema[at]mpsaz.org ).

I hope people will find my tool as useful as it is for me, I'm saving tons of a time a day when adding files to courses.

Also, please excuse any gramatical/spelling errors and any run-on sentances. I'm actually still a high school senior, and engish was never really my forte.

Thanks,
Richie Foreman
CTE Dept, Mesa Public Schools
oforema[at]mpsaz.org
Average of ratings: Useful (1)
In reply to Richie Foreman

Re: Solution: Adding Multiple Resources At Once!

by Ben Bowler -

Can I have a look at the code for this. I have a huge number of resources to add and no way to add them.

 

Ben

In reply to Ben Bowler

Re: Solution: Adding Multiple Resources At Once!

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Hi Ben - that post is nearly 6 years old now and there are many ways to add multiple resources to Moodle. If you can state exactly what you want to do -and if you are using Moodle 1.9 or Moodle 2.0 then perhaps we can point you in the right direction.

In reply to Mary Cooch

Re: Solution: Adding Multiple Resources At Once!

by Ger Tielemans -
zip (files or even a filled dir-tree) - upload - ask moodle to unzip..
In reply to Ger Tielemans

Re: Solution: Adding Multiple Resources At Once!

by Valery Fremaux -
Picture of Plugin developers

This does NOT publish automatically a set of resource entries in the course. You have to choose the "main file" you will publish. 

Is there any update on that possibility to build a lot of queued "Resource entries" in the course in one operation ?