When generating Moodle exercises using R's exams
package, the exsection
meta-information header is very helpful for helping us to organise our question banks in Moodle.
By default, questions will be imported into Moodle in the category specified in the exsection
tag, but always within the course instance (e.g. the Semester 2, 2025 instance of a paper).
Each course instance sits within a higher level category within Moodle. For example, STAT115_S2_2025 (the Moodle instance for STAT115 in Semester 2 2025) sits within the STAT100 level category for us.
What would be helpful would be to be able to import questions directly into the higher level category (e.g. into STAT100, rather than STAT115_S2_2025). This is so we can pull questions between instances of courses more easily.
At the moment, you can control this in Moodle itself by deselecting the "get context from file" option when you import (see screenshot below).
The trouble with this is that colleagues forget to do this, leading to a messy bank (with questions nestled within course instances and the higher level course category).
So, is it possible to set the question to be imported into the course category level within R (either within the question .Rmd file itself or the R code that generates the XML)?
I can see in the XMLs generated by exams2moodle
that the exsection appears after $course$ by default (see below). Is there the option to change this within R?
This won't be an issue that needs solving from when Moodle 5.0 is released, as one will be able to use questions from the question banks of other courses. So questions won't need to be stored outside of individual course instances (at the higher level category) to be accessed in future versions of a course or in other courses.