Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.0.2, 2.3.1
-
Any
-
MOODLE_20_STABLE, MOODLE_23_STABLE
-
MOODLE_22_STABLE, MOODLE_23_STABLE
-
MDL-27083-master -
-
Description
We've found a series of actions that can lead to broken quizzes and loss of questions
To reproduce
1) Create a new quiz. This quiz has initially no questions and in my case gets an id=45;
select id,name,questions from mdl_quiz where name like "Test%";
|
id | name | questions |
45 | Test quiz |
2) Choose a spare category (or create it accordingly).
you can see in my case this new category has id=544:
select id,name from mdl_question_categories where name like "Test%";
|
id | name |
544 | Test category - to be deleted |
3) Create a test question belonging to this category. In my case this question gets an id=10418, and is assigned the right category:
select id,category,name from mdl_question where name like "Test%";
|
id | category | name |
10418 | 544 | Test question - short answer type |
4) Add this question to the quiz. You can see the question is correctly added to the quiz:
select id,name,questions from mdl_quiz where name like "Test%";
|
id | name | questions |
45 | Test quiz | 10418,0 |
5) Now the malfunctioning part: Delete the recently created category. Moodle will ask you to select another category to move the Test question to. Choose any existing category.
THIS SEEMS TO WORK, but in fact it doesn't. What happen is: category is deleted BUT affected questions are not assigned to the new category, so they become orphaned from a category point of view:
select id,category,name from mdl_question where id=10418;
|
id | category | name |
10418 | 544 | Test question - short answer type |
BUT:
select id,name from mdl_question_categories where id=544;
|
Empty set (0.00 sec)
|
So category is in fact deleted but affected question retains the old category id.
This situation leads to 2 major problems:
1) Questions inside the deleted category aren't in fact moved into the indicated category, but they are "lost" inside the database and cannot be further accessed. -> So DATA LOSS.
2) Affected quizzes cease to work, as they have questions belonging to a non-existent category. The attached picture shows that the test quiz has one question inserted but it's not shown due to this problem. So if you try to preview or attempt these quizzes, you get a "Category ID is invalid" error. The only solution is to delete the offending quiz and to regenerate it. Well, you can also go to the database and correct the wrong category id of the affected questions, but clearly this isn't an option for everybody.