Moodle

Gradebook categories not always restoring correctly from backup

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9.1
  • Component/s: Backup, Gradebook
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

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.

Activity

Hide
Gary Anderson added a comment -

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.

Show
Gary Anderson added a comment - 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.
Hide
Gary Anderson added a comment -

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.

Show
Gary Anderson added a comment - 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.
Hide
Gary Anderson added a comment -

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.

Show
Gary Anderson added a comment - 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.
Hide
Martin Dougiamas added a comment -

Thanks, Gary. Passing to Petr for 1.9.1

Show
Martin Dougiamas added a comment - Thanks, Gary. Passing to Petr for 1.9.1
Hide
Petr Škoda (skodak) added a comment -

working on gradebook restore rewrite just now...

Show
Petr Škoda (skodak) added a comment - working on gradebook restore rewrite just now...
Hide
Petr Škoda (skodak) added a comment -

should be fixed now, thanks for the report

Show
Petr Škoda (skodak) added a comment - should be fixed now, thanks for the report
Hide
Gary Anderson added a comment -

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.

Show
Gary Anderson added a comment - 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.
Hide
Gary Anderson added a comment -

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

Show
Gary Anderson added a comment - 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

People

Vote (2)
Watch (5)

Dates

  • Created:
    Updated:
    Resolved: