--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign all submissions downloaded event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class all_submissions_downloaded extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has downloaded all the submissions.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_all_submissions_downloaded', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action.
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'r';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+}
/**
* Return localised event name.
*
- * @return \lang_string
+ * @return string
*/
public static function get_name() {
- return new \lang_string('event_assessable_submitted', 'mod_assign');
+ return get_string('event_assessable_submitted', 'mod_assign');
}
/**
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign extension granted event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class extension_granted extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has granted an extension to {$this->relateduserid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_extension_granted', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->relateduserid)) {
+ throw new \coding_exception('relateduserid is a mandatory property.');
+ }
+ }
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign identities revealed event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class identities_revealed extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has revealed the identities in assignment {$this->objectid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_identities_revealed', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign marker updated event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class marker_updated extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has set the marker of {$this->relateduserid} to {$this->other['markerid']}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_marker_updated', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->other['markerid'])) {
+ throw new \coding_exception('markerid must be set in $other.');
+ } else if (!isset($this->relateduserid)) {
+ throw new \coding_exception('relateduserid must be set.');
+ }
+ }
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign statement accepted event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class statement_accepted extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "The user {$this->userid} has accepted the statement of the submission {$this->objectid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_statement_accepted', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action.
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'r';
+ $this->data['level'] = self::LEVEL_PARTICIPATING;
+ $this->data['objecttable'] = 'assign_submission';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign submission duplicated event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class submission_duplicated extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "The user {$this->userid} duplicated his submission {$this->objectid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_submission_duplicated', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action.
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'c';
+ $this->data['level'] = self::LEVEL_PARTICIPATING;
+ $this->data['objecttable'] = 'assign_submission';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign submission graded event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class submission_graded extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has graded the submission {$this->objectid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_submission_graded', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign_grades';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->relateduserid)) {
+ throw new \coding_exception('relateduserid is a mandatory property.');
+ }
+ }
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign submission locked event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class submission_locked extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} locked the submission for user {$this->relateduserid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_submission_locked', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->relateduserid)) {
+ throw new \coding_exception('relateduserid is a mandatory property.');
+ }
+ }
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign submission status updated event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class submission_status_updated extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has updated the status of the submission {$this->objectid} to {$this->other['newstatus']}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_submission_status_updated', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign_submission';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->other['newstatus'])) {
+ throw new \coding_exception('newstatus must be set in $other.');
+ }
+ }
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign submission unlocked event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class submission_unlocked extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} unlocked the submission for user {$this->relateduserid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_submission_unlocked', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->relateduserid)) {
+ throw new \coding_exception('relateduserid is a mandatory property.');
+ }
+ }
+}
--- /dev/null
+<?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 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();
+
+/**
+ * mod_assign submission updated event class.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class submission_updated extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "The user {$this->userid} has updated the submission {$this->objectid}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_submission_updated', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action.
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_PARTICIPATING;
+ $this->data['objecttable'] = 'assign_submission';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+}
--- /dev/null
+<?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.
+ *
+ * @package mod_assign
+ * @copyright 2013 Frédéric Massart
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class workflow_state_updated extends \core\event\base {
+
+ /**
+ * Legacy log data.
+ *
+ * @var array
+ */
+ protected $legacylogdata;
+
+ /**
+ * Returns description of what happened.
+ *
+ * @return string
+ */
+ public function get_description() {
+ return "User {$this->userid} has set the workflow state of {$this->relateduserid} to {$this->other['newstate']}.";
+ }
+
+ /**
+ * Return legacy data for add_to_log().
+ *
+ * @return array
+ */
+ public function get_legacy_logdata() {
+ return $this->legacylogdata;
+ }
+
+ /**
+ * Return localised event name.
+ *
+ * @return string
+ */
+ public static function get_name() {
+ return get_string('event_workflow_state_updated', 'mod_assign');
+ }
+
+ /**
+ * Get URL related to the action
+ *
+ * @return \moodle_url
+ */
+ public function get_url() {
+ return new \moodle_url('/mod/assign/view.php', array('id' => $this->context->instanceid));
+ }
+
+ /**
+ * Init method.
+ *
+ * @return void
+ */
+ protected function init() {
+ $this->data['crud'] = 'u';
+ $this->data['level'] = self::LEVEL_TEACHING;
+ $this->data['objecttable'] = 'assign';
+ }
+
+ /**
+ * Sets the legacy event log data.
+ *
+ * @param stdClass $legacylogdata legacy log data.
+ * @return void
+ */
+ public function set_legacy_logdata($legacylogdata) {
+ $this->legacylogdata = $legacylogdata;
+ }
+
+ /**
+ * Custom validation.
+ *
+ * @throws \coding_exception
+ * @return void
+ */
+ protected function validate_data() {
+ if (!isset($this->other['newstate'])) {
+ throw new \coding_exception('newstate must be set in $other.');
+ } else if (!isset($this->relateduserid)) {
+ throw new \coding_exception('relateduserid must be set.');
+ }
+ }
+}
$string['editingstatus'] = 'Editing status';
$string['editaction'] = 'Actions...';
$string['event_assessable_submitted'] = 'A submission has been submitted.';
+$string['event_all_submissions_downloaded'] = 'All the submissions are being downloaded.';
+$string['event_extension_granted'] = 'An extension has been granted.';
+$string['event_identities_revealed'] = 'The identities have been revealed.';
+$string['event_marker_updated'] = 'The allocated marker has been updated.';
+$string['event_statement_accepted'] = 'The user has accepted the statement of the submission.';
+$string['event_submission_duplicated'] = 'The user duplicated his submission.';
+$string['event_submission_graded'] = 'The submission has been graded.';
+$string['event_submission_locked'] = 'The submissions have been locked for a user.';
+$string['event_submission_status_updated'] = 'The status of the submission has been updated.';
+$string['event_submission_unlocked'] = 'The submissions have been unlocked for a user.';
+$string['event_submission_updated'] = 'The user has saved a submission.';
+$string['event_workflow_state_updated'] = 'The state of the workflow has been updated.';
$string['extensionduedate'] = 'Extension due date';
$string['extensionnotafterduedate'] = 'Extension date must be after the due date';
$string['extensionnotafterfromdate'] = 'Extension date must be after the allow submissions from date';
$result .= $this->get_renderer()->continue_button($url);
$result .= $this->view_footer();
} else if ($zipfile = $this->pack_files($filesforzipping)) {
- $this->add_to_log('download all submissions', get_string('downloadall', 'assign'));
+ $addtolog = $this->add_to_log('download all submissions', get_string('downloadall', 'assign'), '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $this->get_instance()->id
+ );
+ $event = \mod_assign\event\all_submissions_downloaded::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
// Send file and delete after sending.
send_temp_file($zipfile, $filename);
// We will not get here - send_temp_file calls exit.
$logmessage = get_string('submissionstatementacceptedlog',
'mod_assign',
fullname($USER));
- $this->add_to_log('submission statement accepted', $logmessage);
+ $addtolog = $this->add_to_log('submission statement accepted', $logmessage, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $submission->id
+ );
+ $event = \mod_assign\event\statement_accepted::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
$logdata = $this->add_to_log('submit for grading', $this->format_submission_for_log($submission), '', true);
$this->notify_graders($submission);
$result = $this->update_user_flags($flags);
if ($result) {
- $this->add_to_log('grant extension', $userid);
+ $addtolog = $this->add_to_log('grant extension', $userid, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $flags->assignment,
+ 'relateduserid' => $userid
+ );
+ $event = \mod_assign\event\extension_granted::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
return $result;
}
}
}
- $this->add_to_log('grade submission', $this->format_grade_for_log($grade));
+ $addtolog = $this->add_to_log('grade submission', $this->format_grade_for_log($grade), '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $grade->id,
+ 'relateduserid' => $userid
+ );
+ $event = \mod_assign\event\submission_graded::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
return get_string('quickgradingchangessaved', 'assign');
$this->gradebook_item_update(null, $grade);
}
- $this->add_to_log('reveal identities', get_string('revealidentities', 'assign'));
+ $addtolog = $this->add_to_log('reveal identities', get_string('revealidentities', 'assign'), '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $update->id
+ );
+ $event = \mod_assign\event\identities_revealed::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
return false;
}
- $this->add_to_log('submissioncopied', $this->format_submission_for_log($submission));
+ $addtolog = $this->add_to_log('submissioncopied', $this->format_submission_for_log($submission), '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $submission->id
+ );
+ $event = \mod_assign\event\submission_duplicated::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
$complete = COMPLETION_INCOMPLETE;
if ($submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
$logmessage = get_string('submissionstatementacceptedlog',
'mod_assign',
fullname($USER));
- $this->add_to_log('submission statement accepted', $logmessage);
+ $addtolog = $this->add_to_log('submission statement accepted', $logmessage, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $submission->id
+ );
+ $event = \mod_assign\event\statement_accepted::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
- $this->add_to_log('submit', $this->format_submission_for_log($submission));
+
+ $addtolog = $this->add_to_log('submit', $this->format_submission_for_log($submission), '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $submission->id
+ );
+ $event = \mod_assign\event\submission_updated::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
$complete = COMPLETION_INCOMPLETE;
if ($submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
$logmessage = get_string('reverttodraftforstudent',
'assign',
array('id'=>$user->id, 'fullname'=>fullname($user)));
- $this->add_to_log('revert submission to draft', $logmessage);
+ $addtolog = $this->add_to_log('revert submission to draft', $logmessage, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $submission->id,
+ 'relateduserid' => ($this->get_instance()->teamsubmission) ? null : $userid,
+ 'other' => array(
+ 'newstatus' => $submission->status
+ )
+ );
+ $event = \mod_assign\event\submission_status_updated::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
/**
$logmessage = get_string('locksubmissionforstudent',
'assign',
array('id'=>$user->id, 'fullname'=>fullname($user)));
- $this->add_to_log('lock submission', $logmessage);
+ $addtolog = $this->add_to_log('lock submission', $logmessage, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $flags->assignment,
+ 'relateduserid' => $user->id
+ );
+ $event = \mod_assign\event\submission_locked::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
*
* @return void
*/
- private function process_set_batch_marking_workflow_state() {
+ protected function process_set_batch_marking_workflow_state() {
global $DB;
require_sesskey();
'fullname'=>fullname($user),
'state'=>$state);
$message = get_string('setmarkingworkflowstateforlog', 'assign', $params);
- $this->add_to_log('set marking workflow state', $message);
+ $addtolog = $this->add_to_log('set marking workflow state', $message, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $this->get_instance()->id,
+ 'relateduserid' => $userid,
+ 'other' => array(
+ 'newstate' => $state
+ )
+ );
+ $event = \mod_assign\event\workflow_state_updated::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
}
}
*
* @return void
*/
- private function process_set_batch_marking_allocation() {
+ protected function process_set_batch_marking_allocation() {
global $DB;
require_sesskey();
'fullname'=>fullname($user),
'marker'=>fullname($marker));
$message = get_string('setmarkerallocationforlog', 'assign', $params);
- $this->add_to_log('set marking allocation', $message);
+ $addtolog = $this->add_to_log('set marking allocation', $message, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $this->get_instance()->id,
+ 'relateduserid' => $userid,
+ 'other' => array(
+ 'markerid' => $marker->id
+ )
+ );
+ $event = \mod_assign\event\marker_updated::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
}
}
$logmessage = get_string('unlocksubmissionforstudent',
'assign',
array('id'=>$user->id, 'fullname'=>fullname($user)));
- $this->add_to_log('unlock submission', $logmessage);
+ $addtolog = $this->add_to_log('unlock submission', $logmessage, '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $flags->assignment,
+ 'relateduserid' => $user->id
+ );
+ $event = \mod_assign\event\submission_unlocked::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
/**
}
$this->update_grade($grade);
$this->notify_grade_modified($grade);
- $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
- $this->add_to_log('grade submission', $this->format_grade_for_log($grade));
+ $addtolog = $this->add_to_log('grade submission', $this->format_grade_for_log($grade), '', true);
+ $params = array(
+ 'context' => $this->context,
+ 'objectid' => $grade->id,
+ 'relateduserid' => $userid
+ );
+ $event = \mod_assign\event\submission_graded::create($params);
+ $event->set_legacy_logdata($addtolog);
+ $event->trigger();
}
return parent::apply_grade_to_user($formdata, $userid, $attemptnumber);
}
+ public function testable_format_submission_for_log(stdClass $submission) {
+ return parent::format_submission_for_log($submission);
+ }
+
public function testable_get_grading_userid_list() {
return parent::get_grading_userid_list();
}
return parent::process_add_attempt($userid);
}
+ public function testable_process_lock($userid = 0) {
+ return parent::process_lock($userid);
+ }
+
+ public function testable_process_save_quick_grades($postdata) {
+ // Ugly hack to get something into the method.
+ global $_POST;
+ $_POST = $postdata;
+ return parent::process_save_quick_grades();
+ }
+
+ public function testable_process_unlock($userid = 0) {
+ return parent::process_unlock($userid);
+ }
+
+ public function testable_process_copy_previous_attempt(&$notices) {
+ return parent::process_copy_previous_attempt($notices);
+ }
+
+ public function testable_process_revert_to_draft($userid = 0) {
+ return parent::process_revert_to_draft($userid);
+ }
+
+ public function testable_process_set_batch_marking_allocation($selectedusers, $markerid) {
+ // Ugly hack to get something into the method.
+ global $_POST;
+ $_POST['selectedusers'] = $selectedusers;
+ $_POST['allocatedmarker'] = $markerid;
+ return parent::process_set_batch_marking_allocation();
+ }
+
+ public function testable_process_set_batch_marking_workflow_state($selectedusers, $state) {
+ // Ugly hack to get something into the method.
+ global $_POST;
+ $_POST['selectedusers'] = $selectedusers;
+ $_POST['markingworkflowstate'] = $state;
+ return parent::process_set_batch_marking_workflow_state();
+ }
+
public function testable_submissions_open($userid = 0) {
return parent::submissions_open($userid);
}
$output = $assign->get_renderer()->render($gradingtable);
$this->assertNotEquals(true, strpos($output, $this->students[0]->lastname));
}
+
+ public function test_extension_granted_event() {
+ $this->setUser($this->editingteachers[0]);
+
+ $tomorrow = time() + 24*60*60;
+ $yesterday = time() - 24*60*60;
+
+ $assign = $this->create_instance(array('duedate' => $yesterday, 'cutoffdate' => $yesterday));
+ $sink = $this->redirectEvents();
+
+ $assign->testable_save_user_extension($this->students[0]->id, $tomorrow);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\extension_granted', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($assign->get_instance()->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'grant extension',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ $this->students[0]->id,
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+ }
+
+ public function test_submission_locked_event() {
+ $this->editingteachers[0]->ignoresesskey = true;
+ $this->setUser($this->editingteachers[0]);
+
+ $assign = $this->create_instance();
+ $sink = $this->redirectEvents();
+
+ $assign->testable_process_lock($this->students[0]->id);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\submission_locked', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($assign->get_instance()->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'lock submission',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ get_string('locksubmissionforstudent', 'assign', array('id' => $this->students[0]->id,
+ 'fullname' => fullname($this->students[0]))),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Revert to defaults.
+ $this->editingteachers[0]->ignoresesskey = false;
+ }
+
+ public function test_identities_revealed_event() {
+ $this->editingteachers[0]->ignoresesskey = true;
+ $this->setUser($this->editingteachers[0]);
+
+ $assign = $this->create_instance(array('blindmarking'=>1));
+ $sink = $this->redirectEvents();
+
+ $assign->testable_process_reveal_identities();
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\identities_revealed', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($assign->get_instance()->id, $event->objectid);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'reveal identities',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ get_string('revealidentities', 'assign'),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Revert to defaults.
+ $this->editingteachers[0]->ignoresesskey = false;
+ }
+
+ public function test_submission_status_updated_event() {
+ $this->editingteachers[0]->ignoresesskey = true;
+ $this->setUser($this->editingteachers[0]);
+
+ $assign = $this->create_instance();
+ $submission = $assign->get_user_submission($this->students[0]->id, true);
+ $submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
+ $assign->testable_update_submission($submission, $this->students[0]->id, true, false);
+
+ $sink = $this->redirectEvents();
+ $assign->testable_process_revert_to_draft($this->students[0]->id);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\submission_status_updated', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($submission->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $this->assertEquals(ASSIGN_SUBMISSION_STATUS_DRAFT, $event->other['newstatus']);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'revert submission to draft',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ get_string('reverttodraftforstudent', 'assign', array('id' => $this->students[0]->id,
+ 'fullname' => fullname($this->students[0]))),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Revert to defaults.
+ $this->editingteachers[0]->ignoresesskey = false;
+ }
+
+ public function test_marker_updated_event() {
+ $this->editingteachers[0]->ignoresesskey = true;
+ $this->setUser($this->editingteachers[0]);
+
+ $assign = $this->create_instance();
+
+ $sink = $this->redirectEvents();
+ $assign->testable_process_set_batch_marking_allocation($this->students[0]->id, $this->teachers[0]->id);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\marker_updated', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($assign->get_instance()->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $this->assertEquals($this->editingteachers[0]->id, $event->userid);
+ $this->assertEquals($this->teachers[0]->id, $event->other['markerid']);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'set marking allocation',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ get_string('setmarkerallocationforlog', 'assign', array('id' => $this->students[0]->id,
+ 'fullname' => fullname($this->students[0]), 'marker' => fullname($this->teachers[0]))),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Revert to defaults.
+ $this->editingteachers[0]->ignoresesskey = false;
+ }
+
+ public function test_workflow_state_updated_event() {
+ $this->editingteachers[0]->ignoresesskey = true;
+ $this->setUser($this->editingteachers[0]);
+
+ $assign = $this->create_instance();
+
+ $sink = $this->redirectEvents();
+ $assign->testable_process_set_batch_marking_workflow_state($this->students[0]->id, ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\workflow_state_updated', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($assign->get_instance()->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $this->assertEquals($this->editingteachers[0]->id, $event->userid);
+ $this->assertEquals(ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW, $event->other['newstate']);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'set marking workflow state',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ get_string('setmarkingworkflowstateforlog', 'assign', array('id' => $this->students[0]->id,
+ 'fullname' => fullname($this->students[0]), 'state' => ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW)),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Revert to defaults.
+ $this->editingteachers[0]->ignoresesskey = false;
+ }
+
+ public function test_submission_duplicated_event() {
+ $this->setUser($this->students[0]);
+
+ $assign = $this->create_instance();
+ $submission1 = $assign->get_user_submission($this->students[0]->id, true, 0);
+ $submission2 = $assign->get_user_submission($this->students[0]->id, true, 1);
+ $submission2->status = ASSIGN_SUBMISSION_STATUS_REOPENED;
+ $assign->testable_update_submission($submission2, $this->students[0]->id, time(), $assign->get_instance()->teamsubmission);
+
+ $sink = $this->redirectEvents();
+ $notices = null;
+ $assign->testable_process_copy_previous_attempt($notices);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\submission_duplicated', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($submission2->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->userid);
+ $submission2->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'submissioncopied',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ $assign->testable_format_submission_for_log($submission2),
+ $assign->get_course_module()->id,
+ $this->students[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+ }
+
+ public function test_submission_unlocked_event() {
+ $this->editingteachers[0]->ignoresesskey = true;
+ $this->setUser($this->editingteachers[0]);
+
+ $assign = $this->create_instance();
+ $sink = $this->redirectEvents();
+
+ $assign->testable_process_unlock($this->students[0]->id);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\submission_unlocked', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($assign->get_instance()->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'unlock submission',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ get_string('unlocksubmissionforstudent', 'assign', array('id' => $this->students[0]->id,
+ 'fullname' => fullname($this->students[0]))),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Revert to defaults.
+ $this->editingteachers[0]->ignoresesskey = false;
+ }
+
+ public function test_submission_graded_event() {
+ $this->setUser($this->editingteachers[0]);
+ $assign = $this->create_instance();
+
+ // Test apply_grade_to_user.
+ $sink = $this->redirectEvents();
+
+ $data = new stdClass();
+ $data->grade = '50.0';
+ $assign->testable_apply_grade_to_user($data, $this->students[0]->id, 0);
+ $grade = $assign->get_user_grade($this->students[0]->id, false, 0);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\submission_graded', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($grade->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'grade submission',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ $assign->format_grade_for_log($grade),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+
+ // Test process_save_quick_grades.
+ $sink = $this->redirectEvents();
+
+ $data = array(
+ 'grademodified_' . $this->students[0]->id => time(),
+ 'quickgrade_' . $this->students[0]->id => '60.0'
+ );
+ $assign->testable_process_save_quick_grades($data);
+ $grade = $assign->get_user_grade($this->students[0]->id, false);
+ $this->assertEquals('60.0', $grade->grade);
+
+ $events = $sink->get_events();
+ $this->assertCount(1, $events);
+ $event = reset($events);
+ $this->assertInstanceOf('\mod_assign\event\submission_graded', $event);
+ $this->assertEquals($assign->get_context(), $event->get_context());
+ $this->assertEquals($grade->id, $event->objectid);
+ $this->assertEquals($this->students[0]->id, $event->relateduserid);
+ $expected = array(
+ $assign->get_course()->id,
+ 'assign',
+ 'grade submission',
+ 'view.php?id=' . $assign->get_course_module()->id,
+ $assign->format_grade_for_log($grade),
+ $assign->get_course_module()->id,
+ $this->editingteachers[0]->id
+ );
+ $this->assertEventLegacyLogData($expected, $event);
+ $sink->close();
+ }
+
}