Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.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  namespace mod_quiz\event;
  18  
  19  /**
  20   * The mod_quiz attempt manual grading complete event.
  21   *
  22   * @package    mod_quiz
  23   * @copyright  2021 The Open University
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  class attempt_manual_grading_completed extends \core\event\base {
  27  
  28      protected function init() {
  29          $this->data['objecttable'] = 'quiz_attempts';
  30          $this->data['crud'] = 'u';
  31          $this->data['edulevel'] = self::LEVEL_TEACHING;
  32      }
  33  
  34      public function get_description() {
  35          return "The attempt with id '$this->objectid' for the user with id '$this->relateduserid' " .
  36              "for the quiz with course module id '$this->contextinstanceid' is now fully graded. Sending notification.";
  37      }
  38  
  39      public static function get_name() {
  40          return get_string('eventattemptmanualgradingcomplete', 'mod_quiz');
  41      }
  42  
  43      public function get_url() {
  44          return new \moodle_url('/mod/quiz/review.php', ['attempt' => $this->objectid]);
  45      }
  46  
  47      protected function validate_data() {
  48          parent::validate_data();
  49  
  50          if (!isset($this->relateduserid)) {
  51              throw new \coding_exception('The \'relateduserid\' must be set.');
  52          }
  53  
  54          if (!isset($this->other['quizid'])) {
  55              throw new \coding_exception('The \'quizid\' value must be set in other.');
  56          }
  57      }
  58  
  59      public static function get_objectid_mapping() {
  60          return ['db' => 'quiz_attempts', 'restore' => 'quiz_attempt'];
  61      }
  62  
  63      public static function get_other_mapping() {
  64          $othermapped = [];
  65          $othermapped['quizid'] = ['db' => 'quiz', 'restore' => 'quiz'];
  66  
  67          return $othermapped;
  68      }
  69  }