Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/workshop/form/comments/backup/moodle2/backup_workshopform_comments_subplugin.class.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00024 defined('MOODLE_INTERNAL') || die();
00025 
00029 class backup_workshopform_comments_subplugin extends backup_subplugin {
00030 
00034     protected function define_workshop_subplugin_structure() {
00035 
00036         // XML nodes declaration
00037         $subplugin = $this->get_subplugin_element(); // virtual optigroup element
00038         $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
00039         $subplugindimension = new backup_nested_element('workshopform_comments_dimension', array('id'), array(
00040             'sort', 'description', 'descriptionformat'));
00041 
00042         // connect XML elements into the tree
00043         $subplugin->add_child($subpluginwrapper);
00044         $subpluginwrapper->add_child($subplugindimension);
00045 
00046         // set source to populate the data
00047         $subplugindimension->set_source_table('workshopform_comments', array('workshopid' => backup::VAR_ACTIVITYID));
00048 
00049         // file annotations
00050         $subplugindimension->annotate_files('workshopform_comments', 'description', 'id');
00051 
00052         return $subplugin;
00053     }
00054 
00058     protected function define_referenceassessment_subplugin_structure() {
00059         return $this->dimension_grades_structure('workshopform_comments_referencegrade');
00060     }
00061 
00065     protected function define_exampleassessment_subplugin_structure() {
00066         return $this->dimension_grades_structure('workshopform_comments_examplegrade');
00067     }
00068 
00072     protected function define_assessment_subplugin_structure() {
00073         return $this->dimension_grades_structure('workshopform_comments_grade');
00074     }
00075 
00077     // internal private methods
00079 
00085     private function dimension_grades_structure($elementname) {
00086 
00087         // create XML elements
00088         $subplugin = $this->get_subplugin_element(); // virtual optigroup element
00089         $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
00090         $subplugingrade = new backup_nested_element($elementname, array('id'), array(
00091             'dimensionid', 'peercomment', 'peercommentformat'));
00092 
00093         // connect XML elements into the tree
00094         $subplugin->add_child($subpluginwrapper);
00095         $subpluginwrapper->add_child($subplugingrade);
00096 
00097         // set source to populate the data
00098         $subplugingrade->set_source_sql(
00099             "SELECT id, dimensionid, peercomment, peercommentformat
00100                FROM {workshop_grades}
00101               WHERE strategy = 'comments' AND assessmentid = ?",
00102               array(backup::VAR_PARENTID));
00103 
00104         return $subplugin;
00105     }
00106 }
 All Data Structures Namespaces Files Functions Variables Enumerations