One of the other projects that I am involved in, besides PoodLL, is the Moodle Association of Japan Hub (MAJ Hub). It is both a Moodle community hub and a set of plugins which add functionality to the standard hub. Most notably the courses uploaded there, are actually restored there and you can try them out before you download them.
The MAJ Hub is still in its early days, so we don’t have too many courses yet. I decided to add one of my courses to the hub. Thats when I hit a wall … legacy files. These are files that remain from the old 1.9 Moodle days. Moodle is not aware of which legacy files are needed where. So just includes the whole lot in the backup file. The result was that my little course turned out to have a 2GB backup file. Since Moodle 2.4 or so there is no way to eliminate legacy files from the back up, even turning them off in the course settings doesn’t help.
Fixing the Backup File
It turns out to be a fairly simple change to one file to force Moodle to leave out legacy files. To do that edit the /backup/moodle2/backup_stepslib.php file.
i) Around line 435, is list of backup steps. Remove “legacyfiles” from that list of steps
The unaltered list, looks like this:
$course = new backup_nested_element(‘course’, array(‘id’, ‘contextid’), array(
‘shortname’, ‘fullname’, ‘idnumber’,
‘summary’, ‘summaryformat’, ‘format’, ‘showgrades’,
‘marker’, ‘maxbytes’, ‘legacyfiles’, ‘showreports’,
‘visible’, ‘groupmode’, ‘groupmodeforce’,
‘defaultgroupingid’, ‘lang’, ‘theme’,
‘enablecompletion’, ‘completionstartonenrol’, ‘completionnotify’));
ii) And around line 515, comment out this line:
$course->annotate_files(‘course’, ‘legacy’, null);
A New Problem
But then I had another problem. The legacy files are actually still used in my course. If I removed them I would cripple the course. Replacing each legacy file is an arduous task, involving opening up each activity selecting the file in the html editor, deleting it and then adding it via the repository system. Gaaargh. “Is there no easier way?” I thought. But I found no easier way. Sooo , I wrote a TinyMCE (html editor) plugin to at least do part of the process. You select all, or part of, the contents of the html editor and click the “poof” icon. Poof fetches any legacy files it find in there and copies them over into the Moodle file system, then it updates the links in the html area.
You can get it from here: https://github.com/justinhunt/moodle-tinymce_poof
And here is a screencast showing it in action.