Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 95df21e3aec9da3c87f2aaf4196553a35e376dfc 1 parent 6fe671e
thompson697 authored
View
77 backup/restorelib.php
@@ -2205,10 +2205,7 @@ function restore_create_events($restore,$xml_file) {
//Get admin->id for later use
$admin = get_admin();
$adminid = $admin->id;
- //First, we check the course_id backup data folder exists
- $dest_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($dest_dir,true);
- $restorelog_file = fopen("$dest_dir/restorelog.html","a");
+
//Now, if we have anything in events, we have to restore that
//events
if ($events) {
@@ -2227,6 +2224,11 @@ function restore_create_events($restore,$xml_file) {
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Events', $restore, $info['EVENT']['#'], array('TIMESTART'));
+ }
+
//Now build the EVENT record structure
$eve->name = backup_todb($info['EVENT']['#']['NAME']['0']['#']);
$eve->description = backup_todb($info['EVENT']['#']['DESCRIPTION']['0']['#']);
@@ -2239,11 +2241,6 @@ function restore_create_events($restore,$xml_file) {
$eve->instance = 0;
$eve->eventtype = backup_todb($info['EVENT']['#']['EVENTTYPE']['0']['#']);
$eve->timestart = backup_todb($info['EVENT']['#']['TIMESTART']['0']['#']);
- $date = usergetdate($eve->timestart);
- fwrite ($restorelog_file,"The Event - ".$eve->name. " - TIMESTART was " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."");
- $eve->timestart += $restore->course_startdateoffset;
- $date = usergetdate($eve->timestart);
- fwrite ($restorelog_file,"&nbsp;&nbsp;&nbsp;the Event TIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$eve->timeduration = backup_todb($info['EVENT']['#']['TIMEDURATION']['0']['#']);
$eve->visible = backup_todb($info['EVENT']['#']['VISIBLE']['0']['#']);
$eve->timemodified = backup_todb($info['EVENT']['#']['TIMEMODIFIED']['0']['#']);
@@ -6259,5 +6256,65 @@ function restore_write_roleoverrides($restore, $overrides, $table, $contextlevel
insert_record('role_capabilities', $override);
}
}
- }
+ }
+ //write activity date changes to the html log file, and update date values in the the xml array
+ function restore_log_date_changes($recordtype, &$restore, &$xml, $TAGS, $NAMETAG='NAME') {
+
+ global $CFG;
+ $openlog = false;
+
+ // loop through time fields in $TAGS
+ foreach ($TAGS as $TAG) {
+
+ // check $TAG has a sensible value
+ if (!empty($xml[$TAG][0]['#']) && is_string($xml[$TAG][0]['#']) && is_numeric($xml[$TAG][0]['#'])) {
+
+ if ($openlog==false) {
+ $openlog = true; // only come through here once
+
+ // open file for writing
+ $course_dir = "$CFG->dataroot/$restore->course_id/backupdata";
+ check_dir_exists($course_dir, true);
+ $restorelog = fopen("$course_dir/restorelog.html", "a");
+
+ // start output for this record
+ $msg = new stdClass();
+ $msg->recordtype = $recordtype;
+ $msg->recordname = $xml[$NAMETAG][0]['#'];
+ fwrite ($restorelog, get_string("backupdaterecordtype", "moodle", $msg));
+ }
+
+ // write old date to $restorelog
+ $value = $xml[$TAG][0]['#'];
+ $date = usergetdate($value);
+
+ $msg = new stdClass();
+ $msg->TAG = $TAG;
+ $msg->weekday = $date['weekday'];
+ $msg->mday = $date['mday'];
+ $msg->month = $date['month'];
+ $msg->year = $date['year'];
+ fwrite ($restorelog, get_string("backupdateold", "moodle", $msg));
+
+ // write new date to $restorelog
+ $value += $restore->course_startdateoffset;
+ $date = usergetdate($value);
+
+ $msg = new stdClass();
+ $msg->TAG = $TAG;
+ $msg->weekday = $date['weekday'];
+ $msg->mday = $date['mday'];
+ $msg->month = $date['month'];
+ $msg->year = $date['year'];
+ fwrite ($restorelog, get_string("backupdatenew", "moodle", $msg));
+
+ // update $value in $xml tree for calling module
+ $xml[$TAG][0]['#'] = "$value";
+ }
+ }
+ // close the restore log, if it was opened
+ if ($openlog) {
+ fclose($restorelog);
+ }
+ }
?>
View
5 lang/en_utf8/moodle.php
@@ -131,6 +131,9 @@
$string['backupcancelled'] = 'Backup Cancelled';
$string['backupcoursefileshelp'] = 'If enabled then course files will be included in automated backups';
$string['backupdate'] = 'Backup Date';
+$string['backupdatenew'] = ' &nbsp; $a->TAG is now $a->weekday, $a->mday $a->month $a->year<br>\n';
+$string['backupdateold'] = '$a->TAG was $a->weekday, $a->mday $a->month $a->year\n';
+$string['backupdaterecordtype'] = '<br>$a->recordtype - $a->recordname<br>\n';
$string['backupdetails'] = 'Backup Details';
$string['backupexecuteathelp'] = 'Choose what time automated backups should run at.';
$string['backupfailed'] = 'Some of your courses weren\'t saved!!';
@@ -1470,4 +1473,4 @@
$string['yourteacher'] = 'your $a';
$string['zippingbackup'] = 'Zipping backup';
-?>
+?>
View
23 mod/assignment/restorelib.php
@@ -32,12 +32,12 @@ function assignment_restore_mods($mod,$restore) {
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
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");
+ //Now get completed xmlized object
+ $info = $data->info;
+ //if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Assignment', $restore, $info['MOD']['#'], array('TIMEDUE', 'TIMEAVAILABLE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -59,18 +59,7 @@ function assignment_restore_mods($mod,$restore) {
$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,"<br>The Assignment - ".$assignment->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the TIMEDUE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the TIMEAVAILABLE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$assignment->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$assignment->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
View
16 mod/chat/restorelib.php
@@ -34,14 +34,14 @@ function chat_restore_mods($mod,$restore) {
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");
+
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
-
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Chat', $restore, $info['MOD']['#'], array('CHATTIME'));
+ }
//Now, build the CHAT record structure
$chat->course = $restore->course_id;
$chat->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
@@ -50,12 +50,6 @@ function chat_restore_mods($mod,$restore) {
$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." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the CHATTIME is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
$chat->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the chat
View
19 mod/choice/restorelib.php
@@ -39,10 +39,10 @@ function choice_restore_mods($mod,$restore) {
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('Choice', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -59,18 +59,7 @@ function choice_restore_mods($mod,$restore) {
$choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']);
$choice->limitanswers = backup_todb($info['MOD']['#']['LIMITANSWERS']['0']['#']);
$choice->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
- $date = usergetdate($choice->timeopen);
- fwrite ($restorelog_file,"<br>The Choice - ".$choice->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;The TIMEOPEN is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the TIMECLOSE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$choice->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//To mantain compatibilty, in 1.4 the publish setting meaning has changed. We
View
31 mod/data/restorelib.php
@@ -46,11 +46,11 @@ function data_restore_mods($mod,$restore) {
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");
+ $info = $data->info;
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Database', $restore, $info['MOD']['#'], array('TIMEAVAILABLEFROM', 'TIMEAVAILABLETO','TIMEVIEWFROM', 'TIMEVIEWTO'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -65,30 +65,9 @@ function data_restore_mods($mod,$restore) {
}
$database->comments = backup_todb($info['MOD']['#']['COMMENTS']['0']['#']);
$database->timeavailablefrom = backup_todb($info['MOD']['#']['TIMEAVAILABLEFROM']['0']['#']);
- $date = usergetdate($database->timeavailablefrom);
- fwrite ($restorelog_file,"<br>The Database - ".$database->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the TTIMEAVAILABLEFROM is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the TIMEAVAILABLETO is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the TIMEVIEWFROM is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the TIMEVIEWTO is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
// Only relevant for restoring backups from 1.6 in a 1.7 install.
if (isset($info['MOD']['#']['PARTICIPANTS']['0']['#'])) {
$database->participants = backup_todb($info['MOD']['#']['PARTICIPANTS']['0']['#']);
View
12 mod/exercise/restorelib.php
@@ -47,12 +47,12 @@ function exercise_restore_mods($mod,$restore) {
$data = backup_getid($restore->backup_unique_code,$mod->modtype,$mod->id);
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");
+ //Now get completed xmlized object
+ $info = $data->info;
+ // if necessary, write to restorelog and adjust date/time fields
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Exercise', $restore, $info['MOD']['#'], array('DEADLINE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
View
29 mod/forum/restorelib.php
@@ -44,10 +44,10 @@ function forum_restore_mods($mod,$restore) {
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('Forum', $restore, $info['MOD']['#'], array('ASSESSTIMESTART', 'ASSESSTIMEFINISH'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -70,18 +70,7 @@ function forum_restore_mods($mod,$restore) {
$forum->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$forum->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
- $date = usergetdate($forum->assesstimestart);
- fwrite ($restorelog_file,"<br>The Forum - ".$forum->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the ASSESSTIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the ASSESSTIMEFINISH is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$forum->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
$forum->scale = backup_todb($info['MOD']['#']['SCALE']['0']['#']);
$forum->forcesubscribe = backup_todb($info['MOD']['#']['FORCESUBSCRIBE']['0']['#']);
@@ -270,10 +259,7 @@ function forum_discussions_restore_mods($forum_id,$info,$restore) {
if (!empty($info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'])) {
$discussions = $info['MOD']['#']['DISCUSSIONS']['0']['#']['DISCUSSION'];
}
- //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 discussions
for($i = 0; $i < sizeof($discussions); $i++) {
$dis_info = $discussions[$i];
@@ -294,12 +280,7 @@ function forum_discussions_restore_mods($forum_id,$info,$restore) {
$discussion->groupid = backup_todb($dis_info['#']['GROUPID']['0']['#']);
$discussion->assessed = backup_todb($dis_info['#']['ASSESSED']['0']['#']);
$discussion->timemodified = backup_todb($dis_info['#']['TIMEMODIFIED']['0']['#']);
- $date = usergetdate($discussion->timemodified);
- fwrite ($restorelog_file,"<br>The Discussion - ".$discussion->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the Discussion TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$discussion->usermodified = backup_todb($dis_info['#']['USERMODIFIED']['0']['#']);
$discussion->timestart = backup_todb($dis_info['#']['TIMESTART']['0']['#']);
$discussion->timestart += $restore->course_startdateoffset;
View
19 mod/glossary/restorelib.php
@@ -41,10 +41,10 @@ function glossary_restore_mods($mod,$restore) {
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('Glossary', $restore, $info['MOD']['#'], array('ASSESSTIMESTART', 'ASSESSTIMEFINISH'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -74,18 +74,7 @@ function glossary_restore_mods($mod,$restore) {
$glossary->assessed = backup_todb($info['MOD']['#']['ASSESSED']['0']['#']);
$glossary->assesstimestart = backup_todb($info['MOD']['#']['ASSESSTIMESTART']['0']['#']);
- $date = usergetdate($glossary->assesstimestart);
- fwrite ($restorelog_file,"<br>The Glossary - ".$glossary->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the Glossary ASSESSTIMESTART is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the Glossary ASSESSTIMEFINISH is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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)
View
33 mod/hotpot/restorelib.php
@@ -108,37 +108,8 @@ function hotpot_restore_mods($mod, $restore) {
}
// if necessary, adjust HotPot date/time fields and write to restorelog
- if (!empty($restore->course_startdateoffset)) {
-
- // check course backup data directory exists
- $course_dir = $CFG->dataroot."/".$restore->course_id."/backupdata";
- check_dir_exists($course_dir, true);
-
- // open $restorelog and start output for this HotPot
- $restorelog = fopen("$course_dir/restorelog.html", "a");
- fwrite ($restorelog, "<br>Hotpot - ".$xml['NAME'][0]['#']." <br>");
-
- // loop through time fields
- $TAGS = array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED');
- foreach ($TAGS as $TAG) {
-
- // check $TAG has a sensible value
- if (!empty($xml[$TAG][0]['#']) && is_string($xml[$TAG][0]['#'])) {
-
- // write old date to $restorelog
- $value = $xml[$TAG][0]['#'];
- $date = usergetdate($value);
- fwrite ($restorelog, "$TAG was ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']);
-
- // write new date to $restorelog
- $value += $restore->course_startdateoffset;
- $date = usergetdate($value);
- fwrite ($restorelog, "&nbsp;&nbsp;&nbsp;$TAG is now ". $date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
-
- // update $value in $xml tree
- $xml[$TAG][0]['#'] = $value;
- }
- }
+ if ($restore->course_startdateoffset) {
+ restore_log_date_changes('Hotpot', $restore, $xml, array('TIMEOPEN', 'TIMECLOSE', 'TIMECREATED', 'TIMEMODIFIED'));
}
$status = hotpot_restore_records(
View
35 mod/journal/restorelib.php
@@ -34,10 +34,10 @@ function journal_restore_mods($mod,$restore) {
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 @@ function journal_restore_mods($mod,$restore) {
$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 @@ function journal_entries_restore_mods($old_journal_id, $new_journal_id,$info,$re
//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 @@ function journal_entries_restore_mods($old_journal_id, $new_journal_id,$info,$re
//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 @@ function journal_entries_restore_mods($old_journal_id, $new_journal_id,$info,$re
}
$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
View
21 mod/lesson/restorelib.php
@@ -51,10 +51,10 @@ function lesson_restore_mods($mod,$restore) {
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('Lesson', $restore, $info['MOD']['#'], array('AVAILABLE', 'DEADLINE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -95,20 +95,9 @@ function lesson_restore_mods($mod,$restore) {
$lesson->displayleftif = isset($info['MOD']['#']['DISPLAYLEFTIF']['0']['#'])?backup_todb($info['MOD']['#']['DISPLAYLEFTIF']['0']['#']):'';
$lesson->progressbar = isset($info['MOD']['#']['PROGRESSBAR']['0']['#'])?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,"<br>The Lesson - ".$lesson->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the Time AVAILABLE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the DEADLINE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$lesson->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
//The structure is equal to the db, so insert the lesson
View
19 mod/quiz/restorelib.php
@@ -54,10 +54,10 @@ function quiz_restore_mods($mod,$restore) {
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('Quiz', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -68,18 +68,7 @@ function quiz_restore_mods($mod,$restore) {
$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,"<br>The Quiz - ".$quiz->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the TIMEOPEN is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the TIMECLOSE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
$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']['#']);
View
19 mod/quiz/restorelibpre15.php
@@ -1226,10 +1226,10 @@ function quiz_restore_pre15_mods($mod,$restore) {
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('Quiz', $restore, $info['MOD']['#'], array('TIMEOPEN', 'TIMECLOSE'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -1239,18 +1239,7 @@ function quiz_restore_pre15_mods($mod,$restore) {
$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." <br>");
- 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,"&nbsp;&nbsp;&nbsp;Time Open is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;Time Close is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
$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']['#']);
View
23 mod/wiki/restorelib.php
@@ -34,10 +34,10 @@ function wiki_restore_mods($mod,$restore) {
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('Wiki', $restore, $info['MOD']['#'], array('TIMEMODIFIED'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -58,12 +58,6 @@ function wiki_restore_mods($mod,$restore) {
$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." <br>");
- $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,"&nbsp;&nbsp;&nbsp;the Wiki TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
//The structure is equal to the db, so insert the wiki
$newid = insert_record ("wiki",$wiki);
@@ -102,10 +96,7 @@ function wiki_entries_restore_mods($old_wiki_id,$new_wiki_id,$info,$restore) {
//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++) {
$ent_info = $entries[$i];
@@ -123,11 +114,7 @@ function wiki_entries_restore_mods($old_wiki_id,$new_wiki_id,$info,$restore) {
$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,"&nbsp;&nbsp;&nbsp;The Entry TIMEMODIFIED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br><br>");
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$entry->userid);
if ($user) {
View
43 mod/workshop/restorelib.php
@@ -48,10 +48,10 @@ function workshop_restore_mods($mod,$restore) {
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('Workshop', $restore, $info['MOD']['#'], array('SUBMISSIONSTART','ASSESSMENTSTART', 'SUBMISSIONEND', 'ASSESSMENTEND', 'RELEASEGRADES'));
+ }
//traverse_xmlize($info); //Debug
//print_object ($GLOBALS['traverse_array']); //Debug
//$GLOBALS['traverse_array']=""; //Debug
@@ -73,37 +73,11 @@ function workshop_restore_mods($mod,$restore) {
$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,"<br>The Workshop - ".$workshop->name." <br>");
- 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,"&nbsp;&nbsp;&nbsp;the SUBMISSIONSTART time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the ASSESSMENTSTART time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the SUBMISSIONEND time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the ASSESSMENTEND time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$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,"&nbsp;&nbsp;&nbsp;the RELEASEGRADES time is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$workshop->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$workshop->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']);
$workshop->ntassessments = backup_todb($info['MOD']['#']['NTASSESSMENTS']['0']['#']);
@@ -351,10 +325,7 @@ function workshop_submissions_restore_mods($old_workshop_id, $new_workshop_id,$i
//Get the submissions array
$submissions = $info['MOD']['#']['SUBMISSIONS']['0']['#']['SUBMISSION'];
- //First, we 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 submissions
for($i = 0; $i < sizeof($submissions); $i++) {
$sub_info = $submissions[$i];
@@ -371,11 +342,7 @@ function workshop_submissions_restore_mods($old_workshop_id, $new_workshop_id,$i
$submission->userid = backup_todb($sub_info['#']['USERID']['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,"&nbsp;&nbsp;&nbsp;the Submission TIMECREATED is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$submission->mailed = backup_todb($sub_info['#']['MAILED']['0']['#']);
$submission->description = backup_todb($sub_info['#']['DESCRIPTION']['0']['#']);
$submission->gradinggrade = backup_todb($sub_info['#']['GRADINGGRADE']['0']['#']);
Please sign in to comment.
Something went wrong with that request. Please try again.