1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * @package workshopform_comments 20 * @copyright 2010 David Mudrak <david@moodle.com> 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 defined('MOODLE_INTERNAL') || die(); 24 25 /** 26 * Provides the information to backup comments grading strategy information 27 */ 28 class backup_workshopform_comments_subplugin extends backup_subplugin { 29 30 /** 31 * Returns the assessment form definition to attach to 'workshop' XML element 32 */ 33 protected function define_workshop_subplugin_structure() { 34 35 // XML nodes declaration 36 $subplugin = $this->get_subplugin_element(); // virtual optigroup element 37 $subpluginwrapper = new backup_nested_element($this->get_recommended_name()); 38 $subplugindimension = new backup_nested_element('workshopform_comments_dimension', array('id'), array( 39 'sort', 'description', 'descriptionformat')); 40 41 // connect XML elements into the tree 42 $subplugin->add_child($subpluginwrapper); 43 $subpluginwrapper->add_child($subplugindimension); 44 45 // set source to populate the data 46 $subplugindimension->set_source_table('workshopform_comments', array('workshopid' => backup::VAR_ACTIVITYID)); 47 48 // file annotations 49 $subplugindimension->annotate_files('workshopform_comments', 'description', 'id'); 50 51 return $subplugin; 52 } 53 54 /** 55 * Returns the dimension grades to attach to 'referenceassessment' XML element 56 */ 57 protected function define_referenceassessment_subplugin_structure() { 58 return $this->dimension_grades_structure('workshopform_comments_referencegrade'); 59 } 60 61 /** 62 * Returns the dimension grades to attach to 'exampleassessment' XML element 63 */ 64 protected function define_exampleassessment_subplugin_structure() { 65 return $this->dimension_grades_structure('workshopform_comments_examplegrade'); 66 } 67 68 /** 69 * Returns the dimension grades to attach to 'assessment' XML element 70 */ 71 protected function define_assessment_subplugin_structure() { 72 return $this->dimension_grades_structure('workshopform_comments_grade'); 73 } 74 75 //////////////////////////////////////////////////////////////////////////// 76 // internal private methods 77 //////////////////////////////////////////////////////////////////////////// 78 79 /** 80 * Returns the structure of dimension grades 81 * 82 * @param string forst parameter of {@link backup_nested_element} constructor 83 */ 84 private function dimension_grades_structure($elementname) { 85 86 // create XML elements 87 $subplugin = $this->get_subplugin_element(); // virtual optigroup element 88 $subpluginwrapper = new backup_nested_element($this->get_recommended_name()); 89 $subplugingrade = new backup_nested_element($elementname, array('id'), array( 90 'dimensionid', 'peercomment', 'peercommentformat')); 91 92 // connect XML elements into the tree 93 $subplugin->add_child($subpluginwrapper); 94 $subpluginwrapper->add_child($subplugingrade); 95 96 // set source to populate the data 97 $subplugingrade->set_source_sql( 98 "SELECT id, dimensionid, peercomment, peercommentformat 99 FROM {workshop_grades} 100 WHERE strategy = 'comments' AND assessmentid = ?", 101 array(backup::VAR_PARENTID)); 102 103 return $subplugin; 104 } 105 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body