From d89dc6daa55078d82682b91ad1c7a3035766183f Mon Sep 17 00:00:00 2001 From: Tim Lock Date: Thu, 23 Jul 2015 13:31:26 +0930 Subject: [PATCH] MDL-42670 mod_assign: Fix recent activity block when blind marking is on --- mod/assign/lib.php | 7 +++++++ mod/assign/tests/lib_test.php | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 6cfa6dde4e3..61d1e9859a4 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -680,7 +680,14 @@ function assign_print_recent_activity($course, $viewfullnames, $timestart) { foreach ($show as $submission) { $cm = $modinfo->get_cm($submission->cmid); + $context = context_module::instance($submission->cmid); + $assign = new assign($context, $cm, $cm->course); $link = $CFG->wwwroot.'/mod/assign/view.php?id='.$cm->id; + // Obscure first and last name if blind marking enabled. + if ($assign->is_blind_marking()) { + $submission->firstname = get_string('participant', 'mod_assign'); + $submission->lastname = $assign->get_uniqueid_for_user($submission->userid); + } print_recent_activity_note($submission->timemodified, $submission, $cm->name, diff --git a/mod/assign/tests/lib_test.php b/mod/assign/tests/lib_test.php index da657d320ab..73336ae9057 100644 --- a/mod/assign/tests/lib_test.php +++ b/mod/assign/tests/lib_test.php @@ -225,6 +225,30 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase { $sink->close(); } + /** Make sure blind marking shows participant \d+ not fullname when assign_print_recent_activity is triggered. */ + public function test_print_recent_activity_fullname_blind_marking() { + // Submitting an assignment generates a notification in blind marking. + $this->preventResetByRollback(); + $sink = $this->redirectMessages(); + + $this->setUser($this->editingteachers[0]); + $assign = $this->create_instance(array('blindmarking' => 1)); + + $data = new stdClass(); + $data->userid = $this->students[0]->id; + $notices = array(); + $this->setUser($this->students[0]); + $assign->submit_for_grading($data, $notices); + + $this->setUser($this->editingteachers[0]); + $uniqueid = $assign->get_uniqueid_for_user($data->userid); + $expectedstr = preg_quote(get_string('participant', 'mod_assign'), '/') . '.*' . $uniqueid; + $this->expectOutputRegex("/{$expectedstr}/"); + assign_print_recent_activity($this->course, false, time() - 3600); + + $sink->close(); + } + public function test_assign_get_recent_mod_activity() { // Submitting an assignment generates a notification. $this->preventResetByRollback();