/** * Return true if a category already exists with the same name * @param string $in_name * * @return bool */ public static function category_exists_with_title($in_name) { $tab_test_category = TestCategory::getCategoryListInfo("title"); foreach ($tab_test_category as $title) { if ($title == $in_name) { return true; } } return false; }
/** * Build the test category * @param int $session_id Internal session ID * @param int $courseId Internal course ID * @param bool $with_base_content Whether to include content from the course without session or not * @param array $id_list If you want to restrict the structure to only the given IDs * @todo add course session */ public function build_test_category($session_id = 0, $courseId = 0, $with_base_content = false, $id_list = array()) { // get all test category in course $tab_test_categories_id = TestCategory::getCategoryListInfo("id", $courseId); foreach ($tab_test_categories_id as $test_category_id) { $test_category = new TestCategory($test_category_id); $copy_course_test_category = new CourseCopyTestcategory($test_category_id, $test_category->name, $test_category->description); $this->course->add_resource($copy_course_test_category); } }