$this->assignment->get_context());
$this->hasgrade = $this->assignment->can_grade();
+ // Check if we have the elevated view capablities to see the blind details.
+ $this->hasviewblind = has_capability('mod/assign:viewblinddetails',
+ $this->assignment->get_context());
+
foreach ($assignment->get_feedback_plugins() as $plugin) {
if ($plugin->is_visible() && $plugin->is_enabled()) {
foreach ($plugin->get_grading_batch_operations() as $action => $description) {
}
// User picture.
- if (!$this->assignment->is_blind_marking()) {
+ if ($this->hasviewblind || !$this->assignment->is_blind_marking()) {
if (!$this->is_downloading()) {
$columns[] = 'picture';
$headers[] = get_string('pictureofuser');
$headers[] = get_string('recordid', 'assign');
}
+ if ($this->hasviewblind) {
+ $columns[] = 'recordid';
+ $headers[] = get_string('recordid', 'assign');
+ }
+
// Submission status.
if ($assignment->is_any_submission_plugin_enabled()) {
$columns[] = 'status';
*/
public function fullname($user) {
if ($this->is_blind_marking()) {
- $uniqueid = $this->get_uniqueid_for_user($user->id);
- return get_string('participant', 'assign') . ' ' . $uniqueid;
+ $hasviewblind = has_capability('mod/assign:viewblinddetails', $this->get_context());
+ if ($hasviewblind) {\r
+ return fullname($user);\r
+ } else {
+ $uniqueid = $this->get_uniqueid_for_user($user->id);
+ return get_string('participant', 'assign') . ' ' . $uniqueid;
+ }
} else {
return fullname($user);
}
$this->assertTrue($assign->can_edit_submission($this->students[0]->id, $this->extrastudents[0]->id));
}
+
+ /**
+ * Test if the view blind details capability works
+ */
+ public function test_can_view_blind_details() {
+ global $PAGE, $DB;
+ $teacherrole = $DB->get_record('role', array('shortname' => 'teacher'));
+ $managerrole = $DB->get_record('role', array('shortname' => 'manager'));
+
+ $student = $this->students[0];// Get a student user.
+ // Create a teacher. Shouldn't be able to view blind marking ID.
+ $teacher = $this->getDataGenerator()->create_user();
+
+ $this->getDataGenerator()->enrol_user($teacher->id,
+ $this->course->id,
+ $teacherrole->id);
+
+ // Create a manager.. Should be able to view blind marking ID.
+ $manager = $this->getDataGenerator()->create_user();
+ $this->getDataGenerator()->enrol_user($manager->id,\r
+ $this->course->id,\r
+ $managerrole->id);
+
+ // Generate blind marking assignment.
+ $assign = $this->create_instance(array('blindmarking' => 1));\r
+ $this->assertEquals(true, $assign->is_blind_marking());
+
+ // Test student names are hidden to teacher.
+ $this->setUser($teacher);\r
+ $gradingtable = new assign_grading_table($assign, 1, '', 0, true);\r
+ $output = $assign->get_renderer()->render($gradingtable);\r
+ $this->assertEquals(true, strpos($output, get_string('hiddenuser', 'assign'))); // "Participant" is somewhere on the page.
+ $this->assertEquals(false, strpos($output, fullname($student))); // Students full name doesn't appear.
+
+ // Test student names are visible to manager.
+ $this->setUser($manager);\r
+ $gradingtable = new assign_grading_table($assign, 1, '', 0, true);\r
+ $output = $assign->get_renderer()->render($gradingtable);\r
+ $this->assertEquals(true, strpos($output, get_string('hiddenuser', 'assign')));
+ $this->assertEquals(true, strpos($output, fullname($student))); //students full name doesn't appear.
+ }
}