MDL-38147 Improvements to caching of course categories, coursecat::get_children() improvements

- Course categories caches are purged by event now
- We store only children of one category in one cache key
- Function coursecat::get_children() can return results sorted and/or paginated. Added tests
MDL-38147 Added function coursecat::search_courses(), get_courses()

Also search_courses_count(), get_courses_count()
- MDL-38147 attempt to preload course contacts