Skip to content
Permalink
Browse files
Merge branch 'MDL-45151-36' of git://github.com/damyon/moodle into MO…
…ODLE_36_STABLE
  • Loading branch information
David Monllaó committed Feb 19, 2019
2 parents b071746 + 3926512 commit 7bab771a8b77cd9e5870b8e1ada490339542be05
@@ -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;
}

@@ -8771,10 +8771,15 @@ public function set_module_viewed() {

// Trigger the course module viewed event.
$assigninstance = $this->get_instance();
$event = \mod_assign\event\course_module_viewed::create(array(
'objectid' => $assigninstance->id,
'context' => $this->get_context()
));
$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 @@ 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();

@@ -1353,4 +1353,43 @@ public function test_course_module_viewed() {
$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);
}

}

0 comments on commit 7bab771

Please sign in to comment.