Open
Description
There is a bug with the grade category after a course import
Steps to reproduce the bug
- Create a course c1
- Add a grade category cat1
- Add a Moodleoverflow activity modflow1
- Set the grade category of the Moodleoverflow activity modflow1 to cat1
- Inspect the database and note the value for
gradecat
in the tablemoodleoverflow
for the Moodleoverflow activity modflow1 in course c1 - Inspect the database and note the value for
categoryid
in the tablegrade_items
for the course c1 - These two values match.
- Create a course c2
- In course c2 import the Moodleoverflow activity modflow1 from c1
- Inspect the database and note the value for
gradecat
in the tablemoodleoverflow
for the Moodleoverflow activity modflow1 in course c2 - Inspect the database and note the value for
categoryid
in the tablegrade_items
for the course c2 - These two values do not match, but they should. The value in the column
gradecat
in the tablemoodleoverflow
was not updated during the restore.
Bonuspoints
- Now enrol a user into course c2.
- Inspect the database and note the value for
gradecat
in the tablemoodleoverflow
for the Moodleoverflow activity modflow1 in course c2 - Inspect the database and note the value for
categoryid
in the tablegrade_items
for the course c2 - The value in the column
gradecat
in the tablemoodleoverflow
was modified and for the course c2 we now use the grade category from course c1.
If you now open the grade report (grade/report/grader/index.php), you can see an exception:
Exception - Attempt to modify property "children" on null
It fails here: https://github.com/moodle/moodle/blob/139a0ad5f0458caaff7506c8b26081eea1c85231/lib/grade/grade_category.php#L2152