/** * Tests that the function returns true when the number of previous students is higher than the minumimum defined, * i.e., the input is ABOVE the lower limit of the input domain. In this case, since the input domain only has a limit, * the lower one, the input is also INSIDE. */ public function test_meets_minimum_previous_students_above() { $this->resetAfterTest(); $this->setAdminUser(); // The course will meet the minimum previous students, so, we expect a true from the function. $expected = true; // We stablish a value that is inside the input domain. $numberofstudents = course_filter::MINIMUM_PREVIOUS_STUDENTS + 1; // We have to creates some courses before creating students, with the attributes defined in setUp. $numberofcoursestocreate = course_filter::MINIMUM_PREVIOUS_COURSES; $previouscourses = $this->create_courses($this->previouscourseattributes, $numberofcoursestocreate); $previouscoursesids = $this->insert_previous_courses_in_historic_data($previouscourses); // We create and enrol the students in one course... $users = $this->create_and_enrol_students($previouscourses[0]->id, $numberofstudents); $this->insert_previous_users_in_historic_data($users, $previouscoursesids[0]); // We get the actual value and we do the assertion. $currentcourseid = $this->currentcourse[0]->id; $actual = course_filter::meets_minimum_previous_students($currentcourseid, $this->currentyear, $this->db); $this->assertEquals($expected, $actual); }
/** * Initializes the course, when is the first instance of the block, looking if it is personalizable or not, and * saving this in database. * * Currently, the students are being selected independently the course is personalizable or not, because maybe later * a csv importation is made, and like this there's no need to select students later. * * @param int $courseid The course where the first instance of this block has been loaded in. * @param int $courseyear The start year of the course. */ private function initialize_course($courseid, $courseyear) { $this->recommendator->select_students($courseid, $courseyear); $personalizable = course_filter::is_course_personalizable($courseid, $courseyear); if ($personalizable) { $this->db->insert_course_selection($courseid, $courseyear, 1); } else { $this->db->insert_course_selection($courseid, $courseyear, 0); } }