Skip to content
Permalink
Browse files
Merge branch 'MDL-45151-35' of git://github.com/damyon/moodle into MO…
…ODLE_35_STABLE
  • Loading branch information
David Monllaó committed Feb 19, 2019
2 parents d6f6c78 + db3008e commit c96968b7e92b7fa79678b1c6ebc3fc05898e4e44
Showing with 47 additions and 0 deletions.
  1. +3 −0 mod/assign/classes/event/base.php
  2. +3 −0 mod/assign/submission/file/locallib.php
  3. +3 −0 mod/assign/submission/onlinetext/locallib.php
  4. +38 −0 mod/assign/tests/events_test.php
@@ -60,6 +60,9 @@ public function set_assign(\assign $assign) {
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 @@ public function save(stdClass $submission, stdClass $data) {
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 @@ public function save(stdClass $submission, stdClass $data) {
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 @@ public function test_group_override_deleted() {
$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);
}
}

0 comments on commit c96968b

Please sign in to comment.