See Release Notes
Long Term Support Release
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 mod_workshop 20 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 */ 23 24 /** 25 * Define all the restore steps that will be used by the restore_workshop_activity_task 26 */ 27 28 /** 29 * Structure step to restore one workshop activity 30 */ 31 class restore_workshop_activity_structure_step extends restore_activity_structure_step { 32 33 protected function define_structure() { 34 35 $paths = array(); 36 37 $userinfo = $this->get_setting_value('userinfo'); // are we including userinfo? 38 39 //////////////////////////////////////////////////////////////////////// 40 // XML interesting paths - non-user data 41 //////////////////////////////////////////////////////////////////////// 42 43 // root element describing workshop instance 44 $workshop = new restore_path_element('workshop', '/activity/workshop'); 45 $paths[] = $workshop; 46 47 // Apply for 'workshopform' subplugins optional paths at workshop level 48 $this->add_subplugin_structure('workshopform', $workshop); 49 50 // Apply for 'workshopeval' subplugins optional paths at workshop level 51 $this->add_subplugin_structure('workshopeval', $workshop); 52 53 // example submissions 54 $paths[] = new restore_path_element('workshop_examplesubmission', 55 '/activity/workshop/examplesubmissions/examplesubmission'); 56 57 // reference assessment of the example submission 58 $referenceassessment = new restore_path_element('workshop_referenceassessment', 59 '/activity/workshop/examplesubmissions/examplesubmission/referenceassessment'); 60 $paths[] = $referenceassessment; 61 62 // Apply for 'workshopform' subplugins optional paths at referenceassessment level 63 $this->add_subplugin_structure('workshopform', $referenceassessment); 64 65 // End here if no-user data has been selected 66 if (!$userinfo) { 67 return $this->prepare_activity_structure($paths); 68 } 69 70 //////////////////////////////////////////////////////////////////////// 71 // XML interesting paths - user data 72 //////////////////////////////////////////////////////////////////////// 73 74 // assessments of example submissions 75 $exampleassessment = new restore_path_element('workshop_exampleassessment', 76 '/activity/workshop/examplesubmissions/examplesubmission/exampleassessments/exampleassessment'); 77 $paths[] = $exampleassessment; 78 79 // Apply for 'workshopform' subplugins optional paths at exampleassessment level 80 $this->add_subplugin_structure('workshopform', $exampleassessment); 81 82 // submissions 83 $paths[] = new restore_path_element('workshop_submission', '/activity/workshop/submissions/submission'); 84 85 // allocated assessments 86 $assessment = new restore_path_element('workshop_assessment', 87 '/activity/workshop/submissions/submission/assessments/assessment'); 88 $paths[] = $assessment; 89 90 // Apply for 'workshopform' subplugins optional paths at assessment level 91 $this->add_subplugin_structure('workshopform', $assessment); 92 93 // aggregations of grading grades in this workshop 94 $paths[] = new restore_path_element('workshop_aggregation', '/activity/workshop/aggregations/aggregation'); 95 96 // Return the paths wrapped into standard activity structure 97 return $this->prepare_activity_structure($paths); 98 } 99 100 protected function process_workshop($data) { 101 global $DB; 102 103 $data = (object)$data; 104 $oldid = $data->id; 105 $data->course = $this->get_courseid(); 106 107 // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset. 108 // See MDL-9367. 109 $data->submissionstart = $this->apply_date_offset($data->submissionstart); 110 $data->submissionend = $this->apply_date_offset($data->submissionend); 111 $data->assessmentstart = $this->apply_date_offset($data->assessmentstart); 112 $data->assessmentend = $this->apply_date_offset($data->assessmentend); 113 114 if ($data->nattachments == 0) { 115 // Convert to the new method for disabling file submissions. 116 $data->submissiontypefile = WORKSHOP_SUBMISSION_TYPE_DISABLED; 117 $data->submissiontypetext = WORKSHOP_SUBMISSION_TYPE_REQUIRED; 118 $data->nattachments = 1; 119 } 120 121 // insert the workshop record 122 $newitemid = $DB->insert_record('workshop', $data); 123 // immediately after inserting "activity" record, call this 124 $this->apply_activity_instance($newitemid); 125 } 126 127 protected function process_workshop_examplesubmission($data) { 128 global $DB; 129 130 $data = (object)$data; 131 $oldid = $data->id; 132 133 $data->workshopid = $this->get_new_parentid('workshop'); 134 $data->example = 1; 135 $data->authorid = $this->task->get_userid(); 136 137 $newitemid = $DB->insert_record('workshop_submissions', $data); 138 $this->set_mapping('workshop_examplesubmission', $oldid, $newitemid, true); // Mapping with files 139 } 140 141 protected function process_workshop_referenceassessment($data) { 142 global $DB; 143 144 $data = (object)$data; 145 $oldid = $data->id; 146 147 $data->submissionid = $this->get_new_parentid('workshop_examplesubmission'); 148 $data->reviewerid = $this->task->get_userid(); 149 150 $newitemid = $DB->insert_record('workshop_assessments', $data); 151 $this->set_mapping('workshop_referenceassessment', $oldid, $newitemid, true); // Mapping with files 152 } 153 154 protected function process_workshop_exampleassessment($data) { 155 global $DB; 156 157 $data = (object)$data; 158 $oldid = $data->id; 159 160 $data->submissionid = $this->get_new_parentid('workshop_examplesubmission'); 161 $data->reviewerid = $this->get_mappingid('user', $data->reviewerid); 162 163 $newitemid = $DB->insert_record('workshop_assessments', $data); 164 $this->set_mapping('workshop_exampleassessment', $oldid, $newitemid, true); // Mapping with files 165 } 166 167 protected function process_workshop_submission($data) { 168 global $DB; 169 170 $data = (object)$data; 171 $oldid = $data->id; 172 173 $data->workshopid = $this->get_new_parentid('workshop'); 174 $data->example = 0; 175 $data->authorid = $this->get_mappingid('user', $data->authorid); 176 177 $newitemid = $DB->insert_record('workshop_submissions', $data); 178 $this->set_mapping('workshop_submission', $oldid, $newitemid, true); // Mapping with files 179 } 180 181 protected function process_workshop_assessment($data) { 182 global $DB; 183 184 $data = (object)$data; 185 $oldid = $data->id; 186 187 $data->submissionid = $this->get_new_parentid('workshop_submission'); 188 $data->reviewerid = $this->get_mappingid('user', $data->reviewerid); 189 190 $newitemid = $DB->insert_record('workshop_assessments', $data); 191 $this->set_mapping('workshop_assessment', $oldid, $newitemid, true); // Mapping with files 192 } 193 194 protected function process_workshop_aggregation($data) { 195 global $DB; 196 197 $data = (object)$data; 198 $oldid = $data->id; 199 200 $data->workshopid = $this->get_new_parentid('workshop'); 201 $data->userid = $this->get_mappingid('user', $data->userid); 202 203 $newitemid = $DB->insert_record('workshop_aggregations', $data); 204 $this->set_mapping('workshop_aggregation', $oldid, $newitemid, true); 205 } 206 207 protected function after_execute() { 208 // Add workshop related files, no need to match by itemname (just internally handled context) 209 $this->add_related_files('mod_workshop', 'intro', null); 210 $this->add_related_files('mod_workshop', 'instructauthors', null); 211 $this->add_related_files('mod_workshop', 'instructreviewers', null); 212 $this->add_related_files('mod_workshop', 'conclusion', null); 213 214 // Add example submission related files, matching by 'workshop_examplesubmission' itemname 215 $this->add_related_files('mod_workshop', 'submission_content', 'workshop_examplesubmission'); 216 $this->add_related_files('mod_workshop', 'submission_attachment', 'workshop_examplesubmission'); 217 218 // Add reference assessment related files, matching by 'workshop_referenceassessment' itemname 219 $this->add_related_files('mod_workshop', 'overallfeedback_content', 'workshop_referenceassessment'); 220 $this->add_related_files('mod_workshop', 'overallfeedback_attachment', 'workshop_referenceassessment'); 221 222 // Add example assessment related files, matching by 'workshop_exampleassessment' itemname 223 $this->add_related_files('mod_workshop', 'overallfeedback_content', 'workshop_exampleassessment'); 224 $this->add_related_files('mod_workshop', 'overallfeedback_attachment', 'workshop_exampleassessment'); 225 226 // Add submission related files, matching by 'workshop_submission' itemname 227 $this->add_related_files('mod_workshop', 'submission_content', 'workshop_submission'); 228 $this->add_related_files('mod_workshop', 'submission_attachment', 'workshop_submission'); 229 230 // Add assessment related files, matching by 'workshop_assessment' itemname 231 $this->add_related_files('mod_workshop', 'overallfeedback_content', 'workshop_assessment'); 232 $this->add_related_files('mod_workshop', 'overallfeedback_attachment', 'workshop_assessment'); 233 } 234 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body