Skip to content

Commit

Permalink
MDL-23362 backup - on restore detect missing modules / skipped activi…
Browse files Browse the repository at this point in the history
…ties, for gradebook.
  • Loading branch information
stronk7 committed Sep 14, 2010
1 parent d87b5a5 commit 58328ce
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backup/moodle2/backup_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ protected function define_structure() {
// Define sources

//Include manual, category and the course grade item
$grade_items_sql ="SELECT * FROM {grade_items}
$grade_items_sql ="SELECT * FROM {grade_items}
WHERE courseid = :courseid
AND (itemtype='manual' OR itemtype='course' OR itemtype='category')";
$grade_items_params = array('courseid'=>backup::VAR_COURSEID);
Expand Down
1 change: 1 addition & 0 deletions backup/moodle2/restore_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public function execute() {
// Find activity_included_setting
if (!$this->get_setting_value('included')) {
$this->log('activity skipped by _included setting', backup::LOG_DEBUG, $this->name);
$this->plan->set_excluding_activities(); // Inform plan we are excluding actvities

} else { // Setting tells us it's ok to execute
parent::execute();
Expand Down
3 changes: 3 additions & 0 deletions backup/moodle2/restore_plan_builder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ static protected function build_activity_plan($controller, $activityid) {
// TODO: Debug information about block not supported
}
}
} else { // Activity is missing in target site, inform plan about that
$plan->set_missing_modules();
}

}

/**
Expand Down
11 changes: 11 additions & 0 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ protected function execute_condition() {
return false;
}

// Some module present in backup file isn't available to restore
// in this site, don't execute
if ($this->task->is_missing_modules()) {
return false;
}

// Some activity has been excluded to be restored, don't execute
if ($this->task->is_excluding_activities()) {
return false;
}

// Arrived here, execute the step
return true;
}
Expand Down
21 changes: 21 additions & 0 deletions backup/util/plan/restore_plan.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class restore_plan extends base_plan implements loggable {
protected $basepath; // Fullpath to dir where backup is available
protected $preloaded; // When executing the plan, do we have preloaded (from checks) info
protected $decoder; // restore_decode_processor in charge of decoding all the interlinks
protected $missingmodules; // to flag if restore has detected some missing module
protected $excludingdactivities; // to flag if restore settings are excluding any activity

/**
* Constructor - instantiates one object of this class
Expand All @@ -51,6 +53,9 @@ public function __construct($controller) {
$this->basepath = $CFG->dataroot . '/temp/backup/' . $controller->get_tempdir();
$this->preloaded = false;
$this->decoder = new restore_decode_processor($this->get_restoreid(), $this->get_info()->original_wwwroot, $CFG->wwwroot);
$this->missingmodules = false;
$this->excludingdactivities = false;

parent::__construct('restore_plan');
}

Expand Down Expand Up @@ -96,6 +101,14 @@ public function is_samesite() {
return $this->controller->is_samesite();
}

public function is_missing_modules() {
return $this->missingmodules;
}

public function is_excluding_activities() {
return $this->excludingdactivities;
}

public function set_preloaded_information() {
$this->preloaded = true;
}
Expand All @@ -108,6 +121,14 @@ public function get_tempdir() {
return $this->controller->get_tempdir();
}

public function set_missing_modules() {
$this->missingmodules = true;
}

public function set_excluding_activities() {
$this->excludingdactivities = true;
}

public function log($message, $level, $a = null, $depth = null, $display = false) {
backup_helper::log($message, $level, $a, $depth, $display, $this->get_logger());
}
Expand Down
8 changes: 8 additions & 0 deletions backup/util/plan/restore_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ public function is_samesite() {
return $this->plan->is_samesite();
}

public function is_missing_modules() {
return $this->plan->is_missing_modules();
}

public function is_excluding_activities() {
return $this->plan->is_excluding_activities();
}

public function set_preloaded_information() {
$this->plan->set_preloaded_information();
}
Expand Down

0 comments on commit 58328ce

Please sign in to comment.