--- /dev/null
+<?PHP //$Id$
+ //This php script contains all the stuff to backup/restore
+ //assignment mods
+
+ //This is the "graphical" structure of the assignment mod:
+ //
+ // assignment
+ // (CL,pk->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;
+ }
+
+?>
--- /dev/null
+<?PHP //$Id$
+ //This php script contains all the stuff to backup/restore
+ //choice mods
+
+ //This is the "graphical" structure of the choice mod:
+ //
+ // choice
+ // (CL,pk->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;
+ }
+
+?>
--- /dev/null
+<?PHP //$Id$
+ //This php script contains all the stuff to backup/restore
+ //resource mods
+
+ //This is the "graphical" structure of the resource mod:
+ //
+ // resource
+ // (CL,pk->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;
+ }
+
+?>