Moodle

Automated backup misses per quiz question categories

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 1.9.4, 1.9.5
  • Fix Version/s: None
  • Component/s: Backup, Questions, Quiz
  • Labels:
    None
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE

Description

Questions that are only in the context of a specific quiz are not backed up by the automated backup. I've attached a manual backup and automated backup of the same course. Whether the question is in use by the quiz or not doesn't seem to matter. (If the question is in use, then it triggers MDL-16275 when restoring.)

To create this problem, add a quiz to a course and in the quiz. In the question area, choose the default category for the quiz (I believe the default category is the default for the class). Create a new question (type doesn't appear to matter) in this category. Allow the automated backup to run. If you look at moodle.xml in the backup, the question won't be there. If you do a manual backup from within the couse, the question will be backed up properly.

Activity

Hide
Paul Grzesina added a comment -

It appears that backup_scheduled.php was not sending the instances to the module backup functions. The following patch seems to be working for me:

Index: backup/backup_scheduled.php
===================================================================
— backup/backup_scheduled.php (revision 1023)
+++ backup/backup_scheduled.php (working copy)
@@ -423,9 +423,13 @@
$preferences->mods[$mod->modname]->instances = array(); // avoid warnings
}
$preferences->mods[$mod->modname]->instances[$mod->instance]>backup = $preferences>mods[$mod->modname]->backup;
+ // backuplib.php expects userinfo
+ // The modules seem to want userdata
$preferences->mods[$mod->modname]->instances[$mod->instance]>userinfo = $preferences>mods[$mod->modname]->userinfo;
+ $preferences->mods[$mod->modname]->instances[$mod->instance]>userdata = $preferences>mods[$mod->modname]->userinfo;
// there isn't really a nice way to do this...
$preferences->mods[$mod->modname]->instances[$mod->instance]>name = get_field($mod>modname,'name','id',$mod->instance);
+ $preferences->mods[$mod->modname]->instances[$mod->instance]>id = $mod>instance;
}
}
}
@@ -492,6 +496,10 @@
foreach ($allmods as $mod) {
$modname = $mod->name;
$modbackup = $modname."_backup_mods";
+ $instances = null;
+ if (isset($preferences->mods[$modname]->instances)) { + $instances = $preferences->mods[$modname]->instances; + }
//If exists the lib & function
$var = "exists_".$modname;
if (isset($$var) && $$var) { @@ -503,7 +511,7 @@ //Call the check function to show more info $modcheckbackup = $modname."_check_backup_mods"; schedule_backup_log($starttime,$course->id," $modname"); - $modcheckbackup($course->id,$$var,$backup_unique_code); + $modcheckbackup($course->id,$$var,$backup_unique_code,$instances); }
}
}

Show
Paul Grzesina added a comment - It appears that backup_scheduled.php was not sending the instances to the module backup functions. The following patch seems to be working for me: Index: backup/backup_scheduled.php =================================================================== — backup/backup_scheduled.php (revision 1023) +++ backup/backup_scheduled.php (working copy) @@ -423,9 +423,13 @@ $preferences->mods[$mod->modname]->instances = array(); // avoid warnings } $preferences->mods[$mod->modname]->instances[$mod->instance]>backup = $preferences>mods[$mod->modname]->backup; + // backuplib.php expects userinfo + // The modules seem to want userdata $preferences->mods[$mod->modname]->instances[$mod->instance]>userinfo = $preferences>mods[$mod->modname]->userinfo; + $preferences->mods[$mod->modname]->instances[$mod->instance]>userdata = $preferences>mods[$mod->modname]->userinfo; // there isn't really a nice way to do this... $preferences->mods[$mod->modname]->instances[$mod->instance]>name = get_field($mod>modname,'name','id',$mod->instance); + $preferences->mods[$mod->modname]->instances[$mod->instance]>id = $mod>instance; } } } @@ -492,6 +496,10 @@ foreach ($allmods as $mod) { $modname = $mod->name; $modbackup = $modname."_backup_mods"; + $instances = null; + if (isset($preferences->mods[$modname]->instances)) { + $instances = $preferences->mods[$modname]->instances; + } //If exists the lib & function $var = "exists_".$modname; if (isset($$var) && $$var) { @@ -503,7 +511,7 @@ //Call the check function to show more info $modcheckbackup = $modname."_check_backup_mods"; schedule_backup_log($starttime,$course->id," $modname"); - $modcheckbackup($course->id,$$var,$backup_unique_code); + $modcheckbackup($course->id,$$var,$backup_unique_code,$instances); } } }
Hide
John Colvin added a comment -

The instances are not being sent in backup_scheduled.php. This patch should fix that issue.

Show
John Colvin added a comment - The instances are not being sent in backup_scheduled.php. This patch should fix that issue.
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

People

Dates

  • Created:
    Updated:
    Resolved: