mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Merge branch 'master-18177' of https://github.com/timpricecatalyst/moodle-1
This commit is contained in:
commit
73d8a50d73
@ -196,6 +196,10 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_logs', new lang_string('generallogs','backup'), new lang_string('configgenerallogs','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), array('value'=>0, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), array('value'=>1, 'locked'=>0)));
|
||||
$temp->add(new admin_setting_configcheckbox_with_lock('backup/backup_general_groups',
|
||||
new lang_string('generalgroups', 'backup'), new lang_string('configgeneralgroups', 'backup'),
|
||||
array('value' => 1, 'locked' => 0)));
|
||||
|
||||
$ADMIN->add('backups', $temp);
|
||||
|
||||
// Create a page for general import configuration and defaults.
|
||||
@ -271,6 +275,8 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_logs', new lang_string('generallogs', 'backup'), new lang_string('configgenerallogs', 'backup'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_histories', new lang_string('generalhistories','backup'), new lang_string('configgeneralhistories','backup'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_questionbank', new lang_string('generalquestionbank','backup'), new lang_string('configgeneralquestionbank','backup'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('backup/backup_auto_groups', new lang_string('generalgroups', 'backup'),
|
||||
new lang_string('configgeneralgroups', 'backup'), 1));
|
||||
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_messages', new lang_string('messages', 'message'), new lang_string('backupmessageshelp','message'), 0));
|
||||
//$temp->add(new admin_setting_configcheckbox('backup/backup_auto_blogs', new lang_string('blogs', 'blog'), new lang_string('backupblogshelp','blog'), 0));
|
||||
|
@ -311,17 +311,25 @@ abstract class info {
|
||||
* @param int $courseid Target course id
|
||||
* @param \base_logger $logger Logger for any warnings
|
||||
* @param int $dateoffset Date offset to be added to any dates (0 = none)
|
||||
* @param \base_task $task Restore task
|
||||
*/
|
||||
public function update_after_restore($restoreid, $courseid, \base_logger $logger, $dateoffset) {
|
||||
public function update_after_restore($restoreid, $courseid, \base_logger $logger,
|
||||
$dateoffset, \base_task $task) {
|
||||
$tree = $this->get_availability_tree();
|
||||
// Set static data for use by get_restore_date_offset function.
|
||||
self::$restoreinfo = array('restoreid' => $restoreid, 'dateoffset' => $dateoffset);
|
||||
self::$restoreinfo = array('restoreid' => $restoreid, 'dateoffset' => $dateoffset,
|
||||
'task' => $task);
|
||||
$changed = $tree->update_after_restore($restoreid, $courseid, $logger,
|
||||
$this->get_thing_name());
|
||||
if ($changed) {
|
||||
// Save modified data.
|
||||
$structure = $tree->save();
|
||||
$this->set_in_database(json_encode($structure));
|
||||
if ($tree->is_empty()) {
|
||||
// If the tree is empty, but the tree has changed, remove this condition.
|
||||
$this->set_in_database(null);
|
||||
} else {
|
||||
$structure = $tree->save();
|
||||
$this->set_in_database(json_encode($structure));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,6 +351,24 @@ abstract class info {
|
||||
return self::$restoreinfo['dateoffset'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the restore task (specifically, the task that calls the
|
||||
* update_after_restore method) for the current restore.
|
||||
*
|
||||
* @param string $restoreid Restore identifier
|
||||
* @return \base_task Restore task
|
||||
* @throws coding_exception If not in a restore (or not in that restore)
|
||||
*/
|
||||
public static function get_restore_task($restoreid) {
|
||||
if (!self::$restoreinfo) {
|
||||
throw new coding_exception('Only valid during restore');
|
||||
}
|
||||
if (self::$restoreinfo['restoreid'] !== $restoreid) {
|
||||
throw new coding_exception('Data not available for that restore id');
|
||||
}
|
||||
return self::$restoreinfo['task'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the name of the item (cm_info or section_info, at present) that
|
||||
* this is controlling availability of. Name should be formatted ready
|
||||
|
@ -663,10 +663,18 @@ class tree extends tree_node {
|
||||
public function update_after_restore($restoreid, $courseid,
|
||||
\base_logger $logger, $name) {
|
||||
$changed = false;
|
||||
foreach ($this->children as $child) {
|
||||
$thischanged = $child->update_after_restore($restoreid, $courseid,
|
||||
$logger, $name);
|
||||
$changed = $changed || $thischanged;
|
||||
foreach ($this->children as $index => $child) {
|
||||
if ($child->include_after_restore($restoreid, $courseid, $logger, $name,
|
||||
info::get_restore_task($restoreid))) {
|
||||
$thischanged = $child->update_after_restore($restoreid, $courseid,
|
||||
$logger, $name);
|
||||
$changed = $changed || $thischanged;
|
||||
} else {
|
||||
unset($this->children[$index]);
|
||||
unset($this->showchildren[$index]);
|
||||
$this->showchildren = array_values($this->showchildren);
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
return $changed;
|
||||
}
|
||||
|
@ -82,13 +82,34 @@ abstract class tree_node {
|
||||
*/
|
||||
public abstract function save();
|
||||
|
||||
/**
|
||||
* Checks whether this node should be included after restore or not. The
|
||||
* node may be removed depending on restore settings, which you can get from
|
||||
* the $task object.
|
||||
*
|
||||
* By default nodes are still included after restore.
|
||||
*
|
||||
* @param string $restoreid Restore ID
|
||||
* @param int $courseid ID of target course
|
||||
* @param \base_logger $logger Logger for any warnings
|
||||
* @param string $name Name of this item (for use in warning messages)
|
||||
* @param \base_task $task Current restore task
|
||||
* @return bool True if there was any change
|
||||
*/
|
||||
public function include_after_restore($restoreid, $courseid, \base_logger $logger, $name,
|
||||
\base_task $task) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates this node after restore, returning true if anything changed.
|
||||
* The default behaviour is simply to return false. If there is a problem
|
||||
* with the update, $logger can be used to output a warning.
|
||||
*
|
||||
* Note: If you need information about the date offset, call
|
||||
* \core_availability\info::get_restore_date_offset($restoreid).
|
||||
* \core_availability\info::get_restore_date_offset($restoreid). For
|
||||
* information on the restoring task and its settings, call
|
||||
* \core_availability\info::get_restore_task($restoreid).
|
||||
*
|
||||
* @param string $restoreid Restore ID
|
||||
* @param int $courseid ID of target course
|
||||
|
@ -127,6 +127,23 @@ class condition extends \core_availability\condition {
|
||||
return $this->groupid ? '#' . $this->groupid : 'any';
|
||||
}
|
||||
|
||||
/**
|
||||
* Include this condition only if we are including groups in restore, or
|
||||
* if it's a generic 'same activity' one.
|
||||
*
|
||||
* @param int $restoreid The restore Id.
|
||||
* @param int $courseid The ID of the course.
|
||||
* @param base_logger $logger The logger being used.
|
||||
* @param string $name Name of item being restored.
|
||||
* @param base_task $task The task being performed.
|
||||
*
|
||||
* @return Integer groupid
|
||||
*/
|
||||
public function include_after_restore($restoreid, $courseid, \base_logger $logger,
|
||||
$name, \base_task $task) {
|
||||
return !$this->groupid || $task->get_setting_value('groups');
|
||||
}
|
||||
|
||||
public function update_after_restore($restoreid, $courseid, \base_logger $logger, $name) {
|
||||
global $DB;
|
||||
if (!$this->groupid) {
|
||||
|
@ -158,6 +158,23 @@ class condition extends \core_availability\condition {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Include this condition only if we are including groups in restore, or
|
||||
* if it's a generic 'same activity' one.
|
||||
*
|
||||
* @param int $restoreid The restore Id.
|
||||
* @param int $courseid The ID of the course.
|
||||
* @param base_logger $logger The logger being used.
|
||||
* @param string $name Name of item being restored.
|
||||
* @param base_task $task The task being performed.
|
||||
*
|
||||
* @return Integer groupid
|
||||
*/
|
||||
public function include_after_restore($restoreid, $courseid, \base_logger $logger,
|
||||
$name, \base_task $task) {
|
||||
return !$this->groupingid || $task->get_setting_value('groups');
|
||||
}
|
||||
|
||||
public function update_after_restore($restoreid, $courseid, \base_logger $logger, $name) {
|
||||
global $DB;
|
||||
if (!$this->groupingid) {
|
||||
|
@ -2,6 +2,13 @@ This files describes API changes in /availability/*.
|
||||
|
||||
The information here is intended only for developers.
|
||||
|
||||
=== 2.9 ===
|
||||
|
||||
* Condition plugins can now implement a new include_after_restore function to
|
||||
indicate that they should be removed during the restore process. (This is
|
||||
implemented so that group and grouping conditions are removed if groups are
|
||||
not restored.)
|
||||
|
||||
=== 2.8 ===
|
||||
|
||||
* There is a new API function in the info_module/info_section objects (and
|
||||
|
@ -137,8 +137,10 @@ abstract class backup_activity_task extends backup_task {
|
||||
// activity and from its related course_modules record and availability
|
||||
$this->add_step(new backup_module_structure_step('module_info', 'module.xml'));
|
||||
|
||||
// Annotate the groups used in already annotated groupings
|
||||
$this->add_step(new backup_annotate_groups_from_groupings('annotate_groups'));
|
||||
// Annotate the groups used in already annotated groupings if groups are to be backed up.
|
||||
if ($this->get_setting_value('groups')) {
|
||||
$this->add_step(new backup_annotate_groups_from_groupings('annotate_groups'));
|
||||
}
|
||||
|
||||
// Here we add all the common steps for any activity and, in the point of interest
|
||||
// we call to define_my_steps() is order to get the particular ones inserted in place.
|
||||
|
@ -83,15 +83,18 @@ class backup_course_task extends backup_task {
|
||||
// Annotate enrolment custom fields.
|
||||
$this->add_step(new backup_enrolments_execution_step('annotate_enrol_custom_fields'));
|
||||
|
||||
// Annotate all the groups and groupings belonging to the course
|
||||
$this->add_step(new backup_annotate_course_groups_and_groupings('annotate_course_groups'));
|
||||
// Annotate all the groups and groupings belonging to the course. This can be optional.
|
||||
if ($this->get_setting_value('groups')) {
|
||||
$this->add_step(new backup_annotate_course_groups_and_groupings('annotate_course_groups'));
|
||||
}
|
||||
|
||||
// Annotate the groups used in already annotated groupings (note this may be
|
||||
// unnecessary now that we are annotating all the course groups and groupings in the
|
||||
// step above. But we keep it working in case we decide, someday, to introduce one
|
||||
// setting to transform the step above into an optional one. This is here to support
|
||||
// course->defaultgroupingid
|
||||
$this->add_step(new backup_annotate_groups_from_groupings('annotate_groups_from_groupings'));
|
||||
// step above). This is here to support course->defaultgroupingid.
|
||||
// This may not be required to annotate if groups are not being backed up.
|
||||
if ($this->get_setting_value('groups')) {
|
||||
$this->add_step(new backup_annotate_groups_from_groupings('annotate_groups_from_groupings'));
|
||||
}
|
||||
|
||||
// Annotate the question_categories belonging to the course context (conditionally).
|
||||
if ($this->get_setting_value('questionbank')) {
|
||||
|
@ -159,5 +159,9 @@ class backup_root_task extends backup_task {
|
||||
$questionbank = new backup_generic_setting('questionbank', base_setting::IS_BOOLEAN, true);
|
||||
$questionbank->set_ui(new backup_setting_ui_checkbox($questionbank, get_string('rootsettingquestionbank', 'backup')));
|
||||
$this->add_setting($questionbank);
|
||||
|
||||
$groups = new backup_groups_setting('groups', base_setting::IS_BOOLEAN, true);
|
||||
$groups->set_ui(new backup_setting_ui_checkbox($groups, get_string('rootsettinggroups', 'backup')));
|
||||
$this->add_setting($groups);
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,15 @@ class backup_filename_setting extends backup_generic_setting {
|
||||
*/
|
||||
class backup_users_setting extends backup_generic_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if backup will include group information depends on @backup_users_setting
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @copyright 2014 Matt Sammarco
|
||||
*/
|
||||
class backup_groups_setting extends backup_generic_setting {
|
||||
}
|
||||
|
||||
/**
|
||||
* root setting to control if backup will include activities or no.
|
||||
* A lot of other settings (_included at activity levels)
|
||||
|
@ -1149,8 +1149,10 @@ class backup_groups_structure_step extends backup_structure_step {
|
||||
|
||||
protected function define_structure() {
|
||||
|
||||
// To know if we are including users
|
||||
$users = $this->get_setting_value('users');
|
||||
// To know if we are including users.
|
||||
$userinfo = $this->get_setting_value('users');
|
||||
// To know if we are including groups and groupings.
|
||||
$groupinfo = $this->get_setting_value('groups');
|
||||
|
||||
// Define each element separated
|
||||
|
||||
@ -1190,27 +1192,29 @@ class backup_groups_structure_step extends backup_structure_step {
|
||||
|
||||
// Define sources
|
||||
|
||||
$group->set_source_sql("
|
||||
SELECT g.*
|
||||
FROM {groups} g
|
||||
JOIN {backup_ids_temp} bi ON g.id = bi.itemid
|
||||
WHERE bi.backupid = ?
|
||||
AND bi.itemname = 'groupfinal'", array(backup::VAR_BACKUPID));
|
||||
// This only happens if we are including groups/groupings.
|
||||
if ($groupinfo) {
|
||||
$group->set_source_sql("
|
||||
SELECT g.*
|
||||
FROM {groups} g
|
||||
JOIN {backup_ids_temp} bi ON g.id = bi.itemid
|
||||
WHERE bi.backupid = ?
|
||||
AND bi.itemname = 'groupfinal'", array(backup::VAR_BACKUPID));
|
||||
|
||||
// This only happens if we are including users
|
||||
if ($users) {
|
||||
$member->set_source_table('groups_members', array('groupid' => backup::VAR_PARENTID));
|
||||
$grouping->set_source_sql("
|
||||
SELECT g.*
|
||||
FROM {groupings} g
|
||||
JOIN {backup_ids_temp} bi ON g.id = bi.itemid
|
||||
WHERE bi.backupid = ?
|
||||
AND bi.itemname = 'groupingfinal'", array(backup::VAR_BACKUPID));
|
||||
$groupinggroup->set_source_table('groupings_groups', array('groupingid' => backup::VAR_PARENTID));
|
||||
|
||||
// This only happens if we are including users.
|
||||
if ($userinfo) {
|
||||
$member->set_source_table('groups_members', array('groupid' => backup::VAR_PARENTID));
|
||||
}
|
||||
}
|
||||
|
||||
$grouping->set_source_sql("
|
||||
SELECT g.*
|
||||
FROM {groupings} g
|
||||
JOIN {backup_ids_temp} bi ON g.id = bi.itemid
|
||||
WHERE bi.backupid = ?
|
||||
AND bi.itemname = 'groupingfinal'", array(backup::VAR_BACKUPID));
|
||||
|
||||
$groupinggroup->set_source_table('groupings_groups', array('groupingid' => backup::VAR_PARENTID));
|
||||
|
||||
// Define id annotations (as final)
|
||||
|
||||
$member->annotate_ids('userfinal', 'userid');
|
||||
@ -1241,7 +1245,7 @@ class backup_users_structure_step extends backup_structure_step {
|
||||
// To know if we are including role assignments
|
||||
$roleassignments = $this->get_setting_value('role_assignments');
|
||||
|
||||
// Define each element separated
|
||||
// Define each element separate.
|
||||
|
||||
$users = new backup_nested_element('users');
|
||||
|
||||
|
@ -249,5 +249,22 @@ class restore_root_task extends restore_task {
|
||||
// The restore does not process the grade histories when some activities are ignored.
|
||||
// So let's define a dependency to prevent false expectations from our users.
|
||||
$activities->add_dependency($gradehistories);
|
||||
|
||||
// Define groups and groupings.
|
||||
$defaultvalue = false;
|
||||
$changeable = false;
|
||||
if (isset($rootsettings['groups']) && $rootsettings['groups']) { // Only enabled when available.
|
||||
$defaultvalue = true;
|
||||
$changeable = true;
|
||||
} else if (!isset($rootsettings['groups'])) {
|
||||
// It is likely this is an older backup that does not contain information on the group setting,
|
||||
// in which case groups should be restored and this setting can be changed.
|
||||
$defaultvalue = true;
|
||||
$changeable = true;
|
||||
}
|
||||
$groups = new restore_groups_setting('groups', base_setting::IS_BOOLEAN, $defaultvalue);
|
||||
$groups->set_ui(new backup_setting_ui_checkbox($groups, get_string('rootsettinggroups', 'backup')));
|
||||
$groups->get_ui()->set_changeable($changeable);
|
||||
$this->add_setting($groups);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,15 @@ class restore_generic_setting extends root_backup_setting {}
|
||||
*/
|
||||
class restore_users_setting extends restore_generic_setting {}
|
||||
|
||||
/**
|
||||
* root setting to control if restore will create groups/grouping information. Depends on @restore_users_setting
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @copyright 2014 Matt Sammarco
|
||||
*/
|
||||
class restore_groups_setting extends restore_generic_setting {
|
||||
}
|
||||
|
||||
/**
|
||||
* root setting to control if restore will create role assignments
|
||||
* or no (any level), depends of @restore_users_setting
|
||||
|
@ -683,7 +683,7 @@ class restore_update_availability extends restore_execution_step {
|
||||
if (!is_null($section->availability)) {
|
||||
$info = new \core_availability\info_section($section);
|
||||
$info->update_after_restore($this->get_restoreid(),
|
||||
$this->get_courseid(), $this->get_logger(), $dateoffset);
|
||||
$this->get_courseid(), $this->get_logger(), $dateoffset, $this->task);
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
@ -703,7 +703,7 @@ class restore_update_availability extends restore_execution_step {
|
||||
if (!is_null($cm->availability)) {
|
||||
$info = new \core_availability\info_module($cm);
|
||||
$info->update_after_restore($this->get_restoreid(),
|
||||
$this->get_courseid(), $this->get_logger(), $dateoffset);
|
||||
$this->get_courseid(), $this->get_logger(), $dateoffset, $this->task);
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
@ -937,10 +937,13 @@ class restore_groups_structure_step extends restore_structure_step {
|
||||
|
||||
$paths = array(); // Add paths here
|
||||
|
||||
$paths[] = new restore_path_element('group', '/groups/group');
|
||||
$paths[] = new restore_path_element('grouping', '/groups/groupings/grouping');
|
||||
$paths[] = new restore_path_element('grouping_group', '/groups/groupings/grouping/grouping_groups/grouping_group');
|
||||
|
||||
// Do not include group/groupings information if not requested.
|
||||
$groupinfo = $this->get_setting_value('groups');
|
||||
if ($groupinfo) {
|
||||
$paths[] = new restore_path_element('group', '/groups/group');
|
||||
$paths[] = new restore_path_element('grouping', '/groups/groupings/grouping');
|
||||
$paths[] = new restore_path_element('grouping_group', '/groups/groupings/grouping/grouping_groups/grouping_group');
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
|
||||
@ -1069,7 +1072,7 @@ class restore_groups_members_structure_step extends restore_structure_step {
|
||||
|
||||
$paths = array(); // Add paths here
|
||||
|
||||
if ($this->get_setting_value('users')) {
|
||||
if ($this->get_setting_value('groups') && $this->get_setting_value('users')) {
|
||||
$paths[] = new restore_path_element('group', '/groups/group');
|
||||
$paths[] = new restore_path_element('member', '/groups/group/group_members/group_member');
|
||||
}
|
||||
|
@ -574,7 +574,8 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
'backup_auto_userscompletion' => 'userscompletion',
|
||||
'backup_auto_logs' => 'logs',
|
||||
'backup_auto_histories' => 'grade_histories',
|
||||
'backup_auto_questionbank' => 'questionbank'
|
||||
'backup_auto_questionbank' => 'questionbank',
|
||||
'backup_auto_groups' => 'groups'
|
||||
);
|
||||
$plan = $controller->get_plan();
|
||||
foreach ($settings as $config => $settingname) {
|
||||
@ -612,7 +613,8 @@ abstract class backup_controller_dbops extends backup_dbops {
|
||||
'backup_general_userscompletion' => 'userscompletion',
|
||||
'backup_general_logs' => 'logs',
|
||||
'backup_general_histories' => 'grade_histories',
|
||||
'backup_general_questionbank' => 'questionbank'
|
||||
'backup_general_questionbank' => 'questionbank',
|
||||
'backup_general_groups' => 'groups'
|
||||
);
|
||||
$plan = $controller->get_plan();
|
||||
foreach ($settings as $config=>$settingname) {
|
||||
|
@ -87,6 +87,7 @@ $string['configgeneralfilters'] = 'Sets the default for including filters in a b
|
||||
$string['configgeneralhistories'] = 'Sets the default for including user history within a backup.';
|
||||
$string['configgenerallogs'] = 'If enabled logs will be included in backups by default.';
|
||||
$string['configgeneralquestionbank'] = 'If enabled the question bank will be included in backups by default. PLEASE NOTE: Disabling this setting will disable the backup of activities which use the question bank, such as the quiz.';
|
||||
$string['configgeneralgroups'] = 'Sets the default for including groups and groupings in a backup.';
|
||||
$string['configgeneralroleassignments'] = 'If enabled by default roles assignments will also be backed up.';
|
||||
$string['configgeneraluserscompletion'] = 'If enabled user completion information will be included in backups by default.';
|
||||
$string['configgeneralusers'] = 'Sets the default for whether to include users in backups.';
|
||||
@ -138,6 +139,7 @@ $string['generalhistories'] = 'Include histories';
|
||||
$string['generalgradehistories'] = 'Include histories';
|
||||
$string['generallogs'] = 'Include logs';
|
||||
$string['generalquestionbank'] = 'Include question bank';
|
||||
$string['generalgroups'] = 'Include groups and groupings';
|
||||
$string['generalroleassignments'] = 'Include role assignments';
|
||||
$string['generalsettings'] = 'General backup settings';
|
||||
$string['generaluserscompletion'] = 'Include user completion information';
|
||||
@ -235,6 +237,7 @@ $string['rootsettinguserscompletion'] = 'Include user completion details';
|
||||
$string['rootsettingquestionbank'] = 'Include question bank';
|
||||
$string['rootsettinglogs'] = 'Include course logs';
|
||||
$string['rootsettinggradehistories'] = 'Include grade history';
|
||||
$string['rootsettinggroups'] = 'Include groups and groupings';
|
||||
$string['rootsettingimscc1'] = 'Convert to IMS Common Cartridge 1.0';
|
||||
$string['rootsettingimscc11'] = 'Convert to IMS Common Cartridge 1.1';
|
||||
$string['sitecourseformatwarning'] = 'This is a front page backup, note that they can only be restored on the front page';
|
||||
|
@ -33,6 +33,12 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
class restore_assign_activity_structure_step extends restore_activity_structure_step {
|
||||
|
||||
/**
|
||||
* Store whether submission details should be included. Details may not be included if the
|
||||
* this is a team submission, but groups/grouping information was not included in the backup.
|
||||
*/
|
||||
protected $includesubmission = true;
|
||||
|
||||
/**
|
||||
* Define the structure of the restore workflow.
|
||||
*
|
||||
@ -80,6 +86,14 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
||||
$data->timemodified = $this->apply_date_offset($data->timemodified);
|
||||
$data->allowsubmissionsfromdate = $this->apply_date_offset($data->allowsubmissionsfromdate);
|
||||
$data->duedate = $this->apply_date_offset($data->duedate);
|
||||
|
||||
// If this is a team submission, but there is no group info we need to flag that the submission
|
||||
// information should not be included. It should not be restored.
|
||||
$groupinfo = $this->task->get_setting_value('groups');
|
||||
if ($data->teamsubmission && !$groupinfo) {
|
||||
$this->includesubmission = false;
|
||||
}
|
||||
|
||||
if (!empty($data->teamsubmissiongroupingid)) {
|
||||
$data->teamsubmissiongroupingid = $this->get_mappingid('grouping',
|
||||
$data->teamsubmissiongroupingid);
|
||||
@ -120,6 +134,10 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
||||
protected function process_assign_submission($data) {
|
||||
global $DB;
|
||||
|
||||
if (!$this->includesubmission) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = (object)$data;
|
||||
$oldid = $data->id;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user