|
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 00032 class backup_assignment_activity_structure_step extends backup_activity_structure_step { 00033 00034 protected function define_structure() { 00035 00036 // To know if we are including userinfo 00037 $userinfo = $this->get_setting_value('userinfo'); 00038 00039 // Define each element separated 00040 $assignment = new backup_nested_element('assignment', array('id'), array( 00041 'name', 'intro', 'introformat', 'assignmenttype', 00042 'resubmit', 'preventlate', 'emailteachers', 'var1', 00043 'var2', 'var3', 'var4', 'var5', 00044 'maxbytes', 'timedue', 'timeavailable', 'grade', 00045 'timemodified')); 00046 00047 $submissions = new backup_nested_element('submissions'); 00048 00049 $submission = new backup_nested_element('submission', array('id'), array( 00050 'userid', 'timecreated', 'timemodified', 'numfiles', 00051 'data1', 'data2', 'grade', 'submissioncomment', 00052 'format', 'teacher', 'timemarked', 'mailed')); 00053 00054 // Build the tree 00055 00056 // Apply for 'assignment' subplugins optional stuff at assignment level (not multiple) 00057 // Remember that order is important, try moving this line to the end and compare XML 00058 $this->add_subplugin_structure('assignment', $assignment, false); 00059 00060 $assignment->add_child($submissions); 00061 $submissions->add_child($submission); 00062 00063 // Apply for 'assignment' subplugins optional stuff at submission level (not multiple) 00064 $this->add_subplugin_structure('assignment', $submission, false); 00065 00066 // Define sources 00067 $assignment->set_source_table('assignment', array('id' => backup::VAR_ACTIVITYID)); 00068 00069 // All the rest of elements only happen if we are including user info 00070 if ($userinfo) { 00071 $submission->set_source_table('assignment_submissions', array('assignment' => backup::VAR_PARENTID)); 00072 } 00073 00074 // Define id annotations 00075 $assignment->annotate_ids('scale', 'grade'); 00076 $submission->annotate_ids('user', 'userid'); 00077 $submission->annotate_ids('user', 'teacher'); 00078 00079 // Define file annotations 00080 $assignment->annotate_files('mod_assignment', 'intro', null); // This file area hasn't itemid 00081 $submission->annotate_files('mod_assignment', 'submission', 'id'); 00082 $submission->annotate_files('mod_assignment', 'response', 'id'); 00083 00084 // Return the root element (assignment), wrapped into standard activity structure 00085 return $this->prepare_activity_structure($assignment); 00086 } 00087 }