[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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_quiz attempt started event. 19 * 20 * @package mod_quiz 21 * @copyright 2013 Adrian Greeve <[email protected]> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace mod_quiz\event; 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * The mod_quiz attempt started event class. 29 * 30 * @package mod_quiz 31 * @since Moodle 2.6 32 * @copyright 2013 Adrian Greeve <[email protected]> 33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 34 */ 35 class attempt_started extends \core\event\base { 36 37 /** 38 * Init method. 39 */ 40 protected function init() { 41 $this->data['objecttable'] = 'quiz_attempts'; 42 $this->data['crud'] = 'c'; 43 $this->data['edulevel'] = self::LEVEL_PARTICIPATING; 44 } 45 46 /** 47 * Returns description of what happened. 48 * 49 * @return string 50 */ 51 public function get_description() { 52 return "The user with id '$this->relateduserid' has started the attempt with id '$this->objectid' for the " . 53 "quiz with course module id '$this->contextinstanceid'."; 54 } 55 56 /** 57 * Returns localised general event name. 58 * 59 * @return string 60 */ 61 public static function get_name() { 62 return get_string('eventquizattemptstarted', 'mod_quiz'); 63 } 64 65 /** 66 * Does this event replace a legacy event? 67 * 68 * @return string legacy event name 69 */ 70 static public function get_legacy_eventname() { 71 return 'quiz_attempt_started'; 72 } 73 74 /** 75 * Returns relevant URL. 76 * 77 * @return \moodle_url 78 */ 79 public function get_url() { 80 return new \moodle_url('/mod/quiz/review.php', array('attempt' => $this->objectid)); 81 } 82 83 /** 84 * Legacy event data if get_legacy_eventname() is not empty. 85 * 86 * @return \stdClass 87 */ 88 protected function get_legacy_eventdata() { 89 $attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid); 90 91 $legacyeventdata = new \stdClass(); 92 $legacyeventdata->component = 'mod_quiz'; 93 $legacyeventdata->attemptid = $attempt->id; 94 $legacyeventdata->timestart = $attempt->timestart; 95 $legacyeventdata->timestamp = $attempt->timestart; 96 $legacyeventdata->userid = $this->relateduserid; 97 $legacyeventdata->quizid = $attempt->quiz; 98 $legacyeventdata->cmid = $this->contextinstanceid; 99 $legacyeventdata->courseid = $this->courseid; 100 101 return $legacyeventdata; 102 } 103 104 /** 105 * Return the legacy event log data. 106 * 107 * @return array 108 */ 109 protected function get_legacy_logdata() { 110 $attempt = $this->get_record_snapshot('quiz_attempts', $this->objectid); 111 112 return array($this->courseid, 'quiz', 'attempt', 'review.php?attempt=' . $this->objectid, 113 $attempt->quiz, $this->contextinstanceid); 114 } 115 116 /** 117 * Custom validation. 118 * 119 * @throws \coding_exception 120 * @return void 121 */ 122 protected function validate_data() { 123 parent::validate_data(); 124 if (!isset($this->relateduserid)) { 125 throw new \coding_exception('The \'relateduserid\' must be set.'); 126 } 127 } 128 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |