From e5d30fdcc975f3149c0bee9eff22509725b60f6e Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Tue, 18 Sep 2007 04:03:02 +0000 Subject: [PATCH] added needsupdate flag into backup/restore, added a new switch for restore on/off for grade histories, fixed some NULL related warnings --- backup/backuplib.php | 3 +++ backup/restore_check.html | 5 ++++- backup/restore_form.html | 16 +++++++++++++++- backup/restorelib.php | 17 ++++++++++------- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/backup/backuplib.php b/backup/backuplib.php index d3534d7e44..a3d89ec880 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -1513,6 +1513,9 @@ fwrite ($bf,full_tag("HIDDEN",5,false,$grade_item->hidden)); fwrite ($bf,full_tag("LOCKED",5,false,$grade_item->locked)); fwrite ($bf,full_tag("LOCKTIME",5,false,$grade_item->locktime)); + fwrite ($bf,full_tag("NEEDSUPDATE",5,false,$grade_item->needsupdate)); + fwrite ($bf,full_tag("TIMECREATED",5,false,$grade_item->timecreated)); + fwrite ($bf,full_tag("TIMEMODIFIED",5,false,$grade_item->timemodified)); // back up the other stuff here // mod grades should only be backed up if selected diff --git a/backup/restore_check.html b/backup/restore_check.html index 0456fd4347..a0f3940060 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -92,9 +92,11 @@ $restore_course_files = required_param('restore_course_files'); //restore_site_files $restore_site_files = required_param('restore_site_files'); + //restore_gradebook_history + $restore_gradebook_history = required_param('restore_gradebook_history'); //restore_messages $restore_messages = required_param('restore_messages'); - + //Check we've selected a course to restore to $course_id = optional_param('course_id', 0, PARAM_INT); @@ -129,6 +131,7 @@ $restore->course_files=$restore_course_files; $restore->site_files=$restore_site_files; $restore->messages=$restore_messages; + $restore->restore_gradebook_history=$restore_gradebook_history; $restore->course_id=$course_id; //add new vars to restore object $restore->course_startdateoffset = $coursestartdatedateoffset; diff --git a/backup/restore_form.html b/backup/restore_form.html index b3e6798835..7a18c3029a 100644 --- a/backup/restore_form.html +++ b/backup/restore_form.html @@ -12,6 +12,8 @@ error( 'course_header object missing from session' ); } + $restore_gradebook_history = optional_param('restore_gradebook_history', 1, PARAM_INT); + //Check that we have all we need //backup_unique_code $backup_unique_code = required_param( 'backup_unique_code' ); @@ -468,7 +470,17 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { echo ""; } echo ""; - + + // do you want grade histories to be restored? + echo ""; + echo ""; + echo get_string ('gradebookhistories', 'grades').":"; + echo ""; + $gradebook_history_options[0] = get_string("no"); + $gradebook_history_options[1] = get_string("yes"); + choose_from_menu($gradebook_history_options, "restore_gradebook_history", $restore_gradebook_history, ""); + echo ""; + //Now print the Messages tr echo ""; echo ""; @@ -487,6 +499,8 @@ function selectItemInCheckboxByName(formId, checkName, checked ) { echo ""; } echo ""; + + } ?> diff --git a/backup/restorelib.php b/backup/restorelib.php index ae6e34054d..0bd2c9c39c 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -1564,7 +1564,7 @@ $dbrec->grademin = backup_todb($info['GRADE_ITEM']['#']['GRADEMIN']['0']['#']); /// needs to be restored first - if ($info['GRADE_ITEM']['#']['SCALEID']['0']['#']) { + if (backup_todb($info['GRADE_ITEM']['#']['SCALEID']['0']['#'])) { $scale = backup_getid($restore->backup_unique_code,"scale",backup_todb($info['GRADE_ITEM']['#']['SCALEID']['0']['#'])); $dbrec->scaleid = $scale->new_id; } @@ -1578,6 +1578,9 @@ $dbrec->hidden = backup_todb($info['GRADE_ITEM']['#']['HIDDEN']['0']['#']); $dbrec->locked = backup_todb($info['GRADE_ITEM']['#']['LOCKED']['0']['#']); $dbrec->locktime = backup_todb($info['GRADE_ITEM']['#']['LOCKTIME']['0']['#']); + $dbrec->needsupdate = backup_todb($info['GRADE_ITEM']['#']['NEEDSUPDATE']['0']['#']); + $dbrec->timecreated = backup_todb($info['GRADE_ITEM']['#']['TIMECREATED']['0']['#']); + $dbrec->timemodified = backup_todb($info['GRADE_ITEM']['#']['TIMEMODIFIED']['0']['#']); // get the current sortorder, add 1 to it and use that if ($lastitem = get_record_sql("SELECT sortorder, id FROM {$CFG->prefix}grade_items @@ -1622,7 +1625,7 @@ $grade->rawgrademax = backup_todb($ite_info['#']['RAWGRADEMAX']['0']['#']); $grade->rawgrademin = backup_todb($ite_info['#']['RAWGRADEMIN']['0']['#']); // need to find scaleid - if ($ite_info['#']['RAWSCALEID']['0']['#']) { + if (backup_todb($ite_info['#']['RAWSCALEID']['0']['#'])) { $scale = backup_getid($restore->backup_unique_code,"scale",backup_todb($ite_info['#']['RAWSCALEID']['0']['#'])); $grade->rawscaleid = $scale->new_id; } @@ -1696,7 +1699,7 @@ } // process histories - if ($gchcount && $continue && !isset($SESSION->restore->importing)) { + if ($gchcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) { if (!defined('RESTORE_SILENTLY')) { echo '
  • '.get_string('gradecategoryhistory','grades').'
  • '; } @@ -1789,7 +1792,7 @@ } // process histories - if ($gghcount && $continue && !isset($SESSION->restore->importing)) { + if ($gghcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) { if (!defined('RESTORE_SILENTLY')) { echo '
  • '.get_string('gradegradeshistory','grades').'
  • '; } @@ -1870,7 +1873,7 @@ // process histories - if ($ggthcount && $continue && !isset($SESSION->restore->importing)) { + if ($ggthcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) { if (!defined('RESTORE_SILENTLY')) { echo '
  • '.get_string('gradegradestexthistory','grades').'
  • '; } @@ -1944,7 +1947,7 @@ } // process histories - if ($gihcount && $continue && !isset($SESSION->restore->importing)) { + if ($gihcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) { if (!defined('RESTORE_SILENTLY')) { echo '
  • '.get_string('gradeitemshistory','grades').'
  • '; } @@ -2083,7 +2086,7 @@ } // process histories - if ($gohcount && $continue && !isset($SESSION->restore->importing)) { + if ($gohcount && $continue && !isset($SESSION->restore->importing) && $restore->restore_gradebook_history) { if (!defined('RESTORE_SILENTLY')) { echo '
  • '.get_string('gradeoutcomeshistory','grades').'
  • '; } -- 2.39.5