What follows is a journal of the attempt to bring BIM 2.0’s backup functionality into line with the new approach in Moodle 2.x.
Done. Appears to be all working. Will work on restore next and do some testing.
First up is trying to understand the developer docs on the new backup process. What follows is an attempt to both summarise/understand those docs and explain what changes I’ve made to BIM 2.0. The Backup 2.0 general architecture documents are also used.
What I believe it all boils down to is the ability to convert the database structure for a BIM activity into an XML file/structure. The aim here will be to keep the XML structure produced as close to that produced by 1.9 as possible.
- Preparation – knowing what to backup
Much of this is done in the “BIM data” section below.
- Draw the DB schema.
- Identify where the user information is located in the schema.
- Determine correct order of backup.
- Identify attributes and elements.
All “id” fields should be attributes.
- Identify not needed elements.
Any field except those in parent elements should be included.
- Identify the file areas used.
Text fields and attachements appear to fit into this sector. This appears to be a bit new in Moodle 2.
- Annotating important bits
e.g. the ID fields.
- Remove the old backup stuff.
Basically backuplib.php in the bim directory.
- Tell Moodle that BIM 2.0 is supporting backups.
Add the following to mod/bim/lib.php
case FEATURE_BACKUP_MOODLE2: return true;
- Set up the directory for the code
- Set up and test the backup process (which won’t work at the moment).
The backup documentation includes a simple script that speeds up the develop/test cycle for backups. put that in place and run it. Breaks as expected
- Start putting in the code
- create empty mod/bim/backup/moodle2/backup_bim_settingslib.php
- backup_bim_stepslib.php – another empty file
- backup_bim_activity_task.class.php the place the above files are used. For now just some skeleton code with empty methods.
- Run the backup again.
Which runs without error as expected.
- Create the bim.xml file – as an empty file
- Some empty code into backup_bim_stepslib.php
- Call the method from the steps file from backup_bim_activity_task.class.php.
- Now to define each of the elements essentially a translation of the provided code with the description of the bim data below. This produces an empty backup file for bim.
- Define the tree of data following the skeleton code.
- Connecting it all to the database
A fairly simple set of method calls building on the above. Tested and all seems to be working. Woo hoo!
- Annotating IDs
This appears to be related to signposting user (and other) information, something I missed the first time.
For BIM, the relevant fields to annotate are user and group.
- Annotating files
Not sure about this section. Need to read some more and update.
- Encode references to URLs?
Done as per example.
The following is based on this 2010 post documenting the development work on the backup process for BIM 1.0. With some extra work based on the preparation information from above.
The bim data hierarchy (bullet points represent table names)
course (not needed) **** CHECK IF THIS IS INCLUDED ****
intro (????file area???)
bim (not needed)
BIM (not needed)
title (???? file area ???? )
body (??? file area????)
bim (not needed)
bim (not needed)
question (this is an id back into bim_questions)
link (???file area??)
title (??file area??)
post (?? file area?? )
comments (?? file area??)
In BIM 1.0 the user data includes: student feeds, marking and group allocation.