Need student data but cannot get any data- restore fails bug

Need student data but cannot get any data- restore fails bug

by John Reese -
Number of replies: 1

Hello,

We know about but this huge bug where we cannot restore a course from a backup

https://tracker.moodle.org/browse/MDL-34172

We are having trouble restoring a course and keep getting the following error and have the same exact debug details as recorded in Moodle Tracker for MDL-34172
 
This is critical for us as we are trying to review the work of a student who said she submitted the assignments. Is there another way to get her course logs or what she uploaded?

the bug workaround states not to restore course logs! So how can we find what we need to do?

----

Coding error detected, it must be fixed by a programmer: define_restore_log_rules() method needs to be overridden in each subclass of restore_activity_task

More information about this error

Stack trace:
line 255 of /backup/moodle2/restore_activity_task.class.php: coding_exception thrown
line ? of unknownfile: call to restore_activity_task->define_restore_log_rules()
line 50 of /backup/util/helper/restore_logs_processor.class.php: call to call_user_func()
line 73 of /backup/util/helper/restore_logs_processor.class.php: call to restore_logs_processor->__construct()
line 2008 of /backup/moodle2/restore_stepslib.php: call to restore_logs_processor::get_instance()
line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_activity_logs_structure_step->process_log()
line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
line ? of unknownfile: call to progressive_parser->end_tag()
line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
line 187 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
line 148 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
line 46 of /backup/restore.php: call to restore_ui->execute()

 
Average of ratings: -
In reply to John Reese

Re: Need student data but cannot get any data- restore fails bug

by Lawrence N -

Hello John,

I hope this helps those that are having restore problems where you could not restore a course unless you uncheck / do not restore activity log as part of the restore process.

After your test restore, make sure that all the key functionality, scores, logs, assignments, grades, etc. are intact. In a nutshell, while the restore may look like it went successfully, best to test that all the the data is fine after the restore

Here is the workaround explanation …

Background:
----------

The problem was during the restore, we get the following error, which is exactly recorded as a bug: https://tracker.moodle.org/browse/MDL-34172

———

Coding error detected, it must be fixed by a programmer: define_restore_log_rules() method needs to be overridden in each subclass of restore_activity_task

More information about this error

Stack trace:
line 255 of /backup/moodle2/restore_activity_task.class.php: coding_exception thrown
line ? of unknownfile: call to restore_activity_task->define_restore_log_rules()
line 50 of /backup/util/helper/restore_logs_processor.class.php: call to call_user_func()
line 73 of /backup/util/helper/restore_logs_processor.class.php: call to restore_logs_processor->__construct()
line 2008 of /backup/moodle2/restore_stepslib.php: call to restore_logs_processor::get_instance()
line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_activity_logs_structure_step->process_log()
line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
line 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
line ? of unknownfile: call to progressive_parser->end_tag()
line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
line 187 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
line 148 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
line 46 of /backup/restore.php: call to restore_ui->execute()

——

This is what I discovered.
This is an activity problem. Hence, we need to look at all activities under the /mod directory In every activity, they have the same path pattern /mod/$OurActivityName/backup/moodle2/ In the moodle2 folder there is a “restore” php file with name of the file patterned as:

restore_’$OurActivityName’_activity_task.class.php where $OurActivityName is the name of the activity.
So if it was a book activity, the file we are interested in is: “restore_book_activity_task.class.php” If it was a hotpot activity, the file we are interested in is: “restore_hotpot_activity_task.class.php” If it was a journal activity, the file we are interested in is: “restore_journal_activity_task.class.php” ... and so on.

In each of these files, there are 6 basic functions that they must have:

protected function define_my_settings() {
}

protected function define_my_steps() {
}

static public function define_decode_contents() {
}

static public function define_decode_rules() {
}

static public function define_restore_log_rules() {
}

static public function define_restore_log_rules_for_course() {
}

The key are the last 2 functions: define_restore_log_rules() and define_restore_log_rules_for_course(). If the activity does not have these 2, the restore will fail because these defines the rules for restore.

To fix it, we simply copy from and activity that have these 2 functions and add them accordingly with their associated activity name.

The problem we had was with Hotpot and Journal activity. They were missing these 2 functions!

Hotpot: restore_hotpot_activity_task.class.php
————

/** added fix … */

/**

    Define the restore log rules that will be applied
    by the {@link restore_logs_processor} when restoring
    folder logs. It must return one array
    of {@link restore_log_rule} objects

    */
    static public function define_restore_log_rules() {
    $rules = array();

$rules[] = new restore_log_rule(‘hotpot’, ‘add’, ‘view.php?id={course_module}’, ‘{folder}’);
$rules[] = new restore_log_rule(‘hotpot’, ‘edit’, ‘edit.php?id={course_module}’, ‘{folder}’);
$rules[] = new restore_log_rule(‘hotpot’, ‘view’, ‘view.php?id={course_module}’, ‘{folder}’);

return $rules;
}

/**

    Define the restore log rules that will be applied
    by the {@link restore_logs_processor} when restoring
    course logs. It must return one array
    of {@link restore_log_rule} objects
    Note this rules are applied when restoring course logs
    by the restore final task, but are defined here at
    activity level. All them are rules not linked to any module instance (cmid = 0)
    /
    static public function define_restore_log_rules_for_course() {
    $rules = array();

$rules[] = new restore_log_rule(‘hotpot’, ‘view all’, ‘index.php?id={course}’, null);

return $rules;
}

Journal: restore_journal_activity_task.class.php
————————

/** added fix … */

/**

    Define the restore log rules that will be applied
    by the {@link restore_logs_processor} when restoring
    folder logs. It must return one array
    of {@link restore_log_rule} objects

    */
    static public function define_restore_log_rules() {
    $rules = array();

$rules[] = new restore_log_rule(‘journal’, ‘add’, ‘view.php?id={course_module}’, ‘{folder}’);
$rules[] = new restore_log_rule(‘journal’, ‘edit’, ‘edit.php?id={course_module}’, ‘{folder}’);
$rules[] = new restore_log_rule(‘journal’, ‘view’, ‘view.php?id={course_module}’, ‘{folder}’);

return $rules;
}

/**

    Define the restore log rules that will be applied
    by the {@link restore_logs_processor} when restoring
    course logs. It must return one array
    of {@link restore_log_rule} objects
    Note this rules are applied when restoring course logs
    by the restore final task, but are defined here at
    activity level. All them are rules not linked to any module instance (cmid = 0)
    /

static public function define_restore_log_rules_for_course() {
$rules = array();

$rules[] = new restore_log_rule(‘journal’, ‘view all’, ‘index.php?id={course}’, null);

return $rules;
}

It is important that the activity blocks have these functions in place for the restore to work without the need to "uncheck" activity logs so it would work.


Hope this helps. Feel free to contact me for me details.