Commit ad10ad14 authored by Frederic Massart's avatar Frederic Massart
Browse files

MDL-40055 mod_assign: Replace add_to_log 'reveal identities'

parent 3d1331be
<?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 \lang_string
*/
public static function get_name() {
return new \lang_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'] = 50; // TODO MDL-37658.
$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;
}
}
...@@ -143,6 +143,7 @@ $string['editaction'] = 'Actions...'; ...@@ -143,6 +143,7 @@ $string['editaction'] = 'Actions...';
$string['event_assessable_submitted'] = 'A submission has been submitted.'; $string['event_assessable_submitted'] = 'A submission has been submitted.';
$string['event_all_submissions_downloaded'] = 'All the submissions are being downloaded.'; $string['event_all_submissions_downloaded'] = 'All the submissions are being downloaded.';
$string['event_extension_granted'] = 'An extension has been granted.'; $string['event_extension_granted'] = 'An extension has been granted.';
$string['event_identities_revealed'] = 'The identities have been revealed.';
$string['event_submission_locked'] = 'The submissions have been locked for a user.'; $string['event_submission_locked'] = 'The submissions have been locked for a user.';
$string['extensionduedate'] = 'Extension due date'; $string['extensionduedate'] = 'Extension due date';
$string['extensionnotafterduedate'] = 'Extension date must be after the due date'; $string['extensionnotafterduedate'] = 'Extension date must be after the due date';
......
...@@ -4842,7 +4842,14 @@ class assign { ...@@ -4842,7 +4842,14 @@ class assign {
$this->gradebook_item_update(null, $grade); $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();
} }
......
...@@ -1005,5 +1005,36 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase { ...@@ -1005,5 +1005,36 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$this->editingteachers[0]->ignoresesskey = false; $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;
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment