From 96112b52249a7ab145ac2e71da14e72987fb4028 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 18 May 2003 22:55:54 +0000 Subject: [PATCH] Initial version. Does nothing !!, but needed to show info in restore_form.php --- backup/mod/assignment/restorelib.php | 64 ++++++++++++++++++++++++++++ backup/mod/choice/restorelib.php | 61 ++++++++++++++++++++++++++ backup/mod/resource/restorelib.php | 47 ++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 backup/mod/assignment/restorelib.php create mode 100644 backup/mod/choice/restorelib.php create mode 100644 backup/mod/resource/restorelib.php diff --git a/backup/mod/assignment/restorelib.php b/backup/mod/assignment/restorelib.php new file mode 100644 index 00000000000..a587c581257 --- /dev/null +++ b/backup/mod/assignment/restorelib.php @@ -0,0 +1,64 @@ +id) + // | + // | + // | + // assignment_submisions + // (UL,pk->id, fk->assignment,files) + // + // Meaning: pk->primary key field of the table + // fk->foreign key to link with parent + // nt->nested field (recursive data) + // CL->course level info + // UL->user level info + // files->table may have files) + // + //----------------------------------------------------------- + + //This function executes all the backup procedure about this mod + function assignment_restore_mods($bf,$preferences) { + + global $CFG; + + $status = true; + + //Iterate over assignment table + $assignments = get_records ("assignment","course",$preferences->backup_course,"id"); + if ($assignments) { + foreach ($assignments as $assignment) { + //Start mod + fwrite ($bf,start_tag("MOD",3,true)); + //Print assignment data + fwrite ($bf,full_tag("ID",4,false,$assignment->id)); + fwrite ($bf,full_tag("MODTYPE",4,false,"assignment")); + fwrite ($bf,full_tag("NAME",4,false,$assignment->name)); + fwrite ($bf,full_tag("DESCRIPTION",4,false,$assignment->description)); + fwrite ($bf,full_tag("FORMAT",4,false,$assignment->format)); + fwrite ($bf,full_tag("RESUBMIT",4,false,$assignment->resubmit)); + fwrite ($bf,full_tag("TYPE",4,false,$assignment->type)); + fwrite ($bf,full_tag("MAXBYTES",4,false,$assignment->maxbytes)); + fwrite ($bf,full_tag("TIMEDUE",4,false,$assignment->timedue)); + fwrite ($bf,full_tag("GRADE",4,false,$assignment->grade)); + fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$assignment->timemodified)); + //if we've selected to backup users info, then execute backup_assignment_submisions + if ($preferences->mods["assignment"]->userinfo) { + $status = backup_assignment_submissions($bf,$preferences,$assignment->id); + } + //End mod + $status =fwrite ($bf,end_tag("MOD",3,true)); + } + } + //if we've selected to backup users info, then backup files too + if ($preferences->mods["assignment"]->userinfo) { + $status = backup_assignment_files($bf,$preferences); + } + return $status; + } + +?> diff --git a/backup/mod/choice/restorelib.php b/backup/mod/choice/restorelib.php new file mode 100644 index 00000000000..8f1a1c85ab7 --- /dev/null +++ b/backup/mod/choice/restorelib.php @@ -0,0 +1,61 @@ +id) + // | + // | + // | + // choice_answers + // (UL,pk->id, fk->choice) + // + // Meaning: pk->primary key field of the table + // fk->foreign key to link with parent + // nt->nested field (recursive data) + // CL->course level info + // UL->user level info + // files->table may have files) + // + //----------------------------------------------------------- + + function choice_restore_mods($bf,$preferences) { + + global $CFG; + + $status = true; + + //Iterate over choice table + $choices = get_records ("choice","course",$preferences->backup_course,"id"); + if ($choices) { + foreach ($choices as $choice) { + //Start mod + fwrite ($bf,start_tag("MOD",3,true)); + //Print choice data + fwrite ($bf,full_tag("ID",4,false,$choice->id)); + fwrite ($bf,full_tag("MODTYPE",4,false,"choice")); + fwrite ($bf,full_tag("NAME",4,false,$choice->name)); + fwrite ($bf,full_tag("TEXT",4,false,$choice->text)); + fwrite ($bf,full_tag("FORMAT",4,false,$choice->format)); + fwrite ($bf,full_tag("ANSWER1",4,false,$choice->answer1)); + fwrite ($bf,full_tag("ANSWER2",4,false,$choice->answer2)); + fwrite ($bf,full_tag("ANSWER3",4,false,$choice->answer3)); + fwrite ($bf,full_tag("ANSWER4",4,false,$choice->answer4)); + fwrite ($bf,full_tag("ANSWER5",4,false,$choice->answer5)); + fwrite ($bf,full_tag("ANSWER6",4,false,$choice->answer6)); + fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish)); + fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified)); + //if we've selected to backup users info, then execute backup_choice_answers + if ($preferences->mods["choice"]->userinfo) { + $status = backup_choice_answers($bf,$preferences,$choice->id); + } + //End mod + $status =fwrite ($bf,end_tag("MOD",3,true)); + } + } + return $status; + } + +?> diff --git a/backup/mod/resource/restorelib.php b/backup/mod/resource/restorelib.php new file mode 100644 index 00000000000..ddf121f5457 --- /dev/null +++ b/backup/mod/resource/restorelib.php @@ -0,0 +1,47 @@ +id,files) + // + // Meaning: pk->primary key field of the table + // fk->foreign key to link with parent + // nt->nested field (recursive data) + // CL->course level info + // UL->user level info + // files->table may have files) + // + //----------------------------------------------------------- + + //This function executes all the restore procedure about this mod + function resource_restore_mods($bf,$preferences) { + global $CFG; + + $status = true; + + ////Iterate over resource table + $resources = get_records ("resource","course",$preferences->backup_course,"id"); + if ($resources) { + foreach ($resources as $resource) { + //Start mod + fwrite ($bf,start_tag("MOD",3,true)); + //Print assignment data + fwrite ($bf,full_tag("ID",4,false,$resource->id)); + fwrite ($bf,full_tag("MODTYPE",4,false,"resource")); + fwrite ($bf,full_tag("NAME",4,false,$resource->name)); + fwrite ($bf,full_tag("TYPE",4,false,$resource->type)); + fwrite ($bf,full_tag("REFERENCE",4,false,$resource->reference)); + fwrite ($bf,full_tag("SUMMARY",4,false,$resource->summary)); + fwrite ($bf,full_tag("ALLTEXT",4,false,$resource->alltext)); + fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$resource->timemodified)); + //End mod + $status = fwrite ($bf,end_tag("MOD",3,true)); + } + } + return $status; + } + +?>