Editing database preset zip archives

Editing database preset zip archives

by Ian Lindsay -
Number of replies: 2

Hi.

I need to maintain synchronisation of database fields between a number of presets that give differently formatted views of the same database (can explain the use case if anyone really wants to know). 

I came to the conclusion that the easiest way to do this was to export the preset for each view as a zip archive and then copy the preset.xml file contained therein, which describes the fields in the database, to each of the other preset archives before applying these presets via the "import from zip file" option.

To initially try this, I unpacked the zip archives, modified preset.xml then rezipped the files. However, on attempting to apply the preset I always receive an error of the form:

[tempdir]/forms/tempup_MfSuB0_extracted is not a preset.

A bit more investigation showed that this occurred even with no changes to the files - simply unzipping and re-zipping the archive was enough to trigger the error. Applying the downloaded preset zip archive without un/re-zipping works fine. I've reproduced this both on a Windows system using 7-zip and on Linux using Gnome Archive Manager.

Interestingly, a work-around seems to be to make a copy of the preset zip archive, unzip this, edit preset.xml as desired and then drag+drop it into the still-zipped copy of the archive, overwriting the previous version of the file in the archive (only tried this on Windows / 7-zip). The resulting zip preset then seems to work perfectly, successfully modifying the database with any changes made to the preset.xml

I can continue using this workaround for now, but would love to know what is causing this and be able to use un/re-zipped archives if I have to make more complex changes in the future, or even construct my own preset archives from scratch.

Grateful for any suggestions. Our Moodle is version 3.5 (20180628) with Database version 2018051400.

Regards,

Ian

Average of ratings: -
In reply to Ian Lindsay

Re: Editing database preset zip archives

by Alexander Schukin -

Hello, Ian!

I faced the same problem. I needed to make several databases with similar structure. I exported the preset, edited them and imported ZIP-archive with preset back. I edited several files: preset.xml, addtemplate.html, listtemplate.html and singletemplate.html.

At me this mistake was displayed too and I could not understand why it does not work.

Only having tried your way at me everything successfully was imported. Thanks you! 

But it is not absolutely successful - for some reason in templates after signs [[ excess gaps appeared. I cannot understand why so yet, but I delete these gaps manually.


Alexander

In reply to Alexander Schukin

Re: Editing database preset zip archives

by Ian Lindsay -

Hi Alexander.

I'm glad my temporary workaround was helpful for you too. I haven't tried editing any of the template files outside Moodle but it sounds like you might have found a further slight problem here.

The original problem is still something of a mystery for me. I haven't had time to investigate further, but I suspect some slight difference between the zip archive specification Moodle uses and that used by common archive managers. I'd still be interested to here from anyone more familiar with the internal working of the Database module.

Regards,

Ian.