/** * Test feedback with assignment restricted to future date. * * @throws \coding_exception */ public function test_feedback_restricted() { global $DB; $this->resetAfterTest(); $generator = $this->getDataGenerator(); $course = $generator->create_course(); $student = $generator->create_user(); // Enrol student. $studentrole = $DB->get_record('role', array('shortname' => 'student')); $generator->enrol_user($student->id, $course->id, $studentrole->id); // Create assign instance. $this->create_assignment($course->id, time() + DAYSECS * 2); $actual = local::upcoming_deadlines($student->id); $expected = 1; $this->assertCount($expected, $actual); // Create restricted assign instance. $opts = ['availability' => $this->get_date_condition_json(time() + WEEKSECS)]; $assign = $this->create_assignment($course->id, time() + DAYSECS * 2, $opts); // Mark restricted assign instasnce. $data = $assign->get_user_grade($student->id, true); $data->grade = '50.5'; $assign->update_grade($data); // Student should only see 1 feedback item as one is normal and one is restricted until next week. $this->setUser($student); $actual = activity::events_graded(); $expected = 1; $this->assertCount($expected, $actual); }
public function test_no_upcoming_deadlines() { global $USER; $actual = local::upcoming_deadlines($USER->id); $expected = array(); $this->assertSame($actual, $expected); $actual = local::deadlines(); $expected = '<p>You have no upcoming deadlines.</p>'; $this->assertSame($actual, $expected); }
public function test_assign_upcoming_deadlines() { $this->setUser($this->editingteachers[0]); $this->create_instance(['duedate' => time()]); $deadlines = local::upcoming_deadlines($this->editingteachers[0]->id); $this->assertCount(1, $deadlines); $this->setUser($this->students[0]); $deadlines = local::upcoming_deadlines($this->students[0]->id); $this->assertCount(1, $deadlines); $this->setUser($this->teachers[0]); $deadlines = local::upcoming_deadlines($this->teachers[0]->id); $this->assertCount(1, $deadlines); $this->setUser($this->editingteachers[0]); $this->create_instance(['duedate' => time() + 3 * DAYSECS]); $deadlines = local::upcoming_deadlines($this->editingteachers[0]->id); $this->assertCount(2, $deadlines); $this->setUser($this->students[0]); $deadlines = local::upcoming_deadlines($this->students[0]->id); $this->assertCount(2, $deadlines); $this->setUser($this->teachers[0]); $deadlines = local::upcoming_deadlines($this->teachers[0]->id); $this->assertCount(2, $deadlines); /* TODO create non visible deadline. $this->setUser($this->editingteachers[0]); $this->create_instance(['duedate' => time() + 3 * DAYSECSe]); $deadlines = local::upcoming_deadlines($this->editingteachers[0]->id); $this->assertCount(3, $deadlines); $this->setUser($this->students[0]); $deadlines = local::upcoming_deadlines($this->students[0]->id); $this->assertCount(2, $deadlines); $this->setUser($this->teachers[0]); $deadlines = local::upcoming_deadlines($this->teachers[0]->id); $this->assertCount(3, $deadlines); */ $this->create_instance(['duedate' => time() + 4 * DAYSECS]); $this->create_instance(['duedate' => time() + 4 * DAYSECS]); $max = 2; $this->setUser($this->students[0]); $deadlines = local::upcoming_deadlines($this->students[0]->id, $max); $this->assertCount(2, $deadlines); }