-
Bug
-
Resolution: Fixed
-
Minor
-
3.11.10, 4.0.4, 4.0.5, 4.1
-
MOODLE_311_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
-
MOODLE_400_STABLE, MOODLE_401_STABLE
-
MDL-76026_401 -
- Create a course "Course 1"
- Go to question bank and add a true/false question
- Go to question categories
- Edit the "Default for Course 1" category which contains the question
- Change the name to something new like "Default for Course 1 NEW"
- Save
- Notice the following:
Notice: Trying to get property 'id' of non-object in /home/xxx/moodledata/imaster/moodle/question/bank/managecategories/classes/question_category_object.php on line 487 |
Notice: Trying to get property 'id' of non-object in /home/xxx/moodledata/imaster/moodle/question/bank/managecategories/classes/question_category_object.php on line 490 |
This appears to be a regression caused by MDL-74427, which added a new method
get_real_question_ids_in_category() and updated existing code to use this method. The method returns array values (just ints) but we're accessing each result like it's an object:
https://github.com/moodle/moodle/blob/0fcea11234a9d5016e7c55fa8e51621ac218a878/question/bank/managecategories/classes/question_category_object.php#L487-L490
Another thing to perhaps note, is that we don't seem to get an entry in the question table for random questions added to a quiz in 4.0 and above (I'm not sure myself whether this is expected, so reporting here). The only way I was able to see a question record with qtype = 'random' was to:
- Create a 311 site
- Create a course
- Create a question in the question bank
- Create a quiz and add a random question
- Upgrade the site to 400 (and the qtype='random' still exists)
I'll leave it up to those with more knowledge of the question bank to comment on whether this is expected or not (and therefore whether the code dealing with renaming these random questions is still relevant).