Merge branch 'MDL-45151-35' of git://github.com/damyon/moodle into MOODLE_35_STABLE
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -254,6 +254,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();
|
||||
|
||||
@@ -232,6 +232,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();
|
||||
|
||||
|
||||
@@ -1323,4 +1323,42 @@ class assign_events_testcase extends advanced_testcase {
|
||||
$this->assertEquals(context_module::instance($cm->id), $event->get_context());
|
||||
$this->assertEventContextNotUsed($event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user