MDL-42670 mod_assign: Fix recent activity block when blind marking is on

This commit is contained in:
Tim Lock 2015-07-23 13:31:26 +09:30 committed by Eloy Lafuente (stronk7)
parent f06d8d94a1
commit d89dc6daa5
2 changed files with 31 additions and 0 deletions

View File

@ -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,

View File

@ -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();