1
0
mirror of https://github.com/moodle/moodle.git synced 2025-05-15 12:45:41 +02:00

Granular backup & restore:

This patch allows the much requested selection of individual instances of modules within a course to backup and restore.
It needs A LOT of testing and probably some prettyifying too.
This commit is contained in:
mjollnir_ 2006-01-13 03:45:31 +00:00
parent 0f4e83c173
commit 1ecea97679
44 changed files with 2026 additions and 619 deletions

@ -34,6 +34,7 @@
$modname = $mod->name;
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modbackupone = $modname."_backup_one_mod";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
include_once($modfile);
@ -41,6 +42,21 @@
$var = "exists_".$modname;
$$var = true;
$count++;
// check that there are instances and we can back them up individually
if (count_records('course_modules','course',$course->id,'module',$mod->id) && function_exists($modbackupone)) {
$var = 'exists_one_'.$modname;
$$var = true;
$varname = $modname.'_instances';
$$varname = get_all_instances_in_course($modname,$course);
foreach ($$varname as $instance) {
$var = 'backup_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,0);
$var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,0);
$var = 'backup_'.$modname.'_instances';
$$var = 1; // we need this later to determine what to display in modcheckbackup.
}
}
}
}
//Check data
@ -194,7 +210,28 @@
echo $backup_user_options[$$var]."</b>";
//Call the check function to show more info
$modcheckbackup = $modname."_check_backup_mods";
$table->data = $modcheckbackup($id,$$var,$backup_unique_code);
$var = $modname.'_instances';
$instancestopass = array();
if (!empty($$var) && is_array($$var) && count($$var)) {
$table->data = array();
$countinstances = 0;
foreach ($$var as $instance) {
$var1 = 'backup_'.$modname.'_instance_'.$instance->id;
$var2 = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
if (!empty($$var1)) {
$obj = new StdClass;
$obj->name = $instance->name;
$obj->userdata = $$var2;
$obj->id = $instance->id;
$instancestopass[$instance->id]= $obj;
$countinstances++;
echo '<input type="hidden" name="'.$var1.'" value="'.$$var1.'" />';
echo '<input type="hidden" name="'.$var2.'" value="'.$$var2.'" />';
}
}
}
$table->data = $modcheckbackup($id,$$var,$backup_unique_code,$instancestopass);
print_table($table);
echo "</td></tr>";
}

@ -34,6 +34,7 @@
$modname = $mod->name;
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modbackupone = $modname."_backup_one_mod";
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
include_once($modfile);
@ -41,6 +42,21 @@
$var = "exists_".$modname;
$$var = true;
$count++;
if (count_records('course_modules','course',$course->id,'module',$mod->id) && function_exists($modbackupone)) {
$var = 'exists_one_'.$modname;
$$var = true;
$varname = $modname.'_instances';
$$varname = get_all_instances_in_course($modname,$course);
foreach ($$varname as $instance) {
$preferences->mods[$modname]->instances[$instance->id]->name = $instance->name;
$var = 'backup_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,0);
$preferences->mods[$modname]->instances[$instance->id]->backup = $$var;
$var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,0);
$preferences->mods[$modname]->instances[$instance->id]->userinfo = $$var;
}
}
}
}

@ -33,6 +33,7 @@
$modname = $mod->name;
$modfile = "$CFG->dirroot/mod/$modname/backuplib.php";
$modbackup = $modname."_backup_mods";
$modbackupone = $modname.'_backup_one_mod';
$modcheckbackup = $modname."_check_backup_mods";
if (file_exists($modfile)) {
include_once($modfile);
@ -40,6 +41,11 @@
$var = "exists_".$modname;
$$var = true;
$count++;
// check that there are instances and we can back them up individually
if (count_records('course_modules','course',$course->id,'module',$mod->id) && function_exists($modbackupone)) {
$var = 'exists_one_'.$modname;
$$var = true;
}
}
}
//Check data
@ -94,7 +100,7 @@ function selectItemInRadioByName(formId, radioName, selectIndex ) {
}
function selectItemInCheckboxByName(formId, checkName, checked ) {
myForm = document.getElementById(formId)
myForm = document.getElementById(formId);
for (i=0,n=myForm.elements.length;i<n;i++) {
myLen = checkName.length;
myName = myForm.elements[i].name;
@ -144,19 +150,42 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
$var = "backup_".$modname;
//choose_from_menu($backup_options, $var, $$var, "");
//Print the checkbox
print_checkbox($var, $$var, $$var, get_string("modulenameplural",$modname));
$var = "backup_user_info_".$modname;
print_checkbox($var, $$var, $$var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'backup_'.$modname.'\',this.checked)');
echo "</td><td align=\"right\">&nbsp;";
echo "</td><td>";
$var = "backup_user_info_".$modname;
if (empty($to)) {
$backup_user_options[0] = get_string("withoutuserdata");
$backup_user_options[1] = get_string("withuserdata");
//choose_from_menu($backup_user_options, $var, $$var, "");
print_checkbox($var, $$var, $$var, get_string("userdata"));
print_checkbox($var, $$var, $$var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'backup_user_info_'.$modname.'\',this.checked)');
} else {
echo '<input type="hidden" name="'.$var.'" value="0" />';
}
echo "</td></tr>\n";
// if we have the backup_one_mod function, loop here.
$var = 'exists_one_'.$modname;
if (!empty($$var)) {
echo '<tr><td></td><td colspan="3"><table class="backup-form-instances">';
$instances = get_all_instances_in_course($modname,$course);
foreach ($instances as $instance) {
echo '<tr><td>';
$var = 'backup_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,1);
print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'backup_'.$modname.'\'].checked=1;');
echo '</td><td align="right">&nbsp;';
$var = 'backup_user_info_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,1);
if (empty($to)) {
print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'backup_user_info_'.$modname.'\'].checked=1;');
} else {
echo '<input type="hidden" name="'.$var.'" value="0" />';
}
echo '</td></tr>';
}
echo '</table></td></tr>';
}
}
}
//Line

@ -363,26 +363,32 @@ function schedule_backup_course_configure($course,$starttime = 0) {
$var = "exists_".$modname;
$$var = true;
$count++;
// PENNY NOTES: I have moved from here to the closing brace inside
// by two sets of ifs()
// to avoid the backup failing on a non existant backup.
// If the file/function/whatever doesn't exist, we don't want to set this
// this module in backup preferences at all.
//Check data
//Check module info
$var = "backup_".$modname;
if (!isset($$var)) {
$$var = $backup_config->backup_sche_modules;
}
//Now stores all the mods preferences into an array into preferences
$preferences->mods[$modname]->backup = $$var;
//Check include user info
$var = "backup_user_info_".$modname;
if (!isset($$var)) {
$$var = $backup_config->backup_sche_withuserdata;
}
//Now stores all the mods preferences into an array into preferences
$preferences->mods[$modname]->userinfo = $$var;
//And the name of the mod
$preferences->mods[$modname]->name = $modname;
}
}
//Check data
//Check module info
$var = "backup_".$modname;
if (!isset($$var)) {
$$var = $backup_config->backup_sche_modules;
}
//Now stores all the mods preferences into an array into preferences
$preferences->mods[$modname]->backup = $$var;
//Check include user info
$var = "backup_user_info_".$modname;
if (!isset($$var)) {
$$var = $backup_config->backup_sche_withuserdata;
}
//Now stores all the mods preferences into an array into preferences
$preferences->mods[$modname]->userinfo = $$var;
//And the name of the mod
$preferences->mods[$modname]->name = $modname;
}
}
}

@ -505,6 +505,32 @@
fwrite ($bf,full_tag("NAME",4,false,$element->name));
fwrite ($bf,full_tag("INCLUDED",4,false,$included));
fwrite ($bf,full_tag("USERINFO",4,false,$userinfo));
if (is_array($preferences->mods[$element->name]->instances)
&& count($preferences->mods[$element->name]->instances)) {
fwrite ($bf, start_tag("INSTANCES",4,true));
foreach ($preferences->mods[$element->name]->instances as $id => $object) {
if (!empty($object->backup)) {
//Calculate info
$included = "false";
$userinfo = "false";
if ($object->backup) {
$included = "true";
if ($object->userinfo) {
$userinfo = "true";
}
}
fwrite ($bf, start_tag("INSTANCE",5,true));
fwrite ($bf, full_tag("ID",5,false,$id));
fwrite ($bf, full_tag("NAME",5,false,$object->name));
fwrite ($bf, full_tag("INCLUDED",5,false,$included)) ;
fwrite ($bf, full_tag("USERINFO",5,false,$userinfo));
fwrite ($bf, end_tag("INSTANCE",5,true));
}
}
fwrite ($bf, end_tag("INSTANCES",4,true));
}
//Print the end
fwrite ($bf,end_tag("MOD",3,true));
@ -946,6 +972,14 @@
fwrite ($bf,start_tag("MODS",4,true));
$first_record = false;
}
// if we're doing selected instances, check that too.
if (is_array($preferences->mods[$moduletype]->instances)
&& count($preferences->mods[$moduletype]->instances)
&& (!array_key_exists($course_module[$tok]->instance,$preferences->mods[$moduletype]->instances)
|| empty($preferences->mods[$moduletype]->instances[$course_module[$tok]->instance]->backup))) {
$tok = strtok(",");
continue;
}
//Print mod info from course_modules
fwrite ($bf,start_tag("MOD",5,true));
//Save neccesary info to backup_ids
@ -1612,14 +1646,27 @@
$status = true;
//First, re-check if necessary functions exists
$modbackup = $module."_backup_mods";
if (function_exists($modbackup)) {
//Call the function
$status = $modbackup($bf,$preferences);
} else {
//Something was wrong. Function should exist.
$status = false;
if (is_array($preferences->mods[$module]->instances)) {
$onemodbackup = $module.'_backup_one_mod';
if (function_exists($onemodbackup)) {
foreach ($preferences->mods[$module]->instances as $instance => $object) {
if (!empty($object->backup)) {
$status = $onemodbackup($bf,$preferences,$instance);
}
}
} else {
$status = false;
}
} else { // whole module.
//First, re-check if necessary functions exists
$modbackup = $module."_backup_mods";
if (function_exists($modbackup)) {
//Call the function
$status = $modbackup($bf,$preferences);
} else {
//Something was wrong. Function should exist.
$status = false;
}
}
return $status;
@ -1857,4 +1904,27 @@
return $status;
}
/**
* compatibility function
* with new granular backup
* we need to know
*/
function backup_userdata_selected($preferences,$modname,$modid) {
return ((empty($preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->userinfo))
|| (is_array($preferences->mods[$modname]->instances)
&& array_key_exists($modid,$preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->instances[$modid]->userinfo)));
}
function backup_mod_selected($preferences,$modname,$modid) {
return ((empty($preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->backup))
|| (is_array($preferences->mods[$modname]->instances)
&& array_key_exists($modid,$preferences->mods[$modname]->instances)
&& !empty($preferences->mods[$modname]->instances[$modid]->backup)));
}
?>

@ -34,7 +34,7 @@ function blackboard_convert($dir){
// Check for a Blackboard manifest file
if (is_readable($dir.'/imsmanifest.xml')){
if (is_readable($dir.'/imsmanifest.xml') && !is_readable($dir.'/moodle.xml')){
if (!function_exists('xslt_create')) { // XSLT MUST be installed for this to work
notify('You need the XSLT library installed in PHP to open this Blackboard file');

@ -42,6 +42,13 @@
$$var = optional_param( $var,0);
$var = "restore_user_info_".$modname;
$$var = optional_param( $var,0);
$instances = $info->mods[$mod->name]->instances;
foreach ($instances as $instance) {
$var = 'restore_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,0);
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,0);
}
}
}
//restoreto
@ -75,6 +82,14 @@
$restore->mods[$modname]->restore=$$var;
$var = "restore_user_info_".$modname;
$restore->mods[$modname]->userinfo=$$var;
$instances = $info->mods[$mod->name]->instances;
foreach ($instances as $instance) {
$var = 'restore_'.$modname.'_instance_'.$instance->id;
$restore->mods[$modname]->instances[$instance->id]->restore = $$var;
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
$restore->mods[$modname]->instances[$instance->id]->userinfo = $$var;
}
}
}
$restore->restoreto=$restore_restoreto;

@ -213,7 +213,7 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
//choose_from_menu($restore_options, $restore_var, $$restore_var, "");
//choose_from_radio($restore_options, $restore_var, $$restore_var);
//Print the checkbox
print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname));
print_checkbox($restore_var, $$restore_var, $$restore_var, get_string("modulenameplural",$modname),'','selectItemInCheckboxByName(\'form1\',\'restore_'.$modname.'\',this.checked)');
//If backup contains user data, then show menu, else fix it to
//without user data
echo "</td><td align=\"right\">&nbsp;";
@ -223,13 +223,33 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
$restore_user_options[0] = get_string("no");
//choose_from_menu($restore_user_options, $user_info_var, $$user_info_var, "");
//choose_from_radio($restore_user_options, $user_info_var, $$user_info_var);
print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"));
print_checkbox($user_info_var, $$user_info_var, $$user_info_var, get_string("userdata"),'','selectItemInCheckboxByName(\'form1\',\'restore_user_info_'.$modname.'\',this.checked)');
} else {
//Module haven't userdata
echo get_string("withoutuserdata");
echo "<input type=\"hidden\" name=\"$user_info_var\" value=\"0\" />";
}
echo "</td></tr>";
$instances = $info->mods[$modname]->instances;
if (!empty($instances) && is_array($instances)) {
echo '<tr><td></td><td colspan="3"><table class="restore-form-instances">';
foreach ($instances as $instance) {
echo '<tr><td>';
$var = 'restore_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,1);
print_checkbox($var,$$var,$$var,$instance->name,$instance->name,'this.form.elements[\'restore_'.$modname.'\'].checked=1;');
echo '</td><td align="right">&nbsp;';
$var = 'restore_user_info_'.$modname.'_instance_'.$instance->id;
$$var = optional_param($var,1);
if ($info->mods[$modname]->instances[$instance->id]->userinfo == 'true') {
print_checkbox($var,$$var,$$var,get_string('userdata'),'','this.form.elements[\'restore_user_info_'.$modname.'\'].checked=1;');
} else {
echo '<input type="hidden" name="'.$var.'" value="0" />';
}
echo '</td></tr>';
}
echo '</table></td></tr>';
}
} else {
//Module isn't restorable
echo "<input type=\"hidden\" name=\"$restore_var\" value=\"0\" />";

@ -336,6 +336,19 @@
} else {
$tab[$elem][1] = get_string("included")." ".get_string("withoutuserdata");
}
if (is_array($mod->instances) && count($mod->instances)) {
foreach ($mod->instances as $instance) {
if ($instance->backup) {
$elem++;
$tab[$elem][0] = $instance->name;
if ($instance->userinfo == 'true') {
$tab[$elem][1] = get_string("included")." ".get_string("withuserdata");
} else {
$tab[$elem][1] = get_string("included")." ".get_string("withoutuserdata");
}
}
}
}
}
$elem++;
}
@ -844,47 +857,51 @@
if (!empty($sect->mods)) {
//For each mod inside section
foreach ($sect->mods as $keym => $mod) {
//Check if we've to restore this module
//Check if we've to restore this module (and instance)
if ($restore->mods[$mod->type]->restore) {
//Get the module id from modules
$module = get_record("modules","name",$mod->type);
if ($module) {
$course_module->course = $restore->course_id;
$course_module->module = $module->id;
$course_module->section = $newid;
$course_module->added = $mod->added;
$course_module->deleted = $mod->deleted;
$course_module->score = $mod->score;
$course_module->indent = $mod->indent;
$course_module->visible = $mod->visible;
if (isset($mod->groupmode)) {
$course_module->groupmode = $mod->groupmode;
}
$course_module->instance = 0;
//NOTE: The instance (new) is calculated and updated in db in the
// final step of the restore. We don't know it yet.
//print_object($course_module); //Debug
//Save it to db
$newidmod = insert_record("course_modules",$course_module);
if ($newidmod) {
//save old and new module id
//In the info field, we save the original instance of the module
//to use it later
backup_putid ($restore->backup_unique_code,"course_modules",
$keym,$newidmod,$mod->instance);
if (!is_array($restore->mods[$mod->type]->instances) // we don't care about per instance
|| (array_key_exists($mod->instance,$restore->mods[$mod->type]->instances)
&& !empty($restore->mods[$mod->type]->instances[$mod->instance]->restore))) {
//Get the module id from modules
$module = get_record("modules","name",$mod->type);
if ($module) {
$course_module->course = $restore->course_id;
$course_module->module = $module->id;
$course_module->section = $newid;
$course_module->added = $mod->added;
$course_module->deleted = $mod->deleted;
$course_module->score = $mod->score;
$course_module->indent = $mod->indent;
$course_module->visible = $mod->visible;
if (isset($mod->groupmode)) {
$course_module->groupmode = $mod->groupmode;
}
$course_module->instance = 0;
//NOTE: The instance (new) is calculated and updated in db in the
// final step of the restore. We don't know it yet.
//print_object($course_module); //Debug
//Save it to db
$newidmod = insert_record("course_modules",$course_module);
if ($newidmod) {
//save old and new module id
//In the info field, we save the original instance of the module
//to use it later
backup_putid ($restore->backup_unique_code,"course_modules",
$keym,$newidmod,$mod->instance);
} else {
$status = false;
}
//Now, calculate the sequence field
if ($status) {
if ($sequence) {
$sequence .= ",".$newidmod;
} else {
$sequence = $newidmod;
}
}
} else {
$status = false;
}
//Now, calculate the sequence field
if ($status) {
if ($sequence) {
$sequence .= ",".$newidmod;
} else {
$sequence = $newidmod;
}
}
} else {
$status = false;
}
}
}
@ -2387,13 +2404,17 @@
echo '<ul>';
//Iterate over each module
foreach ($info as $mod) {
$modrestore = $mod->modtype."_restore_mods";
if (function_exists($modrestore)) {
//print_object ($mod); //Debug
$status = $modrestore($mod,$restore);
} else {
//Something was wrong. Function should exist.
$status = false;
if (!is_array($restore->mods[$mod->modtype]->instances) // we don't care about per instance
|| (array_key_exists($mod->id,$restore->mods[$mod->modtype]->instances)
&& !empty($restore->mods[$mod->modtype]->instances[$mod->id]->restore))) {
$modrestore = $mod->modtype."_restore_mods";
if (function_exists($modrestore)) {
//print_object ($mod); //Debug
$status = $modrestore($mod,$restore);
} else {
//Something was wrong. Function should exist.
$status = false;
}
}
}
echo '</ul>';
@ -3213,6 +3234,23 @@
break;
}
}
if ($this->level == 7) {
switch ($tagName) {
case "ID":
$this->info->tempId = $this->getContents();
$this->info->mods[$this->info->tempName]->instances[$this->info->tempId]->id = $this->info->tempId;
break;
case "NAME":
$this->info->mods[$this->info->tempName]->instances[$this->info->tempId]->name = $this->getContents();
break;
case "INCLUDED":
$this->info->mods[$this->info->tempName]->instances[$this->info->tempId]->backup = $this->getContents();
break;
case "USERINFO":
$this->info->mods[$this->info->tempName]->instances[$this->info->tempId]->userinfo = $this->getContents();
break;
}
}
}
}
@ -4627,4 +4665,19 @@
return $restore;
}
/**
* compatibility function
* checks for per-instance backups AND
* older per-module backups
* and returns whether userdata has been selected.
*/
function restore_userdata_selected($restore,$modname,$modid) {
// check first for per instance array
if (!empty($restore->mods[$modname]->instances)) { // supports per instance
return array_key_exists($modid,$restore->mods[$modname]->instances)
&& !empty($restore->mods[$modname]->instances[$modid]->userinfo);
}
return !empty($restore->mods[$modname]->userinfo);
}
?>

@ -32,45 +32,61 @@
$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("PREVENTLATE",4,false,$assignment->preventlate));
fwrite ($bf,full_tag("EMAILTEACHERS",4,false,$assignment->emailteachers));
fwrite ($bf,full_tag("VAR1",4,false,$assignment->var1));
fwrite ($bf,full_tag("VAR2",4,false,$assignment->var2));
fwrite ($bf,full_tag("VAR3",4,false,$assignment->var3));
fwrite ($bf,full_tag("VAR4",4,false,$assignment->var4));
fwrite ($bf,full_tag("VAR5",4,false,$assignment->var5));
fwrite ($bf,full_tag("ASSIGNMENTTYPE",4,false,$assignment->assignmenttype));
fwrite ($bf,full_tag("MAXBYTES",4,false,$assignment->maxbytes));
fwrite ($bf,full_tag("TIMEDUE",4,false,$assignment->timedue));
fwrite ($bf,full_tag("TIMEAVAILABLE",4,false,$assignment->timeavailable));
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);
if (backup_mod_selected($preferences,'assignment',$assignment->id)) {
$status = assignment_backup_one_mod($bf,$preferences,$assignment);
// backup files happens in backup_one_mod now too.
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
//if we've selected to backup users info, then backup files too
if ($status) {
if ($preferences->mods["assignment"]->userinfo) {
$status = backup_assignment_files($bf,$preferences);
}
}
return $status;
}
function assignment_backup_one_mod($bf,$preferences,$assignment) {
global $CFG;
if (is_numeric($assignment)) {
$assignment = get_record('assignment','id',$assignment);
}
$status = true;
//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("PREVENTLATE",4,false,$assignment->preventlate));
fwrite ($bf,full_tag("EMAILTEACHERS",4,false,$assignment->emailteachers));
fwrite ($bf,full_tag("VAR1",4,false,$assignment->var1));
fwrite ($bf,full_tag("VAR2",4,false,$assignment->var2));
fwrite ($bf,full_tag("VAR3",4,false,$assignment->var3));
fwrite ($bf,full_tag("VAR4",4,false,$assignment->var4));
fwrite ($bf,full_tag("VAR5",4,false,$assignment->var5));
fwrite ($bf,full_tag("ASSIGNMENTTYPE",4,false,$assignment->assignmenttype));
fwrite ($bf,full_tag("MAXBYTES",4,false,$assignment->maxbytes));
fwrite ($bf,full_tag("TIMEDUE",4,false,$assignment->timedue));
fwrite ($bf,full_tag("TIMEAVAILABLE",4,false,$assignment->timeavailable));
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 and
//backup_assignment_files_instance
if (backup_userdata_selected($preferences,'assignment',$assignment->id)) {
$status = backup_assignment_submissions($bf,$preferences,$assignment->id);
if ($status) {
$status = backup_assignment_files_instance($bf,$preferences,$assignment->id);
}
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup assignment_submissions contents (executed from assignment_backup_mods)
function backup_assignment_submissions ($bf,$preferences,$assignment) {
@ -134,8 +150,38 @@
}
function backup_assignment_files_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/assignment/",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."/assignment/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/assignment/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/assignment/".$instanceid);
}
}
return $status;
}
//Return an array of info (name,value)
function assignment_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function assignment_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += assignment_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","assignment");
if ($ids = assignment_ids ($course)) {
@ -156,6 +202,21 @@
return $info;
}
//Return an array of info (name,value)
function assignment_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("submissions","assignment");
if ($ids = assignment_submission_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function assignment_encode_content_links ($content,$preferences) {
@ -198,4 +259,14 @@
WHERE a.course = '$course' AND
s.assignment = a.id");
}
//Returns an array of assignment_submissions id
function assignment_submission_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.assignment
FROM {$CFG->prefix}assignment_submissions s
WHERE s.assignment = $instanceid");
}
?>

@ -87,7 +87,7 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['assignment']->userinfo) {
if (restore_userdata_selected($restore,'assignment',$mod->id)) {
//Restore assignmet_submissions
$status = assignment_submissions_restore_mods ($mod->id, $newid,$info,$restore);
}

@ -32,29 +32,46 @@
$chats = get_records ("chat","course",$preferences->backup_course,"id");
if ($chats) {
foreach ($chats as $chat) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print chat data
fwrite ($bf,full_tag("ID",4,false,$chat->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"chat"));
fwrite ($bf,full_tag("NAME",4,false,$chat->name));
fwrite ($bf,full_tag("INTRO",4,false,$chat->intro));
fwrite ($bf,full_tag("KEEPDAYS",4,false,$chat->keepdays));
fwrite ($bf,full_tag("STUDENTLOGS",4,false,$chat->studentlogs));
fwrite ($bf,full_tag("SCHEDULE",4,false,$chat->schedule));
fwrite ($bf,full_tag("CHATTIME",4,false,$chat->chattime));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$chat->timemodified));
//if we've selected to backup users info, then execute backup_chat_messages
if ($preferences->mods["chat"]->userinfo) {
$status = backup_chat_messages($bf,$preferences,$chat->id);
if (backup_mod_selected($preferences,'chat',$chat->id)) {
$status = chat_backup_one_mod($bf,$preferences,$chat);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
}
function chat_backup_one_mod($bf,$preferences,$chat) {
global $CFG;
if (is_numeric($chat)) {
$chat = get_record('chat','id',$chat);
}
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print chat data
fwrite ($bf,full_tag("ID",4,false,$chat->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"chat"));
fwrite ($bf,full_tag("NAME",4,false,$chat->name));
fwrite ($bf,full_tag("INTRO",4,false,$chat->intro));
fwrite ($bf,full_tag("KEEPDAYS",4,false,$chat->keepdays));
fwrite ($bf,full_tag("STUDENTLOGS",4,false,$chat->studentlogs));
fwrite ($bf,full_tag("SCHEDULE",4,false,$chat->schedule));
fwrite ($bf,full_tag("CHATTIME",4,false,$chat->chattime));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$chat->timemodified));
//if we've selected to backup users info, then execute backup_chat_messages
if (backup_userdata_selected($preferences,'chat',$chat->id)) {
$status = backup_chat_messages($bf,$preferences,$chat->id);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup chat_messages contents (executed from chat_backup_mods)
function backup_chat_messages ($bf,$preferences,$chat) {
@ -88,7 +105,15 @@
}
//Return an array of info (name,value)
function chat_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function chat_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += chat_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","chat");
if ($ids = chat_ids ($course)) {
@ -109,6 +134,24 @@
return $info;
}
//Return an array of info (name,value)
function chat_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("messages","chat");
if ($ids = chat_message_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function chat_encode_content_links ($content,$preferences) {
@ -151,4 +194,14 @@
WHERE c.course = '$course' AND
m.chatid = c.id");
}
//Returns an array of chat id
function chat_message_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT m.id , m.chatid
FROM {$CFG->prefix}chat_messages m
WHERE m.chatid = $instanceid");
}
?>

@ -60,7 +60,7 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['chat']->userinfo) {
if (restore_userdata_selected($restore,'chat',$mod->id)) {
//Restore chat_messages
$status = chat_messages_restore_mods ($mod->id, $newid,$info,$restore);
}

@ -36,38 +36,55 @@
$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("PUBLISH",4,false,$choice->publish));
fwrite ($bf,full_tag("RELEASE",4,false,$choice->release));
fwrite ($bf,full_tag("DISPLAY",4,false,$choice->display));
fwrite ($bf,full_tag("ALLOWUPDATE",4,false,$choice->allowupdate));
fwrite ($bf,full_tag("SHOWUNANSWERED",4,false,$choice->showunanswered));
fwrite ($bf,full_tag("LIMITANSWERS",4,false,$choice->limitanswers));
fwrite ($bf,full_tag("TIMEOPEN",4,false,$choice->timeopen));
fwrite ($bf,full_tag("TIMECLOSE",4,false,$choice->timeclose));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified));
//Now backup choice_options
$status = backup_choice_options($bf,$preferences,$choice->id);
//if we've selected to backup users info, then execute backup_choice_answers
if ($preferences->mods["choice"]->userinfo && $status) {
$status = backup_choice_answers($bf,$preferences,$choice->id);
if (backup_mod_selected($preferences,'choice',$choice->id)) {
$status = choice_backup_one_mod($bf,$preferences,$choice);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
}
function choice_backup_one_mod($bf,$preferences,$choice) {
global $CFG;
if (is_numeric($choice)) {
$choice = get_record('choice','id',$choice);
}
$status = true;
//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("PUBLISH",4,false,$choice->publish));
fwrite ($bf,full_tag("RELEASE",4,false,$choice->release));
fwrite ($bf,full_tag("DISPLAY",4,false,$choice->display));
fwrite ($bf,full_tag("ALLOWUPDATE",4,false,$choice->allowupdate));
fwrite ($bf,full_tag("SHOWUNANSWERED",4,false,$choice->showunanswered));
fwrite ($bf,full_tag("LIMITANSWERS",4,false,$choice->limitanswers));
fwrite ($bf,full_tag("TIMEOPEN",4,false,$choice->timeopen));
fwrite ($bf,full_tag("TIMECLOSE",4,false,$choice->timeclose));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified));
//Now backup choice_options
$status = backup_choice_options($bf,$preferences,$choice->id);
//if we've selected to backup users info, then execute backup_choice_answers
if (backup_userdata_selected($preferences,'choice',$choice->id)) {
$status = backup_choice_answers($bf,$preferences,$choice->id);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup choice_answers contents (executed from choice_backup_mods)
function backup_choice_answers ($bf,$preferences,$choice) {
@ -130,7 +147,15 @@
}
////Return an array of info (name,value)
function choice_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function choice_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += choice_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","choice");
if ($ids = choice_ids ($course)) {
@ -151,6 +176,24 @@
return $info;
}
////Return an array of info (name,value)
function choice_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("responses","choice");
if ($ids = choice_answer_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function choice_encode_content_links ($content,$preferences) {
@ -193,4 +236,14 @@
WHERE a.course = '$course' AND
s.choiceid = a.id");
}
//Returns an array of choice_answers id
function choice_answer_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.choiceid
FROM {$CFG->prefix}choice_answers s
WHERE s.choiceid = $instanceid");
}
?>

@ -116,7 +116,7 @@
}
//now restore the answers for this choice.
if ($restore->mods['choice']->userinfo) {
if (restore_userdata_selected($restore,'choice',$mod->id)) {
//Restore choice_answers
$status = choice_answers_restore_mods($newid,$info,$restore);
}

94
mod/data/backuplib.php Normal file

@ -0,0 +1,94 @@
<?php
/* THIS IS A STUB BACKUPLIB.PHP TO
* DEMONSTRATE THE NEW GRANULAR
* BACKUP/RESTORE API.
* IT NEEDS TO BE FILLED OUT!!!
*/
function data_backup_mods($bf,$preferences) {
global $CFG;
$status = true;
// iterate
if ($datas = get_records('data','course',$preferences->backup_course,"id")) {
foreach ($datas as $data) {
if (backup_mod_selected($preferences,'data',$data->id)) {
$status = data_backup_one_mod($bf,$preferences,$data);
// backup files happens in backup_one_mod now too.
}
}
}
return $status;
}
function data_backup_one_mod($bf,$preferences,$data) {
global $CFG;
if (is_numeric($data)) { // backwards compatibility
$data = get_record('data','id',$data);
}
$instanceid = $data->id;
$status = true;
// Start mod
// fwrite ($bf,start_tag("MOD",3,true));
// Print data
// fwrite($bf,full_tag("ID",4,false,$data->id));
// ... etc
// if we've selected to backup users info, then call any other functions we need
// including backing up individual files
if (backup_userdata_selected($preferences,'data',$data->id)) {
//$status = backup_someuserdata_for_this_instance();
//$status = backup_somefiles_for_this_instance();
// ... etc
}
// End mod
// $status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
function data_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
// any other needed stuff
}
return $info;
}
function data_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += data_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
// otherwise continue as normal
//First the course data
$info[0][0] = get_string("modulenameplural","data");
if ($ids = data_ids ($course)) {
$info[0][1] = count($ids);
} else {
$info[0][1] = 0;
}
//Now, if requested, the user_data
if ($user_data) {
// any other needed stuff
}
return $info;
}
function data_ids($course) {
// stub function, return number of modules
return 1;
}

