Note: You are currently viewing documentation for Moodle 3.4. Up-to-date documentation for the latest stable version of Moodle is likely available here: How to minimize the question bank when doing backup/restore.

How to minimize the question bank when doing backup/restore: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
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.
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.


Originally, the question bank in a course and the upper level categories of questions has always been included in a backup.  In 2007, a Tracker issue (MDL-12403) was made to allow teachers and administrators to limit the questions included in a backup to just the ones needed. Discussion on that this issue showed that a solution was difficult and 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.
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 2.9, this issue is still open. As teachers and admins need to share questions and share courses which often include quizzes (one of the most popular activities in Moodle), it is still possible to minimize the questions, though doing it manually is complicated. The following workaround was successfully done in Moodle 2.9.1, and the resulting course backup file was restored on a Moodle 2.8.5 site.  
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.


This workaround strategy is based on the design of the question bank which only includes questions in a backup that are in the same category or a higher level category.  Thus System Level questions are included in every backup on the site.  Note that Moodle uses the word "category" in two ways which can be confusing.  A "category" can refer to a group of courses (Course Category) or a group of questions (question bank category).  In this section, we usually use "category" to mean a group of questions in the question bank.  These categories are also called "contexts".
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.


'''Workaround to Minimize Questions in a Course Backup'''
'''What questions will be included in a course backup?'''
#1.  Move all questions from System Level and other upper level Categories in your question bank to lower category levels--down to course level categories.  (this makes it difficult to view and share, but is necessary).
#2.  Move the course (or a copy of the course) to a temporary Course Category somewhere on your site where there are no other courses.
*3.  Make a backup of your course and restore this backup in the same Course Category.  (Moodle will automatically push all upper level category questions into course level categories--you will see this happen on the screen).
*4.  Go into the newly restored course and open the Question Bank.  You will see all questions are at the course level. 
5.  Prune (delete) all unneeded questions in your newly restored course.  Do not worry about deleting here, because you are only deleting course level copies of the questions.  The original questions on your site are not affected. 
6.  As you delete groups of questions, Moodle will list and confirm the questions you wish to delete. If you mistakenly try to delete a question that is being used in your course, Moodle will mark that one with an asterisk.  Then cancel the deletion, and try selecting again.  Note those questions and cancel the deletion and choose only unneeded questions.  (in the case of thousands of questions, this deletion process can take a long time).
7.  After you have minimized the questions manually by deletion at these course level categories, you can now make a backup and only the remaining questions you selected will be in the backup file.


In addition, you can encourage Moodle HQ to tackle this issue by voting, watching, and commenting in these two tracker issues: MDL-41924 and MDL-12403.
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.
 
In addition, you can encourage Moodle HQ to tackle this issue by voting, watching, and commenting in these tracker issues: MDL-41924, MDL-63871, MDL-63872, and MDL-63873.
 
[[es:Como minimizar el Banco de Preguntas al hacer respaldo/restauracion]]
[[fr:Comment minimiser la banque de questions lors d'une sauvegarde/restauration d'un cours]]

Latest revision as of 15:45, 5 November 2018

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.

In addition, you can encourage Moodle HQ to tackle this issue by voting, watching, and commenting in these tracker issues: MDL-41924, MDL-63871, MDL-63872, and MDL-63873.