-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.4.2
-
None
-
MOODLE_404_STABLE
The question bank category screen has logic that prevents you from deleting a question category with questions in it. This logic requires you to move the questions to another category before the delete will process. For instance, if "Category A" has a question in it, you must first move the question to another category before you can delete category A.
During the move phase, however, the interface presents the category you are deleting in the "move" pulldown. If you select that category, Moodle will delete the category, leaving the questions that were in it in an orphaned state.
Here are steps to reproduce the issue.
1. From the course home page, choose more / question bank.
2. Choose categories from the pulldown
3. Add a new question category under TOP, calling it "Category A"
4. Choose questions from the pulldown
5. Click "Create a new question". Create a question and put it into "Category A"
6. Choose categories from the pulldown
7. Confirm that "Category A" has 1 question in it.
8. Delete "Category A". You will get a message asking you to move the questions to a different category.
9. Choose "Category A" and click "Save in Category"
10. The main question category screen will reappear. "Category A" will be gone.
11. Go to questions, choose "top for (course)", check "also show questions from subcategories", click "apply filters"
12. The question you created in Category A will not appear.
Note that in the example above, if the question in "Category A" was used in a quiz, that quiz would not be usable by the end of the process. Going into to the quiz would yield a "Cant find data record in database" error.
Note that if you go into the database after running through the process above, the category record (mdl_question_categories) will no longer exist, but the following tables WILL still have records referencing the question that was in the category : mdl_question, mdl_question_bank_entries, mdl_question_versions. Also note that the questioncategoryid field of the mdl_question_bank_entries record will now reference a non-existent question category. So another negative consequence of this behavior is that it produces orphan records.
The behavior that I would expect is as follows:
A. The category you are deleting should not appear in the move pulldown
B. There should be logic that executes immediately before the deletion of a category that stops the deletion if there are still questions in the category.