first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,112 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign all submissions downloaded event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign all submissions downloaded event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class all_submissions_downloaded extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @return all_submissions_downloaded
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id
);
self::$preventcreatecall = false;
/** @var submission_graded $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has downloaded all the submissions for the assignment " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventallsubmissionsdownloaded', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call all_submissions_downloaded::create() directly, use all_submissions_downloaded::create_from_assign() instead.');
}
parent::validate_data();
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
}
@@ -0,0 +1,126 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign assessable submitted event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign assessable submitted event class.
*
* @property-read array $other {
* Extra information about event.
*
* - bool submission_editable: is submission editable.
* }
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class assessable_submitted extends base {
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $submission
* @param bool $editable
* @return assessable_submitted
*/
public static function create_from_submission(\assign $assign, \stdClass $submission, $editable) {
global $USER;
$data = array(
'context' => $assign->get_context(),
'objectid' => $submission->id,
'other' => array(
'submission_editable' => $editable,
),
);
if (!empty($submission->userid) && ($submission->userid != $USER->id)) {
$data['relateduserid'] = $submission->userid;
}
/** @var assessable_submitted $event */
$event = self::create($data);
$event->set_assign($assign);
$event->add_record_snapshot('assign_submission', $submission);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has submitted the submission with id '$this->objectid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventassessablesubmitted', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['objecttable'] = 'assign_submission';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['submission_editable'])) {
throw new \coding_exception('The \'submission_editable\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign_submission', 'restore' => 'submission');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign abstract base event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign abstract base event class.
*
* Most mod_assign events can extend this class.
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class base extends \core\event\base {
/** @var \assign */
protected $assign;
/**
* Legacy log data.
*
* @var array
*/
protected $legacylogdata;
/**
* Set assign instance for this event.
* @param \assign $assign
* @throws \coding_exception
*/
public function set_assign(\assign $assign) {
if ($this->is_triggered()) {
throw new \coding_exception('set_assign() must be done before triggerring of event');
}
if ($assign->get_context()->id != $this->get_context()->id) {
throw new \coding_exception('Invalid assign isntance supplied!');
}
if ($assign->is_blind_marking()) {
$this->data['anonymous'] = 1;
}
$this->assign = $assign;
}
/**
* Get assign instance.
*
* NOTE: to be used from observers only.
*
* @throws \coding_exception
* @return \assign
*/
public function get_assign() {
if ($this->is_restored()) {
throw new \coding_exception('get_assign() is intended for event observers only');
}
if (!isset($this->assign)) {
debugging('assign property should be initialised in each event', DEBUG_DEVELOPER);
global $CFG;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$cm = get_coursemodule_from_id('assign', $this->contextinstanceid, 0, false, MUST_EXIST);
$course = get_course($cm->course);
$this->assign = new \assign($this->get_context(), $cm, $course);
}
return $this->assign;
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/view.php', array('id' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
}
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign batch set marker allocation viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign batch set marker allocation viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class batch_set_marker_allocation_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @return batch_set_marker_allocation_viewed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var batch_set_marker_allocation_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbatchsetmarkerallocationviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the batch set marker allocation for the assignment with course " .
"module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call batch_set_marker_allocation_viewed::create() directly, use batch_set_marker_allocation_viewed::create_from_assign() instead.');
}
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign assignment batch set workflow stated viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign assignment batch set workflow stated viewed event.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class batch_set_workflow_state_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @return batch_set_workflow_state_viewed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var batch_set_workflow_state_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbatchsetworkflowstateviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the batch set workflow for the assignment with course " .
"module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call batch_set_workflow_state_viewed::create() directly, use batch_set_workflow_state_viewed::create_from_assign() instead.');
}
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,52 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign instance list viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign instance list viewed event class.
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
/**
* Create the event from course record.
*
* @param \stdClass $course
* @return course_module_instance_list_viewed
*/
public static function create_from_course(\stdClass $course) {
$params = array(
'context' => \context_course::instance($course->id)
);
$event = \mod_assign\event\course_module_instance_list_viewed::create($params);
$event->add_record_snapshot('course', $course);
return $event;
}
}
@@ -0,0 +1,56 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign course module viewed event.
*
* @package mod_assign
* @copyright 2018 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* The mod_assign course module viewed event class.
*
* @package mod_assign
* @since Moodle 3.6
* @copyright 2018 Victor Deniz <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'assign';
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
}
@@ -0,0 +1,118 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign extension granted event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign extension granted event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class extension_granted extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param int $userid
* @return extension_granted
*/
public static function create_from_assign(\assign $assign, $userid) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id,
'relateduserid' => $userid,
);
self::$preventcreatecall = false;
/** @var extension_granted $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has granted an extension for the user with id '$this->relateduserid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventextensiongranted', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call extension_granted::create() directly, use extension_granted::create_from_assign() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
}
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign feedback viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign feedback viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class feedback_viewed extends base {
/**
* Create instance of event.
*
* @param \assign $assign
* @param \stdClass $grade
* @return feedback_viewed
*/
public static function create_from_grade(\assign $assign, \stdClass $grade) {
$data = array(
'objectid' => $grade->id,
'relateduserid' => $grade->userid,
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
/** @var feedback_viewed $event */
$event = self::create($data);
$event->set_assign($assign);
$event->add_record_snapshot('assign_grades', $grade);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_grades';
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventfeedbackviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the feedback for the user with id '$this->relateduserid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign_grades', 'restore' => 'grade');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,128 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign grading form viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign grading form viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grading_form_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @param \stdClass $user
* @return grading_form_viewed
*/
public static function create_from_user(\assign $assign, \stdClass $user) {
$data = array(
'relateduserid' => $user->id,
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var grading_form_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventgradingformviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the grading form for the user with id '$this->relateduserid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call grading_form_viewed::create() directly, use grading_form_viewed::create_from_user() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign grading table viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign grading table viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class grading_table_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @return grading_table_viewed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var grading_table_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventgradingtableviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the grading table for the assignment with course module " .
"id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call grading_table_viewed::create() directly, use grading_table_viewed::create_from_assign() instead.');
}
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,118 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign group override created event.
*
* @package mod_assign
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign group override created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assign.
* - int groupid: the id of the group.
* }
*
* @package mod_assign
* @since Moodle 3.2
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class group_override_created extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_overrides';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoverridecreated', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the override with id '$this->objectid' for the assign with " .
"course module id '$this->contextinstanceid' for the group with id '{$this->other['groupid']}'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/overrideedit.php', array('id' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
if (!isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign_overrides', 'restore' => 'assign_override');
}
/**
* Get other mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
return $othermapped;
}
}
@@ -0,0 +1,117 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign group override deleted event.
*
* @package mod_assign
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign group override deleted event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assign.
* - int groupid: the id of the group.
* }
*
* @package mod_assign
* @since Moodle 3.2
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class group_override_deleted extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_overrides';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoverridedeleted', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the override with id '$this->objectid' for the assign with " .
"course module id '$this->contextinstanceid' for the group with id '{$this->other['groupid']}'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/overrides.php', array('cmid' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
if (!isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign_overrides', 'restore' => 'assign_override');
}
/**
* Get other mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
return $othermapped;
}
}
@@ -0,0 +1,117 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign group override updated event.
*
* @package mod_assign
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign group override updated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assign.
* - int groupid: the id of the group.
* }
*
* @package mod_assign
* @since Moodle 3.2
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class group_override_updated extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_overrides';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoverrideupdated', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the override with id '$this->objectid' for the assign with " .
"course module id '$this->contextinstanceid' for the group with id '{$this->other['groupid']}'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/overrideedit.php', array('id' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
if (!isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign_overrides', 'restore' => 'assign_override');
}
/**
* Get other mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
return $othermapped;
}
}
@@ -0,0 +1,112 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign identities revealed event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign identities revealed event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class identities_revealed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @return identities_revealed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id
);
self::$preventcreatecall = false;
/** @var identities_revealed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has revealed identities in the assignment with course module " .
"id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventidentitiesrevealed', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call identities_revealed::create() directly, use identities_revealed::create_from_assign() instead.');
}
parent::validate_data();
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
}
+140
View File
@@ -0,0 +1,140 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign marker updated event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign marker updated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int markerid: user id of marker.
* }
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class marker_updated extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $user
* @param \stdClass $marker
* @return marker_updated
*/
public static function create_from_marker(\assign $assign, \stdClass $user, \stdClass $marker) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id,
'relateduserid' => $user->id,
'other' => array(
'markerid' => $marker->id,
),
);
self::$preventcreatecall = false;
/** @var marker_updated $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
$event->add_record_snapshot('user', $marker);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has set the marker for the user with id '$this->relateduserid' to " .
"'{$this->other['markerid']}' for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventmarkerupdated', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call marker_updated::create() directly, use marker_updated::create_from_marker() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['markerid'])) {
throw new \coding_exception('The \'markerid\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['markerid'] = array('db' => 'user', 'restore' => 'user');
return $othermapped;
}
}
@@ -0,0 +1,134 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign remove submission form viewed event.
*
* @package mod_assign
* @copyright 2019 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign remove submission form viewed event class.
*
* @package mod_assign
* @copyright 2019 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class remove_submission_form_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @param \stdClass $user
* @return remove_submission_form_viewed
*/
public static function create_from_user(\assign $assign, \stdClass $user) {
$data = array(
'relateduserid' => $user->id,
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var remove_submission_form_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventremovesubmissionformviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
if ($this->userid != $this->relateduserid) {
return "The user with id '$this->userid' viewed the " .
"remove submission form for the user with id '$this->relateduserid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
return "The user with id '$this->userid' viewed their remove submission form for the assignment with course module id " .
"'$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call remove_submission_form_viewed::create() directly, use ' .
'remove_submission_form_viewed::create_from_user() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
/**
* This is documented in the parent class.
*
* @return array an array of other values and their corresponding mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,121 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign reveal identities confirmation page viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign reveal identities confirmation page viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class reveal_identities_confirmation_page_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @return reveal_identities_confirmation_page_viewed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var reveal_identities_confirmation_page_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventrevealidentitiesconfirmationpageviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the confirmation page for revealing identities for the " .
"assignment with course module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call reveal_identities_confirmation_page_viewed::create() directly, use reveal_identities_confirmation_page_viewed::create_from_grade() instead.');
}
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,114 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign statement accepted event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign statement accepted event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class statement_accepted extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $submission
* @return statement_accepted
*/
public static function create_from_submission(\assign $assign, \stdClass $submission) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $submission->id
);
self::$preventcreatecall = false;
/** @var statement_accepted $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('assign_submission', $submission);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has accepted the statement of the submission with id '$this->objectid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventstatementaccepted', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'assign_submission';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call statement_accepted::create() directly, use statement_accepted::create_from_submission() instead.');
}
parent::validate_data();
}
public static function get_objectid_mapping() {
return array('db' => 'assign_submission', 'restore' => 'submission');
}
}
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission form viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission form viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_confirmation_form_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @return submission_confirmation_form_viewed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var submission_confirmation_form_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionconfirmationformviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the submission confirmation form for the assignment with " .
"course module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_confirmation_form_viewed::create() directly, use submission_confirmation_form_viewed::create_from_assign() instead.');
}
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,92 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission_created abstract event.
*
* @package mod_assign
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission_created abstract event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int submissionid: ID number of this submission.
* - int submissionattempt: Number of attempts made on this submission.
* - string submissionstatus: Status of the submission.
* - int groupid: (optional) The group ID if this is a teamsubmission.
* - string groupname: (optional) The name of the group if this is a teamsubmission.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class submission_created extends base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissioncreated', 'mod_assign');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['submissionid'])) {
throw new \coding_exception('The \'submissionid\' value must be set in other.');
}
if (!isset($this->other['submissionattempt'])) {
throw new \coding_exception('The \'submissionattempt\' value must be set in other.');
}
if (!isset($this->other['submissionstatus'])) {
throw new \coding_exception('The \'submissionstatus\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['submissionid'] = array('db' => 'assign_submission', 'restore' => 'submission');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
return $othermapped;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission duplicated event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission duplicated event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_duplicated extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $submission
* @return submission_duplicated
*/
public static function create_from_submission(\assign $assign, \stdClass $submission) {
$data = array(
'objectid' => $submission->id,
'context' => $assign->get_context(),
);
self::$preventcreatecall = false;
/** @var submission_duplicated $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('assign_submission', $submission);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' duplicated their submission with id '$this->objectid' for the " .
"assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionduplicated', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'assign_submission';
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_duplicated::create() directly, use submission_duplicated::create_from_submission() instead.');
}
parent::validate_data();
}
public static function get_objectid_mapping() {
return array('db' => 'assign_submission', 'restore' => 'submission');
}
}
@@ -0,0 +1,133 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission form viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission form viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_form_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @param \stdClass $user
* @return submission_form_viewed
*/
public static function create_from_user(\assign $assign, \stdClass $user) {
$data = array(
'relateduserid' => $user->id,
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var submission_form_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionformviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
if ($this->userid != $this->relateduserid) {
return "The user with id '$this->userid' viewed the submission form for the user with id '$this->relateduserid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
return "The user with id '$this->userid' viewed their submission for the assignment with course module id " .
"'$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_form_viewed::create() directly, use submission_form_viewed::create_from_user() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,119 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission graded event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission graded event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_graded extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $grade
* @return submission_graded
*/
public static function create_from_grade(\assign $assign, \stdClass $grade) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $grade->id,
'relateduserid' => $grade->userid
);
self::$preventcreatecall = false;
/** @var submission_graded $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('assign_grades', $grade);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has graded the submission '$this->objectid' for the user with " .
"id '$this->relateduserid' for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissiongraded', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign_grades';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_graded::create() directly, use submission_graded::create_from_grade() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign_grades', 'restore' => 'grade');
}
}
@@ -0,0 +1,118 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission locked event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission locked event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_locked extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $user
* @return submission_locked
*/
public static function create_from_user(\assign $assign, \stdClass $user) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id,
'relateduserid' => $user->id,
);
self::$preventcreatecall = false;
/** @var submission_locked $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' locked the submission for the user with id '$this->relateduserid' for " .
"the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionlocked', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_locked::create() directly, use submission_locked::create_from_user() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
}
@@ -0,0 +1,154 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace mod_assign\event;
use assign;
use coding_exception;
use stdClass;
/**
* The mod_assign submission removed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int submissionid: ID number of this submission.
* - int submissionattempt: Number of attempts made on this submission.
* - string submissionstatus: Status of the submission.
* - int groupid: (optional) The group ID if this is a teamsubmission.
* - string groupname: (optional) The name of the group if this is a teamsubmission.
* }
*
* @package mod_assign
* @since Moodle 4.0
* @copyright 2022 TU Berlin
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_removed extends base {
/**
* Create instance of event.
*
* @param assign $assign
* @param stdClass $submission
* @return submission_removed
* @throws coding_exception
*/
public static function create_from_submission(assign $assign, stdClass $submission): submission_removed {
$groupname = null;
$groupid = 0;
if (empty($submission->userid) && !empty($submission->groupid)) {
$groupname = groups_get_group_name($submission->groupid);
$groupid = $submission->groupid;
}
$data = [
'context' => $assign->get_context(),
'objectid' => $submission->id,
'relateduserid' => $assign->get_instance()->teamsubmission ? null : $submission->userid,
'anonymous' => $assign->is_blind_marking() ? 1 : 0,
'other' => [
'submissionid' => $submission->id,
'submissionattempt' => $submission->attemptnumber,
'submissionstatus' => $submission->status,
'groupid' => $groupid,
'groupname' => $groupname
]
];
/** @var submission_removed $event */
$event = self::create($data);
$event->set_assign($assign);
$event->add_record_snapshot('assign_submission', $submission);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'assign_submission';
}
/**
* Returns localised general event name.
*
* @return string
* @throws coding_exception
*/
public static function get_name(): string {
return get_string('eventsubmissionremoved', 'mod_assign');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description(): string {
$descriptionstring = "The user with id '$this->userid' removed the submission with id '$this->objectid' in " .
"the assignment with course module id '$this->contextinstanceid' submitted by ";
if (!empty($this->other['groupid'])) {
$groupname = $this->other['groupname'];
$groupid = $this->other['groupid'];
$descriptionstring .= "the group '$groupname' with id '$groupid'.";
} else {
$descriptionstring .= "the user with id '$this->relateduserid'.";
}
return $descriptionstring;
}
/**
* Custom validation.
*
* @return void
* @throws coding_exception
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['submissionid'])) {
throw new coding_exception('The \'submissionid\' value must be set in other.');
}
if (!isset($this->other['submissionattempt'])) {
throw new coding_exception('The \'submissionattempt\' value must be set in other.');
}
if (!isset($this->other['submissionstatus'])) {
throw new coding_exception('The \'submissionstatus\' value must be set in other.');
}
}
/**
* Get objectid mapping.
*
* @return array
*/
public static function get_objectid_mapping(): array {
return ['db' => 'assign_submission', 'restore' => 'submission'];
}
/**
* Get other mapping.
*
* @return array
*/
public static function get_other_mapping(): array {
$othermapped = [];
$othermapped['submissionid'] = ['db' => 'assign_submission', 'restore' => 'submission'];
$othermapped['groupid'] = ['db' => 'groups', 'restore' => 'group'];
return $othermapped;
}
}
@@ -0,0 +1,120 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission status updated event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission status updated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - string newstatus: status of submission.
* }
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_status_updated extends base {
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $submission
* @return submission_status_updated
*/
public static function create_from_submission(\assign $assign, \stdClass $submission) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $submission->id,
'relateduserid' => ($assign->get_instance()->teamsubmission) ? null : $submission->userid,
'other' => array(
'newstatus' => $submission->status
)
);
/** @var submission_status_updated $event */
$event = self::create($data);
$event->set_assign($assign);
$event->add_record_snapshot('assign_submission', $submission);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated the status of the submission with id '$this->objectid' for " .
"the assignment with course module id '$this->contextinstanceid' to the status '{$this->other['newstatus']}'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionstatusupdated', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign_submission';
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['newstatus'])) {
throw new \coding_exception('The \'newstatus\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign_submission', 'restore' => 'submission');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
@@ -0,0 +1,124 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission status viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission status viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_status_viewed extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @param \assign $assign
* @return submission_status_viewed
*/
public static function create_from_assign(\assign $assign) {
$data = array(
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
self::$preventcreatecall = false;
/** @var submission_status_viewed $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
return $event;
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionstatusviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has viewed the submission status page for the assignment with " .
"course module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_status_viewed::create() directly, use submission_status_viewed::create_from_assign() instead.');
}
parent::validate_data();
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,118 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission unlocked event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission unlocked event class.
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_unlocked extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $user
* @return submission_unlocked
*/
public static function create_from_user(\assign $assign, \stdClass $user) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id,
'relateduserid' => $user->id,
);
self::$preventcreatecall = false;
/** @var submission_unlocked $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' unlocked the submission for the user with id '$this->relateduserid' " .
"for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionunlocked', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call submission_unlocked::create() directly, use submission_unlocked::create_from_user() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
}
@@ -0,0 +1,92 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission updated event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission updated event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int submissionid: ID number of this submission.
* - int submissionattempt: Number of attempts made on this submission.
* - string submissionstatus: Status of the submission.
* - int groupid: (optional) The group ID if this is a teamsubmission.
* - string groupname: (optional) The name of the group if this is a teamsubmission.
* }
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class submission_updated extends base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionupdated', 'mod_assign');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['submissionid'])) {
throw new \coding_exception('The \'submissionid\' value must be set in other.');
}
if (!isset($this->other['submissionattempt'])) {
throw new \coding_exception('The \'submissionattempt\' value must be set in other.');
}
if (!isset($this->other['submissionstatus'])) {
throw new \coding_exception('The \'submissionstatus\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['submissionid'] = array('db' => 'assign_submission', 'restore' => 'submission');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
return $othermapped;
}
}
@@ -0,0 +1,122 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign submission viewed event.
*
* @package mod_assign
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign submission viewed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int assignid: the id of the assignment.
* }
*
* @package mod_assign
* @since Moodle 2.7
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class submission_viewed extends base {
/**
* Create instance of event.
*
* @param \assign $assign
* @param \stdClass $submission
* @return submission_viewed
*/
public static function create_from_submission(\assign $assign, \stdClass $submission) {
$data = array(
'objectid' => $submission->id,
'relateduserid' => $submission->userid,
'context' => $assign->get_context(),
'other' => array(
'assignid' => $assign->get_instance()->id,
),
);
/** @var submission_viewed $event */
$event = self::create($data);
$event->set_assign($assign);
$event->add_record_snapshot('assign_submission', $submission);
return $event;
}
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_submission';
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubmissionviewed', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the submission for the user with id '$this->relateduserid' for the " .
"assignment with course module id '$this->contextinstanceid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign_submission', 'restore' => 'submission');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,115 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign user override created event.
*
* @package mod_assign
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign user override created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assign.
* }
*
* @package mod_assign
* @since Moodle 3.2
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_override_created extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_overrides';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoverridecreated', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the override with id '$this->objectid' for the assign with " .
"course module id '$this->contextinstanceid' for the user with id '{$this->relateduserid}'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/overrideedit.php', array('id' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign_overrides', 'restore' => 'assign_override');
}
/**
* Get other mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,115 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign user override deleted event.
*
* @package mod_assign
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign user override deleted event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assign.
* }
*
* @package mod_assign
* @since Moodle 3.2
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_override_deleted extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_overrides';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoverridedeleted', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the override with id '$this->objectid' for the assign with " .
"course module id '$this->contextinstanceid' for the user with id '{$this->relateduserid}'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/overrides.php', array('cmid' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign_overrides', 'restore' => 'assign_override');
}
/**
* Get other mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,116 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The mod_assign user override updated event.
*
* @package mod_assign
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_assign user override updated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int assignid: the id of the assign.
* }
*
* @package mod_assign
* @since Moodle 3.2
* @copyright 2016 Ilya Tregubov
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_override_updated extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['objecttable'] = 'assign_overrides';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoverrideupdated', 'mod_assign');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the override with id '$this->objectid' for the assign with " .
"course module id '$this->contextinstanceid' for the user with id '{$this->relateduserid}'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/assign/overrideedit.php', array('id' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['assignid'])) {
throw new \coding_exception('The \'assignid\' value must be set in other.');
}
}
/**
* Get objectid mapping
*/
public static function get_objectid_mapping() {
return array('db' => 'assign_overrides', 'restore' => 'assign_override');
}
/**
* Get other mapping
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['assignid'] = array('db' => 'assign', 'restore' => 'assign');
return $othermapped;
}
}
@@ -0,0 +1,137 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_assign workflow state updated event.
*
* @package mod_assign
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_assign\event;
defined('MOODLE_INTERNAL') || die();
/**
* mod_assign workflow state updated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - string newstate: state of submission.
* }
*
* @package mod_assign
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class workflow_state_updated extends base {
/**
* Flag for prevention of direct create() call.
* @var bool
*/
protected static $preventcreatecall = true;
/**
* Create instance of event.
*
* @since Moodle 2.7
*
* @param \assign $assign
* @param \stdClass $user
* @param string $state
* @return workflow_state_updated
*/
public static function create_from_user(\assign $assign, \stdClass $user, $state) {
$data = array(
'context' => $assign->get_context(),
'objectid' => $assign->get_instance()->id,
'relateduserid' => $user->id,
'other' => array(
'newstate' => $state,
),
);
self::$preventcreatecall = false;
/** @var workflow_state_updated $event */
$event = self::create($data);
self::$preventcreatecall = true;
$event->set_assign($assign);
$event->add_record_snapshot('user', $user);
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has set the workflow state of the user with id '$this->relateduserid' " .
"to the state '{$this->other['newstate']}' for the assignment with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventworkflowstateupdated', 'mod_assign');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = 'assign';
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
if (self::$preventcreatecall) {
throw new \coding_exception('cannot call workflow_state_updated::create() directly, use workflow_state_updated::create_from_user() instead.');
}
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['newstate'])) {
throw new \coding_exception('The \'newstate\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'assign', 'restore' => 'assign');
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}