While working on MDL-27626 I am facing yet another issue with the order in which the handling methods are called for selected paths in the XML tree (moodle.xml in my case). The problem appears when there is a sub-branch in the middle of a branch and then other sub-branches follow at the end. This pattern is typical for structures like this (real example):
<QUESTION_CATEGORIES>
|
<QUESTION_CATEGORY>
|
<ID>59</ID>
|
<NAME>Course level sub-sub-category</NAME>
|
<INFO></INFO>
|
<CONTEXT>
|
<LEVEL>course</LEVEL>
|
</CONTEXT>
|
<STAMP>glum+110531083817+9h2lta</STAMP>
|
<PARENT>0</PARENT>
|
<SORTORDER>999</SORTORDER>
|
<QUESTIONS>
|
<QUESTION>
|
<ID>7</ID>
|
...
|
<MODIFIEDBY>2</MODIFIEDBY>
|
</QUESTION>
|
</QUESTIONS>
|
</QUESTION_CATEGORY>
|
</QUESTION_CATEGORIES>
|
Note that the QUESTION_CATEGORY element has a CONTEXT sub-path within its final elements and then another QUESTIONS sub-path after its final elements. So far, I've been dealing with the sub-path in the middle of final tags by relying on the processing method being called twice, with both halves of the final data being passed separately. That works well, but the order. See how notify_path_start(), notify_path_end() and dispatch_chunk() are called when parsing the structure above:
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES start
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY start
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY process
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/CONTEXT start
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/CONTEXT process
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/CONTEXT end
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/QUESTIONS start
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/QUESTIONS/QUESTION start
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY process
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/QUESTIONS/QUESTION process
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/QUESTIONS/QUESTION end
|
/MOODLE_BACKUP/COURSE/QUESTION_CATEGORIES/QUESTION_CATEGORY/QUESTIONS end
|
As you can see, the "QUESTIONS start" and "QUESTIONS/QUESTION start" are triggered before the "QUESTION_CATEGORY process" is dispatched with the second remaining half of the category data (STAMP, PARENT and SORTORDER).
I believe I will be able to hack the question bank conversion code to cope with that. I just want to be sure this is expected behaviour. Or is there a way how the second incarnation of "QUESTION_CATEGORY process" could come before the questions starts?
For now, I'm setting this as a blocker as we must decide and specify the parser's behaviour to rely on.