1 |
efrain |
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 assignsubmission_file submission_created event.
|
|
|
19 |
*
|
|
|
20 |
* @package assignsubmission_file
|
|
|
21 |
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace assignsubmission_file\event;
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* The assignsubmission_file submission_created event class.
|
|
|
31 |
*
|
|
|
32 |
* @property-read array $other {
|
|
|
33 |
* Extra information about the event.
|
|
|
34 |
*
|
|
|
35 |
* - int filesubmissioncount: The number of files uploaded.
|
|
|
36 |
* }
|
|
|
37 |
*
|
|
|
38 |
* @package assignsubmission_file
|
|
|
39 |
* @since Moodle 2.7
|
|
|
40 |
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
|
|
|
41 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
42 |
*/
|
|
|
43 |
class submission_created extends \mod_assign\event\submission_created {
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* Init method.
|
|
|
47 |
*/
|
|
|
48 |
protected function init() {
|
|
|
49 |
parent::init();
|
|
|
50 |
$this->data['objecttable'] = 'assignsubmission_file';
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Returns non-localised description of what happened.
|
|
|
55 |
*
|
|
|
56 |
* @return string
|
|
|
57 |
*/
|
|
|
58 |
public function get_description() {
|
|
|
59 |
$descriptionstring = "The user with id '$this->userid' created a file submission and uploaded " .
|
|
|
60 |
"'{$this->other['filesubmissioncount']}' file/s in the assignment with course module id " .
|
|
|
61 |
"'$this->contextinstanceid'";
|
|
|
62 |
if (!empty($this->other['groupid'])) {
|
|
|
63 |
$descriptionstring .= " for the group with id '{$this->other['groupid']}'.";
|
|
|
64 |
} else {
|
|
|
65 |
$descriptionstring .= ".";
|
|
|
66 |
}
|
|
|
67 |
|
|
|
68 |
return $descriptionstring;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Custom validation.
|
|
|
73 |
*
|
|
|
74 |
* @throws \coding_exception
|
|
|
75 |
* @return void
|
|
|
76 |
*/
|
|
|
77 |
protected function validate_data() {
|
|
|
78 |
parent::validate_data();
|
|
|
79 |
if (!isset($this->other['filesubmissioncount'])) {
|
|
|
80 |
throw new \coding_exception('The \'filesubmissioncount\' value must be set in other.');
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
public static function get_objectid_mapping() {
|
|
|
85 |
// No mapping available for 'assignsubmission_file'.
|
|
|
86 |
return array('db' => 'assignsubmission_file', 'restore' => \core\event\base::NOT_MAPPED);
|
|
|
87 |
}
|
|
|
88 |
}
|