* 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'));
+ global $DB;
+ // Note: The shared setUp leads to terrible tests. Please don't use it.
+ $roles = $DB->get_records('role', null, '', 'shortname, id');
+ $course = $this->getDataGenerator()->create_course([]);
$student = $this->students[0];// Get a student user.
+ $this->getDataGenerator()->enrol_user($student->id,
+ $course->id,
+ $roles['student']->id);
+
// 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);
+ $course->id,
+ $roles['teacher']->id);
// Create a manager.. Should be able to view blind marking ID.
$manager = $this->getDataGenerator()->create_user();
$this->getDataGenerator()->enrol_user($manager->id,
- $this->course->id,
- $managerrole->id);
+ $course->id,
+ $roles['manager']->id);
// Generate blind marking assignment.
- $assign = $this->create_instance(array('blindmarking' => 1));
+ $assign = $this->create_instance(array('course' => $course->id, 'blindmarking' => 1));
$this->assertEquals(true, $assign->is_blind_marking());
// Test student names are hidden to teacher.