Importing R-Exams Questions into Moodle outside Course Instance Category

Importing R-Exams Questions into Moodle outside Course Instance Category

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).

enter image description here

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?

enter image description here

Answer

Import R exams questions into Moodle via XML format and place them in a custom question category outside the course instance.

Enjoyed this question?

Check out more content on our blog or follow us on social media.

Browse more questions