Issue Details (XML | Word | Printable)

Key: MDL-13059
Type: Sub-task Sub-task
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Petr Skoda
Reporter: Gary Anderson
Votes: 2
Watchers: 5
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-13847

Gradebook categories not always restoring correctly from backup

Created: 19/Jan/08 11:18 PM   Updated: 30/Mar/08 12:21 AM
Return to search
Component/s: Backup, Gradebook
Affects Version/s: 1.9
Fix Version/s: 1.9.1

File Attachments: 1. Zip Archive backup-math101 WORKING.zip (8 kB)
2. Zip Archive backup-math101-20080119-0549.zip (7 kB)

Image Attachments:

1. Original Course Grader report.jpg
(67 kB)

2. Restored Course Grader report.jpg
(64 kB)

Participants: Gary Anderson, Martin Dougiamas and Petr Skoda
Security Level: None
Resolved date: 18/Mar/08
Affected Branches: MOODLE_19_STABLE
Fixed Branches: MOODLE_19_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Gary Anderson added a comment - 03/Mar/08 06:08 AM
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.


Gary Anderson added a comment - 03/Mar/08 10:11 AM
Looking further at this, while I recommend the above change (as it will allow courses to be restored with some additional hand tweaking), the aggregation method for the course is not in the backup XML, so there is no way to restore it. Apparently it uses the default aggregation method for the new course, which will not be correct in the case of weighted courses.

Gary Anderson added a comment - 04/Mar/08 04:02 PM
Changing this to critical to try to give this more attention. Without at least setting the categoryid to null, fixing the gradebook for a course will require going into the database by hand.

Martin Dougiamas added a comment - 04/Mar/08 04:13 PM
Thanks, Gary. Passing to Petr for 1.9.1

Petr Skoda added a comment - 09/Mar/08 09:53 AM
working on gradebook restore rewrite just now...

Petr Skoda added a comment - 18/Mar/08 04:57 AM
should be fixed now, thanks for the report

Gary Anderson added a comment - 30/Mar/08 12:15 AM
Although the original zip file restores without the categories, it does import OK without creating phantom entries.

I needed to reset the course aggregation method to weighted mean of grades, and assigned weights to each category, and the computations were correct, as was all the formatting.

I then exported and did a restore and the computations on the new course worked correctly.

So, in summary, while backing up from the original release of 1.9 does not fully restore categories, it does import in a way that can be fixed.

And, backing up and restoring from the most recent update works correctly for backup and restore for 1.9, at least with respect to the sample gradebook tutorial that I made on docs.moodle.org for weighted grades.


Gary Anderson added a comment - 30/Mar/08 12:21 AM
As a demonstration of a working backup for anyone wanting to test a weighted gradebook further, attached is a backup of the course used in http://docs.moodle.org/en/Gradebook_1.9_Tutorial