Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   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   * This file contains the class for restore of this submission plugin
  19   *
  20   * @package assignsubmission_onlinetext
  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  /**
  26   * Restore subplugin class.
  27   *
  28   * Provides the necessary information needed to restore
  29   * one assign_submission subplugin.
  30   *
  31   * @package assignsubmission_onlinetext
  32   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  33   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class restore_assignsubmission_onlinetext_subplugin extends restore_subplugin {
  36  
  37      /**
  38       * Returns array the paths to be handled by the subplugin at assignment level
  39       * @return array
  40       */
  41      protected function define_submission_subplugin_structure() {
  42  
  43          $paths = array();
  44  
  45          $elename = $this->get_namefor('submission');
  46  
  47          // We used get_recommended_name() so this works.
  48          $elepath = $this->get_pathfor('/submission_onlinetext');
  49          $paths[] = new restore_path_element($elename, $elepath);
  50  
  51          return $paths;
  52      }
  53  
  54      /**
  55       * Processes one assignsubmission_onlinetext element
  56       *
  57       * @param mixed $data
  58       */
  59      public function process_assignsubmission_onlinetext_submission($data) {
  60          global $DB;
  61  
  62          $data = (object)$data;
  63          $data->assignment = $this->get_new_parentid('assign');
  64          $oldsubmissionid = $data->submission;
  65          // The mapping is set in the restore for the core assign activity
  66          // when a submission node is processed.
  67          $data->submission = $this->get_mappingid('submission', $data->submission);
  68  
  69          $DB->insert_record('assignsubmission_onlinetext', $data);
  70  
  71          $this->add_related_files('assignsubmission_onlinetext', 'submissions_onlinetext', 'submission', null, $oldsubmissionid);
  72      }
  73  
  74  }