Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/feedback/backup/moodle2/backup_feedback_stepslib.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00031 class backup_feedback_activity_structure_step extends backup_activity_structure_step {
00032 
00033     protected function define_structure() {
00034 
00035         // To know if we are including userinfo
00036         $userinfo = $this->get_setting_value('userinfo');
00037 
00038         // Define each element separated
00039         $feedback = new backup_nested_element('feedback', array('id'), array(
00040                                                 'name',
00041                                                 'intro',
00042                                                 'introformat',
00043                                                 'anonymous',
00044                                                 'email_notification',
00045                                                 'multiple_submit',
00046                                                 'autonumbering',
00047                                                 'site_after_submit',
00048                                                 'page_after_submit',
00049                                                 'page_after_submitformat',
00050                                                 'publish_stats',
00051                                                 'timeopen',
00052                                                 'timeclose',
00053                                                 'timemodified',
00054                                                 'completionsubmit'));
00055 
00056         $completeds = new backup_nested_element('completeds');
00057 
00058         $completed = new backup_nested_element('completed', array('id'), array(
00059                                                 'userid',
00060                                                 'timemodified',
00061                                                 'random_response',
00062                                                 'anonymous_response'));
00063 
00064         $items = new backup_nested_element('items');
00065 
00066         $item = new backup_nested_element('item', array('id'), array(
00067                                                 'template',
00068                                                 'name',
00069                                                 'label',
00070                                                 'presentation',
00071                                                 'typ',
00072                                                 'hasvalue',
00073                                                 'position',
00074                                                 'required',
00075                                                 'dependitem',
00076                                                 'dependvalue',
00077                                                 'options'));
00078 
00079         $trackings = new backup_nested_element('trackings');
00080 
00081         $tracking = new backup_nested_element('tracking', array('id'), array(
00082                                                 'userid',
00083                                                 'completed'));
00084 
00085         $values = new backup_nested_element('values');
00086 
00087         $value = new backup_nested_element('value', array('id'), array(
00088                                                 'item',
00089                                                 'template',
00090                                                 'completed',
00091                                                 'value'));
00092 
00093         // Build the tree
00094         $feedback->add_child($items);
00095         $items->add_child($item);
00096 
00097         $feedback->add_child($completeds);
00098         $completeds->add_child($completed);
00099 
00100         $completed->add_child($values);
00101         $values->add_child($value);
00102 
00103         $feedback->add_child($trackings);
00104         $trackings->add_child($tracking);
00105 
00106         // Define sources
00107         $feedback->set_source_table('feedback', array('id' => backup::VAR_ACTIVITYID));
00108 
00109         $item->set_source_table('feedback_item', array('feedback' => backup::VAR_PARENTID));
00110 
00111         // All these source definitions only happen if we are including user info
00112         if ($userinfo) {
00113             $completed->set_source_sql('
00114                 SELECT *
00115                   FROM {feedback_completed}
00116                  WHERE feedback = ?',
00117                 array(backup::VAR_PARENTID));
00118 
00119             $value->set_source_table('feedback_value', array('completed' => backup::VAR_PARENTID));
00120 
00121             $tracking->set_source_table('feedback_tracking', array('feedback' => backup::VAR_PARENTID));
00122         }
00123 
00124         // Define id annotations
00125 
00126         $completed->annotate_ids('user', 'userid');
00127 
00128         $tracking->annotate_ids('user', 'userid');
00129 
00130         // Define file annotations
00131 
00132         $feedback->annotate_files('mod_feedback', 'intro', null); // This file area hasn't itemid
00133 
00134         $item->annotate_files('mod_feedback', 'item', 'id');
00135 
00136         // Return the root element (feedback), wrapped into standard activity structure
00137         return $this->prepare_activity_structure($feedback);
00138     }
00139 
00140 }
 All Data Structures Namespaces Files Functions Variables Enumerations