Skip to content
Browse files

added backup/restore compatibility for Moodle 1.5 (and earlier)

  • Loading branch information...
1 parent 3e42156 commit ea2cf995996eaab76eaaa454fcf7225fb5afe45b gbateson committed Jan 25, 2006
Showing with 26 additions and 5 deletions.
  1. +18 −4 mod/hotpot/backuplib.php
  2. +8 −1 mod/hotpot/restorelib.php
View
22 mod/hotpot/backuplib.php
@@ -44,15 +44,22 @@ function hotpot_backup_mods($bf, $preferences) {
$hotpots = get_records ("hotpot","course",$preferences->backup_course,"id");
if ($hotpots) {
foreach ($hotpots as $hotpot) {
- if (backup_mod_selected($preferences,'hotpot',$hotpot->id)) {
- $status = hotpot_backup_one_mod($bf,$preferences,$hotpot->id);
+ if (function_exists('backup_mod_selected')) {
+ // Moodle >= 1.6
+ $backup_mod_selected = backup_mod_selected($preferences, 'hotpot', $hotpot->id);
+ } else {
+ // Moodle <= 1.5
+ $backup_mod_selected = true;
+ }
+ if ($backup_mod_selected) {
+ $status = hotpot_backup_one_mod($bf, $preferences, $hotpot->id);
}
}
}
return $status;
}
- function hotpot_backup_one_mod($bf, $preferences, $instance = 0) {
+ function hotpot_backup_one_mod($bf, $preferences, $instance=0) {
// $bf : resource id for b(ackup) f(ile)
// $preferences : object containing switches and settings for this backup
$level = 3;
@@ -65,7 +72,14 @@ function hotpot_backup_one_mod($bf, $preferences, $instance = 0) {
$record_tags = array('MODTYPE'=>'hotpot');
$excluded_tags = array();
$more_backup = '';
- if (backup_userdata_selected($preferences,'hotpot',$instance)) {
+ if (function_exists('backup_userdata_selected')) {
+ // Moodle >= 1.6
+ $backup_userdata_selected = backup_userdata_selected($preferences, 'hotpot', $instance);
+ } else {
+ // Moodle <= 1.5
+ $backup_userdata_selected = $preferences->mods['hotpot']->userinfo;
+ }
+ if ($backup_userdata_selected) {
$more_backup .= '$GLOBALS["hotpot_backup_string_ids"] = array();';
$more_backup .= '$status = hotpot_backup_attempts($bf, $record, $level, $status);';
$more_backup .= '$status = hotpot_backup_questions($bf, $record, $level, $status);';
View
9 mod/hotpot/restorelib.php
@@ -80,7 +80,14 @@ function hotpot_restore_mods($mod, $restore) {
$more_restore .= 'print "<li>".get_string("modulename", "hotpot")." &quot;".$record->name."&quot;</li>";';
}
$more_restore .= 'backup_flush(300);';
- if (restore_userdata_selected($restore,'hotpot',$mod->id)) {
+ if (function_exists('restore_userdata_selected')) {
+ // Moodle >= 1.6
+ $restore_userdata_selected = restore_userdata_selected($restore, 'hotpot', $mod->id);
+ } else {
+ // Moodle <= 1.5
+ $restore_userdata_selected = $restore->mods['hotpot']->userinfo;
+ }
+ if ($restore_userdata_selected) {
if (isset($xml["STRING_DATA"]) && isset($xml["QUESTION_DATA"])) {
// HotPot v2.1+
$more_restore .= '$status = hotpot_restore_strings($restore, $status, $xml, $record);';

0 comments on commit ea2cf99

Please sign in to comment.
Something went wrong with that request. Please try again.