|
Moodle
2.2.1
http://www.collinsharper.com
|
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_accumulative_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_accumulative_dimension', array('id'), array( 00040 'sort', 'description', 'descriptionformat', 'grade', 'weight')); 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_accumulative', array('workshopid' => backup::VAR_ACTIVITYID)); 00048 00049 // id annotations 00050 $subplugindimension->annotate_ids('scale', 'grade'); 00051 00052 // file annotations 00053 $subplugindimension->annotate_files('workshopform_accumulative', 'description', 'id'); 00054 00055 return $subplugin; 00056 } 00057 00061 protected function define_referenceassessment_subplugin_structure() { 00062 return $this->dimension_grades_structure('workshopform_accumulative_referencegrade'); 00063 } 00064 00068 protected function define_exampleassessment_subplugin_structure() { 00069 return $this->dimension_grades_structure('workshopform_accumulative_examplegrade'); 00070 } 00071 00075 protected function define_assessment_subplugin_structure() { 00076 return $this->dimension_grades_structure('workshopform_accumulative_grade'); 00077 } 00078 00080 // internal private methods 00082 00088 private function dimension_grades_structure($elementname) { 00089 00090 // create XML elements 00091 $subplugin = $this->get_subplugin_element(); // virtual optigroup element 00092 $subpluginwrapper = new backup_nested_element($this->get_recommended_name()); 00093 $subplugingrade = new backup_nested_element($elementname, array('id'), array( 00094 'dimensionid', 'grade', 'peercomment', 'peercommentformat')); 00095 00096 // connect XML elements into the tree 00097 $subplugin->add_child($subpluginwrapper); 00098 $subpluginwrapper->add_child($subplugingrade); 00099 00100 // set source to populate the data 00101 $subplugingrade->set_source_sql( 00102 "SELECT id, dimensionid, grade, peercomment, peercommentformat 00103 FROM {workshop_grades} 00104 WHERE strategy = 'accumulative' AND assessmentid = ?", 00105 array(backup::VAR_PARENTID)); 00106 00107 return $subplugin; 00108 } 00109 }