|
|
|
@@ -1,5 +1,53 @@
|
|
|
|
|
<?php
|
|
|
|
|
<<<<<<< backuplib.php
|
|
|
|
|
/* THIS IS A STUB BACKUPLIB.PHP TO
|
|
|
|
|
* DEMONSTRATE THE NEW GRANULAR
|
|
|
|
|
* BACKUP/RESTORE API.
|
|
|
|
|
* IT NEEDS TO BE FILLED OUT!!!
|
|
|
|
|
*/
|
|
|
|
|
//This php script contains all the stuff to backup/restore
|
|
|
|
|
//assignment mods
|
|
|
|
|
=======
|
|
|
|
|
>>>>>>> 1.2
|
|
|
|
|
|
|
|
|
|
<<<<<<< backuplib.php
|
|
|
|
|
//This is the "graphical" structure of the assignment mod:
|
|
|
|
|
//
|
|
|
|
|
// data
|
|
|
|
|
// (CL,pk->id)
|
|
|
|
|
// |
|
|
|
|
|
// |
|
|
|
|
|
// |
|
|
|
|
|
// ---------------------------------------------------------------------------------
|
|
|
|
|
// | |
|
|
|
|
|
//data_records (UL,pk->id, fk->data) data_fields (pk->id, fk->data)
|
|
|
|
|
// | |
|
|
|
|
|
// | |
|
|
|
|
|
// ----------------------------------------------------------------------------- |
|
|
|
|
|
// | | | |
|
|
|
|
|
//data_ratings(fk->recordid, pk->id) data_comments (fk->recordid, pk->id) | |
|
|
|
|
|
// data_content(pk->id, fk->recordid, fk->fieldid)
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// 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)
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//Backup assignment files because we've selected to backup user info
|
|
|
|
|
//and files are user info's level
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Return a content encoded to support interactivities linking. Every module
|
|
|
|
|
|
|
|
|
|
//////////REAL DATABASE MODULE
|
|
|
|
|
|
|
|
|
|
=======
|
|
|
|
|
//This php script contains all the stuff to backup/restore
|
|
|
|
|
//assignment mods
|
|
|
|
|
|
|
|
|
@@ -37,6 +85,7 @@
|
|
|
|
|
|
|
|
|
|
//Return a content encoded to support interactivities linking. Every module
|
|
|
|
|
|
|
|
|
|
>>>>>>> 1.2
|
|
|
|
|
function data_backup_mods($bf,$preferences) {
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
|
@@ -64,6 +113,32 @@ function data_backup_one_mod($bf,$preferences,$data) {
|
|
|
|
|
|
|
|
|
|
$status = true;
|
|
|
|
|
|
|
|
|
|
<<<<<<< backuplib.php
|
|
|
|
|
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,"data"));
|
|
|
|
|
fwrite ($bf,full_tag("NAME",4,false,$data->name));
|
|
|
|
|
fwrite ($bf,full_tag("INTRO",4,false,$data->intro));
|
|
|
|
|
fwrite ($bf,full_tag("RATINGS",4,false,$data->ratings));
|
|
|
|
|
fwrite ($bf,full_tag("COMMENTS",4,false,$data->comments));
|
|
|
|
|
fwrite ($bf,full_tag("TIMEAVAILABLEFROM",4,false,$data->timeavailablefrom));
|
|
|
|
|
fwrite ($bf,full_tag("TIMEAVAILABLETO",4,false,$data->timeavailableto));
|
|
|
|
|
fwrite ($bf,full_tag("TIMEVIEWFROM",4,false,$data->timeviewfrom));
|
|
|
|
|
fwrite ($bf,full_tag("TIMEVIEWTO",4,false,$data->timeviewto));
|
|
|
|
|
fwrite ($bf,full_tag("PARTICIPANTS",4,false,$data->participants));
|
|
|
|
|
fwrite ($bf,full_tag("REQUIREDENTRIES",4,false,$data->requiredentries));
|
|
|
|
|
fwrite ($bf,full_tag("REQUIREDENTRIESTOVIEW",4,false,$data->requiredentriestoview));
|
|
|
|
|
fwrite ($bf,full_tag("MAXENTRIES",4,false,$data->maxentries));
|
|
|
|
|
fwrite ($bf,full_tag("RSSARTICLES",4,false,$data->rssarticles));
|
|
|
|
|
fwrite ($bf,full_tag("SINGLETEMPLATE",4,false,$data->singletemplate));
|
|
|
|
|
fwrite ($bf,full_tag("LISTTEMPLATE",4,false,$data->listtemplate));
|
|
|
|
|
fwrite ($bf,full_tag("ADDTEMPLATE",4,false,$data->addtemplate));
|
|
|
|
|
fwrite ($bf,full_tag("RSSTEMPLATE",4,false,$data->rsstemplate));
|
|
|
|
|
fwrite ($bf,full_tag("LISTTEMPLATEHEADER",4,false,$data->listtemplateheader));
|
|
|
|
|
fwrite ($bf,full_tag("LISTTEMPLATEFOOTER",4,false,$data->listtemplatefooter));
|
|
|
|
|
fwrite ($bf,start_end("MOD",3,true));
|
|
|
|
|
=======
|
|
|
|
|
fwrite ($bf,start_tag("MOD",3,true));
|
|
|
|
|
//Print assignment data
|
|
|
|
|
fwrite ($bf,full_tag("ID",4,false,$data->id));
|
|
|
|
@@ -88,6 +163,7 @@ function data_backup_one_mod($bf,$preferences,$data) {
|
|
|
|
|
fwrite ($bf,full_tag("LISTTEMPLATEHEADER",4,false,$data->listtemplateheader));
|
|
|
|
|
fwrite ($bf,full_tag("LISTTEMPLATEFOOTER",4,false,$data->listtemplatefooter));
|
|
|
|
|
|
|
|
|
|
>>>>>>> 1.2
|
|
|
|
|
|
|
|
|
|
// if we've selected to backup users info, then call any other functions we need
|
|
|
|
|
// including backing up individual files
|
|
|
|
@@ -95,6 +171,13 @@ function data_backup_one_mod($bf,$preferences,$data) {
|
|
|
|
|
//$status = backup_someuserdata_for_this_instance();
|
|
|
|
|
//$status = backup_somefiles_for_this_instance();
|
|
|
|
|
// ... etc
|
|
|
|
|
<<<<<<< backuplib.php
|
|
|
|
|
$status = backup_data_records($bf,$preferences,$data->id);
|
|
|
|
|
$status = backup_data_fields($bf,$preferences,$data->id);
|
|
|
|
|
if ($status) {
|
|
|
|
|
$status = backup_data_files_instance($bf,$preferences,$assignment->id); //recursive copy
|
|
|
|
|
}
|
|
|
|
|
=======
|
|
|
|
|
$status = backup_data_records($bf,$preferences,$data->id);
|
|
|
|
|
$status = backup_data_fields($bf,$preferences,$data->id);
|
|
|
|
|
if ($status) {
|
|
|
|
@@ -201,6 +284,10 @@ function backup_data_content($bf,$preferences,$recordid){
|
|
|
|
|
fwrite ($bf,full_tag("RECORDID",8,false,$cnt_sub->recordid));
|
|
|
|
|
fwrite ($bf,full_tag("FIELDID",8,false,$cnt_sub->fieldid));
|
|
|
|
|
fwrite ($bf,full_tag("CONTENT",8,false,$cnt_sub->content));
|
|
|
|
|
fwrite ($bf,full_tag("CONTENT1",8,false,$cnt_sub->content1));
|
|
|
|
|
fwrite ($bf,full_tag("CONTENT2",8,false,$cnt_sub->content2));
|
|
|
|
|
fwrite ($bf,full_tag("CONTENT3",8,false,$cnt_sub->content3));
|
|
|
|
|
fwrite ($bf,full_tag("CONTENT4",8,false,$cnt_sub->content4));
|
|
|
|
|
//End submission
|
|
|
|
|
$status =fwrite ($bf,end_tag("CONTENT",7,true));
|
|
|
|
|
}
|
|
|
|
@@ -234,12 +321,16 @@ function backup_data_ratings($bf,$preferences,$recordid){
|
|
|
|
|
}
|
|
|
|
|
//Write end tag
|
|
|
|
|
$status =fwrite ($bf,end_tag("RATINGS",6,true));
|
|
|
|
|
>>>>>>> 1.2
|
|
|
|
|
}
|
|
|
|
|
<<<<<<< backuplib.php
|
|
|
|
|
=======
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
function backup_data_comments($bf,$preferences,$recordid){
|
|
|
|
|
global $CFG;
|
|
|
|
|
$status = true;
|
|
|
|
|
>>>>>>> 1.2
|
|
|
|
|
|
|
|
|
|
$data_comments = get_records("data_comments","recordid",$recordid);
|
|
|
|
|
|
|
|
|
@@ -305,6 +396,131 @@ function backup_data_files_instance($bf,$preferences,$instanceid) {
|
|
|
|
|
}
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
//Backup assignment_submissions contents (executed from assignment_backup_mods)
|
|
|
|
|
|
|
|
|
|
function backup_data_records($bf,$preferences,$dataid){
|
|
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
$status = true;
|
|
|
|
|
|
|
|
|
|
$data_records = get_records("data_records","data",$dataid);
|
|
|
|
|
//If there is submissions
|
|
|
|
|
if ($data_records) {
|
|
|
|
|
//Write start tag
|
|
|
|
|
$status =fwrite ($bf,start_tag("RECORDS",4,true));
|
|
|
|
|
//Iterate over each submission
|
|
|
|
|
foreach ($data_records as $rec_sub) {
|
|
|
|
|
//Start submission
|
|
|
|
|
$status =fwrite ($bf,start_tag("RECORDS",5,true));
|
|
|
|
|
//Print submission contents
|
|
|
|
|
fwrite ($bf,full_tag("ID",6,false,$rec_sub->id));
|
|
|
|
|
fwrite ($bf,full_tag("USERID",6,false,$rec_sub->userid));
|
|
|
|
|
fwrite ($bf,full_tag("GROUPID",6,false,$rec_sub->groupid));
|
|
|
|
|
fwrite ($bf,full_tag("DATAID",6,false,$rec_sub->dataid));
|
|
|
|
|
fwrite ($bf,full_tag("TIMECREATED",6,false,$rec_sub->timecreated));
|
|
|
|
|
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$rec_sub->timemodified));
|
|
|
|
|
//End submission
|
|
|
|
|
$status =fwrite ($bf,end_tag("RECORDS",5,true));
|
|
|
|
|
|
|
|
|
|
backup_data_content($bf,$preferences,$rec_sub->id);
|
|
|
|
|
backup_data_ratings($bf,$preferences,$rec_sub->id);
|
|
|
|
|
backup_data_comments($bf,$preferences,$rec_sub->id);
|
|
|
|
|
}
|
|
|
|
|
//Write end tag
|
|
|
|
|
$status =fwrite ($bf,end_tag("RECORDS",4,true));
|
|
|
|
|
}
|
|
|
|
|
return $status;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function backup_data_fields($bf,$preferences,$dataid){
|
|
|
|
|
global $CFG;
|
|
|
|
|
$status = true;
|
|
|
|
|
|
|
|
|
|
$data_fields = get_records("data_fields","data",$dataid);
|
|
|
|
|
//If there is submissions
|
|
|
|
|
if ($data_fields) {
|
|
|
|
|
//Write start tag
|
|
|
|
|
$status =fwrite ($bf,start_tag("FIELDS",4,true));
|
|
|
|
|
//Iterate over each submission
|
|
|
|
|
foreach ($data_fields as $fie_sub) {
|
|
|
|
|
//Start submission
|
|
|
|
|
$status =fwrite ($bf,start_tag("FIELDS",5,true));
|
|
|
|
|
//Print submission contents
|
|
|
|
|
fwrite ($bf,full_tag("ID",6,false,$fie_sub->id));
|
|
|
|
|
fwrite ($bf,full_tag("DATAID",6,false,$fie_sub->dataid));
|
|
|
|
|
fwrite ($bf,full_tag("TYPE",6,false,$fie_sub->type));
|
|
|
|
|
fwrite ($bf,full_tag("NAME",6,false,$fie_sub->name));
|
|
|
|
|
fwrite ($bf,full_tag("DESCRIPTION",6,false,$fie_sub->description));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM1",6,false,$fie_sub->param1));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM2",6,false,$fie_sub->param2));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM3",6,false,$fie_sub->param3));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM4",6,false,$fie_sub->param4));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM5",6,false,$fie_sub->param5));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM6",6,false,$fie_sub->param6));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM7",6,false,$fie_sub->param7));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM8",6,false,$fie_sub->param8));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM9",6,false,$fie_sub->param9));
|
|
|
|
|
fwrite ($bf,full_tag("PARAM10",6,false,$fie_sub->param10));
|
|
|
|
|
|
|
|
|
|
//End submission
|
|
|
|
|
$status =fwrite ($bf,end_tag("FIELDS",5,true));
|
|
|
|
|
}
|
|
|
|
|
//Write end tag
|
|
|
|
|
$status =fwrite ($bf,end_tag("FIELDS",4,true));
|
|
|
|
|
}
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function backup_data_content($bf,$preferences,$recordid){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function backup_data_ratings($bf,$preferences,$recordid){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function backup_data_comments($bf,$preferences,$recordid){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function backup_data_files($bf,$preferences) {
|
|
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
|
|
$status = true;
|
|
|
|
|
|
|
|
|
|
//First we check to moddata exists and create it as necessary
|
|
|
|
|
//in temp/backup/$backup_code dir
|
|
|
|
|
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
|
|
|
|
|
//Now copy the assignment dir
|
|
|
|
|
if ($status) {
|
|
|
|
|
//Only if it exists !! Thanks to Daniel Miksik.
|
|
|
|
|
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/data")) {
|
|
|
|
|
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/data",
|
|
|
|
|
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/data");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function backup_data_file_instance($bf,$preferences,$instanceid) {
|
|
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
$status = true;
|
|
|
|
|
|
|
|
|
|
//First we check to moddata exists and create it as necessary
|
|
|
|
|
//in temp/backup/$backup_code dir
|
|
|
|
|
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
|
|
|
|
|
$status = check_dir_exists($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/data/",true);
|
|
|
|
|
//Now copy the assignment dir
|
|
|
|
|
if ($status) {
|
|
|
|
|
//Only if it exists !! Thanks to Daniel Miksik.
|
|
|
|
|
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/data/".$instanceid)) {
|
|
|
|
|
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/data/".$instanceid,
|
|
|
|
|
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/data/".$instanceid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function data_check_backup_mods_instances($instance,$backup_unique_code) {
|
|
|
|
|
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
|
|
|
|
|