[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package mod_feedback 19 * @subpackage backup-moodle2 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_feedback_activity_task 26 */ 27 28 /** 29 * Structure step to restore one feedback activity 30 */ 31 class restore_feedback_activity_structure_step extends restore_activity_structure_step { 32 33 protected function define_structure() { 34 35 $paths = array(); 36 $userinfo = $this->get_setting_value('userinfo'); 37 38 $paths[] = new restore_path_element('feedback', '/activity/feedback'); 39 $paths[] = new restore_path_element('feedback_item', '/activity/feedback/items/item'); 40 if ($userinfo) { 41 $paths[] = new restore_path_element('feedback_completed', '/activity/feedback/completeds/completed'); 42 $paths[] = new restore_path_element('feedback_value', '/activity/feedback/completeds/completed/values/value'); 43 $paths[] = new restore_path_element('feedback_tracking', '/activity/feedback/trackings/tracking'); 44 } 45 46 // Return the paths wrapped into standard activity structure 47 return $this->prepare_activity_structure($paths); 48 } 49 50 protected function process_feedback($data) { 51 global $DB; 52 53 $data = (object)$data; 54 $oldid = $data->id; 55 $data->course = $this->get_courseid(); 56 57 $data->timeopen = $this->apply_date_offset($data->timeopen); 58 $data->timeclose = $this->apply_date_offset($data->timeclose); 59 $data->timemodified = $this->apply_date_offset($data->timemodified); 60 61 // insert the feedback record 62 $newitemid = $DB->insert_record('feedback', $data); 63 // immediately after inserting "activity" record, call this 64 $this->apply_activity_instance($newitemid); 65 } 66 67 protected function process_feedback_item($data) { 68 global $DB; 69 70 $data = (object)$data; 71 $oldid = $data->id; 72 $data->feedback = $this->get_new_parentid('feedback'); 73 74 //dependitem 75 $data->dependitem = $this->get_mappingid('feedback_item', $data->dependitem); 76 77 $newitemid = $DB->insert_record('feedback_item', $data); 78 $this->set_mapping('feedback_item', $oldid, $newitemid, true); // Can have files 79 } 80 81 protected function process_feedback_completed($data) { 82 global $DB; 83 84 $data = (object)$data; 85 $oldid = $data->id; 86 $data->feedback = $this->get_new_parentid('feedback'); 87 $data->userid = $this->get_mappingid('user', $data->userid); 88 $data->timemodified = $this->apply_date_offset($data->timemodified); 89 90 $newitemid = $DB->insert_record('feedback_completed', $data); 91 $this->set_mapping('feedback_completed', $oldid, $newitemid); 92 } 93 94 protected function process_feedback_value($data) { 95 global $DB; 96 97 $data = (object)$data; 98 $oldid = $data->id; 99 $data->completed = $this->get_new_parentid('feedback_completed'); 100 $data->item = $this->get_mappingid('feedback_item', $data->item); 101 $data->course_id = $this->get_courseid(); 102 103 $newitemid = $DB->insert_record('feedback_value', $data); 104 $this->set_mapping('feedback_value', $oldid, $newitemid); 105 } 106 107 protected function process_feedback_tracking($data) { 108 global $DB; 109 110 $data = (object)$data; 111 $oldid = $data->id; 112 $data->feedback = $this->get_new_parentid('feedback'); 113 $data->completed = $this->get_mappingid('feedback_completed', $data->completed); 114 $data->userid = $this->get_mappingid('user', $data->userid); 115 116 $newitemid = $DB->insert_record('feedback_tracking', $data); 117 } 118 119 120 protected function after_execute() { 121 // Add feedback related files, no need to match by itemname (just internally handled context) 122 $this->add_related_files('mod_feedback', 'intro', null); 123 $this->add_related_files('mod_feedback', 'page_after_submit', null); 124 $this->add_related_files('mod_feedback', 'item', 'feedback_item'); 125 } 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |