Skip to content

Commit

Permalink
MDL-27532 Add backup support for course report per-course data
Browse files Browse the repository at this point in the history
  • Loading branch information
sammarshallou committed May 18, 2011
1 parent d04f7fb commit 5e0dae1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
34 changes: 34 additions & 0 deletions backup/moodle2/backup_coursereport_plugin.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();

/**
* Base class for course report backup plugins.
*
* NOTE: When you back up a course, it potentially may run backup for all
* course reports. In order to control whether a particular report gets
* backed up, a course report should make use of the second and third
* parameters in get_plugin_element().
*
* @package moodlecore
* @subpackage backup-moodle2
* @copyright 2011 onwards The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class backup_coursereport_plugin extends backup_plugin {
// Use default parent behaviour
}
1 change: 1 addition & 0 deletions backup/moodle2/backup_plan_builder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_subplugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_settingslib.php');
Expand Down
4 changes: 4 additions & 0 deletions backup/moodle2/backup_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,10 @@ protected function define_structure() {
// save course data (in case of user theme, legacy theme, etc)
$this->add_plugin_structure('theme', $course, true);

// attach course report plugin structure to $course element; multiple
// course reports can save course data if required
$this->add_plugin_structure('coursereport', $course, true);

// attach plagiarism plugin structure to $course element, only one allowed
$this->add_plugin_structure('plagiarism', $course, false);

Expand Down
29 changes: 29 additions & 0 deletions backup/moodle2/restore_coursereport_plugin.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();

/**
* Restore for course plugin: course report.
*
* @package moodlecore
* @subpackage backup-moodle2
* @copyright 2011 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class restore_coursereport_plugin extends restore_plugin {
// Use default parent behaviour
}
2 changes: 2 additions & 0 deletions backup/moodle2/restore_plan_builder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
require_once($CFG->dirroot . '/backup/moodle2/restore_qtype_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_format_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_theme_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_coursereport_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_qtype_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_format_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_theme_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_coursereport_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/backup_plagiarism_plugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_subplugin.class.php');
require_once($CFG->dirroot . '/backup/moodle2/restore_settingslib.php');
Expand Down
3 changes: 3 additions & 0 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,9 @@ protected function define_structure() {
// Apply for 'theme' plugins optional paths at course level
$this->add_plugin_structure('theme', $course);

// Apply for 'course report' plugins optional paths at course level
$this->add_plugin_structure('coursereport', $course);

// Apply for plagiarism plugins optional paths at course level
$this->add_plugin_structure('plagiarism', $course);

Expand Down

0 comments on commit 5e0dae1

Please sign in to comment.