Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6621

Re: Restored course has no grades on gradebook

$
0
0
by James Williams.  

Hi all,

I know this might be an old(ish) thread, but I struck the same issue after backing up and restoring a course on MOODLE 2.7.9+ (with some local customisations).


I backed up the course using the admin/cli/backup.php (which I copied to a new file) and added the following chunk of code to  backup the grade_histories and the log activity.


I added this to admin/cli/backup.php - everything before "// Execution" line:

    $tasks = $bc->get_plan()->get_tasks();
    foreach ($tasks as &$task) {
        if ($task instanceof \backup_root_task) {
            $setting = $task->get_setting('logs');
            $setting->set_value('1');
            $setting = $task->get_setting('grade_histories');
            $setting->set_value('1');
        }
    }

// Execution.
$bc->finish_ui();
$bc->execute_plan();
$results = $bc->get_results();

The logs didn't get backed up, because we struck bug MDL-46455, which right now is open and results in non-legacy logs (mdl_log table) not being backed up, because we're using the newer log format (mdl_logstore_standard_log).


However, the grades are in the backup .mbz file, and I restored the subject from the CLI command line using Moosh.

(See: https://github.com/tmuras/moosh)

I added a hack in here, too, to try and make sure that Moosh CLI course-restore function did indeed try to restore the grades and logs (if I'd been using legacy logs) by adding the following:

I added the "// Customisation" section to the bottom of:

Moosh/Command/Moodle23/Course/CourseRestore.php:

        foreach ($tasks as &$task) {
            $setting = $task->get_setting('enrol_migratetomanual');
            $setting->set_value('1');

                        // Customisation - ensure "grade_histories" is enabled if they exist...
                        if ($task instanceof \restore_root_task) {
                                $setting = $task->get_setting('grade_histories');
                                $setting->set_value('1');
                        // End Customisation
            }
        }
        $rc->execute_precheck();
        $rc->execute_plan();
        $rc->destroy();

        echo "New course ID for '$shortname': $courseid in {$category->id}\n";
    }
}

Then used "moosh.php course-restore" to restore my MBZ file with the grade histories.


But, in the Grades / Grader Report for the restored subject, there were no grades showing up - there were simply no students listed, despite all the participants being in the subject.


Looking in the database afte the restore, the grades WERE indeed restored, however the problem was that the restoration of users and enrolments did NOT restore the ROLES - so the students were "enrolled" in the restored subject as participants, but had no role (i.e. were not students or teachers or anything).


So I went into:

> Subject Administration > Users > Enrolled Users

And added a "Student" role to one of the students, and then they appeared in the Grades / Grader Report view.


Hope this helps someone else finding this thread.


Viewing all articles
Browse latest Browse all 6621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>