Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/workshop/form/numerrors/backup/moodle2/backup_workshopform_numerrors_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 
00025 defined('MOODLE_INTERNAL') || die();
00026 
00030 class backup_workshopform_numerrors_subplugin extends backup_subplugin {
00031 
00035     protected function define_workshop_subplugin_structure() {
00036 
00037         // XML nodes declaration
00038         $subplugin = $this->get_subplugin_element(); // virtual optigroup element
00039         $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
00040         $subpluginmap = new backup_nested_element('workshopform_numerrors_map', array('id'), array(
00041             'nonegative', 'grade'));
00042         $subplugindimension = new backup_nested_element('workshopform_numerrors_dimension', array('id'), array(
00043             'sort', 'description', 'descriptionformat', 'grade0', 'grade1', 'weight'));
00044 
00045         // connect XML elements into the tree
00046         $subplugin->add_child($subpluginwrapper);
00047         $subpluginwrapper->add_child($subpluginmap);
00048         $subpluginwrapper->add_child($subplugindimension);
00049 
00050         // set source to populate the data
00051         $subpluginmap->set_source_table('workshopform_numerrors_map', array('workshopid' => backup::VAR_ACTIVITYID));
00052         $subplugindimension->set_source_table('workshopform_numerrors', array('workshopid' => backup::VAR_ACTIVITYID));
00053 
00054         // file annotations
00055         $subplugindimension->annotate_files('workshopform_numerrors', 'description', 'id');
00056 
00057         return $subplugin;
00058     }
00059 
00063     protected function define_referenceassessment_subplugin_structure() {
00064         return $this->dimension_grades_structure('workshopform_numerrors_referencegrade');
00065     }
00066 
00070     protected function define_exampleassessment_subplugin_structure() {
00071         return $this->dimension_grades_structure('workshopform_numerrors_examplegrade');
00072     }
00073 
00077     protected function define_assessment_subplugin_structure() {
00078         return $this->dimension_grades_structure('workshopform_numerrors_grade');
00079     }
00080 
00082     // internal private methods
00084 
00090     private function dimension_grades_structure($elementname) {
00091 
00092         // create XML elements
00093         $subplugin = $this->get_subplugin_element(); // virtual optigroup element
00094         $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
00095         $subplugingrade = new backup_nested_element($elementname, array('id'), array(
00096             'dimensionid', 'grade', 'peercomment', 'peercommentformat'));
00097 
00098         // connect XML elements into the tree
00099         $subplugin->add_child($subpluginwrapper);
00100         $subpluginwrapper->add_child($subplugingrade);
00101 
00102         // set source to populate the data
00103         $subplugingrade->set_source_sql(
00104             "SELECT id, dimensionid, grade, peercomment, peercommentformat
00105                FROM {workshop_grades}
00106               WHERE strategy = 'numerrors' AND assessmentid = ?",
00107               array(backup::VAR_PARENTID));
00108 
00109         return $subplugin;
00110     }
00111 }
 All Data Structures Namespaces Files Functions Variables Enumerations