[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/assign/backup/moodle2/ -> backup_assign_stepslib.php (source)

   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   * Define all the backup steps that will be used by the backup_assign_activity_task
  19   *
  20   * @package   mod_assign
  21   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Define the complete choice structure for backup, with file and id annotations
  29   *
  30   * @package   mod_assign
  31   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  32   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  class backup_assign_activity_structure_step extends backup_activity_structure_step {
  35  
  36      /**
  37       * Define the structure for the assign activity
  38       * @return void
  39       */
  40      protected function define_structure() {
  41  
  42          // To know if we are including userinfo.
  43          $userinfo = $this->get_setting_value('userinfo');
  44  
  45          // Define each element separated.
  46          $assign = new backup_nested_element('assign', array('id'),
  47                                              array('name',
  48                                                    'intro',
  49                                                    'introformat',
  50                                                    'alwaysshowdescription',
  51                                                    'submissiondrafts',
  52                                                    'sendnotifications',
  53                                                    'sendlatenotifications',
  54                                                    'sendstudentnotifications',
  55                                                    'duedate',
  56                                                    'cutoffdate',
  57                                                    'allowsubmissionsfromdate',
  58                                                    'grade',
  59                                                    'timemodified',
  60                                                    'completionsubmit',
  61                                                    'requiresubmissionstatement',
  62                                                    'teamsubmission',
  63                                                    'requireallteammemberssubmit',
  64                                                    'teamsubmissiongroupingid',
  65                                                    'blindmarking',
  66                                                    'revealidentities',
  67                                                    'attemptreopenmethod',
  68                                                    'maxattempts',
  69                                                    'markingworkflow',
  70                                                    'markingallocation',
  71                                                    'preventsubmissionnotingroup'));
  72  
  73          $userflags = new backup_nested_element('userflags');
  74  
  75          $userflag = new backup_nested_element('userflag', array('id'),
  76                                                  array('userid',
  77                                                        'assignment',
  78                                                        'mailed',
  79                                                        'locked',
  80                                                        'extensionduedate',
  81                                                        'workflowstate',
  82                                                        'allocatedmarker'));
  83  
  84          $submissions = new backup_nested_element('submissions');
  85  
  86          $submission = new backup_nested_element('submission', array('id'),
  87                                                  array('userid',
  88                                                        'timecreated',
  89                                                        'timemodified',
  90                                                        'status',
  91                                                        'groupid',
  92                                                        'attemptnumber',
  93                                                        'latest'));
  94  
  95          $grades = new backup_nested_element('grades');
  96  
  97          $grade = new backup_nested_element('grade', array('id'),
  98                                             array('userid',
  99                                                   'timecreated',
 100                                                   'timemodified',
 101                                                   'grader',
 102                                                   'grade',
 103                                                   'attemptnumber'));
 104  
 105          $pluginconfigs = new backup_nested_element('plugin_configs');
 106  
 107          $pluginconfig = new backup_nested_element('plugin_config', array('id'),
 108                                                     array('plugin',
 109                                                           'subtype',
 110                                                           'name',
 111                                                           'value'));
 112  
 113          // Build the tree.
 114          $assign->add_child($userflags);
 115          $userflags->add_child($userflag);
 116          $assign->add_child($submissions);
 117          $submissions->add_child($submission);
 118          $assign->add_child($grades);
 119          $grades->add_child($grade);
 120          $assign->add_child($pluginconfigs);
 121          $pluginconfigs->add_child($pluginconfig);
 122  
 123          // Define sources.
 124          $assign->set_source_table('assign', array('id' => backup::VAR_ACTIVITYID));
 125          $pluginconfig->set_source_table('assign_plugin_config',
 126                                          array('assignment' => backup::VAR_PARENTID));
 127  
 128          if ($userinfo) {
 129              $userflag->set_source_table('assign_user_flags',
 130                                       array('assignment' => backup::VAR_PARENTID));
 131  
 132              $submission->set_source_table('assign_submission',
 133                                       array('assignment' => backup::VAR_PARENTID));
 134  
 135              $grade->set_source_table('assign_grades',
 136                                       array('assignment' => backup::VAR_PARENTID));
 137  
 138              // Support 2 types of subplugins.
 139              $this->add_subplugin_structure('assignsubmission', $submission, true);
 140              $this->add_subplugin_structure('assignfeedback', $grade, true);
 141          }
 142  
 143          // Define id annotations.
 144          $userflag->annotate_ids('user', 'userid');
 145          $userflag->annotate_ids('user', 'allocatedmarker');
 146          $submission->annotate_ids('user', 'userid');
 147          $submission->annotate_ids('group', 'groupid');
 148          $grade->annotate_ids('user', 'userid');
 149          $grade->annotate_ids('user', 'grader');
 150          $assign->annotate_ids('grouping', 'teamsubmissiongroupingid');
 151  
 152          // Define file annotations.
 153          // These file areas don't have an itemid.
 154          $assign->annotate_files('mod_assign', 'intro', null);
 155          $assign->annotate_files('mod_assign', 'introattachment', null);
 156  
 157          // Return the root element (choice), wrapped into standard activity structure.
 158  
 159          return $this->prepare_activity_structure($assign);
 160      }
 161  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1