31
mod/data/restorelib.php Normal file

@ -0,0 +1,31 @@
<?php
/* THIS IS A STUB RESTORELIB.PHP TO
* DEMONSTRATE THE NEW GRANULAR
* BACKUP/RESTORE API.
* IT NEEDS TO BE FILLED OUT!!!
*/
function data_restore_mods($mod,$restore) {
global $CFG;
$status = true;
// this all carries on exactly like normal except where checking for user data do
if (restore_userdata_selected($restore,'data',$mod->id)) {
// restore userdata, including files.
}
// instead of the old way:
// if ($restore->mods['data']->userinfo) {
// this should be the ONLY CHANGE IN THIS FILE.
return $status;
}
?>

@ -47,45 +47,62 @@
$exercises = get_records ("exercise","course",$preferences->backup_course,"id");
if ($exercises) {
foreach ($exercises as $exercise) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print exercise data
fwrite ($bf,full_tag("ID",4,false,$exercise->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"exercise"));
fwrite ($bf,full_tag("NAME",4,false,$exercise->name));
fwrite ($bf,full_tag("NELEMENTS",4,false,$exercise->nelements));
fwrite ($bf,full_tag("PHASE",4,false,$exercise->phase));
fwrite ($bf,full_tag("GRADINGSTRATEGY",4,false,$exercise->gradingstrategy));
fwrite ($bf,full_tag("USEMAXIMUM",4,false,$exercise->usemaximum));
fwrite ($bf,full_tag("ASSESSMENTCOMPS",4,false,$exercise->assessmentcomps));
fwrite ($bf,full_tag("ANONYMOUS",4,false,$exercise->anonymous));
fwrite ($bf,full_tag("MAXBYTES",4,false,$exercise->maxbytes));
fwrite ($bf,full_tag("DEADLINE",4,false,$exercise->deadline));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$exercise->timemodified));
fwrite ($bf,full_tag("GRADE",4,false,$exercise->grade));
fwrite ($bf,full_tag("GRADINGGRADE",4,false,$exercise->gradinggrade));
fwrite ($bf,full_tag("SHOWLEAGUETABLE",4,false,$exercise->showleaguetable));
fwrite ($bf,full_tag("USEPASSWORD",4,false,$exercise->usepassword));
fwrite ($bf,full_tag("PASSWORD",4,false,$exercise->password));
//Now we backup exercise elements
$status = backup_exercise_elements($bf,$preferences,$exercise->id);
//Now we backup any teacher submissions (these are an integral part of the exercise)
$status = backup_exercise_submissions($bf, $preferences, $exercise->id);
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
//we need to backup the teacher files (the exercise descriptions)
$status = backup_exercise_teacher_files($bf, $preferences, $exercise->id);
//if we've selected to backup users info, then backup files too
if ($status) {
if ($preferences->mods["exercise"]->userinfo) {
$status = backup_exercise_student_files($bf,$preferences, $exercise->id);
}
if (backup_mod_selected($preferences,'exercise',$exercise->id)) {
$status = exercise_backup_one_mod($bf,$preferences,$exercise);
}
}
}
return $status;
}
function exercise_backup_one_mod($bf,$preferences,$exercise) {
global $CFG;
if (is_numeric($exercise)) {
$exercise = get_record('exercise','id',$exercise);
}
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print exercise data
fwrite ($bf,full_tag("ID",4,false,$exercise->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"exercise"));
fwrite ($bf,full_tag("NAME",4,false,$exercise->name));
fwrite ($bf,full_tag("NELEMENTS",4,false,$exercise->nelements));
fwrite ($bf,full_tag("PHASE",4,false,$exercise->phase));
fwrite ($bf,full_tag("GRADINGSTRATEGY",4,false,$exercise->gradingstrategy));
fwrite ($bf,full_tag("USEMAXIMUM",4,false,$exercise->usemaximum));
fwrite ($bf,full_tag("ASSESSMENTCOMPS",4,false,$exercise->assessmentcomps));
fwrite ($bf,full_tag("ANONYMOUS",4,false,$exercise->anonymous));
fwrite ($bf,full_tag("MAXBYTES",4,false,$exercise->maxbytes));
fwrite ($bf,full_tag("DEADLINE",4,false,$exercise->deadline));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$exercise->timemodified));
fwrite ($bf,full_tag("GRADE",4,false,$exercise->grade));
fwrite ($bf,full_tag("GRADINGGRADE",4,false,$exercise->gradinggrade));
fwrite ($bf,full_tag("SHOWLEAGUETABLE",4,false,$exercise->showleaguetable));
fwrite ($bf,full_tag("USEPASSWORD",4,false,$exercise->usepassword));
fwrite ($bf,full_tag("PASSWORD",4,false,$exercise->password));
//Now we backup exercise elements
$status = backup_exercise_elements($bf,$preferences,$exercise->id);
//Now we backup any teacher submissions (these are an integral part of the exercise)
$status = backup_exercise_submissions($bf, $preferences, $exercise->id);
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
//we need to backup the teacher files (the exercise descriptions)
$status = backup_exercise_teacher_files($bf, $preferences, $exercise->id);
//if we've selected to backup users info, then backup files too
if ($status) {
if (backup_userdata_selected($preferences,'exercise',$exercise->id)) {
$status = backup_exercise_student_files($bf,$preferences, $exercise->id);
}
}
return $status;
}
//Backup exercise_elements contents (executed from exercise_backup_mods)
function backup_exercise_elements ($bf,$preferences,$exercise) {
@ -177,14 +194,14 @@
fwrite ($bf,full_tag("ISEXERCISE",6,false,$submission->isexercise));
fwrite ($bf,full_tag("LATE",6,false,$submission->late));
//Now we backup any exercise assessments (if student data required)
if ($preferences->mods["exercise"]->userinfo) {
if (backup_userdata_selected($preferences,'exercise',$exerciseid)) {
$status = backup_exercise_assessments($bf,$preferences,$exerciseid,$submission->id);
}
//End submission
$status =fwrite ($bf,end_tag("SUBMISSION",5,true));
}
//if we've selected to backup users info, then backup the student submisions
if ($preferences->mods["exercise"]->userinfo) {
if (backup_userdata_selected($preferences,'exercise',$exerciseid)) {
$exercise_submissions = get_records_select("exercise_submissions","exerciseid = $exerciseid
AND isexercise = 0");
//If there is submissions
@ -362,7 +379,14 @@
}
//Return an array of info (name,value)
function exercise_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function exercise_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += exercise_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","exercise");
if ($ids = exercise_ids ($course)) {
@ -383,6 +407,24 @@
return $info;
}
//Return an array of info (name,value)
function exercise_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("submissions","exercise");
if ($ids = exercise_submission_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
@ -411,4 +453,14 @@
WHERE w.course = '$course' AND
s.exerciseid = w.id");
}
//Returns an array of exercise_submissions id
function exercise_submission_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.exerciseid
FROM {$CFG->prefix}exercise_submissions s
WHERE s.exerciseid = $instanceid");
}
?>

@ -221,7 +221,7 @@
$submission->late = backup_todb($sub_info['#']['LATE']['0']['#']);
// always save the exercise descriptions and optionally the student submissions
if ($submission->isexercise or $restore->mods["exercise"]->userinfo) {
if ($submission->isexercise or restore_userdata_selected($restore,'exercise',$old_exercise_id)) {
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$olduserid);
if ($user) {
@ -248,7 +248,7 @@
//Now copy moddata associated files
$status = exercise_restore_files($oldid, $newid,$restore);
//Now we need to restore exercise_assessments (user level table)
if ($status and $restore->mods['exercise']->userinfo) {
if ($status and restore_userdata_selected($restore,'exercise',$old_exercise_id)) {
$status = exercise_assessments_restore($new_exercise_id, $newid,$sub_info,$restore);
}
} else {

@ -42,51 +42,103 @@
$forums = get_records ("forum","course",$preferences->backup_course,"id");
if ($forums) {
foreach ($forums as $forum) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print forum data
fwrite ($bf,full_tag("ID",4,false,$forum->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"forum"));
fwrite ($bf,full_tag("TYPE",4,false,$forum->type));
fwrite ($bf,full_tag("NAME",4,false,$forum->name));
fwrite ($bf,full_tag("INTRO",4,false,$forum->intro));
fwrite ($bf,full_tag("OPEN",4,false,$forum->open));
fwrite ($bf,full_tag("ASSESSED",4,false,$forum->assessed));
fwrite ($bf,full_tag("ASSESSPUBLIC",4,false,$forum->assesspublic));
fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$forum->assesstimestart));
fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$forum->assesstimefinish));
fwrite ($bf,full_tag("MAXBYTES",4,false,$forum->maxbytes));
fwrite ($bf,full_tag("SCALE",4,false,$forum->scale));
fwrite ($bf,full_tag("FORCESUBSCRIBE",4,false,$forum->forcesubscribe));
fwrite ($bf,full_tag("TRACKINGTYPE",4,false,$forum->trackingtype));
fwrite ($bf,full_tag("RSSTYPE",4,false,$forum->rsstype));
fwrite ($bf,full_tag("RSSARTICLES",4,false,$forum->rssarticles));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$forum->timemodified));
//if we've selected to backup users info, then execute backup_forum_suscriptions and
//backup_forum_discussions
if ($preferences->mods["forum"]->userinfo) {
$status = backup_forum_subscriptions($bf,$preferences,$forum->id);
if ($status) {
$status = backup_forum_discussions($bf,$preferences,$forum->id);
}
if ($status) {
$status = backup_forum_read($bf,$preferences,$forum->id);
}
if (backup_mod_selected($preferences,'forum',$forum->id)) {
$status = forum_backup_one_mod($bf,$preferences,$forum);
// backup files happens in backup_one_mod now too.
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
//if we've selected to backup users info, then backup files too
if ($status) {
if ($preferences->mods["forum"]->userinfo) {
$status = backup_forum_files($bf,$preferences);
}
}
return $status;
}
function forum_backup_one_mod($bf,$preferences,$forum) {
global $CFG;
if (is_numeric($forum)) {
$forum = get_record('forum','id',$forum);
}
$instanceid = $forum->id;
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print forum data
fwrite ($bf,full_tag("ID",4,false,$forum->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"forum"));
fwrite ($bf,full_tag("TYPE",4,false,$forum->type));
fwrite ($bf,full_tag("NAME",4,false,$forum->name));
fwrite ($bf,full_tag("INTRO",4,false,$forum->intro));
fwrite ($bf,full_tag("OPEN",4,false,$forum->open));
fwrite ($bf,full_tag("ASSESSED",4,false,$forum->assessed));
fwrite ($bf,full_tag("ASSESSPUBLIC",4,false,$forum->assesspublic));
fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$forum->assesstimestart));
fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$forum->assesstimefinish));
fwrite ($bf,full_tag("MAXBYTES",4,false,$forum->maxbytes));
fwrite ($bf,full_tag("SCALE",4,false,$forum->scale));
fwrite ($bf,full_tag("FORCESUBSCRIBE",4,false,$forum->forcesubscribe));
fwrite ($bf,full_tag("TRACKINGTYPE",4,false,$forum->trackingtype));
fwrite ($bf,full_tag("RSSTYPE",4,false,$forum->rsstype));
fwrite ($bf,full_tag("RSSARTICLES",4,false,$forum->rssarticles));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$forum->timemodified));
//if we've selected to backup users info, then execute backup_forum_suscriptions and
//backup_forum_discussions
if (backup_userdata_selected($preferences,'forum',$forum->id)) {
$status = backup_forum_subscriptions($bf,$preferences,$forum->id);
if ($status) {
$status = backup_forum_discussions($bf,$preferences,$forum->id);
}
if ($status) {
$status = backup_forum_read($bf,$preferences,$forum->id);
}
if ($status) {
$status = backup_forum_files_instance($bf,$preferences,$forum->id);
}
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
function forum_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("subscriptions","forum");
if ($ids = forum_subscription_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
//Discussions
$info[$instance->id.'2'][0] = get_string("discussions","forum");
if ($ids = forum_discussion_ids_by_instance ($instance->id)) {
$info[$instance->id.'2'][1] = count($ids);
} else {
$info[$instance->id.'2'][1] = 0;
}
//Posts
$info[$instance->id.'3'][0] = get_string("posts","forum");
if ($ids = forum_post_ids_by_instance ($instance->id)) {
$info[$instance->id.'3'][1] = count($ids);
} else {
$info[$instance->id.'3'][1] = 0;
}
//Ratings
$info[$instance->id.'4'][0] = get_string("ratings","forum");
if ($ids = forum_rating_ids_by_instance ($instance->id)) {
$info[$instance->id.'4'][1] = count($ids);
} else {
$info[$instance->id.'4'][1] = 0;
}
}
return $info;
}
//Backup forum_subscriptions contents (executed from forum_backup_mods)
function backup_forum_subscriptions ($bf,$preferences,$forum) {
@ -259,7 +311,6 @@
//Backup forum files because we've selected to backup user info
//and files are user info's level
function backup_forum_files($bf,$preferences) {
global $CFG;
$status = true;
@ -271,8 +322,15 @@
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum")) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum",
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/forum");
$handle = opendir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum");
while (false!==($item = readdir($handle))) {
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum/".$item)
&& array_key_exists($item,$preferences->mods['forum']->instances)
&& !empty($preferences->mods['forum']->instances[$item]->backup)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum/".$item,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/forum/",$item);
}
}
}
}
@ -281,8 +339,40 @@
}
//Backup forum files because we've selected to backup user info
//and files are user info's level
function backup_forum_files_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/forum/",true);
//Now copy the forum dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/forum/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/forum/".$instanceid);
}
}
return $status;
}
////Return an array of info (name,value)
function forum_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function forum_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += forum_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","forum");
if ($ids = forum_ids ($course)) {
@ -384,6 +474,16 @@
s.forum = a.id");
}
//Returns an array of forum subscriptions id
function forum_subscription_ids_by_instance($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_subscriptions s
WHERE s.forum = $instanceid");
}
//Returns an array of forum discussions id
function forum_discussion_ids_by_course ($course) {
@ -396,6 +496,16 @@
s.forum = a.id");
}
//Returns an array of forum discussions id
function forum_discussion_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.forum
FROM {$CFG->prefix}forum_discussions s
WHERE s.forum = $instanceid");
}
//Returns an array of forum posts id
function forum_post_ids_by_course ($course) {
@ -410,6 +520,18 @@
p.discussion = s.id");
}
//Returns an array of forum posts id
function forum_post_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT p.id , p.discussion, s.forum
FROM {$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s
WHERE s.forum = $instanceid AND
p.discussion = s.id");
}
//Returns an array of ratings posts id
function forum_rating_ids_by_course ($course) {
@ -425,4 +547,18 @@
p.discussion = s.id AND
r.post = p.id");
}
//Returns an array of ratings posts id
function forum_rating_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT r.id, r.post, p.discussion, s.forum
FROM {$CFG->prefix}forum_ratings r,
{$CFG->prefix}forum_posts p,
{$CFG->prefix}forum_discussions s
WHERE s.forum = $instanceid AND
p.discussion = s.id AND
r.post = p.id");
}
?>

@ -100,7 +100,7 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['forum']->userinfo) {
if (restore_userdata_selected($restore,'forum',$mod->id)) {
//Restore forum_subscriptions
$status = forum_subscriptions_restore_mods ($newid,$info,$restore);
if ($status) {

@ -38,50 +38,67 @@
$glossaries = get_records ("glossary","course",$preferences->backup_course,"mainglossary");
if ($glossaries) {
foreach ($glossaries as $glossary) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print glossary data
fwrite ($bf,full_tag("ID",4,false,$glossary->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"glossary"));
fwrite ($bf,full_tag("NAME",4,false,$glossary->name));
fwrite ($bf,full_tag("INTRO",4,false,$glossary->intro));
fwrite ($bf,full_tag("STUDENTCANPOST",4,false,$glossary->studentcanpost));
fwrite ($bf,full_tag("ALLOWDUPLICATEDENTRIES",4,false,$glossary->allowduplicatedentries));
fwrite ($bf,full_tag("DISPLAYFORMAT",4,false,$glossary->displayformat));
fwrite ($bf,full_tag("MAINGLOSSARY",4,false,$glossary->mainglossary));
fwrite ($bf,full_tag("SHOWSPECIAL",4,false,$glossary->showspecial));
fwrite ($bf,full_tag("SHOWALPHABET",4,false,$glossary->showalphabet));
fwrite ($bf,full_tag("SHOWALL",4,false,$glossary->showall));
fwrite ($bf,full_tag("ALLOWCOMMENTS",4,false,$glossary->allowcomments));
fwrite ($bf,full_tag("ALLOWPRINTVIEW",4,false,$glossary->allowprintview));
fwrite ($bf,full_tag("USEDYNALINK",4,false,$glossary->usedynalink));
fwrite ($bf,full_tag("DEFAULTAPPROVAL",4,false,$glossary->defaultapproval));
fwrite ($bf,full_tag("GLOBALGLOSSARY",4,false,$glossary->globalglossary));
fwrite ($bf,full_tag("ENTBYPAGE",4,false,$glossary->entbypage));
fwrite ($bf,full_tag("EDITALWAYS",4,false,$glossary->editalways));
fwrite ($bf,full_tag("RSSTYPE",4,false,$glossary->rsstype));
fwrite ($bf,full_tag("RSSARTICLES",4,false,$glossary->rssarticles));
fwrite ($bf,full_tag("TIMECREATED",4,false,$glossary->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$glossary->timemodified));
fwrite ($bf,full_tag("ASSESSED",4,false,$glossary->assessed));
fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$glossary->assesstimestart));
fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$glossary->assesstimefinish));
fwrite ($bf,full_tag("SCALE",4,false,$glossary->scale));
//Only if preferences->backup_users != 2 (none users). Else, teachers entries will be included.
if ($preferences->backup_users != 2) {
backup_glossary_entries($bf,$preferences,$glossary->id, $preferences->mods["glossary"]->userinfo);
if (backup_mod_selected($preferences,'glossary',$glossary->id)) {
$status = glossary_backup_one_mod($bf,$preferences,$glossary);
}
backup_glossary_categories($bf,$preferences,$glossary->id, $preferences->mods["glossary"]->userinfo);
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
}
function glossary_backup_one_mod($bf,$preferences,$glossary) {
global $CFG;
if (is_numeric($glossary)) {
$glossary = get_record('glossary','id',$glossary);
}
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print glossary data
fwrite ($bf,full_tag("ID",4,false,$glossary->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"glossary"));
fwrite ($bf,full_tag("NAME",4,false,$glossary->name));
fwrite ($bf,full_tag("INTRO",4,false,$glossary->intro));
fwrite ($bf,full_tag("STUDENTCANPOST",4,false,$glossary->studentcanpost));
fwrite ($bf,full_tag("ALLOWDUPLICATEDENTRIES",4,false,$glossary->allowduplicatedentries));
fwrite ($bf,full_tag("DISPLAYFORMAT",4,false,$glossary->displayformat));
fwrite ($bf,full_tag("MAINGLOSSARY",4,false,$glossary->mainglossary));
fwrite ($bf,full_tag("SHOWSPECIAL",4,false,$glossary->showspecial));
fwrite ($bf,full_tag("SHOWALPHABET",4,false,$glossary->showalphabet));
fwrite ($bf,full_tag("SHOWALL",4,false,$glossary->showall));
fwrite ($bf,full_tag("ALLOWCOMMENTS",4,false,$glossary->allowcomments));
fwrite ($bf,full_tag("ALLOWPRINTVIEW",4,false,$glossary->allowprintview));
fwrite ($bf,full_tag("USEDYNALINK",4,false,$glossary->usedynalink));
fwrite ($bf,full_tag("DEFAULTAPPROVAL",4,false,$glossary->defaultapproval));
fwrite ($bf,full_tag("GLOBALGLOSSARY",4,false,$glossary->globalglossary));
fwrite ($bf,full_tag("ENTBYPAGE",4,false,$glossary->entbypage));
fwrite ($bf,full_tag("EDITALWAYS",4,false,$glossary->editalways));
fwrite ($bf,full_tag("RSSTYPE",4,false,$glossary->rsstype));
fwrite ($bf,full_tag("RSSARTICLES",4,false,$glossary->rssarticles));
fwrite ($bf,full_tag("TIMECREATED",4,false,$glossary->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$glossary->timemodified));
fwrite ($bf,full_tag("ASSESSED",4,false,$glossary->assessed));
fwrite ($bf,full_tag("ASSESSTIMESTART",4,false,$glossary->assesstimestart));
fwrite ($bf,full_tag("ASSESSTIMEFINISH",4,false,$glossary->assesstimefinish));
fwrite ($bf,full_tag("SCALE",4,false,$glossary->scale));
//Only if preferences->backup_users != 2 (none users). Else, teachers entries will be included.
if ($preferences->backup_users != 2) {
backup_glossary_entries($bf,$preferences,$glossary->id, $preferences->mods["glossary"]->userinfo);
}
backup_glossary_categories($bf,$preferences,$glossary->id, $preferences->mods["glossary"]->userinfo);
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup glossary_categories and entries_categories contents (executed from glossary_backup_mods)
function backup_glossary_categories ($bf,$preferences,$glossary, $userinfo) {
@ -314,7 +331,14 @@
}
////Return an array of info (name,value)
function glossary_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function glossary_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += glossary_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","glossary");
if ($ids = glossary_ids ($course)) {
@ -335,6 +359,24 @@
return $info;
}
////Return an array of info (name,value)
function glossary_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("concepts","glossary");
if ($ids = glossary_entries_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function glossary_encode_content_links ($content,$preferences) {
@ -377,4 +419,14 @@
WHERE a.course = '$course' AND
s.glossaryid = a.id");
}
//Returns an array of glossary_answers id
function glossary_entries_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.glossaryid
FROM {$CFG->prefix}glossary_entries s
WHERE s.glossaryid = $instanceid");
}
?>

@ -182,7 +182,7 @@
$entry->sourceglossaryid = $source->new_id;
}
//If it's a teacher entry or userinfo was selected, restore the entry
if ($entry->teacherentry or $restore->mods['glossary']->userinfo) {
if ($entry->teacherentry or restore_userdata_selected($restore,'glossary',$old_glossary_id)) {
//The structure is equal to the db, so insert the glossary_entries
$newid = insert_record ("glossary_entries",$entry);

@ -36,19 +36,36 @@
//
//-----------------------------------------------------------
function hotpot_backup_mods($bf, $preferences) {
global $CFG;
$status = true;
//Iterate over hotpot table
$hotpots = get_records ("hotpot","course",$preferences->backup_course,"id");
if ($hotpots) {
foreach ($hotpots as $hotpot) {
if (backup_mod_selected($preferences,'hotpot',$hotpot->id)) {
$status = hotpot_backup_one_mod($bf,$preferences,$hotpot->id);
}
}
}
return $status;
}
function hotpot_backup_one_mod($bf, $preferences, $instance = 0) {
// $bf : resource id for b(ackup) f(ile)
// $preferences : object containing switches and settings for this backup
$level = 3;
$status = true;
$table = 'hotpot';
$select = "course=$preferences->backup_course";
$select = "course=$preferences->backup_course AND id='$instance'";
$records_tag = '';
$records_tags = array();
$record_tag = 'MOD';
$record_tags = array('MODTYPE'=>'hotpot');
$excluded_tags = array();
$more_backup = '';
if ($preferences->mods['hotpot']->userinfo) {
if (backup_userdata_selected($preferences,'hotpot',$instance)) {
$more_backup .= '$GLOBALS["hotpot_backup_string_ids"] = array();';
$more_backup .= '$status = hotpot_backup_attempts($bf, $record, $level, $status);';
$more_backup .= '$status = hotpot_backup_questions($bf, $record, $level, $status);';
@ -250,7 +267,15 @@
return $status;
}
////Return an array of info (name, value)
function hotpot_check_backup_mods($course, $user_data=false, $backup_unique_code) {
function hotpot_check_backup_mods($course, $user_data=false, $backup_unique_code, $instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += hotpot_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
// the course data
$info[0][0] = get_string('modulenameplural','hotpot');
$info[0][1] = count_records('hotpot', 'course', $course);
@ -264,4 +289,24 @@
}
return $info;
}
////Return an array of info (name, value)
function hotpot_check_backup_mods_instances($instance,$backup_unique_code) {
// the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
// the user_data, if requested
if (!empty($instance->userdata)) {
global $CFG;
$table = "{$CFG->prefix}hotpot_attempts a";
$select = "a.hotpot = $instance->id";
$info[$instance->id.'1'][0] = get_string('attempts', 'quiz');
$info[$instance->id.'1'][1] = count_records_sql("SELECT COUNT(*) FROM $table WHERE $select");
}
return $info;
}
?>

@ -73,7 +73,7 @@ function hotpot_restore_mods($mod, $restore) {
// print a message after each hotpot is backed up
$more_restore .= 'print "<li>".get_string("modulename", "hotpot")." &quot;".$record->name."&quot;</li>";';
$more_restore .= 'backup_flush(300);';
if ($restore->mods['hotpot']->userinfo) {
if (restore_userdata_selected($restore,'hotpot',$mod->id)) {
if (isset($xml["STRING_DATA"]) && isset($xml["QUESTION_DATA"])) {
// HotPot v2.1+
$more_restore .= '$status = hotpot_restore_strings($restore, $status, $xml, $record);';

@ -31,29 +31,46 @@
$journals = get_records ("journal","course",$preferences->backup_course,"id");
if ($journals) {
foreach ($journals as $journal) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print journal data
fwrite ($bf,full_tag("ID",4,false,$journal->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"journal"));
fwrite ($bf,full_tag("NAME",4,false,$journal->name));
fwrite ($bf,full_tag("INTRO",4,false,$journal->intro));
fwrite ($bf,full_tag("INTROFORMAT",4,false,$journal->introformat));
fwrite ($bf,full_tag("DAYS",4,false,$journal->days));
fwrite ($bf,full_tag("ASSESSED",4,false,$journal->assessed));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$journal->timemodified));
//if we've selected to backup users info, then execute backup_journal_entries
if ($preferences->mods["journal"]->userinfo) {
$status = backup_journal_entries($bf,$preferences,$journal->id);
if (backup_mod_selected($preferences,'journal',$journal->id)) {
$status = journal_backup_one_mod($bf,$preferences,$journal);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
}
function journal_backup_one_mod($bf,$preferences,$journal) {
global $CFG;
if (is_numeric($journal)) {
$journal = get_record('journal','id',$journal);
}
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print journal data
fwrite ($bf,full_tag("ID",4,false,$journal->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"journal"));
fwrite ($bf,full_tag("NAME",4,false,$journal->name));
fwrite ($bf,full_tag("INTRO",4,false,$journal->intro));
fwrite ($bf,full_tag("INTROFORMAT",4,false,$journal->introformat));
fwrite ($bf,full_tag("DAYS",4,false,$journal->days));
fwrite ($bf,full_tag("ASSESSED",4,false,$journal->assessed));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$journal->timemodified));
//if we've selected to backup users info, then execute backup_journal_entries
if (backup_userdata_selected($preferences,'journal',$journal->id)) {
$status = backup_journal_entries($bf,$preferences,$journal->id);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup journal_entries contents (executed from journal_backup_mods)
function backup_journal_entries ($bf,$preferences,$journal) {
@ -91,7 +108,14 @@
}
////Return an array of info (name,value)
function journal_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function journal_check_backup_mods($course,$user_data=false,$backup_unique_code, $instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += journal_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","journal");
if ($ids = journal_ids ($course)) {
@ -112,6 +136,23 @@
return $info;
}
////Return an array of info (name,value)
function journal_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("entries","journal");
if ($ids = journal_entry_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
@ -140,4 +181,14 @@
WHERE a.course = '$course' AND
s.journal = a.id");
}
//Returns an array of journal entries id
function journal_entry_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.journal
FROM {$CFG->prefix}journal_entries s
WHERE s.journal = $instanceid");
}
?>

@ -67,7 +67,7 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['journal']->userinfo) {
if (restore_userdata_selected($restore,'journal',$mod->id)) {
//Restore journal_entries
$status = journal_entries_restore_mods ($mod->id, $newid,$info,$restore);
}

@ -25,27 +25,60 @@
////Iterate over label table
if ($labels = get_records ("label","course", $preferences->backup_course,"id")) {
foreach ($labels as $label) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$label->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"label"));
fwrite ($bf,full_tag("NAME",4,false,$label->name));
fwrite ($bf,full_tag("CONTENT",4,false,$label->content));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$label->timemodified));
//End mod
$status = fwrite ($bf,end_tag("MOD",3,true));
if (backup_mod_selected($preferences,'label',$label->id)) {
$status = label_backup_one_mod($bf,$preferences,$label);
}
}
}
return $status;
}
function label_backup_one_mod($bf,$preferences,$label) {
global $CFG;
if (is_numeric($label)) {
$label = get_record('label','id',$label);
}
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$label->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"label"));
fwrite ($bf,full_tag("NAME",4,false,$label->name));
fwrite ($bf,full_tag("CONTENT",4,false,$label->content));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$label->timemodified));
//End mod
$status = fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
////Return an array of info (name,value)
function label_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function label_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += label_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","label");
$info[0][1] = count_records("label", "course", "$course");
return $info;
}
////Return an array of info (name,value)
function label_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
return $info;
}
?>

@ -45,72 +45,89 @@
$lessons = get_records("lesson", "course", $preferences->backup_course, "id");
if ($lessons) {
foreach ($lessons as $lesson) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print lesson data
fwrite ($bf,full_tag("ID",4,false,$lesson->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"lesson"));
fwrite ($bf,full_tag("NAME",4,false,$lesson->name));
fwrite ($bf,full_tag("PRACTICE",4,false,$lesson->practice));
fwrite ($bf,full_tag("MODATTEMPTS",4,false,$lesson->modattempts));
fwrite ($bf,full_tag("PASSWORD",4,false,$lesson->password));
fwrite ($bf,full_tag("USEPASSWORD",4,false,$lesson->usepassword));
fwrite ($bf,full_tag("DEPENDENCY",4,false,$lesson->dependency));
fwrite ($bf,full_tag("CONDITIONS",4,false,$lesson->conditions));
fwrite ($bf,full_tag("GRADE",4,false,$lesson->grade));
fwrite ($bf,full_tag("CUSTOM",4,false,$lesson->custom));
fwrite ($bf,full_tag("ONGOING",4,false,$lesson->ongoing));
fwrite ($bf,full_tag("USEMAXGRADE",4,false,$lesson->usemaxgrade));
fwrite ($bf,full_tag("MAXANSWERS",4,false,$lesson->maxanswers));
fwrite ($bf,full_tag("MAXATTEMPTS",4,false,$lesson->maxattempts));
fwrite ($bf,full_tag("REVIEW",4,false,$lesson->review));
fwrite ($bf,full_tag("NEXTPAGEDEFAULT",4,false,$lesson->nextpagedefault));
fwrite ($bf,full_tag("MINQUESTIONS",4,false,$lesson->minquestions));
fwrite ($bf,full_tag("MAXPAGES",4,false,$lesson->maxpages));
fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed));
fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime));
fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake));
fwrite ($bf,full_tag("TREE",4,false,$lesson->tree));
fwrite ($bf,full_tag("MEDIAFILE",4,false,$lesson->mediafile));
fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow));
fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$lesson->height));
fwrite ($bf,full_tag("BGCOLOR",4,false,$lesson->bgcolor));
fwrite ($bf,full_tag("DISPLAYLEFT",4,false,$lesson->displayleft));
fwrite ($bf,full_tag("SHOWHIGHSCORES",4,false,$lesson->highscores));
fwrite ($bf,full_tag("MAXHIGHSCORES",4,false,$lesson->maxhighscores));
fwrite ($bf,full_tag("AVAILABLE",4,false,$lesson->available));
fwrite ($bf,full_tag("DEADLINE",4,false,$lesson->deadline));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$lesson->timemodified));
//Now we backup lesson pages
$status = backup_lesson_pages($bf,$preferences,$lesson->id);
//if we've selected to backup users info, then backup grades, high scores, and timer info
if ($status) {
if ($preferences->mods["lesson"]->userinfo) {
if(!backup_lesson_grades($bf, $preferences, $lesson->id)) {
return false;
}
if (!backup_lesson_high_scores($bf, $preferences, $lesson->id)) {
return false;
}
if (!backup_lesson_timer($bf, $preferences, $lesson->id)) {
return false;
}
}
// back up the default for the course. There might not be one, but if there
// is, there will only be one.
$status = backup_lesson_default($bf,$preferences);
//End mod
if ($status) {
$status =fwrite ($bf,end_tag("MOD",3,true));
}
if (backup_mod_selected($preferences,'lesson',$lesson->id)) {
$status = lesson_backup_one_mod($bf,$preferences,$lesson);
}
}
}
return $status;
}
function lesson_backup_one_mod($bf,$preferences,$lesson) {
global $CFG;
if (is_numeric($lesson)) {
$lesson = get_record('lesson','id',$lesson);
}
$status = true;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print lesson data
fwrite ($bf,full_tag("ID",4,false,$lesson->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"lesson"));
fwrite ($bf,full_tag("NAME",4,false,$lesson->name));
fwrite ($bf,full_tag("PRACTICE",4,false,$lesson->practice));
fwrite ($bf,full_tag("MODATTEMPTS",4,false,$lesson->modattempts));
fwrite ($bf,full_tag("PASSWORD",4,false,$lesson->password));
fwrite ($bf,full_tag("USEPASSWORD",4,false,$lesson->usepassword));
fwrite ($bf,full_tag("DEPENDENCY",4,false,$lesson->dependency));
fwrite ($bf,full_tag("CONDITIONS",4,false,$lesson->conditions));
fwrite ($bf,full_tag("GRADE",4,false,$lesson->grade));
fwrite ($bf,full_tag("CUSTOM",4,false,$lesson->custom));
fwrite ($bf,full_tag("ONGOING",4,false,$lesson->ongoing));
fwrite ($bf,full_tag("USEMAXGRADE",4,false,$lesson->usemaxgrade));
fwrite ($bf,full_tag("MAXANSWERS",4,false,$lesson->maxanswers));
fwrite ($bf,full_tag("MAXATTEMPTS",4,false,$lesson->maxattempts));
fwrite ($bf,full_tag("REVIEW",4,false,$lesson->review));
fwrite ($bf,full_tag("NEXTPAGEDEFAULT",4,false,$lesson->nextpagedefault));
fwrite ($bf,full_tag("MINQUESTIONS",4,false,$lesson->minquestions));
fwrite ($bf,full_tag("MAXPAGES",4,false,$lesson->maxpages));
fwrite ($bf,full_tag("TIMED",4,false,$lesson->timed));
fwrite ($bf,full_tag("MAXTIME",4,false,$lesson->maxtime));
fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake));
fwrite ($bf,full_tag("TREE",4,false,$lesson->tree));
fwrite ($bf,full_tag("MEDIAFILE",4,false,$lesson->mediafile));
fwrite ($bf,full_tag("SLIDESHOW",4,false,$lesson->slideshow));
fwrite ($bf,full_tag("WIDTH",4,false,$lesson->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$lesson->height));
fwrite ($bf,full_tag("BGCOLOR",4,false,$lesson->bgcolor));
fwrite ($bf,full_tag("DISPLAYLEFT",4,false,$lesson->displayleft));
fwrite ($bf,full_tag("SHOWHIGHSCORES",4,false,$lesson->highscores));
fwrite ($bf,full_tag("MAXHIGHSCORES",4,false,$lesson->maxhighscores));
fwrite ($bf,full_tag("AVAILABLE",4,false,$lesson->available));
fwrite ($bf,full_tag("DEADLINE",4,false,$lesson->deadline));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$lesson->timemodified));
//Now we backup lesson pages
$status = backup_lesson_pages($bf,$preferences,$lesson->id);
//if we've selected to backup users info, then backup grades, high scores, and timer info
if ($status) {
if (backup_userdata_selected($preferences,'lesson',$lesson->id)) {
if(!backup_lesson_grades($bf, $preferences, $lesson->id)) {
return false;
}
if (!backup_lesson_high_scores($bf, $preferences, $lesson->id)) {
return false;
}
if (!backup_lesson_timer($bf, $preferences, $lesson->id)) {
return false;
}
}
// back up the default for the course. There might not be one, but if there
// is, there will only be one.
$status = backup_lesson_default($bf,$preferences);
//End mod
if ($status) {
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
}
//Backup lesson_pages contents (executed from lesson_backup_mods)
function backup_lesson_pages ($bf, $preferences, $lessonid) {
@ -139,7 +156,7 @@
//Now we backup lesson answers for this page
$status = backup_lesson_answers($bf, $preferences, $page->id);
// backup branch table info for branch tables.
if ($status && $preferences->mods["lesson"]->userinfo) {
if ($status && backup_userdata_selected($preferences,'lesson',$lessonid)) {
if (!backup_lesson_branch($bf, $preferences, $page->id)) {
return false;
}
@ -192,7 +209,7 @@
fwrite ($bf,full_tag("ANSWERTEXT",8,false,$answer->answer));
fwrite ($bf,full_tag("RESPONSE",8,false,$answer->response));
//Now we backup any lesson attempts (if student data required)
if ($preferences->mods["lesson"]->userinfo) {
if (backup_userdata_selected($preferences,'lesson',$answer->lessonid)) {
$status = backup_lesson_attempts($bf,$preferences,$answer->id);
}
//End rubric
@ -401,7 +418,14 @@
}
//Return an array of info (name,value)
function lesson_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function lesson_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += lesson_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","lesson");
if ($ids = lesson_ids($course)) {
@ -422,6 +446,24 @@
return $info;
}
//Return an array of info (name,value)
function lesson_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("attempts","lesson");
if ($ids = lesson_attempts_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Return a content encoded to support interactivities linking. Every module
//should have its own. They are called automatically from the backup procedure.
function lesson_encode_content_links ($content,$preferences) {
@ -464,4 +506,14 @@
WHERE l.course = '$course' AND
a.lessonid = l.id");
}
//Returns an array of lesson_submissions id
function lesson_attempts_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT a.id , a.lessonid
FROM {$CFG->prefix}lesson_attempts a
WHERE a.lessonid = $instanceid");
}
?>

@ -98,10 +98,11 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//We have to restore the lesson pages which are held in their logical order...
$status = lesson_pages_restore_mods($newid,$info,$restore);
$userdata = restore_userdata_selected($restore,"lesson",$mod->id);
$status = lesson_pages_restore_mods($newid,$info,$restore,$userdata);
//...and the user grades, high scores, and timer (if required)
if ($status) {
if ($restore->mods["lesson"]->userinfo) {
if ($userdata) {
if(!lesson_grades_restore_mods($newid,$info,$restore)) {
return false;
}
@ -126,7 +127,7 @@
}
//This function restores the lesson_pages
function lesson_pages_restore_mods($lessonid,$info,$restore) {
function lesson_pages_restore_mods($lessonid,$info,$restore,$userdata=false) {
global $CFG;
@ -182,11 +183,11 @@
//We have the newid, update backup_ids (restore logs will use it!!)
backup_putid($restore->backup_unique_code,"lesson_pages", $oldid, $newid);
//We have to restore the lesson_answers table now (a page level table)
$status = lesson_answers_restore($lessonid,$newid,$page_info,$restore);
$status = lesson_answers_restore($lessonid,$newid,$page_info,$restore,$userdata);
//Need to update useranswer field (which has answer id's in it)
//for matching and multi-answer multi-choice questions
if ($restore->mods["lesson"]->userinfo) { // firs check to see if we even have to do this
if ($userdata) { // first check to see if we even have to do this
// if multi-answer multi-choice question or matching
if (($page->qtype == 3 && $page->qoption) ||
$page->qtype == 5) {
@ -213,7 +214,7 @@
}
// backup branch table info for branch tables.
if ($status && $restore->mods["lesson"]->userinfo) {
if ($status && $userdata) {
if (!lesson_branch_restore($lessonid,$newid,$page_info,$restore)) {
return false;
}
@ -243,7 +244,7 @@
//This function restores the lesson_answers
function lesson_answers_restore($lessonid,$pageid,$info,$restore) {
function lesson_answers_restore($lessonid,$pageid,$info,$restore,$userdata=false) {
global $CFG;
@ -311,7 +312,7 @@
// field in attempts. This is done in the lesson_pages_restore_mods
backup_putid($restore->backup_unique_code,"lesson_answers", $oldid, $newid);
if ($restore->mods['lesson']->userinfo) {
if ($userdata) {
//We have to restore the lesson_attempts table now (a answers level table)
$status = lesson_attempts_restore($lessonid, $pageid, $newid, $answer_info, $restore);
}

@ -103,22 +103,28 @@
// (course independent)
//Insert necessary category ids to backup_ids table
function insert_category_ids ($course,$backup_unique_code) {
function insert_category_ids ($course,$backup_unique_code,$instances=null) {
global $CFG;
//Create missing categories and reasign orphaned questions
fix_orphaned_questions($course);
// defaults
$where = "q.course = '$course' AND g.quiz = q.id AND ";
$from = ", {$CFG->prefix}quiz q";
// but if we have an array of quiz ids, use those instead.
if (!empty($instances) && is_array($instances) && count($instances)) {
$where = ' g.quiz IN ('.implode(',',array_keys($instances)).') AND ';
}
//Detect used categories (by category in questions)
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
(backup_code, table_name, old_id)
SELECT DISTINCT $backup_unique_code,'quiz_categories',t.category
FROM {$CFG->prefix}quiz_questions t,
{$CFG->prefix}quiz_question_instances g,
{$CFG->prefix}quiz q
WHERE q.course = '$course' AND
g.quiz = q.id AND
g.question = t.id",false);
{$CFG->prefix}quiz_question_instances g
$from
WHERE $where g.question = t.id",false);
//Now, foreach detected category, we look for their parents upto 0 (top category)
$categories = get_records_sql("SELECT old_id, old_id
@ -709,6 +715,62 @@
}
function quiz_backup_one_mod($bf,$preferences,$quiz) {
$status = true;
if (is_numeric($quiz)) {
$quiz = get_record('quiz','id',$quiz);
}
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print quiz data
fwrite ($bf,full_tag("ID",4,false,$quiz->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"quiz"));
fwrite ($bf,full_tag("NAME",4,false,$quiz->name));
fwrite ($bf,full_tag("INTRO",4,false,$quiz->intro));
fwrite ($bf,full_tag("TIMEOPEN",4,false,$quiz->timeopen));
fwrite ($bf,full_tag("TIMECLOSE",4,false,$quiz->timeclose));
fwrite ($bf,full_tag("OPTIONFLAGS",4,false,$quiz->optionflags));
fwrite ($bf,full_tag("PENALTYSCHEME",4,false,$quiz->penaltyscheme));
fwrite ($bf,full_tag("ATTEMPTS_NUMBER",4,false,$quiz->attempts));
fwrite ($bf,full_tag("ATTEMPTONLAST",4,false,$quiz->attemptonlast));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$quiz->grademethod));
fwrite ($bf,full_tag("DECIMALPOINTS",4,false,$quiz->decimalpoints));
fwrite ($bf,full_tag("REVIEW",4,false,$quiz->review));
fwrite ($bf,full_tag("QUESTIONSPERPAGE",4,false,$quiz->questionsperpage));
fwrite ($bf,full_tag("SHUFFLEQUESTIONS",4,false,$quiz->shufflequestions));
fwrite ($bf,full_tag("SHUFFLEANSWERS",4,false,$quiz->shuffleanswers));
fwrite ($bf,full_tag("QUESTIONS",4,false,$quiz->questions));
fwrite ($bf,full_tag("SUMGRADES",4,false,$quiz->sumgrades));
fwrite ($bf,full_tag("GRADE",4,false,$quiz->grade));
fwrite ($bf,full_tag("TIMECREATED",4,false,$quiz->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$quiz->timemodified));
fwrite ($bf,full_tag("TIMELIMIT",4,false,$quiz->timelimit));
fwrite ($bf,full_tag("PASSWORD",4,false,$quiz->password));
fwrite ($bf,full_tag("SUBNET",4,false,$quiz->subnet));
fwrite ($bf,full_tag("POPUP",4,false,$quiz->popup));
//Now we print to xml question_instances (Course Level)
$status = backup_quiz_question_instances($bf,$preferences,$quiz->id);
//Now we print to xml question_versions (Course Level)
$status = backup_quiz_question_versions($bf,$preferences,$quiz->id);
//if we've selected to backup users info, then execute:
// - backup_quiz_grades
// - backup_quiz_attempts
if (backup_userdata_selected($preferences,'quiz',$quiz->id) && $status) {
$status = backup_quiz_grades($bf,$preferences,$quiz->id);
if ($status) {
$status = backup_quiz_attempts($bf,$preferences,$quiz->id);
}
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//STEP 2. Backup quizzes and associated structures
// (course dependent)
function quiz_backup_mods($bf,$preferences) {
@ -721,49 +783,9 @@
$quizzes = get_records ("quiz","course",$preferences->backup_course,"id");
if ($quizzes) {
foreach ($quizzes as $quiz) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print quiz data
fwrite ($bf,full_tag("ID",4,false,$quiz->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"quiz"));
fwrite ($bf,full_tag("NAME",4,false,$quiz->name));
fwrite ($bf,full_tag("INTRO",4,false,$quiz->intro));
fwrite ($bf,full_tag("TIMEOPEN",4,false,$quiz->timeopen));
fwrite ($bf,full_tag("TIMECLOSE",4,false,$quiz->timeclose));
fwrite ($bf,full_tag("OPTIONFLAGS",4,false,$quiz->optionflags));
fwrite ($bf,full_tag("PENALTYSCHEME",4,false,$quiz->penaltyscheme));
fwrite ($bf,full_tag("ATTEMPTS_NUMBER",4,false,$quiz->attempts));
fwrite ($bf,full_tag("ATTEMPTONLAST",4,false,$quiz->attemptonlast));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$quiz->grademethod));
fwrite ($bf,full_tag("DECIMALPOINTS",4,false,$quiz->decimalpoints));
fwrite ($bf,full_tag("REVIEW",4,false,$quiz->review));
fwrite ($bf,full_tag("QUESTIONSPERPAGE",4,false,$quiz->questionsperpage));
fwrite ($bf,full_tag("SHUFFLEQUESTIONS",4,false,$quiz->shufflequestions));
fwrite ($bf,full_tag("SHUFFLEANSWERS",4,false,$quiz->shuffleanswers));
fwrite ($bf,full_tag("QUESTIONS",4,false,$quiz->questions));
fwrite ($bf,full_tag("SUMGRADES",4,false,$quiz->sumgrades));
fwrite ($bf,full_tag("GRADE",4,false,$quiz->grade));
fwrite ($bf,full_tag("TIMECREATED",4,false,$quiz->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$quiz->timemodified));
fwrite ($bf,full_tag("TIMELIMIT",4,false,$quiz->timelimit));
fwrite ($bf,full_tag("PASSWORD",4,false,$quiz->password));
fwrite ($bf,full_tag("SUBNET",4,false,$quiz->subnet));
fwrite ($bf,full_tag("POPUP",4,false,$quiz->popup));
//Now we print to xml question_instances (Course Level)
$status = backup_quiz_question_instances($bf,$preferences,$quiz->id);
//Now we print to xml question_versions (Course Level)
$status = backup_quiz_question_versions($bf,$preferences,$quiz->id);
//if we've selected to backup users info, then execute:
// - backup_quiz_grades
// - backup_quiz_attempts
if ($preferences->mods["quiz"]->userinfo and $status) {
$status = backup_quiz_grades($bf,$preferences,$quiz->id);
if ($status) {
$status = backup_quiz_attempts($bf,$preferences,$quiz->id);
}
if (backup_mod_selected($preferences,'quiz',$quiz->id)) {
$status = quiz_backup_one_mod($bf,$preferences,$quiz);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
@ -958,6 +980,38 @@
return $status;
}
function quiz_check_backup_mods_instances($instance,$backup_unique_code) {
// the keys in this array need to be unique as they get merged...
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
//Categories
$info[$instance->id.'1'][0] = get_string("categories","quiz");
if ($ids = quiz_category_ids_by_backup ($backup_unique_code)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
//Questions
$info[$instance->id.'2'][0] = get_string("questions","quiz");
if ($ids = quiz_question_ids_by_backup ($backup_unique_code)) {
$info[$instance->id.'2'][1] = count($ids);
} else {
$info[$instance->id.'2'][1] = 0;
}
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
//Grades
$info[$instance->id.'3'][0] = get_string("grades");
if ($ids = quiz_grade_ids_by_instance ($instance->id)) {
$info[$instance->id.'3'][1] = count($ids);
} else {
$info[$instance->id.'3'][1] = 0;
}
}
return $info;
}
//Backup quiz_rqp_state contents (executed from backup_quiz_states)
function backup_quiz_rqp_state ($bf,$preferences,$state) {
@ -1004,11 +1058,20 @@
}
////Return an array of info (name,value)
function quiz_check_backup_mods($course,$user_data=false,$backup_unique_code) {
/// $instances is an array with key = instanceid, value = object (name,id,userdata)
function quiz_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
//Deletes data from mdl_backup_ids (categories section)
delete_category_ids ($backup_unique_code);
//Create date into mdl_backup_ids (categories section)
insert_category_ids ($course,$backup_unique_code);
insert_category_ids ($course,$backup_unique_code,$instances);
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += quiz_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","quiz");
if ($ids = quiz_ids ($course)) {
@ -1110,4 +1173,13 @@
g.quiz = a.id");
}
function quiz_grade_ids_by_instance($instanceid) {
global $CFG;
return get_records_sql ("SELECT g.id, g.quiz
FROM {$CFG->prefix}quiz_grades g
WHERE g.quiz = $instanceid");
}
?>

@ -1336,7 +1336,7 @@
//We have to restore the question_versions now (course level table)
$status = quiz_question_versions_restore_mods($newid,$info,$restore);
//Now check if want to restore user data and do it.
if ($restore->mods['quiz']->userinfo) {
if (restore_userdata_selected($restore,'quiz',$mod->id)) {
//Restore quiz_attempts
$status = quiz_attempts_restore_mods ($newid,$info,$restore);
if ($status) {

@ -1274,7 +1274,7 @@
//We have to restore the question_versions now (course level table)
$status = quiz_question_versions_restore_pre15_mods($newid,$info,$restore);
//Now check if want to restore user data and do it.
if ($restore->mods['quiz']->userinfo) {
if (restore_userdata_selected($restore,'quiz',$mod->id)) {
//Restore quiz_attempts
$status = quiz_attempts_restore_pre15_mods ($newid,$info,$restore, $quiz->questions);
if ($status) {

@ -26,35 +26,73 @@
$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("POPUP",4,false,$resource->popup));
fwrite ($bf,full_tag("OPTIONS",4,false,$resource->options));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$resource->timemodified));
//End mod
$status = fwrite ($bf,end_tag("MOD",3,true));
if (backup_mod_selected($preferences,'resource',$resource->id)) {
$status = resource_backup_one_mod($bf,$preferences,$resource);
}
}
}
return $status;
}
////Return an array of info (name,value)
function resource_check_backup_mods($course,$user_data=false,$backup_unique_code) {
//First the course data
$info[0][0] = get_string("modulenameplural","resource");
if ($ids = resource_ids ($course)) {
$info[0][1] = count($ids);
} else {
$info[0][1] = 0;
function resource_backup_one_mod($bf,$preferences,$resource) {
global $CFG;
if (is_numeric($resource)) {
$resource = get_record('resource','id',$resource);
}
$status = true;
//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("POPUP",4,false,$resource->popup));
fwrite ($bf,full_tag("OPTIONS",4,false,$resource->options));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$resource->timemodified));
//End mod
$status = fwrite ($bf,end_tag("MOD",3,true));
if ($status && ($resource->type == 'file' || $resource->type == 'directory' || $resource->type == 'ims')) { // more should go here later!
// backup files for this resource.
$status = resource_backup_files($bf,$preferences,$resource);
}
return $status;
}
////Return an array of info (name,value)
function resource_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += resource_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","resource");
if ($ids = resource_ids ($course)) {
$info[0][1] = count($ids);
} else {
$info[0][1] = 0;
}
return $info;
}
////Return an array of info (name,value)
function resource_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = '<b>'.$instance->name.'</b>';
$info[$instance->id.'0'][1] = '';
return $info;
}
@ -90,4 +128,41 @@
WHERE a.course = '$course'");
}
function resource_backup_files($bf,$preferences,$resource) {
global $CFG;
$status = true;
if (!file_exists($CFG->dataroot.'/'.$preferences->backup_course.'/'.$resource->reference)) {
return true ; // doesn't exist but we don't want to halt the entire process so still return true.
}
$status = $status && check_and_create_course_files_dir($preferences->backup_unique_code);
// if this is somewhere deeply nested we need to do all the structure stuff first.....
$bits = explode('/',$resource->reference);
$newbit = '';
for ($i = 0; $i< count($bits)-1; $i++) {
$newbit .= $bits[$i].'/';
$status = $status && check_dir_exists($CFG->dataroot.'/temp/backup/'.$preferences->backup_unique_code.'/course_files/'.$newbit,true);
}
$status = $status && backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$resource->reference,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/course_files/".$resource->reference);
// now, just in case we check moddata ( going forwards, resources should use this )
$status = $status && check_and_create_moddata_dir($preferences->backup_unique_code);
$status = $status && check_dir_exists($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/".$CFG->moddata."/resource/",true);
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
$instanceid = $resource->id;
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/resource/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/resource/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/resource/".$instanceid);
}
}
return $status;
}
?>

@ -89,6 +89,11 @@
//We have the newid, update backup_ids
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
// restore any associated files...
if ($resource->type == 'file' || $resource->type == 'directory' || $resource->type == 'ims') {
resource_restore_files($mod->id,$newid,$resource,$restore);
}
} else {
$status = false;
@ -304,4 +309,42 @@
}
return $status;
}
function resource_restore_files($oldid,$newid,$resource,$restore) {
global $CFG;
$status = true;
$status = check_dir_exists($CFG->dataroot."/".$restore->course_id,true);
// we need to do anything referenced by $resource->reference and anything in moddata/resource/instance
// do referenced files/dirs first.
$temp_path = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.'/course_files/'.$resource->reference;
if (file_exists($temp_path)) { // ok, it was backed up, restore it.
$new_path = $CFG->dataroot.'/'.$restore->course_id.'/'.$resource->reference;
// if this is somewhere deeply nested we need to do all the structure stuff first.....
$bits = explode('/',$resource->reference);
$newbit = '';
for ($i = 0; $i< count($bits)-1; $i++) {
$newbit .= $bits[$i].'/';
$status = $status && check_dir_exists($CFG->dataroot.'/'.$restore->course_id.'/'.$newbit,true);
}
$status = $status && backup_copy_file($temp_path,$new_path);
}
// and now for moddata.
$temp_path = $CFG->dataroot."/temp/backup/".$restore->backup_unique_code.
"/moddata/resource/".$oldid;
if (file_exists($temp_path)) { // there's something to back up, restore it.
$new_path = $CFG->dataroot."/".$restore->course_id."/".$CFG->moddata;
$status = $status && check_dir_exists($new_path,true);
$new_path .= '/resource';
$status = $status && check_dir_exists($new_path,true);
$new_path .= '/'.$newid;
$status = $status && backup_copy_file($temp_path,$new_path);
}
return $status;
}
?>

@ -36,47 +36,57 @@
$scorms = get_records ("scorm","course",$preferences->backup_course,"id");
if ($scorms) {
foreach ($scorms as $scorm) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print scorm data
fwrite ($bf,full_tag("ID",4,false,$scorm->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"scorm"));
fwrite ($bf,full_tag("NAME",4,false,$scorm->name));
fwrite ($bf,full_tag("REFERENCE",4,false,$scorm->reference));
fwrite ($bf,full_tag("VERSION",4,false,$scorm->version));
fwrite ($bf,full_tag("MAXGRADE",4,false,$scorm->maxgrade));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$scorm->grademethod));
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("HIDEBROWSE",4,false,$scorm->hidebrowse));
fwrite ($bf,full_tag("HIDETOC",4,false,$scorm->hidetoc));
fwrite ($bf,full_tag("HIDENAV",4,false,$scorm->hidenav));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
fwrite ($bf,full_tag("POPUP",4,false,$scorm->popup));
fwrite ($bf,full_tag("OPTIONS",4,false,$scorm->options));
fwrite ($bf,full_tag("WIDTH",4,false,$scorm->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$scorm->height));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
//if we've selected to backup users info, then execute backup_scorm_scoes_track
if ($status) {
if ($preferences->mods["scorm"]->userinfo) {
$status = backup_scorm_scoes_track($bf,$preferences,$scorm->id);
}
if (backup_mod_selected($preferences,'scorm',$scorm->id)) {
$status = scorm_backup_one_mod($bf,$preferences,$scorm);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
//backup scorm files
if ($status) {
$status = backup_scorm_files($bf,$preferences);
}
}
return $status;
}
function scorm_backup_one_mod($bf,$preferences,$scorm) {
$status = true;
if (is_numeric($scorm)) {
$scorm = get_record('scorm','id',$scorm);
}
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print scorm data
fwrite ($bf,full_tag("ID",4,false,$scorm->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"scorm"));
fwrite ($bf,full_tag("NAME",4,false,$scorm->name));
fwrite ($bf,full_tag("REFERENCE",4,false,$scorm->reference));
fwrite ($bf,full_tag("VERSION",4,false,$scorm->version));
fwrite ($bf,full_tag("MAXGRADE",4,false,$scorm->maxgrade));
fwrite ($bf,full_tag("GRADEMETHOD",4,false,$scorm->grademethod));
fwrite ($bf,full_tag("LAUNCH",4,false,$scorm->launch));
fwrite ($bf,full_tag("SUMMARY",4,false,$scorm->summary));
fwrite ($bf,full_tag("HIDEBROWSE",4,false,$scorm->hidebrowse));
fwrite ($bf,full_tag("HIDETOC",4,false,$scorm->hidetoc));
fwrite ($bf,full_tag("HIDENAV",4,false,$scorm->hidenav));
fwrite ($bf,full_tag("AUTO",4,false,$scorm->auto));
fwrite ($bf,full_tag("POPUP",4,false,$scorm->popup));
fwrite ($bf,full_tag("OPTIONS",4,false,$scorm->options));
fwrite ($bf,full_tag("WIDTH",4,false,$scorm->width));
fwrite ($bf,full_tag("HEIGHT",4,false,$scorm->height));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$scorm->timemodified));
$status = backup_scorm_scoes($bf,$preferences,$scorm->id);
//if we've selected to backup users info, then execute backup_scorm_scoes_track
if ($status) {
if (backup_userdata_selected($preferences,'scorm',$scorm->id)) {
$status = backup_scorm_scoes_track($bf,$preferences,$scorm->id);
$status = backup_scorm_files_instance($bf,$preferences,$scorm->id);
}
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup scorm_scoes contents (executed from scorm_backup_mods)
function backup_scorm_scoes ($bf,$preferences,$scorm) {
@ -151,7 +161,14 @@
}
////Return an array of info (name,value)
function scorm_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function scorm_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += scorm_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","scorm");
if ($ids = scorm_ids ($course)) {
@ -172,6 +189,43 @@
return $info;
}
function scorm_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = $instance->name;
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("scoes","scorm");
if ($ids = scorm_scoes_track_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
function backup_scorm_files_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/scorm/",true);
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/scorm/".$instanceid);
}
}
return $status;
}
//Backup scorm package files
function backup_scorm_files($bf,$preferences) {
@ -185,8 +239,15 @@
//Now copy the scorm dir
if ($status) {
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm")) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm",
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/scorm");
$handle = opendir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm");
while (false!==($item = readdir($handle))) {
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/sorm/".$item)
&& array_key_exists($item,$preferences->mods['scorm']->instances)
&& !empty($preferences->mods['scorm']->instances[$item]->backup)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/scorm/".$item,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/scorm/",$item);
}
}
}
}
@ -236,4 +297,14 @@
WHERE a.course = '$course' AND
s.scormid = a.id");
}
//Returns an array of scorm_scoes id
function scorm_scoes_track_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.scormid
FROM {$CFG->prefix}scorm_scoes_track s
WHERE s.scormid = $instanceid");
}
?>

@ -125,7 +125,7 @@
$status = scorm_restore_files ($scorm, $restore);
if ($status) {
$status = scorm_scoes_restore_mods ($newid,$info,$restore);
$status = scorm_scoes_restore_mods ($newid,$info,$restore,$mod->id);
if ($status) {
$launchsco = backup_getid($restore->backup_unique_code,"scorm_scoes",$oldlaunch);
$scorm->launch = $launchsco->new_id;
@ -144,7 +144,7 @@
}
//This function restores the scorm_scoes
function scorm_scoes_restore_mods($scorm_id,$info,$restore) {
function scorm_scoes_restore_mods($scorm_id,$info,$restore,$oldmodid) {
global $CFG;
@ -193,7 +193,7 @@
}
//Now check if want to restore user data and do it.
if ($restore->mods['scorm']->userinfo) {
if (restore_userdata_selected($restore,'scorm',$oldmodid)) {
//Restore scorm_scoes
if ($status) {
if ($restore->backup_version < 2005031300) {

@ -32,32 +32,46 @@
$surveys = get_records ("survey","course",$preferences->backup_course,"id");
if ($surveys) {
foreach ($surveys as $survey) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print choice data
fwrite ($bf,full_tag("ID",4,false,$survey->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"survey"));
fwrite ($bf,full_tag("TEMPLATE",4,false,$survey->template));
fwrite ($bf,full_tag("DAYS",4,false,$survey->days));
fwrite ($bf,full_tag("TIMECREATED",4,false,$survey->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$survey->timemodified));
fwrite ($bf,full_tag("NAME",4,false,$survey->name));
fwrite ($bf,full_tag("INTRO",4,false,$survey->intro));
fwrite ($bf,full_tag("QUESTIONS",4,false,$survey->questions));
//if we've selected to backup users info, then execute backup_survey_answers and
//backup_survey_analysis
if ($preferences->mods["survey"]->userinfo) {
$status = backup_survey_answers($bf,$preferences,$survey->id);
$status = backup_survey_analysis($bf,$preferences,$survey->id);
if (backup_mod_selected($preferences,'survey',$survey->id)) {
$status = survey_backup_one_mod($bf,$preferences,$survey);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
return $status;
}
function survey_backup_one_mod($bf,$preferences,$survey) {
$status = true;
if (is_numeric($survey)) {
$survey = get_record('survey','id',$survey);
}
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print choice data
fwrite ($bf,full_tag("ID",4,false,$survey->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"survey"));
fwrite ($bf,full_tag("TEMPLATE",4,false,$survey->template));
fwrite ($bf,full_tag("DAYS",4,false,$survey->days));
fwrite ($bf,full_tag("TIMECREATED",4,false,$survey->timecreated));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$survey->timemodified));
fwrite ($bf,full_tag("NAME",4,false,$survey->name));
fwrite ($bf,full_tag("INTRO",4,false,$survey->intro));
fwrite ($bf,full_tag("QUESTIONS",4,false,$survey->questions));
//if we've selected to backup users info, then execute backup_survey_answers and
//backup_survey_analysis
if (backup_userdata_selected($preferences,'survey',$survey->id)) {
$status = backup_survey_answers($bf,$preferences,$survey->id);
$status = backup_survey_analysis($bf,$preferences,$survey->id);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup survey_answers contents (executed from survey_backup_mods)
function backup_survey_answers ($bf,$preferences,$survey) {
@ -119,8 +133,31 @@
return $status;
}
function survey_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = $instance->name;
$info[$instance->id.'0'][1] = '';
if (!empty($instance->userdata)) {
//Subscriptions
$info[$instance->id.'1'][0] = get_string("answers","survey");
if ($ids = survey_answer_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
////Return an array of info (name,value)
function survey_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function survey_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += survey_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","survey");
if ($ids = survey_ids ($course)) {
@ -185,4 +222,13 @@
s.survey = a.id");
}
function survey_answer_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.survey
FROM {$CFG->prefix}survey_answers s
WHERE s.survey = $instanceid");
}
?>

@ -61,7 +61,7 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['survey']->userinfo) {
if (restore_userdata_selected($restore,'survey',$mod->id)) {
//Restore survey_answers
$status = survey_answers_restore_mods ($newid,$info,$restore);
//Restore survey_analysis

@ -31,50 +31,75 @@
////Iterate over wiki table
if ($wikis = get_records ("wiki","course", $preferences->backup_course,"id")) {
foreach ($wikis as $wiki) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$wiki->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"wiki"));
fwrite ($bf,full_tag("NAME",4,false,$wiki->name));
fwrite ($bf,full_tag("SUMMARY",4,false,$wiki->summary));
fwrite ($bf,full_tag("PAGENAME",4,false,$wiki->wtype));
fwrite ($bf,full_tag("WTYPE",4,false,$wiki->wtype));
fwrite ($bf,full_tag("EWIKIPRINTTITLE",4,false,$wiki->ewikiprinttitle));
fwrite ($bf,full_tag("HTMLMODE",4,false,$wiki->htmlmode));
fwrite ($bf,full_tag("EWIKIACCEPTBINARY",4,false,$wiki->ewikiacceptbinary));
fwrite ($bf,full_tag("DISABLECAMELCASE",4,false,$wiki->disablecamelcase));
fwrite ($bf,full_tag("SETPAGEFLAGS",4,false,$wiki->setpageflags));
fwrite ($bf,full_tag("STRIPPAGES",4,false,$wiki->strippages));
fwrite ($bf,full_tag("REMOVEPAGES",4,false,$wiki->removepages));
fwrite ($bf,full_tag("REVERTCHANGES",4,false,$wiki->revertchanges));
fwrite ($bf,full_tag("INITIALCONTENT",4,false,$wiki->initialcontent));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$wiki->timemodified));
//backup entries and pages
if ($preferences->mods["wiki"]->userinfo) {
$status=backup_wiki_entries($bf,$preferences,$wiki->id, $preferences->mods["wiki"]->userinfo);
if (backup_mod_selected($preferences,'wiki',$wiki->id)) {
wiki_backup_one_mod($bf,$preferences,$wiki);
}
//End mod
fwrite ($bf,end_tag("MOD",3,true));
}
}
//if we've selected to backup users info, then backup files too
if ($status) {
if ($preferences->mods["wiki"]->userinfo) {
$status = backup_wiki_files($bf,$preferences);
}
}
return $status;
}
function wiki_backup_one_mod($bf,$preferences,$wiki) {
$status = true;
if (is_numeric($wiki)) {
$wiki = get_record('wiki','id',$wiki);
}
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print assignment data
fwrite ($bf,full_tag("ID",4,false,$wiki->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"wiki"));
fwrite ($bf,full_tag("NAME",4,false,$wiki->name));
fwrite ($bf,full_tag("SUMMARY",4,false,$wiki->summary));
fwrite ($bf,full_tag("PAGENAME",4,false,$wiki->wtype));
fwrite ($bf,full_tag("WTYPE",4,false,$wiki->wtype));
fwrite ($bf,full_tag("EWIKIPRINTTITLE",4,false,$wiki->ewikiprinttitle));
fwrite ($bf,full_tag("HTMLMODE",4,false,$wiki->htmlmode));
fwrite ($bf,full_tag("EWIKIACCEPTBINARY",4,false,$wiki->ewikiacceptbinary));
fwrite ($bf,full_tag("DISABLECAMELCASE",4,false,$wiki->disablecamelcase));
fwrite ($bf,full_tag("SETPAGEFLAGS",4,false,$wiki->setpageflags));
fwrite ($bf,full_tag("STRIPPAGES",4,false,$wiki->strippages));
fwrite ($bf,full_tag("REMOVEPAGES",4,false,$wiki->removepages));
fwrite ($bf,full_tag("REVERTCHANGES",4,false,$wiki->revertchanges));
fwrite ($bf,full_tag("INITIALCONTENT",4,false,$wiki->initialcontent));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$wiki->timemodified));
//backup entries and pages
if (backup_userdata_selected($preferences,'wiki',$wiki->id)) {
$status = backup_wiki_entries($bf,$preferences,$wiki->id, $preferences->mods["wiki"]->userinfo);
$status = backup_wiki_files_instance($bf,$preferences,$wiki->id);
}
//End mod
fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
function wiki_check_backup_mods_instances($instance,$backup_unique_code) {
$info[$instance->id.'0'][0] = $instance->name;
$info[$instance->id.'0'][1] = '';
// wiki_check_backup_mods ignores userdata, so we do too.
return $info;
}
////Return an array of info (name,value)
function wiki_check_backup_mods($course,$user_data=false,$backup_unique_code) {
//First the course data
$info[0][0] = get_string("modulenameplural","wiki");
$info[0][1] = count_records("wiki", "course", "$course");
return $info;
function wiki_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += wiki_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","wiki");
$info[0][1] = count_records("wiki", "course", "$course");
return $info;
}
//Backup wiki_entries contents (executed from wiki_backup_mods)
@ -147,6 +172,28 @@
return $status;
}
function backup_wiki_files_instance($bf,$preferences,$instancid) {
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/wiki/",true);
//Now copy the forum dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$instanceid)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$instanceid,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki/".$instanceid);
}
}
return $status;
}
//Backup wiki binary files
function backup_wiki_files($bf,$preferences) {
@ -161,8 +208,15 @@
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki")) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki",
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki");
$handle = opendir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki");
while (false!==($item = readdir($handle))) {
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$item)
&& array_key_exists($item,$preferences->mods['wiki']->instances)
&& !empty($preferences->mods['wiki']->instances[$item]->backup)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/wiki/".$item,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/wiki/",$item);
}
}
}
}

@ -67,7 +67,7 @@
backup_putid($restore->backup_unique_code,$mod->modtype,
$mod->id, $newid);
//Now check if want to restore user data and do it.
if ($restore->mods['wiki']->userinfo) {
if (restore_userdata_selected($restore,'wiki',$mod->id)) {
//Restore wiki_entries
$status = wiki_entries_restore_mods($mod->id,$newid,$info,$restore);
}

@ -46,59 +46,74 @@
$workshops = get_records ("workshop","course",$preferences->backup_course,"id");
if ($workshops) {
foreach ($workshops as $workshop) {
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print workshop data
fwrite ($bf,full_tag("ID",4,false,$workshop->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"workshop"));
fwrite ($bf,full_tag("NAME",4,false,$workshop->name));
fwrite ($bf,full_tag("DESCRIPTION",4,false,$workshop->description));
fwrite ($bf,full_tag("WTYPE",4,false,$workshop->wtype));
fwrite ($bf,full_tag("NELEMENTS",4,false,$workshop->nelements));
fwrite ($bf,full_tag("NATTACHMENTS",4,false,$workshop->nattachments));
fwrite ($bf,full_tag("FORMAT",4,false,$workshop->format));
fwrite ($bf,full_tag("GRADINGSTRATEGY",4,false,$workshop->gradingstrategy));
fwrite ($bf,full_tag("RESUBMIT",4,false,$workshop->resubmit));
fwrite ($bf,full_tag("AGREEASSESSMENTS",4,false,$workshop->agreeassessments));
fwrite ($bf,full_tag("HIDEGRADES",4,false,$workshop->hidegrades));
fwrite ($bf,full_tag("ANONYMOUS",4,false,$workshop->anonymous));
fwrite ($bf,full_tag("INCLUDESELF",4,false,$workshop->includeself));
fwrite ($bf,full_tag("MAXBYTES",4,false,$workshop->maxbytes));
fwrite ($bf,full_tag("SUBMISSIONSTART",4,false,$workshop->submissionstart));
fwrite ($bf,full_tag("ASSESSMENTSTART",4,false,$workshop->assessmentstart));
fwrite ($bf,full_tag("SUBMISSIONEND",4,false,$workshop->submissionend));
fwrite ($bf,full_tag("ASSESSMENTEND",4,false,$workshop->assessmentend));
fwrite ($bf,full_tag("RELEASEGRADES",4,false,$workshop->releasegrades));
fwrite ($bf,full_tag("GRADE",4,false,$workshop->grade));
fwrite ($bf,full_tag("GRADINGGRADE",4,false,$workshop->gradinggrade));
fwrite ($bf,full_tag("NTASSESSMENTS",4,false,$workshop->ntassessments));
fwrite ($bf,full_tag("ASSESSMENTCOMPS",4,false,$workshop->assessmentcomps));
fwrite ($bf,full_tag("NSASSESSMENTS",4,false,$workshop->nsassessments));
fwrite ($bf,full_tag("OVERALLOCATION",4,false,$workshop->overallocation));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$workshop->timemodified));
fwrite ($bf,full_tag("TEACHERWEIGHT",4,false,$workshop->teacherweight));
fwrite ($bf,full_tag("SHOWLEAGUETABLE",4,false,$workshop->showleaguetable));
fwrite ($bf,full_tag("USEPASSWORD",4,false,$workshop->usepassword));
fwrite ($bf,full_tag("PASSWORD",4,false,$workshop->password));
//Now we backup workshop elements
$status = backup_workshop_elements($bf,$preferences,$workshop->id);
//if we've selected to backup users info, then execute backup_workshop_submisions
if ($preferences->mods["workshop"]->userinfo) {
$status = backup_workshop_submissions($bf,$preferences,$workshop->id);
if (backup_mod_selected($preferences,'workshop',$workshop->id)) {
$status = workshop_backup_one_mod($bf,$preferences,$workshop);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
}
}
//if we've selected to backup users info, then backup files too
if ($status) {
if ($preferences->mods["workshop"]->userinfo) {
$status = backup_workshop_files($bf,$preferences);
}
}
return $status;
}
function workshop_backup_one_mod($bf,$preferences,$workshop) {
$status = true;
if (is_numeric($workshop)) {
$workshop = get_record('workshop','id',$workshop);
}
$instanceid = $workshop->id;
//Start mod
fwrite ($bf,start_tag("MOD",3,true));
//Print workshop data
fwrite ($bf,full_tag("ID",4,false,$workshop->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"workshop"));
fwrite ($bf,full_tag("NAME",4,false,$workshop->name));
fwrite ($bf,full_tag("DESCRIPTION",4,false,$workshop->description));
fwrite ($bf,full_tag("WTYPE",4,false,$workshop->wtype));
fwrite ($bf,full_tag("NELEMENTS",4,false,$workshop->nelements));
fwrite ($bf,full_tag("NATTACHMENTS",4,false,$workshop->nattachments));
fwrite ($bf,full_tag("FORMAT",4,false,$workshop->format));
fwrite ($bf,full_tag("GRADINGSTRATEGY",4,false,$workshop->gradingstrategy));
fwrite ($bf,full_tag("RESUBMIT",4,false,$workshop->resubmit));
fwrite ($bf,full_tag("AGREEASSESSMENTS",4,false,$workshop->agreeassessments));
fwrite ($bf,full_tag("HIDEGRADES",4,false,$workshop->hidegrades));
fwrite ($bf,full_tag("ANONYMOUS",4,false,$workshop->anonymous));
fwrite ($bf,full_tag("INCLUDESELF",4,false,$workshop->includeself));
fwrite ($bf,full_tag("MAXBYTES",4,false,$workshop->maxbytes));
fwrite ($bf,full_tag("SUBMISSIONSTART",4,false,$workshop->submissionstart));
fwrite ($bf,full_tag("ASSESSMENTSTART",4,false,$workshop->assessmentstart));
fwrite ($bf,full_tag("SUBMISSIONEND",4,false,$workshop->submissionend));
fwrite ($bf,full_tag("ASSESSMENTEND",4,false,$workshop->assessmentend));
fwrite ($bf,full_tag("RELEASEGRADES",4,false,$workshop->releasegrades));
fwrite ($bf,full_tag("GRADE",4,false,$workshop->grade));
fwrite ($bf,full_tag("GRADINGGRADE",4,false,$workshop->gradinggrade));
fwrite ($bf,full_tag("NTASSESSMENTS",4,false,$workshop->ntassessments));
fwrite ($bf,full_tag("ASSESSMENTCOMPS",4,false,$workshop->assessmentcomps));
fwrite ($bf,full_tag("NSASSESSMENTS",4,false,$workshop->nsassessments));
fwrite ($bf,full_tag("OVERALLOCATION",4,false,$workshop->overallocation));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$workshop->timemodified));
fwrite ($bf,full_tag("TEACHERWEIGHT",4,false,$workshop->teacherweight));
fwrite ($bf,full_tag("SHOWLEAGUETABLE",4,false,$workshop->showleaguetable));
fwrite ($bf,full_tag("USEPASSWORD",4,false,$workshop->usepassword));
fwrite ($bf,full_tag("PASSWORD",4,false,$workshop->password));
//Now we backup workshop elements
$status = backup_workshop_elements($bf,$preferences,$workshop->id);
//if we've selected to backup users info, then execute backup_workshop_submisions
if (backup_userdata_selected($preferences,'workshop',$workshop->id)) {
$ws = array();
$status = backup_workshop_submissions($bf,$preferences,$workshop->id,$ws);
$status = backup_workshop_files_instance($bf,$preferences,$workshop->id,$ws);
}
//End mod
$status =fwrite ($bf,end_tag("MOD",3,true));
return $status;
}
//Backup workshop_elements contents (executed from workshop_backup_mods)
function backup_workshop_elements ($bf,$preferences,$workshop) {
@ -168,7 +183,7 @@
}
//Backup workshop_stockcomments contents (executed from backup_workshop_elements)
function backup_workshop_stockcomments ($bf,$preferences,$workshop,$elementid) {
function backup_workshop_stockcomments ($bf,$preferences,$workshop,$elementno) {
global $CFG;
@ -198,7 +213,7 @@
}
//Backup workshop_submissions contents (executed from workshop_backup_mods)
function backup_workshop_submissions ($bf,$preferences,$workshop) {
function backup_workshop_submissions ($bf,$preferences,$workshop,&$workshop_submissions) {
global $CFG;
@ -365,8 +380,8 @@
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop")) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop",
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/workshop");
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop/",
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/workshop/");
}
}
@ -374,8 +389,55 @@
}
function backup_workshop_files_instance($bf,$preferences,$instanceid,$ws) {
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/workshop/",true);
//Now copy the forum dir
if ($status) {
foreach ($ws as $submission) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop/".$submission->id)) {
$status = backup_copy_file($CFG->dataroot."/".$preferences->backup_course."/".$CFG->moddata."/workshop/".$submission->id,
$CFG->dataroot."/temp/backup/".$preferences->backup_unique_code."/moddata/workshop/".$submission->id);
}
}
}
return $status;
}
function workshop_check_backup_mods_instances($instance,$backup_unique_code) {
//First the course data
$info[$instance->id.'0'][0] = $instance->name;
$info[$instance->id.'0'][1] = '';
//Now, if requested, the user_data
if (!empty($instance->userdata)) {
$info[$instance->id.'1'][0] = get_string("submissions","workshop");
if ($ids = workshop_submission_ids_by_instance ($instance->id)) {
$info[$instance->id.'1'][1] = count($ids);
} else {
$info[$instance->id.'1'][1] = 0;
}
}
return $info;
}
//Return an array of info (name,value)
function workshop_check_backup_mods($course,$user_data=false,$backup_unique_code) {
function workshop_check_backup_mods($course,$user_data=false,$backup_unique_code,$instances=null) {
if (!empty($instances) && is_array($instances) && count($instances)) {
$info = array();
foreach ($instances as $id => $instance) {
$info += workshop_check_backup_mods_instances($instance,$backup_unique_code);
}
return $info;
}
//First the course data
$info[0][0] = get_string("modulenameplural","workshop");
if ($ids = workshop_ids ($course)) {
@ -438,4 +500,13 @@
WHERE w.course = '$course' AND
s.workshopid = w.id");
}
function workshop_submission_ids_by_instance ($instanceid) {
global $CFG;
return get_records_sql ("SELECT s.id , s.workshopid
FROM {$CFG->prefix}workshop_submissions s
WHERE s.workshopid = $instanceid");
}
?>

@ -148,7 +148,7 @@
//We have to restore the workshop_elements table now (course level table)
$status = workshop_elements_restore_mods($newid,$info,$restore);
//Now check if want to restore user data and do it.
if ($restore->mods['workshop']->userinfo) {
if (restore_userdata_selected($restore,'workshop',$mod->id)) {
//Restore workshop_submissions
$status = workshop_submissions_restore_mods ($mod->id, $newid,$info,$restore);
}

@ -891,7 +891,12 @@ body#grade-index .grades .weighted {
text-align: right;
}
.backup-form-instances {
margin:0px 20px 0px 20px;
}
.restore-form-instances {
margin:0px 20px 0px 20px;
}
/***
*** Login