Getting files out of Moodle

Getting files out of Moodle

by Deleted user -
Number of replies: 1
Just to set the stage. I'm a really novice programmer, and only heard about Moodle 2 days ago. I've got a project assigned to me to make a plugin that when a user submits a file for an assignment, it changes the name of the file ("studentname-course.[extension]"), and sends the completed file somewhere else on the machine that uploads it to dropbox (I've already got a dropbox setup). I'm not looking for a full answer, but if someone could point me in the right direction I would so very much appreciate it.
Average of ratings: -
In reply to Deleted user

Re: Getting files out of Moodle

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
You need to create an event observer, probably for the \mod_assign\event\assessable_submitted event (for a full list of events go to /report/eventlist/index.php on your Moodle). This task will be defined in /mod/assign/classes/event/assessable_submitted.php.

More info on Events: https://docs.moodle.org/dev/Events_API
You'll eventually get to the files table. In Moodle, files are renamed with a hash of the file contents. This is done to reduce duplication. With the hash, you can use the first two pairs of hex numbers to find the original file. These docs might be useful: https://docs.moodle.org/dev/File_API_internals.

In your implementation, I would recommend you spin out an adhoc task to do the file shifting, as moving files during an event observer event might impact the user experience. https://docs.moodle.org/dev/Task_API
Average of ratings: Useful (2)