mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Merge branch 'MDL-45151-master' of git://github.com/damyon/moodle
This commit is contained in:
commit
4f3f8fba67
5 changed files with 57 additions and 4 deletions
|
@ -60,6 +60,9 @@ abstract class base extends \core\event\base {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -8987,10 +8987,15 @@ class assign {
|
|||
|
||||
// Trigger the course module viewed event.
|
||||
$assigninstance = $this->get_instance();
|
||||
$event = \mod_assign\event\course_module_viewed::create(array(
|
||||
$params = [
|
||||
'objectid' => $assigninstance->id,
|
||||
'context' => $this->get_context()
|
||||
));
|
||||
];
|
||||
if ($this->is_blind_marking()) {
|
||||
$params['anonymous'] = 1;
|
||||
}
|
||||
|
||||
$event = \mod_assign\event\course_module_viewed::create($params);
|
||||
|
||||
$event->add_record_snapshot('assign', $assigninstance);
|
||||
$event->trigger();
|
||||
|
|
|
@ -252,6 +252,9 @@ class assign_submission_file extends assign_submission_plugin {
|
|||
if (!empty($submission->userid) && ($submission->userid != $USER->id)) {
|
||||
$params['relateduserid'] = $submission->userid;
|
||||
}
|
||||
if ($this->assignment->is_blind_marking()) {
|
||||
$params['anonymous'] = 1;
|
||||
}
|
||||
$event = \assignsubmission_file\event\assessable_uploaded::create($params);
|
||||
$event->set_legacy_files($files);
|
||||
$event->trigger();
|
||||
|
|
|
@ -251,6 +251,9 @@ class assign_submission_onlinetext extends assign_submission_plugin {
|
|||
if (!empty($submission->userid) && ($submission->userid != $USER->id)) {
|
||||
$params['relateduserid'] = $submission->userid;
|
||||
}
|
||||
if ($this->assignment->is_blind_marking()) {
|
||||
$params['anonymous'] = 1;
|
||||
}
|
||||
$event = \assignsubmission_onlinetext\event\assessable_uploaded::create($params);
|
||||
$event->trigger();
|
||||
|
||||
|
|
|
@ -1353,4 +1353,43 @@ class assign_events_testcase extends advanced_testcase {
|
|||
$this->assertInstanceOf('\mod_assign\event\course_module_viewed', $event);
|
||||
$this->assertEquals($context, $event->get_context());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that all events generated with blindmarking enabled are anonymous
|
||||
*/
|
||||
public function test_anonymous_events() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
||||
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
||||
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
||||
$instance = $generator->create_instance(array('course' => $course->id, 'blindmarking' => 1));
|
||||
|
||||
$cm = get_coursemodule_from_instance('assign', $instance->id, $course->id);
|
||||
$context = context_module::instance($cm->id);
|
||||
$assign = new assign($context, $cm, $course);
|
||||
|
||||
$this->setUser($teacher);
|
||||
$sink = $this->redirectEvents();
|
||||
|
||||
$assign->lock_submission($student1->id);
|
||||
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
$this->assertTrue((bool)$event->anonymous);
|
||||
|
||||
$assign->reveal_identities();
|
||||
$sink = $this->redirectEvents();
|
||||
$assign->lock_submission($student2->id);
|
||||
|
||||
$events = $sink->get_events();
|
||||
$event = reset($events);
|
||||
|
||||
$this->assertFalse((bool)$event->anonymous);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue