Permalink
Browse files

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
  • Loading branch information...
1 parent ea82d6b commit 163ff97e84e8718b02d324bb5f32cd09ab37f808 thompson697 committed Sep 13, 2006
View
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>moodle17devw</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
@@ -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;
@@ -33,7 +33,12 @@ function assignment_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
@@ -55,7 +60,18 @@ 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
@@ -33,7 +33,12 @@ function chat_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
@@ -46,6 +51,12 @@ 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
@@ -39,6 +39,11 @@ function choice_restore_mods($mod,$restore) {
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 @@ function choice_restore_mods($mod,$restore) {
$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,"<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
@@ -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,"<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>");
$database->participants = backup_todb($info['MOD']['#']['PARTICIPANTS']['0']['#']);
$database->requiredentries = backup_todb($info['MOD']['#']['REQUIREDENTRIES']['0']['#']);
$database->requiredentriestoview = backup_todb($info['MOD']['#']['REQUIREDENTRIESTOVIEW']['0']['#']);
@@ -48,7 +48,12 @@ function exercise_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
@@ -62,8 +67,14 @@ function exercise_restore_mods($mod,$restore) {
$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,"<br>The Exercise - ".$exercise->name." <br>");
+ 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,"&nbsp;&nbsp;&nbsp;the DEADLINE is now " .$date['weekday'].", ".$date['mday']." ".$date['month']." ".$date['year']."<br>");
$exercise->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
$exercise->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
$exercise->gradinggrade = backup_todb($info['MOD']['#']['GRADINGGRADE']['0']['#']);
Oops, something went wrong.

0 comments on commit 163ff97

Please sign in to comment.