Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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   * The mod_assign submission updated event.
  19   *
  20   * @package    mod_assign
  21   * @copyright  2013 Frédéric Massart
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  namespace mod_assign\event;
  26  
  27  defined('MOODLE_INTERNAL') || die();
  28  
  29  /**
  30   * The mod_assign submission updated event class.
  31   *
  32   * @property-read array $other {
  33   *      Extra information about the event.
  34   *
  35   *      - int submissionid: ID number of this submission.
  36   *      - int submissionattempt: Number of attempts made on this submission.
  37   *      - string submissionstatus: Status of the submission.
  38   *      - int groupid: (optional) The group ID if this is a teamsubmission.
  39   *      - string groupname: (optional) The name of the group if this is a teamsubmission.
  40   * }
  41   *
  42   * @package    mod_assign
  43   * @since      Moodle 2.6
  44   * @copyright  2013 Frédéric Massart
  45   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  46   */
  47  abstract class submission_updated extends base {
  48  
  49      /**
  50       * Init method.
  51       */
  52      protected function init() {
  53          $this->data['crud'] = 'u';
  54          $this->data['edulevel'] = self::LEVEL_PARTICIPATING;
  55      }
  56  
  57      /**
  58       * Returns localised general event name.
  59       *
  60       * @return string
  61       */
  62      public static function get_name() {
  63          return get_string('eventsubmissionupdated', 'mod_assign');
  64      }
  65  
  66      /**
  67       * Custom validation.
  68       *
  69       * @throws \coding_exception
  70       * @return void
  71       */
  72      protected function validate_data() {
  73          parent::validate_data();
  74          if (!isset($this->other['submissionid'])) {
  75              throw new \coding_exception('The \'submissionid\' value must be set in other.');
  76          }
  77          if (!isset($this->other['submissionattempt'])) {
  78              throw new \coding_exception('The \'submissionattempt\' value must be set in other.');
  79          }
  80          if (!isset($this->other['submissionstatus'])) {
  81              throw new \coding_exception('The \'submissionstatus\' value must be set in other.');
  82          }
  83      }
  84  
  85      public static function get_other_mapping() {
  86          $othermapped = array();
  87          $othermapped['submissionid'] = array('db' => 'assign_submission', 'restore' => 'submission');
  88          $othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
  89  
  90          return $othermapped;
  91      }
  92  }