During the restore, the section's sequence field is ignored and the
order of modules is controlled by the order of the <contents> activity
elements. This patch makes sure that the modules are listed in that
section in the right order.
Also, the patch removes the obsolete stash sectionidslist which was
introduced when the method get_stash_itemids() had not existed yet.
This helper class keeps the referenced ids to be dumped into the
inforef.xml files. For now, it uses a in-memory storage structures but
in the future we may refactor it so that it can use some persistent
storage (like converter's stashes).
We want to set migrated content file in the File module as a main file.
Main files are files with sortorder set to 1. Therefore the file manager
must provide a way to set the sortorder property of the new file record.
The second change allowing filepaths not ending with slash is a helper
as we can easily use dirname() as a value (see the usage in the next
commits). Not providing the dirname() was a bug as the reference to a
file in the HTML text did not respect the migrated file path.
Currently the underlying backup/restore code does not differentiate null
and empty array data. So we have to explicitly check that we got array,
even though the correct set_stash() was called.
These static caches were bad idea of mine. Multiple conversion jobs
executed from a single PHP script share such variables, of course, which
is wrong. This patch removes one static cache completely and
reimplements the other two static caches as normal member variables.
Returning the converted array has no benefit here and makes the things
more complicated. From now on, the method is supposed to write what it
needs directly into the opened file, without returning anything.
This patch introduces a framework for the question bank conversion. It
deals with the common question data (that are not qtype-specific) and
the way how to make sure that the qtype plugins have access to the paths
they are interested in.
Grouped elements contain arrays with the sub-paths. This patch makes
sure that the sub-paths are pre-cooked recursively. However because the
recipes do not distinguish the full path to the element, only the
implicit recipe (making the tags lowecase) is applied. To avoid
potential data loss (for example dropfields recipe would delete all
fields from the whole grouped tree, not only the direct descendants of
the path where the recipe is declared), explicit recipes are forbidden
for grouped elements. The developer has to convert the $data manually as
needed.
In case the source $rootpath passed to the migrate_directory() does not
exist, an empty array is returned by the method. Note that if the
directory exists and is empty, the directory itself is converter so
there would be a new record created. However, the restore process
ignores these records anyway, as the directory records are created
automatically by certain file api methods.
The new file manager class is introduced. Once its public properties are
set, one can use it to migrate either a single file or a whole
directory. The course_files conversion reworked so that it uses the new
manager now. The files.xml written at the very end of the conversion,
giving all handlers a chance to migrate the files they need.
This is needed to give the modules a chance to actually rewrite course
modules related information. Resource module needs this so it is able to
split its own information into its successors (url, folder, page etc).
For system and course levels, we do not need itemid as we work with
single system context and single course context only. Thanks to this, we
can generate contextid for the restored course even we do not know its
original id yet.