From: thompson697 Date: Wed, 13 Sep 2006 13:19:39 +0000 (+0000) Subject: Complete work on Roll Forwards - Restore from previous semester (MDL-5532) X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=163ff97e84e8718b02d324bb5f32cd09ab37f808;p=moodle.git Complete work on Roll Forwards - Restore from previous semester (MDL-5532) * Add fields to restore form to enable changes to Short Name, Full Name and Start Date * Start Date offset added to Restore process * Created Restorelog file in Course files area * Activity Modules use offset to change dates * Activity Modules write changes to Restorelog --- diff --git a/.project b/.project new file mode 100644 index 0000000000..ef2de094cf --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + moodle17devw + + + + + + + + diff --git a/backup/restore_check.html b/backup/restore_check.html index 3661d1dbb5..1f75e280e4 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -19,10 +19,10 @@ if ($form1 = data_submitted()); { $currentcourseshortname = $course_header->course_shortname; //"store_ShortName"; - $course_header->course_shortname = $form1->shortname; //"update_ShortName"; - $course_header->course_fullname = $form1->fullname; //"update_FullName"; + $course_header->course_shortname = $form1->shortname; //"update_ShortName"; + $course_header->course_fullname = $form1->fullname; //"update_FullName"; $form1->startdate = make_timestamp($form1->startyear, $form1->startmonth, $form1->startday); - $currentcoursestartdate = $course_header->course_startdate; + $currentcoursestartdate = $course_header->course_startdate; $coursestartdatedateoffset = $form1->startdate - $currentcoursestartdate; $restore->course_startdateoffset = $coursestartdatedateoffset; //change to restore } @@ -116,7 +116,7 @@ $restore->course_files=$restore_course_files; $restore->messages=$restore_messages; $restore->course_id=$course_id; -//add new vars to restore object + //add new vars to restore object $restore->course_startdateoffset = $coursestartdatedateoffset; $restore->course_shortname = $currentcourseshortname; diff --git a/mod/assignment/restorelib.php b/mod/assignment/restorelib.php index ee255e0ec1..a60f324926 100644 --- a/mod/assignment/restorelib.php +++ b/mod/assignment/restorelib.php @@ -33,7 +33,12 @@ if ($data) { //Now get completed xmlized object - $info = $data->info; + $info = $data->info; + //First, we check to "course_id" exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -55,7 +60,18 @@ $assignment->assignmenttype = backup_todb($info['MOD']['#']['ASSIGNMENTTYPE']['0']['#']); $assignment->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); $assignment->timedue = backup_todb($info['MOD']['#']['TIMEDUE']['0']['#']); + $date = usergetdate($assignment->timedue); + fwrite ($restorelog_file,"
The Assignment - ".$assignment->name."
"); + fwrite ($restorelog_file,"The TIMEDUE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $assignment->timedue += $restore->course_startdateoffset; + $date = usergetdate($assignment->timedue); + fwrite ($restorelog_file,"   the TIMEDUE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $assignment->timeavailable = backup_todb($info['MOD']['#']['TIMEAVAILABLE']['0']['#']); + $date = usergetdate($assignment->timeavailable); + fwrite ($restorelog_file,"The TIMEAVAILABLE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $assignment->timeavailable += $restore->course_startdateoffset; + $date = usergetdate($assignment->timeavailable); + fwrite ($restorelog_file,"   the TIMEAVAILABLE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $assignment->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']); $assignment->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); diff --git a/mod/chat/restorelib.php b/mod/chat/restorelib.php index dddf7fec5a..40669b0a87 100644 --- a/mod/chat/restorelib.php +++ b/mod/chat/restorelib.php @@ -33,7 +33,12 @@ if ($data) { //Now get completed xmlized object - $info = $data->info; + $info = $data->info; + //First, we check to "course_id" exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -46,6 +51,12 @@ $chat->studentlogs = backup_todb($info['MOD']['#']['STUDENTLOGS']['0']['#']); $chat->schedule = backup_todb($info['MOD']['#']['SCHEDULE']['0']['#']); $chat->chattime = backup_todb($info['MOD']['#']['CHATTIME']['0']['#']); + $date = usergetdate($chat->chattime); + fwrite ($restorelog_file,"The Chat - ".$chat->name."
"); + fwrite ($restorelog_file,"The CHATTIME was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $chat->chattime += $restore->course_startdateoffset; + $date = usergetdate($chat->chattime); + fwrite ($restorelog_file,"   the CHATTIME is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."

"); $chat->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); //The structure is equal to the db, so insert the chat diff --git a/mod/choice/restorelib.php b/mod/choice/restorelib.php index 83ab0461e7..c9be13e200 100644 --- a/mod/choice/restorelib.php +++ b/mod/choice/restorelib.php @@ -39,6 +39,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -53,9 +58,20 @@ $choice->display = backup_todb($info['MOD']['#']['DISPLAY']['0']['#']); $choice->allowupdate = backup_todb($info['MOD']['#']['ALLOWUPDATE']['0']['#']); $choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']); - $choice->limitanswers = backup_todb($info['MOD']['#']['LIMITANSWERS']['0']['#']); + $choice->limitanswers = backup_todb($info['MOD']['#']['LIMITANSWERS']['0']['#']); $choice->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']); + $date = usergetdate($choice->timeopen); + fwrite ($restorelog_file,"
The Choice - ".$choice->name."
"); + fwrite ($restorelog_file,"The TIMEOPEN was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $choice->timeopen += $restore->course_startdateoffset; + $date = usergetdate($choice->timeopen); + fwrite ($restorelog_file,"   The TIMEOPEN is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $choice->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']); + $date = usergetdate($choice->timeclose); + fwrite ($restorelog_file,"The TIMECLOSE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $choice->timeclose += $restore->course_startdateoffset; + $date = usergetdate($choice->timeclose); + fwrite ($restorelog_file,"   the TIMECLOSE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $choice->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); //To mantain compatibilty, in 1.4 the publish setting meaning has changed. We diff --git a/mod/data/restorelib.php b/mod/data/restorelib.php index 080e8dca6b..4a830a3f73 100644 --- a/mod/data/restorelib.php +++ b/mod/data/restorelib.php @@ -46,7 +46,12 @@ function data_restore_mods($mod,$restore) { if ($data) { //Now get completed xmlized object - $info = $data->info; + $info = $data->info; + //First, we check to "course_id" exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -58,9 +63,30 @@ function data_restore_mods($mod,$restore) { $database->ratings = backup_todb($info['MOD']['#']['RATINGS']['0']['#']); $database->comments = backup_todb($info['MOD']['#']['COMMENTS']['0']['#']); $database->timeavailablefrom = backup_todb($info['MOD']['#']['TIMEAVAILABLEFROM']['0']['#']); + $date = usergetdate($database->timeavailablefrom); + fwrite ($restorelog_file,"
The Database - ".$database->name."
"); + fwrite ($restorelog_file,"The TIMEAVAILABLEFROM was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $database->timeavailablefrom += $restore->course_startdateoffset; + $date = usergetdate($database->timeavailablefrom); + fwrite ($restorelog_file,"   the TTIMEAVAILABLEFROM is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $database->timeavailableto = backup_todb($info['MOD']['#']['TIMEAVAILABLETO']['0']['#']); + $date = usergetdate($database->timeavailableto); + fwrite ($restorelog_file,"The TIMEAVAILABLETO was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $database->timeavailableto += $restore->course_startdateoffset; + $date = usergetdate($database->timeavailableto); + fwrite ($restorelog_file,"   the TIMEAVAILABLETO is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $database->timeviewfrom = backup_todb($info['MOD']['#']['TIMEVIEWFROM']['0']['#']); + $date = usergetdate($database->timeviewfrom); + fwrite ($restorelog_file,"The TIMEVIEWFROM was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $database->timeviewfrom += $restore->course_startdateoffset; + $date = usergetdate($database->timeviewfrom); + fwrite ($restorelog_file,"   the TIMEVIEWFROM is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $database->timeviewto = backup_todb($info['MOD']['#']['TIMEVIEWTO']['0']['#']); + $date = usergetdate($database->timeviewto); + fwrite ($restorelog_file,"The TIMEVIEWTO was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $database->timeviewto += $restore->course_startdateoffset; + $date = usergetdate($database->timeviewto); + fwrite ($restorelog_file,"   the TIMEVIEWTO is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $database->participants = backup_todb($info['MOD']['#']['PARTICIPANTS']['0']['#']); $database->requiredentries = backup_todb($info['MOD']['#']['REQUIREDENTRIES']['0']['#']); $database->requiredentriestoview = backup_todb($info['MOD']['#']['REQUIREDENTRIESTOVIEW']['0']['#']); diff --git a/mod/exercise/restorelib.php b/mod/exercise/restorelib.php index f5169415ff..4ea561ffe5 100644 --- a/mod/exercise/restorelib.php +++ b/mod/exercise/restorelib.php @@ -48,7 +48,12 @@ if ($data) { //Now get completed xmlized object - $info = $data->info; + $info = $data->info; + //First, we check to "course_id" exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -62,8 +67,14 @@ $exercise->usemaximum = backup_todb($info['MOD']['#']['USEMAXIMUM']['0']['#']); $exercise->assessmentcomps = backup_todb($info['MOD']['#']['ASSESSMENTCOMPS']['0']['#']); $exercise->anonymous = backup_todb($info['MOD']['#']['ANONYMOUS']['0']['#']); - $exercise->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); + $exercise->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); $exercise->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']); + $date = usergetdate($exercise->deadline); + fwrite ($restorelog_file,"
The Exercise - ".$exercise->name."
"); + fwrite ($restorelog_file,"The DEADLINE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $exercise->deadline += $restore->course_startdateoffset; + $date = usergetdate($exercise->deadline); + fwrite ($restorelog_file,"   the DEADLINE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $exercise->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); $exercise->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']); $exercise->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']); diff --git a/mod/forum/restorelib.php b/mod/forum/restorelib.php index b1a4e6f865..c37309c4a9 100644 --- a/mod/forum/restorelib.php +++ b/mod/forum/restorelib.php @@ -44,6 +44,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -65,9 +70,20 @@ $forum->assesspublic = backup_todb($info['MOD']['#']['ASSESSPUBLIC']['0']['#']); } - $forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']); + $forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']); $forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']); + $date = usergetdate($forum->assesstimestart); + fwrite ($restorelog_file,"
The Forum - ".$forum->name."
"); + fwrite ($restorelog_file,"The ASSESSTIMESTART was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $forum->assesstimestart += $restore->course_startdateoffset; + $date = usergetdate($forum->assesstimestart); + fwrite ($restorelog_file,"   the ASSESSTIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $forum->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']); + $date = usergetdate($forum->assesstimefinish); + fwrite ($restorelog_file,"The ASSESSTIMEFINISH was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $forum->assesstimefinish += $restore->course_startdateoffset; + $date = usergetdate($forum->assesstimefinish); + fwrite ($restorelog_file,"   the ASSESSTIMEFINISH is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); $forum->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']); $forum->forcesubscribe = backup_todb($info['MOD']['#']['FORCESUBSCRIBE']['0']['#']); @@ -250,7 +266,11 @@ //Get the discussions array $discussions = $info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION']; - + //First, we check that "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //Iterate over discussions for($i = 0; $i < sizeof($discussions); $i++) { $dis_info = $discussions[$i]; @@ -271,10 +291,17 @@ $discussion->groupid = backup_todb($dis_info['#']['GROUPID']['0']['#']); $discussion->assessed = backup_todb($dis_info['#']['ASSESSED']['0']['#']); $discussion->timemodified = backup_todb($dis_info['#']['TIMEMODIFIED']['0']['#']); - $discussion->usermodified = backup_todb($dis_info['#']['USERMODIFIED']['0']['#']); + $date = usergetdate($discussion->timemodified); + fwrite ($restorelog_file,"
The Discussion - ".$discussion->name."
"); + fwrite ($restorelog_file,"The Discussion TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $discussion->timemodified += $restore->course_startdateoffset; + $date = usergetdate($discussion->timemodified); + fwrite ($restorelog_file,"   the Discussion TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); + $discussion->usermodified = backup_todb($dis_info['#']['USERMODIFIED']['0']['#']); $discussion->timestart = backup_todb($dis_info['#']['TIMESTART']['0']['#']); + $discussion->timestart += $restore->course_startdateoffset; $discussion->timeend = backup_todb($dis_info['#']['TIMEEND']['0']['#']); - + $discussion->timeend += $restore->course_startdateoffset; //We have to recode the userid field $user = backup_getid($restore->backup_unique_code,"user",$discussion->userid); if ($user) { @@ -453,9 +480,11 @@ //Now, build the FORUM_POSTS record structure $post->discussion = $discussion_id; $post->parent = backup_todb($pos_info['#']['PARENT']['0']['#']); - $post->userid = backup_todb($pos_info['#']['USERID']['0']['#']); + $post->userid = backup_todb($pos_info['#']['USERID']['0']['#']); $post->created = backup_todb($pos_info['#']['CREATED']['0']['#']); + $post->created += $restore->course_startdateoffset; $post->modified = backup_todb($pos_info['#']['MODIFIED']['0']['#']); + $post->modified += $restore->course_startdateoffset; $post->mailed = backup_todb($pos_info['#']['MAILED']['0']['#']); $post->subject = backup_todb($pos_info['#']['SUBJECT']['0']['#']); $post->message = backup_todb($pos_info['#']['MESSAGE']['0']['#']); diff --git a/mod/glossary/restorelib.php b/mod/glossary/restorelib.php index a3b58fe185..d234e5c57a 100644 --- a/mod/glossary/restorelib.php +++ b/mod/glossary/restorelib.php @@ -41,6 +41,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -70,7 +75,18 @@ $glossary->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']); $glossary->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']); + $date = usergetdate($glossary->assesstimestart); + fwrite ($restorelog_file,"
The Glossary - ".$glossary->name."
"); + fwrite ($restorelog_file,"The Glossary ASSESSTIMESTART was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $glossary->assesstimestart += $restore->course_startdateoffset; + $date = usergetdate($glossary->assesstimestart); + fwrite ($restorelog_file,"   the Glossary ASSESSTIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $glossary->assesstimefinish = backup_todb($info['MOD']['#']['ASSESSTIMEFINISH']['0']['#']); + $date = usergetdate($glossary->assesstimefinish); + fwrite ($restorelog_file,"The Glossary ASSESSTIMEFINISH was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $glossary->assesstimefinish += $restore->course_startdateoffset; + $date = usergetdate($glossary->assesstimefinish); + fwrite ($restorelog_file,"   the Glossary ASSESSTIMEFINISH is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $glossary->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']); //We have to recode the scale field if it's <0 (positive is a grade, not a scale) diff --git a/mod/hotpot/restorelib.php b/mod/hotpot/restorelib.php index a702fe4cb4..d975a30b4c 100644 --- a/mod/hotpot/restorelib.php +++ b/mod/hotpot/restorelib.php @@ -290,11 +290,16 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, // maintain a cache of info on table columns static $table_columns = array(); + global $CFG, $db; //move outside if - increase scope if (empty($table_columns[$table])) { - global $CFG, $db; $table_columns[$table] = $db->MetaColumns("$CFG->prefix$table"); } - + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + //global $CFG; + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); // get values for fields in this record $record = new stdClass(); $TAGS = array_keys($xml); @@ -302,6 +307,14 @@ function hotpot_restore_record(&$restore, $status, &$xml, $table, $foreign_keys, $value = $xml[$TAG][0]['#']; if (is_string($value)) { $tag = strtolower($TAG); + if ($TAG == "TIMEOPEN" || $TAG == "TIMECLOSE" || $TAG == "TIMECREATED" ||$TAG == "TIMEMODIFIED"){ + $date = usergetdate($value); + fwrite ($restorelog_file,"
The Hotpot - ".$record->name."
"); + fwrite ($restorelog_file,"The date was ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $value += $restore->course_startdateoffset; + $date = usergetdate($value); + fwrite ($restorelog_file,"   the date is now ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); + } $record->$tag = backup_todb($value); } } diff --git a/mod/journal/restorelib.php b/mod/journal/restorelib.php index 2ac8a5ad73..da1a426194 100644 --- a/mod/journal/restorelib.php +++ b/mod/journal/restorelib.php @@ -34,6 +34,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -46,6 +51,12 @@ $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,"
The Journal - ".$journal->name."
"); + 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,"   the Journal TTIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); //We have to recode the assessed field if it is <0 (scale) if ($journal->assessed < 0) { @@ -93,7 +104,11 @@ //Get the entries array $entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY']; - + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //Iterate over entries for($i = 0; $i < sizeof($entries); $i++) { $entry_info = $entries[$i]; @@ -107,14 +122,24 @@ //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,"   the Entry MODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $entry->text = backup_todb($entry_info['#']['TEXT']['0']['#']); $entry->format = backup_todb($entry_info['#']['FORMAT']['0']['#']); $entry->rating = backup_todb($entry_info['#']['RATING']['0']['#']); $entry->comment = backup_todb($entry_info['#']['COMMENT']['0']['#']); $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,"   the Entry TIMEMARKED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $entry->mailed = backup_todb($entry_info['#']['MAILED']['0']['#']); //We have to recode the userid field diff --git a/mod/lesson/restorelib.php b/mod/lesson/restorelib.php index 89adcb3652..6ed6137de7 100644 --- a/mod/lesson/restorelib.php +++ b/mod/lesson/restorelib.php @@ -47,6 +47,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -86,9 +91,20 @@ $lesson->displayleftif = backup_todb($info['MOD']['#']['DISPLAYLEFTIF']['0']['#']); $lesson->progressbar = backup_todb($info['MOD']['#']['PROGRESSBAR']['0']['#']); $lesson->highscores = backup_todb($info['MOD']['#']['SHOWHIGHSCORES']['0']['#']); - $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']); + $lesson->maxhighscores = backup_todb($info['MOD']['#']['MAXHIGHSCORES']['0']['#']); $lesson->available = backup_todb($info['MOD']['#']['AVAILABLE']['0']['#']); + $date = usergetdate($lesson->available); + fwrite ($restorelog_file,"
The Lesson - ".$lesson->name."
"); + fwrite ($restorelog_file,"The Time AVAILABLE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $lesson->available += $restore->course_startdateoffset; + $date = usergetdate($lesson->available); + fwrite ($restorelog_file,"   the Time AVAILABLE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $lesson->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']); + $date = usergetdate($lesson->deadline); + fwrite ($restorelog_file,"The DEADLINE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $lesson->deadline += $restore->course_startdateoffset; + $date = usergetdate($lesson->deadline); + fwrite ($restorelog_file,"   the DEADLINE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $lesson->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); //The structure is equal to the db, so insert the lesson diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index f1b666d553..fb44a86661 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -54,6 +54,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -62,9 +67,20 @@ $quiz = new stdClass; $quiz->course = $restore->course_id; $quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); - $quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']); + $quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']); $quiz->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']); + $date = usergetdate($quiz->timeopen); + fwrite ($restorelog_file,"
The Quiz - ".$quiz->name."
"); + fwrite ($restorelog_file,"The TIMEOPEN was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $quiz->timeopen += $restore->course_startdateoffset; + $date = usergetdate($quiz->timeopen); + fwrite ($restorelog_file,"   the TIMEOPEN is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $quiz->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']); + $date = usergetdate($quiz->timeclose); + fwrite ($restorelog_file,"The TIMECLOSE was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $quiz->timeclose += $restore->course_startdateoffset; + $date = usergetdate($quiz->timeclose); + fwrite ($restorelog_file,"   the TIMECLOSE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."

"); $quiz->optionflags = backup_todb($info['MOD']['#']['OPTIONFLAGS']['0']['#']); $quiz->penaltyscheme = backup_todb($info['MOD']['#']['PENALTYSCHEME']['0']['#']); $quiz->attempts = backup_todb($info['MOD']['#']['ATTEMPTS_NUMBER']['0']['#']); diff --git a/mod/quiz/restorelibpre15.php b/mod/quiz/restorelibpre15.php index 823d1d2165..214db9b5b7 100644 --- a/mod/quiz/restorelibpre15.php +++ b/mod/quiz/restorelibpre15.php @@ -1226,6 +1226,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -1235,7 +1240,18 @@ $quiz->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); $quiz->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']); $quiz->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']); + $date = usergetdate($quiz->timeopen); + fwrite ($restorelog_file,"The Quiz Named - ".$quiz->name."
"); + fwrite ($restorelog_file,"The Original Time Open was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $quiz->timeopen += $restore->course_startdateoffset; + $date = usergetdate($quiz->timeopen); + fwrite ($restorelog_file,"   Time Open is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $quiz->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']); + $date = usergetdate($quiz->timeclose); + fwrite ($restorelog_file,"The Original Time Close was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $quiz->timeclose += $restore->course_startdateoffset; + $date = usergetdate($quiz->timeclose); + fwrite ($restorelog_file,"   Time Close is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."

"); $quiz->attempts = backup_todb($info['MOD']['#']['ATTEMPTS_NUMBER']['0']['#']); $quiz->attemptonlast = backup_todb($info['MOD']['#']['ATTEMPTONLAST']['0']['#']); $quiz->feedback = backup_todb($info['MOD']['#']['FEEDBACK']['0']['#']); diff --git a/mod/wiki/restorelib.php b/mod/wiki/restorelib.php index 8a016b0e59..3e9c753d73 100644 --- a/mod/wiki/restorelib.php +++ b/mod/wiki/restorelib.php @@ -34,6 +34,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -54,6 +59,12 @@ $wiki->revertchanges = backup_todb($info['MOD']['#']['REVERTCHANGES']['0']['#']); $wiki->initialcontent = backup_todb($info['MOD']['#']['INITIALCONTENT']['0']['#']); $wiki->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']); + $date = usergetdate($wiki->timemodified); + fwrite ($restorelog_file,"The Wiki - ".$wiki->name."
"); + $status = fwrite ($restorelog_file,"The Wiki TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $wiki->timemodified += $restore->course_startdateoffset; + $date = usergetdate($wiki->timemodified); + fwrite ($restorelog_file,"   the Wiki TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); //The structure is equal to the db, so insert the wiki $newid = insert_record ("wiki",$wiki); @@ -92,7 +103,11 @@ //Get the entries array $entries = $info['MOD']['#']['ENTRIES']['0']['#']['ENTRY']; - + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //Iterate over entries for($i = 0; $i < sizeof($entries); $i++) { $ent_info = $entries[$i]; @@ -110,7 +125,11 @@ $entry->groupid = backup_todb($ent_info['#']['GROUPID']['0']['#']); $entry->pagename = backup_todb($ent_info['#']['PAGENAME']['0']['#']); $entry->timemodified = backup_todb($ent_info['#']['TIMEMODIFIED']['0']['#']); - + $date = usergetdate($entry->timemodified); + fwrite ($restorelog_file,"The Entry TIMEMODIFIED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $entry->timemodified += $restore->course_startdateoffset; + $date = usergetdate($entry->timemodified); + fwrite ($restorelog_file,"   The Entry TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."

"); //We have to recode the userid field $user = backup_getid($restore->backup_unique_code,"user",$entry->userid); if ($user) { @@ -181,7 +200,9 @@ $page->author = backup_todb($pag_info['#']['AUTHOR']['0']['#']); $page->userid = backup_todb($pag_info['#']['USERID']['0']['#']); $page->created = backup_todb($pag_info['#']['CREATED']['0']['#']); + $page->created += $restore->course_startdateoffset; $page->lastmodified = backup_todb($pag_info['#']['LASTMODIFIED']['0']['#']); + $page->lastmodified += $restore->course_startdateoffset; $page->refs = str_replace("$@LINEFEED@$","\n",backup_todb($pag_info['#']['REFS']['0']['#'])); $page->meta = backup_todb($pag_info['#']['META']['0']['#']); $page->hits = backup_todb($pag_info['#']['HITS']['0']['#']); diff --git a/mod/workshop/restorelib.php b/mod/workshop/restorelib.php index 1bd107e83a..1258529fb8 100644 --- a/mod/workshop/restorelib.php +++ b/mod/workshop/restorelib.php @@ -48,6 +48,11 @@ if ($data) { //Now get completed xmlized object $info = $data->info; + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //traverse_xmlize($info); //Debug //print_object ($GLOBALS['traverse_array']); //Debug //$GLOBALS['traverse_array']=""; //Debug @@ -69,11 +74,37 @@ $workshop->includeself = backup_todb($info['MOD']['#']['INCLUDESELF']['0']['#']); $workshop->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']); $workshop->submissionstart = backup_todb($info['MOD']['#']['SUBMISSIONSTART']['0']['#']); + $date = usergetdate($workshop->submissionstart); + fwrite ($restorelog_file,"
The Workshop - ".$workshop->name."
"); + fwrite ($restorelog_file,"The SUBMISSIONSTART time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $workshop->submissionstart += $restore->course_startdateoffset; + $date = usergetdate($workshop->submissionstart); + fwrite ($restorelog_file,"   the SUBMISSIONSTART time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $workshop->assessmentstart = backup_todb($info['MOD']['#']['ASSESSMENTSTART']['0']['#']); + $date = usergetdate($workshop->assessmentstart); + fwrite ($restorelog_file,"The ASSESSMENTSTART time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $workshop->assessmentstart += $restore->course_startdateoffset; + $date = usergetdate($workshop->assessmentstart); + fwrite ($restorelog_file,"   the ASSESSMENTSTART time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $workshop->deadline = backup_todb($info['MOD']['#']['DEADLINE']['0']['#']); $workshop->submissionend = backup_todb($info['MOD']['#']['SUBMISSIONEND']['0']['#']); + $date = usergetdate($workshop->submissionend); + fwrite ($restorelog_file,"The SUBMISSIONEND time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $workshop->submissionend += $restore->course_startdateoffset; + $date = usergetdate($workshop->submissionend); + fwrite ($restorelog_file,"   the SUBMISSIONEND time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $workshop->assessmentend = backup_todb($info['MOD']['#']['ASSESSMENTEND']['0']['#']); + $date = usergetdate($workshop->assessmentend); + fwrite ($restorelog_file,"The ASSESSMENTEND time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $workshop->assessmentend += $restore->course_startdateoffset; + $date = usergetdate($workshop->assessmentend); + fwrite ($restorelog_file,"   the ASSESSMENTEND time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $workshop->releasegrades = backup_todb($info['MOD']['#']['RELEASEGRADES']['0']['#']); + $date = usergetdate($workshop->releasegrades); + fwrite ($restorelog_file,"The RELEASEGRADES time was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $workshop->releasegrades += $restore->course_startdateoffset; + $date = usergetdate($workshop->releasegrades); + fwrite ($restorelog_file,"   the RELEASEGRADES time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $workshop->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']); $workshop->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']); $workshop->ntassessments = backup_todb($info['MOD']['#']['NTASSESSMENTS']['0']['#']); @@ -321,7 +352,11 @@ //Get the submissions array $submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION']; - + //First, we check to "course_id" folder exists and create is as necessary in CFG->dataroot + $dest_dir = $CFG->dataroot."/".$restore->course_id; + check_dir_exists($dest_dir,true); + $file = $dest_dir."/restorelog.html"; + $restorelog_file = fopen($file,"a"); //Iterate over submissions for($i = 0; $i < sizeof($submissions); $i++) { $sub_info = $submissions[$i]; @@ -336,8 +371,13 @@ //Now, build the WORKSHOP_SUBMISSIONS record structure $submission->workshopid = $new_workshop_id; $submission->userid = backup_todb($sub_info['#']['USERID']['0']['#']); - $submission->title = backup_todb($sub_info['#']['TITLE']['0']['#']); + $submission->title = backup_todb($sub_info['#']['TITLE']['0']['#']); $submission->timecreated = backup_todb($sub_info['#']['TIMECREATED']['0']['#']); + $date = usergetdate($submission->timecreated); + fwrite ($restorelog_file,"The Submission - ".$submission->title. " - TIMECREATED was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year'].""); + $submission->timecreated += $restore->course_startdateoffset; + $date = usergetdate($submission->timecreated); + fwrite ($restorelog_file,"   the Submission TIMECREATED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."
"); $submission->mailed = backup_todb($sub_info['#']['MAILED']['0']['#']); $submission->description = backup_todb($sub_info['#']['DESCRIPTION']['0']['#']); $submission->gradinggrade = backup_todb($sub_info['#']['GRADINGGRADE']['0']['#']);