Apply modularity to the creation of the log file during restore to a new course.

Remove the responsibility for loging the application of the course start date offset, from activity modules to the backup module.
Merged from stable branch
This commit is contained in:
thompson697 2006-10-17 10:05:41 +00:00
parent 352b8da86a
commit cf0b1faded
17 changed files with 150 additions and 293 deletions

View file

@ -34,10 +34,10 @@
if ($data) {
//Now get completed xmlized object
$info = $data->info;
//First, check the course_id backup folder exists in CFG->dataroot
$dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
$restorelog_file = fopen("$dest_dir/restorelog.html","a");
//if necessary, write to restorelog and adjust date/time fields
if ($restore->course_startdateoffset) {
restore_log_date_changes('Journal', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
}
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@ -50,12 +50,6 @@
$journal->days = backup_todb($info['MOD']['#']['DAYS']['0']['#']);
$journal->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$journal->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$date = usergetdate($journal->timemodified);
fwrite ($restorelog_file,"<br>The Journal - ".$journal->name." <br>");
fwrite ($restorelog_file,"The Journal TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$journal->timemodified += $restore->course_startdateoffset;
$date = usergetdate($journal->timemodified);
fwrite ($restorelog_file,"&nbsp;&nbsp;&nbsp;the Journal TTIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
//We have to recode the assessed field if it is <0 (scale)
if ($journal->assessed < 0) {
@ -103,10 +97,7 @@
//Get the entries array
$entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY'];
//First, check the course_id backup folder exists in CFG->dataroot
$dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
check_dir_exists($dest_dir,true);
$restorelog_file = fopen("$dest_dir/restorelog.html","a");
//Iterate over entries
for($i = 0; $i < sizeof($entries); $i++) {
$entry_info = $entries[$i];
@ -114,19 +105,15 @@
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
//We'll need this later!!
$oldid = backup_todb($sub_info['#']['ID']['0']['#']);
$olduserid = backup_todb($sub_info['#']['USERID']['0']['#']);
//We'll need this later!! $sub_info changed to $entry_info
$oldid = backup_todb($entry_info['#']['ID']['0']['#']);
$olduserid = backup_todb($entry_info['#']['USERID']['0']['#']);
//Now, build the JOURNAL_ENTRIES record structure
$entry->journal = $new_journal_id;
$entry->userid = backup_todb($entry_info['#']['USERID']['0']['#']);
$entry->userid = backup_todb($entry_info['#']['USERID']['0']['#']);
$entry->modified = backup_todb($entry_info['#']['MODIFIED']['0']['#']);
$date = usergetdate($entry->modified);
fwrite ($restorelog_file,"The Entry -".$entry->journal."- MODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$entry->modified += $restore->course_startdateoffset;
$date = usergetdate($entry->modified);
fwrite ($restorelog_file,"&nbsp;&nbsp;&nbsp;the Entry MODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$entry->text = backup_todb($entry_info['#']['TEXT']['0']['#']);
$entry->format = backup_todb($entry_info['#']['FORMAT']['0']['#']);
$entry->rating = backup_todb($entry_info['#']['RATING']['0']['#']);
@ -137,11 +124,7 @@
}
$entry->teacher = backup_todb($entry_info['#']['TEACHER']['0']['#']);
$entry->timemarked = backup_todb($entry_info['#']['TIMEMARKED']['0']['#']);
$date = usergetdate($entry->timemarked);
fwrite ($restorelog_file,"The Entry -".$entry->journal."- TIMEMARKED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
$entry->timemarked += $restore->course_startdateoffset;
$date = usergetdate($entry->timemarked);
fwrite ($restorelog_file,"&nbsp;&nbsp;&nbsp;the Entry TIMEMARKED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$entry->mailed = backup_todb($entry_info['#']['MAILED']['0']['#']);
//We have to recode the userid field