Details
Description
Attached is an course backup of a sample course that is not restoring the homework grading category correctly. Note that the Exams grading category is correctly working.
Changing the aggregation type does not solve the problem.
The bug is a a little nasty in that you are unable to delete the category (it says it has a problem with setting the parent category) and you can not even delete the imported course fully for the same reason.
I have uploaded a screen shot of the original and restored course to demonstrate the issue.
This uses the latest CVS update of Moodle 1.9 Beta 4.
Trying to see what the problem is on this, I note that $dbrec->categoryid is not being initialized as items in the grade_item table are being restored. Changing at around line 1597 of /backup/restorelib.php
$dbrec->courseid = $restore->course_id;
if (isset($SESSION->restore->importing)) {
to
$dbrec->courseid = $restore->course_id;
$dbrec->categoryid =null;
if (isset($SESSION->restore->importing)) {
is the easiest partial fix.
The problem is that grade categories have categoryid set to null, but a conditional does not consider this.
In reality, there should be an unset called after the insert_record later in the code, but the $dbrec is used after that in the code, so the fix will be more complicated.
Also, this fix does not resolve all proglems. The aggregation method for the course is not set even after this fix, but that can not be corrected until something is done about this problem.