|
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 00025 defined('MOODLE_INTERNAL') || die(); 00026 00031 class restore_workshopform_rubric_subplugin extends restore_subplugin { 00032 00034 // mappings of XML paths to the processable methods 00036 00040 protected function define_workshop_subplugin_structure() { 00041 00042 $paths = array(); 00043 00044 $elename = $this->get_namefor('config'); 00045 $elepath = $this->get_pathfor('/workshopform_rubric_config'); 00046 $paths[] = new restore_path_element($elename, $elepath); 00047 00048 $elename = $this->get_namefor('dimension'); 00049 $elepath = $this->get_pathfor('/workshopform_rubric_dimension'); 00050 $paths[] = new restore_path_element($elename, $elepath); 00051 00052 $elename = $this->get_namefor('level'); 00053 $elepath = $this->get_pathfor('/workshopform_rubric_dimension/workshopform_rubric_level'); 00054 $paths[] = new restore_path_element($elename, $elepath); 00055 00056 return $paths; // And we return the interesting paths 00057 } 00058 00062 protected function define_referenceassessment_subplugin_structure() { 00063 00064 $paths = array(); 00065 00066 $elename = $this->get_namefor('referencegrade'); 00067 $elepath = $this->get_pathfor('/workshopform_rubric_referencegrade'); // we used get_recommended_name() so this works 00068 $paths[] = new restore_path_element($elename, $elepath); 00069 00070 return $paths; // And we return the interesting paths 00071 } 00072 00076 protected function define_exampleassessment_subplugin_structure() { 00077 00078 $paths = array(); 00079 00080 $elename = $this->get_namefor('examplegrade'); 00081 $elepath = $this->get_pathfor('/workshopform_rubric_examplegrade'); // we used get_recommended_name() so this works 00082 $paths[] = new restore_path_element($elename, $elepath); 00083 00084 return $paths; // And we return the interesting paths 00085 } 00086 00090 protected function define_assessment_subplugin_structure() { 00091 00092 $paths = array(); 00093 00094 $elename = $this->get_namefor('grade'); 00095 $elepath = $this->get_pathfor('/workshopform_rubric_grade'); // we used get_recommended_name() so this works 00096 $paths[] = new restore_path_element($elename, $elepath); 00097 00098 return $paths; // And we return the interesting paths 00099 } 00100 00102 // defined path elements are dispatched to the following methods 00104 00108 public function process_workshopform_rubric_config($data) { 00109 global $DB; 00110 00111 $data = (object)$data; 00112 $data->workshopid = $this->get_new_parentid('workshop'); 00113 $DB->insert_record('workshopform_rubric_config', $data); 00114 } 00115 00119 public function process_workshopform_rubric_dimension($data) { 00120 global $DB; 00121 00122 $data = (object)$data; 00123 $oldid = $data->id; 00124 00125 $data->workshopid = $this->get_new_parentid('workshop'); 00126 00127 $newitemid = $DB->insert_record('workshopform_rubric', $data); 00128 $this->set_mapping($this->get_namefor('dimension'), $oldid, $newitemid, true); 00129 00130 // Process files for this workshopform_rubric->id only 00131 $this->add_related_files('workshopform_rubric', 'description', $this->get_namefor('dimension'), null, $oldid); 00132 } 00133 00137 public function process_workshopform_rubric_level($data) { 00138 global $DB; 00139 00140 $data = (object)$data; 00141 $data->dimensionid = $this->get_new_parentid($this->get_namefor('dimension')); 00142 $DB->insert_record('workshopform_rubric_levels', $data); 00143 } 00144 00148 public function process_workshopform_rubric_referencegrade($data) { 00149 $this->process_dimension_grades_structure('workshop_referenceassessment', $data); 00150 } 00151 00155 public function process_workshopform_rubric_examplegrade($data) { 00156 $this->process_dimension_grades_structure('workshop_exampleassessment', $data); 00157 } 00158 00162 public function process_workshopform_rubric_grade($data) { 00163 $this->process_dimension_grades_structure('workshop_assessment', $data); 00164 } 00165 00167 // internal private methods 00169 00179 private function process_dimension_grades_structure($elementname, $data) { 00180 global $DB; 00181 00182 $data = (object)$data; 00183 $oldid = $data->id; 00184 00185 $data->assessmentid = $this->get_new_parentid($elementname); 00186 $data->strategy = 'rubric'; 00187 $data->dimensionid = $this->get_mappingid($this->get_namefor('dimension'), $data->dimensionid); 00188 00189 $DB->insert_record('workshop_grades', $data); 00190 } 00191 }