How to minimize the question bank when doing backup/restore
When you back up and restore a course or a quiz, often a very large question bank is backed up which includes many questions not being used in the course or quiz. This can be a problem when the question bank on a site gets very large (over 1000 questions or over 500mb). At this point, backup and restore may fail due to timeouts or other technical reasons. Sharing courses on the Hub is also difficult because large question banks of unrelated questions are included which make sharing backup files difficult and confusing to teachers receiving the question bank.
In 2013, a checkbox was added to the Backup procedure to completely remove the question bank in a backup file. Thus from Moodle 2.7, it was possible to do an all-or-nothing inclusion or exclusion of the question bank. When the checkbox to exclude the question bank is checked, all quizzes are also removed from the backup.
This did not solve the original issue so a separate Tracker issue was made concerning how to minimize or select the questions included in a backup (MDL-41924). As of Moodle 3.4, this issue is still open. Additional suggestions were later added in MDL-63871, MDL-63872, and MDL-63873.
The key to being able to decrease the number of questions included in a course backup is understanding the circumstances in which the system level or course category level question banks are included in a backup.
What questions will be included in a course backup?
A question category can belong to one of four contexts: system, course category, course, and course module (aka quiz).
If the "Include question bank" option is not selected when performing a course backup, no question banks are included in the backup, but all quiz activities are also excluded from the backup.
A course backup created with the "Include question bank" option selected will always include all course level question bank categories. It will also include any course module level question categories for quizzes within the course. Whether or not any system level or course category level question banks are also included in the backup depends upon a couple of factors.
Storage location of quiz questions
By default, when adding the first question to a new quiz the question is stored in the default question category for the course. However, the user can select to store the question in any question category to which the course has access including question categories at the system and course category context. Subsequent new questions will default to storing the question in the most recently selected question category.
If a quiz question is stored in a question category in the system context, the entire system level question bank will be included in the course backup. Similarly, if a quiz question is stored in a question category in the course category context, the entire course category question bank will be included in the course backup.
Target of Random questions
Quizzes may contain random questions which pull questions at random from a specified question category.
If a random question is set to pull questions from a question category in the system context, the entire system level question bank will be included in the course backup. If a random question is set to pull questions from a question category in the course category context, the entire course category question bank will be included in the course backup.
A note on nested course categories
When a course category question bank is included in a course backup, only the question bank for the course category targeted by the random question or storing quiz questions is included in the backup. The question banks from peer or child course categories are not included in the backup.
Take for example the following course category hierarchy:
School of Science Physical Science Physics Chemistry Life Science Biology Zoology
If a quiz in a course were to have a random question pulling from a question category located within the Physical Science question bank, only the Physical Science question bank is included in the backup. The question banks of child (Physics and Chemistry) course categories or peer (Life Science) course categories are NOT included in the backup.
To reduce the number of questions included in a course backup, try to use system and course category question bank only as needed. One of primary benefits of storing questions in a system or course category level question bank is the ability to make modifications to a question once and have it apply to numerous courses. However, if questions will only be used by a single course it would be better to store the questions in a course level question bank category so as to avoid having to include the entire course category or system level question bank in a backup of the course.